mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
f4eee51260
xfs/111 is failing today, primarily because it obliterates the root inode chunk and the verifiers fail the mount - i.e. the test fails to properly test the thing it's meant to test. Change the test so that the induced corruption is further into the filesystem, but still hitting the inodes which have been created for the test, so that the fs can mount and continue. This requires that the helper binary (itrash) take an offset, which we will figure out by using xfs_db. This changes the locations of the inodes we hit; we're not really going to be able to predict that terribly well, so remove the output which shows inode offsets, and just keep track of whether we managed to obliterate any at all. The test still fails, because the fs is corrupted; this was done intentionally, so run xfs_repair before the test exits to fix things up. (This test doesn't run often; it's not in the auto group, and all the failures are extremely noisy and time consuming...) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
55 lines
1006 B
C
55 lines
1006 B
C
/*
|
|
* Bulkstat test case from Roger Willcocks <willcor@gmail.com>
|
|
*/
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
|
|
char buffer[32768];
|
|
int overwrote;
|
|
|
|
void die(char *func)
|
|
{
|
|
perror(func);
|
|
exit(1);
|
|
}
|
|
|
|
void nuke()
|
|
{
|
|
int i;
|
|
for (i = 2048; i < 32768-1; i++)
|
|
if (buffer[i] == 'I' && buffer[i+1] == 'N') {
|
|
buffer[i] = buffer[i+1] = 'X';
|
|
overwrote = 1;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int f;
|
|
loff_t offset;
|
|
|
|
if (argc != 3) {
|
|
printf("%s <device> <offset>\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
f = open(argv[1], O_RDWR);
|
|
offset = atoll(argv[2]);
|
|
|
|
if (f < 0) die("open");
|
|
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, 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;
|
|
}
|