diff --git a/src/itrash.c b/src/itrash.c index 21e1c5c5..42692d07 100644 --- a/src/itrash.c +++ b/src/itrash.c @@ -8,6 +8,7 @@ #include char buffer[32768]; +int overwrote; void die(char *func) { @@ -21,20 +22,32 @@ void nuke() for (i = 2048; i < 32768-1; i++) if (buffer[i] == 'I' && buffer[i+1] == 'N') { buffer[i] = buffer[i+1] = 'X'; - printf("Overwrote IN @offset %d\n", i); + overwrote = 1; } } int main(int argc, char* argv[]) { - int f = open(argv[1], O_RDWR); + int f; + loff_t offset; + + if (argc != 3) { + printf("%s \n", argv[0]); + exit(1); + } + + f = open(argv[1], O_RDWR); + offset = atoll(argv[2]); + if (f < 0) die("open"); - if (lseek(f, 32768, SEEK_SET) < 0) die("lseek"); + if (lseek(f, offset, SEEK_SET) < 0) die("lseek"); if (read(f, buffer, 32768) != 32768) die("read"); printf("Starting overwrite\n"); nuke(); - if (lseek(f, 32768, SEEK_SET) < 0) die("lseek"); + if (lseek(f, offset, SEEK_SET) < 0) die("lseek"); if (write(f, buffer, 32768) != 32768) die("write"); + if (!overwrote) + printf("Did not overwrite any inodes\n"); printf("Overwrite complete\n"); close(f); return 0; diff --git a/tests/xfs/111 b/tests/xfs/111 index f33f3396..7c8f2638 100755 --- a/tests/xfs/111 +++ b/tests/xfs/111 @@ -40,6 +40,8 @@ _supported_fs xfs _supported_os Linux _require_scratch +rm -f $seqres.full + [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found" # real QA test starts here @@ -56,16 +58,27 @@ do $XFS_IO_PROG -f -c "pwrite 0 512" $SCRATCH_MNT/${I} > /dev/null let I=$I+1 done + +# Roughly the middle of the created inodes +INO=`ls -i $SCRATCH_MNT/512 | awk '{print $1}'` umount $SCRATCH_DEV -echo Blat inode clusters -src/itrash $SCRATCH_DEV +# Figure out where that middle inode starts +BYTE=`$XFS_DB_PROG -c "convert inode $INO byte" $SCRATCH_DEV \ + | awk '{print $2}' | sed s/[\(\)]//g` -_scratch_mount +echo Blat inode clusters +src/itrash $SCRATCH_DEV $BYTE + +_scratch_mount || _fail "Couldn't mount after itrash" echo Attempting bulkstat #src/bstat -q $SCRATCH_MNT -xfs_fsr $SCRATCH_MNT +$XFS_FSR_PROG $SCRATCH_MNT | _filter_scratch + +# Fix up intentional corruption so test can pass +umount $SCRATCH_DEV +$XFS_REPAIR_PROG $SCRATCH_DEV >> $seqres.full 2>&1 status=0 exit diff --git a/tests/xfs/111.out b/tests/xfs/111.out index 88a5c997..fd56c3c8 100644 --- a/tests/xfs/111.out +++ b/tests/xfs/111.out @@ -8,93 +8,6 @@ realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX Create some files Blat inode clusters Starting overwrite -Overwrote IN @offset 2048 -Overwrote IN @offset 2304 -Overwrote IN @offset 2560 -Overwrote IN @offset 2816 -Overwrote IN @offset 3072 -Overwrote IN @offset 3328 -Overwrote IN @offset 3584 -Overwrote IN @offset 3840 -Overwrote IN @offset 4096 -Overwrote IN @offset 4352 -Overwrote IN @offset 4608 -Overwrote IN @offset 4864 -Overwrote IN @offset 5120 -Overwrote IN @offset 5376 -Overwrote IN @offset 5632 -Overwrote IN @offset 5888 -Overwrote IN @offset 6144 -Overwrote IN @offset 6400 -Overwrote IN @offset 6656 -Overwrote IN @offset 6912 -Overwrote IN @offset 7168 -Overwrote IN @offset 7424 -Overwrote IN @offset 7680 -Overwrote IN @offset 7936 -Overwrote IN @offset 8192 -Overwrote IN @offset 8448 -Overwrote IN @offset 8704 -Overwrote IN @offset 8960 -Overwrote IN @offset 9216 -Overwrote IN @offset 9472 -Overwrote IN @offset 9728 -Overwrote IN @offset 9984 -Overwrote IN @offset 10240 -Overwrote IN @offset 10496 -Overwrote IN @offset 10752 -Overwrote IN @offset 11008 -Overwrote IN @offset 11264 -Overwrote IN @offset 11520 -Overwrote IN @offset 11776 -Overwrote IN @offset 12032 -Overwrote IN @offset 12288 -Overwrote IN @offset 12544 -Overwrote IN @offset 12800 -Overwrote IN @offset 13056 -Overwrote IN @offset 13312 -Overwrote IN @offset 13568 -Overwrote IN @offset 13824 -Overwrote IN @offset 14080 -Overwrote IN @offset 14336 -Overwrote IN @offset 14592 -Overwrote IN @offset 14848 -Overwrote IN @offset 15104 -Overwrote IN @offset 15360 -Overwrote IN @offset 15616 -Overwrote IN @offset 15872 -Overwrote IN @offset 16128 -Overwrote IN @offset 24576 -Overwrote IN @offset 24832 -Overwrote IN @offset 25088 -Overwrote IN @offset 25344 -Overwrote IN @offset 25600 -Overwrote IN @offset 25856 -Overwrote IN @offset 26112 -Overwrote IN @offset 26368 -Overwrote IN @offset 26624 -Overwrote IN @offset 26880 -Overwrote IN @offset 27136 -Overwrote IN @offset 27392 -Overwrote IN @offset 27648 -Overwrote IN @offset 27904 -Overwrote IN @offset 28160 -Overwrote IN @offset 28416 -Overwrote IN @offset 28672 -Overwrote IN @offset 28928 -Overwrote IN @offset 29184 -Overwrote IN @offset 29440 -Overwrote IN @offset 29696 -Overwrote IN @offset 29952 -Overwrote IN @offset 30208 -Overwrote IN @offset 30464 -Overwrote IN @offset 30720 -Overwrote IN @offset 30976 -Overwrote IN @offset 31232 -Overwrote IN @offset 31488 -Overwrote IN @offset 31744 -Overwrote IN @offset 32000 -Overwrote IN @offset 32256 -Overwrote IN @offset 32512 Overwrite complete Attempting bulkstat +SCRATCH_MNT start inode=0