summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/udev/udev-extraconf/mount.sh34
1 files changed, 27 insertions, 7 deletions
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index c4695ee27d..537828e3e3 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -45,6 +45,13 @@ automount_systemd() {
45 return 45 return
46 fi 46 fi
47 47
48 # Only go for auto-mounting when the device has been cleaned up in remove
49 # or has not been identified yet
50 if [ -e "/tmp/.automount-$name" ]; then
51 logger "mount.sh/automount" "[$MOUNT_BASE/$name] is already cached"
52 return
53 fi
54
48 # Skip the partition which are already in /etc/fstab 55 # Skip the partition which are already in /etc/fstab
49 grep "^[[:space:]]*$DEVNAME" /etc/fstab && return 56 grep "^[[:space:]]*$DEVNAME" /etc/fstab && return
50 for n in LABEL PARTLABEL UUID PARTUUID; do 57 for n in LABEL PARTLABEL UUID PARTUUID; do
@@ -100,6 +107,13 @@ automount() {
100 # Get the unique name for mount point 107 # Get the unique name for mount point
101 get_label_name "${DEVNAME}" 108 get_label_name "${DEVNAME}"
102 109
110 # Only go for auto-mounting when the device has been cleaned up in remove
111 # or has not been identified yet
112 if [ -e "/tmp/.automount-$name" ]; then
113 logger "mount.sh/automount" "[$MOUNT_BASE/$name] is already cached"
114 return
115 fi
116
103 ! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name" 117 ! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name"
104 # Silent util-linux's version of mounting auto 118 # Silent util-linux's version of mounting auto
105 if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ; 119 if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
@@ -172,12 +186,18 @@ if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_t
172fi 186fi
173 187
174if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then 188if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
175 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
176 do
177 $UMOUNT $mnt
178 done
179
180 # Remove empty directories from auto-mounter
181 name="`basename "$DEVNAME"`" 189 name="`basename "$DEVNAME"`"
182 test -e "/tmp/.automount-$name" && rm_dir "$MOUNT_BASE/$name" 190 tmpfile=`find /tmp | grep "\.automount-.*${name}$"`
191 if [ ! -e "/sys/$DEVPATH" -a -e "$tmpfile" ]; then
192 logger "mount.sh/remove" "cleaning up $DEVNAME, was mounted by the auto-mounter"
193 for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
194 do
195 $UMOUNT $mnt
196 done
197 # Remove mount directory created by the auto-mounter
198 # and clean up our tmp cache file
199 mntdir=`cat "$tmpfile"`
200 rm_dir "$MOUNT_BASE/$mntdir"
201 rm "$tmpfile"
202 fi
183fi 203fi