#! /bin/sh # # Written by Stas Maximov 1998 SVR4 (UnixWare) # stmax@u213.srcc.msu.su # (C) 1996 The Free Software Foundation. # # uni_cat () # $1 is the archive name { case "$1" in *.cpio.Z) compress -dc "$1" ;; *.cpio.gz) gzip -dc "$1" ;; *) cat "$1" ;; esac } mccpiofs_list () # $1 is the archive name { uni_cat "$1" | cpio -itv | /usr/bin/awk ' { if (substr($9,length($9),1) == ",") { tmp = substr($9, 1, length($9)-1); $9 = $8; $8 = tmp } else if (substr($10,length($10),1) == ",") { tmp = substr($10, 1, length($10)-1); $10 = $9 $9 = tmp } print $0 }' } mccpiofs_copyout () # $1 is the archive name # $2 is a name of a file within the archive # $3 is a name of a file within the system (to add from or extract to) { TMPDIR=/tmp/mctmpdir.$$ # FIXME: TMP RACE: when mkdir fails, we go there, anyway mkdir $TMPDIR uni_cat "$1" | (cd $TMPDIR; cpio -iumd "$2"; mv "$2" "$3") 2>/dev/null rm -rf $TMPDIR } # # main # umask 077 case "$1" in list) mccpiofs_list $2 exit 0 ;; copyout) mccpiofs_copyout $2 $3 $4 exit 0 ;; esac exit 1