]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/ioctl_iflags.2
mknod.2: tfix
[thirdparty/man-pages.git] / man2 / ioctl_iflags.2
CommitLineData
cfb3e187
MK
1.\" Copyright (c) 2017 by Michael Kerrisk <mtk.manpages@gmail.com>
2.\"
3.\" %%%LICENSE_START(VERBATIM)
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
23.\" %%%LICENSE_END
24.\"
25.\"
a5409de9 26.TH IOCTL_IFLAGS 2 2019-11-19 "Linux" "Linux Programmer's Manual"
cfb3e187
MK
27.SH NAME
28ioctl_iflags \- ioctl() operations for inode flags
29.SH DESCRIPTION
30Various Linux filesystems support the notion of
31.IR "inode flags" \(emattributes
32that modify the semantics of files and directories.
33These flags can be retrieved and modified using two
34.BR ioctl (2)
35operations:
e646a1ba 36.PP
cfb3e187 37.in +4n
b8302363 38.EX
cfb3e187
MK
39int attr;
40fd = open("pathname", ...);
41
42ioctl(fd, FS_IOC_GETFLAGS, &attr); /* Place current flags
43 in \(aqattr\(aq */
44attr |= FS_NOATIME_FL; /* Tweak returned bit mask */
45ioctl(fd, FS_IOC_SETFLAGS, &attr); /* Update flags for inode
46 referred to by \(aqfd\(aq */
b8302363 47.EE
e646a1ba
MK
48.in
49.PP
cfb3e187
MK
50The
51.BR lsattr (1)
52and
53.BR chattr (1)
54shell commands provide interfaces to these two operations,
55allowing a user to view and modify the inode flags associated with a file.
e646a1ba 56.PP
cfb3e187
MK
57The following flags are supported
58(shown along with the corresponding letter used to indicate the flag by
59.BR lsattr (1)
60and
61.BR chattr (1)):
62.TP
63.BR FS_APPEND_FL " \(aqa\(aq"
64The file can be opened only with the
65.B O_APPEND
66flag.
67(This restriction applies even to the superuser.)
68Only a privileged process
69.RB ( CAP_LINUX_IMMUTABLE )
70can set or clear this attribute.
71.TP
72.BR FS_COMPR_FL " \(aqc\(aq"
73Store the file in a compressed format on disk.
74This flag is
75.I not
76supported by most of the mainstream filesystem implementations;
77one exception is
78.BR btrfs (5).
79.TP
80.BR FS_DIRSYNC_FL " \(aqD\(aq (since Linux 2.6.0)"
81Write directory changes synchronously to disk.
82This flag provides semantics equivalent to the
83.BR mount (2)
84.B MS_DIRSYNC
85option, but on a per-directory basis.
86This flag can be applied only to directories.
87.\" .TP
88.\" .BR FS_EXTENT_FL " \(aqe\(aq"
89.\" FIXME Some support on ext4? (EXT4_EXTENTS_FL)
90.TP
91.BR FS_IMMUTABLE_FL " \(aqi\(aq"
92The file is immutable:
93no changes are permitted to the file contents or metadata
94(permissions, timestamps, ownership, link count and so on).
95(This restriction applies even to the superuser.)
96Only a privileged process
97.RB ( CAP_LINUX_IMMUTABLE )
98can set or clear this attribute.
99.TP
100.BR FS_JOURNAL_DATA_FL " \(aqj\(aq"
101Enable journaling of file data on
102.BR ext3 (5)
103and
104.BR ext4 (5)
105filesystems.
106On a filesystem that is journaling in
107.I ordered
108or
109.I writeback
110mode, a privileged
111.RB ( CAP_SYS_RESOURCE )
112process can set this flag to enable journaling of data updates on
113a per-file basis.
114.TP
115.BR FS_NOATIME_FL " \(aqA\(aq"
116Don't update the file last access time when the file is accessed.
117This can provide I/O performance benefits for applications that do not care
118about the accuracy of this timestamp.
119This flag provides functionality similar to the
120.BR mount (2)
121.BR MS_NOATIME
122flag, but on a per-file basis.
123.\" .TP
124.\" .BR FS_NOCOMP_FL " \(aq\(aq"
125.\" FIXME Support for FS_NOCOMP_FL on Btrfs?
126.TP
127.BR FS_NOCOW_FL " \(aqC\(aq (since Linux 2.6.39)"
128The file will not be subject to copy-on-write updates.
129This flag has an effect only on filesystems that support copy-on-write
130semantics, such as Btrfs.
131See
132.BR chattr (1)
133and
134.BR btrfs (5).
135.TP
136.BR FS_NODUMP_FL " \(aqd\(aq"
137Don't include this file in backups made using
138.BR dump (8).
139.TP
140.BR FS_NOTAIL_FL " \(aqt\(aq"
141This flag is supported only on Reiserfs.
142It disables the Reiserfs tail-packing feature,
143which tries to pack small files (and the final fragment of larger files)
144into the same disk block as the file metadata.
145.TP
c7fc938f
MK
146.BR FS_PROJINHERIT_FL " \(aqP\(aq (since Linux 4.5)"
147.\" commit 040cb3786d9b25293b8b0b05b90da0f871e1eb9b
148.\" Flag name was added in Linux 4.4
ba71223d 149.\" FIXME Not currently supported because not in FS_FL_USER_MODIFIABLE?
c7fc938f
MK
150Inherit the quota project ID.
151Files and subdirectories will inherit the project ID of the directory.
152This flag can be applied only to directories.
153.TP
cfb3e187
MK
154.BR FS_SECRM_FL " \(aqs\(aq"
155Mark the file for secure deletion.
156This feature is not implemented by any filesystem,
157since the task of securely erasing a file from a recording medium
158is surprisingly difficult.
159.TP
160.BR FS_SYNC_FL " \(aqS\(aq"
161Make file updates synchronous.
162For files, this makes all writes synchronous
163(as though all opens of the file were with the
164.BR O_SYNC
165flag).
166For directories, this has the same effect as the
167.BR FS_DIRSYNC_FL
168flag.
169.TP
170.BR FS_TOPDIR_FL " \(aqT\(aq"
171Mark a directory for special treatment under the Orlov block-allocation
172strategy.
173See
174.BR chattr (1)
175for details.
176This flag can be applied only to directories and
177has an effect only for ext2, ext3, and ext4.
178.TP
179.BR FS_UNRM_FL " \(aqu\(aq"
180Allow the file to be undeleted if it is deleted.
181This feature is not implemented by any filesystem,
182since it is possible to implement file-recovery mechanisms outside the kernel.
183.PP
184In most cases,
185when any of the above flags is set on a directory,
186the flag is inherited by files and subdirectories
187created inside that directory.
188Exceptions include
189.BR FS_TOPDIR_FL ,
190which is not inheritable, and
191.BR FS_DIRSYNC_FL ,
192which is inherited only by subdirectories.
1172adfa
MK
193.SH CONFORMING TO
194Inode flags are a nonstandard Linux extension.
cfb3e187
MK
195.SH NOTES
196In order to change the inode flags of a file using the
197.BR FS_IOC_SETFLAGS
198operation,
199the effective user ID of the caller must match the owner of the file,
200or the caller must have the
201.BR CAP_FOWNER
202capability.
1373b981
MK
203.PP
204The type of the argument given to the
205.BR FS_IOC_GETFLAGS
206and
207.BR FS_IOC_SETFLAGS
208operations is
209.IR "int\ *" ,
210notwithstanding the implication in the kernel source file
211.I include/uapi/linux/fs.h
212that the argument is
213.IR "long\ *" .
cfb3e187
MK
214.SH SEE ALSO
215.BR chattr (1),
216.BR lsattr (1),
217.BR mount (2),
218.BR btrfs (5),
219.BR ext4 (5),
220.BR xfs (5),
221.BR xattr (7),
222.BR mount (8)