From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  2-JAN-1991 09:55:18.25
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	SYS$DEVICE_SCAN

Received:  by crdgw1.ge.com (5.57/GE 1.80)
	 id AA23364; Wed, 2 Jan 91 09:39:33 EST
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Wed,  2 JAN 91 06:21:49 PST
Received: from HEARN.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.2.2MX) with BSMTP id 8899; Wed, 02 Jan 91 09:15:29 EST
X-Delivery-Notice:  SMTP MAIL FROM does not correspond to sender.
Received: from KUB.NL (S211KENO) by HEARN.BITNET (Mailer R2.07) with BSMTP id
 2538; Wed, 02 Jan 91 15:15:05 MET
Date: Wed, 2 Jan 91 14:55 N
From: Kees Noyens - KUB/DRC <S211KENO%KUB.NL@CUNYVM.CUNY.EDU>
Subject: SYS$DEVICE_SCAN
To: info-vax@kl.sri.com
Message-Id: <DE35BC4CE05F400116@KUB.NL>
X-Envelope-To: info-vax@kl.sri.com
X-Vms-To: IN%"info-vax@kl.sri.com"
Comments: This message was sent with PMDF 3.1

Catherine Nolan <CNOLAN@dragon.cpe.ulowell.edu> writes:

>       I have written a C routine that will return the # of free blocks and
>       the error count on of a specified disk.  What I want to know is how
>       can I, from a C routine, find out all the disks on the current system
>       so that I can return out the # of free blocks etc on all of them.

Here is an example. It calculates the total number of free disk space on
your system and several other things. It requires VMS 5.2 or higher.
Have fun.

Kees Noyens
Computing Centre Tilburg University
The Netherlands

Surfnet : KUBVX1::S211KENO
Bitnet  : S211KENO@HTIKUB5.BITNET
Internet: S211KENO%HTIKUB5.BITNET@CUNYVM.CUNY.EDU

==========================================================================

        PROGRAM DBL
C
C  LINK OPTIONS:
C       LINK dbl,sys$system:sys.stb/sel
C
        IMPLICIT INTEGER*4(A-Z)
        INCLUDE '($DCDEF)'
        INCLUDE '($DVIDEF)'
        INCLUDE '($DVSDEF)'
        INCLUDE '($SSDEF)'
C
        CHARACTER*64 DEVNAM,MEDIANAM
        CHARACTER*12 VOLNAM
        CHARACTER*1  DEVSEA
        INTEGER*4    CLASS,TP,SYS$GETDVIW,OPCNT,MAX,FREE,TOTMAX,TOTFREE
        INTEGER*4    TOTIO,TOTDISK,TOTUSED,USED,VOLNAMLEN,MEDIALEN,HOAV
        INTEGER*4    SYS$DEVICE_SCAN,STATUS,DEVLEN,CONTXT,IOSB(2),NCU
        INTEGER*4    FREEBL,FP,UP,CATCH,MERGE,MEMBER,FAIL,REFCNT
        STRUCTURE /ITMLST/
          UNION
            MAP
              INTEGER*2 BUFLEN
              INTEGER*2 CODE
              INTEGER*4 BUFADR
              INTEGER*4 RETLENADR
            END MAP
            MAP
              INTEGER*4 END_LIST
            END MAP
          END UNION
        END STRUCTURE
        RECORD /ITMLST/ DVI (2)
        RECORD /ITMLST/ GDV (6)
        RECORD /ITMLST/ GDS (7)
        CONTXT          =0
        TOTDISK         =0
        TOTIO           =0
        TOTMAX          =0
        TOTFREE         =0
        DEVSEA          ='*'
        CLASS           =DC$_DISK
        TP              =DT$_RA90
        DVI(1).buflen   =4
        DVI(1).code     =DVS$_DEVCLASS
        DVI(1).bufadr   =%LOC(CLASS)
        DVI(1).retlenadr=%LOC(NCU)
