Commit Graph

386 Commits

Author SHA1 Message Date
wrstuden 3bf14d81e9 Add support for fcntl(2) to generate VOP_FCNTL calls. Any fcntl
call with F_FSCTL set and F_SETFL calls generate calls to a new
fileop fo_fcntl. Add genfs_fcntl() and soo_fcntl() which return 0
for F_SETFL and EOPNOTSUPP otherwise. Have all leaf filesystems
use genfs_fcntl().

Reviewed by: thorpej
Tested by: wrstuden
1999-08-03 20:19:16 +00:00
sommerfeld d96e35f23c Fix PR4439: directory link count in unions where only upper directory
exists is bogus.  The goal here is to produce a synthetic link count
which won't confuse fts and similar routines which "know" that
directories with a link count of 2 don't have subdirectories (and
thus, they can avoid having to stat every entry in the directory
looking for subdirectories which aren't there).

We know that non-UNIX filesystem implementations may return a link
count of `1' for directories with an indeterminate number of
subdirectories; if either the upper or lower layer returns a link
count of `1', return a link count of 1.  If both layers return a link
count of 2, return a link count of 2; otherwise, return the sum of the
link count of both layers.

Also, fix PR7430: unionfs ignores read-only mounts.  Check for
MNT_RDONLY in union_lookup (more-or-less as in layer_lookup) as well
as union_access() and union_setattr().

Note that a read-only union layer may still cause side effects on the
underlying filesystems...  Most notably, we'll still attempt to create
shadow directories in the upper layer.  Also, of course, we'll
side-effect atimes in the lower layer.
1999-08-01 23:16:34 +00:00
sommerfeld cb448a064d Fix PR5146: reboot with working directory in unionfs causes
"panic: lockmgr: using decommisioned lock"
(only if DIAGNOSTIC)

