X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fwriteme.c;h=bf5c971e611815bc8a6ee2baa2ee1169397a5d06;hb=301db1b716f2f5cc395817fcf1b322ae78677925;hp=ab8692f8427ea14bb8ca7d713fd75f259b52841d;hpb=f12449c72130061905dfa9f1a52c8488066ee2fb;p=fs%2Flustre-release.git diff --git a/lustre/tests/writeme.c b/lustre/tests/writeme.c index ab8692f..bf5c971 100644 --- a/lustre/tests/writeme.c +++ b/lustre/tests/writeme.c @@ -4,29 +4,43 @@ #include #include +void usage(char *prog) +{ + printf("usage: %s [-s] filename\n", prog); +} + int main(int argc, char **argv) { - int fd, rc; + int fd, rc; + int do_sync = 0; int i = 0; + int file_arg = 1; char buf[4096]; - + memset(buf, 0, 4096); - if (argc != 2) { - printf("Usage openme \n"); + if (argc < 2 || argc > 3) { + usage(argv[0]); exit(1); } - fd = open(argv[1], O_RDWR | O_CREAT, 0600); - if (fd == -1) { + if (strcmp(argv[1], "-s") == 0) { + do_sync = 1; + file_arg++; + } + + fd = open(argv[file_arg], O_RDWR | O_CREAT, 0600); + if (fd == -1) { printf("Error opening %s\n", argv[1]); exit(1); } - while (1) { - sprintf(buf, "write %d\n", i); - rc = write(fd, buf, sizeof(buf)); - sleep(1); + while (1) { + sprintf(buf, "write %d\n", i); + rc = write(fd, buf, sizeof(buf)); + if (do_sync) + sync(); + sleep(1); } return 0; }