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,
-1is returned, anderrnogets 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βlabelreferences 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 fitENOTTYβ 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_SETFSLABELmust always be null-terminated β οΈ - the string returned by
FS_IOC_GETFSLABELwill 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
- Copyright 2018, Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms