/* * df: yes, this, again, is what you'd expect. */ #include #include #define ONEMEG (1024L*1024L) unsigned long drivelist; /* all the active filesystems */ short current; /* filesystem we're sitting on */ char everything=0; /* df -a - show used space, too */ extern int getopt(); extern int opterr, optind; extern char *optarg; #ifdef __STDC__ void getdrivelist(void); void showdrivefor(char*, int); void showalldrives(void); #else void getdrivelist(); void showdrivefor(); void showalldrives(); #endif main(argc, argv) char **argv; { register i, st; getdrivelist(); while ((st=getopt(argc, argv, "t")) != EOF) { switch (st) { case 't': everything=1; break; default: fprintf(stderr, "usage: df [-t] [path ...]\n"); exit(1); } } if (everything) printf("fs\tkbytes\tused\tavail\tcapacity\n"); else printf("fs\tused\tavail\tcapacity\n"); if (optind >= argc) showalldrives(); else for (i=optind; i 31) { fprintf(stderr, "%s - invalid filesystem number\n", path); return; } } else drv = current-1; #if 0 /* mapped devices don't show up in the drivelist */ /* so this code is - *sigh - commented out */ if ((drivelist & (1<