summaryrefslogtreecommitdiffstats
path: root/recipes-core/udev/udev/slugos/mount.sh
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/udev/udev/slugos/mount.sh')
-rw-r--r--recipes-core/udev/udev/slugos/mount.sh83
1 files changed, 0 insertions, 83 deletions
diff --git a/recipes-core/udev/udev/slugos/mount.sh b/recipes-core/udev/udev/slugos/mount.sh
deleted file mode 100644
index b5298e97a..000000000
--- a/recipes-core/udev/udev/slugos/mount.sh
+++ /dev/null
@@ -1,83 +0,0 @@
1#!/bin/sh
2#
3# Called from udev
4# Attemp to mount any added block devices
5# and remove any removed devices
6#
7
8MOUNT="/bin/mount"
9PMOUNT="/usr/bin/pmount"
10UMOUNT="/bin/umount"
11name="`basename "$DEVNAME"`"
12
13if ( blkid "$DEVNAME" | grep -q 'TYPE="mdraid"' )
14then
15 logger "udev/mount.sh" "[$DEVNAME] is a member of an array, ignoring"
16 exit 0
17fi
18
19for line in `cat /etc/udev/mount.blacklist | grep -v ^#`
20do
21 if ( echo "$DEVNAME" | grep -q "$line" )
22 then
23 logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
24 exit 0
25 fi
26done
27
28automount() {
29 ! test -d "/media/$name" && mkdir -p "/media/$name"
30
31 if ! $MOUNT -t auto -o sync $DEVNAME "/media/$name"
32 then
33 #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
34 rm_dir "/media/$name"
35 else
36 logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
37 touch "/tmp/.automount-$name"
38 fi
39}
40
41rm_dir() {
42 # We do not want to rm -r populated directories
43 if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
44 then
45 ! test -z "$1" && rm -r "$1"
46 else
47 logger "mount.sh/automount" "Not removing non-empty directory [$1]"
48 fi
49}
50
51if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then
52 # SlugOS: we pivot to the rootfs based on UUID, not on fstab -- so the fstab may not
53 # be correct at this point in the boot. So we must not let udev mount devices based
54 # soley on the fstab, lest we mount overtop the real rootfs. For now we just comment
55 # out the logic below and let the automount logic (far below) deal with all udev mount
56 # operations.
57 #if [ -x "$PMOUNT" ]; then
58 # $PMOUNT $DEVNAME 2> /dev/null
59 #elif [ -x $MOUNT ]; then
60 # $MOUNT $DEVNAME 2> /dev/null
61 #fi
62
63 # If the device isn't mounted at this point, it isn't configured in fstab
64 # 20061107: Small correction: The rootfs partition may be called just "rootfs" and not by
65 # its true device name so this would break. If the rootfs is mounted on two places
66 # during boot, it confuses the heck out of fsck. So Im auto-adding the root-partition
67 # to /etc/udev/mount.blacklist via postinst
68
69 cat /proc/mounts | awk '{print $1}' | grep -q "^$DEVNAME$" || automount
70
71fi
72
73
74
75if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
76 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
77 do
78 $UMOUNT -l $mnt
79 done
80
81 # Remove empty directories from auto-mounter
82 test -e "/tmp/.automount-$name" && rm_dir "/media/$name"
83fi