Merge "Enable BR2_TARGET_ROOTFS_SQUASHFS4_XZ for SpaceCast"
diff --git a/configs/gflt110_defconfig b/configs/gflt110_defconfig
index d08ccc5..44abb8e 100644
--- a/configs/gflt110_defconfig
+++ b/configs/gflt110_defconfig
@@ -20,7 +20,7 @@
 BR2_ROOTFS_SKELETON_CUSTOM=y
 BR2_ROOTFS_POST_BUILD_SCRIPT="${TOPDIR}/support/scripts/postbuild.sh"
 BR2_TARGET_GENERIC_PLATFORM_NAME="gflt110"
-BR2_TARGET_GENERIC_PLATFORMS_SUPPORTED="GFLT110, GFLT120"
+BR2_TARGET_GENERIC_PLATFORMS_SUPPORTED="GFLT110, GFLT120, GFLT300"
 # BR2_PACKAGE_BUSYBOX is not set
 BR2_PACKAGE_TOOLBOX=y
 BR2_PACKAGE_TOYBOX=y
diff --git a/fs/skeleton/bin/watchdog b/fs/skeleton/bin/watchdog
index f703ca9..fce2c6d 100755
--- a/fs/skeleton/bin/watchdog
+++ b/fs/skeleton/bin/watchdog
@@ -60,7 +60,14 @@
   exit 1
 fi
 
-echo -1000 >/proc/$$/oom_score_adj
+if [ -e /proc/$$/oom_score_adj ]; then
+  echo -1000 >/proc/$$/oom_score_adj
+elif [ -e /proc/$$/oom_adj ]; then
+  # Older kernels (e.g. fiberjack) need this to adjust the oom score.
+  echo -1000 >/proc/$$/oom_adj
+else
+  echo "WARNING: Failed to adjust OOM score for pid: $$!"
+fi
 
 write()
 {
@@ -91,6 +98,9 @@
 
 devwatchdog_setup()
 {
+  if [ ! -e "$file" ]; then
+    echo "watchdog setup failed: $file does not exist!"
+  fi
   exec 9>$file
 }
 
diff --git a/fs/skeleton/etc/init.d/S08volcheck.platform_gfiberlt b/fs/skeleton/etc/init.d/S08volcheck.platform_gfiberlt
new file mode 100755
index 0000000..a49b8df
--- /dev/null
+++ b/fs/skeleton/etc/init.d/S08volcheck.platform_gfiberlt
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+CONFIG_MTD_NO=
+
+check_mtd()
+{
+  local a b c d e
+  cat /proc/mtd |
+  while read a b c d; do
+    # convert 'mtdxx:' to 'xx'
+    e=${a%:*}
+    [ $d = $1 ] && echo "${e#mtd}"
+  done
+}
+
+mount_jffs2()
+{
+  local mtd_no=$1
+  local device=/dev/mtdblock$mtd_no
+  local dir="$2"
+
+  mount -t jffs2 -o defaults,noatime $device $dir \
+    || { echo "error mounting jffs2 on '$device' as '$dir'"; return 1; }
+}
+
+recover_jffs2()
+{
+  local mtd_no=$1
+  local device=/dev/mtd$mtd_no
+  local dir="$2"
+
+  echo "formating '$device' for jffs2"
+
+  flash_erase --jffs $device 0 0
+  mount_jffs2 $mtd_no "$dir"
+}
+
+case "$1" in
+  start)
+    # Get MTD partition number
+    part_name='"config"'
+    if [ $(cat /etc/platform) = "GFLT110" ]; then
+      part_name='"user_data"'
+    fi
+
+    CONFIG_MTD_NO=$(check_mtd $part_name)
+
+    mount_jffs2 $CONFIG_MTD_NO /config \
+      || recover_jffs2 $CONFIG_MTD_NO /config
+
+    # /config must be writeable by non-root
+    chown bin.sys /config
+    chmod 775 /config
+
+    if [ -e /config/DEBUG ]; then
+      echo "Enabling DEBUG mode because /config/DEBUG is set." >&2
+      echo >/tmp/DEBUG
+    fi
+    ;;
+  stop)
+    umount /config
+    ;;
+  restart|reload)
+    ;;
+  *)
+    echo "Usage: $0 {start|stop|restart}" >&2
+    exit 1
+esac
diff --git a/fs/skeleton/etc/init.d/S40network b/fs/skeleton/etc/init.d/S40network
index f50a7e6..7033e38 100755
--- a/fs/skeleton/etc/init.d/S40network
+++ b/fs/skeleton/etc/init.d/S40network
@@ -347,7 +347,7 @@
 case "$1" in
   start)
     if is-fiberjack; then
-      local lan_port=$(cat /etc/config/lanport)
+      lan_port=$(cat /etc/config/lanport)
       echo "Starting LAN."
       ifup lo
       if [ -n "$lan_port" ]; then
@@ -500,7 +500,7 @@
   stop)
     if [ ! -e /tmp/NFS ]; then
       if is-fiberjack; then
-        local lan_port=$(cat /etc/config/lanport)
+        lan_port=$(cat /etc/config/lanport)
         echo "Stopping LAN."
         ifdown lo
         if [ -n "$lan_port" ]; then