w_statfs -- Get File System Status Information


 #include <sys/statfs.h>

 int w_statfs(const char *fileSystem, struct w_statfs *statInfo,
              size_t infoSize);


w_statfs gets file system status information. The following arguments are required:
is the name of the file system for which status information is to be provided. File system names can be obtained by using the w_getmntent function.

is a pointer to a w_statfs structure that is declared in the <sys/statfs.h> header. The following elements of this structure provide file system status information:
int statfs_len
is the size of the w_statfs structure.
int statfs_blksize
is the block size for the file system.
unsigned int statfs_total_space
is the total number of blocks used by the file system.
unsigned int statfs_free_space
is the number of free blocks available to unprivileged users.
specifies the number of bytes of information to be stored. If infoSize is larger than the size of the w_statfs structure, then all of the information is stored; if it is shorter than the structure, then only a portion of the information is stored; and if infoSize is 0, then no information is stored. A value of 0 for infoSize may be used to test whether or not a file system exists.


If successful, w_statfs returns the number of bytes stored. If infoSize is 0, the total number of bytes of information available is returned. A -1 is returned if unsuccessful.


The w_statfs function may be useful in OpenEdition applications; however, it is not defined by the POSIX.1 standard and should not be used in portable applications.


The following example illustrates the use of w_statfs to obtain file system status information:
  #include <sys/types.h>
  #include <sys/statfs.h>
  #include <sys/stat.h>
  #include <string.h>
  #include <stdio.h>

     const char fileSys[] = "POSIX.FILE.SYSTEM";
     char *mountPoint = "/u/userid/dev";
     char *mountType = "HFS     ";
     struct w_statfs workArea;

        /* Initialize work area.               */
     memset(&workArea, 0x00, sizeof(workArea));

        /* Mount file system.                  */
     if (mount(mountPoint, fileSys, mountType, MTM_RDWR, 0, NULL) != 0)
        perror("error mounting file system");

        /* Get file system status information. */
     if (w_statfs(fileSys, &workArea, sizeof(workArea)) == -1)
        perror("w_statfs error");
        printf("Length = %dn", workArea.statfs_len);
        printf("Block Size = %dn", workArea.statfs_blksize);
        printf("Blocks Used = %un", workArea.statfs_total_space);
        printf("Blocks Allocated = %un", workArea.statfs_used_space);
        printf("Free Space = %un", workArea.statfs_free_space);



w_statfs, w_getmntent

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.