getmnt(2)
NAME
getmnt − get information on mounted file systems.
SYNTAX
#include <sys/types.h>
#include <h/mount.h>
getmnt(context, buffer, nbytes)
int *context;
struct fs_data*buffer;
int nbytes;
DESCRIPTION
The getmnt system call retrieves the names and statistics of mounted file systems.
The context argument is the current logical location within the internal system mount table and must be initially set to 0. The nbytes argument defines the size of buffer into which file system information is returned. Buffer sizes must be a multiple of sizeof(struct fs_data) bytes. Larger buffer sizes should be used to allow return of information about multiple file systems.
The number of file systems described by the information placed in buffer is returned by getmount. The context argument is also updated to reflect the current logical location within the system mount table, allowing successive getmounts to retrieve information about all file systems. The context argument is set to 0 when information about all file systems has been retrieved. Errors initialize errno to appropriate diagnostic values and return statuses of -1.
Large size buffers allow information about multiple file systems to be retrieved by a single getmnt. Such information is returned within consecutive buffer locations. The information for each file system is described by the structure fs_data:
struct fs_data {
structfs_data_reqfd_req;/* required data */
u_intfd_spare[113];/* spare */
};/* 2560 bytes */
struct fs_data_req { /* required part for all file systems */
u_int flags; /* how mounted */
u_intmtsize; /* max transfer size in bytes */
u_intotsize; /* optimal transfer size in bytes */
u_intbsize; /* fs block size in bytes for vm code */
u_intfstype; /* see ../h/fs_types.h */
u_intgtot; /* total number of gnodes */
u_intgfree; /* # of free gnodes */
u_intbtot; /* total number of 1K blocks */
u_intbfree; /* # of free 1K blocks */
u_intbfreen; /* user consumable 1K blocks */
u_intpgthresh; /* min size in bytes before paging*/
intuid; /* uid that mounted me */
dev_tdev; /* major/minor of fs */
dev_tpad; /* alignment: dev_t is a short*/
chardevname[MAXPATHLEN + 4]; /* name of dev */
charpath[MAXPATHLEN + 4]; /* name of mount point */
}
DIAGNOSTICS
[EFAULT] Either buffer or context causes an illegal address to be referenced.
[EINVAL] context is invalid or the buffer is too small.