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.

  • dev is a device number that identifies a device containing a mounted filesystem (like, the device holding the fs, not just any rando device).
  • ubuf is a pointer to a ustat structure, 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 ustat structure that ubuf points to gets filled in. periodt.
  • on error, -1 is returned, and errno is set to tell you what went wrong.

πŸ”₯ ERRORS πŸ”₯

  • EFAULT β€” ubuf points outside of your accessible address space. bestie that pointer is lost. 😭
  • EINVAL β€” dev does not refer to a device containing a mounted filesystem.
  • ENOSYS β€” the mounted filesystem referenced by dev does 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms