aoe-mkdevs 1.4 KB

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