C       DVI(2).buflen   =4
C       DVI(2).code     =DVS$_DEVTYPE
C       DVI(2).bufadr   =%LOC(TP)
C       DVI(2).retlenadr=%LOC(NCU)
        DVI(2).END_LIST =0
        GDS(1).buflen   =4
        GDS(1).code     =DVI$_SHDW_CATCHUP_COPYING
        GDS(1).bufadr   =%LOC(CATCH)
        GDS(2).buflen   =4
        GDS(2).code     =DVI$_SHDW_FAILED_MEMBER
        GDS(2).bufadr   =%LOC(FAIL)
        GDS(3).buflen   =4
        GDS(3).code     =DVI$_SHDW_MEMBER
        GDS(3).bufadr   =%LOC(MEMBER)
        GDS(4).buflen   =4
        GDS(4).code     =DVI$_SHDW_MERGE_COPYING
        GDS(4).bufadr   =%LOC(MERGE)
        GDS(5).buflen   =4
        GDS(5).code     =DVI$_HOST_AVAIL
        GDS(5).bufadr   =%LOC(HOAV)
        GDS(6).buflen   =4
        GDS(6).code     =DVI$_REFCNT
        GDS(6).bufadr   =%LOC(REFCNT)
        GDS(7).end_list =0
        GDV(1).buflen   =4
        GDV(1).code     =DVI$_FREEBLOCKS
        GDV(1).bufadr   =%LOC(FREEBL)
        GDV(2).buflen   =4
        GDV(2).code     =DVI$_MAXBLOCK
        GDV(2).bufadr   =%LOC(MAX)
        GDV(3).buflen   =64
        GDV(3).code     =DVI$_MEDIA_NAME
        GDV(3).bufadr   =%LOC(MEDIANAM)
        GDV(3).retlenadr=%LOC(MEDIALEN)
        GDV(4).buflen   =4
        GDV(4).code     =DVI$_OPCNT
        GDV(4).bufadr   =%LOC(OPCNT)
        GDV(5).buflen   =12
        GDV(5).code     =DVI$_VOLNAM
        GDV(5).bufadr   =%LOC(VOLNAM)
        GDV(5).retlenadr=%LOC(VOLNAMLEN)
        GDV(6).end_list =0
        TYPE *,'   device      label    type  maxblocks  blocks    free',
        1    '  blocks    used    I/O'
        TYPE *,'   ------      -----    ----  ---------  --------------',
        1    '  --------------  -------'
        DO WHILE (.true.)
                MEDIANAM(1:64)=' '
                VOLNAM(1:12)=' '
                DEVNAM(1:64)=' '
                STATUS=SYS$DEVICE_SCAN(DEVNAM,DEVLEN,DEVSEA,DVI,CONTXT)
                IF (STATUS.NE.SS$_NORMAL)GO TO 101
                STATUS=SYS$GETDVIW(,,DEVNAM(:DEVLEN),GDS,,,,)
                IF (STATUS.NE.SS$_NORMAL)GO TO 100
                IF ((.NOT.HOAV).OR.MEMBER.OR.FAIL.OR.CATCH.OR.MERGE.OR.
        1       (REFCNT.EQ.0)) GO TO 100
                STATUS=SYS$GETDVIW(,,DEVNAM(:DEVLEN),GDV,,,,)
                IF (STATUS.NE.SS$_NORMAL)GO TO 100
                IF(MAX.EQ.0) GO TO 100
                TOTDISK=TOTDISK+1
                TOTMAX=TOTMAX+MAX
                TOTFREE=TOTFREE+FREEBL
                TOTIO=TOTIO+OPCNT
                USED=MAX-FREEBL
                FP=100*FREEBL/MAX
                UP=100-FP
                VOLNAM(VOLNAMLEN+1:)=' '
                WRITE(*,10) DEVNAM,VOLNAM,MEDIANAM,MAX,
        1       FREEBL,FP,USED,UP,OPCNT
10              FORMAT(A14,' (',A6,')  ',A6,I9,I9,'  (',I2,'%)  ',
        1       I7,'  (',I2,'%)',I9)
100     END DO
101     CONTINUE
        TOTMAX=TOTMAX*8/15625
        TOTFREE=TOTFREE*8/15625
        TOTUSED=TOTMAX-TOTFREE
        FP=100*TOTFREE/TOTMAX
        UP=100-FP
        TYPE *,' '
        WRITE (*,11) TOTDISK,TOTMAX,TOTFREE,FP,TOTUSED,UP,TOTIO
11      FORMAT('       Totals:            ',I3,I7,' Mb.',I7,' Mb.(',
        1       I2,'%) ',I6,' Mb.(',I2,'%)',I9)
        CALL EXIT(SS$_NORMAL)
        END

