]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man2/ioctl_iflags.2
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man2 / ioctl_iflags.2
CommitLineData
cfb3e187
MK
1.\" Copyright (c) 2017 by Michael Kerrisk <mtk.manpages@gmail.com>
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
cfb3e187
MK
4.\"
5.\"
4c1c5274 6.TH ioctl_iflags 2 (date) "Linux man-pages (unreleased)"
cfb3e187
MK
7.SH NAME
8ioctl_iflags \- ioctl() operations for inode flags
9.SH DESCRIPTION
10Various Linux filesystems support the notion of
36546c38 11.IR "inode flags" \[em]attributes
cfb3e187
MK
12that modify the semantics of files and directories.
13These flags can be retrieved and modified using two
14.BR ioctl (2)
15operations:
c6d039a3 16.P
cfb3e187 17.in +4n
b8302363 18.EX
cfb3e187
MK
19int attr;
20fd = open("pathname", ...);
fe5dba13 21\&
cfb3e187 22ioctl(fd, FS_IOC_GETFLAGS, &attr); /* Place current flags
b957f81f 23 in \[aq]attr\[aq] */
cfb3e187
MK
24attr |= FS_NOATIME_FL; /* Tweak returned bit mask */
25ioctl(fd, FS_IOC_SETFLAGS, &attr); /* Update flags for inode
b957f81f 26 referred to by \[aq]fd\[aq] */
b8302363 27.EE
e646a1ba 28.in
c6d039a3 29.P
cfb3e187
MK
30The
31.BR lsattr (1)
32and
33.BR chattr (1)
34shell commands provide interfaces to these two operations,
35allowing a user to view and modify the inode flags associated with a file.
c6d039a3 36.P
cfb3e187
MK
37The following flags are supported
38(shown along with the corresponding letter used to indicate the flag by
39.BR lsattr (1)
40and
41.BR chattr (1)):
42.TP
b957f81f 43.BR FS_APPEND_FL " \[aq]a\[aq]"
cfb3e187
MK
44The file can be opened only with the
45.B O_APPEND
46flag.
47(This restriction applies even to the superuser.)
48Only a privileged process
49.RB ( CAP_LINUX_IMMUTABLE )
50can set or clear this attribute.
51.TP
b957f81f 52.BR FS_COMPR_FL " \[aq]c\[aq]"
cfb3e187
MK
53Store the file in a compressed format on disk.
54This flag is
55.I not
56supported by most of the mainstream filesystem implementations;
57one exception is
58.BR btrfs (5).
59.TP
b957f81f 60.BR FS_DIRSYNC_FL " \[aq]D\[aq] (since Linux 2.6.0)"
cfb3e187
MK
61Write directory changes synchronously to disk.
62This flag provides semantics equivalent to the
63.BR mount (2)
64.B MS_DIRSYNC
65option, but on a per-directory basis.
66This flag can be applied only to directories.
67.\" .TP
b957f81f 68.\" .BR FS_EXTENT_FL " \[aq]e\[aq]"
cfb3e187
MK
69.\" FIXME Some support on ext4? (EXT4_EXTENTS_FL)
70.TP
b957f81f 71.BR FS_IMMUTABLE_FL " \[aq]i\[aq]"
cfb3e187
MK
72The file is immutable:
73no changes are permitted to the file contents or metadata
3ded684c 74(permissions, timestamps, ownership, link count, and so on).
cfb3e187
MK
75(This restriction applies even to the superuser.)
76Only a privileged process
77.RB ( CAP_LINUX_IMMUTABLE )
78can set or clear this attribute.
79.TP
b957f81f 80.BR FS_JOURNAL_DATA_FL " \[aq]j\[aq]"
cfb3e187
MK
81Enable journaling of file data on
82.BR ext3 (5)
83and
84.BR ext4 (5)
85filesystems.
86On a filesystem that is journaling in
87.I ordered
88or
89.I writeback
90mode, a privileged
91.RB ( CAP_SYS_RESOURCE )
92process can set this flag to enable journaling of data updates on
93a per-file basis.
94.TP
b957f81f 95.BR FS_NOATIME_FL " \[aq]A\[aq]"
cfb3e187
MK
96Don't update the file last access time when the file is accessed.
97This can provide I/O performance benefits for applications that do not care
98about the accuracy of this timestamp.
99This flag provides functionality similar to the
100.BR mount (2)
1ae6b2c7 101.B MS_NOATIME
cfb3e187
MK
102flag, but on a per-file basis.
103.\" .TP
b957f81f 104.\" .BR FS_NOCOMP_FL " \[aq]\[aq]"
cfb3e187
MK
105.\" FIXME Support for FS_NOCOMP_FL on Btrfs?
106.TP
b957f81f 107.BR FS_NOCOW_FL " \[aq]C\[aq] (since Linux 2.6.39)"
cfb3e187
MK
108The file will not be subject to copy-on-write updates.
109This flag has an effect only on filesystems that support copy-on-write
110semantics, such as Btrfs.
111See
112.BR chattr (1)
113and
114.BR btrfs (5).
115.TP
b957f81f 116.BR FS_NODUMP_FL " \[aq]d\[aq]"
cfb3e187
MK
117Don't include this file in backups made using
118.BR dump (8).
119.TP
b957f81f 120.BR FS_NOTAIL_FL " \[aq]t\[aq]"
cfb3e187
MK
121This flag is supported only on Reiserfs.
122It disables the Reiserfs tail-packing feature,
123which tries to pack small files (and the final fragment of larger files)
124into the same disk block as the file metadata.
125.TP
b957f81f 126.BR FS_PROJINHERIT_FL " \[aq]P\[aq] (since Linux 4.5)"
c7fc938f
MK
127.\" commit 040cb3786d9b25293b8b0b05b90da0f871e1eb9b
128.\" Flag name was added in Linux 4.4
ba71223d 129.\" FIXME Not currently supported because not in FS_FL_USER_MODIFIABLE?
c7fc938f
MK
130Inherit the quota project ID.
131Files and subdirectories will inherit the project ID of the directory.
132This flag can be applied only to directories.
133.TP
b957f81f 134.BR FS_SECRM_FL " \[aq]s\[aq]"
cfb3e187
MK
135Mark the file for secure deletion.
136This feature is not implemented by any filesystem,
137since the task of securely erasing a file from a recording medium
138is surprisingly difficult.
139.TP
b957f81f 140.BR FS_SYNC_FL " \[aq]S\[aq]"
cfb3e187
MK
141Make file updates synchronous.
142For files, this makes all writes synchronous
143(as though all opens of the file were with the
1ae6b2c7 144.B O_SYNC
cfb3e187
MK
145flag).
146For directories, this has the same effect as the
1ae6b2c7 147.B FS_DIRSYNC_FL
cfb3e187
MK
148flag.
149.TP
b957f81f 150.BR FS_TOPDIR_FL " \[aq]T\[aq]"
cfb3e187
MK
151Mark a directory for special treatment under the Orlov block-allocation
152strategy.
153See
154.BR chattr (1)
155for details.
156This flag can be applied only to directories and
157has an effect only for ext2, ext3, and ext4.
158.TP
b957f81f 159.BR FS_UNRM_FL " \[aq]u\[aq]"
cfb3e187
MK
160Allow the file to be undeleted if it is deleted.
161This feature is not implemented by any filesystem,
162since it is possible to implement file-recovery mechanisms outside the kernel.
c6d039a3 163.P
cfb3e187
MK
164In most cases,
165when any of the above flags is set on a directory,
166the flag is inherited by files and subdirectories
167created inside that directory.
168Exceptions include
169.BR FS_TOPDIR_FL ,
170which is not inheritable, and
171.BR FS_DIRSYNC_FL ,
172which is inherited only by subdirectories.
3113c7f3 173.SH STANDARDS
4131356c 174Linux.
cfb3e187
MK
175.SH NOTES
176In order to change the inode flags of a file using the
1ae6b2c7 177.B FS_IOC_SETFLAGS
cfb3e187
MK
178operation,
179the effective user ID of the caller must match the owner of the file,
180or the caller must have the
1ae6b2c7 181.B CAP_FOWNER
cfb3e187 182capability.
c6d039a3 183.P
1373b981 184The type of the argument given to the
1ae6b2c7 185.B FS_IOC_GETFLAGS
1373b981 186and
1ae6b2c7 187.B FS_IOC_SETFLAGS
1373b981 188operations is
1ae6b2c7 189.IR int\~* ,
1373b981
MK
190notwithstanding the implication in the kernel source file
191.I include/uapi/linux/fs.h
192that the argument is
1ae6b2c7 193.IR long\~* .
cfb3e187
MK
194.SH SEE ALSO
195.BR chattr (1),
196.BR lsattr (1),
197.BR mount (2),
198.BR btrfs (5),
199.BR ext4 (5),
200.BR xfs (5),
201.BR xattr (7),
202.BR mount (8)