-
-
Save terrelln/4bba325abdfa3a6f014e9911ac92a185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/bin/sh | |
set -e | |
MNT=/mnt/f2fs-minimized-test-mnt | |
DISK=/tmp/f2fs-minimized-test-disk | |
SRC_FILE=/tmp/f2fs-minimized-test-seq | |
DST_FILE=$MNT/$(basename $SRC_FILE) | |
# Clean up | |
rm -f $DISK $SRC_FILE | |
umount $MNT ||: | |
mkdir -p $MNT | |
# Write source file - If the file is 1 byte smaller the error doesn't happen | |
seq 1200000 | head -c 7700481 > $SRC_FILE | |
SRC_FILE_SHA1=$(sha1sum $SRC_FILE | awk {'print $1'}) | |
# Check that the source file matches our expected sha1sum so we know that | |
# we are testing the same thing | |
if [ "$SRC_FILE_SHA1" != "4424a58b862c0bdc1001c0193c91e99156faeac4" ]; then | |
echo "UNEXPECTED: $SRC_FILE does not have the correct sha1sum... WAT?" | |
exit 1 | |
fi | |
# Create the filesystem & mount it | |
dd if=/dev/zero of=$DISK bs=4096 seek=1048575 count=1 | |
mkfs.f2fs -O compression,extra_attr $DISK | |
mount -t f2fs $DISK $MNT | |
# Copy our source file | |
cp $SRC_FILE $DST_FILE | |
# chattr +c - without this line the error doesn't happen | |
chattr +c $DST_FILE | |
# Unmount & remount the filesystem - without this the error doesn't happen | |
umount $MNT | |
mount -t f2fs $DISK $MNT | |
# Cheeck that the first 7700480 match, and only the last byte differs - it is zero | |
# in the $DST_FILE | |
if [ "$(head -c 7700480 $SRC_FILE | sha1sum)" != "$(head -c 7700480 $DST_FILE | sha1sum)" ]; then | |
echo "UNEXPECTED: The first 7700480 bytes of the file should match" | |
exit 1 | |
fi | |
# Check that the $SRC_FILE does not match the $DST_FILE | |
DST_FILE_SHA1=$(sha1sum $DST_FILE | awk {'print $1'}) | |
if [ "$SRC_FILE_SHA1" != "$DST_FILE_SHA1" ]; then | |
echo "EXPECTED: FAILURE!" | |
sha1sum $SRC_FILE $DST_FILE | |
else | |
echo "UNEXPECTED: SUCCESS" | |
exit 1 | |
fi | |
# Cleanup | |
rm -f $DISK $SRC_FILE | |
umount $MNT ||: | |
rmdir $MNT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment