getmnt(2)getmnt(2)Namegetmnt - get information about mounted file systems
Syntax
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
getmnt(start, buffer, nbytes, mode, path)
int *start;
struct fs_data *buffer;
int nbytes, mode;
char *path;
Description
The system call retrieves information about mounted file systems.
The mode argument is one of the following: or
If mode is or then path is the name of a single file system for which
information is desired, start and nbytes are ignored, and buffer is
assumed to be large enough to hold one structure.
If mode is or then path is ignored. The start argument is the current
logical location within the internal system mount table and must be
initially set to The start argument is updated to reflect the current
logical location within the system mount table, allowing successive
executions of to retrieve information about all the mounted file sys‐
tems. The nbytes argument defines the size of buffer, into which the
file system information is returned. Buffer sizes must be a multiple
of bytes. Larger buffer sizes allow information about multiple file
systems to be returned.
If mode is or then dynamic information (the number of free inodes and
the number of free blocks) could be out of date, but these calls are
guaranteed to return. The file system information in memory is not
updated.
If mode is or then the file system information in memory is updated.
However, if the server of any file system for which information is
being retrieved is down, then these calls will hang until the server
responds.
When information about multiple file systems is returned, it is stored
within consecutive buffer locations. The information for each file
system is described by the structure
struct fs_data {
struct fs_data_req fd_req; /* required data */
u_int fd_spare[113]; /* spare */
}; /* 2560 bytes */
struct fs_data_req { /* required part for all file systems */
u_int flags; /* how mounted */
u_int mtsize; /* max transfer size in bytes */
u_int otsize; /* optimal transfer size in bytes */
u_int bsize; /* fs block size in bytes for vm code */
u_int fstype; /* see ../h/fs_types.h */
u_int gtot; /* total number of gnodes */
u_int gfree; /* # of free gnodes */
u_int btot; /* total number of 1K blocks */
u_int bfree; /* # of free 1K blocks */
u_int bfreen; /* user consumable 1K blocks */
u_int pgthresh; /* min size in bytes before paging*/
int uid; /* uid that mounted me */
dev_t dev; /* major/minor of fs */
dev_t pad; /* alignment: dev_t is a short*/
char devname[MAXPATHLEN + 4]; /* name of dev */
char path[MAXPATHLEN + 4]; /* name of mount point */
}
Return Values
Upon successful completion, a value indicating the number of structures
stored in buffer is returned. If the file system is not mounted (mode
is or or there are no more file systems in the mount table (mode is or
is returned. Otherwise, is returned and the global variable errno is
set to indicate the error.
Diagnostics
[ENOTDIR] A component of the path prefix of path is not a
directory.
[EINVAL] Invalid argument.
[ENAMETOOLONG] The length of a component of path exceeds 255 charac‐
ters, or the length of path exceeds 1023 characters.
[ENOENT] The file referred to by path does not exist.
[EACCESS] Search permission is denied for a component of the
path prefix of path.
[ELOOP] Too many symbolic links were encountered in translat‐
ing path.
[EFAULT] Either buffer or start causes an illegal address to
be referenced.
[EIO] An I/O error occurred while reading from the file
system.
See Alsogfsi(5)getmnt(2)