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 the fs_spec field matches the special_file argument.
  • getfsfile() β€” searches the file from the start and returns the first entry it finds where the fs_file field 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:fsent
  • getfsent(), 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 β€” while getfsfile() and getfsspec() 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 πŸ”₯

getmntent(3), fstab(5)


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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms