Home | History | Annotate | only in /src/sys/miscfs/kernfs
History log of /src/sys/miscfs/kernfs
RevisionDateAuthorComments
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.3 05-Jan-1994  mycroft Clean up deleted files.
 1.2 20-May-1993  cgd header cleanup
 1.1 23-Mar-1993  cgd files which implement the kern filesystem. from Jan-Simon Pendry,
pendry@vangogh.cs.berkeley.edu
 1.7 26-May-2020  bouyer Add need-flags for kernfs.
Compile Xen kernfs support only if kernfs is compiled in the kernel.
Should fix MODULAR build.
 1.6 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.5 20-Jul-2014  hannken Change kernfs from hashlist to vcache.
 1.4 03-Mar-2010  pooka branches: 1.4.20; 1.4.34;
You have found a scroll of genocide --More--
What class of monsters do you wish to genocide? --More--
> fs_foo.h
Wiped out all fs_foo.h
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.96;
merge ktrace-lwp.
 1.2 08-Sep-2003  itojun add /kern/ipsecsa and /kern/ipsecsp, which can be inspected by setkey(8).
it allows easier access to ipsecsa/sp. it works around problem where
setkey -D does not work with large number of ipsec SAs due to socket buffer
size.
 1.1 16-Apr-2002  thorpej branches: 1.1.6; 1.1.8; 1.1.14;
Cleanup how file system configuration information is declared, grouping
related information together, with the file system code itself.

This is just low-hanging fruit -- more to come.
 1.1.14.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.14.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.14.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 16-Apr-2002  jdolecek file files.kernfs was added on branch kqueue on 2002-06-23 17:50:10 +0000
 1.1.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.6.1 16-Apr-2002  nathanw file files.kernfs was added on branch nathanw_sa on 2002-06-20 03:47:57 +0000
 1.3.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.74.1 11-Mar-2010  yamt sync with head
 1.4.34.1 10-Aug-2014  tls Rebase.
 1.4.20.2 03-Dec-2017  jdolecek update from HEAD
 1.4.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.45 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.44 07-Apr-2020  jdolecek branches: 1.44.28;
switch KERNFS_ALLOCENTRY() to use kmem_zalloc() instead of malloc()
 1.43 04-Feb-2020  riastradh Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, pullup-2, pullup-1.4T...
 1.42 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.41 02-Jan-2020  thorpej branches: 1.41.2;
- Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.40 20-Jul-2014  hannken branches: 1.40.28; 1.40.32;
Change kernfs from hashlist to vcache.
 1.39 20-Jul-2014  hannken Remove another KAME IPSEC residue, "struct secasvar" and "struct secpolicy".
 1.38 17-Jul-2014  hannken Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.
 1.37 22-Mar-2012  drochner branches: 1.37.2; 1.37.12;
remove KAME IPSEC, replaced by FAST_IPSEC
 1.36 27-Sep-2011  christos branches: 1.36.2; 1.36.6;
define KERNFS_MAXNAMLEN and use it.`
 1.35 11-Jan-2009  christos merge christos-time_t
 1.34 01-Aug-2008  apb branches: 1.34.2;
#include <sys/tree.h> to get a definition for SPLAY_ENTRY.
Needed by third party code, such as lsof.
 1.33 28-Jun-2008  rumble branches: 1.33.2;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.32 28-Dec-2006  alc branches: 1.32.40; 1.32.44; 1.32.46; 1.32.48;
fix comment (forgotten in rev 1.19):
- pfsnode -> kernfs_node
- procfs -> kernfs
 1.31 23-Jun-2006  christos branches: 1.31.4;
remove useless genop
 1.30 23-Jun-2006  bouyer For internal types call kernfs_default_xread() directly, as no entry in
the splay tree has been added for these types. Fix kern/33797 by
Geoff C. Wing.
While here also fix writes the same way (probably broken for 2 years),
and properly implement KERNFS_XREAD.
The IPsec code could probably be moved out now, and use kernfs_alloctype().
 1.29 23-Jun-2006  bouyer Backout previous: of course the change
"Allow optional /kern regular files to have custom read methods..."
works, it's used by Xen.
 1.28 23-Jun-2006  christos PR/33797: Geoff C. Wing: kernfs files are not supplying information
Roll back the change:
'Allow optional /kern regular files to have custom read methods...'
which does not work.
 1.27 14-Mar-2006  bouyer branches: 1.27.6;
Allow optionnal /kern regular files to have custom read methods, the same
way writes are handled: Add KERNFS_XREAD and KERNFS_FILEOP_WRITE files
operations definitions to kfsfileop, a xread function pointer to
kernfs_fileop, rename kernfs_read to kernfs_default_xread and add a
kernfs_read calling kernfs_try_fileop(KERNFS_FILEOP_READ).

Proposed on tech-kern on Feb 18 2006.
 1.26 11-Dec-2005  christos branches: 1.26.4; 1.26.6; 1.26.8; 1.26.10;
merge ktrace-lwp.
 1.25 30-Aug-2005  xtraeme Remove __P()
 1.24 20-May-2005  chs branches: 1.24.2;
kernfs does not support mmap(), remove code that pretends that it does.
 1.23 20-May-2004  atatat branches: 1.23.10;
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.22 07-May-2004  cl Allow additional entries (files, subdirs) in kernfs. Also allow
defining additional kfstypes and provide hooks to run arbitrary code
for any vnodeop on the additional types.
 1.21 07-May-2004  cl Make lookup and readdir return the same inode number. kernfs_readdir
now uses kernfs_allocvp to map from kernfs entry to inode number,
kernfs_allocvp is now the only place where entries are mapped to inode
numbers. Also make KERNFS_FILENO not return random results for entries
not in kern_targets.
 1.20 27-Sep-2003  darcy branches: 1.20.2;
Changes as discussed with itojun on tech-kern. I have modified the enums
to have KFS or PFS differentiators. Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
 1.19 26-Sep-2003  atatat Make kernfs peacefully co-exist with procfs.
 1.18 08-Sep-2003  itojun add /kern/ipsecsa and /kern/ipsecsp, which can be inspected by setkey(8).
it allows easier access to ipsecsa/sp. it works around problem where
setkey -D does not work with large number of ipsec SAs due to socket buffer
size.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.16 21-Feb-2001  jdolecek branches: 1.16.24;
make some more constant arrays 'const'
 1.15 27-Jan-2001  jdolecek Back previous out, it was right the way it was. Seems like I should
attend some basic arithmetic lessons to avoid such mistakes :-/
 1.14 27-Jan-2001  jdolecek fix 'physmem' - the actual value we want is ctob(physmem)
 1.13 14-Jul-2000  thorpej Sprinkle some const.
 1.12 01-Mar-1998  fvdl branches: 1.12.14; 1.12.24;
Merge with Lite2 + local changes
 1.11 10-May-1997  pk Move `struct kern_target' definition into kernfs.h
 1.10 09-Feb-1996  christos miscfs prototype changes
 1.9 29-Mar-1995  briggs KERNEL -> _KERNEL
 1.8 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.7 15-Jun-1994  mycroft Minor update from JSP after merging my changes.
 1.6 08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.5 05-Jan-1994  cgd update with latest kernfs file system from jsp@sequent.com
 1.4 28-May-1993  cgd add some more functionality: a setattr which supports chmod+chown+chgrp,
and the various support elsewhere to deal with it.
 1.3 27-Mar-1993  cgd added ".." and support for "rrootdev"
 1.2 25-Mar-1993  cgd changed copyright notice thanks to following statement:

Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...

You may put this copyright message on the source code:

/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
 1.1 23-Mar-1993  cgd branches: 1.1.1;
files which implement the kern filesystem. from Jan-Simon Pendry,
pendry@vangogh.cs.berkeley.edu
 1.1.1.2 01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.1 01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.12.24.1 14-Jul-2000  thorpej Update from trunk:
Sprinkle some const.
 1.12.14.2 12-Mar-2001  bouyer Sync with HEAD.
 1.12.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.16.24.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.24.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.24.3 18-Sep-2004  skrll Sync with HEAD.
 1.16.24.2 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.16.24.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.4 24-May-2005  riz Pull up revision 1.24 (requested by chs in ticket #1540):
kernfs does not support mmap(), remove code that pretends that it does.
 1.20.2.3 23-May-2004  tron branches: 1.20.2.3.2;
Pull up revision 1.23 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.20.2.2 15-May-2004  tron Pull up revision 1.22 (requested by cl in ticket #336):
Allow additional entries (files, subdirs) in kernfs. Also allow
defining additional kfstypes and provide hooks to run arbitrary code
for any vnodeop on the additional types.
 1.20.2.1 14-May-2004  jdc Pull up revision 1.21 (requested by cl in ticket #322).

Make lookup and readdir return the same inode number. kernfs_readdir
now uses kernfs_allocvp to map from kernfs entry to inode number,
kernfs_allocvp is now the only place where entries are mapped to inode
numbers. Also make KERNFS_FILENO not return random results for entries
not in kern_targets.
 1.20.2.3.2.1 24-May-2005  riz Pull up revision 1.24 (requested by chs in ticket #1540):
kernfs does not support mmap(), remove code that pretends that it does.
 1.23.10.1 28-May-2005  tron Pull up revision 1.24 (requested by chs in ticket #329):
kernfs does not support mmap(), remove code that pretends that it does.
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.26.10.1 19-Apr-2006  elad sync with head.
 1.26.8.2 26-Jun-2006  yamt sync with head.
 1.26.8.1 01-Apr-2006  yamt sync with head.
 1.26.6.1 22-Apr-2006  simonb Sync with head.
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.6.1 13-Jul-2006  gdamore Merge from HEAD.
 1.31.4.1 12-Jan-2007  ad Sync with head.
 1.32.48.1 03-Jul-2008  simonb Sync with head.
 1.32.46.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.44.1 04-May-2009  yamt sync with head.
 1.32.40.3 17-Jan-2009  mjf Sync with HEAD.
 1.32.40.2 28-Sep-2008  mjf Sync with HEAD.
 1.32.40.1 29-Jun-2008  mjf Sync with HEAD.
 1.33.2.1 19-Oct-2008  haad Sync with HEAD.
 1.34.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.36.6.1 05-Apr-2012  mrg sync to latest -current.
 1.36.2.1 17-Apr-2012  yamt sync with head
 1.37.12.1 10-Aug-2014  tls Rebase.
 1.37.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.32.1 12-Feb-2020  martin Pull up following revision(s) (requested by riastradh in ticket #702):

sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...
 1.40.28.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.40.28.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.41.2.2 29-Feb-2020  ad Sync with head.
 1.41.2.1 17-Jan-2020  ad Sync with head.
 1.44.28.1 02-Aug-2025  perseant Sync with HEAD
 1.29 20-Jul-2014  hannken Change kernfs from hashlist to vcache.
 1.28 17-Jul-2014  hannken Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.
 1.27 08-Apr-2014  christos From Ilya Zykov: Unbreak kernfs which was broken by this commit

|Make the spec_node table implementation private to spec_vnops.c.
|To retrieve a spec_node, two new lookup functions (by device or by mount)
|are implemented. Both return a referenced vnode, for an opened block device
|the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
|will not fire. Otherwise any vnode matching the criteria gets returned.
|No objections on tech-kern.

The effect was that ls /kernfs appeared empty in most cases.
 1.26 27-Feb-2014  hannken branches: 1.26.2;
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.25 22-Mar-2012  drochner branches: 1.25.2; 1.25.4;
remove KAME IPSEC, replaced by FAST_IPSEC
 1.24 12-Jun-2011  rmind branches: 1.24.2; 1.24.6;
Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.23 21-Jul-2010  hannken branches: 1.23.6;
Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.22 21-Jul-2010  hannken Using vfinddev() leads to vnode races as it returns an unreferenced
vnode that may disappear before the caller has a chance to reference it.

Reference the vnode while the specfs cache is locked.

Welcome to 5.99.37.

No objections on tech-kern.
 1.21 01-Jul-2010  hannken Remove vlockmgr(). Generic vnode lock operations now use a rwlock located
in the vnode. All LK_* flags move from sys/lock.h to sys/vnode.h. Calls
to vlockmgr() in file systems get replaced with VOP_LOCK() or VOP_UNLOCK().

Welcome to 5.99.34.

Discussed on tech-kern.
 1.20 15-Mar-2009  cegger branches: 1.20.2; 1.20.4;
ansify function definitions
 1.19 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.18 11-Jan-2009  christos branches: 1.18.2;
merge christos-time_t
 1.17 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.16 05-May-2008  ad branches: 1.16.8;
- Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.15 30-Jan-2008  ad branches: 1.15.6; 1.15.8; 1.15.10;
Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
 1.14 02-Jan-2008  ad Merge vmlocking2 to head.
 1.13 10-Oct-2007  ad branches: 1.13.4; 1.13.6; 1.13.10;
Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.12 11-Mar-2007  ad branches: 1.12.12; 1.12.14; 1.12.16;
Remove useless cast.
 1.11 27-Feb-2007  ad branches: 1.11.2;
Destroy the hash locks on final unmount.
 1.10 15-Feb-2007  ad branches: 1.10.2;
Replace some uses of lockmgr() / simplelocks.
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 30-Aug-2005  xtraeme Remove __P()
 1.7 26-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 07-May-2004  cl branches: 1.6.2; 1.6.6; 1.6.8;
remove code no longer needed since the type/permission information
is available in the entry's struct kern_target and every entry has a
(possibly shared) struct kern_target now.
 1.5 27-Sep-2003  darcy branches: 1.5.2;
Changes as discussed with itojun on tech-kern. I have modified the enums
to have KFS or PFS differentiators. Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
 1.4 26-Sep-2003  atatat Make kernfs peacefully co-exist with procfs.
 1.3 10-Sep-2003  itojun fix permission of /kern/hostname to 0644
 1.2 10-Sep-2003  dan test against kt to get the right node of the given type, from enami@
 1.1 08-Sep-2003  itojun add /kern/ipsecsa and /kern/ipsecsp, which can be inspected by setkey(8).
it allows easier access to ipsecsa/sp. it works around problem where
setkey -D does not work with large number of ipsec SAs due to socket buffer
size.
 1.5.2.1 14-May-2004  jdc Pull up revision 1.6 (requested by cl in ticket #322).

remove code no longer needed since the type/permission information
is available in the entry's struct kern_target and every entry has a
(possibly shared) struct kern_target now.
 1.6.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.6.1 29-Apr-2005  kent sync with -current
 1.6.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.6.2.2 03-Aug-2004  skrll Sync with HEAD
 1.6.2.1 07-May-2004  skrll file kernfs_subr.c was added on branch ktrace-lwp on 2004-08-03 10:54:05 +0000
 1.7.4.6 04-Feb-2008  yamt sync with head.
 1.7.4.5 21-Jan-2008  yamt sync with head
 1.7.4.4 27-Oct-2007  yamt sync with head.
 1.7.4.3 03-Sep-2007  yamt sync with head.
 1.7.4.2 26-Feb-2007  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.2.3 17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.11.2.2 05-Apr-2007  ad Compile fixes.
 1.11.2.1 13-Mar-2007  ad Sync with head.
 1.12.16.1 14-Oct-2007  yamt sync with head.
 1.12.14.3 23-Mar-2008  matt sync with HEAD
 1.12.14.2 09-Jan-2008  matt sync with HEAD
 1.12.14.1 06-Nov-2007  matt sync with HEAD
 1.12.12.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.10.1 02-Jan-2008  bouyer Sync with HEAD
 1.13.6.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.13.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.15.10.3 11-Aug-2010  yamt sync with head.
 1.15.10.2 04-May-2009  yamt sync with head.
 1.15.10.1 16-May-2008  yamt sync with head.
 1.15.8.1 18-May-2008  yamt sync with head.
 1.15.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.16.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.4.4 19-May-2011  rmind Implement sharing of vnode_t::v_interlock amongst vnodes:
- Lock is shared amongst UVM objects using uvm_obj_setlock() or getnewvnode().
- Adjust vnode cache to handle unsharing, add VI_LOCKSHARE flag for that.
- Use sharing in tmpfs and layerfs for underlying object.
- Simplify locking in ubc_fault().
- Sprinkle some asserts.

Discussed with ad@.
 1.20.4.3 05-Mar-2011  rmind sync with head
 1.20.4.2 03-Jul-2010  rmind sync with head
 1.20.4.1 16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.20.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.23.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.24.6.1 05-Apr-2012  mrg sync to latest -current.
 1.24.2.2 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.24.2.1 17-Apr-2012  yamt sync with head
 1.25.4.1 18-May-2014  rmind sync with head
 1.25.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.1 10-Aug-2014  tls Rebase.
 1.101 16-Feb-2025  joe remove unecessary branches
 1.100 07-Apr-2020  jdolecek branches: 1.100.28;
switch to kmem_zalloc() instead of malloc() for struct kernfs_mount
 1.99 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.98 04-Feb-2020  riastradh Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, pullup-2, pullup-1.4T...
 1.97 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.96 17-Feb-2017  hannken branches: 1.96.14; 1.96.18; 1.96.20;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.95 20-Jul-2014  hannken branches: 1.95.4; 1.95.8; 1.95.12;
Change kernfs from hashlist to vcache.
 1.94 17-Jul-2014  hannken Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.
 1.93 23-Mar-2014  hannken branches: 1.93.2;
Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.92 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.91 27-Sep-2011  christos branches: 1.91.2; 1.91.12; 1.91.16;
define KERNFS_MAXNAMLEN and use it.`
 1.90 30-Nov-2009  pooka Introduce genfs_statvfs() as pretty much a no-info statvfs and
convert several pseudo file systems to use it.
 1.89 15-Mar-2009  cegger ansify function definitions
 1.88 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.87 17-Dec-2008  cegger branches: 1.87.2;
kill MALLOC and FREE macros.
 1.86 28-Jun-2008  rumble branches: 1.86.4;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.85 10-May-2008  rumble branches: 1.85.2;
Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

As a consequence, most of the file systems can now be loaded as new style
modules.

Quick sanity check by ad@.
 1.84 29-Apr-2008  ad branches: 1.84.2;
PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.
 1.83 28-Jan-2008  dholland branches: 1.83.6; 1.83.8; 1.83.10;
Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.
 1.82 26-Nov-2007  pooka Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.81 31-Jul-2007  pooka branches: 1.81.2; 1.81.4; 1.81.10; 1.81.12;
* nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods
 1.80 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.79 17-Jul-2007  pooka branches: 1.79.2;
Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok
 1.78 12-Jul-2007  dsl Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.
 1.77 30-Jun-2007  pooka Using POOL_INIT here makes no sense, since file systems always have
an init method. So get rid of it and #ifdef _LKM and just always
init in the init method. Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
 1.76 19-Jan-2007  hannken branches: 1.76.6; 1.76.8;
New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE. This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).
 1.75 09-Dec-2006  chs a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
these now always return the parent vnode locked. namei() works as before.
lookup() and various other paths no longer acquire vnode locks in the
wrong order via vrele(). fixes PR 32535.
as a nice side effect, path lookup is also up to 25% faster.
- the above allows us to get rid of PDIRUNLOCK.
- also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
- remove an assumption in layer_node_find() that all file systems implement
a recursive VOP_LOCK() (unionfs doesn't).
- require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
fill in eopnotsupp() for file systems that don't support being exported
and remove the checks for NULL. (layerfs calls these without checking.)
- in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
adjust which vnode is locked. fixes PR 33374.
- apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
 1.74 16-Nov-2006  christos branches: 1.74.2;
__unused removal on arguments; approved by core.
 1.73 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.72 02-Sep-2006  christos branches: 1.72.2; 1.72.4;
add missing initializers.
 1.71 14-May-2006  elad integrate kauth.
 1.70 11-Dec-2005  christos branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
merge ktrace-lwp.
 1.69 23-Sep-2005  jmmv Apply the NFS exports list rototill patch:

- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
 1.68 30-Aug-2005  xtraeme Remove __P()
 1.67 29-Mar-2005  thorpej branches: 1.67.2;
- Define a VFS_ATTACH() macro that places a reference to a vfsops structure
into the "vfsops" link set.
- Use VFS_ATTACH() where vfsops are declared for individual file systems.
- In vfsinit(), traverse the "vfsops" link set, rather than vfs_list_initial[].
 1.66 02-Jan-2005  thorpej branches: 1.66.2;
Add the system call and VFS infrastructure for file system extended
attributes.

From FreeBSD.
 1.65 13-Sep-2004  jdolecek set mp->mnt_stat.f_namemax on filesystem mount, for use by statvfs
 1.64 29-May-2004  tron Don't leak memory in VFS_MOUNT() if set_statvfs_info() fails.
 1.63 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.62 25-May-2004  atatat Sysctl descriptions under vfs subtree
 1.61 27-Apr-2004  jrf First pass for some caddr_t removal and changes to get rid of it where we
no longer use and/or need it

- removed casts from unionfs, deadfs and fdesc
(there are more to hunt down still)
- changed vfs_quotactl args argumet from caddr_t to void *
- changed vfs_quotactl structures/callers to reflect the api change

Compiled fine and ran for about a day. Approved/reviewed by
christos@netbsd.org and gimpy@netbsd.org.
 1.60 21-Apr-2004  christos add sys/dirent.h
 1.59 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.58 24-Mar-2004  atatat branches: 1.58.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.57 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.56 27-Sep-2003  darcy Changes as discussed with itojun on tech-kern. I have modified the enums
to have KFS or PFS differentiators. Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
 1.55 26-Sep-2003  atatat Make kernfs peacefully co-exist with procfs.
 1.54 08-Sep-2003  itojun add /kern/ipsecsa and /kern/ipsecsp, which can be inspected by setkey(8).
it allows easier access to ipsecsa/sp. it works around problem where
setkey -D does not work with large number of ipsec SAs due to socket buffer
size.
 1.53 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.52 29-Jun-2003  fvdl branches: 1.52.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.51 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.50 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.49 22-Apr-2003  christos fix lkm malloc lossage.
 1.48 16-Apr-2003  christos PR/1796: John Kohl: statfs misbehaves under chrooted environments.

- Under chroot it displays only the visible filesystems with appropriate paths.
- The statfs f_mntonname gets adjusted to contain the real path from root.
- While was there, fixed a bug in ext2fs, locking problems with vfs_getfsstat(),
and factored out some of the vfsop statfs() code to copy_statfs_info(). This
fixes the problem where some filesystems forgot to set fsid.
- Made coda look more like a normal fs.
 1.47 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.46 21-Sep-2002  christos MNT_GETARGS support
 1.45 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.44 30-Jul-2002  soren Die, qaddr_t, die! - mnt_data in struct mount is already effectively
a void *, so stop pretending otherwise.
 1.43 15-Nov-2001  lukem branches: 1.43.8;
don't need <sys/types.h> when including <sys/param.h>
 1.42 10-Nov-2001  lukem add RCSIDs
 1.41 15-Sep-2001  chs branches: 1.41.2;
add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.
 1.40 30-May-2001  mrg branches: 1.40.2; 1.40.4;
use _KERNEL_OPT
 1.39 04-Feb-2001  mrg branches: 1.39.2;
clean up some KERNFS_DIAGNOSTIC calls.
 1.38 22-Jan-2001  jdolecek make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const
 1.37 10-Jun-2000  assar make vfs_getnewfsid only take one argument and fetch the name of the
filesystem from the supplied mount argument. also make makefstype
take a const parameter. update all the callers.
 1.36 16-Mar-2000  jdolecek branches: 1.36.2;
Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.
 1.35 26-Feb-1999  wrstuden branches: 1.35.8; 1.35.14;
Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.
 1.34 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.33 05-Jul-1998  jonathan * defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.
 1.32 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.31 18-Feb-1998  thorpej Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().
 1.30 10-Sep-1997  christos PR/4098: Alan Barrett: Fix diagnostic printf formatting.
 1.29 22-Dec-1996  cgd branches: 1.29.10;
Change the second and third args to struct vfsops' (*vfs_mount)() to
'const char *', and 'void *', respectively. The second arg is taken directly
from user arguments, and is const there, so must be const in the prototypes
and functions. The third arg is also taken directly from user arguments.
It doesn't have to be changed, but since it's cleaner to keep the type
the same as the user arg's type, and I'm already making the 'const char *'
change...
 1.28 13-Oct-1996  christos backout previous kprintf changes
 1.27 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.26 22-Apr-1996  christos remove include of <sys/cpu.h>
 1.25 09-Feb-1996  christos miscfs prototype changes
 1.24 18-Jun-1995  cgd don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN
 1.23 09-Mar-1995  mycroft copy*str() should use size_t.
 1.22 08-Mar-1995  cgd use u_long for copyin*
 1.21 18-Jan-1995  mycroft Clean up the code to frob mnt_stat a (tiny) bit.
 1.20 15-Dec-1994  mycroft Call foo_statfs() from a common place when mounting.
 1.19 15-Sep-1994  mycroft stat the file system at mount time, for `df -n', et al.
 1.18 29-Jun-1994  cgd branches: 1.18.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.17 15-Jun-1994  mycroft Minor update from JSP after merging my changes.
 1.16 15-Jun-1994  mycroft Fix a bug in finding the raw root device.
 1.15 08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.14 23-Apr-1994  cgd make fs types consistent over new kernels. also, some proto foo.
 1.13 21-Apr-1994  cgd Convert mount, vnode, and buf structs to use <sys/queue.h>. Also,
some knf and structure frobbing to do along with it.
 1.12 14-Apr-1994  cgd fs types are names now.
 1.11 05-Jan-1994  cgd update with latest kernfs file system from jsp@sequent.com
 1.10 20-Dec-1993  cgd branches: 1.10.2;
pull load average and misc changes down from magnum
 1.9 18-Dec-1993  mycroft Canonicalize all #includes.
 1.8 23-Aug-1993  cgd branches: 1.8.2;
changes from 0.9-ALPHA2 to 0.9-BETA
 1.7 07-Jun-1993  cgd branches: 1.7.2;
give various filesystems their own vnode types
 1.6 07-Jun-1993  cgd give miscfs filesystems their own mount structure malloc type.
 1.5 28-May-1993  cgd add some more functionality: a setattr which supports chmod+chown+chgrp,
and the various support elsewhere to deal with it.
 1.4 27-Mar-1993  cgd added cdevvp (after taking it out of vfs_subr.c) because realized
that it was only needed here.
 1.3 27-Mar-1993  cgd added ".." and support for "rrootdev"
 1.2 25-Mar-1993  cgd changed copyright notice thanks to following statement:

Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...

You may put this copyright message on the source code:

/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
 1.1 23-Mar-1993  cgd branches: 1.1.1;
files which implement the kern filesystem. from Jan-Simon Pendry,
pendry@vangogh.cs.berkeley.edu
 1.1.1.2 01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.1 01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.7.2.1 20-Aug-1993  cgd kill old, badly placed incarnation of cdevvp
 1.8.2.3 03-Dec-1993  cgd don't try to get rootdev at vfs init time. wait until kernfs mount time
to do it. this is hackish, but it gets the job done, and is slightly
more robust than the previous way it was done...
 1.8.2.2 29-Nov-1993  mycroft Don't crash deferencing a null pointer if the raw root device was not found.
 1.8.2.1 14-Nov-1993  mycroft Canonicalize all #includes.
 1.10.2.3 06-Jan-1994  pk Re-instate EOPNOTSUPP
 1.10.2.2 28-Dec-1993  pk Return ENODEV rather then EOPNOTSUPP for unsupported operations.
 1.10.2.1 20-Dec-1993  pk file kernfs_vfsops.c was added on branch magnum on 1993-12-28 16:21:43 +0000
 1.18.2.1 16-Sep-1994  cgd from trunk, per mycroft
 1.29.10.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.35.14.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.35.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.35.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.36.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.39.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.39.2.6 17-Sep-2002  nathanw Catch up to -current.
 1.39.2.5 01-Aug-2002  nathanw Catch up to -current.
 1.39.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.39.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.39.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.39.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.40.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.40.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.40.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.40.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.41.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.43.8.2 29-Aug-2002  gehenna catch up with -current.
 1.43.8.1 16-May-2002  gehenna Replace the direct-access to devsw table with calling devsw APIs.
 1.52.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.52.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.52.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.52.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.52.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.52.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.52.2.2 03-Aug-2004  skrll Sync with HEAD
 1.52.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.58.2.1 29-May-2004  tron Pull up revision 1.62 (requested by atatat in ticket #393):
Sysctl descriptions under vfs subtree
 1.66.2.1 29-Apr-2005  kent sync with -current
 1.67.2.6 04-Feb-2008  yamt sync with head.
 1.67.2.5 07-Dec-2007  yamt sync with head
 1.67.2.4 03-Sep-2007  yamt sync with head.
 1.67.2.3 26-Feb-2007  yamt sync with head.
 1.67.2.2 30-Dec-2006  yamt sync with head.
 1.67.2.1 21-Jun-2006  yamt sync with head.
 1.70.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.70.10.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.70.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.70.8.2 03-Sep-2006  yamt sync with head.
 1.70.8.1 24-May-2006  yamt sync with head.
 1.70.6.1 01-Jun-2006  kardel Sync with head.
 1.70.4.1 09-Sep-2006  rpaulo sync with head
 1.72.4.2 10-Dec-2006  yamt sync with head.
 1.72.4.1 22-Oct-2006  yamt sync with head
 1.72.2.3 01-Feb-2007  ad Sync with head.
 1.72.2.2 12-Jan-2007  ad Sync with head.
 1.72.2.1 18-Nov-2006  ad Sync with head.
 1.74.2.1 17-Feb-2007  tron Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.76.8.1 11-Jul-2007  mjf Sync with head.
 1.76.6.2 20-Aug-2007  ad Sync with HEAD.
 1.76.6.1 15-Jul-2007  ad Sync with head.
 1.79.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.81.12.2 31-Jul-2007  pooka * nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
use VFS_PROTOS() instead of manually prototyping the methods
 1.81.12.1 31-Jul-2007  pooka file kernfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:17 +0000
 1.81.10.2 18-Feb-2008  mjf Sync with HEAD.
 1.81.10.1 08-Dec-2007  mjf Sync with HEAD.
 1.81.4.2 23-Mar-2008  matt sync with HEAD
 1.81.4.1 09-Jan-2008  matt sync with HEAD
 1.81.2.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.83.10.3 11-Mar-2010  yamt sync with head
 1.83.10.2 04-May-2009  yamt sync with head.
 1.83.10.1 16-May-2008  yamt sync with head.
 1.83.8.1 18-May-2008  yamt sync with head.
 1.83.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.83.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.83.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.84.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.84.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.85.2.1 03-Jul-2008  simonb Sync with head.
 1.86.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.86.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.87.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.91.16.1 18-May-2014  rmind sync with head
 1.91.12.2 03-Dec-2017  jdolecek update from HEAD
 1.91.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.91.2.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.93.2.1 10-Aug-2014  tls Rebase.
 1.95.12.1 21-Apr-2017  bouyer Sync with HEAD
 1.95.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.95.4.1 28-Aug-2017  skrll Sync with HEAD
 1.96.20.2 29-Feb-2020  ad Sync with head.
 1.96.20.1 17-Jan-2020  ad Sync with head.
 1.96.18.1 12-Feb-2020  martin Pull up following revision(s) (requested by riastradh in ticket #702):

sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...
 1.96.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.96.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.100.28.1 02-Aug-2025  perseant Sync with HEAD
 1.174 27-Mar-2022  christos dedup the eofs link/symlink methods
 1.173 12-Mar-2022  riastradh kernfs: Just fail with EOPNOTSUPP, don't panic, on VOP_BMAP.

Reported-by: syzbot+870d2eb4b4c8904ac734@syzkaller.appspotmail.com
 1.172 19-Jul-2021  dholland Abolish all the silly indirection macros for initializing vnode ops tables.

These are things of the form #define foofs_op genfs_op, or #define
foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides
obfuscation, and have gotten cutpasted all over everywhere.

Part 3; cvs randomly didn't commit all the files the first time, still
hunting down the files it skipped.
 1.171 18-Jul-2021  dholland Use macros for the canned parts of device and fifo vnode op tables.

Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain
the portion of the vnode ops table declaration that is
(conservatively) the same in every fs. Use these in every fs that
supports devices and/or fifos with separate ops tables.

Note that ptyfs works differently (it has one type of vnode with
open-coded dispatch to the specfs code, which I haven't changed in
this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic
dispatch that already does more or less the same thing, which I also
haven't changed.

Also note that this anticipates a few bits in the next changeset here
and there, and adds missing but unreachable calls in some cases (e.g.
most fses weren't defining whiteout on devices and fifos, but it isn't
reachable there), and it changes parsepath on devices and fifos to
genfs_badop from genfs_parsepath (but it's not reachable there
either).

It appears that devices in kernfs were missing kqfilter, so it's
possible that if you try to use kqueue on /kern/rootdev that it'll
explode.

And finally note that the ops declaration tables aren't
order-dependent. (Other than vop_default_desc has to come first.)
Otherwise this wouldn't work.
 1.170 06-Jul-2021  dholland Fix perms on /kern/{r,}rootdev.
 1.169 06-Jul-2021  dholland Add missing VOP_KQFILTER to kernfs.

Not sure if lack of it can be used for local DoS or not, but best to
fix.
 1.168 29-Jun-2021  dholland - Add a new vnode op: VOP_PARSEPATH.
- Move namei_getcomponent to genfs_vnops.c and call it genfs_parsepath.
- Add a parsepath entry to every vnode ops table.

VOP_PARSEPATH takes a directory vnode to be searched and a complete
following path and chooses how much of that path to consume. To begin
with, all parsepath calls are genfs_parsepath, which locates the first
'/' as always.

Note that the call doesn't take the whole struct componentname, only
the string. The other bits of struct componentname should not be
needed and there's no reason to cause potential complications by
exposing them.
 1.167 28-Jun-2021  chs VOP_BMAP() may be called via ioctl(FIOGETBMAP) on any vnode that applications
can open. change various pseudo-fs *_bmap methods return an error instead of
panic.

Reported-by: syzbot+8289a3eaf2ba60958c87@syzkaller.appspotmail.com
 1.166 27-Jun-2020  christos branches: 1.166.6;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.165 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.164 24-Feb-2020  ad v_interlock -> vmobjlock
 1.163 04-Feb-2020  riastradh Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, pullup-2, pullup-1.4T...
 1.162 02-Jan-2020  thorpej branches: 1.162.2;
- Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.161 29-Aug-2019  hannken Add missing operation VOP_GETPAGES() returning EFAULT.

Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.

Observed by maxv@
 1.160 03-Sep-2018  riastradh branches: 1.160.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.159 31-Mar-2018  christos branches: 1.159.2;
factor out some repeated code and simplify the logputchar function.
 1.158 26-May-2017  riastradh branches: 1.158.2; 1.158.8;
Make VOP_RECLAIM do the last unlock of the vnode.

VOP_RECLAIM naturally has exclusive access to the vnode, so having it
locked on entry is not strictly necessary -- but it means if there
are any final operations that must be done on the vnode, such as
ffs_update, requiring exclusive access to it, we can now kassert that
the vnode is locked in those operations.

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.
 1.157 11-Apr-2017  riastradh Make VOP_INACTIVE preserve vnode lock on return.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2017/04/01/msg021751.html

Ride 7.99.68, a bumpy bus of incremental vfs improvements!
 1.156 20-Aug-2016  hannken branches: 1.156.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.155 20-Apr-2015  riastradh branches: 1.155.2;
Make VOP_LINK return directory still locked and referenced.

Ride 7.99.10 bump.
 1.154 25-Jul-2014  dholland branches: 1.154.2; 1.154.4; 1.154.6; 1.154.10;
Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.
 1.153 20-Jul-2014  hannken Change kernfs from hashlist to vcache.
 1.152 17-Jul-2014  hannken Finish KAME IPSEC removal:
- Remove field kfs_value, it is always zero. Compute the hash from kt_tag.
- Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp.

While here, remove kfs_type from allocvp(), it is always kt->kt_tag.
 1.151 08-Apr-2014  christos From Ilya Zykov: Unbreak kernfs which was broken by this commit

|Make the spec_node table implementation private to spec_vnops.c.
|To retrieve a spec_node, two new lookup functions (by device or by mount)
|are implemented. Both return a referenced vnode, for an opened block device
|the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
|will not fire. Otherwise any vnode matching the criteria gets returned.
|No objections on tech-kern.

The effect was that ls /kernfs appeared empty in most cases.
 1.150 07-Feb-2014  hannken branches: 1.150.2;
Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
 1.149 23-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
 1.148 17-Jan-2014  hannken Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
 1.147 18-Mar-2013  plunky branches: 1.147.6;
C99 section 6.7.2.3 (Tags) Note 3 states that:

A type specifier of the form

enum identifier

without an enumerator list shall only appear after the type it
specifies is complete.

which means that we cannot pass an "enum vtype" argument to
kauth_access_action() without fully specifying the type first.
Unfortunately there is a complicated include file loop which
makes that difficult, so convert this minimal function into a
macro (and capitalize it).

(ok elad@)
 1.146 22-Mar-2012  drochner branches: 1.146.2;
remove KAME IPSEC, replaced by FAST_IPSEC
 1.145 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.144 12-Dec-2011  njoly branches: 1.144.2;
Start making fs read(2) fail with EISDIR if the implementation does
not allow read on directories (kernfs, rumpfs, ptyfs and sysvbfs).
Adjust man page accordingly, and add a small corresponding vfs
testcase.
 1.143 21-Jul-2010  hannken branches: 1.143.8; 1.143.12;
Using vfinddev() leads to vnode races as it returns an unreferenced
vnode that may disappear before the caller has a chance to reference it.

Reference the vnode while the specfs cache is locked.

Welcome to 5.99.37.

No objections on tech-kern.
 1.142 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.141 31-Mar-2010  pooka If msgbuf is not enabled, do not report the node in readdir. That
way ls -l won't report funny errors because getattr for a readdir
result fails.

XXX: lookup for msgbuf still succeeds even if not enabled
 1.140 22-Jan-2010  njoly branches: 1.140.2; 1.140.4;
Remove unneeded strlen() call in KFShostname case.
 1.139 08-Jan-2010  pooka The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase). Plenty of mix'n match upper/lowercase has creeped
into the tree since then. Nuke the macros and convert all callsites
to lowercase.

no functional change
 1.138 03-Jul-2009  elad Where possible, extract the file-system's access() routine to two internal
functions: the first checking if the operation is possible (regardless of
permissions), the second checking file-system permissions, ACLs, etc.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
 1.137 23-Jun-2009  elad Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
 1.136 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.135 11-Jan-2009  christos branches: 1.135.2;
merge christos-time_t
 1.134 02-Jan-2008  ad branches: 1.134.6; 1.134.8; 1.134.12; 1.134.20;
Merge vmlocking2 to head.
 1.133 26-Nov-2007  pooka branches: 1.133.2; 1.133.6;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.132 28-Dec-2006  elad branches: 1.132.6; 1.132.18; 1.132.20; 1.132.26;
Revert bogus NULL check introduced in revision 1.96 that generated false
Coverity "bugs".
 1.131 28-Dec-2006  alc revert previous, after inspection `kfs->kfs_kt' could really not be NULL here.

reported/requested by elad@
 1.130 26-Dec-2006  alc CID-3855: check if 'kfs->kfs_kt != NULL' before dereferencing it
 1.129 09-Dec-2006  chs a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
these now always return the parent vnode locked. namei() works as before.
lookup() and various other paths no longer acquire vnode locks in the
wrong order via vrele(). fixes PR 32535.
as a nice side effect, path lookup is also up to 25% faster.
- the above allows us to get rid of PDIRUNLOCK.
- also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
- remove an assumption in layer_node_find() that all file systems implement
a recursive VOP_LOCK() (unionfs doesn't).
- require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
fill in eopnotsupp() for file systems that don't support being exported
and remove the checks for NULL. (layerfs calls these without checking.)
- in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
adjust which vnode is locked. fixes PR 33374.
- apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
 1.128 16-Nov-2006  christos branches: 1.128.2;
__unused removal on arguments; approved by core.
 1.127 04-Nov-2006  jmmv Use size_t in a couple of places as it makes more sense WRT the places
where the variables are later used. From PR kern/25277 by Jeff Ito.
 1.126 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.125 23-Jun-2006  christos branches: 1.125.4; 1.125.6;
remove useless genop
 1.124 23-Jun-2006  bouyer For internal types call kernfs_default_xread() directly, as no entry in
the splay tree has been added for these types. Fix kern/33797 by
Geoff C. Wing.
While here also fix writes the same way (probably broken for 2 years),
and properly implement KERNFS_XREAD.
The IPsec code could probably be moved out now, and use kernfs_alloctype().
 1.123 23-Jun-2006  bouyer Backout previous: of course the change
"Allow optional /kern regular files to have custom read methods..."
works, it's used by Xen.
 1.122 23-Jun-2006  christos PR/33797: Geoff C. Wing: kernfs files are not supplying information
Roll back the change:
'Allow optional /kern regular files to have custom read methods...'
which does not work.
 1.121 07-Jun-2006  kardel branches: 1.121.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.120 14-May-2006  elad branches: 1.120.2;
integrate kauth.
 1.119 04-Apr-2006  christos Coverity CID 1087: Clarify NULL test.
 1.118 14-Mar-2006  bouyer branches: 1.118.2;
Allow optionnal /kern regular files to have custom read methods, the same
way writes are handled: Add KERNFS_XREAD and KERNFS_FILEOP_WRITE files
operations definitions to kfsfileop, a xread function pointer to
kernfs_fileop, rename kernfs_read to kernfs_default_xread and add a
kernfs_read calling kernfs_try_fileop(KERNFS_FILEOP_READ).

Proposed on tech-kern on Feb 18 2006.
 1.117 01-Mar-2006  yamt branches: 1.117.2; 1.117.4;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.116 24-Dec-2005  perry branches: 1.116.2; 1.116.4; 1.116.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.115 11-Dec-2005  christos merge ktrace-lwp.
 1.114 23-Nov-2005  christos Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.113 02-Nov-2005  yamt branches: 1.113.2;
merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.112 01-Sep-2005  christos branches: 1.112.2;
Also protect the ipsec ioctls from negative offsets to prevent panics
in m_copydata(). Pointed out by Karl Janmar. Move the negative offset
check from kernfs_xread() to kernfs_read().
 1.111 31-Aug-2005  christos Don't allow negative offsets when reading the message buffer, because it
can allow reading arbitrary kernel memory.
 1.110 30-Aug-2005  xtraeme Remove __P()
 1.109 29-May-2005  christos branches: 1.109.2;
- sprinkle const
- avoid shadowed variables.
 1.108 20-May-2005  chs kernfs does not support mmap(), remove code that pretends that it does.
 1.107 26-Feb-2005  perry branches: 1.107.2;
nuke trailing whitespace
 1.106 27-Oct-2004  skrll branches: 1.106.4; 1.106.6;
Backout previous.
 1.105 27-Oct-2004  skrll Don't pass &proc0 in the UIO_SYSSPACE case it is not needed.
 1.104 13-May-2004  cl Workaround for gcc 2.95.3 failing to initialize structures
and/or unions inside structures using nested designators.
Should be reverted when gcc >=3.3.3 is ready for vax.
 1.103 12-May-2004  jrf caddr_t -> void * and removal of some more casts.
 1.102 07-May-2004  cl Allow additional entries (files, subdirs) in kernfs. Also allow
defining additional kfstypes and provide hooks to run arbitrary code
for any vnodeop on the additional types.
 1.101 07-May-2004  cl Make lookup and readdir return the same inode number. kernfs_readdir
now uses kernfs_allocvp to map from kernfs entry to inode number,
kernfs_allocvp is now the only place where entries are mapped to inode
numbers. Also make KERNFS_FILENO not return random results for entries
not in kern_targets.
 1.100 07-May-2004  cl Find the right entry when doing lookup on dotdot in kern/ipsec subdirs.
Also remove some duplicate code.
 1.99 29-Apr-2004  jrf Removed remaining caddr_t casts we do not need in miscfs. Recompiled
kernel and ran for a day or so. There are still some caddr_t types in
the arguments of some calls, I will do those separately (later) as
they touch a lot more of the system.
Approved by christos@NetBSD.org.
 1.98 27-Sep-2003  darcy branches: 1.98.2;
Changes as discussed with itojun on tech-kern. I have modified the enums
to have KFS or PFS differentiators. Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
 1.97 26-Sep-2003  atatat Make kernfs peacefully co-exist with procfs.
 1.96 10-Sep-2003  itojun check before deref kfs_kt
 1.95 10-Sep-2003  dan Make /kern/. have linkcount 2 in non-IPSEC case, 4 in IPSEC case.
Thanks to Valeriy E. Ushakov.
 1.94 10-Sep-2003  itojun check if rootdev/rrootdev actually exists.
 1.93 10-Sep-2003  simonb 8 spaces is evil, convert to tab.
 1.92 10-Sep-2003  dan Make vnode times on /kern/boottime be the boot time, not "now".

Handy because ls(1) helpfully converts the time to human-readable
format when printing, and because shell tools like "test -nt" and
"find -newer" can be used against it.

"Inspired" by a discussion about removing lockfiles older than the
last reboot, and Al Crooks' handy observation that a close
approximation can be found with /var/run/dmesg.boot

While here, notice that a lot of the kernfs structures and naming
changed suddenly, and though it seems a clear improvement, there was no
mention in commit logs.
 1.91 08-Sep-2003  itojun remove non-precise comment
 1.90 08-Sep-2003  itojun add /kern/ipsecsa and /kern/ipsecsp, which can be inspected by setkey(8).
it allows easier access to ipsecsa/sp. it works around problem where
setkey -D does not work with large number of ipsec SAs due to socket buffer
size.
 1.89 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.88 29-Jun-2003  fvdl branches: 1.88.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.87 29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.86 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.85 10-Apr-2003  jdolecek use former genfs_eopnotsupp_rele() as genfs_eopnotsupp(), so that vnodes
are vput()/vrele()d as necessary - some filesystems did use the wrong
one for some ops, and it's just safer to not take the chance

based on suggestion by Bill Studenmund
 1.84 12-Oct-2002  jdolecek put back the while loop in kernfs_getattr() removed in rev 1.82; it's
necessary to get the whole file length e.g. for msgbuf

this fixes the '/kern/msgbuf & less' problem reported on port-i386
by Dave Tyson
 1.83 03-Aug-2002  simonb Just use the "time" variable in the *_getattr functions instead of a call
to (the potentially expensive) microtime().
 1.82 19-Jul-2002  jdolecek Properly detect error in kernfs_xread().
Fixes kern/10278 by IWAMOTO Toshihiro, though implemented different way.

While here, clean up some int vs. size_t confusion, make
kernfs_x{read|write}() static and g/c some #if 0 stuff.
 1.81 05-Jul-2002  lukem be consistent about how va_[acm]time is set to the current time
(inspired by how procfs does it)
 1.80 05-Jul-2002  lukem set vap->va_ctime to vap->va_atime (the current time),
rather than vap->va_ctime (which is a no-op).
 1.79 06-Dec-2001  chs branches: 1.79.8; 1.79.10;
add a VOP_PUTPAGES method for all the filesystems that don't have pages,
just unlock the interlock.
 1.78 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.77 10-Nov-2001  lukem add RCSIDs
 1.76 03-Jun-2001  chs branches: 1.76.2; 1.76.6;
let kernfs_mmap() use the default error method.
 1.75 21-Feb-2001  jdolecek branches: 1.75.2;
make some more constant arrays 'const'
 1.74 04-Feb-2001  mrg clean up some KERNFS_DIAGNOSTIC calls.
 1.73 27-Jan-2001  jdolecek Back previous out, it was right the way it was. Seems like I should
attend some basic arithmetic lessons to avoid such mistakes :-/
 1.72 27-Jan-2001  jdolecek fix 'physmem' - the actual value we want is ctob(physmem)
 1.71 22-Jan-2001  jdolecek make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const
 1.70 03-Aug-2000  thorpej MALLOC()/FREE() are not to be used for variable sized allocations.
 1.69 14-Jul-2000  thorpej Sprinkle some const.
 1.68 28-Jun-2000  mrg <vm/vm.h> -> <uvm/uvm_extern.h>
 1.67 25-Aug-1999  sommerfeld branches: 1.67.2; 1.67.8; 1.67.12;
Change variable used for directory offset from "int" to "off_t".
Overkill, but avoids a host of truncation problems.
 1.66 24-Aug-1999  sommerfeld Fix PR8270:

Problem turned out to be due to improper handling of reads beyond EOF:
they should just return without error with the uio unchanged, and the
caller will recognize this as a zero-byte return (EOF).

The previous fix to protect directory reads against bogus uio_offset
values returned EINVAL, which broke mount -o union, which only
union'ed in the lower directory if the upper directory cleanly
returned EOF.

While we're here, protect kernfs as well.
 1.65 03-Aug-1999  wrstuden Add support for fcntl(2) to generate VOP_FCNTL calls. Any fcntl
call with F_FSCTL set and F_SETFL calls generate calls to a new
fileop fo_fcntl. Add genfs_fcntl() and soo_fcntl() which return 0
for F_SETFL and EOPNOTSUPP otherwise. Have all leaf filesystems
use genfs_fcntl().

Reviewed by: thorpej
Tested by: wrstuden
 1.64 08-Jul-1999  wrstuden Bump osrelease to 1.4E. Add layerfs files, remove null_subr.c.

Update coda to new struct lock in struct vnode.

make fdescfs, kernfs, portalfs, and procfs actually lock their vnodes.
It's not that hard.

Make unionfs set v_vnlock = NULL so any overlayed fs will call its
VOP_LOCK.
 1.63 24-Mar-1999  mrg branches: 1.63.2; 1.63.4;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.62 13-Aug-1998  kleink Per POSIX, fail with EINVAL if advisory locking is attempted on a file type
that doesn't support it, rather than using a homegrown EBADF or EOPNOTSUPP.
 1.61 10-Aug-1998  matthias create miscfs/genfs/genfs_vnops.c:genfs_enoioctl and make all the other
filesystems use it instead of a private version.
 1.60 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.59 03-Aug-1998  kleink Recognize _PC_SYNC_IO.
 1.58 08-Mar-1998  mrg standardise options header includes.
 1.57 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.56 12-Feb-1998  thorpej Don't include option headers if building an LKM.
 1.55 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.54 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly. :-)
 1.53 10-Oct-1997  fvdl Bump last argument to VOP_READDIR to off_t (from u_long).
 1.52 19-Sep-1997  leo Implement the kernel part of pr-1891. This allows for a more flexible sized
msgbuf. Note that old 'dmesg' and 'syslogd' binaries will continue running,
though old 'dmesg' binaries will output a few bytes of junk at the start of
the buffer, and will miss a few bytes at the end of the buffer.
 1.51 10-Sep-1997  christos PR/4098: Alan Barrett: Fix diagnostic printf formatting.
 1.50 10-May-1997  pk branches: 1.50.4;
Move `struct kern_target' definition into kernfs.h
 1.49 08-May-1997  mycroft Pass the vnode type to vaccess(), and use it when checking VEXEC. Make sure
that the mode bits passed to vaccess() and returned by foo_getattr() contain
only permission bits.
 1.48 25-Oct-1996  cgd define path name string variables that we should not (and, thankfully, do
not) modify as 'const char *' rather 'char *'.
 1.47 13-Oct-1996  christos backout previous kprintf changes
 1.46 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.45 07-Sep-1996  mycroft Implement poll(2).
 1.44 01-Sep-1996  mycroft Add a set of generic file system operations that most file systems use.
Also, fix some time stamp bogosities.
 1.43 16-Mar-1996  christos Fix printf format follies.
 1.42 13-Feb-1996  mycroft GC *_nullop(). Minor nits.
 1.41 09-Feb-1996  christos miscfs prototype changes
 1.40 09-Feb-1996  mycroft Fix vop_link, vop_symlink, and vop_remove semantics in several ways:
* Change the argument names to vop_link so they actually make sense.
* Implement vop_link and vop_symlink for all file systems, so they do proper
cleanup.
* Require the file system to decide whether or not linking and unlinking of
directories is allowed, and disable it for all current file systems.
 1.39 09-Oct-1995  mycroft Fix the inode calculation in kernfs_getattr().
 1.38 09-Oct-1995  mycroft Use the index number as the cookie, rather than multiplying by UIO_MX.
 1.37 09-Oct-1995  mycroft Add support for cookies, mostly from Greg Hudson.
 1.36 15-Apr-1995  cgd fix timeval vs. timespec warnings
 1.35 03-Feb-1995  mycroft Return EROFS rather than ENOENT in many cases. Also some cosmetic cleanup.
 1.34 27-Dec-1994  mycroft Format police.
 1.33 24-Dec-1994  ws Implement and use a common access checking routine
 1.32 14-Dec-1994  mycroft Remove a_fp.
 1.31 01-Dec-1994  mycroft Make sure averunnable.fscale is filled before using it.
 1.30 14-Nov-1994  christos fixed struct comment
 1.29 20-Oct-1994  cgd update for new syscall args description mechanism
 1.28 21-Jul-1994  mycroft Implement /kern/msgbuf.
 1.27 29-Jun-1994  cgd branches: 1.27.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.26 15-Jun-1994  mycroft Minor update from JSP after merging my changes.
 1.25 15-Jun-1994  mycroft Deal with silly DIAGNOSTIC check.
 1.24 15-Jun-1994  mycroft Use vget() for devices.
 1.23 08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.22 17-May-1994  mycroft Really fix the file size problem.
 1.21 17-May-1994  cgd actually set va_size!
 1.20 14-Feb-1994  ws Add .. entry to /kern
 1.19 11-Feb-1994  cgd don't give bogus return code from read()
 1.18 09-Feb-1994  cgd don't panic if user does 'cat /kern', though result is dubious.
 1.17 05-Jan-1994  cgd update with latest kernfs file system from jsp@sequent.com
 1.16 22-Dec-1993  cgd fix return type of vnode print routine
 1.15 20-Dec-1993  cgd branches: 1.15.2;
pull load average and misc changes down from magnum
 1.14 18-Dec-1993  mycroft Canonicalize all #includes.
 1.13 20-Nov-1993  cgd #ifdef out /kern/root at theo's request
 1.12 07-Sep-1993  ws branches: 1.12.2;
Changes to VFS readdir semantics
NFS changes for better cookie support
ISOFS changes for better Rockridge support and support for generation numbers
 1.11 02-Aug-1993  mycroft Make kernfs_print have a return type of void.
 1.10 07-Jun-1993  cgd give various filesystems their own vnode types
 1.9 28-May-1993  cgd add some more functionality: a setattr which supports chmod+chown+chgrp,
and the various support elsewhere to deal with it.
 1.8 28-May-1993  cgd add kernfs_access function, to kill kernfs security hole
 1.7 20-May-1993  cgd header cleanup
 1.6 27-Apr-1993  cgd fix several off-by-one errors in hostname setting/reading
 1.5 27-Apr-1993  mycroft Use EPERM when write permission is denied, not EBADF.
 1.4 27-Mar-1993  cgd added ".." and support for "rrootdev"
 1.3 25-Mar-1993  cgd fixed problem where you couldn't unmount after looking...
 1.2 25-Mar-1993  cgd changed copyright notice thanks to following statement:

Return-Path: jsp@compnews.co.uk
Received: from ben.uknet.ac.uk by postgres.Berkeley.EDU (5.61/1.29)
id AA25983; Thu, 25 Mar 93 05:37:37 -0800
Received: from fennel.compnews.co.uk by ben.uknet.ac.uk via UKIP with SMTP (PP)
id <g.05640-0@ben.uknet.ac.uk>; Thu, 25 Mar 1993 13:37:19 +0000
Received: from sage.compnews.co.uk by fennel.compnews.co.uk;
Thu, 25 Mar 93 13:37:08 GMT
Message-Id: <28109.9303251337@sage.compnews.co.uk>
From: jsp@compnews.co.uk (Jan-Simon Pendry)
Date: Thu, 25 Mar 1993 13:37:05 +0100
In-Reply-To: cgd@postgres.berkeley.edu's message as of Mar 25, 5:32am.
Phone-Number-1: +44 430 432450
Phone-Number-2: +44 430 432480 x20
Fax-Number: +44 430 432022
X-Mailer: Mail User's Shell (7.2.5 10/14/92)
To: cgd@postgres.berkeley.edu
Subject: Re: fdesc/kernfs/etc code...

You may put this copyright message on the source code:

/*
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
 1.1 23-Mar-1993  cgd branches: 1.1.1;
files which implement the kern filesystem. from Jan-Simon Pendry,
pendry@vangogh.cs.berkeley.edu
 1.1.1.2 01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.1 01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.12.2.4 29-Nov-1993  mycroft Don't crash deferencing a null pointer if the raw root device was not found.
 1.12.2.3 20-Nov-1993  cgd update from trunk
 1.12.2.2 14-Nov-1993  mycroft Canonicalize all #includes.
 1.12.2.1 24-Sep-1993  mycroft kernfs_vnops: averunnable changes.
 1.15.2.3 06-Jan-1994  pk Re-instate EOPNOTSUPP
 1.15.2.2 28-Dec-1993  pk Use ENODEV rather then EOPNOTSUP for unsupported operations on non-socket devices
 1.15.2.1 20-Dec-1993  pk file kernfs_vnops.c was added on branch magnum on 1993-12-28 16:35:19 +0000
 1.27.2.1 22-Jul-1994  cgd from trunk.
 1.50.4.3 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.50.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.50.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.63.4.1 02-Aug-1999  thorpej Update from trunk.
 1.63.2.1 28-Aug-1999  he Pull up revisions 1.66-1.67:
Protect {fdesc,kernfs,procfs}_readdir against directory seeks
with bogus offsets. (sommerfeld)
 1.67.12.1 14-Jul-2000  thorpej Update from trunk:
Sprinkle some const.
 1.67.8.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.67.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.67.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.67.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.75.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.75.2.5 13-Aug-2002  nathanw Catch up to -current.
 1.75.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.75.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.75.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.75.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.76.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.76.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.76.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.79.10.3 29-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #5952):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.114 via patch
Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.79.10.2 14-Oct-2002  lukem Pull up revision 1.84 (requested by jdolecek in ticket #911):
put back the while loop in kernfs_getattr() removed in rev 1.82; it's
necessary to get the whole file length e.g. for msgbuf
this fixes the '/kern/msgbuf & less' problem reported on port-i386
by Dave Tyson
 1.79.10.1 21-Jul-2002  lukem Pull up revision 1.82 (requested by jdolocek in ticket #526):
Properly detect error in kernfs_xread().
Fixes kern/10278 by IWAMOTO Toshihiro, though implemented different way.
While here, clean up some int vs. size_t confusion, make
kernfs_x{read|write}() static and g/c some #if 0 stuff.
 1.79.8.3 29-Aug-2002  gehenna catch up with -current.
 1.79.8.2 20-Jul-2002  gehenna catch up with -current.
 1.79.8.1 15-Jul-2002  gehenna catch up with -current.
 1.88.2.10 11-Dec-2005  christos Sync with head.
 1.88.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.88.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.88.2.7 31-Oct-2004  skrll Reduce diff to HEAD.
 1.88.2.6 27-Oct-2004  skrll Fix various comments that describe the argument structures
 1.88.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.88.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.88.2.3 24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.88.2.2 03-Aug-2004  skrll Sync with HEAD
 1.88.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.98.2.7 29-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #10155):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.114 via patch
Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.98.2.6 01-Sep-2005  riz Pull up following revision(s) (requested by christos in ticket #5637):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.112
Also protect the ipsec ioctls from negative offsets to prevent panics
in m_copydata(). Pointed out by Karl Janmar. Move the negative offset
check from kernfs_xread() to kernfs_read().
 1.98.2.5 31-Aug-2005  tron Pull up following revision(s) (requested by christos in ticket #5633):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.111
Don't allow negative offsets when reading the message buffer, because it
can allow reading arbitrary kernel memory.
 1.98.2.4 24-May-2005  riz Pull up revision 1.108 (requested by chs in ticket #1540):
kernfs does not support mmap(), remove code that pretends that it does.
 1.98.2.3 15-May-2004  tron branches: 1.98.2.3.2;
Pull up revision 1.104 (requested by cl in ticket #326):
Workaround for gcc 2.95.3 failing to initialize structures
and/or unions inside structures using nested designators.
Should be reverted when gcc >=3.3.3 is ready for vax.
 1.98.2.2 15-May-2004  tron Pull up revision 1.102 (requested by cl in ticket #336):
Allow additional entries (files, subdirs) in kernfs. Also allow
defining additional kfstypes and provide hooks to run arbitrary code
for any vnodeop on the additional types.
 1.98.2.1 14-May-2004  jdc Pull up revision 1.100 and 1.101 (requested by cl in ticket #322).

Find the right entry when doing lookup on dotdot in kern/ipsec subdirs.
Also remove some duplicate code.

Make lookup and readdir return the same inode number. kernfs_readdir
now uses kernfs_allocvp to map from kernfs entry to inode number,
kernfs_allocvp is now the only place where entries are mapped to inode
numbers. Also make KERNFS_FILENO not return random results for entries
not in kern_targets.
 1.98.2.3.2.4 29-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #10155):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.114 via patch
Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.98.2.3.2.3 01-Sep-2005  riz branches: 1.98.2.3.2.3.2;
Pull up following revision(s) (requested by christos in ticket #5637):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.112
Also protect the ipsec ioctls from negative offsets to prevent panics
in m_copydata(). Pointed out by Karl Janmar. Move the negative offset
check from kernfs_xread() to kernfs_read().
 1.98.2.3.2.2 31-Aug-2005  tron Pull up following revision(s) (requested by christos in ticket #5633):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.111
Don't allow negative offsets when reading the message buffer, because it
can allow reading arbitrary kernel memory.
 1.98.2.3.2.1 24-May-2005  riz Pull up revision 1.108 (requested by chs in ticket #1540):
kernfs does not support mmap(), remove code that pretends that it does.
 1.98.2.3.2.3.2.1 29-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #10155):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.114 via patch
Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.106.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.106.4.1 29-Apr-2005  kent sync with -current
 1.107.2.4 24-Nov-2005  tron Pull up following revision(s) (requested by christos in ticket #992):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.114 via patch
Fix 64 bit truncation problem reported by http://www.securitylab.net
 1.107.2.3 01-Sep-2005  tron Pull up following revision(s) (requested by christos in ticket #728):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.112
Also protect the ipsec ioctls from negative offsets to prevent panics
in m_copydata(). Pointed out by Karl Janmar. Move the negative offset
check from kernfs_xread() to kernfs_read().
 1.107.2.2 31-Aug-2005  tron Pull up following revision(s) (requested by christos in ticket #727):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.111
Don't allow negative offsets when reading the message buffer, because it
can allow reading arbitrary kernel memory.
 1.107.2.1 28-May-2005  tron Pull up revision 1.108 (requested by chs in ticket #329):
kernfs does not support mmap(), remove code that pretends that it does.
 1.109.2.4 21-Jan-2008  yamt sync with head
 1.109.2.3 07-Dec-2007  yamt sync with head
 1.109.2.2 30-Dec-2006  yamt sync with head.
 1.109.2.1 21-Jun-2006  yamt sync with head.
 1.112.2.1 20-Oct-2005  yamt adapt kernfs.
 1.113.2.1 29-Nov-2005  yamt sync with head.
 1.116.6.3 01-Jun-2006  kardel Sync with head.
 1.116.6.2 22-Apr-2006  simonb Sync with head.
 1.116.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.116.4.1 09-Sep-2006  rpaulo sync with head
 1.116.2.1 05-Feb-2006  yamt adapt kernfs.
 1.117.4.2 19-Apr-2006  elad sync with head.
 1.117.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.117.2.4 26-Jun-2006  yamt sync with head.
 1.117.2.3 24-May-2006  yamt sync with head.
 1.117.2.2 11-Apr-2006  yamt sync with head
 1.117.2.1 01-Apr-2006  yamt sync with head.
 1.118.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.120.2.1 19-Jun-2006  chap Sync with head.
 1.121.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.125.6.2 10-Dec-2006  yamt sync with head.
 1.125.6.1 22-Oct-2006  yamt sync with head
 1.125.4.2 12-Jan-2007  ad Sync with head.
 1.125.4.1 18-Nov-2006  ad Sync with head.
 1.128.2.1 17-Feb-2007  tron Apply patch (requested by chs in ticket #422):
- Fix various deadlock problems with nullfs and unionfs.
- Speed up path lookups by upto 25%.
 1.132.26.2 18-Feb-2008  mjf Sync with HEAD.
 1.132.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.132.20.1 09-Jan-2008  matt sync with HEAD
 1.132.18.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.132.6.1 16-Sep-2007  ad Checkpoint work in progress on the vnode lifecycle and reference counting
stuff. This makes it work properly without kernel_lock and fixes a few
quite old bugs. See vfs_subr.c 1.283.2.17 for details.
 1.133.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.133.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.134.20.2 28-Apr-2009  skrll Sync with HEAD.
 1.134.20.1 19-Jan-2009  skrll Sync with HEAD.
 1.134.12.4 11-Aug-2010  yamt sync with head.
 1.134.12.3 11-Mar-2010  yamt sync with head
 1.134.12.2 18-Jul-2009  yamt sync with head.
 1.134.12.1 04-May-2009  yamt sync with head.
 1.134.8.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.134.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.135.2.2 23-Jul-2009  jym Sync with HEAD.
 1.135.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.140.4.3 05-Mar-2011  rmind sync with head
 1.140.4.2 03-Jul-2010  rmind sync with head
 1.140.4.1 30-May-2010  rmind sync with head
 1.140.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.140.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.143.12.2 05-Apr-2012  mrg sync to latest -current.
 1.143.12.1 18-Feb-2012  mrg merge to -current.
 1.143.8.2 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.143.8.1 17-Apr-2012  yamt sync with head
 1.144.2.2 03-Sep-2016  bouyer Revert ticket 1367, it causes a kernel panic in test lib/libc/gen/t_getcwd
as seen in e.g.
http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/netbsd-6/i386/201608291710Z_anita.txt

lib/libc/gen/t_getcwd (206/500): 2 test cases
getcwd_err: [0.006614s] Passed.
getcwd_fts: uvm_fault(0xc0e221b0, 0, 1) -> 0xe
fatal page fault in supervisor mode
trap type 6 code 0 eip c023ba9f cs 9 eflags 10246 cr2 1c ilevel 0
panic: trap
cpu1: Begin traceback...
panic(c04616d0,cdcfb938,cdcfb938,c023ba9f,9,10246,1c,0,1c,0) at netbsd:panic+0x18
trap() at netbsd:trap+0xb51
--- trap (number 6) ---
kernfs_readdir(cdcfbc0c,1,c11ce0b4,c0439f60,c11ce0b4,cdcfbc58,c0cc0cc0,cdcfbc7c,0,0) at netbsd:kernfs_readdir+0x98f
VOP_READDIR(c11ce0b4,cdcfbc58,c0cc0cc0,cdcfbc7c,0,0,c19287e0,1,cdcfbc58,cdcfbc74) at netbsd:VOP_READDIR+0x68
vn_readdir(c14c3000,bb512000,0,1000,cdcfbcbc,c19287e0,0,0,c14c3000,0) at netbsd:vn_readdir+0xbd
sys___getdents30(c19287e0,cdcfbd00,cdcfbd28,186,bb516000,0,cdcfbd00,c1199bf4,2,bb7a4fe7) at netbsd:sys___getdents30+0x8c
syscall(cdcfbd48,bb6b00b3,ab,bf7f001f,bb6b001f,0,bb5010d0,bf7fe764,bb7c4be0,0) at netbsd:syscall+0xaa
cpu1: End traceback...
 1.144.2.1 27-Aug-2016  bouyer Pull up following revision(s) (requested by is in ticket #1367):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.151
>From Ilya Zykov: Unbreak kernfs which was broken by this commit

|Make the spec_node table implementation private to spec_vnops.c.
|To retrieve a spec_node, two new lookup functions (by device or by mount)
|are implemented. Both return a referenced vnode, for an opened block device
|the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
|will not fire. Otherwise any vnode matching the criteria gets returned.
|No objections on tech-kern.

The effect was that ls /kernfs appeared empty in most cases.
 1.146.2.3 03-Dec-2017  jdolecek update from HEAD
 1.146.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.146.2.1 23-Jun-2013  tls resync from head
 1.147.6.1 18-May-2014  rmind sync with head
 1.150.2.1 10-Aug-2014  tls Rebase.
 1.154.10.1 29-Aug-2019  martin Pull up following revision(s) (requested by hannken in ticket #1703):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.161
sys/miscfs/procfs/procfs_vnops.c: revision 1.207

Add missing operation VOP_GETPAGES() returning EFAULT.

Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.

Observed by maxv@
 1.154.6.1 29-Aug-2019  martin Pull up following revision(s) (requested by hannken in ticket #1703):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.161
sys/miscfs/procfs/procfs_vnops.c: revision 1.207

Add missing operation VOP_GETPAGES() returning EFAULT.

Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.

Observed by maxv@
 1.154.4.3 28-Aug-2017  skrll Sync with HEAD
 1.154.4.2 05-Oct-2016  skrll Sync with HEAD
 1.154.4.1 06-Jun-2015  skrll Sync with HEAD
 1.154.2.1 29-Aug-2019  martin Pull up following revision(s) (requested by hannken in ticket #1703):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.161
sys/miscfs/procfs/procfs_vnops.c: revision 1.207

Add missing operation VOP_GETPAGES() returning EFAULT.

Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.

Observed by maxv@
 1.155.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.156.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.158.8.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.158.8.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.158.2.1 29-Aug-2019  martin Pull up following revision(s) (requested by hannken in ticket #1346):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.161
sys/miscfs/procfs/procfs_vnops.c: revision 1.207

Add missing operation VOP_GETPAGES() returning EFAULT.

Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.

Observed by maxv@
 1.159.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.159.2.1 10-Jun-2019  christos Sync with HEAD
 1.160.4.3 06-Jul-2021  martin Pull up following revision(s) (requested by dholland in ticket #1318):

sys/miscfs/kernfs/kernfs_vnops.c: revision 1.169
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.170

Add missing VOP_KQFILTER to kernfs.

Not sure if lack of it can be used for local DoS or not, but best to
fix.

-

Fix perms on /kern/{r,}rootdev.
 1.160.4.2 12-Feb-2020  martin Pull up following revision(s) (requested by riastradh in ticket #702):

sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...
 1.160.4.1 01-Sep-2019  martin Pull up following revision(s) (requested by hannken in ticket #132):
sys/miscfs/kernfs/kernfs_vnops.c: revision 1.161
sys/miscfs/procfs/procfs_vnops.c: revision 1.207
Add missing operation VOP_GETPAGES() returning EFAULT.
Without this operation posix_fadvise(..., POSIX_FADV_WILLNEED)
would leave the v_interlock held.
Observed by maxv@
 1.162.2.1 29-Feb-2020  ad Sync with head.
 1.166.6.1 01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed