📄 getmnt.2
字号:
.\" SCCSID: @(#)getmnt.2 2.3 5/19/87.TH getmnt 2.SH Namegetmnt \- get information about mounted file systems.SH Syntax.B #include <sys/types.h>.br.B #include <sys/param.h>.br.B #include <sys/mount.h>.PP.B getmnt(\fIstart, buffer, nbytes, mode, path\fB).br.B int \fI*start\fB;.br.B struct fs_data \fI*buffer\fB;.br.B int \fInbytes, mode\fB; .br.B char \fI*path\fP;.SH Description.NXR "getmnt system call".NXR "file system" "getting information on mounted"The.PN getmntsystem call retrieves information about mounted file systems..PPThe.I modeargument is one of the following:.PN STAT_ONE ,.PN NOSTAT_ONE ,.PN STAT_MANY ,or.PN NOSTAT_MANY ..PPIf.I modeis.PN STAT_ONEor.PN NOSTAT_ONE ,then.I pathis the name of a single file system for which information is desired,.I startand.I nbytesare ignored,and.I bufferis assumed to be large enough to hold one.PN fs_datastructure..PPIf.I modeis.PN STAT_MANYor.PN NOSTAT_MANY ,then.I pathis ignored.The.I startargument is the current logical location within the internal systemmount table and must be initially set to.PN 0 .The .I startargument is updated to reflect the current logicallocation within the system mount table,allowing successive executions of.PN getmntto retrieve information about all the mounted file systems.The.I nbytesargument defines the size of.IR buffer ,into which the file system information is returned.Buffer sizes must be a multiple of .PN "sizeof(struct fs_data)"bytes.Larger buffer sizes allow information about multiple file systemsto be returned..PPIf.I modeis.PN NOSTAT_ONEor.PN NOSTAT_MANY ,then dynamic.PN fs_datainformation (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..\" The .\" .I start.\" argument is set to 0 when information about all file.\" systems has been retrieved..PPIf.I modeis.PN STAT_ONEor.PN STAT_MANY ,then the file system information in memory is updated.However,if the server of any file system for which information is beingretrieved is down,then these calls will hang until the server responds..PPWhen information about multiple filesystems is returned,it is stored within consecutive .I bufferlocations. The information for each file system is described by the structure.PN fs_data:.EX 0struct 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 */}.EE.SH Return Values.PPUpon successful completion, a value indicating the number of.PN fs_datastructures stored in.I bufferis returned.If the file system is not mounted (\fImode\fR is.PN STAT_ONEor.PN NOSTAT_ONE )or there are no more file systemsin the mount table (\fImode\fR is.PN STAT_MANYor.PN NOSTAT_MANY ),.PN 0is returned.Otherwise,.PN \-1is returned and the global variable.I errnois set to indicate the error..SH Diagnostics.TP 18[ENOTDIR]A component of the path prefix of.I pathis not a directory..TP[EINVAL]Invalid argument..TP[ENAMETOOLONG]The length of a component of.I pathexceeds 255 characters,or the length of.I pathexceeds 1023 characters..TP[ENOENT]The file referred to by.I pathdoes not exist..TP[EACCESS]Search permission is denied for a component of the path prefix of.IR path ..TP[ELOOP]Too many symbolic links were encountered in translating.IR path ..TP[EFAULT]Either.I bufferor.I startcauses an illegal address to be referenced..TP[EIO]An I/O error occurred while reading from the file system..SH See Alsogfsi(5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -