---
name: "ioctl_fslabel"
section: "2"
platform: "linux"
package: "manpages-dev"
version: "6.03-2"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/ioctl_fslabel"
---

# ioctl\_fslabel(2)

get or set a filesystem label

## NAME

ioctl\_fslabel - 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\]);**

## DESCRIPTION

If a filesystem supports online label manipulation, these [**ioctl**(2)](/ioctl/2.md) operations can be used to get or set the filesystem label for the filesystem on which *fd* resides. The **FS\_IOC\_SETFSLABEL** operation requires privilege (**CAP\_SYS\_ADMIN**).

## RETURN VALUE

On success zero is returned. On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

Possible errors include (but are not limited to) the following:

- **EFAULT**

  *label* references an inaccessible memory area.

- **EINVAL**

  The specified label exceeds the maximum label length for the filesystem.

- **ENOTTY**

  This can appear if the filesystem does not support online label manipulation.

- **EPERM**

  The calling process does not have sufficient permissions to set the label.

## VERSIONS

These [**ioctl**(2)](/ioctl/2.md) operations first appeared in Linux 4.18. They were previously known as **BTRFS\_IOC\_GET\_FSLABEL** and **BTRFS\_IOC\_SET\_FSLABEL** and were private to Btrfs.

## STANDARDS

This API is Linux-specific.

## NOTES

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. The string provided to **FS\_IOC\_SETFSLABEL** must always be null-terminated, and the string returned by **FS\_IOC\_GETFSLABEL** will always be null-terminated.

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**blkid**(8)](/blkid/8.md)
