base-files: Added support for swap configuration in /etc/config/fstab

SVN-Revision: 8947
This commit is contained in:
Rod Whitby 2007-09-22 13:47:20 +00:00
parent 9de337e21d
commit ac8f66b987
3 changed files with 27 additions and 1 deletions

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=base-files PKG_NAME:=base-files
PKG_RELEASE:=11 PKG_RELEASE:=12
PKG_FILE_DEPEND:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/ PKG_FILE_DEPEND:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/

View file

@ -4,3 +4,7 @@ config mount
option fstype ext3 option fstype ext3
option options rw,sync option options rw,sync
option enabled 0 option enabled 0
config swap
option device /dev/sda2
option enabled 0

View file

@ -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() { do_unmount() {
local cfg="$1" local cfg="$1"
config_get target "$cfg" target 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() { start() {
config_load fstab config_load fstab
config_foreach do_mount mount config_foreach do_mount mount
config_foreach do_swapon swap
} }
stop() { stop() {
config_load fstab config_load fstab
config_foreach do_unmount mount config_foreach do_unmount mount
config_foreach do_swapoff swap
} }