"Fossies" - the Fresh Open Source Software Archive

Member "aoe-aoe6-86/aoetools-36/aoe-mkdevs" (4 Jul 2015, 1416 Bytes) of archive /linux/misc/aoe-aoe6-86.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # aoe-mkdevs - make static device nodes on systems without udev
    3 # Copyright 2009, CORAID, Inc., and licensed under GPL v.2.
    4 
    5 n_shelves=${n_shelves:-10}
    6 n_partitions=${n_partitions:-16}
    7 
    8 if test "$#" != "1"; then
    9     echo "Usage: `basename $0` {dir}" 1>&2
   10     echo "       n_partitions=16 `basename $0` {dir}" 1>&2
   11     exit 1
   12 fi
   13 dir=$1
   14 zero="`basename $0`"
   15 MAJOR=152
   16 
   17 dyn=/sys/module/aoe/parameters/aoe_dyndevs
   18 if test -r "$dyn" && test "`cat $dyn`" = 1; then
   19     cat 1>&2 <<EOF
   20 $zero Error: aoe module is using dynamic devices.
   21 $zero: Please see the aoe-mkdevs manpage.
   22 $zero: Exiting.
   23 EOF
   24     exit 1
   25 fi
   26 if test "`ps axwwww | grep 'udev[d]'`" || test -d "/dev/.udev"; then
   27     cat 1>&2 <<EOF
   28 $zero Error: udev detected.  You shouldn't need to use $zero.
   29 $zero: Please see the aoe-mkdevs manpage.
   30 $zero: Exiting.
   31 EOF
   32     exit 1
   33 fi
   34 
   35 set -e
   36 
   37 mkdir -p $dir
   38 
   39 # (Status info is in sysfs.  See status.sh.)
   40 # rm -f $dir/stat
   41 # mknod -m 0400 $dir/stat c $MAJOR 1
   42 rm -f $dir/err
   43 mknod -m 0400 $dir/err c $MAJOR 2
   44 rm -f $dir/discover
   45 mknod -m 0200 $dir/discover c $MAJOR 3
   46 rm -f $dir/interfaces
   47 mknod -m 0200 $dir/interfaces c $MAJOR 4
   48 rm -f $dir/revalidate
   49 mknod -m 0200 $dir/revalidate c $MAJOR 5
   50 rm -f $dir/flush
   51 mknod -m 0200 $dir/flush c $MAJOR 6
   52 
   53 # pass along the env var to aoe-mkshelf
   54 export n_partitions
   55 
   56 mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'`
   57 i=0
   58 while test $i -lt $n_shelves; do
   59     sh $mkshelf $dir $i
   60     i=`expr $i + 1`
   61 done