2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
46 void mkf(int idx, int p);
49 main(int argc, char **argv)
63 if (strcmp(*argv, "-c") == 0) {
67 if (asize > 64 || asize < 1) {
68 fprintf(stderr, "bad alpha size %s\n", *argv);
71 } else if (strcmp(*argv, "-d") == 0) {
73 } else if (strcmp(*argv, "-l") == 0) {
78 fprintf(stderr, "bad name length %s\n", *argv);
81 } else if (strcmp(*argv, "-p") == 0) {
86 fprintf(stderr, "bad process count %s\n",
90 } else if (strcmp(*argv, "-n") == 0) {
92 } else if (strcmp(*argv, "-v") == 0) {
94 } else if (strcmp(*argv, "-h") == 0) {
97 fprintf(stderr,"unknown switch \"%s\"\n", *argv);
105 fprintf(stderr,"permname: usage %s [-c alpha size] [-l name length] "
106 "[-p proc count] [-n] [-v] [-d] [-h]\n", argv0);
107 fprintf(stderr," -n : don't actually perform action\n");
108 fprintf(stderr," -v : be verbose\n");
109 fprintf(stderr," -d : create directories, not files\n");
115 "alphabet size must be multiple of process count\n");
118 asplit = asize / nproc;
119 alpha = malloc(asize + 1);
120 buf = malloc(len + 1);
121 for (a = 0, tot = 1; a < len; a++)
123 if (vflag) fprintf(stderr,"[%d] ",pid);
125 "alpha size = %d, name length = %d, total files = %lld, nproc=%d\n",
126 asize, len, tot, nproc);
128 for (a = 0; a < asize; a++) {
132 alpha[a] = 'A' + a - 26;
134 alpha[a] = '0' + a - 52;
140 for (a = 0; a < nproc; a++) {
155 if (errno==ECHILD) break;
171 last = (idx == len - 1);
174 for (i = p * asplit; i < (p + 1) * asplit; i++) {
178 if (vflag) printf("[%d] mkdir %s\n", pid, buf);
180 if (mkdir(buf, 0777)<0) {
186 if (vflag) printf("[%d] touch %s\n", pid, buf);
188 int f=creat(buf, 0666);
201 for (i = 0; i < asize; i++) {