iso9660.in 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #! /bin/sh
  2. # ISO9660 VFS for MC by Michael Shigorin <mike@altlinux.org>,
  3. # modifications by Grigory Milev <week@altlinux.org>
  4. # and Kachalov Anton <mouse@linux.ru.net> April 2003
  5. # based on lslR by Tomas Novak <tnovak@ipex.cz> April 2000
  6. # -- look there for additional parsing comments if needed
  7. # tested to comply with isoinfo 2.0's output
  8. test_iso () {
  9. CHARSET=`echo "$save_ctype" | sed -n -e 's/.*\.\(.*\)"$/\1/p' | tr '[A-Z]' '[a-z]'`
  10. if test -n "$CHARSET"; then
  11. isoinfo -j $CHARSET 2>&1 | grep "Unknown charset" >/dev/null && CHARSET=
  12. fi
  13. if test -n "$CHARSET"; then
  14. JOLIET_OPT="-j $CHARSET -J"
  15. else
  16. JOLIET_OPT="-J"
  17. fi
  18. ISOINFO="isoinfo -R"
  19. isoinfo -d -i "$1" | grep "NO Joliet" > /dev/null || ISOINFO="$ISOINFO $JOLIET_OPT"
  20. }
  21. mcisofs_list () {
  22. # left as a reminder to implement compressed image support =)
  23. case "$1" in
  24. *.bz2) MYCAT="bzip2 -dc";;
  25. *.gz) MYCAT="gzip -dc";;
  26. *.z) MYCAT="gzip -dc";;
  27. *.Z) MYCAT="gzip -dc";;
  28. *) MYCAT="cat";;
  29. esac
  30. $ISOINFO -l -i "$1" | @AWK@ '
  31. BEGIN {
  32. dir="";
  33. # Pattern to match 8 first fields.
  34. rx = "[^ ]+[ ]+";
  35. rx = "^" rx rx rx rx rx rx rx rx;
  36. irx = "^\\[ *[0-9]* *[0-9]+\\] ";
  37. }
  38. /^$/ { next }
  39. /^d---------/ { next }
  40. /^Directory listing of [^ ].*$/ {
  41. dir=substr($0, 23);
  42. next;
  43. }
  44. { $11 != "" } {
  45. name=$0
  46. sub(rx, "", name)
  47. attr=substr($0, 1, length($0)-length(name))
  48. # strip inodes and extra dir entries; fix perms
  49. sub(irx, "", name)
  50. sub("^---------- 0 0 0", "-r--r--r-- 1 root root", attr)
  51. sub(" $", "", name)
  52. ## sub(";[0-9]+$", "", name) ## would break copyout
  53. # skip . and ..
  54. if (name ~ /^\.\.?/) next;
  55. printf "%s%s%s\n", attr, dir, name
  56. }'
  57. }
  58. mcisofs_copyout () {
  59. $ISOINFO -i "$1" -x "/$2" > "$3"
  60. }
  61. save_ctype=`locale 2>/dev/null | grep LC_CTYPE`
  62. LC_ALL=C
  63. cmd="$1"
  64. shift
  65. case "$cmd" in
  66. list)
  67. test_iso "$@";
  68. mcisofs_list "$@";
  69. exit 0;;
  70. copyout)
  71. test_iso "$@";
  72. mcisofs_copyout "$@";
  73. exit 0;;
  74. esac
  75. exit 1