/var/lib/pcp/testsuite/src/mkfiles.c is in pcp-testsuite 3.8.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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);
}
|