getmntent(3) Library Functions Manual getmntent(3) getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r - C (libc, -lc) #include #include FILE *setmntent(const char *filename, const char *type); struct mntent *getmntent(FILE *stream); int addmntent(FILE *restrict stream, const struct mntent *restrict mnt); int endmntent(FILE *streamp); char *hasmntopt(const struct mntent *mnt, const char *opt); /* GNU */ #include struct mntent *getmntent_r(FILE *restrict streamp, struct mntent *restrict mntbuf, char buf[restrict .buflen], int buflen); glibc (. feature_test_macros(7)): getmntent_r(): glibc 2.19: _DEFAULT_SOURCE glibc 2.19 : _BSD_SOURCE || _SVID_SOURCE /etc/fstab /etc/mtab. setmntent() filename , getmntent(). type , mode fclose(3). endmntent(), fclose(3). getmntent() stream , . , getmntent(). addmntent() mnt mntent stream. endmntent() stream, . hashmntopt() mnt_opts ( ) mnt mntent , opt. mount(8). The reentrant getmntent_r() function is similar to getmntent(), but stores the mntent structure in the provided *mntbuf, and stores the strings pointed to by the entries in that structure in the provided array buf of size buflen. mntent : struct mntent { char *mnt_fsname; /* */ char *mnt_dir; /* */ char *mnt_type; /* ( mntent.h) */ char *mnt_opts; /* ( mntent.h) */ int mnt_freq; /* dump, */ int mnt_passno; /* fsck */ }; Since fields in the mtab and fstab files are separated by whitespace, octal escapes are used to represent the characters space (\040), tab (\011), newline (\012), and backslash (\\) in those files when they occur in one of the four strings in a mntent structure. The routines addmntent() and getmntent() will convert from string representation to escaped representation and back. When converting from escaped representation, the sequence \134 is also converted to a backslash. getmntent() getmntent_r() mntent NULL . addmntent() 0 1 . endmntent() 1. hasmntopt() , , NULL. /etc/fstab /etc/mtab attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |setmntent(), endmntent(), | | MT-Safe | |hasmntopt() | | | +----------------------------+----------------------------------------------------------+--------------------------+ |getmntent() | | MT-Unsafe race:mntentbuf | | | | locale | +----------------------------+----------------------------------------------------------+--------------------------+ |addmntent() | | MT-Safe race:stream | | | | locale | +----------------------------+----------------------------------------------------------+--------------------------+ |getmntent_r() | | MT-Safe locale | +----------------------------+----------------------------------------------------------+--------------------------+ . The nonreentrant functions are from SunOS 4.1.3. A routine getmntent_r() was introduced in HP-UX 10, but it returns an int. The prototype shown above is glibc-only. System V also has a getmntent() function but the calling sequence differs, and the returned structure is different. Under System V /etc/mnttab is used. 4.4BSD and Digital UNIX have a routine getmntinfo(), a wrapper around the system call getfsstat(). fopen(3), fstab(5), mount(8) () Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 15 2024 . getmntent(3)