Whamcloud - gitweb
b=3031
[fs/lustre-release.git] / lustre / tests / openclose.c
index cc4b06d..0def4b2 100644 (file)
@@ -2,6 +2,9 @@
  * vim:expandtab:shiftwidth=8:tabstop=8:
  */
 
+/* for O_DIRECT */
+#define _GNU_SOURCE
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/wait.h>
 #include <sys/ioctl.h>
 
-#include <linux/lustre_lite.h>
-
-#ifndef O_DIRECT
-# define O_DIRECT         040000 /* direct disk access hint */
-#endif
+#include <lustre/lustre_user.h>
 
 int main(int argc, char *argv[])
 {
@@ -62,9 +61,8 @@ 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",
@@ -85,9 +83,8 @@ int main(int argc, char *argv[])
                                                 argv[0], ret, err);
                                 if (!rc)
                                         rc = err;
-
-                                live_threads--;
                         }
+                        live_threads--;
                 }
         } else {
                 if (threads)
@@ -115,7 +112,8 @@ int main(int argc, char *argv[])
                                 rc = errno;
                                 break;
                         }
-                        if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0) {
+                        if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0 &&
+                            errno != ENOTTY) {
                                 fprintf(stderr, "ioctl(): %s\n",
                                         strerror(errno));
                                 rc = errno;