mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. #!/bin/bash
  2. # udev external PROGRAM script
  3. # return devfs-names for ide-devices
  4. # BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}", GROUP="%c{3}"
  5. HOST="${2%\.[0-9]}"
  6. TARGET="${2#[0-9]\.}"
  7. if [ -z "${HOST#[13579]}" ]; then
  8. HOST=$((${HOST} - 1))
  9. BUS="1"
  10. else
  11. BUS="0"
  12. fi
  13. get_dev_number() {
  14. num=0
  15. DRIVE="${1%%[0-9]*}"
  16. for x in /proc/ide/*/media; do
  17. if [ -e "${x}" ]; then
  18. read lMEDIA < ${x}
  19. if [ "${lMEDIA}" = "$2" ]; then
  20. num=$((${num} + 1))
  21. fi
  22. if [ "${x}" = "/proc/ide/${DRIVE}/media" ]; then
  23. break
  24. fi
  25. fi
  26. done
  27. echo $((${num} - 1))
  28. }
  29. if [ -z "$3" ] && [ -f /proc/ide/${1}/media ]; then
  30. read MEDIA < /proc/ide/${1}/media
  31. if [ "${MEDIA}" = "cdrom" ]; then
  32. echo ide/host${HOST}/bus${BUS}/target${TARGET}/lun0/cd cdroms/cdrom`get_dev_number $1 cdrom` ${MEDIA}
  33. elif [ "${MEDIA}" = "floppy" ]; then
  34. echo ide/host${HOST}/bus${BUS}/target${TARGET}/lun0/disc floppies/floppy`get_dev_number $1 floppy`/disc ${MEDIA}
  35. elif [ "${MEDIA}" = "disk" ]; then
  36. echo ide/host${HOST}/bus${BUS}/target${TARGET}/lun0/disc discs/disc`get_dev_number $1 disk`/disc ${MEDIA}
  37. fi
  38. else
  39. echo ide/host${HOST}/bus${BUS}/target${TARGET}/lun0/part$3 discs/disc`get_dev_number $1 disk`/part$3
  40. fi