2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 void mkf(int idx, int p);
35 main(int argc, char **argv)
49 if (strcmp(*argv, "-c") == 0) {
53 if (asize > 64 || asize < 1) {
54 fprintf(stderr, "bad alpha size %s\n", *argv);
57 } else if (strcmp(*argv, "-d") == 0) {
59 } else if (strcmp(*argv, "-l") == 0) {
64 fprintf(stderr, "bad name length %s\n", *argv);
67 } else if (strcmp(*argv, "-p") == 0) {
72 fprintf(stderr, "bad process count %s\n",
76 } else if (strcmp(*argv, "-n") == 0) {
78 } else if (strcmp(*argv, "-v") == 0) {
80 } else if (strcmp(*argv, "-h") == 0) {
83 fprintf(stderr,"unknown switch \"%s\"\n", *argv);
91 fprintf(stderr,"permname: usage %s [-c alpha size] [-l name length] "
92 "[-p proc count] [-n] [-v] [-d] [-h]\n", argv0);
93 fprintf(stderr," -n : don't actually perform action\n");
94 fprintf(stderr," -v : be verbose\n");
95 fprintf(stderr," -d : create directories, not files\n");
101 "alphabet size must be multiple of process count\n");
104 asplit = asize / nproc;
105 alpha = malloc(asize + 1);
106 buf = malloc(len + 1);
107 for (a = 0, tot = 1; a < len; a++)
109 if (vflag) fprintf(stderr,"[%d] ",pid);
111 "alpha size = %d, name length = %d, total files = %lld, nproc=%d\n",
112 asize, len, tot, nproc);
114 for (a = 0; a < asize; a++) {
118 alpha[a] = 'A' + a - 26;
120 alpha[a] = '0' + a - 52;
126 for (a = 0; a < nproc; a++) {
141 if (errno==ECHILD) break;
157 last = (idx == len - 1);
160 for (i = p * asplit; i < (p + 1) * asplit; i++) {
164 if (vflag) printf("[%d] mkdir %s\n", pid, buf);
166 if (mkdir(buf, 0777)<0) {
172 if (vflag) printf("[%d] touch %s\n", pid, buf);
174 int f=creat(buf, 0666);
187 for (i = 0; i < asize; i++) {