X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fopenclose.c;h=22c859c2956618f6cc6ddf1c5350b294c92dbcb5;hb=44711ce0e1c6de1bb016d4d39e1054efb0223568;hp=cc4b06d36c00cb8d796e8ea350368ad8b6cd014d;hpb=02f811ce0636a94b77ea18d5d2ffb5fa91bab1ad;p=fs%2Flustre-release.git diff --git a/lustre/tests/openclose.c b/lustre/tests/openclose.c index cc4b06d..22c859c 100644 --- a/lustre/tests/openclose.c +++ b/lustre/tests/openclose.c @@ -2,6 +2,9 @@ * vim:expandtab:shiftwidth=8:tabstop=8: */ +/* for O_DIRECT */ +#define _GNU_SOURCE + #include #include #include @@ -13,10 +16,9 @@ #include #include -#include - +#include #ifndef O_DIRECT -# define O_DIRECT 040000 /* direct disk access hint */ +#define O_DIRECT 0 #endif int main(int argc, char *argv[]) @@ -62,15 +64,14 @@ int main(int argc, char *argv[]) pid_t ret; ret = waitpid(0, &status, 0); - if (ret == 0) { + if (ret == 0) continue; - } if (ret < 0) { - fprintf(stderr, "error: %s: wait - %s\n", - argv[0], strerror(errno)); if (!rc) rc = errno; + fprintf(stderr, "error: %s: wait - %s\n", + argv[0], strerror(rc)); } else { /* * This is a hack. We _should_ be able to use @@ -85,9 +86,8 @@ int main(int argc, char *argv[]) argv[0], ret, err); if (!rc) rc = err; - - live_threads--; } + live_threads--; } } else { if (threads) @@ -97,42 +97,42 @@ int main(int argc, char *argv[]) fd = open(filename, O_RDWR|O_CREAT, 0644); if (fd < 0) { + rc = errno; fprintf(stderr, "open(%s, O_CREAT): %s\n", filename, - strerror(errno)); - exit(errno); + strerror(rc)); + exit(rc); } if (close(fd) < 0) { - fprintf(stderr, "close(): %s\n", strerror(errno)); rc = errno; + fprintf(stderr, "close(): %s\n", strerror(rc)); goto unlink; } for (i = 0; i < count; i++) { fd = open(filename, O_RDWR|O_LARGEFILE|O_DIRECT); if (fd < 0) { - fprintf(stderr, "open(%s, O_RDWR): %s\n", - filename, strerror(errno)); rc = errno; + fprintf(stderr, "open(%s, O_RDWR): %s\n", + filename, strerror(rc)); break; } - if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0) { - fprintf(stderr, "ioctl(): %s\n", - strerror(errno)); + if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0 && + errno != ENOTTY) { rc = errno; + fprintf(stderr, "ioctl(): %s\n", strerror(rc)); break; } if (close(fd) < 0) { - fprintf(stderr, "close(): %s\n", - strerror(errno)); rc = errno; + fprintf(stderr, "close(): %s\n", strerror(rc)); break; } } unlink: if (unlink(filename) < 0) { - fprintf(stderr, "unlink(%s): %s\n", filename, - strerror(errno)); rc = errno; + fprintf(stderr, "unlink(%s): %s\n", filename, + strerror(rc)); } if (threads) printf("Thread %d done: rc = %d\n", thread, rc);