Debian Codegraph @

extfs/uadf

raw
1 #! /bin/sh
2
3 # Description:
4 # This is a parser for Amiga ADF disk images in Midnight Commander. You
5 # need the GPL unADF program (part of ADFlib >= 0.7.9b) written by Laurent
6 # Clevy and Dan Sutherland.
7
8 # Author: Guus Jansman
9
10 # Limitations:
11 # Some files seem to have a description. These are not handled (yet).
12 # Files can only be added as root (under Linux only so disabled now).
13 # File attributes are not preserved.
14
15 # Alternative programs (not supported by this script):
16 # AdfOpus (win32, Dan Sutherland and Gary Harris)
17 # readdisk (part of UAE)
18
19 # Settings:
20 UNADF="unadf"
21
22 mcadffs_list ()
23 {
24 $UNADF -lr "$1" 2>/dev/null | gawk -v uid=$(id -ru) '
25 BEGIN { date="JanFebMarAprMayJunJulAugSepOctNovDec" }
26 /^$/ { next }
27 /^unADF/ { next }
28 /^compsum/ { next }
29 /^Device/ { next }
30 /^Volume/ { next }
31 /^Warning/ { next }
32 {
33 slashpos=index($0, "/")
34 str=substr($0, slashpos+18)
35 if (substr(str, length(str)) == "/")
36 {
37 perm="drwxr-xr-x"
38 str=substr(str, 1, length(str)-1)
39 sz=0
40 }
41 else
42 {
43 perm="-rw-r--r--"
44 sz=substr($0, 1, slashpos-5)
45 }
46 tm=substr($0, slashpos+8, 5)
47 dt=substr($0, slashpos-4, 10)
48 split(dt, a, "/")
49 printf "%s 1 %-8d %-8d %8d %3s %2d %4d %s %s\n", perm, uid, 0, sz, substr(date, (a[2]-1)*3+1, 3), a[3], a[1], tm, str
50 }'
51 }
52
53 mcadffs_copyout ()
54 {
55 $UNADF -p "$1" "$2" > "$3" 2>/dev/null
56 }
57
58 mcadffs_test ()
59 {
60 if $UNADF -l "$1" >/dev/null 2>&1; then
61 echo "OK"
62 else
63 echo "UNKNOWN"
64 fi
65 }
66
67 umask 077
68
69 cmd=$1
70 shift
71 case "$cmd" in
72 list) mcadffs_list "$@" ;;
73 copyout) mcadffs_copyout "$@" ;;
74 # copyin) mcadffs_copyin "$@" ;; # Can only be performed as root
75 # rm) mcadffs_rm "$@" ;; # Can only be performed as root
76 # test) mcadffs_test "$@" ;; # Not supported by MC extfs
77 *) exit 1 ;;
78 esac
79 exit 0