kernel - SWAP CACHE part 20/many - add 'cache' and 'noscache' chflags.
[dragonfly.git] / usr.bin / chflags / chflags.1
1 .\"-
2 .\" Copyright (c) 1989, 1990, 1993, 1994
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Institute of Electrical and Electronics Engineers, Inc.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)chflags.1   8.4 (Berkeley) 5/2/95
37 .\" $FreeBSD: src/bin/chflags/chflags.1,v 1.30 2008/03/09 12:10:24 rwatson Exp $
38 .\" $DragonFly: src/usr.bin/chflags/chflags.1,v 1.8 2008/11/12 15:18:26 swildner Exp $
39 .\"
40 .Dd November 11, 2008
41 .Dt CHFLAGS 1
42 .Os
43 .Sh NAME
44 .Nm chflags
45 .Nd change file flags
46 .Sh SYNOPSIS
47 .Nm
48 .Op Fl fhv
49 .Oo
50 .Fl R
51 .Op Fl H | Fl L | Fl P
52 .Oc
53 .Ar flags
54 .Ar
55 .Sh DESCRIPTION
56 The
57 .Nm
58 utility modifies the file flags of the listed files
59 as specified by the
60 .Ar flags
61 operand.
62 .Pp
63 The options are as follows:
64 .Bl -tag -width indent
65 .It Fl f
66 Do not display a diagnostic message if
67 .Nm
68 could not modify the flags for
69 .Va file ,
70 nor modify the exit status to reflect such failures.
71 .It Fl H
72 If the
73 .Fl R
74 option is specified, symbolic links on the command line are followed.
75 (Symbolic links encountered in the tree traversal are not followed.)
76 .It Fl h
77 If the
78 .Ar file
79 is a symbolic link,
80 change the file flags of the link itself rather than the file to which it points.
81 .It Fl L
82 If the
83 .Fl R
84 option is specified, all symbolic links are followed.
85 .It Fl P
86 If the
87 .Fl R
88 option is specified, no symbolic links are followed.
89 This is the default.
90 .It Fl R
91 Change the file flags for the file hierarchies rooted
92 in the files instead of just the files themselves.
93 .It Fl v
94 Cause
95 .Nm
96 to be verbose, showing filenames as the flags are modified.
97 If the
98 .Fl v
99 option is specified more than once, the old and new flags of the file
100 will also be printed, in octal notation.
101 .El
102 .Pp
103 The flags are specified as an octal number or a comma separated list
104 of keywords.
105 The following keywords are currently defined:
106 .Bl -tag -offset indent -width ".Cm nouhistory"
107 .It Cm arch , archived
108 set the archived flag (super-user only)
109 .It Cm opaque
110 set the opaque flag (owner or super-user only)
111 .It Cm nodump
112 set the nodump flag (owner or super-user only)
113 .It Cm noshistory
114 set the system nohistory flag (super-user only)
115 .It Cm nouhistory , nohistory
116 set the user nohistory flag (owner or super-user only)
117 .It Cm sappnd , sappend
118 set the system append-only flag (super-user only)
119 .It Cm schg , schange , simmutable
120 set the system immutable flag (super-user only)
121 .It Cm sunlnk , sunlink
122 set the system undeletable flag (super-user only)
123 .It Cm uappnd , uappend
124 set the user append-only flag (owner or super-user only)
125 .It Cm uchg , uchange , uimmutable
126 set the user immutable flag (owner or super-user only)
127 .It Cm uunlnk , uunlink
128 set the user undeletable flag (owner or super-user only)
129 .It Cm cache , ucache, snocache
130 control the data swapcache (recursive)
131 .El
132 .Pp
133 Putting the letters
134 .Dq Cm no
135 before or removing the letters
136 .Dq Cm no
137 from a keyword causes the flag to be cleared.
138 For example:
139 .Pp
140 .Bl -tag -offset indent -width "nouchg" -compact
141 .It Cm nouchg
142 clear the user immutable flag (owner or super-user only)
143 .It Cm dump
144 clear the nodump flag (owner or super-user only)
145 .El
146 .Pp
147 A few of the octal values include:
148 .Bl -tag -offset indent -width ".Li 10"
149 .It Li 0
150 Clear all file flags.
151 .It Li 1
152 Translates to the
153 .Cm nodump
154 keyword.
155 .It Li 2
156 Translates to the
157 .Cm uchg
158 keyword.
159 .It Li 3
160 Translates to the
161 .Cm uchg , nodump
162 keywords.
163 .It Li 4
164 Translates to the
165 .Cm uappnd
166 keyword.
167 .It Li 10
168 Translates to the
169 .Cm opaque
170 keyword.
171 .It Li 20
172 translates to the
173 .Cm uunlnk
174 keyword.
175 .El
176 .Pp
177 Other combinations of keywords may be placed by using
178 the octets assigned; however, these are the most notable.
179 .Pp
180 Unless the
181 .Fl H ,
182 .Fl L ,
183 or
184 .Fl h
185 options are given,
186 .Nm
187 on a symbolic link always succeeds and has no effect.
188 The
189 .Fl H ,
190 .Fl L
191 and
192 .Fl P
193 options are ignored unless the
194 .Fl R
195 option is specified.
196 In addition, these options override each other and the
197 command's actions are determined by the last one specified.
198 .Pp
199 You can use "ls -lo" to see the flags of existing files.
200 .Pp
201 Note that the ability to change certain flags is dependent
202 on the current kernel
203 .Va securelevel
204 setting.
205 See
206 .Xr security 7
207 for more information on this setting.
208 .Sh SWAPCACHE FLAGS
209 The
210 .Cm [u]cache
211 bit may be set to enable swapcache data caching.
212 The superuser flag,
213 .Cm noscache
214 may be used to disable swapcache data caching and overrides the
215 user flag.
216 .Pp
217 The flag is recursive and need only be set on a top-level directory
218 to automatically apply to the entire subtree, though you may have
219 to refresh the namecache with a dummy
220 .Xr find 1
221 command.
222 You do not have to recursive set the flag with
223 .Nm
224 .Op R
225 and, in fact, we do not recommend it under any circumstances.
226 .Pp
227 If you intend to use swapcache data the
228 .Cm vm.swapcache.use_chflags
229 sysctl determines whether the chflags flags are used or not.
230 If turned off and
231 .Cm vm.swapcache.data_enable
232 is turned on, data caching is turned on globally and the
233 file flags are ignored.
234 If use_chflags is turned on along with data_enable then only
235 subtrees marked cacheable will be swapcached.
236 .Pp
237 You would typically want to enable the cache on /usr, /home, and /bin
238 and disable it for /usr/obj.
239 .Pp
240 This only applies to data caching.  Meta-data caching is universal when
241 enabled.
242 .Sh EXIT STATUS
243 .Ex -std
244 .Sh SEE ALSO
245 .Xr ls 1 ,
246 .Xr chflags 2 ,
247 .Xr stat 2 ,
248 .Xr fts 3 ,
249 .Xr security 7 ,
250 .Xr symlink 7 ,
251 .Xr swapcache 8
252 .Sh HISTORY
253 The
254 .Nm
255 command first appeared in
256 .Bx 4.4 .
257 .Sh BUGS
258 Only a limited number of utilities are
259 .Nm
260 aware.
261 Some of these tools include
262 .Xr ls 1 ,
263 .Xr cp 1 ,
264 .Xr find 1 ,
265 .Xr install 1 ,
266 .Xr dump 8 ,
267 and
268 .Xr restore 8 .
269 In particular a tool which is not currently
270 .Nm
271 aware is the
272 .Xr pax 1
273 utility.