.TITLE DISKSPACE - Get free disk space data for OVERLORD .IDENT /V03.00/ ; ; Author: Chris Chaundy ; Date: 30-Jun-1981 ; Update: 25-Nov-1982 (VAX/VMS V3, plus 'safety' features) ; ; For every mounted FILES-11 disk on the system, provide the calling ; program with the name, type and number of free blocks on the disk. ; ; Calling sequence: ; ; status = DISKSPACE (maxnum, number, diskname, disktype, freeblks) ; ; Inputs: ; maxnum - maximum number of disk units to be handled ; ; Outputs: ; status - return status code ; number - number of mounted FILES-11 disks found ; diskname - buffer to hold generic names of disks ; disktype - type of disk (to judge minimum safe space) ; freeblks - number of free blocks on the disk ; ; Side-effects: ; none ;- ; Equated Symbols $DDBDEF ; Device data block defns $UCBDEF ; Unit control block defns $VCBDEF ; Volume control block defns $SSDEF ; Status code definitions NAME_SIZ = 16 ; Size of generic device name MAXNUM = 4 ; Argument offsets NUMBER = 8 DISKNAME = 12 DISKTYPE = 16 FREEBLKS = 20 ; Main routine .PSECT DISKSPACE_CODE_,NOWRT,EXE .ENTRY DISKSPACE,0 ; Get into kernel mode so we $CMKRNL_S SCAN_DATA,(AP) ; can do something useful RET SCAN_DATA: .WORD ^M MOVL L^SCH$GL_CURPCB,R4 ; Get our PCB address ;%%% JSB L^SCH$IOLOCKR ; Lock down the I/O data base MOVAL @MAXNUM(AP),R2 ; Get address of max unit count IFRD #4,(R2),5$ ; Check for readability BRW 50$ 5$: CLRL R3 ; Init disk unit count MOVAL L^IOC$GL_DEVLIST-DDB$L_LINK, - R4 ; Get adr of adr of first DDB 10$: MOVL DDB$L_LINK(R4),R4 ; Get address of next DDB BEQL 30$ ; If EQL, done MOVL DDB$L_UCB(R4),R5 ; Get address of first UCB BEQL 10$ ; Skip if no UCB's CMPB UCB$B_DEVCLASS(R5), - #DC$_DISK ; Is device a disk? BNEQ 10$ ; If NEQ no 20$: BBC #DEV$V_MNT, - UCB$L_DEVCHAR(R5),40$ ; Device not mounted BBS #DEV$V_FOR, - UCB$L_DEVCHAR(R5),40$ ; Mounted foreign MULL3 #NAME_SIZ,R3,R0 ; Compute name index PUSHAB @DISKNAME(AP)[R0] ; Compute name buffer address MOVL #NAME_SIZ-1,R0 ; Set buffer size ADDL3 #1,(SP),R1 ; Set buffer address IFNOWRT R0,(R1),50$ ; Check for writability JSB L^IOC$CVT_DEVNAM ; Get the device name MOVB R1,@(SP)+ ; Save name size MOVAB @DISKTYPE(AP)[R3],R2 ; Get adr of disk type storage IFNOWRT #1,(R2),50$ ; Check for writability MOVB UCB$B_DEVTYPE(R5),(R2) ; Save device type MOVL UCB$L_VCB(R5),R6 ; Get address of VCB BEQL 40$ ; If EQL none, dismounted MOVAL @FREEBLKS(AP)[R3],R2 ; Get adr of free block storage IFNOWRT #4,(R2),50$ ; Check for writability MOVL VCB$L_FREE(R6),(R2) ; Get free block count AOBLSS @MAXNUM(AP),R3,40$ ; Bump number of disks found 30$: MOVAL @NUMBER(AP),R2 ; Get address of tape count IFNOWRT #4,(R2),50$ ; Check for writability MOVL R3,(R2) ; Save count of tapes found MOVL #SS$_NORMAL,R0 ; Set success BRB 60$ 40$: MOVL UCB$L_LINK(R5),R5 ; Get address of next UCB BNEQ 20$ ; If NEQ there is one BRW 10$ ; Else, try next device 50$: MOVL #SS$_ACCVIO,R0 ; Show access violation 60$: PUSHR #^M ; Save return status MOVL L^SCH$GL_CURPCB,R4 ; Get our PCB address again ;%%% JSB L^SCH$IOUNLOCK ; Unlock the I/O data base ;%%% SETIPL #0 ; Drop IPL POPR #^M ; Restore status code RET ; .END