Debian Codegraph @

tests/m_rootdir_acl/script

raw
1 test_description="create fs image from dir using inline_data and acls"
2 if ! test -x $DEBUGFS_EXE; then
3 echo "$test_name: $test_description: skipped (no debugfs)"
4 return 0
5 fi
6
7 if ! setfacl --help > /dev/null 2>&1 ; then
8 echo "$test_name: $test_description: skipped (no setfacl)"
9 return 0
10 fi
11
12 os=$(uname -s)
13 if [ "$os" = "GNU" ]; then
14 # requires Posix ACL support
15 echo "$test_name: $test_description: skipped for $os"
16 return 0
17 fi
18
19 MKFS_DIR=$(mktemp -d ./$test_name-XXXXXX.tmp)
20 OUT=$test_name.log
21 EXP=$test_dir/expect
22 EXP2=$test_dir/expect2 # work around btrfs ordering, https://github.com/tytso/e2fsprogs/issues/158
23
24 touch $MKFS_DIR/emptyfile
25 dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile
26 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null
27 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null
28 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null
29 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null
30 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null
31 dd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null
32 ln $MKFS_DIR/bigzerofile $MKFS_DIR/bigzerofile_hardlink
33 ln -s /silly_bs_link $MKFS_DIR/silly_bs_link
34 mkdir $MKFS_DIR/emptydir
35 mkdir $MKFS_DIR/dir
36 echo "Test me" > $MKFS_DIR/dir/file
37 mkdir $MKFS_DIR/acl_dir
38 echo "Test me 2" > $MKFS_DIR/acl_dir/file
39
40 setfacl --restore=- <<EOF
41 # file: $MKFS_DIR/acl_dir
42 user::rwx
43 group::r-x
44 group:42:r-x
45 mask::r-x
46 other::r-x
47 default:user::rwx
48 default:group::r-x
49 default:group:4:r-x
50 default:mask::r-x
51 default:other::r-x
52 EOF
53 setfacl --restore=- <<EOF
54 # file: $MKFS_DIR/acl_dir/file
55 user::rwx
56 group::r-x
57 group:42:r-x
58 mask::r-x
59 other::r-x
60 EOF
61
62 if ! getfattr -d -m - $MKFS_DIR/acl_dir | grep -q posix_acl; then
63 echo "$test_name: $test_description: skipped (no posix_acl xattrs)"
64 rm -rf $MKFS_DIR
65 return 0
66 fi
67
68 # use 512-byte inodes so with/out security.selinux xattr doesn't fail
69 $MKE2FS -q -F -o Linux -T ext4 -I 512 -O metadata_csum,inline_data,64bit -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 > $OUT 2>&1
70
71 $DUMPE2FS $TMPFILE >> $OUT 2>&1
72 cat > $TMPFILE.cmd << ENDL
73 stat /emptyfile
74 stat /bigfile
75 stat /sparsefile
76 stat /bigzerofile
77 stat /fifo
78 stat /emptydir
79 stat /dir
80 stat /dir/file
81 stat /acl_dir
82 stat /acl_dir/file
83 ENDL
84 $DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | $EGREP "(stat|Size:|Type:)" >> $OUT
85
86 cat > $TMPFILE.cmd << ENDL
87 ea_list dir/file
88 ea_list acl_dir
89 ea_list acl_dir/file
90 ENDL
91 $DEBUGFS -f $TMPFILE.cmd $TMPFILE >> $OUT 2>&1
92
93 $FSCK -f -n $TMPFILE >> $OUT 2>&1
94
95 sed -f $cmd_dir/filter.sed -f $test_dir/output.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp
96 mv $OUT.tmp $OUT
97
98 # Do the verification
99 cmp -s $OUT $EXP || cmp -s $OUT $EXP2
100 status=$?
101
102 if [ "$status" = 0 ] ; then
103 echo "$test_name: $test_description: ok"
104 touch $test_name.ok
105 else
106 echo "$test_name: $test_description: failed"
107 diff $DIFF_OPTS $EXP $OUT > $test_name.failed
108 echo " --- alternate $EXP2 ---" >> $test_name.failed
109 diff $DIFF_OPTS $EXP2 $OUT >> $test_name.failed
110 fi
111
112 rm -rf $TMPFILE.cmd $MKFS_DIR
113 unset MKFS_DIR OUT EXP EXP2