Whamcloud - gitweb
- new test program to make many files fast
authorbraam <braam>
Thu, 7 Nov 2002 18:25:21 +0000 (18:25 +0000)
committerbraam <braam>
Thu, 7 Nov 2002 18:25:21 +0000 (18:25 +0000)
lustre/tests/createmany.c [new file with mode: 0644]

diff --git a/lustre/tests/createmany.c b/lustre/tests/createmany.c
new file mode 100644 (file)
index 0000000..27ba3f7
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int main(int argc, char ** argv)
+{
+        int i, rc, count;
+        char filename[4096];
+
+        if (argc < 3) { 
+                printf("Usage %s filenamebase count\n", argv[0]);
+                return 1;
+        }
+
+        if (strlen(argv[1]) > 4080) { 
+                printf("name too long\n");
+                return 1;
+        }
+
+        count = strtoul(argv[2], NULL, 0);
+
+            
+        for (i=0 ; i < count ; i++) { 
+                sprintf(filename, "%s-%d", argv[1], i); 
+                rc = mknod(filename, S_IFREG| 0444, 0);
+                if (rc) { 
+                        printf("mknod(%s) error: %s\n", 
+                               filename, strerror(errno));
+                        break;
+                }
+        }
+        return rc;
+}