home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 20228 < prev    next >
Encoding:
Text File  |  1993-01-03  |  4.4 KB  |  157 lines

  1. Path: sparky!uunet!cis.ohio-state.edu!ucbvax!MC.MARICOPA.EDU!SHOECRAFT
  2. From: SHOECRAFT@MC.MARICOPA.EDU (Steve Shoecraft)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: ACP-QIO to read QUOTA.SYS
  5. Message-ID: <01GT2536ZPMQ00021R@mc.maricopa.edu>
  6. Date: 3 Jan 93 05:22:44 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 145
  11.  
  12.  
  13.   o Is the CHAN arg to $QIO a channel to the device or to QUOTA.SYS?
  14.  
  15. A channel to the device, returned by the $ASSIGN system service.
  16.  
  17.   o Can/should the P1 parameter be Fortran structure type /JIBDEF1/,
  18.      /JIBDEF/, or those UNIONed togather? (i.e. can it be a short JIB,
  19.      and if so how short?)
  20.  
  21. I've used FIBDEF1 in the example below.  If you'll notice, FIBDEF1 has the 
  22. declarations for cntrlfunc and cntrlval in it. Those are all you will need to 
  23. access the quota information.
  24.  
  25.   o Do you need the P2 arg if the JIB$L_CNTRLVAL is set to match all
  26.      group & member UIC's, and if so, what do you put in the the
  27.      DQF$L_UIC field of the quota data block?
  28.  
  29. You need the P2 arg regardless if you are getting one or all of the quota 
  30. records.  Think of the P2 arg as the input block and the P4 arg as the output 
  31. block. In the example below, I've used the same block for input and output, 
  32. since I'm only getting information for 1 user.  If you want to return quota 
  33. records for multiple users, you have to specify the starting UIC in the 
  34. DQF$L_UIC field of the input block.  If you want an example on returning 
  35. multiple records, e-mail me directly, and I'll send you one.
  36.  
  37.   o What value do you put in the 2nd word of the descriptor to the
  38.      JIB & quota block? (e.q. what are "x" and "y" in DSC$K_DTYPE_x
  39.      DCS$K_CLASS_y.  I'm currently trying to use zero for both...)
  40.  
  41. I just declared a structure containing two longwords; 1 for the length, 1 for 
  42. the address of the structure I'm passing.  The DSC$K_DTYPE is the data type, 
  43. the DSC$K_CLASS is the class of the 
  44.  
  45.     ++ Dave
  46.  
  47. Do you have an address dave??
  48.  
  49. - Steve
  50. SHOECRAFT@MC.MARICOPA.EDU
  51. ---------------------------------------------------------------------------
  52. #include <fibdef.h>
  53. #include <iodef.h>
  54. #include <jpidef.h>
  55. #include <psldef.h>
  56.  
  57. #define NEAR_PCT    0.10        /* 10% left or 90% used */
  58.  
  59. main()
  60. {
  61.     struct item_desc {
  62.         long len;
  63.         long addr;
  64.     };
  65.     struct item {
  66.         short len;
  67.         short code;
  68.         long buffer;
  69.         long retlen;
  70.     };
  71.     struct io_status_block {
  72.         short status;
  73.         short count;
  74.         long devdep;
  75.         long more;
  76.     };
  77.     struct quota_transfer_block {
  78.         long dqf$l_flags;
  79.         long dqf$l_uic;
  80.         long dqf$l_usage;
  81.         long dqf$l_permquota;
  82.         long dqf$l_overdraft;
  83.         long reserved[3];
  84.     };
  85.     char *devname = "SYS$DISK", *ptr;
  86.     struct item_desc curdev, fibdesc, qtbdesc;
  87.     struct io_status_block iosb;
  88.     struct fibdef1 fib;
  89.     struct quota_transfer_block qftb;
  90.     unsigned long status, uic, current, max;
  91.     unsigned short io_channel, qftb_len;
  92.     struct {
  93.         struct item uic;
  94.         struct item nullitem;
  95.     } jpi_itmlst = {
  96.         { sizeof(uic),JPI$_UIC,&uic,0 },
  97.         { 0, 0, 0, 0 }
  98.     };
  99.     register int x;
  100.  
  101.     /* Set up the default device descriptor */
  102.     curdev.len = strlen(devname);
  103.     curdev.addr = devname;
  104.  
  105.     /* Assign an IO channel to the default device */
  106.     status = sys$assign(&curdev,&io_channel,PSL$C_USER,0);
  107.     if ( (status & 1) == 0)
  108.         exit(status);
  109.  
  110.     /* Call $GETJPI to get the current user's UIC */
  111.     status = sys$getjpi(0,0,0,&jpi_itmlst,&iosb,0,0);
  112.     if ( (status & 1) == 0 || iosb.status != 1)
  113.         goto abort;
  114.  
  115.     /* Set up the FIB, QTB, and descriptors */
  116.     ptr = &fib;
  117.     for(x=0; x < sizeof(fib); x++) ptr[x] = 0;
  118.     fib.fib$w_cntrlfunc = FIB$C_EXA_QUOTA;
  119.     fibdesc.len = FIB$K_LENGTH;
  120.     fibdesc.addr = &fib;
  121.     qftb.dqf$l_uic = uic;
  122.     qtbdesc.len = sizeof(qftb);
  123.     qtbdesc.addr = &qftb;
  124.     qftb_len = 0;
  125.  
  126.     /* Call $QIO to get the quota info */
  127.     status = sys$qiow(0,io_channel,IO$_ACPCONTROL,&iosb,0,0,
  128.         &fibdesc,&qtbdesc,&qftb_len,&qtbdesc,0,0);
  129.     if ( (status & 1) == 0 || iosb.status != 1)
  130.         goto abort;
  131.  
  132.     current = qftb.dqf$l_usage;
  133.     max = qftb.dqf$l_permquota;
  134.     if (current > max-(max*NEAR_PCT) && current < max)
  135.         near_message();
  136.     else if (current >= max)
  137.         full_message();
  138. abort:
  139.     sys$dassgn(io_channel);
  140.     exit(status);
  141. }
  142.  
  143. near_message()
  144. {
  145.     printf("%c\t%s",7,"WARNING: Your are near to using all of your");
  146.     printf(" disk quota.\n");
  147. }
  148.  
  149. full_message()
  150. {
  151.     printf("%c\t%s",7,"WARNING: You have exhausted your disk quota.");
  152.     printf("  You will need to\n\t  purge or delete files before you");
  153.     printf(" will be able to add new ones.\n\t  Call your System");
  154.     printf(" Manager for information on how to do this.\n");
  155. }
  156.  
  157.