GETFSENT(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… GETFSENT β€” the libc manual page, but make it make sense

okay so bestie, you're in section 3 of the Library Functions Manual (that's the libc one, <fstab.h> territory) and honestly? this whole page is about reading entries out of your file system descriptor file. iconic behaviour, lowkey. let's get into it πŸŽ€


✨ NAME ✨

getfsent, getfsspec, getfsfile, setfsent, endfsent β€” get file system descriptor file entry

like, that's the whole vibe. it grabs you an entry. πŸ“

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” so you already have it, no cap, just link it and go πŸ’–

🫢 SYNOPSIS 🫢

#include <fstab.h>

struct fstab *
getfsent(void);

struct fstab *
getfsspec(const char *spec);

struct fstab *
getfsfile(const char *file);

int
setfsent(void);

void
endfsent(void);

void
setfstab(const char *file);

const char *
getfstab(void);

not me listing all seven of them, every single one, because we do NOT skip functions on this page ✨

πŸ’… DESCRIPTION πŸ’…

so getfsent(), getfsspec(), and getfsfile() each hand you back a pointer to an object β€” and that object has the following structure, containing the broken-out fields of a line in the file system description file, <fstab.h>:

struct fstab {
        char    *fs_spec;       /* block special device name */
        char    *fs_file;       /* file system path prefix */
        char    *fs_vfstype;    /* File system type, ufs, nfs */
        char    *fs_mntops;     /* Mount options ala -o */
        char    *fs_type;       /* FSTAB_* from fs_mntops */
        int     fs_freq;        /* dump frequency, in days */
        int     fs_passno;      /* pass number on parallel fsck */
};

the fields mean exactly what fstab(5) says they mean β€” go read that one, it's the whole lore πŸ¦‹

  • setfsent() opens the file (closing any previously opened file) or rewinds it if it's already open. very "reuse the same handle, bestie" of it.
  • endfsent() closes the file. that's it. that's the function. πŸ’€
  • setfstab() sets the file to be used by subsequent operations. ⚠️ important caveat: the value set by setfstab() does not persist across calls to endfsent(). so don't get attached.
  • getfstab() returns the name of the file that will be used. just the name. a little peek. πŸ‘€

getfsspec() and getfsfile() search the entire file (opening it if necessary) for a matching special file name or file system file name. whole-file scavenger hunt energy πŸ”₯

and for programs wishing to read the entire database, getfsent() reads the next entry (opening the file if necessary). one at a time, like a sensible main character 🌸

also!! all entries in the file with a type field equivalent to FSTAB_XX are ignored. yes, ignored. we don't see them. they're not invited to the group chat πŸ™ˆ

πŸŽ€ RETURN VALUES πŸŽ€

  • getfsent(), getfsspec(), and getfsfile() return a NULL pointer on EOF or error. NULL means "nothing for you, queen". 😭
  • setfsent() returns 0 on failure, 1 on success.
  • endfsent() returns nothing. void. a true minimalist. πŸ’œ

🌈 ENVIRONMENT 🌈

  • PATH_FSTAB β€” if the environment variable PATH_FSTAB is set, all operations are performed against the specified file. but ⚠️ PATH_FSTAB will not be honored if the process environment or memory address space is considered β€œtainted”. (See issetugid(2) for more information.) so if you're tainted? it's giving "we're not doing that". πŸ’€

πŸ“ FILES πŸ“

  • /etc/fstab

πŸ‘‘ SEE ALSO πŸ‘‘

fstab(5) β€” literally the plot, go read it 🫢

⭐ HISTORY ⭐

the lore!! πŸ“œ

  • getfsent() appeared in 4.0BSD
  • endfsent(), getfsfile(), getfsspec(), and setfsent() appeared in 4.3BSD
  • setfstab() and getfstab() appeared in FreeBSD 5.1

generational icons, all of them ✨

πŸ’€ BUGS πŸ’€

okay so THIS is the one you cannot sleep on:

these functions use static data storage. if the data is needed for future use, it should be copied before any subsequent calls overwrite it.

fr fr. it's the same buffer every time. if you stash that pointer and go make another call, your data is GONE and you're gonna be debugging at 2am like 😭. copy it. please. for me. πŸ’–


and that's the page!! brought to you by Debian, dated April 7, 2003 β€” yes, that April 7, 2003, and it's still out here explaining fstab to us all these years later. slay, honestly. πŸ§šβ€β™€οΈπŸŒΈ

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms