Home | History | Annotate | only in /src/sys/fs/ptyfs
History log of /src/sys/fs/ptyfs
RevisionDateAuthorComments
 1.1 14-Jun-2010  pooka branches: 1.1.2; 1.1.4; 1.1.6;
Install ptyfs userspace header into user's space.
 1.1.6.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.6.1 14-Jun-2010  uebayasi file Makefile was added on branch uebayasi-xip on 2010-08-17 06:47:18 +0000
 1.1.4.2 11-Aug-2010  yamt sync with head.
 1.1.4.1 14-Jun-2010  yamt file Makefile was added on branch yamt-nfs-mp on 2010-08-11 22:54:34 +0000
 1.1.2.2 03-Jul-2010  rmind sync with head
 1.1.2.1 14-Jun-2010  rmind file Makefile was added on branch rmind-uvmplock on 2010-07-03 01:19:50 +0000
 1.4 11-Oct-2014  uebayasi Define filesystem attributes with vfs dependency.
 1.3 02-Mar-2010  pooka branches: 1.3.20;
Don't generate unused fs_thefs.h headers.
 1.2 11-Dec-2005  christos branches: 1.2.74; 1.2.96;
merge ktrace-lwp.
 1.1 11-Nov-2004  jdolecek branches: 1.1.2;
move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.1.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 11-Nov-2004  skrll file files.ptyfs was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.2.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.74.1 11-Mar-2010  yamt sync with head
 1.3.20.1 03-Dec-2017  jdolecek update from HEAD
 1.16 27-Nov-2020  christos make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.15 17-Jan-2020  ad branches: 1.15.6;
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.14 15-Aug-2014  hannken branches: 1.14.20; 1.14.26;
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.13 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.12 04-Apr-2014  christos branches: 1.12.4;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.11 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.10 24-Oct-2012  christos branches: 1.10.2;
rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.9 18-Sep-2012  christos Always do the chroot filename mapping; it is pointless not to do it.
 1.8 15-Mar-2009  christos branches: 1.8.12; 1.8.18; 1.8.20; 1.8.22;
Add a chroot flag, so that ptyfs can be mounted in a chrooted environment.
XXX: This is a hack, in reality we should allow multiple ptyfs mounts.
 1.7 28-Jun-2008  rumble branches: 1.7.4; 1.7.10;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.6 11-Dec-2005  christos branches: 1.6.70; 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 03-Dec-2005  christos - protect userland exported files against multiple inclusion.
- make sure that kernel only files don't compile in userland using #error
- XXX: some kernel only files still get installed.
- XXX: some files used in userland, don't get installed.
 1.4 12-Sep-2005  christos Fix the CHANGE part too.
 1.3 16-Dec-2004  atatat branches: 1.3.10;
Reorder ptyfs pseudo inode numbers so that 0 and 1 are unused, 2 is
the root of the file system, and slaves and masters alternate starting
at 3. This means the inode numbers won't be really large until you
really allocate a really lot of ptys.
 1.2 25-Nov-2004  christos Add pty group and mode settings.
 1.1 11-Nov-2004  jdolecek branches: 1.1.2;
move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.1.2.6 11-Dec-2005  christos Sync with head.
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.1.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 11-Nov-2004  skrll file ptyfs.h was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.3.10.1 21-Jun-2006  yamt sync with head.
 1.6.78.1 03-Jul-2008  simonb Sync with head.
 1.6.76.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.74.1 04-May-2009  yamt sync with head.
 1.6.70.1 29-Jun-2008  mjf Sync with HEAD.
 1.7.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.22.3 03-Dec-2017  jdolecek update from HEAD
 1.8.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.20.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.8.18.1 01-Oct-2012  riz Pull up following revision(s) (requested by christos in ticket #566):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.11
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.12
sys/fs/ptyfs/ptyfs.h: revision 1.9
sbin/mount_ptyfs/mount_ptyfs.c: revision 1.14
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.43
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.44
Does not make sense to mount this as NFS, so it is not a bug.
We can now mount multiple instances, but all of them show all the ptys.
let us get mounted multiple times.
remove -c and chroot option; they are always on now
Always do the chroot filename mapping; it is pointless not to do it.
 1.8.12.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.8.12.1 30-Oct-2012  yamt sync with head
 1.10.2.1 18-May-2014  rmind sync with head
 1.12.4.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.14.26.1 17-Jan-2020  ad Sync with head.
 1.14.20.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.6.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.34 27-Nov-2020  christos make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.33 15-Oct-2014  christos branches: 1.33.32;
From Ilia Zykov:
- correct some incorrect comments
- add XXX warning
- increase security by activating when get the slave
- make pty_vn_open() private to tty_ptm.c
 1.32 16-Aug-2014  hannken Needs HASH_SLIST, not HASH_LIST.
 1.31 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.30 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.29 27-Mar-2014  christos branches: 1.29.4;
From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
 1.28 26-Mar-2014  christos if one of the ptyfs instances has grabbed the handle don't grab it again,
Ilya Zykov
 1.27 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.26 27-Feb-2014  hannken The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

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

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

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

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

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

Discussed on tech-kern.

Welcome to 6.99.33
 1.25 24-Oct-2012  christos branches: 1.25.2;
rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.24 23-Oct-2012  christos fix the mystery of the bad directory times.
 1.23 12-Jun-2011  rmind branches: 1.23.2; 1.23.8; 1.23.12;
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.22 19-Nov-2010  dholland branches: 1.22.6;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.21 21-Jul-2010  hannken Make holding v_interlock mandatory for callers of vget().

Announced some time ago on tech-kern.
 1.20 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.19 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.18 24-Mar-2009  haad branches: 1.18.2; 1.18.4;
Destroy mutexes used to guard hash table during vfs_detach. Fixes LOCKDEBUG
panic when ptyfs module is unloaded.
 1.17 17-Dec-2008  cegger branches: 1.17.2;
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 25-Jan-2008  ad - Make new vnode construction MPSAFE.
- Replace use of lockmgr().
 1.13 24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.12 02-Jan-2008  ad Merge vmlocking2 to head.
 1.11 08-Dec-2007  pooka branches: 1.11.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.10 26-Nov-2007  pooka branches: 1.10.2;
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.9 10-Oct-2007  ad branches: 1.9.4;
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.8 21-Jul-2007  ad branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10;
Don't depend on uvm_extern.h pulling in proc.h.
 1.7 14-May-2006  elad branches: 1.7.18; 1.7.28;
integrate kauth.
 1.6 13-Apr-2006  christos Strip the chrooted portion of the path from the reported pty path. Reported
and tested by Lasse Kliemann. Thanks!
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.6; 1.5.8; 1.5.10; 1.5.12;
merge ktrace-lwp.
 1.4 12-Sep-2005  christos don't play with ctime directly anymore.
 1.3 12-Sep-2005  christos Fix the CHANGE part too.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2; 1.2.14;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.14.6 04-Feb-2008  yamt sync with head.
 1.2.14.5 21-Jan-2008  yamt sync with head
 1.2.14.4 07-Dec-2007  yamt sync with head
 1.2.14.3 27-Oct-2007  yamt sync with head.
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 21-Jun-2006  yamt sync with head.
 1.2.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_subr.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.5.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.10.3 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.5.10.2 19-Apr-2006  elad sync with head.
 1.5.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.5.8.1 24-May-2006  yamt sync with head.
 1.5.6.2 01-Jun-2006  kardel Sync with head.
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.7.28.1 15-Aug-2007  skrll Sync with HEAD.
 1.7.18.6 23-Oct-2007  ad Sync with head.
 1.7.18.5 09-Oct-2007  ad Sync with head.
 1.7.18.4 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.7.18.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.7.18.2 05-Apr-2007  ad Compile fixes.
 1.7.18.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.8.10.2 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.8.10.1 21-Jul-2007  ad file ptyfs_subr.c was added on branch matt-mips64 on 2007-07-21 19:06:22 +0000
 1.8.8.1 14-Oct-2007  yamt sync with head.
 1.8.6.3 23-Mar-2008  matt sync with HEAD
 1.8.6.2 09-Jan-2008  matt sync with HEAD
 1.8.6.1 06-Nov-2007  matt sync with HEAD
 1.8.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.8.4.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.9.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.9.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.9.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.2.2 26-Dec-2007  ad Sync with head.
 1.10.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.11.4.1 02-Jan-2008  bouyer 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.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.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.18.4.3 05-Mar-2011  rmind sync with head
 1.18.4.2 03-Jul-2010  rmind sync with head
 1.18.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.18.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.22.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.12.3 03-Dec-2017  jdolecek update from HEAD
 1.23.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.8.1 31-Oct-2012  riz Pull up following revision(s) (requested by christos in ticket #639):
sys/fs/ptyfs/ptyfs_subr.c: revision 1.24
fix the mystery of the bad directory times.
 1.23.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.23.2.1 30-Oct-2012  yamt sync with head
 1.25.2.1 18-May-2014  rmind sync with head
 1.29.4.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.33.32.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.58 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.57 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.56 17-Feb-2017  hannken branches: 1.56.14; 1.56.20;
Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
 1.55 21-Oct-2014  christos branches: 1.55.2; 1.55.4; 1.55.6;
Revert previous; it does not work with COMPAT_BSDPTY, screen(1) fails because
it does a TIOCPTSNAME immediately after opening ptmx and finds an old style pty.
 1.54 15-Oct-2014  christos From Ilia Zykov:
- correct some incorrect comments
- add XXX warning
- increase security by activating when get the slave
- make pty_vn_open() private to tty_ptm.c
 1.53 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.52 14-Aug-2014  maxv Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.

Sent on tech-kern@, ok christos@
 1.51 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.50 16-Apr-2014  maxv branches: 1.50.2;
An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
 1.49 04-Apr-2014  christos branches: 1.49.2;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.48 27-Mar-2014  christos From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
 1.47 23-Mar-2014  hannken Change all vfsops to use C99 designated initializers.

No functional changes intended.
 1.46 19-Mar-2014  christos - return an error if we could not get the pts pathname
- correct getting pathname if the mount point inside a chroot
(Ilya Zykov)
 1.45 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.44 18-Sep-2012  christos branches: 1.44.2;
let us get mounted multiple times.
 1.43 18-Sep-2012  christos Always do the chroot filename mapping; it is pointless not to do it.
 1.42 08-Jan-2010  pooka branches: 1.42.12; 1.42.18; 1.42.20; 1.42.22;
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.41 30-Nov-2009  pooka Introduce genfs_statvfs() as pretty much a no-info statvfs and
convert several pseudo file systems to use it.
 1.40 21-Mar-2009  christos Fix old userland compat.
 1.39 15-Mar-2009  christos Add a chroot flag, so that ptyfs can be mounted in a chrooted environment.
XXX: This is a hack, in reality we should allow multiple ptyfs mounts.
 1.38 11-Jan-2009  christos branches: 1.38.2;
merge christos-time_t
 1.37 26-Oct-2008  joerg branches: 1.37.2; 1.37.4; 1.37.6; 1.37.14; 1.37.18;
Remove logic to compute relative pathes to chroots. It breaks the
default case of ptyfs mounted under /dev/pts as any chroot would get
/%d as slave names. This allows null mounts of ptyfs to work.
To allow pty allocation from within chroots, either no ptyfs must be
mounted or a null mount exist.
 1.36 28-Jun-2008  rumble branches: 1.36.2;
Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.35 13-May-2008  simonb branches: 1.35.2;
mnt_data is a pointer, set it to NULL not 0 when we're finished with it.
 1.34 13-May-2008  simonb Use the correct malloc type when free()ing the ptyfs mount structure.
Fixes the "free 2: inuse 0, probable double free" panic when using ptyfs
and KMEMSTATS.
 1.33 10-May-2008  rumble 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.32 29-Apr-2008  ad branches: 1.32.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.31 28-Jan-2008  dholland branches: 1.31.6; 1.31.8; 1.31.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.30 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.29 24-Sep-2007  rumble branches: 1.29.4;
Avoid stack allocation of large dirent structures in foo_readdir().
 1.28 31-Jul-2007  pooka branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8;
* 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.27 26-Jul-2007  pooka Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter.
 1.26 17-Jul-2007  pooka branches: 1.26.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.25 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.24 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.23 19-Jan-2007  hannken branches: 1.23.6; 1.23.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.22 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.21 16-Nov-2006  christos branches: 1.21.2;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 03-Sep-2006  christos branches: 1.19.2; 1.19.4;
add missing initializers
 1.18 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.17 20-Jun-2006  tron Make this compile again.
 1.16 20-Jun-2006  christos Don't allocate too much stuff on the stack.
 1.15 14-May-2006  elad branches: 1.15.4;
integrate kauth.
 1.14 28-Apr-2006  christos Do the count check after we process getargs.
 1.13 13-Apr-2006  christos Strip the chrooted portion of the path from the reported pty path. Reported
and tested by Lasse Kliemann. Thanks!
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 01-Oct-2005  christos use a counter to prevent from mounting ptyfs twice. Using save_ptm is not
good enough, because if we don't have COMPAT_BSDPTY, then it will stay NULL.
 1.10 29-Sep-2005  christos Move the duplicate mount check sooner, and fix a leak.
 1.9 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.8 29-May-2005  christos branches: 1.8.2;
- rename variables to avoid shadowing.
- add a few const.
 1.7 11-May-2005  christos Remove compat code that hard-codes default group and mode for pty creation.
Hi Matt!
 1.6 29-Mar-2005  thorpej - 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.5 26-Feb-2005  perry nuke trailing whitespace
 1.4 02-Jan-2005  christos branches: 1.4.2; 1.4.4;
make this compile again; hi potr
 1.3 25-Nov-2004  christos Add pty group and mode settings.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.2.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_vfsops.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.4.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.8.2.7 04-Feb-2008  yamt sync with head.
 1.8.2.6 07-Dec-2007  yamt sync with head
 1.8.2.5 27-Oct-2007  yamt sync with head.
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.4 11-May-2006  elad sync with head
 1.12.10.3 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.12.10.2 19-Apr-2006  elad sync with head.
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.4 03-Sep-2006  yamt sync with head.
 1.12.8.3 11-Aug-2006  yamt sync with head
 1.12.8.2 26-Jun-2006  yamt sync with head.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.2 01-Jun-2006  kardel Sync with head.
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.15.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.19.4.2 10-Dec-2006  yamt sync with head.
 1.19.4.1 22-Oct-2006  yamt sync with head
 1.19.2.3 01-Feb-2007  ad Sync with head.
 1.19.2.2 12-Jan-2007  ad Sync with head.
 1.19.2.1 18-Nov-2006  ad Sync with head.
 1.21.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.23.8.1 11-Jul-2007  mjf Sync with head.
 1.23.6.3 09-Oct-2007  ad Sync with head.
 1.23.6.2 20-Aug-2007  ad Sync with HEAD.
 1.23.6.1 15-Jul-2007  ad Sync with head.
 1.26.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.28.8.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.28.8.1 31-Jul-2007  pooka file ptyfs_vfsops.c was added on branch matt-mips64 on 2007-07-31 21:14:19 +0000
 1.28.6.1 06-Oct-2007  yamt sync with head.
 1.28.4.3 23-Mar-2008  matt sync with HEAD
 1.28.4.2 09-Jan-2008  matt sync with HEAD
 1.28.4.1 06-Nov-2007  matt sync with HEAD
 1.28.2.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.28.2.1 02-Oct-2007  joerg Sync with HEAD.
 1.29.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.29.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.31.10.3 11-Mar-2010  yamt sync with head
 1.31.10.2 04-May-2009  yamt sync with head.
 1.31.10.1 16-May-2008  yamt sync with head.
 1.31.8.1 18-May-2008  yamt sync with head.
 1.31.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.35.2.1 03-Jul-2008  simonb Sync with head.
 1.36.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.37.18.1 28-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.37.14.1 28-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.37.6.2 09-Nov-2008  christos account for major and minor being unsigned long long
 1.37.6.1 26-Oct-2008  christos file ptyfs_vfsops.c was added on branch christos-time_t on 2008-11-09 02:05:20 +0000
 1.37.4.1 25-Apr-2014  sborrill Pull up the following revisions(s) (requested by maxv in ticket #1901):
sys/kern/vfs_syscalls.c: revision 1.478, 1.480 via patch
sys/coda/coda_vfsops.c: revision 1.81
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50 via patch
sys/fs/puffs/puffs_vfsops.c: revision 1.110 via patch
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59 via patch
sys/fs/udf/udf_vfsops.c: revision 1.67
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/kern/vfs_syscalls.c: revision 1.479
sys/miscfs/nullfs/null_vfsops.c: revision 1.88 via patch
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/nfs/nfs_vfsops.c: revision 1.227
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/ufs/mfs/mfs_vfsops.c: revision 1.107

Due to missing checks in the mount syscall, and a wrong assumption on the
file systems side, the kernel could allocate an unbounded or zero-sized
memory buffer, and could dereference a NULL pointer when particular
arguments are given by a user.
 1.37.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.37.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.42.22.3 03-Dec-2017  jdolecek update from HEAD
 1.42.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.42.20.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.42.18.3 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.2 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.42.18.1 01-Oct-2012  riz branches: 1.42.18.1.2; 1.42.18.1.4;
Pull up following revision(s) (requested by christos in ticket #566):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.11
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.12
sys/fs/ptyfs/ptyfs.h: revision 1.9
sbin/mount_ptyfs/mount_ptyfs.c: revision 1.14
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.43
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.44
Does not make sense to mount this as NFS, so it is not a bug.
We can now mount multiple instances, but all of them show all the ptys.
let us get mounted multiple times.
remove -c and chroot option; they are always on now
Always do the chroot filename mapping; it is pointless not to do it.
 1.42.18.1.4.2 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.1.4.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.42.18.1.2.2 27-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1115):
sys/miscfs/umapfs/umap_vfsops.c: revision 1.94
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
1) 'error' is returned while it does not even hold an error code. Which
means that zero is returned, and the kernel keeps mounting (and it
probably ends up in a deadlock/memory corruption somewhere).
2) 'nentries' and 'gnentries' are int and user-controlled, and there's no
check to ensure they are greater than zero. Since they are used to
compute the size of two copyin's, a user can control the copied size
by giving a negative value (like 128-2^29), and thus overwrite kernel
memory.
Both triggerable from root only.
 1.42.18.1.2.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1050):
sys/ufs/chfs/chfs_vfsops.c: revision 1.11
sys/fs/unionfs/unionfs_vfsops.c: revision 1.13
sys/fs/nilfs/nilfs_vfsops.c: revision 1.16
sys/ufs/mfs/mfs_vfsops.c: revision 1.107
sys/fs/sysvbfs/sysvbfs_vfsops.c: revision 1.43
sys/ufs/ffs/ffs_vfsops.c: revision 1.297
sys/kern/vfs_syscalls.c: revision 1.478
sys/kern/vfs_syscalls.c: revision 1.479
sys/fs/puffs/puffs_vfsops.c: revision 1.110
sys/fs/cd9660/cd9660_vfsops.c: revision 1.84
sys/nfs/nfs_vfsops.c: revision 1.227
sys/fs/v7fs/v7fs_vfsops.c: revision 1.10
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.180
sys/miscfs/umapfs/umap_vfsops.c: revision 1.92
sys/fs/filecorefs/filecore_vfsops.c: revision 1.76
sys/miscfs/nullfs/null_vfsops.c: revision 1.88
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.50
sys/coda/coda_vfsops.c: revision 1.81
sys/ufs/lfs/lfs_vfsops.c: revision 1.321
sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.59
sys/fs/hfs/hfs_vfsops.c: revision 1.31
sys/miscfs/overlay/overlay_vfsops.c: revision 1.61
sys/fs/union/union_vfsops.c: revision 1.72
sys/fs/ntfs/ntfs_vfsops.c: revision 1.94
sys/kern/vfs_syscalls.c: revision 1.480
sys/fs/efs/efs_vfsops.c: revision 1.25
sys/kern/vfs_syscalls.c: revision 1.482
sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.107
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c: revision 1.12
sys/miscfs/procfs/procfs_vfsops.c: revision 1.91
sys/fs/smbfs/smbfs_vfsops.c: revision 1.100
sys/fs/adosfs/advfsops.c: revision 1.70
sys/fs/udf/udf_vfsops.c: revision 1.67
Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.
ok christos@
An (un)privileged user can easily make the kernel dereference a NULL
pointer.
The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).
ok christos@
Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.
If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
 1.42.12.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.42.12.1 30-Oct-2012  yamt sync with head
 1.44.2.1 18-May-2014  rmind sync with head
 1.49.2.1 10-Aug-2014  tls Rebase.
 1.50.2.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.55.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.55.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.55.2.1 28-Aug-2017  skrll Sync with HEAD
 1.56.20.1 17-Jan-2020  ad Sync with head.
 1.56.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.69 05-Aug-2022  riastradh ptyfs: Don't copy out cookies past end of buffer.

Reported-by: syzbot+2aae7c4eddc796f917e6@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=5fe24c1da952ac2ea498d745d6479bc6be91a751
 1.68 08-Dec-2021  andvar s/efficent/efficient/ in comments.
 1.67 20-Oct-2021  thorpej Overhaul of the EVFILT_VNODE kevent(2) filter:

- Centralize vnode kevent handling in the VOP_*() wrappers, rather than
forcing each individual file system to deal with it (except VOP_RENAME(),
because VOP_RENAME() is a mess and we currently have 2 different ways
of handling it; at least it's reasonably well-centralized in the "new"
way).
- Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ,
compatible with the same events in FreeBSD.
- Track which kevent notifications clients are interested in receiving
to avoid doing work for events no one cares about (avoiding, e.g.
taking locks and traversing the klist to send a NOTE_WRITE when
someone is merely watching for a file to be deleted, for example).

In support of the above:

- Add support in vnode_if.sh for specifying PRE- and POST-op handlers,
to be invoked before and after vop_pre() and vop_post(), respectively.
Basic idea from FreeBSD, but implemented differently.
- Add support in vnode_if.sh for specifying CONTEXT fields in the
vop_*_args structures. These context fields are used to convey information
between the file system VOP function and the VOP wrapper, but do not
occupy an argument slot in the VOP_*() call itself. These context fields
are initialized and subsequently interpreted by PRE- and POST-op handlers.
- Version VOP_REMOVE(), uses the a context field for the file system to report
back the resulting link count of the target vnode. Return this in tmpfs,
udf, nfs, chfs, ext2fs, lfs, and ufs.

