tinyramfs/device-helper

41 lines
898 B
Plaintext
Raw Normal View History

2020-04-12 01:01:02 +05:30
#!/bin/sh -f
#
# create /dev/disk/by-* and /dev/mapper/* symlinks
create_symlink()
{
sym="$1"
sym="${sym%\"}"
sym="${sym#\"}"
sym="${dir}${sym}"
mkdir -p "$dir" 2> /dev/null
ln -s "/dev/${MDEV}" "$sym" 2> /dev/null
}
# int main()
{
[ "$MDEV" ] || exit 1
for line in $(blkid "$MDEV"); do case "${line%%=*}" in
UUID)
dir="/dev/disk/by-uuid/"
create_symlink "${line##*=}"
;;
LABEL)
dir="/dev/disk/by-label/"
create_symlink "${line##*=}"
;;
PARTUUID)
dir="/dev/disk/by-partuuid/"
create_symlink "${line##*=}"
;;
esac; done
2020-04-12 01:01:02 +05:30
[ -e "/sys/block/${MDEV}/dm/name" ] && {
2020-04-12 01:01:02 +05:30
mkdir -p /dev/mapper 2> /dev/null
read -r name < "/sys/block/${MDEV}/dm/name"
ln -s "/dev/${MDEV}" "/dev/mapper/${name}" 2> /dev/null
}
}