overlay/018: re-factor and add to hardlink group

Use helpers to records and check inode numbers so we can repeat
the same test after each hardlink copy up and mount cycle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Amir Goldstein
2017-07-05 15:02:00 +03:00
committed by Eryu Guan
parent 65fd511691
commit a76feb07aa
2 changed files with 26 additions and 9 deletions
+25 -8
View File
@@ -61,25 +61,42 @@ echo "patient zero" >> $lowerdir/foo
ln $lowerdir/foo $lowerdir/bar
# Record inode numbers in format <ino> <nlink>
function record_ino_nlink()
{
ls -li $FILES | awk '{ print $1, $3 }' > $1
}
# Check inode numbers match recorded inode numbers
function check_ino_nlink()
{
before=$1
after=$2
record_ino_nlink $after
# Test constant stat(2) st_ino/st_nlink -
# Compare before..after - expect silence
# We use diff -u so out.bad will tell us which stage failed
diff -u $before $after
}
_scratch_mount
rm -f $tmp.before $tmp.after
rm -f $tmp.*
foo=$SCRATCH_MNT/foo
bar=$SCRATCH_MNT/bar
# Record inode number and nlink before copy up
ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.before
FILES="$foo $bar"
record_ino_nlink $tmp.before
# Modify content of one of the hardlinks
echo "mutated" >> $foo
# Record inode number and nlink after copy up
ls -li $foo $bar | awk '{ print $1, $3 }' > $tmp.after
# Compare ino/nlink before..after - expect silence
diff $tmp.before $tmp.after
check_ino_nlink $tmp.before $tmp.after
# Compare content of files - expect silence
diff $foo $bar
+1 -1
View File
@@ -20,7 +20,7 @@
015 auto quick whiteout
016 auto quick copyup
017 auto quick copyup
018 auto quick copyup
018 auto quick copyup hardlink
019 auto stress
020 auto quick copyup perms
021 auto quick copyup