NetBSD 9.99.92.
 1.66 18-Jul-2021  dholland Fix ptyfs link and symlink ops.

They were set (via macro obfuscation just eliminated) to
genfs_abortop, which is the wrong thing. These code paths are
currently inaccessible because of EROFS enforcement in namei, but if
either were reached odd behavior would likely ensue. Use
genfs_eopnotsupp like the rest of the ops that don't make sense here.
 1.65 18-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.
 1.64 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.63 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.62 27-Nov-2020  christos branches: 1.62.4;
make the order of the arguments in the PTYFS_FILENO macro consistent with
the order in the function calls. One of them was incorrect. Noticed by martin@
 1.61 24-Nov-2020  christos PR/55821: tar can not extract base.tgz anymore (./dev/pts and mounted ptyfs)
Allow chown/chmod at the root of ptyfs.
 1.60 27-Jun-2020  christos branches: 1.60.2;
Introduce genfs_pathconf() and use it for the default case in all filesystems.
 1.59 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.58 13-Apr-2020  ad Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed(). Signature matches
FreeBSD.
 1.57 26-Sep-2019  christos branches: 1.57.6;
provide VNOVALSIZE and VNOVALFLAGS to avoid casting in source.
 1.56 26-Sep-2019  christos cast VNOVAL to the the va_size type which is u_quad_t... I think it is time
