Home | History | Annotate | Download | only in man9
History log of /src/share/man/man9/vnsubr.9
RevisionDateAuthorComments
 1.48  29-Jun-2021  dholland Add containment for the cloning devices hack in vn_open.

Cloning devices (and also things like /dev/stderr) work by allocating
a struct file, stuffing it in the file table (which is a layer
violation), stuffing the file descriptor number for it in a magic
field of struct lwp (which is gross), and then "failing" with one of
two magic errnos, EDUPFD or EMOVEFD.

Before this commit, all callers of vn_open in the kernel (there are
quite a few) were expected to check for these errors and handle the
situation. Needless to say, none of them except for open() itself did,
resulting in internal negative errnos being returned to userspace.

This hack is fairly deeply rooted and cannot be eliminated all at
once. This commit adds logic to handle the magic errnos inside
vn_open; now on success vn_open returns either a vnode or an integer
file descriptor, along with a flag that says whether the underlying
code requested EDUPFD or EMOVEFD. Callers not prepared to cope with
file descriptors can pass NULL for the extra return values, in which
case if a file descriptor would be produced vn_open fails with
EOPNOTSUPP.

Since I'm rearranging vn_open's signature anyway, stop exposing struct
nameidata. Instead, take three arguments: an optional vnode to use as
the starting point (like openat()), the path, and additional namei
flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei
behavior, e.g. NOFOLLOW, can be requested via the open flags.)

This change requires a kernel bump. Ride the one an hour ago.
(That was supposed to be coordinated; did not intend to let an hour
slip by. My fault.)
 1.47  17-Nov-2019  wiz file system police. New sentence, new line.
 1.46  16-Nov-2019  mlelstv Document new functions vn_bdev_open and vn_bdev_openpath.
 1.45  05-Jan-2017  wiz branches: 1.45.14;
Bump date for previous.
 1.44  02-Jan-2017  hannken Rename vget() to vcache_vget() and vcache_tryvget() respectively and
move the definitions to sys/vnode_impl.h.

No functional change intended.

Welcome to 7.99.54
 1.43  11-Jul-2015  wiz branches: 1.43.2;
Avoid Pq.
 1.42  27-Feb-2014  hannken The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Change deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
the vnode is locked and unlock and return ENOENT in this case.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Adresses PR kern/37706 (Forced unmount of file systems is unsafe)

Discussed on tech-kern.

Welcome to 6.99.33
 1.41  30-Jan-2011  rmind branches: 1.41.4; 1.41.10;
vn_lock: describe flags, remove reference to lockmgr.
 1.40  02-Dec-2010  wiz branches: 1.40.2;
Remove boilerplate in CODE REFERENCES on file paths.
Describe in intro(9) how to read paths in the CODE REFERENCES section.
 1.39  18-Jun-2010  hannken Remove the concept of recursive vnode locks by eliminating
vn_setrecurse(), vn_restorerecurse() and LK_CANRECURSE.
Welcome to 5.99.31

Discussed on tech-kern.
 1.38  02-Jun-2009  jnemeth branches: 1.38.2;
note that vn_open locks the vnode
 1.37  28-May-2009  wiz Use Dv in more places.
 1.36  28-May-2009  jnemeth clarify vnode locking for vn_rdwr()
 1.35  27-May-2009  jnemeth correct vn_stat definition and description
 1.34  30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.33  10-Apr-2008  riz branches: 1.33.2;
Catch the documentation up with the changes in vfs_vnops.c revision
1.155 - s/struct file/file_t/, and dropping a struct lwp * arg from
some functions.
 1.32  08-Oct-2007  hannken branches: 1.32.6;
Bump date.
 1.31  07-Oct-2007  hannken Update the file system copy-on-write handler.

- Instead of hooking the handler on the specdev of a mounted file system
hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'. Use
`mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
 1.30  07-Mar-2007  dogcow branches: 1.30.4;
running in emulated wizd mode, convert caddr_t to void *.
 1.29  16-Feb-2007  hannken Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().
 1.28  23-Jan-2007  wiz Sort ERRORS.
 1.27  21-Jan-2007  hannken Add and update documentation for fstrans(9) file system suspension helper.

wiz?
 1.26  04-Oct-2006  pooka ucred -> kauth sweep
 1.25  04-Mar-2006  rumble Typo.
 1.24  29-Jan-2006  rpaulo More ktrace-lwp that I got wrong in the first try.

Thanks to Gregory McGarry for pointing this out.
 1.23  20-Dec-2005  rpaulo Adapt man pages to ktrace-lwp.
 1.22  06-Jun-2005  wiz Grammar fix and improvement from jmc@openbsd.
 1.21  25-May-2004  hannken Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.

- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
Snapshots may not be opened for writing and the attributes are read-only.
Use the mtime as the time this snapshot was taken.
Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
 1.20  14-Mar-2004  cube vn_close() expects an unlocked vnode.
 1.19  14-Feb-2004  hannken Add a generic copy-on-write hook to add/remove functions that will be
called with every buffer written through spec_strategy().

Used by fss(4). Future file-system-internal snapshots will need them too.

Welcome to 1.6ZK

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
 1.18  22-Oct-2003  hannken Forgot to update the .Dd line. From Thomas Klausner <wiz@netbsd.org>.
 1.17  21-Oct-2003  hannken Add section 9 man pages for:
vfs_write_suspend, vfs_write_resume, vn_start_write and vn_finished_write.
 1.16  30-Jun-2003  wiz Fixes to make these man page look nice with groff-1.19.
 1.15  16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.14  06-Apr-2003  wiz Fix a typo, from Igor Sobrado in PR 19680.
 1.13  04-Feb-2003  perry "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.12  20-Oct-2002  wiz Sort SEE ALSO.
 1.11  20-Oct-2002  gmcgarry Xr file.9
 1.10  14-Oct-2002  gmcgarry link for vn_rdwr()
 1.9  14-Oct-2002  wiz New sentence, new line.
 1.8  14-Oct-2002  gmcgarry Move the vnode file descriptor operations into their own file.
Add vn_marktext() and vn_statfile() descriptions.
 1.7  14-Oct-2002  gmcgarry vn_stat() now takes a struct vnode *. The description already implied this.
 1.6  13-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.5  06-Jan-2002  deberg fix typo
 1.4  31-Oct-2001  gmcgarry Document new VEXECMAP vnode flag and rename vn_marktext() to vn_markexec().
 1.3  22-Oct-2001  gmcgarry fnctl -> fcntl
 1.2  22-Oct-2001  wiz Whitespace, punctuation fixes; sort sections, fix xrefs.
 1.1  22-Oct-2001  gmcgarry Programmer's guide to the VFS interface.
 1.30.4.1  06-Nov-2007  matt sync with HEAD
 1.32.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.33.2.1  18-May-2008  yamt sync with head.
 1.38.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.40.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.41.10.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.4.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.43.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.45.14.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed