mirror of
https://git.yoctoproject.org/poky
synced 2026-09-17 12:49:36 +02:00
Depending on kernel version used, the system can hung when trying to mount the extended partition (not the logical one) as it is a holder for other partitions and does not have a filesystem in it. To avoid this to happen we just mount partitions when these are using known filesystems so it does not try to mount a partition for an unsupported filesystem. Reported-by: Vladan Jovanovic <vladan.jovanovic@gmail.com> Reported-by: Leonardo Sandoval Gonzalez <b42214@freescale.com> (From OE-Core master rev: 895c9685a7f95dc84786213f945895a504a16254) (From OE-Core rev: cdb8ccc8f9b4959e84d1ee071de29e8a54974c11) Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Tested-by: Vladan Jovanovic <vladan.jovanovic@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
77 lines
1.9 KiB
Bash
77 lines
1.9 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Called from udev
|
|
#
|
|
# Attempt to mount any added block devices and umount any removed devices
|
|
|
|
|
|
MOUNT="/bin/mount"
|
|
PMOUNT="/usr/bin/pmount"
|
|
UMOUNT="/bin/umount"
|
|
for line in `grep -v ^# /etc/udev/mount.blacklist`
|
|
do
|
|
if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ];
|
|
then
|
|
logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
automount() {
|
|
name="`basename "$DEVNAME"`"
|
|
|
|
! test -d "/media/$name" && mkdir -p "/media/$name"
|
|
# Silent util-linux's version of mounting auto
|
|
if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
|
|
then
|
|
MOUNT="$MOUNT -o silent"
|
|
fi
|
|
|
|
if ! $MOUNT -t auto $DEVNAME "/media/$name"
|
|
then
|
|
#logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!"
|
|
rm_dir "/media/$name"
|
|
else
|
|
logger "mount.sh/automount" "Auto-mount of [/media/$name] successful"
|
|
touch "/tmp/.automount-$name"
|
|
fi
|
|
}
|
|
|
|
rm_dir() {
|
|
# We do not want to rm -r populated directories
|
|
if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
|
|
then
|
|
! test -z "$1" && rm -r "$1"
|
|
else
|
|
logger "mount.sh/automount" "Not removing non-empty directory [$1]"
|
|
fi
|
|
}
|
|
|
|
if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" ]; then
|
|
if [ -x "$PMOUNT" ]; then
|
|
$PMOUNT $DEVNAME 2> /dev/null
|
|
elif [ -x $MOUNT ]; then
|
|
$MOUNT $DEVNAME 2> /dev/null
|
|
fi
|
|
|
|
# If the device isn't mounted at this point, it isn't
|
|
# configured in fstab (note the root filesystem can show up as
|
|
# /dev/root in /proc/mounts, so check the device number too)
|
|
if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
|
|
grep -q "^$DEVNAME " /proc/mounts || automount
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
|
|
for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
|
|
do
|
|
$UMOUNT $mnt
|
|
done
|
|
|
|
# Remove empty directories from auto-mounter
|
|
name="`basename "$DEVNAME"`"
|
|
test -e "/tmp/.automount-$name" && rm_dir "/media/$name"
|
|
fi
|