Article 157245 of comp.os.vms:
Yingzhong Wen wrote:

>Hi, folks, 
>
>Does anyone know what's the system call (in C) to check the
>free space on a disk in VMS system? In Unix systems, the
>system call to check free space on a disk is the C function
>statfs or statvfs. I don't know what is the equivalent function
>in VMS systems. 
>
>Thanks for your help.
>
>Yingzhong Wen
>ywen@cs.buffalo.edu

I don't know if there is an equivalent C routine in DEC C. However, the system 
routine $GETDVIW will return gobs of usefull information. Here is an example:

#include <stdlib.h>
#include <stdio.h>
#include <descrip.h>
#include <string.h>
#include <starlet.h>
#include <lib$routines.h>
#include <dvidef.h>

main()
{
  long int Stat = 0,
           i = 0;
  static char DeviceName[255] = { "DKA0:\0" };
  long int FreeBlocks = 0,
           FreeBlocksBytesReturned = 0,
           MaxBlocks = 0;
  struct dsc$descriptor DeviceName_d =
  { 0,
    DSC$K_DTYPE_T,
    DSC$K_CLASS_S,
    DeviceName
  };
  struct
  {
    short int BufLen;
    short int ItemCode;
    long int *BufAddr;
    long int *ReturnLenAddr;
  } DiskInfoItemList[3];

  /* Get Free Blocks */

  DiskInfoItemList[i].BufLen = sizeof(FreeBlocks);
  DiskInfoItemList[i].ItemCode = DVI$_FREEBLOCKS;
  DiskInfoItemList[i].BufAddr = &FreeBlocks;
  DiskInfoItemList[i++].ReturnLenAddr = &FreeBlocksBytesReturned;

  /* Get Total Blocks */

  DiskInfoItemList[i].BufLen = sizeof(MaxBlocks);
  DiskInfoItemList[i].ItemCode = DVI$_MAXBLOCK;
  DiskInfoItemList[i].BufAddr = &MaxBlocks;
  DiskInfoItemList[i++].ReturnLenAddr = 0;

  /* Terminate list */

  DiskInfoItemList[i].BufLen = 0;
  DiskInfoItemList[i].ItemCode = 0;

  /* Set string length since the system doesn't like nulls in device names */

  DeviceName_d.dsc$w_length = strlen(DeviceName);

  Stat = sys$getdviw( 0, 0, &DeviceName_d, &DiskInfoItemList, 0, 0, 0, 0 );
  if ((Stat & 1) != 1) lib$stop(Stat);

  /* Display returned info. Note that the fourth itemlist parameter
     (ReturnLenAddr) will show which items are actually returned     */

  if (FreeBlocksBytesReturned == sizeof(FreeBlocks) )
  {
    printf("Free blocks on device %s -- %d out of %d\n", 
            DeviceName, FreeBlocks, MaxBlocks);
  }
  else
  {
    printf("Error-- bytes returned = %d\n", FreeBlocksBytesReturned );
  }
}

$ cc diskinfo
$ link diskinfo
$ run diskinfo
Free blocks on device DKA0: -- 761613 out of 2050860




