sysfs(2)
π sysfs(2) β the manual page, bestie edition
okay so before anything else: this is section 2 of the manual, aka System Calls Manual territory β we're talking actual kernel syscalls here, not your cute little shell commands. buckle up π
β¨ NAME β¨
sysfs β get filesystem type information
like. that's the whole job. it tells you stuff about filesystems. iconic of it honestly.
πΈ SYNOPSIS πΈ
[[deprecated]] int sysfs(int option, const char *fsname);
[[deprecated]] int sysfs(int option, unsigned int fs_index, char *buf);
[[deprecated]] int sysfs(int option);
bestie do you see the [[deprecated]] up there? three times?? THREE TIMES. the compiler is literally screaming at you and it is so right to do so π
π DESCRIPTION π
quick heads up before you spiral: if what you actually want is info about the sysfs filesystem that lives mounted at/sys, that is a completely different page. go readsysfs(5). do not pass go. do not collect $200. π«Ά
so. the (obsolete!!) sysfs() system call hands you information about the filesystem types that are, like, currently present in the kernel. the exact shape of the call and the tea it returns depends entirely on which option you're running:
- translates the filesystem identifier string
fsnameinto a filesystem type index. like a lil name-to-number glow-up β¨ - translates the filesystem type index
fs_indexinto a null-terminated filesystem identifier string. that string gets written into the buffer thatbufpoints at. and please double-check thatbufactually has enough room to hold the string, because it will not be checking for you hun π - returns the total number of filesystem types currently present in the kernel. just the count. the vibe check, numerically.
also super important: the numbering of the filesystem type indexes begins with zero. zero-indexed, as the ancestors intended, no cap. π₯
π RETURN VALUE π
on success, sysfs() gives you:
- the filesystem index for option
1 - zero for option
2 - the number of currently configured filesystems for option
3
on error? it's -1, and errno gets set to tell you what went wrong. classic. π
π¦ ERRORS π¦
EFAULTβ eitherfsnameorbufis outside your accessible address space. you reached into a place you were not invited, bestie πEINVALβfsnameis not a valid filesystem type identifier; orfs_indexis out-of-bounds; oroptionis invalid. basically: bad input, bad index, or a number that doesn't exist. any of the three, we don't judge (we do, a little).
β STANDARDS β
None.
that's it. that's the whole section. none. not a single standard claims this thing. she's ungoverned π
π HISTORY π
SVr4.
and here's the part where I hold your hand: this System-V derived system call is obsolete. don't use it. I'm being so serious right now, this is not a drill, this is the manpage itself saying it. π¨
on systems that have /proc, you can get all this same information through /proc β so use that interface instead, okay? please? for me? π₯Ί
π BUGS π
- there is no libc or glibc support. none. not a crumb. π
- there is no way to guess how large
bufshould be. so good luck sizing that buffer, you're on your own, godspeed π«‘
π§ SEE ALSO π§
okay so that's the whole thing!! go use /proc like a good citizen, stay hydrated, and remember: [[deprecated]] is not a personality trait πβ¨
signing off β this came from Linux man-pages 6.20, dated 2026-02-08, and yeah she's old and deprecated but she's still iconic π
π¦ 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 1995, Thomas K. Dyas <tdyas@eden.rutgers.edu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms