home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / vms / 12925 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  5.7 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!ucbvax!cdclu1.genrad.com!dongray
  2. From: dongray@cdclu1.genrad.com (Derek Dongray)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Can I change quota entries from DCL or a program?
  5. Message-ID: <9207291933.AA06009@genrad.com>
  6. Date: 29 Jul 92 19:33:41 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 165
  11.  
  12. > Does anyone know of a EASY way to read and modify the entries in the QUOTA
  13. > file?
  14. >
  15. > I'm trying to design an application which allows specific users to adjust
  16. > quotas for other users. I'd like to be able to do this without writing SHOW
  17. > QUOTA to a file and then parsing it and generating commands for SYSMAN to
  18. > adjust the quota.
  19. >
  20. > I know that ALL-IN-1 somehow checks your quota - anyone know if it does
  21. > anything fancy besides parsing the output of a SHOW QUOTA or SYSMAN command?
  22. >
  23. > --
  24. > Bob Boag                                BITNET:   boag@marshall
  25. > Senior Software Systems Analyst         Internet: boag@marshall.wvnet.edu
  26. > Marshall University Computer Center     Phone:    (304)696-2624
  27. > Huntington, WV 25755-5320               FAX:      (304)696-3601
  28.  
  29. In SYS$LIBRARY:LIB.MLB is a module $DQFDEF which gives the format records in
  30. QUOTA.SYS. It's fairly easy then to write a program to examine/modify a disk
  31. quota entry. See the disk quota ACP control functions in I/O User's Ref, Part
  32. 1. To examine other users' quota entries requires read access to the QUOTA.SYS.
  33. To change a quota entry, the program must lock the volume (FIB$C_LOCK_VOL) and
  34. unlock when doen (FIB$C_UNLK_VOL); to do this requires either SYSPRV or being
  35. the volume owner.
  36.  
  37. Following my sig is a pascal program to list all disk quotas on the current
  38. disk. Obviously, the requires read access to QUOTA.SYS.
  39.  
  40. --------------------------------------------------------------------------------
  41. Name : Derek Dongray, Systems Manager, GenRad Ltd.
  42. Phone : 061 486 1511 ext 166
  43. PSS : 234261600119::Dongray                 UKnet : Derek.Dongray@GenRad.co.uk
  44. InterNet : Dongray@cdclu1.GenRad.com        CompuServe : 70374,2745
  45. Address : Monmouth House, Monmouth Road, Cheadle Hulme, Cheshire, SK8 7AY, UK.
  46. --------------------------------------------------------------------------------
  47. [inherit('sys$library:starlet')]
  48.  
  49. program examine_quota(output);
  50.  
  51. type
  52.  
  53.     byte_unsigned = [byte] 0..255;
  54.     word_unsigned = [word] 0..65535;
  55.     word_integer  = [word] -32768..32767;
  56.  
  57.     io_status_block    = record
  58.         case integer of
  59.     1:     (condition    : [pos( 0)] word_unsigned;
  60.         transfer_count    : [pos(16)] word_integer;
  61.         terminator    : [pos(32)] word_integer;
  62.         terminator_size : [pos(48)] word_integer);
  63.     2:     (sys_condition    : [pos( 0)] integer;
  64.         device_info    : [pos(32)] unsigned);
  65.     3:     (status        : [pos( 0)] word_unsigned;
  66.         offset_to_term    : [pos(16)] word_integer;
  67.         terminator_char : [pos(32)] char;
  68.         reserved_1    : [pos(40)] byte_unsigned;
  69.         terminator_length : [pos(48)] byte_unsigned;
  70.         cursor_pos_from_eol : [pos(56)] byte_unsigned);
  71.     4:     (transmit_speed    : [pos(16)] byte_unsigned;
  72.         receive_speed    : [pos(24)] byte_unsigned;
  73.         cr_fill_count    : [pos(32)] byte_unsigned;
  74.         lf_fill_count    : [pos(40)] byte_unsigned;
  75.         parity_flags    : [pos(48)] byte_unsigned);
  76.             end;
  77.  
  78. { *** Module $DQFDEF *** }
  79. const
  80.     DQF$M_ACTIVE = 1;
  81.     DQF$K_LENGTH = 32;
  82.     DQF$C_LENGTH = 32;
  83.     DQF$S_DQFDEF = 32;
  84.  
  85. type
  86.     DQF$TYPE = record
  87.             case integer of
  88.         1:(
  89.                 DQF$L_FLAGS : [pos(0)] unsigned);
  90.         2:(
  91.                 DQF$V_ACTIVE : [pos(0),bit] boolean;
  92.                 DQF$L_UIC : [pos(32)] unsigned;
  93.                 DQF$L_USAGE : [pos(64)] unsigned;
  94.                 DQF$L_PERMQUOTA : [pos(96)] unsigned;
  95.                 DQF$L_OVERDRAFT : [pos(128)] unsigned);
  96.             end; {of record DQF$TYPE}
  97.  
  98. {End of Module $DQFDEF}
  99.  
  100. var
  101.     qtfb : dqf$type;
  102.     fib  : fib$type;
  103.     qtfdsc, fibdsc : dsc1$type;
  104.     iosb : io_status_block;
  105.     chan, len : word_unsigned;
  106.     stat : integer;
  107.     nambuf : packed array [1..50] of char;
  108.     uic : record case boolean of
  109.        true: (l : unsigned);
  110.        false: (m: word_unsigned; g:word_unsigned);
  111.           end;
  112.  
  113. procedure lib$stop(code:integer); external;
  114.  
  115. begin
  116.    stat := $assign('sys$disk:',chan);
  117.    if not odd(stat) then lib$stop(stat);
  118.  
  119.    qtfb := zero;
  120.  
  121.    fib::fib1$type.fib$w_cntrlfunc := fib$c_exa_quota;
  122.    fib::fib1$type.fib$l_cntrlval := 0;
  123.  
  124. {  +++
  125.    to examine just one entry, set qtfb.dqf$l_uic to the required UIC and
  126.    omit the following. }
  127.  
  128.    fib::fib1$type.fib$v_all_mem := true;
  129.    fib::fib1$type.fib$v_all_grp := true;
  130.    fib::fib$type.fib$l_wcc := 0;
  131.  
  132. {  --- }
  133.  
  134.    fibdsc := zero;
  135.    fibdsc.dsc$w_maxstrlen := 64 {size (fib1$type)?};
  136.    fibdsc.dsc$a_pointer::unsigned := iaddress(fib);
  137.  
  138.    qtfdsc := zero;
  139.    qtfdsc.dsc$w_maxstrlen := 32 {size (dqf1$type)?};
  140.    qtfdsc.dsc$a_pointer::unsigned := iaddress(qtfb);
  141.  
  142.    stat:= $qiow(chan:=chan,
  143.          func:=io$_acpcontrol,
  144.            iosb:=iosb,
  145.          p1:=%immed iaddress(fibdsc),
  146.          p2:=%immed iaddress(qtfdsc),
  147.          p3:=%immed iaddress(len),
  148.               p4:=%immed iaddress(qtfdsc));
  149.  
  150.    while odd(stat) and odd(iosb.condition) do
  151.    begin
  152.       if not odd($idtoasc(qtfb.dqf$l_uic,len,nambuf)) then
  153.       begin
  154.            uic.l := qtfb.dqf$l_uic::unsigned;
  155.            nambuf := '['+oct(uic.g,6,6)+','+oct(uic.m,6,6)+']';
  156.            len := 15;
  157.       end;
  158.  
  159.       writeln('User :',substr(nambuf,1,len));
  160.       writeln('Usage:',qtfb.dqf$l_usage);
  161.       writeln('Quota:',qtfb.dqf$l_permquota);
  162.       writeln('Overd:',qtfb.dqf$l_overdraft);
  163.  
  164.       stat:= $qiow(chan:=chan,
  165.                     func:=io$_acpcontrol,
  166.                     iosb:=iosb,
  167.                     p1:=%immed iaddress(fibdsc),
  168.                     p2:=%immed iaddress(qtfdsc),
  169.                     p3:=%immed iaddress(len),
  170.                     p4:=%immed iaddress(qtfdsc));
  171.  
  172.    end;
  173.  
  174.    $dassgn(chan);
  175. end.
  176.  
  177.