base-files: Added support for swap configuration in /etc/config/fstab
authorrwhitby <rwhitby@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 22 Sep 2007 13:47:20 +0000 (13:47 +0000)
committerrwhitby <rwhitby@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 22 Sep 2007 13:47:20 +0000 (13:47 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8947 3c298f89-4303-0410-b956-a3cf2f4a3e73

package/base-files/Makefile
package/base-files/files/etc/config/fstab
package/base-files/files/etc/init.d/fstab

index 0cf96e2c8641da317118aafaa5ea412123176286..d81ec4f1c4ae78b5d9ec0ee603c323f11a470a9f 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=11
+PKG_RELEASE:=12
 
 PKG_FILE_DEPEND:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 
index 28bb705a49a7192b2afdb4c442cdd025c26f2f3c..eccf0ce69b4ee5a0aa30887b843dbc1bc309cf73 100644 (file)
@@ -4,3 +4,7 @@ config mount
        option fstype   ext3
        option options  rw,sync
        option enabled  0
+
+config swap
+       option device   /dev/sda2
+       option enabled  0
index 2a63a5b1bf43b0e540a640d2ef6eabeca21065fd..b96e0c8a54850a9078ab7375d668ea078cd53b7a 100755 (executable)
@@ -20,6 +20,16 @@ do_mount() {
        }
 }
 
+do_swapon() {
+       local cfg="$1"
+       config_get device "$cfg" device
+       [ -n "device" ] || return 0
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ "$enabled" -gt 0 ] && [ -x /usr/sbin/swapon ] && {
+         /usr/sbin/swapon $device
+       }
+}
+
 do_unmount() {
        local cfg="$1"
        config_get target "$cfg" target
@@ -30,13 +40,25 @@ do_unmount() {
        }
 }
        
+do_swapoff() {
+       local cfg="$1"
+       config_get device "$cfg" device
+       [ -n "device" ] || return 0
+       config_get_bool enabled "$cfg" "enabled" '1'
+       [ "$enabled" -gt 0 ] && [ -x /usr/sbin/swapoff ] && {
+         /usr/sbin/swapoff $device
+       }
+}
+
 start() {
        config_load fstab
        config_foreach do_mount mount
+       config_foreach do_swapon swap
 }
 
 stop() {
        config_load fstab
        config_foreach do_unmount mount
+       config_foreach do_swapoff swap
 }