1: /*
   2:  * PQ - print the quota file affecting you most immediately
   3:  */
   4: 
   5: #ifndef lint
   6: static char *sccsid = "@(#)pq.c	2.8	6/2/81";
   7: #endif
   8: 
   9: #include    <whoami.h>
  10: #include    <stdio.h>
  11: #include    <sys/types.h>
  12: #include    <sys/inode.h>
  13: #include    <sys/stat.h>
  14: #include    <sys/qstat.h>
  15: 
  16: #define reg register
  17: 
  18: #define isquot(i)   ((i.qs_mode & S_IFMT) == S_IFQUOT)
  19: 
  20: struct qstat    Sbuf, Zbuf;
  21: 
  22: main(argc, argv)
  23: reg int     argc;
  24: char        **argv;
  25: {
  26:     reg int     i;
  27:     reg char    *sp;
  28:     int     flag = 0;
  29:     int     lastnode;
  30:     char        buf[80];
  31: 
  32:     if (argc > 1 && argv[1][0] == '-') {
  33:         flag++;
  34:         argv++;
  35:         argc--;
  36:         }
  37: 
  38:     if (argc==1) {
  39:         lastnode=0;
  40:         if (qstat(".",&Sbuf) == -1) {
  41:             perror("qstat");
  42:             exit(1);
  43:         }
  44:         while (lastnode != Sbuf.qs_number) {
  45:             lastnode = Sbuf.qs_number;
  46:             (void) qstat(".q",&Sbuf);
  47:             if (isquot(Sbuf)) {
  48:                 PrintQuota(&Sbuf);
  49:                 exit(0);
  50:             }
  51:             chdir("..");
  52:             if (qstat(".",&Sbuf) == -1) {
  53:                 perror("qstat");
  54:                 exit(1);
  55:             }
  56:         }
  57:         exit(9);
  58:     }
  59:     for (i = 1; i < argc; ++i) {
  60:         strcpy(buf, argv[i]);
  61:         if ((sp = rindex(buf, '.')) == NULL || strcmp(sp, ".q") != 0)
  62:             strcat(buf, "/.q");
  63:         Sbuf = Zbuf;            /* clean out this turkey */
  64:         if (flag || argc > 2)  printf("%-18s    ",argv[i]);
  65:         qstat(buf,&Sbuf);
  66:         if (isquot(Sbuf))
  67:             PrintQuota(&Sbuf);
  68:         else
  69:             printf("no quota\n");
  70:     }
  71: }
  72: 
  73: PrintQuota()
  74: {
  75:     float   cut, a, b;
  76: 
  77:     a = Sbuf.qs_un.qs_qused;
  78:     b = Sbuf.qs_un.qs_qmax;
  79:     printf("%ld/%ld", Sbuf.qs_un.qs_qused, Sbuf.qs_un.qs_qmax);
  80:     if (b > 0.) {
  81:         cut = 100.0 * a / b;
  82:         printf(" (%1.0f%%)", cut);
  83:         }
  84:     putchar('\n');
  85: }

Defined functions

PrintQuota defined in line 73; used 2 times
main defined in line 22; never used

Defined variables

Sbuf defined in line 20; used 15 times
Zbuf defined in line 20; used 1 times
  • in line 63
sccsid defined in line 6; never used

Defined macros

isquot defined in line 18; used 2 times
reg defined in line 16; used 3 times
Last modified: 1983-05-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 759
Valid CSS Valid XHTML 1.0 Strict