|
|
1.1 ! root 1: /* @(#)rename.c 1.2 90/01/03 NFS Rev 2 Testsuite ! 2: * 1.3 Lachman ONC Test Suite source ! 3: * ! 4: * rename a file n times ! 5: */ ! 6: #include <stdio.h> ! 7: #ifdef SVR3 ! 8: #include <fcntl.h> ! 9: #else ! 10: #include <sys/file.h> ! 11: #endif ! 12: ! 13: main(argc, argv) ! 14: int argc; ! 15: char *argv[]; ! 16: { ! 17: int count; ! 18: int i; ! 19: int fd; ! 20: ! 21: if (argc != 2) { ! 22: fprintf(stderr, "usage: %s <count>\n", argv[0]); ! 23: exit(1); ! 24: } ! 25: if ((fd = open("rename1", O_CREAT, 0666)) < 0) { ! 26: perror("rename1"); ! 27: exit(1); ! 28: } ! 29: close(fd); ! 30: ! 31: count = atoi(argv[1]); ! 32: for (i=0; i<count; i++) { ! 33: if (rename("rename1", "rename2") < 0) { ! 34: perror("rename rename1 to rename2"); ! 35: fprintf(stderr, "%d of %d\n", i, count); ! 36: exit(1); ! 37: } ! 38: if (rename("rename2", "rename1") < 0) { ! 39: perror("rename rename2 to rename1"); ! 40: fprintf(stderr, "%d of %d\n", i, count); ! 41: exit(1); ! 42: } ! 43: } ! 44: cleanup: ! 45: unlink("rename1"); ! 46: unlink("rename2"); ! 47: exit(0); ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.