summaryrefslogtreecommitdiff
path: root/qa/src/mkfiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'qa/src/mkfiles.c')
-rw-r--r--qa/src/mkfiles.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/qa/src/mkfiles.c b/qa/src/mkfiles.c
new file mode 100644
index 0000000..0a241af
--- /dev/null
+++ b/qa/src/mkfiles.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1997-2002 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <pcp/pmapi.h>
+#include <pcp/impl.h>
+
+/* Be careful when changing LIMIT. Also change malloc and sprintf! */
+
+#define LIMIT 10000 /* max nfiles allowed */
+
+static void
+usage (void)
+{
+ fprintf(stderr, "Usage %s: basename nfiles\n", pmProgname);
+ exit(1);
+}
+
+int
+main(int argc, char* argv[])
+{
+ char *endp;
+ long nfiles;
+ char *namebuf;
+ char *extptr;
+ int i, sts;
+
+ __pmSetProgname(argv[0]);
+
+ if (argc != 3)
+ usage();
+
+ nfiles = strtol(argv[2], &endp, 0);
+ if (*endp != '\0') {
+ fprintf(stderr, "nfiles \"%s\" is not numeric\n", argv[2]);
+ usage();
+ }
+ if (nfiles > LIMIT) {
+ fprintf(stderr, "be reasonable: nfiles limited to %d\n", LIMIT);
+ usage();
+ }
+
+ i = (int)strlen(argv[1]);
+ namebuf = (char *)malloc(i + 6);
+ if (namebuf == (char *)0) {
+ perror("error allocating filename buffer");
+ exit(1);
+ }
+ strcpy(namebuf, argv[1]);
+ namebuf[i++] = '.';
+ extptr = &namebuf[i];
+
+ for (i = 0; i < nfiles; i++) {
+ sprintf(extptr, "%04d", i);
+ if ((sts = creat(namebuf, 0777)) < 0) {
+ fprintf(stderr, "Error creating %s: %s\n", namebuf, strerror(errno));
+ exit(1);
+ }
+ else
+ close(sts);
+ }
+ exit(0);
+}