diff options
Diffstat (limited to 'tests/f_badsymlinks2')
-rw-r--r-- | tests/f_badsymlinks2/expect.1 | 114 | ||||
-rw-r--r-- | tests/f_badsymlinks2/expect.2 | 7 | ||||
-rw-r--r-- | tests/f_badsymlinks2/image.gz | bin | 0 -> 14302 bytes | |||
-rwxr-xr-x | tests/f_badsymlinks2/mkimage.sh | 127 | ||||
-rw-r--r-- | tests/f_badsymlinks2/name | 1 |
5 files changed, 249 insertions, 0 deletions
diff --git a/tests/f_badsymlinks2/expect.1 b/tests/f_badsymlinks2/expect.1 new file mode 100644 index 0000000..939edce --- /dev/null +++ b/tests/f_badsymlinks2/expect.1 @@ -0,0 +1,114 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Symlink /default/empty (inode #13) is invalid. +Clear? yes + +Symlink /default/fast_isize_too_small (inode #15) is invalid. +Clear? yes + +Symlink /default/fast_isize_too_large (inode #16) is invalid. +Clear? yes + +Symlink /default/slow_isize_too_small (inode #19) is invalid. +Clear? yes + +Symlink /default/slow_isize_too_large (inode #20) is invalid. +Clear? yes + +Symlink /default/one_too_long (inode #22) is invalid. +Clear? yes + +Symlink /default/too_long (inode #23) is invalid. +Clear? yes + +Symlink /encrypted/empty (inode #25) is invalid. +Clear? yes + +Symlink /encrypted/fast_isize_too_large (inode #28) is invalid. +Clear? yes + +Symlink /encrypted/fast_isize_too_small (inode #27) is invalid. +Clear? yes + +Symlink /encrypted/one_too_long (inode #34) is invalid. +Clear? yes + +Symlink /encrypted/slow_isize_too_large (inode #32) is invalid. +Clear? yes + +Symlink /encrypted/slow_isize_too_small (inode #31) is invalid. +Clear? yes + +Symlink /encrypted/too_long (inode #35) is invalid. +Clear? yes + +Symlink /extents/empty (inode #38) is invalid. +Clear? yes + +Symlink /extents/fast_isize_too_small (inode #40) is invalid. +Clear? yes + +Symlink /extents/fast_isize_too_large (inode #41) is invalid. +Clear? yes + +Symlink /extents/slow_isize_too_small (inode #44) is invalid. +Clear? yes + +Symlink /extents/slow_isize_too_large (inode #45) is invalid. +Clear? yes + +Symlink /extents/one_too_long (inode #47) is invalid. +Clear? yes + +Symlink /extents/too_long (inode #48) is invalid. +Clear? yes + +Symlink /extents_encrypted/empty (inode #50) is invalid. +Clear? yes + +Symlink /extents_encrypted/fast_isize_too_large (inode #53) is invalid. +Clear? yes + +Symlink /extents_encrypted/fast_isize_too_small (inode #52) is invalid. +Clear? yes + +Symlink /extents_encrypted/one_too_long (inode #59) is invalid. +Clear? yes + +Symlink /extents_encrypted/slow_isize_too_large (inode #57) is invalid. +Clear? yes + +Symlink /extents_encrypted/slow_isize_too_small (inode #56) is invalid. +Clear? yes + +Symlink /extents_encrypted/too_long (inode #60) is invalid. +Clear? yes + +Symlink /inline_data/empty (inode #63) is invalid. +Clear? yes + +Symlink /inline_data/fast_isize_too_small (inode #65) is invalid. +Clear? yes + +Symlink /inline_data/fast_isize_too_large (inode #66) is invalid. +Clear? yes + +Symlink /inline_data/slow_isize_too_small (inode #69) is invalid. +Clear? yes + +Symlink /inline_data/slow_isize_too_large (inode #70) is invalid. +Clear? yes + +Symlink /inline_data/one_too_long (inode #72) is invalid. +Clear? yes + +Symlink /inline_data/too_long (inode #73) is invalid. +Clear? yes + +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 36/80 files (0.0% non-contiguous), 31/150 blocks +Exit status is 1 diff --git a/tests/f_badsymlinks2/expect.2 b/tests/f_badsymlinks2/expect.2 new file mode 100644 index 0000000..3da98a8 --- /dev/null +++ b/tests/f_badsymlinks2/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 36/80 files (0.0% non-contiguous), 31/150 blocks +Exit status is 0 diff --git a/tests/f_badsymlinks2/image.gz b/tests/f_badsymlinks2/image.gz Binary files differnew file mode 100644 index 0000000..d1f314c --- /dev/null +++ b/tests/f_badsymlinks2/image.gz diff --git a/tests/f_badsymlinks2/mkimage.sh b/tests/f_badsymlinks2/mkimage.sh new file mode 100755 index 0000000..6bbf020 --- /dev/null +++ b/tests/f_badsymlinks2/mkimage.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +# This is the script that was used to create the image.gz in this directory. + +set -e -u + +BLOCKSIZE=4096 + +do_debugfs() { + umount mnt + debugfs -w "$@" image + mount image mnt +} + +do_tune2fs() { + umount mnt + tune2fs $@ image + mount image mnt +} + +symlink() { + local len=$1 + local src=$2 + local target=$(perl -e 'print "A" x '$len) + ln -s $target $src + stat -c %i $src +} + +# Overwrite the length in the header of the encrypted symlink target +set_encrypted_symlink_len() { + local ino=$1 + local len=$2 + + echo "zap_block -f <$ino> -p $((len%256)) -o 0 -l 1 0" + echo "zap_block -f <$ino> -p $((len/256)) -o 1 -l 1 0" +} + +create_symlinks() { + local dir=$1 + local encrypted=${2:-false} + local overhead=0 + local ino + + if $encrypted; then + overhead=2 + fi + + mkdir -p $dir + + { + ino=$(symlink 1 $dir/empty) + echo "set_inode_field <$ino> i_size 10" + echo "set_inode_field <$ino> block[0] 0" + + symlink 1 $dir/fast_min > /dev/null + + ino=$(symlink 10 $dir/fast_isize_too_small) + echo "set_inode_field <$ino> i_size 1" + + ino=$(symlink 10 $dir/fast_isize_too_large) + echo "set_inode_field <$ino> i_size 20" + + symlink $((59 - overhead)) $dir/fast_max > /dev/null + + symlink $((60 - overhead)) $dir/slow_min > /dev/null + + ino=$(symlink 100 $dir/slow_isize_too_small) + echo "set_inode_field <$ino> i_size 80" + + ino=$(symlink 100 $dir/slow_isize_too_large) + echo "set_inode_field <$ino> i_size 120" + + symlink $((BLOCKSIZE - 1 - overhead)) $dir/slow_max > /dev/null + + ino=$(symlink $((BLOCKSIZE - 1 - overhead)) $dir/one_too_long) + echo "set_inode_field <$ino> i_size $BLOCKSIZE" + echo "zap_block -f <$ino> -p 65 0" + if $encrypted; then + set_encrypted_symlink_len $ino $((BLOCKSIZE - overhead)) + fi + + ino=$(symlink $((BLOCKSIZE - 1 - overhead)) $dir/too_long) + echo "set_inode_field <$ino> i_size $((BLOCKSIZE + 1000))" + echo "zap_block -f <$ino> -p 65 0" + if $encrypted; then + set_encrypted_symlink_len $ino $((BLOCKSIZE + 1000 - overhead)) + fi + + } >> debugfs_commands + do_debugfs < debugfs_commands +} + +create_encrypted_symlinks() { + local dir=$1 link + + mkdir $dir + echo | e4crypt add_key $dir + create_symlinks $dir true + + # Move symlinks into an unencrypted directory (leaving their targets + # encrypted). This makes the fsck output consistent. + mv $dir ${dir}~encrypted + mkdir $dir + mv ${dir}~encrypted/* $dir +} + +mkdir -p mnt +umount mnt &> /dev/null || true +dd if=/dev/zero of=image bs=1024 count=600 + +mke2fs -O 'encrypt,^extents,^64bit' -b $BLOCKSIZE -I 256 image +mount image mnt + +create_symlinks mnt/default +create_encrypted_symlinks mnt/encrypted + +do_tune2fs -O extents +create_symlinks mnt/extents +create_encrypted_symlinks mnt/extents_encrypted + +do_debugfs -R 'feature inline_data' +create_symlinks mnt/inline_data + +rm -rf debugfs_commands mnt/*~encrypted +umount mnt +rmdir mnt +gzip -9 -f image diff --git a/tests/f_badsymlinks2/name b/tests/f_badsymlinks2/name new file mode 100644 index 0000000..81d3285 --- /dev/null +++ b/tests/f_badsymlinks2/name @@ -0,0 +1 @@ +more types of corrupted symlinks |