ustat(2)
π ustat(2) β get filesystem statistics π
okay bestie, so this is ustat(2), a real one from the System Calls Manual, and we're gonna talk about it. fair warning: she's deprecated. she's giving legacy. but we still gotta know her, iykyk. π¦
β¨ LIBRARY β¨
Standard C library (libc, -lc). the classic. π
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <unistd.h> /* libc[45] */
#include <ustat.h> /* glibc2 */
[[deprecated]] int ustat(dev_t dev, struct ustat *ubuf);
okay notice the [[deprecated]] right there in the signature?? the compiler is literally side-eyeing you. π
π DESCRIPTION π
so ustat() hands you info about a mounted filesystem. slay, but old.
devis a device number that identifies a device containing a mounted filesystem (like, the device holding the fs, not just any rando device).ubufis a pointer to austatstructure, and that struct has these members:
daddr_t f_tfree; /* Total free blocks */
ino_t f_tinode; /* Number of free inodes */
char f_fname[6]; /* Filsys name */
char f_fpack[6]; /* Filsys pack name */
and here's the tea about the last two fields, f_fname and f_fpack: they are not implemented, like at all. they will always be filled with null bytes ('\0'). so if you were hoping for a cute filesystem name in there... no babe. it's null bytes. it's giving empty. π
π RETURN VALUE π
- on success, zero is returned, and the
ustatstructure thatubufpoints to gets filled in. periodt. - on error,
-1is returned, anderrnois set to tell you what went wrong.
π₯ ERRORS π₯
EFAULTβubufpoints outside of your accessible address space. bestie that pointer is lost. πEINVALβdevdoes not refer to a device containing a mounted filesystem.ENOSYSβ the mounted filesystem referenced bydevdoes not support this operation, or any version of Linux before Linux 1.3.16. yeah, 1.3.16. ancient history. π
π STANDARDS π
None. that's it. no standard claims her. she's free-range. π§
π HISTORY π
SVr4. and then... Removed in glibc 2.28. gone. she left the group chat. π
ustat() is deprecated and has been provided only for compatibility. so real talk: all new programs should use statfs(2) instead. no cap, not a drill, use statfs(2). π
π«Ά HP-UX notes π«Ά
okay so the HP-UX version of the ustat structure has an additional field, f_blksize, that is unknown elsewhere. HP-UX really said "i'll add my own field, it's my world". π
and HP-UX warns: for some filesystems, the number of free inodes does not change. such filesystems will return -1 in the field f_tinode. also, for some filesystems, inodes are dynamically allocated β and such filesystems will return the current number of free inodes. so like, f_tinode is lowkey unpredictable depending on the fs. keep that in mind bestie. β
β SEE ALSO β
okay that's the whole page, you ate it, you understood it. π and for the credits moment: this one came from Linux man-pages 6.20, dated 2026-02-08, so shoutout to the man-pages girlies keeping the lore alive. bye bestie, go call statfs(2) instead. π¦β¨π
π¦ 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