{"id":7048,"date":"2022-12-20T19:34:46","date_gmt":"2022-12-20T22:34:46","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/getmntent-man3\/"},"modified":"2022-12-20T19:34:46","modified_gmt":"2022-12-20T22:34:46","slug":"getmntent-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/getmntent-man3\/","title":{"rendered":"GETMNTENT (man3)"},"content":{"rendered":"<h1 align=\"center\">GETMNTENT<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#FILES\">FILES<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r \u2212 get filesystem descriptor file entry<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <stdio.h> <br \/> #include <mntent.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>FILE *setmntent(const char *<\/b><i>filename<\/i><b>, const char *<\/b><i>type<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>struct mntent *getmntent(FILE *<\/b><i>stream<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int addmntent(FILE *<\/b><i>stream<\/i><b>, const struct mntent *<\/b><i>mnt<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int endmntent(FILE *<\/b><i>streamp<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>char *hasmntopt(const struct mntent *<\/b><i>mnt<\/i><b>, const char *<\/b><i>opt<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">\/* GNU extension bodies\/ usr\/ <b><br \/> #include <mntent.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>struct mntent *getmntent_r(FILE *<\/b><i>streamp<\/i><b>, struct mntent *<\/b><i>mntbuf<\/i><b>, <br \/> char *<\/b><i>buf<\/i><b>, int<\/b> <i>buflen<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:5%; margin-top: 1em\">Feature Test Macro Requirements for glibc (see <b>feature_test_macros<\/b>(7)):<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getmntent_r<\/b>(): <br \/> Since glibc 2.19: <br \/> _DEFAULT_SOURCE <br \/> Glibc 2.19 and earlier: <br \/> _BSD_SOURCE || _SVID_SOURCE<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These routines are used to access the filesystem description file <i>\/etc\/fstab<\/i> and the mounted filesystem description file <i>\/etc\/mtab<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>setmntent<\/b>() function opens the filesystem description file <i>filename<\/i> and returns a file pointer which can be used by <b>getmntent<\/b>(). The argument <i>type<\/i> is the type of access required and can take the same values as the <i>mode<\/i> argument of <b>fopen<\/b>(3). The returned stream should be closed using <b>endmntent<\/b>() rather than <b>fclose<\/b>(3).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>getmntent<\/b>() function reads the next line of the filesystem description file from <i>stream<\/i> and returns a pointer to a structure containing the broken out fields from a line in the file. The pointer points to a static area of memory which is overwritten by subsequent calls to <b>getmntent<\/b>().<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>addmntent<\/b>() function adds the <i>mntent<\/i> structure <i>mnt<\/i> to the end of the open <i>stream<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>endmntent<\/b>() function closes the <i>stream<\/i> associated with the filesystem description file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>hasmntopt<\/b>() function scans the <i>mnt_opts<\/i> field (see below) of the <i>mntent<\/i> structure <i>mnt<\/i> for a substring that matches <i>opt<\/i>. See <i><mntent.h><\/i> and <b>mount<\/b>(8) for valid mount options.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The reentrant <b>getmntent_r<\/b>() function is similar to <b>getmntent<\/b>(), but stores the <i>struct mount<\/i> in the provided <i>*mntbuf<\/i> and stores the strings pointed to by the entries in that struct in the provided array <i>buf<\/i> of size <i>buflen<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mntent<\/i> structure is defined in <i><mntent.h><\/i> as follows:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct mntent { <br \/> char *mnt_fsname; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var name of mounted filesystem bodies\/ usr\/ <br \/> char *mnt_dir; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var filesystem path prefix bodies\/ usr\/ <br \/> char *mnt_type; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var mount type (see mntent.h) bodies\/ usr\/ <br \/> char *mnt_opts; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var mount options (see mntent.h) bodies\/ usr\/ <br \/> int mnt_freq; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var dump frequency in days bodies\/ usr\/ <br \/> int mnt_passno; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var pass number on parallel fsck bodies\/ usr\/ <br \/> };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since fields in the mtab and fstab files are separated by whitespace, octal escapes are used to represent the characters space (\u000040), tab (\u000011), newline (\u000012), and backslash (\\) in those files when they occur in one of the four strings in a <i>mntent<\/i> structure. The routines <b>addmntent<\/b>() and <b>getmntent<\/b>() will convert from string representation to escaped representation and back. When converting from escaped representation, the sequence 134 is also converted to a backslash.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>getmntent<\/b>() and <b>getmntent_r<\/b>() functions return a pointer to the <i>mntent<\/i> structure or NULL on failure.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>addmntent<\/b>() function returns 0 on success and 1 on failure.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>endmntent<\/b>() function always returns 1.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>hasmntopt<\/b>() function returns the address of the substring if a match is found and NULL otherwise.<\/p>\n<h2>FILES <a name=\"FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>\/etc\/fstab<\/i><\/p>\n<p style=\"margin-left:22%;\">filesystem description file<\/p>\n<p style=\"margin-left:11%;\"><i>\/etc\/mtab<\/i><\/p>\n<p style=\"margin-left:22%;\">mounted filesystem description file<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<p align=\"center\" style=\"margin-top: 1em\"><img decoding=\"async\" src=\"grohtml-1660991.png\" alt=\"Image grohtml-1660991.png\"><\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The nonreentrant functions are from SunOS 4.1.3. A routine <b>getmntent_r<\/b>() was introduced in HP-UX 10, but it returns an <i>int<\/i>. The prototype shown above is glibc-only.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">System V also has a <b>getmntent<\/b>() function but the calling sequence differs, and the returned structure is different. Under System V <i>\/etc\/mnttab<\/i> is used. 4.4BSD and Digital UNIX have a routine <b>getmntinfo<\/b>(), a wrapper around the system call <b>getfsstat<\/b>().<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>fopen<\/b>(3), <b>fstab<\/b>(5), <b>mount<\/b>(8)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  getmntent, setmntent, addmntent, endmntent, hasmntopt, getmntent_r \u2212 get filesystem descriptor file entry <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3395,3007],"class_list":["post-7048","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-getmntent","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7048"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7048\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}