to change this to uint64_t...
 1.55 03-Sep-2018  riastradh branches: 1.55.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.54 26-May-2017  riastradh branches: 1.54.8; 1.54.10;
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.53 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.52 20-Aug-2016  hannken branches: 1.52.2;
Remove now obsolete operation vcache_remove().

Welcome to 7.99.36
 1.51 23-Jun-2015  hannken branches: 1.51.2;
No need to call spec_inactive() from ptyfs_incative().
 1.50 21-Aug-2014  maxv branches: 1.50.2;
Remove dead returns:

return VAR/func(XX);
return VAR;

The latter is never reached. Sent on tech-kern@, no disagreement.
 1.49 15-Aug-2014  hannken Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.

OK: Christos Zoulas
 1.48 13-Aug-2014  hannken - Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().

OK: Christos Zoulas
 1.47 25-Jul-2014  dholland branches: 1.47.2;
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.46 04-Apr-2014  christos branches: 1.46.2;
Handle multiple ptyfs mounts with different chroots. ptys opened in one
chroot are only visible in that chroot.
 1.45 27-Mar-2014  christos forgot to commit one patch:
Avoid returning released(free), but still hashed inode numbers.
(Ilya Zykov)
 1.44 21-Mar-2014  christos Ilya Zykov: Prepare readdir for multi-mountpoint use
 1.43 07-Feb-2014  hannken 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.42 05-Nov-2013  christos - support advisory locking on ptys
- get the link count correct for .
XXX: pullup 6
 1.41 18-Mar-2013  plunky branches: 1.41.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.40 24-Oct-2012  christos rename ptyfs_flag -> ptyfs_status to avoid confusion with ptyfs_flags
 1.39 13-Mar-2012  elad branches: 1.39.2;
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.38 12-Dec-2011  njoly 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.37 18-Nov-2011  christos branches: 1.37.4;
Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too.
 1.36 16-Sep-2011  christos branches: 1.36.2;
don't update access/change times on open.
 1.35 12-Jun-2011  rmind 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.34 24-Jun-2010  hannken branches: 1.34.6;
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.33 08-Jan-2010  pooka branches: 1.33.2; 1.33.4;
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.32 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.31 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.30 07-May-2009  elad Extract the open-coded authorization logic for chtimes() from various
file-systems and put it in a single function, genfs_can_chtimes().

This also makes UDF follow the same policy as all other file-systems.

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/04/27/msg004951.html
 1.29 22-Apr-2009  elad Per discussion on tech-kern@:

- Replace use of label/goto with returns

- Rename, change prototype of, and move functions from vfs_subr.c to
genfs_vnops.c
 1.28 20-Apr-2009  elad Refactor some duplicated file-system code.

Proposed and received no objections on tech-kern@:

http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
 1.27 02-Jan-2008  ad branches: 1.27.10; 1.27.18; 1.27.24;
Merge vmlocking2 to head.
 1.26 26-Nov-2007  pooka branches: 1.26.2; 1.26.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.25 24-Sep-2007  rumble branches: 1.25.4;
