Whamcloud - gitweb
Updating from HEAD, in preparation for landing.
authorshaver <shaver>
Sat, 14 Dec 2002 23:09:35 +0000 (23:09 +0000)
committershaver <shaver>
Sat, 14 Dec 2002 23:09:35 +0000 (23:09 +0000)
lustre/tests/runslabinfo
lustre/tests/setuid.c [deleted file]
lustre/tests/toexcl.c

index 48d6602..eba407d 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 while sleep 1 ; do
-       egrep "ll_|ldlm|filp|dentry|inode|portals|size-[0-9]* " /proc/slabinfo
         echo '-----------------------'
+       egrep "ll_|ldlm|filp|dentry|inode|portals|size-[0-9]* " /proc/slabinfo
 done
diff --git a/lustre/tests/setuid.c b/lustre/tests/setuid.c
deleted file mode 100644 (file)
index 04dba5e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/fsuid.h>
-
-int main(int argc, char ** argv)
-{
-        int rc, fsuid;
-
-        if (argc < 2) { 
-                printf("Usage %s fsuid\n", argv[0]);
-                return 1;
-        }
-
-        fsuid = strtoul(argv[2], NULL, 0);
-        rc = setfsuid(fsuid);
-        if (rc) { 
-                printf("mknod(%s) error: %s\n", argv[1], strerror(errno));
-        }
-        return rc;
-} 
index da13217..7f099e8 100644 (file)
@@ -5,20 +5,73 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
+#include <unistd.h>
+
+void
+usage (char *argv0, int help)
+{
+       char *progname = strrchr(argv0, '/');
+
+       if (progname == NULL)
+               progname = argv0;
+       
+       fprintf (help ? stdout : stderr,
+                "Usage: %s [-e] file\n", progname);
+       
+       if (!help)
+       {
+               fprintf (stderr, "   or try '-h' for help\n");
+               exit (1);
+       }
+       
+       printf ("Create the given file with O_EXCL...\n");
+       printf (" -e    expect EEXIST\n");
+       printf (" -h    print help");
+       printf (" Exit status is 0 on success, 1 on failure\n");
+}
 
 int main(int argc, char **argv)
 {
         int rc;
-
-        if (argc != 2) { 
-                printf("usage: %s name\n", argv[0]);
+       int want_eexist = 0;
+       
+       while ((rc = getopt (argc, argv, "eh")) != -1)
+               switch (rc)
+               {
+               case 'e':
+                       want_eexist = 1;
+                       break;
+               case 'h':
+                       usage (argv[1], 1);
+                       return (0);
+               default:
+                       usage (argv[0], 0);
+               }
+       
+        if (optind != argc - 1) { 
+               usage (argv[0], 0);
                 return 1;
         }
 
-        rc = open(argv[1], O_CREAT|O_EXCL, 0644);
+        rc = open(argv[optind], O_CREAT|O_EXCL, 0644);
         if (rc == -1)
-                printf("open failed: %s\n", strerror(errno));
-        else
-                printf("open success.\n");
-        return 0;
+       {
+               if (want_eexist && errno == EEXIST)
+               {
+                       printf("open failed: %s (expected)\n", strerror(errno));
+                       return (0);
+               }
+               printf("open failed: %s\n", strerror(errno));
+               return (1);
+       } else {
+               if (want_eexist)
+               {
+                       printf("open success (expecting EEXIST).\n");
+                       return (1);
+               }
+               printf("open success.\n");
+               return (0);
+       }
+       
+       return ((rc == 0) ? 0 : 1);
 }