2003-04-29 20:03:11 +04:00
|
|
|
#! /bin/sh
|
|
|
|
|
2003-04-29 22:21:40 +04:00
|
|
|
# ISO9660 VFS for MC by Michael Shigorin <mike@altlinux.org>,
|
|
|
|
# modifications by Grigory Milev <week@altlinux.org>
|
|
|
|
# and Kachalov Anton <mouse@linux.ru.net> April 2003
|
2003-04-29 20:03:11 +04:00
|
|
|
# based on lslR by Tomas Novak <tnovak@ipex.cz> April 2000
|
|
|
|
# -- look there for additional parsing comments if needed
|
|
|
|
|
|
|
|
# tested to comply with isoinfo 2.0's output
|
|
|
|
|
|
|
|
test_iso () {
|
2006-07-19 15:19:52 +04:00
|
|
|
CHARSET=`locale charmap 2>/dev/null`
|
|
|
|
if test -z "$CHARSET"; then
|
|
|
|
CHARSET=`locale 2>/dev/null | grep LC_CTYPE | sed -n -e 's/.*\.\(.*\)"$/\1/p'`
|
|
|
|
fi
|
2003-04-29 22:21:40 +04:00
|
|
|
if test -n "$CHARSET"; then
|
2006-07-19 15:19:52 +04:00
|
|
|
CHARSET=`echo "$CHARSET" | tr '[A-Z]' '[a-z]' | sed -e 's/^iso-/iso/'`
|
|
|
|
isoinfo -j $CHARSET -i /dev/null 2>&1 | grep "Unknown charset" >/dev/null && CHARSET=
|
2003-04-29 22:21:40 +04:00
|
|
|
fi
|
|
|
|
if test -n "$CHARSET"; then
|
|
|
|
JOLIET_OPT="-j $CHARSET -J"
|
|
|
|
else
|
|
|
|
JOLIET_OPT="-J"
|
|
|
|
fi
|
|
|
|
ISOINFO="isoinfo -R"
|
|
|
|
isoinfo -d -i "$1" | grep "NO Joliet" > /dev/null || ISOINFO="$ISOINFO $JOLIET_OPT"
|
2003-04-29 20:03:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mcisofs_list () {
|
2003-04-29 22:21:40 +04:00
|
|
|
# left as a reminder to implement compressed image support =)
|
2003-04-29 20:03:11 +04:00
|
|
|
case "$1" in
|
2009-01-24 08:11:35 +03:00
|
|
|
*.lzma) MYCAT="lzma -dc";;
|
2003-04-29 20:03:11 +04:00
|
|
|
*.bz2) MYCAT="bzip2 -dc";;
|
|
|
|
*.gz) MYCAT="gzip -dc";;
|
|
|
|
*.z) MYCAT="gzip -dc";;
|
|
|
|
*.Z) MYCAT="gzip -dc";;
|
|
|
|
*) MYCAT="cat";;
|
|
|
|
esac
|
|
|
|
|
2004-10-29 13:14:38 +04:00
|
|
|
$ISOINFO -l -i "$1" | @AWK@ '
|
2003-04-29 20:03:11 +04:00
|
|
|
BEGIN {
|
|
|
|
dir="";
|
|
|
|
# Pattern to match 8 first fields.
|
|
|
|
rx = "[^ ]+[ ]+";
|
|
|
|
rx = "^" rx rx rx rx rx rx rx rx;
|
2004-10-29 13:14:38 +04:00
|
|
|
irx = "^\\[ *[0-9]* *[0-9]+\\] ";
|
2003-04-29 20:03:11 +04:00
|
|
|
}
|
|
|
|
/^$/ { next }
|
|
|
|
/^d---------/ { next }
|
|
|
|
/^Directory listing of [^ ].*$/ {
|
|
|
|
dir=substr($0, 23);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
{ $11 != "" } {
|
|
|
|
name=$0
|
|
|
|
sub(rx, "", name)
|
|
|
|
attr=substr($0, 1, length($0)-length(name))
|
|
|
|
# strip inodes and extra dir entries; fix perms
|
|
|
|
sub(irx, "", name)
|
|
|
|
sub("^---------- 0 0 0", "-r--r--r-- 1 root root", attr)
|
|
|
|
sub(" $", "", name)
|
2003-04-29 22:21:40 +04:00
|
|
|
## sub(";[0-9]+$", "", name) ## would break copyout
|
2003-04-29 20:03:11 +04:00
|
|
|
# skip . and ..
|
|
|
|
if (name ~ /^\.\.?/) next;
|
|
|
|
printf "%s%s%s\n", attr, dir, name
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
mcisofs_copyout () {
|
|
|
|
$ISOINFO -i "$1" -x "/$2" > "$3"
|
|
|
|
}
|
|
|
|
|
2003-04-29 22:21:40 +04:00
|
|
|
LC_ALL=C
|
2003-04-29 20:03:11 +04:00
|
|
|
|
|
|
|
cmd="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
case "$cmd" in
|
|
|
|
list)
|
|
|
|
test_iso "$@";
|
|
|
|
mcisofs_list "$@";
|
|
|
|
exit 0;;
|
|
|
|
copyout)
|
|
|
|
test_iso "$@";
|
|
|
|
mcisofs_copyout "$@";
|
|
|
|
exit 0;;
|
|
|
|
esac
|
|
|
|
exit 1
|