summaryrefslogtreecommitdiff
path: root/package/block-mount/files/40-mount
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-02-26 22:45:39 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-02-26 22:45:39 +0000
commitfaf7173b4df3a152dbdc574751078b359c116d5b (patch)
tree446e5e5532100cf4c46d1bddfde0a688dbf1c153 /package/block-mount/files/40-mount
parenta35f8c947088b65dd1524938b59fb9b1e429807c (diff)
add the block-mount package by Daniel Dickinson (cshore), replacing existing automount functionality
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19877 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/block-mount/files/40-mount')
-rw-r--r--package/block-mount/files/40-mount84
1 files changed, 84 insertions, 0 deletions
diff --git a/package/block-mount/files/40-mount b/package/block-mount/files/40-mount
new file mode 100644
index 0000000000..0d4f669404
--- /dev/null
+++ b/package/block-mount/files/40-mount
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 2009-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+. /lib/functions/block.sh
+
+blkdev=`dirname $DEVPATH`
+if [ `basename $blkdev` != "block" ]; then
+
+ device=`basename $DEVPATH`
+
+ case "$ACTION" in
+ add)
+
+ local from_fstab
+ local anon_mount
+ local anon_swap
+ local anon_fsck
+ local mds_mount_target
+ local mds_mount_device
+ local mds_mount_fstype
+ local sds_swap_device
+ local use_device
+ local do_fsck=0
+ local fsck_type
+
+ local autoswap_from_fstab
+ local automount_from_fstab
+
+ mount_dev_section_cb() {
+ mds_mount_target="$2"
+ mds_mount_device="$3"
+ mds_mount_fstype="$4"
+ mds_mount_enabled="$6"
+ }
+
+ swap_dev_section_cb() {
+ sds_swap_device="$2"
+ return 0
+ }
+
+ config_get_automount
+ automount_from_fstab="$from_fstab"
+ [ "$automount_from_fstab" -eq 1 ] && {
+ config_get_mount_section_by_device "/dev/$device"
+ use_device="$mds_mount_device"
+ [ "$mds_mount_enabled" -eq 1 ] && {
+ if [ -n "$mds_mount_target" ]; then
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ ( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ else
+ logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
+ fi
+ }
+ }
+
+ [ -z "$use_device" ] && {
+ config_get_autoswap
+ autoswap_from_fstab="$from_fstab"
+
+ [ "$autoswap_from_fstab" -eq 1 ] && {
+ config_get_swap_section_by_device "/dev/$device"
+ use_device="$sds_swap_device"
+ }
+ }
+
+ grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
+ [ "$anon_mount" -eq 1 ] && [ -z "$use_device" ] && {
+ ( mkdir -p /mnt/$device && mount /dev/$device /mnt/$device ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
+ }
+ }
+ reset_dev_section_cb
+ ;;
+ remove)
+ umount /dev/$device
+ ;;
+ esac
+
+fi
+