FS_IOC_SETFSLABEL(2const)

✨ FS_IOC_SETFSLABEL πŸ’…

okay bestie, so this is a page from the Linux man-pages, and the manual it lives in is FS_IOC_SETFSLABEL(2const) β€” yes the 2const is a whole vibe, we love a section suffix. sit down, hydrate, and let's talk about naming your filesystem like it's your notes app 🌸


🌈 NAME

FS_IOC_GETFSLABEL, FS_IOC_SETFSLABEL β€” get or set a filesystem label 🏷️


πŸŽ€ LIBRARY

Standard C library (libc, -lc) 🫢


⭐ SYNOPSIS

#include <linux/fs.h>  /* Definition of *FSLABEL* constants */
#include <sys/ioctl.h>

int ioctl(int fd, FS_IOC_GETFSLABEL, char label[FSLABEL_MAX]);
int ioctl(int fd, FS_IOC_SETFSLABEL, char label[FSLABEL_MAX]);

not me including sys/ioctl.h and linux/fs.h β€” yeah girl you need both, the *FSLABEL* constants live in the second one πŸ’–


πŸ¦‹ DESCRIPTION

so if a filesystem supports online label manipulation (key words: online, meaning you don't gotta unmount anything, we love low-effort slay), you can use these ioctl(2) operations to get or set the filesystem label for the filesystem that fd lives on.

FS_IOC_SETFSLABEL is not for the girlies without clearance tho β€” it requires privilege, specifically CAP_SYS_ADMIN πŸ‘‘

basically: reading your label is free, changing it needs the keys to the kingdom. periodt.

πŸ’œ RETURN VALUE

  • On success, zero is returned ✨
  • On error, -1 is returned, and errno gets set to tell you what went wrong 😭

πŸ™ˆ ERRORS

possible errors include (but are not limited to) the following β€” so like, don't come for me if you get a weird one:

  • EFAULT β€” label references an inaccessible memory area 😡 (your pointer said "trust me" and lied)
  • EINVAL β€” the specified label exceeds the maximum label length for the filesystem πŸ“ too long, bestie, it won't fit
  • ENOTTY β€” this can appear if the filesystem does not support online label manipulation 🚫 tier: this filesystem said "no πŸ’…"
  • EPERM β€” the calling process does not have sufficient permissions to set the label πŸ”’ (see: CAP_SYS_ADMIN, or rather, your lack thereof)

🌸 STANDARDS

Linux. that's it. that's the standard. iykyk 🐧


πŸ’€ HISTORY

Linux 4.18. ✨

they were previously known as BTRFS_IOC_GET_FSLABEL and BTRFS_IOC_SET_FSLABEL and were private to Btrfs β€” so yeah, they got a glow-up, went public, changed their names. main character arc fr fr πŸ‘‘


πŸ”₯ NOTES

okay this part matters, listen up:

  • the maximum string length for this interface is FSLABEL_MAX, and that count includes the terminating null byte ('\0') 🫢
  • filesystems have differing maximum label lengths, and those may or may not include the terminating null β€” so like, it's giving inconsistent, no cap
  • the string you hand to FS_IOC_SETFSLABEL must always be null-terminated ⚠️
  • the string returned by FS_IOC_GETFSLABEL will always be null-terminated βœ…
bestie if you forget the '\0' on the set side you're gonna have a bad time. that's not me being dramatic, that's just the interface.

πŸ’– SEE ALSO


that's the whole page, you ate it πŸ“ go label something responsibly, and remember: CAP_SYS_ADMIN or it's a no from the kernel πŸ‘‘

this has been Linux man-pages 6.20, dated 2026-02-08, page FS_IOC_SETFSLABEL(2const) β€” mwah, ily, bye πŸ’…βœ¨

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