DF-3061 / renamer.c
/* DF-3061 client side: hammer NFS RENAME (v3) on src/dst over the mount. * Run on the machine that has the server's export mounted (the guest can * mount its own export over loopback). */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/wait.h> static const char *dirpath; int main(int argc, char **argv) { int i, n = 4; if (argc < 2) { fprintf(stderr, "usage: %s <mounted-export-dir>\n", argv[0]); exit(2); } dirpath = argv[1]; for (i = 0; i < n; i++) { pid_t p = fork(); if (p == 0) { char a[512], b[512]; snprintf(a, sizeof(a), "%s/src%d", dirpath, i); snprintf(b, sizeof(b), "%s/dst%d", dirpath, i); for (;;) { int fd = open(a, O_CREAT, 0666); if (fd >= 0) close(fd); rename(a, b); rename(b, a); unlink(a); unlink(b); } } } for (;;) pause(); return 0; } |