aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2007-09-22 13:47:20 +0000
committerRod Whitby <rod@whitby.id.au>2007-09-22 13:47:20 +0000
commitac8f66b98748660970964ee641dfaafd9d1f6087 (patch)
tree6e51ffec0e7e792ce695ae66158ebd27a5d092b9 /package/base-files/files/etc
parent9de337e21df9a4c35ea4b692e0b1cb6f09673161 (diff)
downloadupstream-ac8f66b98748660970964ee641dfaafd9d1f6087.tar.gz
upstream-ac8f66b98748660970964ee641dfaafd9d1f6087.tar.bz2
upstream-ac8f66b98748660970964ee641dfaafd9d1f6087.zip
base-files: Added support for swap configuration in /etc/config/fstab
SVN-Revision: 8947
Diffstat (limited to 'package/base-files/files/etc')
-rw-r--r--package/base-files/files/etc/config/fstab4
-rwxr-xr-xpackage/base-files/files/etc/init.d/fstab22
2 files changed, 26 insertions, 0 deletions
diff --git a/package/base-files/files/etc/config/fstab b/package/base-files/files/etc/config/fstab
index 28bb705a49..eccf0ce69b 100644
--- a/package/base-files/files/etc/config/fstab
+++ b/package/base-files/files/etc/config/fstab
@@ -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
diff --git a/package/base-files/files/etc/init.d/fstab b/package/base-files/files/etc/init.d/fstab
index 2a63a5b1bf..b96e0c8a54 100755
--- a/package/base-files/files/etc/init.d/fstab
+++ b/package/base-files/files/etc/init.d/fstab
@@ -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
}