---
name: "FS_IOC_GETFLAGS"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/FS_IOC_SETFLAGS"
---

# FS\_IOC\_GETFLAGS(2const)

ioctl() operations for inode flags

Part of [FS\_IOC\_SETFLAGS(2const)](/FS_IOC_SETFLAGS/2const.md).

## NAME

FS\_IOC\_GETFLAGS, FS\_IOC\_SETFLAGS - ioctl() operations for inode flags

## SYNOPSIS

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

**int ioctl(int** *fd***, FS\_IOC\_GETFLAGS, int \****attr***);** **int ioctl(int** *fd***, FS\_IOC\_SETFLAGS, const int \****attr***);**

## DESCRIPTION

Various Linux filesystems support the notion of *inode flags*—attributes that modify the semantics of files and directories. These flags can be retrieved and modified using two [**ioctl**(2)](/ioctl/2.md) operations:

```
int attr;
fd = open("pathname", ...);
ioctl(fd, FS_IOC_GETFLAGS, &attr);  /* Place current flags
                                       in 'attr' */
attr |= FS_NOATIME_FL;              /* Tweak returned bit mask */
ioctl(fd, FS_IOC_SETFLAGS, &attr);  /* Update flags for inode
                                       referred to by 'fd' */
```

The [**lsattr**(1)](/lsattr/1.md) and [**chattr**(1)](/chattr/1.md) shell commands provide interfaces to these two operations, allowing a user to view and modify the inode flags associated with a file.

The following flags are supported (shown along with the corresponding letter used to indicate the flag by [**lsattr**(1)](/lsattr/1.md) and [**chattr**(1)](/chattr/1.md)):

- **FS\_APPEND\_FL** 'a'

  The file can be opened only with the **O\_APPEND** flag. If applied to a directory, forbids removing files from the directory (via **unlink**(), **rename**(), and the like). (This restriction applies even to the superuser.) Only a privileged process (**CAP\_LINUX\_IMMUTABLE**) can set or clear this attribute.

- **FS\_COMPR\_FL** 'c'

  Store the file in a compressed format on disk. This flag is *not* supported by most of the mainstream filesystem implementations; one exception is [**btrfs**(5)](/btrfs/5.md).

- **FS\_DIRSYNC\_FL** 'D' (since Linux 2.6.0)

  Write directory changes synchronously to disk. This flag provides semantics equivalent to the [**mount**(2)](/mount/2.md) **MS\_DIRSYNC** option, but on a per-directory basis. This flag can be applied only to directories.

- **FS\_IMMUTABLE\_FL** 'i'

  The file is immutable: no changes are permitted to the file contents or metadata (permissions, timestamps, ownership, link count, and so on). (This restriction applies even to the superuser.) Only a privileged process (**CAP\_LINUX\_IMMUTABLE**) can set or clear this attribute.

- **FS\_JOURNAL\_DATA\_FL** 'j'

  Enable journaling of file data on [**ext3**(5)](/ext3/5.md) and [**ext4**(5)](/ext4/5.md) filesystems. On a filesystem that is journaling in *ordered* or *writeback* mode, a privileged (**CAP\_SYS\_RESOURCE**) process can set this flag to enable journaling of data updates on a per-file basis.

- **FS\_NOATIME\_FL** 'A'

  Don't update the file last access time when the file is accessed. This can provide I/O performance benefits for applications that do not care about the accuracy of this timestamp. This flag provides functionality similar to the [**mount**(2)](/mount/2.md) **MS\_NOATIME** flag, but on a per-file basis.

- **FS\_NOCOW\_FL** 'C' (since Linux 2.6.39)

  The file will not be subject to copy-on-write updates. This flag has an effect only on filesystems that support copy-on-write semantics, such as Btrfs. See [**chattr**(1)](/chattr/1.md) and [**btrfs**(5)](/btrfs/5.md).

- **FS\_NODUMP\_FL** 'd'

  Don't include this file in backups made using [**dump**(8)](/dump/8.md).

- **FS\_NOTAIL\_FL** 't'

  This flag is supported only on Reiserfs. It disables the Reiserfs tail-packing feature, which tries to pack small files (and the final fragment of larger files) into the same disk block as the file metadata.

- **FS\_PROJINHERIT\_FL** 'P' (since Linux 4.5)

  Inherit the quota project ID. Files and subdirectories will inherit the project ID of the directory. This flag can be applied only to directories.

- **FS\_SECRM\_FL** 's'

  Mark the file for secure deletion. This feature is not implemented by any filesystem, since the task of securely erasing a file from a recording medium is surprisingly difficult.

- **FS\_SYNC\_FL** 'S'

  Make file updates synchronous. For files, this makes all writes synchronous (as though all opens of the file were with the **O\_SYNC** flag). For directories, this has the same effect as the **FS\_DIRSYNC\_FL** flag.

- **FS\_TOPDIR\_FL** 'T'

  Mark a directory for special treatment under the Orlov block-allocation strategy. See [**chattr**(1)](/chattr/1.md) for details. This flag can be applied only to directories and has an effect only for ext2, ext3, and ext4.

- **FS\_UNRM\_FL** 'u'

  Allow the file to be undeleted if it is deleted. This feature is not implemented by any filesystem, since it is possible to implement file-recovery mechanisms outside the kernel.

In most cases, when any of the above flags is set on a directory, the flag is inherited by files and subdirectories created inside that directory. Exceptions include **FS\_TOPDIR\_FL**, which is not inheritable, and **FS\_DIRSYNC\_FL**, which is inherited only by subdirectories.

## STANDARDS

Linux.

## NOTES

In order to change the inode flags of a file using the **FS\_IOC\_SETFLAGS** operation, the effective user ID of the caller must match the owner of the file, or the caller must have the **CAP\_FOWNER** capability.

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**chattr**(1)](/chattr/1.md), [**lsattr**(1)](/lsattr/1.md), [**mount**(2)](/mount/2.md), [**btrfs**(5)](/btrfs/5.md), [**ext4**(5)](/ext4/5.md), [**xfs**(5)](/xfs/5.md), [**xattr**(7)](/xattr/7.md), [**mount**(8)](/mount/8.md)
