|
|
1.1 ! root 1: #!/bin/sh ! 2: ! 3: # This is an example shell script that can be used as a wrapper for a ! 4: # msdos.fsck (called by the generic fsck frontend). ! 5: # ! 6: # The script accepts a standard fsck command line and decides upon the ! 7: # the raw filesystem data whether it is a CVF or not. If it is a CVF then ! 8: # dmsdosfsck is invoked. ! 9: # ! 10: # The case when it is not a CVF but an uncompressed msdos partition is a bit ! 11: # more complex. First, dosfsck is invoked to check that dos partition. Then ! 12: # the script tries to mount that partition and scans its root directory for ! 13: # CVFs. If there are CVFs it tries to check them, too, by calling dmsdosfsck ! 14: # on them. After that, the msdos partition is unmounted again in order to ! 15: # restore the previous state. If the -r option is present in the fsck ! 16: # command line, some questions are asked. ! 17: # ! 18: # Note that this script needs a helper program that finds out whether a ! 19: # file is a CVF or not. If you have added the file(1) magics for CVFs to ! 20: # /etc/magic (see the dmsdos installation instructions) you can use a ! 21: # combination of file and grep (for example) for that purpose. I think this ! 22: # is a standard way. If you still prefer the older method (by calling the ! 23: # helper program cvftest) just compile cvftest ('make cvftest') and change ! 24: # some lines below (I've commented out the two cvftest calls and placed a ! 25: # file command in the next line). ! 26: ! 27: ########################################################################### ! 28: ! 29: # where to find the different filesystem checker utilities ! 30: DMSDOSFSCK="dmsdosfsck" ! 31: DOSFSCK="dosfsck" ! 32: ! 33: ARGS="$@" ! 34: FILE="" ! 35: ASK=n ! 36: ! 37: while [ "$1" != "" ]; ! 38: do ! 39: case "$1" in ! 40: -u) shift ! 41: shift ;; ! 42: -d) shift ! 43: shift ;; ! 44: -r) ASK=y ! 45: shift ;; ! 46: -*) shift ;; ! 47: *) FILE="$1" ! 48: shift ;; ! 49: esac; ! 50: done ! 51: ! 52: #echo "ARGS=$ARGS" ! 53: #echo "FILE=$FILE" ! 54: ! 55: #if cvftest $FILE ; ! 56: if [ ! -z "`file $FILE | grep CVF`" ]; ! 57: then ! 58: echo "CVF detected, calling dmsdosfsck..." ! 59: $DMSDOSFSCK $ARGS ! 60: CODE="$?" ! 61: else ! 62: echo "no CVF found, calling dosfsck..." ! 63: $DOSFSCK $ARGS ! 64: CODE="$?" ! 65: if [ "$CODE" != "0" ]; ! 66: then ! 67: exit $CODE ! 68: fi ! 69: if [ $ASK = y ]; ! 70: then ! 71: echo -n "search $FILE for CVFs in it and check them, too?" ! 72: read ANS JUNK ! 73: if [ "$ANS" != "y" -a "$ANS" != "Y" ]; ! 74: then ! 75: exit 0 ! 76: fi ! 77: fi ! 78: mkdir /tmp/fsckwrap.$$ ! 79: if [ "$?" != "0" ]; ! 80: then ! 81: echo "need write access to /tmp for automatic CVF check (skipped)" ! 82: exit 0 ! 83: fi ! 84: chmod 700 /tmp/fsckwrap.$$ ! 85: mount -t msdos $FILE /tmp/fsckwrap.$$ ! 86: if [ "$?" != "0" ]; ! 87: then ! 88: echo "cannot search $FILE for CVFs in it (skipped)" ! 89: exit 0 ! 90: fi ! 91: ! 92: CODE="0" ! 93: FIRST=y ! 94: for I in /tmp/fsckwrap.$$/dblspace.0?? /tmp/fsckwrap.$$/drvspace.0?? /tmp/fsckwrap.$$/stacvol.* ! 95: do ! 96: if [ -f $I ]; ! 97: then ! 98: #if cvftest $I ; ! 99: if [ ! -z "`file $I | grep CVF`" ]; ! 100: then ! 101: if [ $FIRST = y ]; ! 102: then ! 103: echo "$FILE contains CVFs" ! 104: FIRST=n ! 105: fi ! 106: echo -n "checking CVF " ! 107: basename $I ! 108: $DMSDOSFSCK $ARGS $I ! 109: if [ "$?" != "0" ]; ! 110: then ! 111: CODE="$?" ! 112: fi ! 113: fi ! 114: fi ! 115: done ! 116: umount /tmp/fsckwrap.$$ ! 117: rmdir /tmp/fsckwrap.$$ ! 118: fi ! 119: ! 120: exit $CODE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.