Home | History | Annotate | Download | only in common
History log of /src/sys/compat/common/vfs_syscalls_20.c
RevisionDateAuthorComments
 1.46  28-Jun-2020  christos Fix struct entry size (thanks kre@)
 1.45  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.44  04-Oct-2019  christos branches: 1.44.2;
deduplicate the conversion function from statvfs -> statfs12
 1.43  26-Sep-2019  christos fix sign-compare issues.
 1.42  22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.41  27-Jan-2019  pgoyette branches: 1.41.4;
Merge the [pgoyette-compat] branch
 1.40  13-Apr-2017  hannken branches: 1.40.10; 1.40.12;
Switch compat_20_sys_getfsstat() to mountlist iterator.
 1.39  24-Jul-2015  maxv branches: 1.39.2; 1.39.4;
Unused inits (harmless).

Found by Brainy.
 1.38  05-Sep-2014  matt branches: 1.38.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.37  27-Nov-2013  christos Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
 1.36  23-Nov-2013  christos change the mountlist CIRCLEQ into a TAILQ
 1.35  24-Jun-2010  hannken branches: 1.35.8; 1.35.18; 1.35.22;
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.34  29-Jun-2009  dholland branches: 1.34.2; 1.34.4;
Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.33  20-Nov-2008  ad branches: 1.33.4;
PR port-amd64 modules/compat missing symbols on amd64

Also, test for compat_??_machdep.c so we don't have to grow more ifdefs
in the makefile.
 1.32  14-Nov-2008  ad _KERNEL_OPT
 1.31  24-Jun-2008  ad branches: 1.31.2; 1.31.4;
Replace references to getsock/getvnode.
 1.30  06-May-2008  ad branches: 1.30.2; 1.30.4;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
 1.29  05-May-2008  ad Remove unneeded includes.
 1.28  30-Apr-2008  ad PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
 1.27  29-Apr-2008  ad kern/38135 vfs_busy/vfs_trybusy confusion

The symptom was that sometimes file systems would occasionally not appear
in output from 'df' or 'mount' if the system was busy. Resolution:

- Make mount locks work somewhat like vm_map locks.
- vfs_trybusy() now only fails if the mount is gone, or if someone is
unmounting the file system. Simple contention on mnt_lock doesn't
cause it to fail.
- vfs_busy() will wait even if the file system is being unmounted.
 1.26  21-Mar-2008  ad branches: 1.26.2; 1.26.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.25  30-Jan-2008  ad branches: 1.25.6;
PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.
 1.24  07-Jan-2008  ad Don't drop vnode refs until we are done with the mount.
 1.23  20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.22  08-Dec-2007  pooka branches: 1.22.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.21  08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.20  26-Nov-2007  pooka branches: 1.20.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.19  01-Nov-2007  oster branches: 1.19.2;
This should be a mutex_enter() instead of a mutex_exit().
Fixes:
Mutex error: mutex_vector_exit: assertion failed: MUTEX_OWNER(mtx->mtx_owner) == curthread
...
mutex_abort(c0aba23c,c07bf8b0,c09c9164,bfbfee34,10) at netbsd:mutex_abort+0x36
mutex_vector_exit(c0aba23c,10,c0aba23c,ca8efc6c,ca8f8540) at netbsd:mutex_vector_exit+0xe2
compat_20_sys_getfsstat(ca8f8540,cb243c48,cb243c68,805eb24,805e000) at netbsd:compat_20_sys_getfsstat+0x1bf
...
 1.18  10-Oct-2007  ad branches: 1.18.2;
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.17  22-Apr-2007  dsl branches: 1.17.6; 1.17.8; 1.17.10;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.16  09-Feb-2007  ad branches: 1.16.2; 1.16.6; 1.16.8;
Merge newlock2 to head.
 1.15  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.14  14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.13  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12  23-Jul-2006  ad branches: 1.12.4; 1.12.6;
Use the LWP cached credentials where sane.
 1.11  13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.10  30-Jun-2006  drochner -fix for previous: don't malloc() with spinlock held
-wrap some long lines
 1.9  12-Jun-2006  christos branches: 1.9.2;
stack police: don't allocate statvfs on the stack.
 1.8  14-May-2006  elad branches: 1.8.2;
integrate kauth.
 1.7  07-Mar-2006  thorpej branches: 1.7.2; 1.7.4;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.6  11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8;
merge ktrace-lwp.
 1.5  13-Sep-2005  christos compat code reorg.
 1.4  26-Feb-2005  perry branches: 1.4.4;
nuke trailing whitespace
 1.3  22-May-2004  christos branches: 1.3.2; 1.3.6; 1.3.8;
grr, forgot to take out the &
 1.2  22-May-2004  christos allocate memory for statvfs instead of using the stack.
 1.1  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.3.8.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.6.1  29-Apr-2005  kent sync with -current
 1.3.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.3.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.3.2.2  03-Aug-2004  skrll Sync with HEAD
 1.3.2.1  22-May-2004  skrll file vfs_syscalls_20.c was added on branch ktrace-lwp on 2004-08-03 10:43:29 +0000
 1.4.4.10  24-Mar-2008  yamt sync with head.
 1.4.4.9  04-Feb-2008  yamt sync with head.
 1.4.4.8  21-Jan-2008  yamt sync with head
 1.4.4.7  07-Dec-2007  yamt sync with head
 1.4.4.6  15-Nov-2007  yamt sync with head.
 1.4.4.5  27-Oct-2007  yamt sync with head.
 1.4.4.4  03-Sep-2007  yamt sync with head.
 1.4.4.3  26-Feb-2007  yamt sync with head.
 1.4.4.2  30-Dec-2006  yamt sync with head.
 1.4.4.1  21-Jun-2006  yamt sync with head.
 1.6.8.4  11-Aug-2006  yamt sync with head
 1.6.8.3  26-Jun-2006  yamt sync with head.
 1.6.8.2  24-May-2006  yamt sync with head.
 1.6.8.1  13-Mar-2006  yamt sync with head.
 1.6.6.2  01-Jun-2006  kardel Sync with head.
 1.6.6.1  22-Apr-2006  simonb Sync with head.
 1.6.4.1  09-Sep-2006  rpaulo sync with head
 1.7.4.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.2.4  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.7.2.3  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.7.2.2  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.7.2.1  07-Mar-2006  elad file vfs_syscalls_20.c was added on branch elad-kernelauth on 2006-03-08 01:48:37 +0000
 1.8.2.1  19-Jun-2006  chap Sync with head.
 1.9.2.1  13-Jul-2006  gdamore Merge from HEAD.
 1.12.6.2  10-Dec-2006  yamt sync with head.
 1.12.6.1  22-Oct-2006  yamt sync with head
 1.12.4.2  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.12.4.1  18-Nov-2006  ad Sync with head.
 1.16.8.1  11-Jul-2007  mjf Sync with head.
 1.16.6.2  27-May-2007  ad Sync with head.
 1.16.6.1  13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.16.2.1  07-May-2007  yamt sync with head.
 1.17.10.1  14-Oct-2007  yamt sync with head.
 1.17.8.3  23-Mar-2008  matt sync with HEAD
 1.17.8.2  09-Jan-2008  matt sync with HEAD
 1.17.8.1  06-Nov-2007  matt sync with HEAD
 1.17.6.4  09-Dec-2007  jmcneill Sync with HEAD.
 1.17.6.3  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.17.6.2  04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.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.18.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.19.2.3  18-Feb-2008  mjf Sync with HEAD.
 1.19.2.2  27-Dec-2007  mjf Sync with HEAD.
 1.19.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.20.2.1  26-Dec-2007  ad Sync with head.
 1.22.4.2  08-Jan-2008  bouyer Sync with HEAD
 1.22.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.25.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.25.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.25.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.26.4.4  11-Aug-2010  yamt sync with head.
 1.26.4.3  18-Jul-2009  yamt sync with head.
 1.26.4.2  04-May-2009  yamt sync with head.
 1.26.4.1  16-May-2008  yamt sync with head.
 1.26.2.1  18-May-2008  yamt sync with head.
 1.30.4.1  27-Jun-2008  simonb Sync with head.
 1.30.2.3  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.2.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.30.2.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.31.4.1  19-Jan-2009  skrll Sync with HEAD.
 1.31.2.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.33.4.1  23-Jul-2009  jym Sync with HEAD.
 1.34.4.1  03-Jul-2010  rmind sync with head
 1.34.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.35.22.1  18-May-2014  rmind sync with head
 1.35.18.2  03-Dec-2017  jdolecek update from HEAD
 1.35.18.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.8.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.38.2.2  28-Aug-2017  skrll Sync with HEAD
 1.38.2.1  22-Sep-2015  skrll Sync with HEAD
 1.39.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.39.2.1  26-Apr-2017  pgoyette Sync with HEAD
 1.40.12.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.40.12.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.40.12.1  10-Jun-2019  christos Sync with HEAD
 1.40.10.1  30-Mar-2018  pgoyette Create and build the compat_20 module
 1.41.4.1  03-Aug-2022  martin Apply patch, requested by riastradh in ticket #1487:

sys/compat/common/vfs_syscalls_20.c (apply patch)

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.44.2.1  17-Jan-2020  ad Sync with head.

RSS XML Feed