![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
| w_statfs | 
| Portability: | SAS/C extension | 
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| PORTABILITY | |
| EXAMPLE | |
| RELATED FUNCTIONS | 
| SYNOPSIS | 
#include <sys/statfs.h>
int w_statfs(const char *fileSystem, struct w_statfs *statInfo,
             size_t infoSize);
| DESCRIPTION | 
w_statfs
 gets file system status information. The following arguments
are required:
fileSystem
w_getmntent
function.
statInfo
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
w_statfs
 structure.
int statfs_blksize
unsigned
int statfs_total_space
unsigned
int statfs_free_space
infoSize
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.
| RETURN VALUE | 
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.
| PORTABILITY | 
The 
w_statfs
 function may be useful in USS applications; however, it is
not defined by the POSIX.1 standard and should not be used in portable applications.
| EXAMPLE | 
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>
  
main()
{
   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");
   else
      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);
}
| RELATED FUNCTIONS | 
![]() Chapter Contents  | 
![]() Previous  | 
![]() Next  | 
![]() Top of Page  | 
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.