aoe-mkshelf.in 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #! /bin/sh
  2. # aoe-mkshelf - device nodes for one shelf without udev
  3. # Copyright 2007, Coraid, Inc., and licensed under GPL v.2.
  4. zero=`basename $0`
  5. if test "$#" != "2"; then
  6. echo "Usage: $zero {dir} {shelfaddress}" 1>&2
  7. echo " n_partitions=16 $zero {dir} {shelfaddress}" 1>&2
  8. exit 1
  9. fi
  10. dyn=/sys/module/aoe/parameters/aoe_dyndevs
  11. if test -r "$dyn" && test "`cat $dyn`" = 1; then
  12. cat 1>&2 <<EOF
  13. $zero Error: aoe module is using dynamic devices.
  14. $zero: Please see the aoe-mkshelf manpage.
  15. $zero: Exiting.
  16. EOF
  17. exit 1
  18. fi
  19. if test "`ps axwwww | grep 'udev[d]'`" || test -d "/dev/.udev"; then
  20. cat 1>&2 <<EOF
  21. $zero Error: udev detected. You shouldn't need to use $zero.
  22. $zero: Please see the aoe-mkshelf manpage.
  23. $zero: Exiting.
  24. EOF
  25. exit 1
  26. fi
  27. n_partitions=${n_partitions:-16}
  28. dir=$1
  29. shelf=$2
  30. nslots=@npershelf@
  31. maxslot=$(($nslots - 1))
  32. MAJOR=152
  33. set -e
  34. minor=$(($nslots * $shelf * $n_partitions))
  35. endp=$(($n_partitions - 1))
  36. for slot in `seq 0 $maxslot`; do
  37. for part in `seq 0 $endp`; do
  38. name=e$shelf.$slot
  39. test "$part" != "0" && name=${name}p$part
  40. rm -f $dir/$name
  41. mknod -m 0660 $dir/$name b $MAJOR $minor
  42. minor=`expr $minor + 1`
  43. done
  44. done