-
Notifications
You must be signed in to change notification settings - Fork 4
/
aoe-mkshelf.in
executable file
·50 lines (44 loc) · 1.13 KB
/
aoe-mkshelf.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh
# aoe-mkshelf - device nodes for one shelf without udev
# Copyright 2009, CORAID, Inc., and licensed under GPL v.2.
zero=`basename $0`
if test "$#" != "2"; then
echo "Usage: $zero {dir} {shelfaddress}" 1>&2
echo " n_partitions=16 $zero {dir} {shelfaddress}" 1>&2
exit 1
fi
dyn=/sys/module/aoe/parameters/aoe_dyndevs
if test -r "$dyn" && test "`cat $dyn`" = 1; then
cat 1>&2 <<EOF
$zero Error: aoe module is using dynamic devices.
$zero: Please see the aoe-mkshelf manpage.
$zero: Exiting.
EOF
exit 1
fi
if test "`ps axwwww | grep 'udev[d]'`" || test -d "/dev/.udev"; then
cat 1>&2 <<EOF
$zero Error: udev detected. You shouldn't need to use $zero.
$zero: Please see the aoe-mkshelf manpage.
$zero: Exiting.
EOF
exit 1
fi
n_partitions=${n_partitions:-16}
dir=$1
shelf=$2
nslots=@npershelf@
maxslot=$(($nslots - 1))
MAJOR=152
set -e
minor=$(($nslots * $shelf * $n_partitions))
endp=$(($n_partitions - 1))
for slot in `seq 0 $maxslot`; do
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