2 * Write a file until filesystem full is reached and then unlink it.
3 * Demonstrates a particular deadlock that Kaz hit in testing. Run
4 * several iterations of this in parallel on a near-full filesystem.
17 int main(int argc, char **argv)
22 unsigned int i, count = 0;
23 unsigned long long bytes = 0;
26 fprintf(stderr, "Insufficient arguments\n");
30 count = (unsigned int)atoi(argv[2]);
35 ptr = memalign(sz, sz);
40 memset(ptr, 0xffffffff, sz);
42 for (i = 0; i < count; i++) {
43 fd = open(argv[1], O_CREAT|O_WRONLY, 0666);
51 written = write(fd, ptr, sz);
53 if (errno == ENOSPC) {
56 printf("Unlinked %s\n", argv[1]);
60 printf("Skipped unlink %s (%s)\n",
61 argv[1], strerror(errno));
66 printf("Wrote zero bytes?\n");
72 printf("Wrote %llu bytes total.\n", bytes);
76 printf("Completed %u iterations of unlink/out-of-space test.\n", i);