1.\" $OpenBSD: vfs_busy.9,v 1.2 2007/05/31 19:20:01 jmc Exp $ 2.\" 3.\" Copyright (c) 2006 Nikolay Sturm <sturm@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: May 31 2007 $ 18.Dt VFS_BUSY 9 19.Os 20.Sh NAME 21.Nm vfs_busy , 22.Nm vfs_isbusy , 23.Nm vfs_unbusy 24.Nd VFS locking API 25.Sh SYNOPSIS 26.In sys/mount.h 27.Pp 28.Ft int 29.Fn vfs_busy "struct mount *mp" "int flags" 30.Ft int 31.Fn vfs_isbusy "struct mount *mp" 32.Ft void 33.Fn vfs_unbusy "struct mount *mp" 34.Sh DESCRIPTION 35The 36.Nm vfs_busy 37API is used to lock mount points to ensure consistent access. 38A read lock can be shared between multiple processes, while a write lock is 39exclusive. 40Normally a write lock is only acquired when unmounting. 41.Pp 42The 43.Fn vfs_busy 44function locks the mount point pointed to by 45.Fa mp , 46where 47.Fa flags 48describes the type of lock to acquire and whether or not to wait for a 49conflicting lock to be released. 50The following flags are available: 51.Pp 52.Bl -tag -width "VB_NOWAITXX" -offset indent -compact 53.It VB_READ 54Acquire a read lock. 55.It VB_WRITE 56Acquire a write lock. 57.It VB_NOWAIT 58Return immediately; do not wait for the conflicting lock to be released. 59.It VB_WAIT 60Wait for the conflicting lock to be released. 61.El 62.Pp 63If a conflicting lock was encountered, 64.Fn vfs_busy 65returns an error. 66.Pp 67The 68.Fn vfs_isbusy 69function checks whether the given mount point is locked. 70.Pp 71.Fn vfs_unbusy 72unlocks the given mount point. 73.Pp 74The 75.Nm vfs_busy 76API is implemented in the file 77.Pa sys/kern/vfs_subr.c . 78.Sh SEE ALSO 79.Xr rwlock 9 , 80.Xr vfs 9 81