mkshelf.sh 610 字节
Newer Older
L
Linus Torvalds 已提交
1 2 3 4
#! /bin/sh

if test "$#" != "2"; then
	echo "Usage: sh `basename $0` {dir} {shelfaddress}" 1>&2
5
	echo "       n_partitions=16 sh `basename $0` {dir} {shelfaddress}" 1>&2
L
Linus Torvalds 已提交
6 7 8 9 10
	exit 1
fi
n_partitions=${n_partitions:-16}
dir=$1
shelf=$2
11 12
nslots=16
maxslot=`echo $nslots 1 - p | dc`
L
Linus Torvalds 已提交
13 14 15 16
MAJOR=152

set -e

17
minor=`echo $nslots \* $shelf \* $n_partitions | bc`
L
Linus Torvalds 已提交
18
endp=`echo $n_partitions - 1 | bc`
19
for slot in `seq 0 $maxslot`; do
L
Linus Torvalds 已提交
20 21 22 23 24 25 26 27 28
	for part in `seq 0 $endp`; do
		name=e$shelf.$slot
		test "$part" != "0" && name=${name}p$part
		rm -f $dir/$name
		mknod -m 0660 $dir/$name b $MAJOR $minor

		minor=`expr $minor + 1`
	done
done