Whamcloud - gitweb
LU-2471 tests: Fix facet_type() to recognise names like mds1_2
[fs/lustre-release.git] / lustre / tests / multiop.c
old mode 100755 (executable)
new mode 100644 (file)
index 4923ac7..4c9899a
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -26,7 +24,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/vfs.h>
+#include <sys/ioctl.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <semaphore.h>
-#include <libcfs/libcfs.h>
-#include <lustre/liblustreapi.h>
+
+#include <lustre/lustreapi.h>
 
 #define T1 "write data before unlink\n"
 #define T2 "write data after unlink\n"
@@ -68,6 +67,8 @@ char usage[] =
 "        d  mkdir\n"
 "        D  open(O_DIRECTORY)\n"
 "        f  statfs\n"
+"        G gid get grouplock\n"
+"        g gid put grouplock\n"
 "        L  link\n"
 "        l  symlink\n"
 "        m  mknod\n"
@@ -181,7 +182,6 @@ int get_flags(char *data, int *rflags)
 }
 
 #define POP_ARG() (pop_arg(argc, argv))
-#define min(a,b) ((a)>(b)?(b):(a))
 
 int main(int argc, char **argv)
 {
@@ -195,6 +195,7 @@ int main(int argc, char **argv)
         int flags;
         int save_errno;
         int verbose = 0;
+        int gid = 0;
 
         if (argc < 3) {
                 fprintf(stderr, usage, argv[0]);
@@ -258,6 +259,22 @@ int main(int argc, char **argv)
                                 exit(save_errno);
                         }
                         break;
+                case 'G':
+                        gid = atoi(commands+1);
+                        if (ioctl(fd, LL_IOC_GROUP_LOCK, gid) == -1) {
+                                save_errno = errno;
+                                perror("ioctl(GROUP_LOCK)");
+                                exit(save_errno);
+                        }
+                        break;
+                case 'g':
+                        gid = atoi(commands+1);
+                        if (ioctl(fd, LL_IOC_GROUP_UNLOCK, gid) == -1) {
+                                save_errno = errno;
+                                perror("ioctl(GROUP_UNLOCK)");
+                                exit(save_errno);
+                        }
+                        break;
                 case 'l':
                         newfile = POP_ARG();
                         if (!newfile)
@@ -321,7 +338,10 @@ int main(int argc, char **argv)
                 case 'o':
                         len = get_flags(commands+1, &flags);
                         commands += len;
-                        fd = open(fname, flags);
+                        if (flags & O_CREAT)
+                                fd = open(fname, flags, 0666);
+                        else
+                                fd = open(fname, flags);
                         if (fd == -1) {
                                 save_errno = errno;
                                 perror("open");
@@ -350,9 +370,12 @@ int main(int argc, char **argv)
                                         perror("read");
                                         exit(save_errno);
                                 }
-                                if (rc < len)
-                                        fprintf(stderr, "short read: %u/%u\n",
-                                                rc, len);
+                               if (rc < len) {
+                                       fprintf(stderr, "short read: %u/%u\n",
+                                               rc, len);
+                                       if (rc == 0)
+                                               exit(ENODATA);
+                               }
                                 len -= rc;
                                 if (verbose >= 2)
                                         printf("%.*s\n", rc, buf_align);