tinyramfs/device-helper
2020-04-21 20:20:39 +03:00

41 lines
898 B
Bash
Executable File

#!/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
[ -e "/sys/block/${MDEV}/dm/name" ] && {
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
}
}