home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / sbin / devmap_mknod.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2010-05-05  |  991b  |  42 lines

  1. #! /bin/sh
  2.  
  3. # Startup script to create the device-mapper control device 
  4. # on non-devfs systems.
  5. # Non-zero exit status indicates failure.
  6.  
  7. # These must correspond to the definitions in device-mapper.h and dm.h
  8. DM_DIR="mapper"
  9. DM_NAME="device-mapper"
  10.  
  11. set -e
  12.  
  13. DIR="/dev/$DM_DIR"
  14. CONTROL="$DIR/control"
  15.  
  16. # Check for devfs, procfs
  17. if test -e /dev/.devfsd ; then
  18.     echo "devfs detected: devmap_mknod.sh script not required."
  19.     exit
  20. fi
  21.  
  22. if test ! -e /proc/devices ; then
  23.     echo "procfs not found: please create $CONTROL manually."
  24.     exit 1
  25. fi
  26.  
  27. # Get major, minor, and mknod
  28. MAJOR=$(sed -n 's/^ *\([0-9]\+\) \+misc$/\1/p' /proc/devices)
  29. MINOR=$(sed -n "s/^ *\([0-9]\+\) \+$DM_NAME\$/\1/p" /proc/misc)
  30.  
  31. if test -z "$MAJOR" -o -z "$MINOR" ; then
  32.     echo "$DM_NAME kernel module not loaded: can't create $CONTROL."
  33.     exit 1
  34. fi
  35.  
  36. mkdir -p --mode=755 $DIR
  37. test -e $CONTROL && rm -f $CONTROL
  38.  
  39. echo "Creating $CONTROL character device with major:$MAJOR minor:$MINOR."
  40. mknod --mode=600 $CONTROL c $MAJOR $MINOR
  41.  
  42.