2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH LOCKFS 8 "Jan 2, 2008"
8 lockfs \- change or report file system locks
12 \fB/usr/sbin/lockfs\fR [\fB-adefhnuw\fR] [\fB-c\fR \fIstring\fR] [\fIfile-system\fR]...
18 \fBlockfs\fR is used to change and report the status of file system locks.
19 \fBlockfs\fR reports the lock status and unlocks the file systems that were
20 improperly left locked.
23 Using \fBlockfs\fR to lock a file system is discouraged because this requires
24 extensive knowledge of SunOS internals to be used effectively and correctly.
27 When invoked with no arguments, \fBlockfs\fR lists the \fBUFS\fR file systems
28 that are locked. If \fIfile-system\fR is not specified, and \fB-a\fR is
29 specified, \fBlockfs\fR is run on all mounted, \fBUFS\fR type file systems.
33 The options are mutually exclusive: \fBwndheuf\fR. If you do specify more than
34 one of these options on a \fBlockfs\fR command line, the utility does not
35 protest and invokes only the last option specified. In particular, you cannot
36 specify a flush (\fB-f\fR) and a lock (for example, \fB-w\fR) on the same
37 command line. However, all locking operations implicitly perform a flush, so
38 the \fB-f\fR is superfluous when specifying a lock.
41 You must be super-user to use any of the following options, with the exception
42 of \fB-a\fR, \fB-f\fR and \fB-v\fR.
45 The following options are supported.
53 Apply command to all mounted, \fBUFS\fR type file systems. \fIfile-system\fR is
54 ignored when \fB-a\fR is specified.
60 \fB\fB-c\fR \fIstring\fR\fR
64 Accept a string that is passed as the comment field. The \fB-c\fR only takes
65 affect when the lock is being set using the \fB-d\fR, \fB-h\fR, \fB-n\fR,
66 \fB-u\fR, or \fB-w\fR options.
76 Delete-lock (\fBdlock\fR) the specified \fIfile-system\fR. dlock suspends
77 access that could remove directory entries.
87 Error-lock (\fBelock\fR) the specified \fIfile-system\fR. elock blocks all
88 local access to the locked file system and returns \fBEWOULDBLOCK\fR on all
89 remote access. File systems are elocked by \fBUFS\fR on detection of internal
90 inconsistency. They may only be unlocked after successful repair by \fBfsck\fR,
91 which is usually done automatically (see \fBmount_ufs\fR(8)). elocked file
92 systems can be unmounted.
102 Force a synchronous flush of all data that is dirty at the time \fBfsflush\fR
103 is run to its backing store for the named file system (or for all file
106 It is a more reliable method than using \fBsync\fR(8) because it does not
107 return until all possible data has been pushed. In the case of \fBUFS\fR
108 filesystems with logging enabled, the log is also rolled before returning.
109 Additional data can be modified by the time \fBfsflush\fR exits, so using one
110 of the locking options is more likely to be of general use.
120 Hard-lock (\fBhlock\fR) the specified \fIfile-system\fR. hlock returns an error
121 on every access to the locked file system, and cannot be unlocked. hlocked file
122 systems can be unmounted.
132 Name-lock (\fBnlock\fR) the specified \fIfile-system\fR. nlock suspends
133 accesses that could change or remove existing directories entries.
143 Unlock (\fBulock\fR) the specified \fIfile-system\fR. ulock awakens suspended
154 Enable verbose output.
164 Write-lock (\fBwlock\fR) the specified \fIfile-system\fR. wlock suspends writes
165 that would modify the file system. Access times are not kept while a file
166 system is write-locked.
172 The following operands are supported.
176 \fB\fIfile-system\fR\fR
180 A list of path names separated by whitespace. Note that \fIfile-system\fR can
181 be a directory rather than the specific name of a file system, such as \fB/\fR
182 or \fB/usr\fR. For example, if you specify \fB/export/home\fR as an argument to
183 a \fBlockfs\fR command and \fB/export/home\fR is mounted on the root (\fB/\fR)
184 file system, the \fBlockfs\fR command will take effect on the root file system.
189 \fBExample 1 \fRUsing \fBlockfs\fR \fB-a\fR
192 In the following examples, \fIfilesystem\fR is the pathname of the mounted-on
193 directory (mount point). \fBLocktype\fR is one of "\fBwrite\fR," "\fIname\fR,"
194 "\fIdelete\fR," "\fIhard\fR," or "\fIunlock\fR". When enclosed in parenthesis,
195 the lock is being set. \fBComment\fR is a string set by the process that last
196 issued a lock command.
200 The following example shows the \fBlockfs\fR output when only the \fB-a\fR
206 example# \fB/usr/sbin/lockfs -a\fR
217 Filesystem Locktype Comment
231 \fBExample 2 \fRUsing \fBlockfs\fR \fB-w\fR
234 The following example shows the \fBlockfs\fR output when the \fB-w\fR option is
235 used to write lock the \fB/var\fR file system and the comment string is set
236 using the \fB-c\fR option. The \fB-a\fR option is then specified on a separate
242 example# \fB/usr/sbin/lockfs -w -c "lockfs: write lock example" /var\fR
243 example# \fB/usr/sbin/lockfs -a\fR
254 Filesystem Locktype Comment
256 /var write lockfs: write lock example
268 \fBExample 3 \fRUsing \fBlockfs\fR \fB-u\fR
271 The following example shows the \fBlockfs\fR output when the \fB-u\fR option is
272 used to unlock the \fB/var\fR file system and the comment string is set using
278 example# \fB/usr/sbin/lockfs -uc "lockfs: unlock example" /var\fR
279 example# \fB/usr/sbin/lockfs /var\fR
290 Filesystem Locktype Comment
291 /var unlock lockfs: unlock example
305 \fBkill\fR(1), \fBmount_ufs\fR(8), \fBsync\fR(8), \fBattributes\fR(5),
314 \fB\fIfile system\fR\fB: Not owner\fR\fR
318 You must be root to use this command.
324 \fB\fIfile system\fR \fB:Deadlock condition detected/avoided\fR\fR
328 A file is enabled for accounting or swapping, on \fIfile system\fR.
334 \fB\fIfile system\fR\fB: Device busy\fR\fR
338 Another process is setting the lock on \fIfile system\fR.