Simplify ptyfs_readdir at pooka's suggestion.

No functional change intended.
 1.24 24-Sep-2007  rumble Avoid stack allocation of large dirent structures in foo_readdir().
 1.23 09-Jul-2007  ad branches: 1.23.6; 1.23.8; 1.23.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.22 19-Jan-2007  christos branches: 1.22.6; 1.22.8;
only change atime on access.
 1.21 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.20 29-Dec-2006  elad Remove support for immutable and append-only flags on ptyfs.
 1.19 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.18 16-Nov-2006  christos branches: 1.18.2;
__unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 23-Jul-2006  ad branches: 1.16.4; 1.16.6;
Use the LWP cached credentials where sane.
 1.15 07-Jun-2006  kardel 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.14 14-May-2006  elad branches: 1.14.2;
integrate kauth.
 1.13 14-Apr-2006  christos Remove dead code.
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 02-Nov-2005  yamt merge yamt-vop branch. remove following VOPs.

VOP_BLKATOFF
VOP_VALLOC
VOP_BALLOC
VOP_REALLOCBLKS
VOP_VFREE
VOP_TRUNCATE
VOP_UPDATE
 1.10 12-Oct-2005  simonb branches: 1.10.2;
Update the mod and access times directly from ptyfs_read() and
ptyfs_write() rather than setting a flag and updating these times
through ptyfs_itimes() at some indeterminate time in the future.
However, just use the "time" variable to set the times instead of
using a potentially expensive call to nanotime(). A HZ resolution
on these timestamps is more than enough.

(Possibly incomplete) fix for PR kern/31430.
OK'd be christos@.
 1.9 12-Sep-2005  christos Fix the CHANGE part too.
 1.8 12-Sep-2005  christos propagate itime changes from the other filesystems.
 1.7 26-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 18-Dec-2004  christos branches: 1.6.2; 1.6.4;
I don't think that the vgone() in vop_inactive is needed; in fact it might
be the source of my deadlocks.
 1.5 29-Nov-2004  atatat Remove the digits() function and simply set va_bytes and va_size to
zero in ptyfs_getattr(). There's no reason to make them something
else and no other devices (except for disk devices) report anything
other than zero here, so why should we be different?
 1.4 25-Nov-2004  atatat Properly set va_fsid so that st_dev ends up correct.
 1.3 19-Nov-2004  atatat Don't call ptyfs_time() with stack garbage. It makes the times look
funny. I was getting stuff somewhere around 1939, but that's where my
kernel is.
 1.2 11-Nov-2004  jdolecek branches: 1.2.2;
update #include path to fs/ptyfs/
 1.1 11-Nov-2004  jdolecek move ptyfs off sys/miscfs/ptyfs/ to sys/fs/ptyfs/
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.2.2.3 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.2 14-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 11-Nov-2004  skrll file ptyfs_vnops.c was added on branch ktrace-lwp on 2004-11-14 08:15:57 +0000
 1.6.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.2.1 29-Apr-2005  kent sync with -current
 1.7.4.7 21-Jan-2008  yamt sync with head
 1.7.4.6 07-Dec-2007  yamt sync with head
 1.7.4.5 27-Oct-2007  yamt sync with head.
 1.7.4.4 03-Sep-2007  yamt sync with head.
 1.7.4.3 26-Feb-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 20-Oct-2005  yamt adapt ptyfs.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.10.7 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.12.10.6 19-Apr-2006  elad sync with head.
 1.12.10.5 11-Mar-2006  elad Fix typo.
 1.12.10.4 11-Mar-2006  elad When calling kauth_cred_ismember_gid(), don't return the error code if
there is one, just treat it as if the check failed.

Pointed out by thorpej@.
 1.12.10.3 11-Mar-2006  elad kauth_cred_groupmember() -> kauth_cred_ismember_gid(), as requested by
thorpej@ to conform to the Darwin KPI.
 1.12.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.12.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.12.8.3 11-Aug-2006  yamt sync with head
 1.12.8.2 26-Jun-2006  yamt sync with head.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.4 01-Jun-2006  kardel Sync with head.
 1.12.6.3 22-Apr-2006  simonb Sync with head.
 1.12.6.2 05-Feb-2006  simonb In the *itimes functions, just call getnanotime() at the start of
the function and use the result if needed, rather than the previous
conditional calls/assignments method. The code is clearer this way,
and benchmarks at about the same speed.
 1.12.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 19-Jun-2006  chap Sync with head.
 1.16.6.2 10-Dec-2006  yamt sync with head.
 1.16.6.1 22-Oct-2006  yamt sync with head
 1.16.4.3 01-Feb-2007  ad Sync with head.
 1.16.4.2 12-Jan-2007  ad Sync with head.
 1.16.4.1 18-Nov-2006  ad Sync with head.
 1.18.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.22.8.1 11-Jul-2007  mjf Sync with head.
 1.22.6.3 09-Oct-2007  ad Sync with head.
 1.22.6.2 13-Apr-2007  ad - Make the devsw interface MP safe, and add some comments.
- Allow individual block/character drivers to be marked MP safe.
- Provide wrappers around the device methods that look up the
device, returning ENXIO if it's not found, and acquire the
kernel lock if needed.
 1.22.6.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.23.10.1 06-Oct-2007  yamt sync with head.
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.23.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.25.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.25.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.26.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.26.2.1 04-Dec-2007  ad Pull the vmlocking changes into a new branch.
 1.27.24.2 23-Jul-2009  jym Sync with HEAD.
 1.27.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.10.5 11-Aug-2010  yamt sync with head.
 1.27.10.4 11-Mar-2010  yamt sync with head
 1.27.10.3 18-Jul-2009  yamt sync with head.
 1.27.10.2 16-May-2009  yamt sync with head
 1.27.10.1 04-May-2009  yamt sync with head.
 1.33.4.2 03-Jul-2010  rmind sync with head
 1.33.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.33.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.34.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.36.2.3 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.36.2.2 30-Oct-2012  yamt sync with head
 1.36.2.1 17-Apr-2012  yamt sync with head
 1.37.4.2 05-Apr-2012  mrg sync to latest -current.
 1.37.4.1 18-Feb-2012  mrg merge to -current.
 1.39.2.4 03-Dec-2017  jdolecek update from HEAD
 1.39.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.2.2 23-Jun-2013  tls resync from head
 1.39.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.41.6.1 18-May-2014  rmind sync with head
 1.46.2.1 10-Aug-2014  tls Rebase.
 1.47.2.1 17-Aug-2014  riz Pull up following revision(s) (requested by hannken in ticket #29):
sbin/mount_ptyfs/mount_ptyfs.8: revision 1.14
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.48
sys/fs/ptyfs/ptyfs_vnops.c: revision 1.49
sys/fs/ptyfs/ptyfs_subr.c: revision 1.30
sys/fs/ptyfs/ptyfs_subr.c: revision 1.31
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.51
sys/fs/ptyfs/ptyfs_subr.c: revision 1.32
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.52
sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.53
sys/fs/ptyfs/ptyfs.h: revision 1.13
sys/fs/ptyfs/ptyfs.h: revision 1.14
Needs HASH_SLIST, not HASH_LIST.
Change ptyfs to vcache.
- Use (type, minor) as key.
- Change ptyfs_allocvp to return a referenced vnode and lock where needed.
- Remove unneeded vnode backpointer ptyfs_vnode.
- Keep a single hashlist for pty nodes to make their attributes persistent.
OK: Christos Zoulas
Overflow if *data_len == OSIZE and args->version >= PTYFS_ARGSVERSION.
Sent on tech-kern@, ok christos@
Adapt to reality -- already open BSD style nodes do not appear on
ptyfs mounts (this changed some months ago).
- Add a map of active controlling ptys per mount and no longer abuse
the vnode lifecycle.
- No longer set "recycle" on VOP_INACTIVE().
- Make ptyfs_used_get() private to ptyfs_subr.c
- Stop copying device attributes from traditional ptys on first allocation.
- Remove unneeded argument "lwp" from ptyfs_allocvp() and ptyfs_free_get().
OK: Christos Zoulas
 1.50.2.3 28-Aug-2017  skrll Sync with HEAD
 1.50.2.2 05-Oct-2016  skrll Sync with HEAD
 1.50.2.1 22-Sep-2015  skrll Sync with HEAD
 1.51.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.52.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.54.10.3 21-Apr-2020  martin Sync with HEAD
 1.54.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.54.10.1 10-Jun-2019  christos Sync with HEAD
 1.54.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.4.2 04-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1703):

sys/fs/ptyfs/ptyfs_vnops.c: revision 1.61

PR/55821: tar can not extract base.tgz anymore (./dev/pts and mounted ptyfs)

Allow chown/chmod at the root of ptyfs.
 1.55.4.1 29-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1504):

sys/fs/ptyfs/ptyfs_vnops.c: revision 1.69

ptyfs: Don't copy out cookies past end of buffer.
 1.57.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.60.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.62.4.1 01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed