1: #define BMAX 100
2: #include <stdio.h>
3: #include <ctype.h>
4:
5: FILE *ifp, *popen();
6: char *quota, diskuse[BMAX];
7: char *usage = "Usage: %s d1 ... dn quota\n";
8:
9: main(argc,argv)
10: int argc;
11: char **argv;
12: {
13: char cmdbuf[BUFSIZ];
14: register char *s;
15:
16: if (!atoi(quota = argv[argc-1]) || (argc < 3)) {
17: fprintf(stderr, usage, *argv);
18: exit(1);
19: }
20: while (argc-- > 2) {
21: sprintf(cmdbuf, "du -s %s", *++argv);
22: if ((ifp = popen(cmdbuf, "r")) == NULL) {
23: perror(popen);
24: exit(1);
25: }
26: else
27: while (fgets(diskuse, BMAX, ifp) != NULL)
28: ;
29: pclose(ifp);
30: for (s = diskuse; isdigit(*s); s++)
31: ;
32: *s = '\0';
33: sprintf(cmdbuf, "setquota %s %s %s", *argv, diskuse, quota);
34: system(cmdbuf);
35: sprintf(cmdbuf, "pq - %s", *argv);
36: system(cmdbuf);
37: }
38: exit(0);
39: }
Defined functions
main
defined in line
9;
never used
Defined variables
quota
defined in line
6; used 3 times
usage
defined in line
7; used 1 times
Defined macros
BMAX
defined in line
1; used 2 times