The problem turned out to be due to the way LK_DRAIN was (not) handled
in union_lock; it just got passed through to the lock on the upper
vnode (which got marked as decommissioned, instead of that happening
to the union vnode.  When the upper vnode was next locked (typically
when it was released), it went kaboom.
1999-08-01 00:00:57 +00:00
sommerfeld 29469abdbd On forced unmount, do a few passes of non-forced cleanups and then do
a single forced pass.  Along for the ride with PR5146 fix.
1999-07-31 23:56:15 +00:00
thorpej fc04cf9982 Add calls to lock the proclist as appropriate. 1999-07-25 18:33:47 +00:00
thorpej 2715b812d1 Rework the process exit path, in preparation for making process exit
and PID allocation MP-safe.  A new process state is added: SDEAD.  This
state indicates that a process is dead, but not yet a zombie (has not
yet been processed by the process reaper).

SDEAD processes exist on both the zombproc list (via p_list) and deadproc
(via p_hash; the proc has been removed from the pidhash earlier in the exit
path).  When the reaper deals with a process, it changes the state to
SZOMB, so that wait4 can process it.

Add a P_ZOMBIE() macro, which treats a proc in SZOMB or SDEAD as a zombie,
and update various parts of the kernel to reflect the new state.
1999-07-22 18:13:36 +00:00
thorpej 7f53187a85 From Bill Studenmund: unlock the fdescfs "/dev/tty" vnode before calling
cttyread()/cttywrite(), and lock it again when it returns.

Squashes the somewhat bizarre lossage I was observing w/ more(1), sudo(1),
etc.
1999-07-19 23:00:47 +00:00
wrstuden a0f2937049 Define VLAYER and make layered fs's set this flag when creating their vnodes.
getnewvnode now checks this bit, and it if's set makes sure a vnode's not
locked before removing it from the free list.

Closes PR 7954 by Alan Barrett <apb@iafrica.com>.
1999-07-15 21:30:31 +00:00
thorpej f9b0db3013 Fix a paste-o in procfs_lookup() introduced with the vnode locking changes.
Fixes PR #7961, Mario Kemper <magick@bundy.lip.owl.de>.
1999-07-14 23:52:22 +00:00
wrstuden b7f5310486 Fix tyop pointed out by Chuck Silvers <chuq@chuq.com>. 1999-07-12 16:37:03 +00:00
wrstuden 9fc36d6807 Bump osrelease to 1.4E. Add layerfs files, remove null_subr.c.
Update coda to new struct lock in struct vnode.

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

Make unionfs set v_vnlock = NULL so any overlayed fs will call its
VOP_LOCK.
1999-07-08 01:26:21 +00:00
wrstuden 9866514df5 Introduce layer library in genfs. This set of files abstracts most of
the functionality of nullfs. The latter is now just a mount & unmount
routine, and a few tables. umapfs borrow most of this infrastructure.

Both fs's are now nfs-exportable.

All layered fs's share a common format to private mount & private
vnode structs (which a particular fs can extend).

Also add genfs_noerr_rele(), a vnode op which will vrele/vput
operand vnodes appropriately.
1999-07-08 01:18:59 +00:00
perseant c951c272b0 Fixes PR #1206, by setting va_mode and va_flags in the copied-up vnode's
attributes.
1999-06-25 19:05:49 +00:00
wrstuden 96321000fc Remove explicit references to null_bypass (used in umap_lock() and
umap_unlock()) so as to not explicitly depend on nullfs being compiled
into the kernel.

umap_bypass won't be too slow as there are no credentials in these two ops
to need mapping.
1999-05-17 20:29:05 +00:00
thorpej e3669c3393 Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
1999-05-05 20:01:01 +00:00
thorpej e9d133eb3b Adjust for cwdinfo changes. Pointed out by Bernd Ernesti. 1999-05-02 00:18:31 +00:00
thorpej ce5ede558e Fix excessive memory usage, and fix handling of SZOMB processes. PR #7164,
Jaromir Dolecek.
1999-04-27 06:02:09 +00:00
drochner 10bc77390d remove unneeded <vm/vm_object.h> 1999-04-10 14:00:38 +00:00
wrstuden 636995172d Make message about not loking a vnode in nullfs_create a little quieter -
now only enabled if NULLFS_DIAGNOSTIC and no longer if DEBUG or DIAGNOSTIC.
1999-04-09 17:27:38 +00:00
bouyer e045fbf363 We must handle MNT_NODEV at open time, so add an open op for null and union,
and do proper checks in union_open(). Fix to nullfs from OpenBSD, extended
to umap and union by me.
1999-03-25 13:05:41 +00:00
sommerfe ef07055d58 Disallow tracing of processes unless tracer's root directory is at or
above tracee's root directory.
1999-03-25 04:45:56 +00:00
sommerfe b6c36d0fe4 fix union node lock to sleep on something it'll be woken on.. 1999-03-24 05:53:59 +00:00
mrg d2397ac5f7 completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
1999-03-24 05:50:49 +00:00
sommerfe 36dc99adac vinvalbuf, called from vclean, could cause a locking-against-self
deadlock in VOP_FSYNC() if the unreferenced vnode picked for
reclamation happened to be stacked on top of a vnode the process
already had locked.  This could happen if the same filesystem was
accessed both through a union mount and directly; it seemed to happen
most frequently when the direct access was through NFS.

Avoid this deadlock by changing vinvalbuf to pass a new FSYNC_RECLAIM
flag bit to VOP_FSYNC() to indicate that a reclaim is in progress and
only a `shallow' fsync is necessary.

Do nothing in *_fsync() in umapfs, nullfs, and unionfs when
FSYNC_RECLAIM is set; the underlying vnodes will shortly be released
in *_reclaim and may be reclaimed (and fsync'ed) later.
1999-03-22 17:24:19 +00:00
perseant 247156f4d2 Apply patch from kern/5538:
Fix group mapping so members of group 0 get other group-ids mapped as well.
Avoid rename panic by checking (*this_vp_p) against NULLVP before
dereferencing it (same change as to NULLFS some time ago).
1999-03-19 21:46:25 +00:00
thorpej 195403fe38 malloc the arg temporary buffer, rather than declaring it as an automatic
array of ARG_MAX size.  ARG_MAX is currently 256k, which causes a rather
serious stack overflow (kernel stacks are not very large, usually 8k).

Fixes memory corruption problems observed after accessig /proc/1/cmdline
during tests.  Problem in my case manifested itself as massive lossage
in ffs_sync(), resulting in a crash, and sometimes, pooched file systems.

XXX This could, and probably should, be rewritten to use a much smaller
temporary buffer, and a loop around uiomove().
1999-03-13 22:26:48 +00:00
thorpej 4865d6ff88 Some changes to `cmdline' to make it work properly:
- Don't error out on P_SYSTEM or SZOMB processes; instead, do what ps(1)
  would do, i.e. the p_comm in parenthesis.
- Use uvm_io() (or procfs_rwmem() if !UVM) to read the target process's
  psstrings and argument vector.  Using copyin() is problematic, because
  it operates on the current processes!  That is, the old code would
  always get the `cmdline' of the process reading the file, not that of
  the target process.
1999-03-13 01:01:30 +00:00
thorpej 5e7b128211 Expose procfs_rwmem(). (This function will go away entirely when we
delete Mach VM.)
1999-03-13 00:57:13 +00:00
christos 8aa2fc5ab8 PR/7143: Jaromir Docelek: Add procfs/cmdline from Linux emulation 1999-03-12 18:45:40 +00:00
bouyer 0a2d2af9e0 Restrict umap mounts to root. Letting any user use this has security
implications.
1999-03-12 18:16:44 +00:00
mycroft b174019ccc Pass null pointers to VOP_UPDATE rather than having all the callers fetch the
current time themselves.
1999-03-05 21:09:48 +00:00
wrstuden 862a56e88b Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.
1999-02-26 23:44:43 +00:00
wrstuden 0078fc50dc Modify VOP_CLOSE vnode op to always take a locked vnode. Change vn_close
to pass down a locked node. Modify union_copyup() to call VOP_CLOSE
locked nodes.

Also fix a bug in union_copyup() where a lock on the lower vnode would
only be released if VOP_OPEN didn't fail.
1999-02-26 23:38:55 +00:00
is fde637530e Machine independent part of fix for PR 6152 (gdb doesn't work on machines
with UVM and seperate I&D-Cache). Mostly by Michael Hitch, but pass struct
proc * instead of the pmap. Reason: said machine will need a method to do
the syncing operation for "curproc", too; this way more code can be shared.
1999-02-25 21:54:53 +00:00
msaitoh 1f5b9b4d63 sprintf->snprintf 1999-02-03 05:05:03 +00:00
drochner 7847c0f52e make it compile with !UVM 1999-01-28 21:18:00 +00:00
msaitoh ea669760d6 Add /proc/#/map. From FreeBSD. 1999-01-25 02:20:08 +00:00
wrstuden c7fc6c74ca Oops. That extra "*" doesn't need to be there. 1999-01-15 22:04:44 +00:00
wrstuden 872d72e705 In nullfs_mount, we need to check if error before VOP_UNLOCK(vp,0) as
vp is initialized iff error==0 in null_node_create.
1999-01-13 01:51:37 +00:00
matt 32a315ff7c Use the so_send and so_receive funcptrs in the socket instead of calling
sosend/soreceive directly.  [I've been meaning to commit these for months.]
1998-10-31 01:18:41 +00:00
ross e1b25b7bd6 Make spec_write() process errors and return them, otherwise we don't even
notice things like hitting the end of a partition or device.  (To be sure,
writes to block special files are rare, but as long as we support them...)
1998-10-02 00:21:39 +00:00
jonathan fcf7a78c02 Workaropund fix for PR #5239 from <minoura@kw.netlaputa.ne.jp>:
stop  null_node_create() from locking the nullfs mountpoint  multiple
  times. Avoids a guaranteed, repeatably "locking against myself" panic
  during mount of a nullfs filesystem.  nullfs filesystems are still as
  buggy as ever (e.g., see PR# 4907) but this you at least mount them.
1998-09-30 06:50:10 +00:00
thorpej 970e60efb8 - Use proclists[], rather than checking allproc and zombproc explicitly.
- Add some comments about locking.
1998-09-08 23:50:13 +00:00
thorpej 7cc905f5c8 Add some braces to make egcs happy (ambiguous else warning). 1998-08-18 06:27:01 +00:00
kleink 5350df2953 Per POSIX, fail with EINVAL if advisory locking is attempted on a file type
that doesn't support it, rather than using a homegrown EBADF or EOPNOTSUPP.
1998-08-13 10:06:31 +00:00
kleink bf1863d17b Add genfs_einval(), which does the obvious thing. 1998-08-13 09:59:52 +00:00
eeh a2dd74ed79 Merge paddr_t changes into the main branch. 1998-08-13 02:10:37 +00:00
matthias 574106c52b create miscfs/genfs/genfs_vnops.c:genfs_enoioctl and make all the other
filesystems use it instead of a private version.
1998-08-10 08:11:10 +00:00
perry 4522c799a1 bzero->memset, bcopy->memcpy, bcmp->memcmp 1998-08-09 20:51:08 +00:00
kleink 12a866151b Recognize _PC_SYNC_IO. 1998-08-03 14:19:57 +00:00
lukem 786b86d71b use AF_LOCAL instead of AF_UNIX 1998-07-18 05:04:35 +00:00
jonathan d275e56dee * defopt COMPAT_{09,10,11,12,13} and COMPAT_NOMID.
TODO: revisit interaction between native compat and emul compat usage.
1998-07-05 08:49:30 +00:00
thorpej 961f0708b1 - Rename nqnfs_vop_lease_check() to genfs_lease_check(). If NFSSERVER is
not in the kernel, genfs_lease_check() is simply a no-op.  This allows
  LKM'd file systems to be exported (previously did not work properly
  due to a compile-time decision based on -DNFSSERVER).
- defopt NFSSERVER
1998-06-25 22:15:28 +00:00
sommerfe 7ba7fbbb23 Always include fifos; "not an option any more". 1998-06-24 20:58:44 +00:00
sommerfe becaafeea0 defopt for options FIFO 1998-06-22 22:00:59 +00:00
cgd 651b44e211 Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install.  (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.)  The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change.  Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
1998-06-12 23:22:30 +00:00
kleink 382743ada3 Convert fsync vnode operator implementations and usage from the old `waitfor'
argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT.
1998-06-05 19:53:00 +00:00
kleink a32a338757 * Convert fsync vnode operator implementations and usage from the old
waitfor argument and MNT_WAIT/MNT_NOWAIT to flags and FSYNC_WAIT.
* In genfs_fsync(), honor the FSYNC_NODATA flag.
1998-06-05 19:52:59 +00:00
fvdl 8ccdc78ffc Since the interlock has been unlocked, also clear LK_INTERLOCK from
a_flags in order to not confuse the layer that is called through
the following VCALL.
1998-05-18 16:47:37 +00:00
pk 097731676e dead_lock() must unlock `v_interlock'. 1998-05-18 14:36:46 +00:00
fvdl 811dba68c1 procfs_readdir: in case of error, check if cookies actually have
been allocated before freeing them. From Wolfgang Solfrank.
1998-04-21 16:36:37 +00:00
veego dd9d3a3015 Fix an error introduced in rev 1.39 where jason fixed kern/5271:
s/vp/ap->a_vp/ in line 715.
1998-04-11 08:51:12 +00:00
thorpej 13eebaf27e Fix two problems in union_link():
(1) Fix a typo that caused a NULL pointer deref.
(2) union_copyup() locks the vnode, so unlock it before calling relookup().
PR #5272, MINOURA, Makoto <minoura@kw.netlaputa.ne.jp>.
1998-04-10 01:43:54 +00:00
thorpej 181995d5f7 Fix possible stray pointer deref in union_access, per PR #5271,
submitted by MINOURA, Makoto <minoura@kw.netlaputa.ne.jp>.
1998-04-10 01:39:45 +00:00
marc efbd14c45d mounting a union causes VOP_WHITEOUT to be called on the upper root
vn, with a 0 component.  If the upper fs was a unionfs,
union_whiteout() would deref compnent to get a struct proc, and panic.
struct proc was only being passed to FIXUP, which never used it.  It
turns out this happened a lot.  I ripped most of the unneeded code
out, and left in the few places that really did need the proc handle.
1998-03-17 08:36:57 +00:00
fvdl f75b1046d4 Fix flags mess-up in vget. LK_EXCLUSIVE -> 0 (even indicated in the
comment, d'oh!)
1998-03-11 15:52:02 +00:00
mrg c6dd5cbefd standardise options header includes. 1998-03-08 14:04:14 +00:00
fvdl 7ba6a2daac Remove extraneous files from Lite2 merge. 1998-03-01 13:45:28 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
fvdl e8d05f0741 Import 4.4BSD-Lite2 1998-03-01 02:12:49 +00:00
thorpej 62cb255d14 Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().
1998-02-18 07:26:57 +00:00
thorpej b5bf2ed6d0 Place a pointer to an array of our vnodeopv_desc *'s in our vfsops
structure, for use by vfs_attach().
1998-02-18 07:05:47 +00:00
thorpej d2924ae854 Prevent the session ID from disappearing if the session leader exits
(thus causing s_leader to become NULL) by storing the session ID separately
in the session structure.  Export the session ID to userspace in the
eproc structure.

Submitted by Tom Proett <proett@nas.nasa.gov>.
1998-02-14 00:37:26 +00:00
thorpej 44ed0e5b79 Don't include option headers if building an LKM. 1998-02-12 20:38:45 +00:00
mrg d90485202c - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
1998-02-10 14:08:44 +00:00
chs f64abc7b4c add flags arg to hashinit(), to pass to malloc(). 1998-02-07 02:44:44 +00:00
mrg 1a8c7604f4 initial import of the new virtual memory system, UVM, into -current.
UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code.  i provided some help
getting swap and paging working, and other bug fixes/ideas.  chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly.  :-)
1998-02-05 07:59:28 +00:00
perry 1a80fd799d RCSID Police. 1998-01-05 19:19:41 +00:00
fvdl 766487d941 Too many vnode ops were marked as bad op, but could happen in practice.
Change them to genfs_eopnotsupp.
1997-11-27 20:36:05 +00:00
mycroft d24c4d31e1 Make the curproc link executable. 1997-10-30 09:14:07 +00:00
christos 4071635fa6 Add missing cast to dev_t 1997-10-16 23:57:51 +00:00
fvdl ce56587f15 Bump last argument to VOP_READDIR to off_t (from u_long). 1997-10-10 02:01:05 +00:00
fvdl ebffddb531 Bump last argument to VOP_READDIR to off_t (from u_long). 1997-10-10 02:01:02 +00:00
fvdl ab940dcf06 Bump last argument to VOP_READDIR to off_t (from u_long). 1997-10-10 02:00:56 +00:00
mycroft 4383ea0b92 Make openstr[] const. 1997-10-09 13:12:01 +00:00
mycroft 64d080efe0 Make various standard wmesg strings const. 1997-10-09 12:59:50 +00:00
thorpej c9efd0562e Make the vfs ops and vnodeop_opv symbols match the name of the
file-system option used to configure the file system into the kernel.
1997-10-06 09:32:31 +00:00
leo e0f973ee3b Implement the kernel part of pr-1891. This allows for a more flexible sized
msgbuf. Note that old 'dmesg' and 'syslogd' binaries will continue running,
though old 'dmesg' binaries will output a few bytes of junk at the start of
the buffer, and will miss a few bytes at the end of the buffer.
1997-09-19 19:14:20 +00:00
enami b4ae3706db Use the same indentation as other two place, sys_ptrace() and
procfs_control().

Ok'ed by Jason R. Thorpe.
1997-09-13 04:25:35 +00:00
christos 4fb8bf7262 PR/4098: Alan Barrett: Fix diagnostic printf formatting. 1997-09-10 13:44:20 +00:00
thorpej a79a3ca472 Fix a reversed argument which caused procfs_checkioperm() to always return
"OK".  Add a few comments to avoid further confusion.
1997-08-27 08:52:51 +00:00
explorer 945beb8d63 Move procfs_checkioperm() from procvs_subr.c to procfs_mem.c, since _subr is
not included in a kernel without procfs, and it seems wrong to pull
all of procfs_subr.c in for just that one function.  Perhaps this
should go into a new file instead?
1997-08-13 04:01:22 +00:00
thorpej f9777e4a1c Fix the procfs hole described on current-users, similar to a fix for
FreeBSD by Sean Eric Fagan, but a bit different.  This makes the checks
in the same places as sef's FreeBSD patch, but does not hardcode the
"kmem" group into the kernel, and also does a check identical to the
(3) and (4) checks in the NetBSD ptrace(2):

	(1) it's not owned by you, or is set-id on exec (unless
	    you're root), or

	(2) it's init, which controls the security level of the
	    entire system, and the system was not compiled with
	    permanently insecure mode turned on.
1997-08-12 22:47:18 +00:00
drochner aa015962db Since there is a "%qx" printf format, don't truncate to long for
debug output.
1997-07-04 19:22:48 +00:00
mycroft 2ee8bc2b79 Don't allow writes to init's memory or registers while in secure mode. 1997-06-25 11:32:15 +00:00
thorpej a149ed59e4 Eliminate use of dtom() in the handing of UNIX domain sockets. Add an
"unp_addrlen" member to the unpcb, and use it when copying the socket
name.  This eliminates that last uses of dtom() in the system.
1997-06-24 19:12:53 +00:00
kleink a1c6b08386 When reading from an empty FIFO no process has opened for writing, and
O_NONBLOCK is set, return 0.
1997-05-18 12:19:29 +00:00
pk 80bb266e0e NULL => 0 (Arne Juul; PR#3629) 1997-05-17 20:31:15 +00:00
pk 420dea1e9a Move `struct kern_target' definition into kernfs.h 1997-05-10 22:04:13 +00:00
mycroft 3be66b88fe Update for lookup() changes. 1997-05-09 04:05:01 +00:00