'\" te .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved .\" 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. .\" 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. .\" 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] .TH LOCKFS 8 "Jan 2, 2008" .SH NAME lockfs \- change or report file system locks .SH SYNOPSIS .LP .nf \fB/usr/sbin/lockfs\fR [\fB-adefhnuw\fR] [\fB-c\fR \fIstring\fR] [\fIfile-system\fR]... .fi .SH DESCRIPTION .sp .LP \fBlockfs\fR is used to change and report the status of file system locks. \fBlockfs\fR reports the lock status and unlocks the file systems that were improperly left locked. .sp .LP Using \fBlockfs\fR to lock a file system is discouraged because this requires extensive knowledge of SunOS internals to be used effectively and correctly. .sp .LP When invoked with no arguments, \fBlockfs\fR lists the \fBUFS\fR file systems that are locked. If \fIfile-system\fR is not specified, and \fB-a\fR is specified, \fBlockfs\fR is run on all mounted, \fBUFS\fR type file systems. .SH OPTIONS .sp .LP The options are mutually exclusive: \fBwndheuf\fR. If you do specify more than one of these options on a \fBlockfs\fR command line, the utility does not protest and invokes only the last option specified. In particular, you cannot specify a flush (\fB-f\fR) and a lock (for example, \fB-w\fR) on the same command line. However, all locking operations implicitly perform a flush, so the \fB-f\fR is superfluous when specifying a lock. .sp .LP You must be super-user to use any of the following options, with the exception of \fB-a\fR, \fB-f\fR and \fB-v\fR. .sp .LP The following options are supported. .sp .ne 2 .na \fB\fB-a\fR\fR .ad .sp .6 .RS 4n Apply command to all mounted, \fBUFS\fR type file systems. \fIfile-system\fR is ignored when \fB-a\fR is specified. .RE .sp .ne 2 .na \fB\fB-c\fR \fIstring\fR\fR .ad .sp .6 .RS 4n Accept a string that is passed as the comment field. The \fB-c\fR only takes affect when the lock is being set using the \fB-d\fR, \fB-h\fR, \fB-n\fR, \fB-u\fR, or \fB-w\fR options. .RE .sp .ne 2 .na \fB\fB-d\fR\fR .ad .sp .6 .RS 4n Delete-lock (\fBdlock\fR) the specified \fIfile-system\fR. dlock suspends access that could remove directory entries. .RE .sp .ne 2 .na \fB\fB-e\fR\fR .ad .sp .6 .RS 4n Error-lock (\fBelock\fR) the specified \fIfile-system\fR. elock blocks all local access to the locked file system and returns \fBEWOULDBLOCK\fR on all remote access. File systems are elocked by \fBUFS\fR on detection of internal inconsistency. They may only be unlocked after successful repair by \fBfsck\fR, which is usually done automatically (see \fBmount_ufs\fR(8)). elocked file systems can be unmounted. .RE .sp .ne 2 .na \fB\fB-f\fR\fR .ad .sp .6 .RS 4n Force a synchronous flush of all data that is dirty at the time \fBfsflush\fR is run to its backing store for the named file system (or for all file systems.) .sp It is a more reliable method than using \fBsync\fR(8) because it does not return until all possible data has been pushed. In the case of \fBUFS\fR filesystems with logging enabled, the log is also rolled before returning. Additional data can be modified by the time \fBfsflush\fR exits, so using one of the locking options is more likely to be of general use. .RE .sp .ne 2 .na \fB\fB-h\fR\fR .ad .sp .6 .RS 4n Hard-lock (\fBhlock\fR) the specified \fIfile-system\fR. hlock returns an error on every access to the locked file system, and cannot be unlocked. hlocked file systems can be unmounted. .RE .sp .ne 2 .na \fB\fB-n\fR\fR .ad .sp .6 .RS 4n Name-lock (\fBnlock\fR) the specified \fIfile-system\fR. nlock suspends accesses that could change or remove existing directories entries. .RE .sp .ne 2 .na \fB\fB-u\fR\fR .ad .sp .6 .RS 4n Unlock (\fBulock\fR) the specified \fIfile-system\fR. ulock awakens suspended accesses. .RE .sp .ne 2 .na \fB\fB-v\fR\fR .ad .sp .6 .RS 4n Enable verbose output. .RE .sp .ne 2 .na \fB\fB-w\fR\fR .ad .sp .6 .RS 4n Write-lock (\fBwlock\fR) the specified \fIfile-system\fR. wlock suspends writes that would modify the file system. Access times are not kept while a file system is write-locked. .RE .SH OPERANDS .sp .LP The following operands are supported. .sp .ne 2 .na \fB\fIfile-system\fR\fR .ad .sp .6 .RS 4n A list of path names separated by whitespace. Note that \fIfile-system\fR can be a directory rather than the specific name of a file system, such as \fB/\fR or \fB/usr\fR. For example, if you specify \fB/export/home\fR as an argument to a \fBlockfs\fR command and \fB/export/home\fR is mounted on the root (\fB/\fR) file system, the \fBlockfs\fR command will take effect on the root file system. .RE .SH USAGE .sp .LP See \fBlargefile\fR(7) for the description of the behavior of \fBlockfs\fR when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). .SH EXAMPLES .LP \fBExample 1 \fRUsing \fBlockfs\fR \fB-a\fR .sp .LP In the following examples, \fIfilesystem\fR is the pathname of the mounted-on directory (mount point). \fBLocktype\fR is one of "\fBwrite\fR," "\fIname\fR," "\fIdelete\fR," "\fIhard\fR," or "\fIunlock\fR". When enclosed in parenthesis, the lock is being set. \fBComment\fR is a string set by the process that last issued a lock command. .sp .LP The following example shows the \fBlockfs\fR output when only the \fB-a\fR option is specified. .sp .in +2 .nf example# \fB/usr/sbin/lockfs -a\fR .fi .in -2 .sp .sp .sp .TS l l l l l l . Filesystem Locktype Comment / unlock /var unlock .TE .sp .in +2 .nf example# .fi .in -2 .sp .LP \fBExample 2 \fRUsing \fBlockfs\fR \fB-w\fR .sp .LP The following example shows the \fBlockfs\fR output when the \fB-w\fR option is used to write lock the \fB/var\fR file system and the comment string is set using the \fB-c\fR option. The \fB-a\fR option is then specified on a separate command line. .sp .in +2 .nf example# \fB/usr/sbin/lockfs -w -c "lockfs: write lock example" /var\fR example# \fB/usr/sbin/lockfs -a\fR .fi .in -2 .sp .sp .sp .TS l l l l l l . Filesystem Locktype Comment / unlock /var write lockfs: write lock example .TE .sp .in +2 .nf example# .fi .in -2 .sp .LP \fBExample 3 \fRUsing \fBlockfs\fR \fB-u\fR .sp .LP The following example shows the \fBlockfs\fR output when the \fB-u\fR option is used to unlock the \fB/var\fR file system and the comment string is set using the \fB-c\fR option. .sp .in +2 .nf example# \fB/usr/sbin/lockfs -uc "lockfs: unlock example" /var\fR example# \fB/usr/sbin/lockfs /var\fR .fi .in -2 .sp .sp .sp .TS l l l l l l . Filesystem Locktype Comment /var unlock lockfs: unlock example .TE .sp .in +2 .nf example# .fi .in -2 .sp .SH SEE ALSO .sp .LP \fBkill\fR(1), \fBmount_ufs\fR(8), \fBsync\fR(8), \fBattributes\fR(7), \fBlargefile\fR(7), \fBufs\fR(4FS), .sp .LP \fI\fR .SH DIAGNOSTICS .sp .ne 2 .na \fB\fIfile system\fR\fB: Not owner\fR\fR .ad .sp .6 .RS 4n You must be root to use this command. .RE .sp .ne 2 .na \fB\fIfile system\fR \fB:Deadlock condition detected/avoided\fR\fR .ad .sp .6 .RS 4n A file is enabled for accounting or swapping, on \fIfile system\fR. .RE .sp .ne 2 .na \fB\fIfile system\fR\fB: Device busy\fR\fR .ad .sp .6 .RS 4n Another process is setting the lock on \fIfile system\fR. .RE