ioctl_fslabel(2)
β¨ ioctl_fslabel β get or set a filesystem label β¨
okay bestie, so this one lives in the System Calls Manual section (that's the (2) on ioctl_fslabel(2), iykyk) π
πΈ LIBRARY πΈ
Standard C library (libc, -lc) β the classic, the icon, the one you already have linked π«Ά
π 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]);
like, two whole flavors of ioctl call, one for reading the label and one for writing it. slay β¨
π¦ DESCRIPTION π¦
so if your filesystem is one of those girlies that supports online label manipulation, these ioctl(2) operations are how you get or set the filesystem label for the filesystem that fd is living on π
the FS_IOC_SETFSLABEL operation requires privilege β specifically CAP_SYS_ADMIN. so no, you can't just waltz in there and rename things without the juice π₯
π« RETURN VALUE π«
- On success, zero is returned. periodt. π
- On error, -1 comes back, and
errnogets set to tell you exactly what went wrong. it's giving "read the error, bestie" π
π ERRORS π
possible errors include (but are not limited to) the following β so don't come for me if you get something else, the list is open-ended fr fr:
EFAULTβlabelreferences an inaccessible memory area. like, that memory said "not today" πEINVALβ the specified label exceeds the maximum label length for the filesystem. too long, girl, trim it βοΈENOTTYβ this can appear if the filesystem does not support online label manipulation. the vibe check failed πEPERMβ the calling process does not have sufficient permissions to set the label. you don't have the clearance, babes π«
π STANDARDS π
Linux. that's it, that's the standard. π
π§ HISTORY π§
- Linux 4.18. β¨
- They were previously known as
BTRFS_IOC_GET_FSLABELandBTRFS_IOC_SETFSLABEL, and were private to Btrfs. glow-up arc complete π¦
π NOTES π
okay this part matters so listen up:
- the maximum string length for this interface is
FSLABEL_MAX, including the terminating null byte ('\0'). - filesystems have differing maximum label lengths, which may or may not include the terminating null. so like, don't assume, every fs has its own rules πΈ
- the string provided to
FS_IOC_SETFSLABELmust always be null-terminated. - the string returned by
FS_IOC_GETFSLABELwill always be null-terminated. she's reliable like that π«Ά
not me being the friend who reminds you about null terminators at 2am π but bestie, the terminator is not optional.
β SEE ALSO β
and that's the whole page, no cap π go forth and label your filesystems, main character π β¨
this was brought to you by Linux man-pages 6.7, dated 2023-10-31 β mwah, kisses, see you in the next man page ππ¦
π¦ where this page comes from
- ubuntu noble: manpages-dev 6.7-2
- π the page's license: GPL-2.0-or-later
- Copyright (c) 2018, Red Hat, Inc. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms