Section (2) ioctl_iflags
ioctl_iflags — ioctl() operations for inode flags
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) operations:
int attr; fd = open(pathname, ...); ioctl(fd, FS_IOC_GETFLAGS, &attr); /* Place current flags in _zsingle_quotesz_attr_zsingle_quotesz_ */ attr |= FS_NOATIME_FL; /* Tweak returned bit mask */ ioctl(fd, FS_IOC_SETFLAGS, &attr); /* Update flags for inode referred to by _zsingle_quotesz_fd_zsingle_quotesz_ */
The lsattr(1) and chattr(1) 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) and chattr(1)):
The file can be opened only with the
O_APPENDflag. (This restriction applies even to the superuser.) Only a privileged process (
CAP_LINUX_IMMUTABLE) can set or clear this attribute.
Store the file in a compressed format on disk. This flag is
notsupported by most of the mainstream filesystem implementations; one exception is btrfs(5).
FS_DIRSYNC_FL_zsingle_quotesz_D_zsingle_quotesz_ (since Linux 2.6.0)
Write directory changes synchronously to disk. This flag provides semantics equivalent to the mount(2)
MS_DIRSYNCoption, but on a per-directory basis. This flag can be applied only to directories.
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.
Enable journaling of file data on ext3(5) and ext4(5) filesystems. On a filesystem that is journaling in
writebackmode, a privileged (
CAP_SYS_RESOURCE) process can set this flag to enable journaling of data updates on a per-file basis.
Don_zsingle_quotesz_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)
MS_NOATIMEflag, but on a per-file basis.
FS_NOCOW_FL_zsingle_quotesz_C_zsingle_quotesz_ (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) and btrfs(5).
Don_zsingle_quotesz_t include this file in backups made using dump(8).
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_zsingle_quotesz_P_zsingle_quotesz_ (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.
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.
Make file updates synchronous. For files, this makes all writes synchronous (as though all opens of the file were with the
O_SYNCflag). For directories, this has the same effect as the
Mark a directory for special treatment under the Orlov block-allocation strategy. See chattr(1) for details. This flag can be applied only to directories and has an effect only for ext2, ext3, and ext4.
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
which is inherited only by subdirectories.
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
The type of the argument given to the
FS_IOC_SETFLAGS operations is int *, notwithstanding the
implication in the kernel source file
include/uapi/linux/fs.h that the argument
is long *.
This page is part of release 5.04 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
Copyright (c) 2017 by Michael Kerrisk <mtk.manpagesgmail.com>
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.