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