w_getmntent -- Get Mounted File System Information


 #include <sys/mntent.h>

 int w_getmntent(void *sysInfo, int infoSize);


w_getmntent gets information about the mounted file systems and saves that information in w_mntent structures, declared in <sys/mntent.h>. The arguments to w_getmntent are:
is a pointer to a buffer area used to save the file system information. The w_getmntent function copies a w_mntent structure into this area for each file system that is mounted.
specifies the size of the sysInfo buffer area. If you are not sure of the required size, you can specify a 0, which will cause the w_getmntent function to return the number of file systems without actually copying any w_mntent information.
The w_mntent structures contains entries that provide the following information:
is the name of a mounted file system. This name can be up to 45 characters in length and ends with a NULL character. You can use this name with the w_statfs function to obtain more information.
is the null-terminated directory name for the mounted file system.
A w_mnth structure, which is also declared in <sys/mntent.h>, is stored at the beginning to the sysInfo buffer area, before any of the w_mntent structues. The w_mnth structure forms a buffer area header that contains positioning information that is used when multiple calls to w_getmntent are made to store information about several mounted file systems. The following w_mnth entries are used:
is the size in bytes of the buffer area.
is the current position in the buffer area.
The positioning information should be initialized to 0s and should not be changed between calls to the w_getmntent function. Subsequent calls to w_getmntent will append new w_mntent structures to the buffer area. A 0 is returned by w_getmntent after information about the last file system has been written to the buffer area.


If successful, w_getmntent returns the number of w_mntent structures that have been copied to the buffer area. If infoSize was 0, the total number of file systems is returned, but no data are copied. A -1 is returned if w_getmntent is unsuccessful.


The w_getmntent 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_getmntent to obtain information about a mounted file system:
  #include <sys/types.h>
  #include <sys/mntent.h>
  #include <string.h>
  #include <stdio.h>

  #define MAX_FILE_SYS 10

     int lastSys = 0, sysCount;

     struct {
        struct w_mnth header;
        struct w_mntent fileSysInfo[MAX_FILE_SYS];
     } bufferArea;

     memset(&bufferArea, 0, sizeof(bufferArea));

     do {
        lastSys = w_getmntent((char *)
                  &bufferArea, sizeof(bufferArea));
        if (lastSys == -1)
           perror("Error during call to w_getmntent.");
        else {
           for (sysCount = 0; sysCount < lastSys; ++ sysCount) {
              printf("File System = %sn",
              printf("Mount Point = %snn",
     } while (lastSys < 0);



mount, w_statfs

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