
#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:
sysInfo
w_getmntent function copies a w_mntent structure
into this area for each
file system that is mounted.
infoSize
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.
w_mntent structures contains entries that provide the
following information:
mnt_fsname
w_statfs function to obtain more
information.
mnt_dir
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:
mnth_size
mnth_cur
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.
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.
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.
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
main()
{
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",
bufferArea.fileSysInfo[sysCount].mnt_fsname);
printf("Mount Point = %snn",
bufferArea.fileSysInfo[sysCount].mnt_mountpoint);
}
}
} while (lastSys < 0);
}
mount, w_statfs
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.