Debian Codegraph @

extfs/ucpio

raw
1 #! /bin/sh
2 #
3 # Written by Stas Maximov 1998 SVR4 (UnixWare)
4 # [email protected]
5 # (C) 1996 The Free Software Foundation.
6 #
7 #
8
9 uni_cat ()
10 # $1 is the archive name
11 {
12 case "$1" in
13 *.cpio.Z) compress -dc "$1"
14 ;;
15 *.cpio.gz) gzip -dc "$1"
16 ;;
17 *) cat "$1"
18 ;;
19 esac
20 }
21
22 mccpiofs_list ()
23 # $1 is the archive name
24 {
25 uni_cat "$1" | cpio -itv | /usr/bin/awk '
26 {
27 if (substr($9,length($9),1) == ",")
28 {
29 tmp = substr($9, 1, length($9)-1);
30 $9 = $8;
31 $8 = tmp
32 }
33 else if (substr($10,length($10),1) == ",")
34 {
35 tmp = substr($10, 1, length($10)-1);
36 $10 = $9
37 $9 = tmp
38 }
39
40 print $0
41 }'
42 }
43
44 mccpiofs_copyout ()
45 # $1 is the archive name
46 # $2 is a name of a file within the archive
47 # $3 is a name of a file within the system (to add from or extract to)
48 {
49 TMPDIR=/tmp/mctmpdir.$$
50 # FIXME: TMP RACE: when mkdir fails, we go there, anyway
51 mkdir $TMPDIR
52 uni_cat "$1" | (cd $TMPDIR; cpio -iumd "$2"; mv "$2" "$3") 2>/dev/null
53 rm -rf $TMPDIR
54 }
55
56 #
57 # main
58 #
59 umask 077
60
61 case "$1" in
62 list) mccpiofs_list $2
63 exit 0
64 ;;
65 copyout) mccpiofs_copyout $2 $3 $4
66 exit 0
67 ;;
68 esac
69
70 exit 1
71