aboutsummaryrefslogtreecommitdiffstats
path: root/core/busybox-initscripts/ide_links
blob: be0c95aa9c0e55c2390ae0d98a4a431265155d27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

[ -f /proc/ide/$MDEV/media ] || exit

media=`cat /proc/ide/$MDEV/media`
for i in $media $media[0-9]* ; do
	if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then
		LINK=$i
		break
	fi
done

# link exist, remove if necessary and exit
if [ "$LINK" ] ; then
	[ "$ACTION" = remove ] && rm $LINK
	exit
fi

# create a link
num=`ls $media[0-9]* 2>/dev/null | wc -l`
ln -sf $MDEV "$media`echo $num`"
[ -e "$media" ] || ln -sf $MDEV "$media"