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`
11 if [ `basename $blkdev` != "block" ]; then
13 device=`basename $DEVPATH`
22 local mds_mount_target
23 local mds_mount_device
24 local mds_mount_fstype
30 local autoswap_from_fstab
31 local automount_from_fstab
33 mount_dev_section_cb() {
37 mds_mount_enabled="$6"
40 swap_dev_section_cb() {
46 automount_from_fstab="$from_fstab"
47 [ "$automount_from_fstab" -eq 1 ] && {
48 config_get_mount_section_by_device "/dev/$device"
49 use_device="$mds_mount_device"
50 [ "$mds_mount_enabled" -eq 1 ] && {
51 if [ -n "$mds_mount_target" ]; then
52 grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
53 ( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
56 logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
61 [ -z "$use_device" ] && {
63 autoswap_from_fstab="$from_fstab"
65 [ "$autoswap_from_fstab" -eq 1 ] && {
66 config_get_swap_section_by_device "/dev/$device"
67 use_device="$sds_swap_device"
71 grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
72 [ "$anon_mount" -eq 1 ] && [ -z "$use_device" ] && {
73 ( mkdir -p /mnt/$device && mount /dev/$device /mnt/$device ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'