mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-12-19 16:38:01 +00:00
Closes: https://bugs.gentoo.org/839171 Signed-off-by: Viorel Munteanu <ceamac.paragon@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/25062 Signed-off-by: Sam James <sam@gentoo.org>
38 lines
1 KiB
Bash
38 lines
1 KiB
Bash
#!/bin/sh
|
|
|
|
# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars.
|
|
|
|
current=$(readlink usbdisk)
|
|
|
|
if [ "${current}" = "${MDEV}" ] && [ "${ACTION}" = "remove" ]; then
|
|
rm -f usbdisk usba1
|
|
fi
|
|
[ -n "${current}" ] && exit
|
|
|
|
if [ -e /sys/block/"${MDEV}" ]; then
|
|
SYSDEV=$(readlink -f /sys/block/"${MDEV}"/device)
|
|
# if /sys device path contains '/usb[0-9]' then we assume its usb
|
|
# also, if it's a usb without partitions we require FAT
|
|
if [ "${SYSDEV##*/usb[0-9]}" != "${SYSDEV}" ]; then
|
|
# do not create link if there is not FAT
|
|
dd if=/dev/"${MDEV}" bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0
|
|
|
|
ln -sf "${MDEV}" usbdisk
|
|
# keep this for compat. people have it in fstab
|
|
ln -sf "${MDEV}" usba1
|
|
fi
|
|
|
|
else
|
|
for i in /sys/block/*/"${MDEV}"; do
|
|
if [ -e "$i" ]; then
|
|
PARENT=$(dirname "$i")
|
|
SYSDEV=$(readlink -f "${PARENT}"/device)
|
|
if [ "${SYSDEV##*/usb[0-9]}" != "${SYSDEV}" ]; then
|
|
ln -sf "${MDEV}" usbdisk
|
|
# keep this for compat. people have it in fstab
|
|
ln -sf "${MDEV}" usba1
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|