From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 16-FEB-1991 13:33:15.23
To:	ARISIA::EVERHART
CC:	
Subj:	Re: Checking Disk quota inside program

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.83)
	 id AA24137; Sat, 16 Feb 91 13:24:14 EST
Received: From DANPOST.UNI-C.DK by CRVAX.SRI.COM with TCP; Sat, 16 FEB 91 10:07:21 PST
Received: from vms2.uni-c.dk by danpost.uni-c.dk (5.65/4.7)
	id AA21417; Sat, 16 Feb 91 18:06:23 GMT
Date: Sat, 16 Feb 91 19:08 +0100
From: ISIS08@ecostat.aau.dk
Subject: Re: Checking Disk quota inside program
To: wuarchive!rex!convex1.tcs.tulane.edu!nayakcp@EDDIE.MIT.EDU,
        NAYAKCP@CONVEX1.TCS.TULANE.EDU, INFO-VAX@SRI.COM
Message-Id: <BAB5F208763F020086@vms2.uni-c.dk>
X-Envelope-To: NAYAKCP@CONVEX1.TCS.TULANE.EDU,
 wuarchive!rex!convex1.tcs.tulane.edu!nayakcp@EDDIE.MIT.EDU, INFO-VAX@SRI.COM
X-Vms-To: 
 UNIL63::IN%"wuarchive!rex!convex1.tcs.tulane.edu!nayakcp@EDDIE.MIT.EDU"
X-Vms-Cc: IN::"NAYAKCP@CONVEX1.TCS.TULANE.EDU",IN::"INFO-VAX@SRI.COM"

> Is there a way to check disk quota from within a running program or at vms
> level and provide a warning if available space is too low.
> 
> What I want is the following:
> 
> 	1. From a command procedure (.com file), check the size of the
> 	last created file.
> 
> 	2. If currant disk space is lower than this file size, issue a warning
> 	about disk space and allow user to stop the process gracefully or
> 	swith to another disk by changing sys$disk interactively or some such
> 	means.

The following MACRO routine will return the users diskquota and diskusage
on the specified disk:

        .title  sys
;
; content : SYS-routines
;
; author  : Arne Vajhxj (june 1989)
;
        .library "SYS$LIBRARY:LIB"
        $SSDEF
        $JPIDEF
        $FIBDEF
        $IODEF
        $DQFDEF
;
; readonly data section
;
        .psect  $PDATA long,pic,con,lcl,shr,noexe,nowrt
argl_getjpi:                            ; argumentlist SYS$GETJPIW
        .long   7
        .long   0                       ; efn
        .long   0                       ; pid-address
        .long   0                       ; process-name
        .address jobinf                 ; item-list
        .long   0                       ; iosb
        .long   0                       ; ast-address
        .long   0                       ; ast-parameter
fibdes: .long   32
        .address fibblk
quodes: .long   32
        .address quoblk
;
; writeread data section
;
        .psect  $LOCAL long,pic,con,lcl,noshr,noexe,wrt
argl_assign:                            ; argumentlist SYS$ASSIGN
        .long   4
        .blkl   1                       ; device-name
        .address argl_qio+8             ; channel
        .long   0                       ; access-mode
        .long   0                       ; nailbox-name
argl_qio:                               ; argumentlist SYS$QIOW
        .long   12
        .long   0                       ; efn
        .blkl   1                       ; channel
        .blkl   1                       ; function
        .long   0                       ; iosb
        .long   0                       ; ast-address
        .long   0                       ; ast-parameter
        .blkl   1                       ; p1
        .blkl   1                       ; p2
        .blkl   1                       ; p3
        .blkl   1                       ; p4
        .long   0                       ; p5
        .long   0                       ; p6
argl_dassgn:                            ; argumentlist SYS$DASSGN
        .long   1
        .blkl   1                       ; channel
jobinf: .blkw   1
        .blkw   1
        .blkl   1
        .blkl   1
        .long   0
fibblk: .blkb   32
quoblk: .blkl   8
len:    .blkw   1
;
; code section
;
        .psect  $CODE long,pic,con,lcl,shr,exe,nowrt
;********************
;
;  SYS_QUOTA ( DISK , QUOTA , USAGE )
;
;  find diskquota and diskusage
;
;********************
        .entry  sys_quota,^m<iv>
        movw    #4,jobinf
        moval   quoblk+DQF$L_UIC,jobinf+4
        movl    #0,jobinf+8
        movw    #JPI$_UIC,jobinf+2
        callg   argl_getjpi,G^SYS$GETJPIW; get pid
        movl    B^4(ap),argl_assign+4
        callg   argl_assign,G^SYS$ASSIGN ; assign disk
        movw    #IO$_ACPCONTROL,argl_qio+12
        moval   fibdes,argl_qio+28
        moval   quodes,argl_qio+32
        moval   len,argl_qio+36
        moval   quodes,argl_qio+40
        movw    #FIB$C_EXA_QUOTA,fibblk+FIB$W_CNTRLFUNC
        callg   argl_qio,G^SYS$QIOW      ; get quota-information
        movl    quoblk+DQF$L_PERMQUOTA,@B^8(ap)
        movl    quoblk+DQF$L_USAGE,@B^12(ap)
        movl    argl_qio+8,argl_dassgn+4
        callg   argl_dassgn,G^SYS$DASSGN ; deassign disk
        ret
        .end

The following FORTRAN program illustrates how to use the routine to
get the number of free diskquota on current disk and put it in a DCL-symbol:

      PROGRAM CHECK
      INTEGER*4 QUOTA,USAGE
      CHARACTER*8 FREESTR
      CALL SYS_QUOTA('SYS$DISK',QUOTA,USAGE)
      WRITE(FREESTR,'(I8)') (QUOTA-USAGE)
      CALL LIB$SET_SYMBOL('FREEBLOCK',FREESTR)
      END

The use of the symbol at the DCL-level should be easy (remember to
use f$integer to convert the string to integer).

Hope this helps you.

                                                               Arne

Arne Vajhxj                             Internet: ISIS08@ECOSTAT.AAU.DK
Institute of Economics and Statistics   PSI:      DATAPAX.23830211371400::ISIS08
Aarhus University
Denmark


