]> code.ossystems Code Review - openembedded-core.git/commitdiff
udev-extraconf: Unmount SD card after ejection
authorYasir-Khan <yasir_khan@mentor.com>
Thu, 14 Aug 2014 14:56:37 +0000 (19:56 +0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 15 Aug 2014 17:19:52 +0000 (18:19 +0100)
Adds udev rule to unmount SD card partitions in case of improper
ejection from card reader.

When SD card is ejected from card reader without being unmounted
first, kernel does not generate a REMOVE event, instead it
generates a CHANGE event(only if polling is enabled
/sys/module/block/parameters/events_dfl_poll_msecs) and we don't
have any udev rule in automount.rules to handle this event,so
partitions never get unmounted. Unmounting of partitions can be
done if udev rules handle this CHANGE event.

Signed-off-by: Abbas Raza <Abbas_Raza@mentor.com>
Signed-off-by: Yasir-Khan <yasir_khan@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/udev/udev-extraconf/automount.rules
meta/recipes-core/udev/udev-extraconf/mount.sh

index 7e844c31bd22933e122f3078c2d638890d8f27b2..62578ea631fb07e95c5ab393c78efc6f9ebb7753 100644 (file)
@@ -16,4 +16,4 @@
 # Media automounting
 SUBSYSTEM=="block", ACTION=="add"    RUN+="/etc/udev/scripts/mount.sh"
 SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh"
-
+SUBSYSTEM=="block", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1" RUN+="/etc/udev/scripts/mount.sh"
index 7df1b6e3e7882de6ba5045a3c1e49f6ba16e7037..3eea910854f350176f9f661b0a7eb226e372e560 100644 (file)
@@ -78,8 +78,7 @@ if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_t
 fi
 
 
-
-if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
+if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
        for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
        do
                $UMOUNT $mnt