getfsent(3)
β¨ getfsent(3) β the fstab whisperer β¨
okay bestie, welcome to getfsent(3), straight out of the Library Functions Manual π this is the girlies who read /etc/fstab for you so you don't have to, and honestly? iconic behaviour.
πΈ NAME πΈ
getfsent, getfsspec, getfsfile, setfsent, endfsent β handle fstab entries π
π LIBRARY π
Standard C library (libc, -lc) π«Ά
π SYNOPSIS π
#include <fstab.h>
int setfsent(void);
struct fstab *getfsent(void);
void endfsent(void);
struct fstab *getfsfile(const char *mount_point);
struct fstab *getfsspec(const char *special_file);
π¦ DESCRIPTION π¦
so these functions read from the file /etc/fstab, no cap. and the struct fstab is defined like this:
struct fstab {
char *fs_spec; /* block device name */
char *fs_file; /* mount point */
char *fs_vfstype; /* filesystem type */
char *fs_mntops; /* mount options */
const char *fs_type; /* rw/rq/ro/sw/xx option */
int fs_freq; /* dump frequency, in days */
int fs_passno; /* pass number on parallel dump */
};
the way that fs_type field is doing the most β on a *BSD system it holds one of these five strings: "rw", "rq", "ro", "sw", "xx". and what do those mean? read-write, read-write with quota, read-only, swap, ignore. periodt. π
setfsent()β opens the file when required and positions it at the first line. main character energy fr.getfsent()β parses the next line from the file. (and yes, it opens the file first when required π)endfsent()β closes the file when required. bye bestie πgetfsspec()β searches the file from the start and returns the first entry it finds where thefs_specfield matches the special_file argument.getfsfile()β searches the file from the start and returns the first entry it finds where thefs_filefield matches the mount_point argument.
π RETURN VALUE π
upon success, getfsent(), getfsfile(), and getfsspec() hand you back a pointer to a struct fstab, while setfsent() returns 1 β slay β¨
upon failure or end-of-file, these functions return NULL and 0, respectively. not slay. π
π ATTRIBUTES π
for an explanation of the terms used in this section, go peek at attributes(7) π
endfsent(),setfsent()β Thread safety:MT-Unsafe race:fsentgetfsent(),getfsspec(),getfsfile()β Thread safety:MT-Unsafe race:fsent locale
π VERSIONS π
several operating systems have these functions, for example *BSD, SunOS, Digital UNIX, and AIX β and AIX also has a getfstype() like okay girl, overachiever π
HP-UX has functions of the same names, except they use a struct checklist instead of a struct fstab, and it calls these functions obsolete, superseded by getmntent(3). oop π
β STANDARDS β
None. literally none. free spirit fr fr.
π°οΈ HISTORY π°οΈ
the getfsent() function appeared in 4.0BSD; the other four functions appeared in 4.3BSD. old ones, but they ate. π
π NOTES π
these functions are not thread-safe. no cap.
since Linux allows mounting a block special device in several places, and since several devices can have the same mount point β where the last device with a given mount point is the interesting one β whilegetfsfile()andgetfsspec()only return the first occurrence, these two functions are not suitable for use under Linux. so like, heads up bestie, this is a whole real limitation, not me being dramatic π«Ά
π₯ SEE ALSO π₯
and that's the whole page, bestie!! π this one's from Linux man-pages 6.20, dated 2026-02-08 β tysm for reading, go mount something responsibly πβ¨π¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2002, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms