Debian Codegraph @

tests/ts/minix/fsck-images

raw symbols SCIP
1 #!/bin/bash
2 #
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="fsck images"
17
18 . "$TS_TOPDIR"/functions.sh
19 ts_init "$*"
20
21 # inode contains UID and GID, use always UID=0 to get the same checksum
22 # TODO any mkfs should use UID=0 per default (custom uid optionally) like mk2fs
23 ts_skip_nonroot
24
25 ts_check_test_command "$TS_CMD_FSCKMINIX"
26 ts_check_test_command "$TS_HELPER_MKFS_MINIX"
27 ts_check_test_command "$TS_CMD_HEXDUMP"
28
29 # on big endian systems some of the subtests have different expected output
30 BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order)
31 BE_EXT=$(test "$BYTE_ORDER" = "BE" && echo ".BE")
32
33 export MKFS_MINIX_TEST_SECOND_SINCE_EPOCH='1438460212'
34
35 check_minix_fs_type() {
36 ts_init_subtest $1
37 TS_EXPECTED+=$BE_EXT
38 img=${TS_OUTPUT}.img
39 dd if=/dev/zero bs=1024 count=16 of=$img >/dev/null 2>&1
40 $TS_HELPER_MKFS_MINIX $2 $img >> $TS_OUTPUT 2>> $TS_ERRLOG
41 echo "mkfs return value: $?" >> $TS_OUTPUT
42 $TS_CMD_FSCKMINIX $img >> $TS_OUTPUT 2>> $TS_ERRLOG
43 echo "fsck return value: $?" >> $TS_OUTPUT
44 $TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>> $TS_ERRLOG
45 rm -f $img
46 ts_finalize_subtest
47 }
48
49 check_minix_fs_type 'v1c14' '-1 -n 14'
50 check_minix_fs_type 'v1c30' '-1 -n 30'
51 check_minix_fs_type 'v2c14' '-2 -n 14'
52 check_minix_fs_type 'v2c30' '-2 -n 30'
53 check_minix_fs_type 'v3c60' '-3 -n 60'
54
55 bad="$TS_OUTDIR/${TS_TESTNAME}.badlist"
56 # TODO seems that mkfs produces non-sense if badblocks are greater than device.
57 echo -e "8\n9" > $bad
58
59 # NOTE, -c with -l ignores -l.
60 check_minix_fs_type 'check-blocks' "-l $bad -c"
61 check_minix_fs_type 'badblocks' "-l $bad"
62
63 rm -f $bad
64
65 # no more big endian tests below
66 if test "$BYTE_ORDER" = "BE"; then
67 ts_finalize
68 fi
69
70 # NOTE this seems odd: a 2nd fsck run would again modify the FS
71 ts_init_subtest "auto-fix"
72 img=${TS_OUTPUT}.img
73 cp "$TS_SELF/broken-root" $img
74 $TS_CMD_FSCKMINIX -sav $img >> $TS_OUTPUT 2>> $TS_ERRLOG
75 echo "fsck reports changed and uncorrected: $?" >> $TS_OUTPUT
76 $TS_CMD_HEXDUMP -C $img >> $TS_OUTPUT 2>> $TS_ERRLOG
77 sed -i 's/Filesystem on .* is dirty/Filesystem auto-fix is dirty/' $TS_OUTPUT $TS_ERRLOG
78 ts_finalize_subtest
79
80 ts_init_subtest "bug.773892"
81 "$TS_CMD_FSCKMINIX" -f "$TS_SELF/debian.bug.773892" 2>&1 >/dev/null
82 echo "fsck reports uncorrected: $?" >> $TS_OUTPUT
83 ts_finalize_subtest
84
85 ts_init_subtest "broken-root"
86 "$TS_CMD_FSCKMINIX" "$TS_SELF/broken-root" >> $TS_OUTPUT 2>> $TS_ERRLOG
87 echo "fsck reports uncorrected: $?" >> $TS_OUTPUT
88 ts_finalize_subtest
89
90 ts_finalize