2 # Copyright (C) 2009-2010 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 .
/lib
/functions
/block.sh
10 blkdev
=`dirname $DEVPATH`
12 if [ `basename $blkdev` != "block" ]; then
14 device
=`basename $DEVPATH`
19 local autoswap_from_fstab
20 local automount_from_fstab
25 local mds_mount_device
27 local sds_swap_enabled
31 mount_dev_section_cb
() {
35 swap_dev_section_cb
() {
42 automount_from_fstab
="$from_fstab"
44 [ "$automount_from_fstab" -eq 1 ] && {
45 config_get_mount_section_by_device
"/dev/$device"
48 # skip trying swap if this device is defined as a mount point
49 [ -z "$mds_mount_device" ] && {
51 autoswap_from_fstab
="$from_fstab"
53 [ "$autoswap_from_fstab" -eq 1 ] && {
54 config_get_swap_section_by_device
"/dev/$device"
55 use_device
="$sds_swap_device"
56 do_swap
="$sds_swap_enabled"
59 [ -z "$use_device" ] && [ "$anon_swap" -eq 1 ] && {
60 use_device
="/dev/$device" && do_swap
=1
64 [ -n "$use_device" ] && [ "$do_swap" -eq 1 ] && {
65 grep -q "$use_device" /proc
/swaps ||
grep -q "$use_device" /proc
/mounts ||
{
72 grep -q "/dev/$device" /proc
/swaps
&& {
73 swapoff
"/dev/$device"