Commit Graph

580 Commits

Author SHA1 Message Date
Bruce Evans
1e1c37f1cd Return ENOTTY instead of EBADF for ioctls on dead vnodes. This fixes
tcsetpgrp() on controlling terminals that are no longer associated
with the session of the calling process, not to mention ioctl.2.
1998-11-22 09:19:07 +00:00
Bruce Evans
c25ded316f Finished updating module event handlers to be compatible with
modeventhand_t.
1998-11-15 15:33:52 +00:00
Peter Wemm
5187e87901 "fix" a warning that has been bugging me for ages. Eliminate a couple
of temporary variables since they are only used once and their types
were the cause of the warnings.
1998-11-09 09:21:25 +00:00
Peter Wemm
497e02e364 Delete stray extern declaration for non-existing variables. 1998-11-09 07:03:04 +00:00
Peter Wemm
8c14bf40a1 Change the #ifdef UNION code into a callable hook. Arrange to have this
set up when unionfs is present, either statically or as a kld module.
1998-11-03 08:01:48 +00:00
Peter Wemm
40c8cfe552 Use TAILQ macros for clean/dirty block list processing. Set b_xflags
rather than abusing the list next pointer with a magic number.
1998-10-31 15:31:29 +00:00
David Greenman
730075613a Added a second argument, "activate" to the vm_page_unwire() call so that
the caller can select either inactive or active queue to put the page on.
1998-10-28 13:37:02 +00:00
Bruce Evans
569555b969 Removed redundant bitrotted checks for major numbers instead of updating
them.
1998-10-26 08:53:13 +00:00
Søren Schmidt
4d075b334c Make devfs update the atime timestamp so that 'w' works when using
options DEVFS.
1998-09-30 20:33:46 +00:00
Poul-Henning Kamp
649c00db71 various nits that didn't make it through the brucefilter. 1998-09-12 20:21:54 +00:00
Bruce Evans
9754189a91 Oops, don't assume that the environment is normal in devfs_mount().
It isn't for the hidden mountpoint.  The static vfs's haven't been
attached then, so mp->mnt_vfc can't be valid.
1998-09-08 16:59:37 +00:00
Bruce Evans
8994ca3ce9 Removed statically configured mount type numbers (MOUNT_*) and all
references to them.

The change a couple of days ago to ignore these numbers in statically
configured vfsconf structs was slightly premature because the cd9660,
cfs, devfs, ext2fs, nfs vfs's still used MOUNT_* instead of the number
in their vfsconf struct.
1998-09-07 13:17:06 +00:00
Poul-Henning Kamp
0375c9f2b8 Add a new vnode op, VOP_FREEBLKS(), which filesystems can use to inform
device drivers about sectors no longer in use.

Device-drivers receive the call through d_strategy, if they have
D_CANFREE in d_flags.

This allows flash based devices to erase the sectors and avoid
pointlessly carrying them around in compactions.

Reviewed by:	Kirk Mckusick, bde
Sponsored by:	M-Systems (www.m-sys.com)
1998-09-05 14:13:12 +00:00
Doug Rabson
e69763a315 Cosmetic changes to the PAGE_XXX macros to make them consistent with
the other objects in vm.
1998-09-04 08:06:57 +00:00
Poul-Henning Kamp
a9ea5c0c51 sort the prototypes 1998-08-25 17:48:54 +00:00
Poul-Henning Kamp
07fe032454 Last commit managed to get mangled somehow. 1998-08-24 18:23:18 +00:00
Poul-Henning Kamp
1d9b3ba13d Remove the last remaining evidence of B_TAPE.
Reclaim 3 unused bits in b_flags
1998-08-24 17:47:25 +00:00
Bruce Evans
4e9a89772a Enabled Lite2 fix for reading from dead ttys. 1998-08-23 11:43:29 +00:00
Bruce Evans
86a14a7a0a Use [u]intptr_t instead of [u_]long for casts between pointers and
integers.  Don't forget to cast to (void *) as well.
1998-08-16 01:21:52 +00:00
Bruce Evans
89785a1654 Fixed printf format errors. 1998-07-30 17:40:45 +00:00
Alexander Langer
f35f7d0dfd Style fixes and a bug fix: don't remove the exit handler if unmount
fails.

Submitted by:	bde
1998-07-27 22:47:17 +00:00
Alexander Langer
3f47ee5c4d A better solution to the rm_at_exit problem: Register the exit function
during first mount.  Unregister the exit function at last unmount.

Concept by:	sef
Reviewed by:	sef
Implemented by:	alex
1998-07-27 01:07:01 +00:00
Alexander Langer
ca2be56ff9 Override the default VFS LKM dispatch functions so that a module
unload function can be provided (this is necessary to unregister
the at_exit handler).
1998-07-25 15:52:44 +00:00
Bruce Evans
15c7382561 Cast pointers to [u]intptr_t instead of to [unsigned] long. 1998-07-15 04:17:55 +00:00
Bruce Evans
a23d65bfc8 Cast pointers to uintptr_t/intptr_t instead of to u_long/long,
respectively.  Most of the longs should probably have been
u_longs, but this changes is just to prevent warnings about
casts between pointers and integers of different sizes, not
to fix poorly chosen types.
1998-07-15 02:32:35 +00:00
Bruce Evans
ac1e407b32 Fixed printf format errors. 1998-07-11 07:46:16 +00:00
Bruce Evans
96eb19e1a3 Quick fix for type mismatches which were fatal if longs aren't 32
bits.  We used a private, wrong, version of `struct dirent' to help
break getdirentries(), and we use a silly check that the size of this
struct is a power of 2 to help break mount() if getdirentries() would
not work.  This fix just changes the struct to match `struct dirent'
(except for the name length).
1998-07-07 04:08:44 +00:00
Julian Elischer
6312920c20 DEVFS completely bypasses the cdevsw and bdevsw tables now.
Each devfs node has (and has had fro a while) a pointer directly to
the correct cdefsw entry so just use it instead of doing the lookup.

There are several other places in the kernel that still use the tables
however, so they can't go away yet..
1998-07-05 23:10:22 +00:00
Julian Elischer
f7ea2f55d1 There is no such thing any more as "struct bdevsw".
There is only cdevsw (which should be renamed in a later edit to deventry
or something). cdevsw contains the union of what were in both bdevsw an
cdevsw entries.  The bdevsw[] table stiff exists and is a second pointer
to the cdevsw entry of the device. it's major is in d_bmaj rather than
d_maj. some cleanup still to happen (e.g. dsopen now gets two pointers
to the same cdevsw struct instead of one to a bdevsw and one to a cdevsw).

rawread()/rawwrite() went away as part of this though it's not strictly
the same  patch, just that it involves all the same lines in the drivers.

cdroms no longer have write() entries (they did have rawwrite (?)).
tapes no longer have support for bdev operations.

Reviewed by: Eivind Eklund and Mike Smith
	Changes suggested by eivind.
1998-07-04 22:30:26 +00:00
Julian Elischer
fd5d1124e2 VOP_STRATEGY grows an (struct vnode *) argument
as the value in b_vp is often not really what you want.
(and needs to be frobbed). more cleanups will follow this.
Reviewed by: Bruce Evans <bde@freebsd.org>
1998-07-04 20:45:42 +00:00
Dmitrij Tejblum
6bfc1a02b1 Remove "not hungly" panics. Cookies now used by the linux and ibcs2
emulators. The emulators assume that filesystem may just ignore cookies, and
handle this case correctly. So we just ignore cookies.

Also sync *_readdir "prototypes" with reality.
1998-06-25 16:54:41 +00:00
Bruce Evans
e5b19842ef Removed unused includes. 1998-06-21 14:53:44 +00:00
Bruce Evans
a395dbb153 Avoid a 64-bit division in procfs_readdir(). Fixed related overflows.
Check args using the same expression as in fdesc and kernfs.  The check
was actually already correct, modulo overflow.  It could be tightened
up to either allow huge (aligned) offsets, treating them as EOF, or
disallow all offsets beyond EOF.

Didn't fix invalid address calculation &foo[i] where i may be out of
bounds.

Didn't fix shooting of foot using a private unportable dirent struct.
1998-06-14 12:53:39 +00:00
Bruce Evans
ecf723aa39 Avoid a 64-bit division in kernfs_readdir(). Fixed related overflows
and arg checking.
1998-06-14 12:34:42 +00:00
Bruce Evans
a41878a77a Avoid a 64-bit division in fdesc_readdir(). Fixed related overflows
and missing arg checking.

Panic instead of returning bogus error codes or forgetting to check
all cases if fdesc_readdir() gets called for a non-directory.  This
can't happen.
1998-06-14 08:46:41 +00:00
Doug Rabson
9d8b200937 Make these files compile. 1998-06-10 21:21:31 +00:00
Alexander Langer
6ead682113 ENOPNOTSUPP --> EOPNOTSUPP
PR:		6906
Submitted by:	Steven G. Kargl <kargl@troutmask.apl.washington.edu>
1998-06-10 19:56:06 +00:00
Peter Wemm
7a204420d3 Don't silently accept attempts to change flags where they are not
supported.
1998-06-10 06:34:57 +00:00
Doug Rabson
ecbb00a262 This commit fixes various 64bit portability problems required for
FreeBSD/alpha.  The most significant item is to change the command
argument to ioctl functions from int to u_long.  This change brings us
inline with various other BSD versions.  Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.
1998-06-07 17:13:14 +00:00
John Dyson
cf2819ccb8 Make flushing dirty pages work correctly on filesystems that
unexpectedly do not complete writes even with sync I/O requests.
This should help the behavior of mmaped files when using
softupdates (and perhaps in other circumstances also.)
1998-05-21 07:47:58 +00:00
Tor Egge
afc6ea238f Disallow reading the current kernel stack. Only the user structure and
the current registers should be accessible.
Reviewed by:	David Greenman <dg@root.com>
1998-05-19 00:00:14 +00:00
Søren Schmidt
0e1e9fdca6 Cleanup after Garret, include unpch.h to get at various macros.. 1998-05-17 09:37:39 +00:00
Mike Smith
7be2d30077 In the words of the submitter:
---------
Make callers of namei() responsible for releasing references or locks
instead of having the underlying filesystems do it.  This eliminates
redundancy in all terminal filesystems and makes it possible for stacked
transport layers such as umapfs or nullfs to operate correctly.

Quality testing was done with testvn, and lat_fs from the lmbench suite.

Some NFS client testing courtesy of Patrik Kudo.

vop_mknod and vop_symlink still release the returned vpp.  vop_rename
still releases 4 vnode arguments before it returns.  These remaining cases
will be corrected in the next set of patches.
---------

Submitted by:	Michael Hancock <michaelh@cet.co.jp>
1998-05-07 04:58:58 +00:00
Mike Smith
79cc756d8b As described by the submitter:
Reverse the VFS_VRELE patch.  Reference counting of vnodes does not need
to be done per-fs.  I noticed this while fixing vfs layering violations.
Doing reference counting in generic code is also the preference cited by
John Heidemann in recent discussions with him.

The implementation of alternative vnode management per-fs is still a valid
requirement for some filesystems but will be revisited sometime later,
most likely using a different framework.

Submitted by:	Michael Hancock <michaelh@cet.co.jp>
1998-05-06 05:29:41 +00:00
John Dyson
c0877f103f Tighten up management of memory and swap space during map allocation,
deallocation cycles.  This should provide a measurable improvement
on swap and memory allocation on loaded systems.  It is unlikely a
complete solution.  Also, provide more map info with procfs.
Chuck Cranor spurred on this improvement.
1998-04-29 04:28:22 +00:00
Julian Elischer
c0bab11dfe Make the devfs SLICE option a standard type option.
(hopefully it will go away eventually anyhow)
1998-04-20 03:57:41 +00:00
Julian Elischer
3e425b968d Add changes and code to implement a functional DEVFS.
This code will be turned on with the TWO options
DEVFS and SLICE. (see LINT)
Two labels PRE_DEVFS_SLICE and POST_DEVFS_SLICE will deliniate these changes.

/dev will be automatically mounted by init (thanks phk)
on bootup. See /sys/dev/slice/slice.4 for more info.
All code should act the same without these options enabled.

Mike Smith, Poul Henning Kamp, Soeren, and a few dozen others

This code does not support the following:
bad144 handling.
Persistance. (My head is still hurting from the last time we discussed this)
ATAPI flopies are not handled by the SLICE code yet.

When this code is running, all major numbers are arbitrary and COULD
be dynamically assigned. (this is not done, for POLA only)
Minor numbers for disk slices ARE arbitray and dynamically assigned.
1998-04-19 23:32:49 +00:00
Dag-Erling Smørgrav
dc73342347 Seventy-odd "its" / "it's" typos in comments fixed as per kern/6108. 1998-04-17 22:37:19 +00:00
Bruce Evans
08637435f2 Moved some #includes from <sys/param.h> nearer to where they are actually
used.
1998-03-28 10:33:27 +00:00
Poul-Henning Kamp
a0502b19d4 Add two new functions, get{micro|nano}time.
They are atomic, but return in essence what is in the "time" variable.
gettime() is now a macro front for getmicrotime().

Various patches to use the two new functions instead of the various
hacks used in their absence.

Some puntuation and grammer patches from Bruce.

A couple of XXX comments.
1998-03-26 20:54:05 +00:00
KATO Takenori
b2bde4cb07 If lowervp is NULLVP, vap was clobbered.
Submitted by:	Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
Obtained from:	NetBSD/pc98
1998-03-17 08:47:50 +00:00
Julian Elischer
2b28ffe5aa Free the vnode in the failure case of vop_symlink()
Suggested by: Michaelh@cet.co.jp
1998-03-10 09:12:19 +00:00
Julian Elischer
b1897c197c Reviewed by: dyson@freebsd.org (john Dyson), dg@root.com (david greenman)
Submitted by:	Kirk McKusick (mcKusick@mckusick.com)
Obtained from:  WHistle development tree
1998-03-08 09:59:44 +00:00
John Dyson
2abc1ef602 Initialize b_resid, and also print out better diagnostics on I/O
errors.  This will allow for better tracking of user error reports.
1998-03-08 08:46:18 +00:00
John Dyson
8f9110f6a1 This mega-commit is meant to fix numerous interrelated problems. There
has been some bitrot and incorrect assumptions in the vfs_bio code.  These
problems have manifest themselves worse on NFS type filesystems, but can
still affect local filesystems under certain circumstances.  Most of
the problems have involved mmap consistancy, and as a side-effect broke
the vfs.ioopt code.  This code might have been committed seperately, but
almost everything is interrelated.

1)	Allow (pmap_object_init_pt) prefaulting of buffer-busy pages that
	are fully valid.
2)	Rather than deactivating erroneously read initial (header) pages in
	kern_exec, we now free them.
3)	Fix the rundown of non-VMIO buffers that are in an inconsistent
	(missing vp) state.
4)	Fix the disassociation of pages from buffers in brelse.  The previous
	code had rotted and was faulty in a couple of important circumstances.
5)	Remove a gratuitious buffer wakeup in vfs_vmio_release.
6)	Remove a crufty and currently unused cluster mechanism for VBLK
	files in vfs_bio_awrite.  When the code is functional, I'll add back
	a cleaner version.
7)	The page busy count wakeups assocated with the buffer cache usage were
	incorrectly cleaned up in a previous commit by me.  Revert to the
	original, correct version, but with a cleaner implementation.
8)	The cluster read code now tries to keep data associated with buffers
	more aggressively (without breaking the heuristics) when it is presumed
	that the read data (buffers) will be soon needed.
9)	Change to filesystem lockmgr locks so that they use LK_NOPAUSE.  The
	delay loop waiting is not useful for filesystem locks, due to the
	length of the time intervals.
10)	Correct and clean-up spec_getpages.
11)	Implement a fully functional nfs_getpages, nfs_putpages.
12)	Fix nfs_write so that modifications are coherent with the NFS data on
	the server disk (at least as well as NFS seems to allow.)
13)	Properly support MS_INVALIDATE on NFS.
14)	Properly pass down MS_INVALIDATE to lower levels of the VM code from
	vm_map_clean.
15)	Better support the notion of pages being busy but valid, so that
	fewer in-transit waits occur.  (use p->busy more for pageouts instead
	of PG_BUSY.)  Since the page is fully valid, it is still usable for
	reads.
16)	It is possible (in error) for cached pages to be busy.  Make the
	page allocation code handle that case correctly.  (It should probably
	be a printf or panic, but I want the system to handle coding errors
	robustly.  I'll probably add a printf.)
17)	Correct the design and usage of vm_page_sleep.  It didn't handle
	consistancy problems very well, so make the design a little less
	lofty.  After vm_page_sleep, if it ever blocked, it is still important
	to relookup the page (if the object generation count changed), and
	verify it's status (always.)
18)	In vm_pageout.c, vm_pageout_clean had rotted, so clean that up.
19)	Push the page busy for writes and VM_PROT_READ into vm_pageout_flush.
20)	Fix vm_pager_put_pages and it's descendents to support an int flag
	instead of a boolean, so that we can pass down the invalidate bit.
1998-03-07 21:37:31 +00:00
John Dyson
aeb52ab0eb Fix certain kinds of block device operations. For example, tunefs on
a block device shouldn't crash the system anymore.
1998-03-04 06:44:59 +00:00
Mike Smith
34bdbbd0de The intent is to get rid of WILLRELE in vnode_if.src by making
a complement to all ops that return a vpp, VFS_VRELE.  This is
initially only for file systems that implement the following ops
that do a WILLRELE:

	vop_create, vop_whiteout, vop_mknod, vop_remove, vop_link,
	vop_rename, vop_mkdir, vop_rmdir, vop_symlink

This is initial DNA that doesn't do anything yet.  VFS_VRELE is
implemented but not called.

A default vfs_vrele was created for fs implementations that use the
standard vnode management routines.

VFS_VRELE implementations were made for the following file systems:

Standard (vfs_vrele)
	ffs mfs nfs msdosfs devfs ext2fs

Custom
	union umapfs

Just EOPNOTSUPP
	fdesc procfs kernfs portal cd9660

These implementations may change as VOP changes are implemented.

In the next phase, in the vop implementations calls to vrele and the vrele
part of vput will be moved to the top layer vfs_vnops and made visible
to all layers.  vput will be replaced by unlock in these cases.  Unlocking
will still be done in the per fs layer but the refcount decrement will be
triggered at the top because it doesn't hurt to hold a vnode reference a
little longer.  This will have minimal impact on the structure of the
existing code.

This will only be done for vnode arguments that are released by the various
fs vop implementations.

Wider use of VFS_VRELE will likely require restructuring of the code.

Reviewed by:	phk, dyson, terry et. al.
Submitted by:	Michael Hancock <michaelh@cet.co.jp>
1998-03-01 22:46:53 +00:00
KATO Takenori
589421d418 Deleted KLOCK-hack. 1998-02-26 03:23:56 +00:00
KATO Takenori
3e7e515734 Deleted unused variable. 1998-02-10 08:04:31 +00:00
KATO Takenori
d6476ada99 Undo UN_KLOCK hack except union_allocvp(). Now, vput() doesn't lock
the vnode.
1998-02-10 03:32:07 +00:00
Eivind Eklund
303b270b0a Staticize. 1998-02-09 06:11:36 +00:00
KATO Takenori
ca6f868824 Fixed pagefault when cred == NOCRED.
PR:		5632
1998-02-07 01:36:24 +00:00
KATO Takenori
39ca14f032 Fixed number of entries in gid-mapfile.
PR:		5640
1998-02-07 01:34:32 +00:00
Eivind Eklund
0b08f5f737 Back out DIAGNOSTIC changes. 1998-02-06 12:14:30 +00:00
KATO Takenori
87884aad6e Workarround for DIAGNOSTIC kernel's panic in union_lookup().
Union_removed_upper() clobbers cache when file is removed.
Upper vp will be removed by union_reclaim().
1998-02-06 02:42:21 +00:00
John Dyson
95461b450d 1) Start using a cleaner and more consistant page allocator instead
of the various ad-hoc schemes.
2)	When bringing in UPAGES, the pmap code needs to do another vm_page_lookup.
3)	When appropriate, set the PG_A or PG_M bits a-priori to both avoid some
	processor errata, and to minimize redundant processor updating of page
	tables.
4)	Modify pmap_protect so that it can only remove permissions (as it
	originally supported.)  The additional capability is not needed.
5)	Streamline read-only to read-write page mappings.
6)	For pmap_copy_page, don't enable write mapping for source page.
7)	Correct and clean-up pmap_incore.
8)	Cluster initial kern_exec pagin.
9)	Removal of some minor lint from kern_malloc.
10)	Correct some ioopt code.
11)	Remove some dead code from the MI swapout routine.
12)	Correct vm_object_deallocate (to remove backing_object ref.)
13)	Fix dead object handling, that had problems under heavy memory load.
14)	Add minor vm_page_lookup improvements.
15)	Some pages are not in objects, and make sure that the vm_page.c can
	properly support such pages.
16)	Add some more page deficit handling.
17)	Some minor code readability improvements.
1998-02-05 03:32:49 +00:00
Eivind Eklund
47cfdb166d Turn DIAGNOSTIC into a new-style option. 1998-02-04 22:34:03 +00:00
KATO Takenori
4e649c4174 Declare the variable `i' when UMAP_DIAGNOSTIC is defined. 1998-02-03 14:30:01 +00:00
Eivind Eklund
3f2076daf5 Make the debug options new-style.
This also zaps a DPT option from lint; it wasn't referenced from
anywhere.
1998-01-31 07:23:16 +00:00
KATO Takenori
9758931d62 Fixed typo in comment. 1998-01-25 09:44:33 +00:00
John Dyson
2d8acc0f4a VM level code cleanups.
1)	Start using TSM.
	Struct procs continue to point to upages structure, after being freed.
	Struct vmspace continues to point to pte object and kva space for kstack.
	u_map is now superfluous.
2)	vm_map's don't need to be reference counted.  They always exist either
	in the kernel or in a vmspace.  The vmspaces are managed by reference
	counts.
3)	Remove the "wired" vm_map nonsense.
4)	No need to keep a cache of kernel stack kva's.
5)	Get rid of strange looking ++var, and change to var++.
6)	Change more data structures to use our "zone" allocator.  Added
	struct proc, struct vmspace and struct vnode.  This saves a significant
	amount of kva space and physical memory.  Additionally, this enables
	TSM for the zone managed memory.
7)	Keep ioopt disabled for now.
8)	Remove the now bogus "single use" map concept.
9)	Use generation counts or id's for data structures residing in TSM, where
	it allows us to avoid unneeded restart overhead during traversals, where
	blocking might occur.
10)	Account better for memory deficits, so the pageout daemon will be able
	to make enough memory available (experimental.)
11)	Fix some vnode locking problems. (From Tor, I think.)
12)	Add a check in ufs_lookup, to avoid lots of unneeded calls to bcmp.
	(experimental.)
13)	Significantly shrink, cleanup, and make slightly faster the vm_fault.c
	code.  Use generation counts, get rid of unneded collpase operations,
	and clean up the cluster code.
14)	Make vm_zone more suitable for TSM.

This commit is partially as a result of discussions and contributions from
other people, including DG, Tor Egge, PHK, and probably others that I
have forgotten to attribute (so let me know, if I forgot.)

This is not the infamous, final cleanup of the vnode stuff, but a necessary
step.  Vnode mgmt should be correct, but things might still change, and
there is still some missing stuff (like ioopt, and physical backing of
non-merged cache files, debugging of layering concepts.)
1998-01-22 17:30:44 +00:00
KATO Takenori
bda1412586 Delete unused code in union_fsync(). 1998-01-22 02:14:59 +00:00
KATO Takenori
3ae6029808 - Move SETKLOC and CLEARKLOCK macros into uion.h.
- Set UN_ULOCK in union_lock() when UN_KLOCK is set.  Caller expects
  that vnode is locked correctly, and may call another function which
  expects locked vnode and may unlock the vnode.
- Do not assume the behavior of inside functions in FreeBSD's
  vfs_suber.c is same as 4.4BSD-Lite2.  Vnode may be locked in
  vget() even though flag is zero.  (Locked vnode is, of course,
  unlocked before returning from vget.)
1998-01-20 10:02:54 +00:00
KATO Takenori
471f80601f Workarround for locking violation while recycling vnode which union fs
used in freelist.
1998-01-18 08:17:48 +00:00
KATO Takenori
afc2a5581f Improve and revise fixes for locking violation.
Obtained from:	NetBSD/pc98
1998-01-18 07:56:41 +00:00
John Dyson
95e5e988e0 Make our v_usecount vnode reference count work identically to the
original BSD code.  The association between the vnode and the vm_object
no longer includes reference counts.  The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.

When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also.  The two "objects" are now
more intimately related, and so the interactions are now much less
complex.

When vnodes are now normally placed onto the free queue with an object still
attached.  The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code.  There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.

A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.

Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
Sean Eric Fagan
dd30ff81d9 Use CHECKIO in procfs_ioctl() to ensure that any changes in UID/GID result
in the expected failure.
1998-01-06 01:37:12 +00:00
Julian Elischer
dd86d26a6d add copyrights 1998-01-02 07:31:07 +00:00
Bruce Evans
cf6347f79b Fixed missing initialization of mp->mnt_stat. At least vm depends on
at least mp->mnt_stat.f_iosize being nonzero.

PR:		5212
1998-01-01 08:28:26 +00:00
Bruce Evans
a954e88d0b Fixed a missing/misplaced/misstyled prototype. 1997-12-30 08:46:44 +00:00
John Dyson
2be70f79f6 Lots of improvements, including restructring the caching and management
of vnodes and objects.  There are some metadata performance improvements
that come along with this.  There are also a few prototypes added when
the need is noticed.  Changes include:

1) Cleaning up vref, vget.
2) Removal of the object cache.
3) Nuke vnode_pager_uncache and friends, because they aren't needed anymore.
4) Correct some missing LK_RETRY's in vn_lock.
5) Correct the page range in the code for msync.

Be gentle, and please give me feedback asap.
1997-12-29 00:25:11 +00:00
Bruce Evans
675ea6f083 Unspammed nested include of <vm/vm_zone.h>. 1997-12-27 02:56:39 +00:00
Sean Eric Fagan
d5f81602a7 Clear the p_stops field on change of user/group id, unless the correct
flag is set in the p_pfsflags field.  This, essentially, prevents an SUID
proram from hanging after being traced.  (E.g., "truss /usr/bin/rlogin" would
fail, but leave rlogin in a stopevent state.)  Yet another case where procctl
is (hopefully ;)) no longer needed in the general case.

Reviewed by:	bde (thanks bruce :))
1997-12-20 03:05:47 +00:00
Bruce Evans
b3a66dd356 Set the sender's low watermark to match the maximum size for atomic
writes that we advertise (PIPE_BUF = 512).
1997-12-19 18:58:14 +00:00
Garrett Wollman
1cbbd625cc Add support for poll(2) on files. vop_nopoll() now returns POLLNVAL
if one of the new poll types is requested; hopefully this will not break
any existing code.  (This is done so that programs have a dependable
way of determining whether a filesystem supports the extended poll types
or not.)

The new poll types added are:

	POLLWRITE - file contents may have been modified
	POLLNLINK - file was linked, unlinked, or renamed
	POLLATTRIB - file's attributes may have been changed
	POLLEXTEND - file was extended

Note that the internal operation of poll() means that it is impossible
for two processes to reliably poll for the same event (this could
be fixed but may not be worth it), so it is not possible to rewrite
`tail -f' to use poll at this time.
1997-12-15 03:09:59 +00:00
Bruce Evans
80987b7a3b Fixed EOF handing.
1. SS_CANTRCVMORE was initially set on the wrong socket, so reads
when there has never been a writer on the socket did not return 0.
Note that such reads are only possible if the fifo was opened in
(O_RDONLY | O_NONBLOCK) mode.

2. SS_CANTSENDMORE was initially set on the wrong socket, but this
was harmless because the wrong socket is never sent from and there
is no need to set the flag initially on the right socket (since open
in (O_WRONLY | O_NONBLOCK) mode fails if there is no reader...).

3. SS_CANTRCVMORE was cleared when read() returns.  This broke the
case where read() returns 0 - subsequent reads are supposed to
return 0 until a writer appears.  There is no need to clear the
flag when read() returns, since it is cleared correctly when a
writer appears.
1997-12-13 13:49:59 +00:00
Bruce Evans
5fb0d3e0b3 Restored fifo_pathconf() from rev.1.32. vop_stdpathconf() is too
general to be of much use.  Using it here weakened the _PC_MAX_CANON,
_PC_MAX_INPUT and _PC_VDISABLE cases.

fifo_pathconf() is not quite correct either.  _PC_CHOWN_RESTRICTED
and _PC_LINK_MAX should be handled by the host file system.  For
directories, the host file system should let us handle _PC_PIPE_BUF.
1997-12-13 12:58:09 +00:00
Sean Eric Fagan
d7b7dcba41 Change the ioctls for procfs around a bit; in particular, whever possible,
change from

	ioctl(fd, PIOC<foo>, &i);

to

	ioctl(fd, PIOC<foo>, i);

This is going from the _IOW to _IO ioctl macro.  The kernel, procctl, and
truss must be in synch for it all to work (not doing so will get errors about
inappropriate ioctl's, fortunately).  Hopefully I didn't forget anything :).
1997-12-13 03:13:49 +00:00
Sean Eric Fagan
ba9d19e99b Fix a problem with procfs_exit() that resulted in missing some procfs
nodes; this also apparantly caused a panic in some circumstances.
Also, since procfs_exit() is getting rid of the nodes when a process
exits, don't bother checking for the process' existance in procfs_inactive().
1997-12-12 03:33:43 +00:00
Sean Eric Fagan
7486d3658f Code to prevent a panic caused by procfs_exit(). Note that i don't know
what is teh root cause -- but, sometimes, a procfs vnode in pfshead is
apparantly corrupt (or a UFS vnode instead).  Without this patch, I can
get it to panic by doing (in csh)

	while (1)
		ps auxwww
	end

and it will panic when the PID's wrap.  With it, it does not panic.
Yes -- I know that this is NOT the right way to fix it.  But I haven't
been able to get it to panic yet (which confuses me).  I am going to
be looking into the vgone() code now, as that may be a part of it.
1997-12-09 05:03:41 +00:00
Sean Eric Fagan
bfcfe2e1b1 A couple of fixes from bruce: first of all, psignal is a void (stupid
me; unfortunately, also makes it hard ot check for errors); second, I had
managed to forget a change to PIOCSFL (it should be _IOW, not _IOR) I had
in my local copy, and Bruce called me on it.

Submitted by:	bde
1997-12-08 22:09:39 +00:00
Sean Eric Fagan
847e5f5f9a Use at_exit() to invoke procfs_exit() instead of calling it directly.
Note that an unload facility should be used to call rm_at_exit() (if
procfs is being loaded as an LKM and is subsequently removed), but it
was non-obvious how to do this in the VFS framework.

Reviewed by:	Julian Elischer
1997-12-08 01:06:36 +00:00
Sean Eric Fagan
d99616387e Clear the stop events and wakeup the process on teh last close of the
procfs/mem file.  While this doesn't prevent an unkillable process, it
means that a broken truss prorgam won't do it accidently now (well,
there's a small window of opportunity).  Note that this requires the
change to truss I am about to commit.
1997-12-07 04:01:03 +00:00
Sean Eric Fagan
2a024a2b05 Changes to allow event-based process monitoring and control. 1997-12-06 04:11:14 +00:00
Bruce Evans
1cd52ec333 Don't include <sys/lock.h> in headers when only `struct simplelock' is
required.  Fixed everything that depended on the pollution.
1997-12-05 19:55:52 +00:00
Poul-Henning Kamp
80b301c385 Staticize. 1997-11-18 15:07:35 +00:00
Tor Egge
b872e9c03f Don't try to obtain an excluive lock on the vm map, since a deadlock might
occur if the process owning the map is wiring pages.
1997-11-14 22:57:46 +00:00
Julian Elischer
171d1bf26d fix slight breakages from PHK's VFS work.
also remove irrelevant copyright, now that all that code has gone away.
1997-11-08 19:02:28 +00:00
Poul-Henning Kamp
4a11ca4e29 Remove a bunch of variables which were unused both in GENERIC and LINT.
Found by:	-Wunused
1997-11-07 08:53:44 +00:00
Poul-Henning Kamp
cb226aaa62 Move the "retval" (3rd) parameter from all syscall functions and put
it in struct proc instead.

This fixes a boatload of compiler warning, and removes a lot of cruft
from the sources.

I have not removed the /*ARGSUSED*/, they will require some looking at.

libkvm, ps and other userland struct proc frobbing programs will need
recompiled.
1997-11-06 19:29:57 +00:00
Bruce Evans
521166c5b2 KNFize rev.1.31. 1997-10-27 15:39:01 +00:00
Bruce Evans
72cd7335b0 Use unique sleep message strings. 1997-10-27 15:33:04 +00:00
Bruce Evans
ef91bd5734 Removed unused #includes. The need for most of them went away with
recent changes (docluster* and vfs improvements).
1997-10-27 13:33:47 +00:00
Poul-Henning Kamp
dba3870c10 VFS interior redecoration.
Rename vn_default_error to vop_defaultop all over the place.
Move vn_bwrite from vfs_bio.c to vfs_default.c and call it vop_stdbwrite.
Use vop_null instead of nullop.
Move vop_nopoll from vfs_subr.c to vfs_default.c
Move vop_sharedlock from vfs_subr.c to vfs_default.c
Move vop_nolock from vfs_subr.c to vfs_default.c
Move vop_nounlock from vfs_subr.c to vfs_default.c
Move vop_noislocked from vfs_subr.c to vfs_default.c
Use vop_ebadf instead of *_ebadf.
Add vop_defaultop for getpages on master vnode in MFS.
1997-10-26 20:55:39 +00:00
Ollivier Robert
baa42bb2cc Fix the same leak as in nullfs. Now the lowervp is properly marked inactive.
Reviewed by:	phk
1997-10-21 21:08:17 +00:00
Ollivier Robert
1fb2a62daa Fix the file leak bug. The lower layer wasn't informed the vnode was inactive
and kept a reference, preventing the blocks to be reclaimed.

Changed the comment in null_inactive to reflect the current situation.

Reviewed by:	phk
1997-10-21 21:01:34 +00:00
Poul-Henning Kamp
e9565321ea VFS clean up "hekto commit"
1.  Add defaults for more VOPs
        VOP_LOCK        vop_nolock
        VOP_ISLOCKED    vop_noislocked
        VOP_UNLOCK      vop_nounlock
    and remove direct reference in filesystems.

2.  Rename the nfsv2 vnop tables to improve sorting order.
1997-10-16 22:01:05 +00:00
Poul-Henning Kamp
987f569678 Another VFS cleanup "kilo commit"
1.  Remove VOP_UPDATE, it is (also) an UFS/{FFS,LFS,EXT2FS,MFS}
    intereface function, and now lives in the ufsmount structure.

2.  Remove VOP_SEEK, it was unused.

3.  Add mode default vops:

    VOP_ADVLOCK          vop_einval
    VOP_CLOSE            vop_null
    VOP_FSYNC            vop_null
    VOP_IOCTL            vop_enotty
    VOP_MMAP             vop_einval
    VOP_OPEN             vop_null
    VOP_PATHCONF         vop_einval
    VOP_READLINK         vop_einval
    VOP_REALLOCBLKS      vop_eopnotsupp

    And remove identical functionality from filesystems

4.   Add vop_stdpathconf, which returns the canonical stuff.  Use
     it in the filesystems.  (XXX: It's probably wrong that specfs
     and fifofs sets this vop, shouldn't it come from the "host"
     filesystem, for instance ufs or cd9660 ?)

5.   Try to make system wide VOP functions have vop_* names.

6.   Initialize the um_* vectors in LFS.

(Recompile your LKMS!!!)
1997-10-16 20:32:40 +00:00
Poul-Henning Kamp
cec0f20ce7 VFS mega cleanup commit (x/N)
1.  Add new file "sys/kern/vfs_default.c" where default actions for
    VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
    POLL, REVOKE and STRATEGY.  Various stuff spread over the entire
    tree belongs here.

2.  Change VOP_BLKATOFF to a normal function in cd9660.

3.  Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC.  These
    are private interface functions between UFS and the underlying
    storage manager layer (FFS/LFS/MFS/EXT2FS).  The functions now
    live in struct ufsmount instead.

4.  Remove a kludge of VOP_ functions in all filesystems, that did
    nothing but obscure the simplicity and break the expandability.
    If a filesystem doesn't implement VOP_FOO, it shouldn't have an
    entry for it in its vnops table.  The system will try to DTRT
    if it is not implemented.  There are still some cruft left, but
    the bulk of it is done.

5.  Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
Julian Elischer
67d65825cf remove forgotten debug printf() 1997-10-16 08:18:38 +00:00
Julian Elischer
2daae425f5 1/ by default make all versions of the same device get the same vnode.
2/ Show the dummy mount in the mount list. it cannot be reached (that I know of)
	but puting it there, means that disks mounted from devfs will have their	things such as the superblock and the bitmaps, synced to disk :)
1997-10-16 07:28:50 +00:00
Julian Elischer
2a5e970deb some cleanups of init code, and changes needed to support disk layering. 1997-10-16 06:29:27 +00:00
Poul-Henning Kamp
138ec1f71a vnops megacommit
1.  Use the default function to access all the specfs operations.
2.  Use the default function to access all the fifofs operations.
3.  Use the default function to access all the ufs operations.
4.  Fix VCALL usage in vfs_cache.c
5.  Use VOCALL to access specfs functions in devfs_vnops.c
6.  Staticize most of the spec and fifofs vnops functions.
7.  Make UFS panic if it lacks bits of the underlying storage handling.
1997-10-15 13:24:07 +00:00
Poul-Henning Kamp
6a525123aa Hmm, realign the vnops into two columns. 1997-10-15 10:05:29 +00:00
Poul-Henning Kamp
539ef70c2d Stylistic overhaul of vnops tables.
1. Remove comment stating the blatantly obvious.
        2. Align in two columns.
        3. Sort all but the default element alphabetically.
        4. Remove XXX comments pointing out entries not needed.
1997-10-15 09:22:02 +00:00
Julian Elischer
d9c15b1f71 if we free all the links to a node, then by definition
we freed the name we used to find it..
SO DON'T free it again later!

pointy hat over here please..
1997-10-12 22:27:11 +00:00
Poul-Henning Kamp
a1c995b626 Last major round (Unless Bruce thinks of somthing :-) of malloc changes.
Distribute all but the most fundamental malloc types.  This time I also
remembered the trick to making things static:  Put "static" in front of
them.

A couple of finer points by:	bde
1997-10-12 20:26:33 +00:00
Poul-Henning Kamp
55166637cd Distribute and statizice a lot of the malloc M_* types.
Substantial input from:	bde
1997-10-11 18:31:40 +00:00
Julian Elischer
d5ad8952dc Allow a deleted deveice to delte it's nodes in other mounted devfs
filesystems even if not in SPLIT_DEVS mode.
1997-10-10 07:54:05 +00:00
KATO Takenori
81bca6ddae Clustered read and write are switched at mount-option level.
1. Clustered I/O is switched by the MNT_NOCLUSTERR and MNT_NOCLUSTERW
   bits of the mnt_flag.  The sysctl variables, vfs.foo.doclusterread
   and vfs.foo.doclusterwrite are deleted.  Only mount option can
   control clustered I/O from userland.
2. When foofs_mount mounts block device, foofs_mount checks D_CLUSTERR
   and D_CLUSTERW bits of the d_flags member in the block device switch
   table.  If D_NOCLUSTERR / D_NOCLUSTERW are set, MNT_NOCLUSTERR /
   MNT_NOCLUSTERW bits will be set.  In this case, MNT_NOCLUSTERR and
   MNT_NOCLUSTERW cannot be cleared from userland.
3. Vnode driver disables both clustered read and write.
4. Union filesystem disables clutered write.

Reviewed by:	bde
1997-09-27 13:40:20 +00:00
John Dyson
99448ed11d Change the M_NAMEI allocations to use the zone allocator. This change
plus the previous changes to use the zone allocator decrease the useage
of malloc by half.  The Zone allocator will be upgradeable to be able
to use per CPU-pools, and has more intelligent usage of SPLs.  Additionally,
it has reasonable stats gathering capabilities, while making most calls
inline.
1997-09-21 04:24:27 +00:00
Poul-Henning Kamp
18ecdb585c Executing binaries on a nullfs (or nullfs-based) filesystem results in
a trap.
PR:		3104
Reviewed by:	phk
Submitted by:	Dan Walters hannibal@cyberstation.net
1997-09-18 18:33:23 +00:00
Julian Elischer
72963672f5 devfs changes to allow old (better) and newer (braindamaged) behaviour.
I'm going to try migrate back, while keeping the newer code.
1997-09-16 09:10:18 +00:00
Peter Wemm
a6aeade2c4 Convert select -> poll.
Delete 'always succeed' select/poll handlers, replaced with generic call.
Flag missing vnode op table entries.
1997-09-14 02:58:12 +00:00
Bruce Evans
41fadeeb28 Removed yet more vestiges of config-time swap configuration and/or
cleaned up nearby cruft.
1997-09-07 16:21:11 +00:00
Bruce Evans
a910e75cdc Removed vestiges of config-time "argument processing" configuration. 1997-09-07 13:49:56 +00:00
Bruce Evans
c109c5775a Staticized. 1997-09-07 06:46:34 +00:00
Bruce Evans
bea0f0be7b Some staticized variables were still declared to be extern. 1997-09-07 05:27:26 +00:00
KATO Takenori
6ca02614a5 Support read-only mount. 1997-09-04 03:14:49 +00:00
Bruce Evans
e4ba6a82b0 Removed unused #includes. 1997-09-02 20:06:59 +00:00
KATO Takenori
1bf978ce42 Include "opt_ddb.h" only when NULLFS_DIAGNOSTIC is defined. 1997-08-28 00:44:43 +00:00
KATO Takenori
e958d078c4 Fixed NULLFS_DIAGNOSTIC stuff. 1997-08-27 08:44:43 +00:00
Julian Elischer
139c7c8e2d remove un-needed if statement (now the poul removed the 'then' clause) 1997-08-27 02:58:40 +00:00
Julian Elischer
bdb9147f65 two fixes submitted by Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
fixes problems in unmounting and propogation.
1997-08-26 17:17:52 +00:00
Poul-Henning Kamp
013739386f Copy&Paste considered harmful:
Remove all traces of the name_cache from devfs.  It is hardly sensible to
use the namecache for an all-RAM filesystem.
1997-08-25 20:31:00 +00:00
Garrett Wollman
57bf258e3d Fix all areas of the system (or at least all those in LINT) to avoid storing
socket addresses in mbufs.  (Socket buffers are the one exception.)  A number
of kernel APIs needed to get fixed in order to make this happen.  Also,
fix three protocol families which kept PCBs in mbufs to not malloc them
instead.  Delete some old compatibility cruft while we're at it, and add
some new routines in the in_cksum family.
1997-08-16 19:16:27 +00:00
KATO Takenori
f5a5311ee8 Added DIAGNOSTIC routine to test inconsistency of vnode when cnp
points `.'.

Obtained from:	NetBSD
1997-08-15 02:36:28 +00:00
KATO Takenori
a03a24c901 Deleted unused code which adjust UN_UNLOCK flag. 1997-08-15 02:35:00 +00:00
KATO Takenori
5842d4e5b2 If the user doesn't have read permission, union_copyup should not copy
a file to upper layer.

Reviewed by:	Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
1997-08-14 03:57:46 +00:00
KATO Takenori
3dc942bbe9 Backed out part of previous change. The example of -b mount in
manpage works again.
1997-08-14 03:52:27 +00:00
KATO Takenori
f8fc96b551 Fixed vnode corruption by undefined case in union_lookup(). When
uerror == 0 && lerror == EACCES, lowervp == NULLVP and union_allocvp
doesn't find existing union node and new union node is created.

Sicne it is dificult to cover all the case, union_lookup always
returns when union_lookup1() returns EACCES.

Submitted by:	Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
Obtained from:	NetBSD/pc98
1997-08-12 07:18:59 +00:00
Sean Eric Fagan
66ad7973ce Check permissions for fp regs as well as normal regs. 1997-08-12 05:23:51 +00:00
Sean Eric Fagan
49356a1f4a Fix procfs security hole -- check permissions on meaningful I/Os (namely,
reading/writing of mem and regs).  Also have to check for the requesting
process being group KMEM -- this is a bit of a hack, but ps et al need it.

Reviewed by:	davidg
1997-08-12 04:34:30 +00:00
Bruce Evans
1fd0b0588f Removed unused #includes. 1997-08-02 14:33:27 +00:00
Julian Elischer
0ec278018b two tiny typo's 1997-07-14 04:53:52 +00:00
Julian Elischer
5897e2693a remove annoying debug message 1997-07-14 04:30:22 +00:00
Alexander Langer
ee97e537f7 More comment cleanup. 1997-06-26 17:12:59 +00:00
Alexander Langer
09c8ff4a78 Typo police. 1997-06-26 16:13:56 +00:00
Alexander Langer
2c39c8177b Style fix my previous commit. 1997-06-26 16:12:53 +00:00
Alexander Langer
8a77722ad7 Block all write operations to /proc/1/* when securelevel > 0.
The additional check in procfs_ctl.c could be backed out, but
I'm leaving it in for good measure.

Reviewed by:	Theo de Raadt <deraadt@OpenBSD.org>
1997-06-21 16:09:49 +00:00
Tor Egge
14a4b83067 Don't remove the controlling tty from the session if the vnode is being
cleaned. This should help for PR kern/3581.
1997-05-29 13:29:13 +00:00
Peter Wemm
e9f7506f89 Fix some warnings (missing prototypes, wrong "generic" args etc)
umapfs uses one of nullfs's functions...
1997-05-25 04:50:02 +00:00
KATO Takenori
c9bf011176 1. Added cast and parenthesis in block size calculaion in
union_statfs().
2. staticized union vops.

Submitted by:	Doug Rabson <dfr@nlsystems.com>
1997-05-07 14:37:32 +00:00
Joerg Wunsch
ce34628b4b Fix the umount problems for DEVFS.
PR:		3276 & 3469 (the fixes), 2738, 2033 (reports)
Submitted by:	Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
1997-05-03 21:19:54 +00:00
KATO Takenori
32cfb899a6 Fixed panic message in union_lock(): union_link --> union_lock. 1997-05-03 01:55:19 +00:00
KATO Takenori
5f3f68a8ba Access correct union mount point in union_access. Old vnode is saved
in savedvp variable and it is used for the argument of
MOUNTTOUNIONMOUNT().  I didn't realize ap->a_vp is modified before
MOUNTTOUNIONMOUNT(), so the change by revision 1.22 is incorrect.
1997-05-02 03:21:54 +00:00
Søren Schmidt
e34cbf1f59 Remove the dependancy on DEV_BSIZE, now specfs works on != 512byte
sector devices given that the fs uses a blocksize of at least a physical
sector size.
1997-05-01 19:12:22 +00:00
KATO Takenori
a9320ff3bd Revised fix for locking violation when unionfs calls vput with
UN_KLOCK flag.

When UN_KLOCK is set, VOP_UNLOCK should keep uppervp locked and clear
UN_ULOCK flag.  To do this, when UN_KLOCK is set, (1) union_unlock
clears UN_ULOCK and does not clear UN_KLOCK, (2) union_lock() does not
access uppervp and does not clear UN_KLOCK, and (3) callers of
vput/VOP_UNLOCK should clear UN_KLOCK.  For example, vput becomes:

	SETKLOCK(union_node);
	vput(vnode);
	CLEARKLOCK(union_node);

where SETKLOCK macro sets UN_KLOCK and CLEARKLOCK macro clears
UN_KLOCK.
1997-04-29 02:06:07 +00:00
Alexander Langer
898fcb3b84 Removed bogon from previous commit: doubly included sys/systm.h. 1997-04-27 21:32:21 +00:00
Alexander Langer
ee7877dfec Prevent debugger attachment to init when securelevel > 0.
Noticed by:	Brian Buchanan <brian@wasteland.calbbs.com>
1997-04-27 19:02:37 +00:00
KATO Takenori
c4ace78562 Undo 1.29. 1997-04-27 10:49:37 +00:00
KATO Takenori
a18ac0ffaf Do nothing instead of adjusting un_flags when (uppervp is locked) &&
(UN_ULOCK is not set) in union_lock.  This condition may indicate
race.  DIAGNOSTIC kernel still panic here.
1997-04-26 13:43:25 +00:00
KATO Takenori
928e13b6a1 Do not clear UN_ULOCK in certain case.
Our vput calls vm_object_deallocate() --> vm_object_terminate().  The
vm_object_terminate() calls vn_lock(), since UN_LOCKED has been
already cleared in union_unlock().  Then, union_lock locks upper vnode
when UN_ULOCK is not set.  The upper vnode is not unlocked when
UN_KLOCK is set in union_unlock(), thus, union_lock tries to lock
locked vnode and we get panic.
1997-04-26 04:09:40 +00:00
KATO Takenori
18b4c8e206 Dirty change in union_lock(). Sometimes upper vnode is locked without
UN_ULOCK flag.  This shows a locking violation but I couldn't find the
reason UN_ULOCK is not set or upper vnode is not unlocked.  I added
the code that detect this case and adjust un_flags.  DIAGNOSTIC kernel
doesn't adjust un_flags, but just panic here to help debug by kernel
hackers.
1997-04-21 15:32:24 +00:00
KATO Takenori
077f31be53 Replace VOP_LOCK with vn_lock. 1997-04-21 12:40:42 +00:00
John Dyson
7cac787bee Fix both a problem with accessing backing objects, and also release
the process map on nonexistant pages.
PR:		kern/3327
Submitted by:	Tor Egge <Tor.Egge@idi.ntnu.no>
1997-04-20 17:12:11 +00:00
KATO Takenori
747e915757 Avoid `lock against myself' panic by following operation:
# mount -t union (or null) dir1 dir2
	# mount -t union (or null) dir2 dir1

The function namei in union_mount calls union_root.  The upper vnode
has been already locked and vn_lock in union_root causes above panic.

Add printf's included in `#ifdef DIAGNOSTIC' for EDEADLK cases.
1997-04-19 06:04:13 +00:00
KATO Takenori
f85e8fc5ca Fix `locking against myself' panic by multi nullfs mount of same
directory pair.
1997-04-17 11:24:57 +00:00
KATO Takenori
c5e17d9e2b Use NULLVP instead of NULL. 1997-04-17 11:17:30 +00:00
KATO Takenori
b69aa7f11a Do not set the uppervp to NULLVP in union_removed_upper. If lowervp
is NULLVP, union node will have neither uppervp nor lowervp.  This
causes page fault trap.

The union_removed_upper just remove union node from cache and it
doesn't set uppervp to NULLVP.  Since union node is removed from
cache, it will not be referenced.

The code that remove union node from cache was copied from
union_inactive.
1997-04-16 16:24:24 +00:00
KATO Takenori
93d71a483c Undo previous commit to avoid panic, and fix order of argument of
VOP_LINK().  The reason of strange behavior was wrong order of the
argument, that is, the operation

	# ln foo bar

in a union fs tried to do

	# ln bar foo

in ufs layer.

Now we can make a link in a union fs.
1997-04-16 03:08:34 +00:00
KATO Takenori
9095719e2b Quick-hack to avoid `lock against myself' panic. It is not the real
fix!

The ufs_link() assumes that vnode is not unlocked and tries to lock it
in certain case.  Because union_link calls VOP_LINK after locking vnode,
vn_lock in ufs_link causes above panic.

Currently, I don't know the real fix for a locking violation in
union_link, but I think it is important to avoid panic.

A vnode is unlocked before calling VOP_LINK and is locked after it if
the vnode is not union fs.  Even though panic went away, the process
that access the union fs in which link was made will hang-up.

Hang-up can be easily reproduced by following operation:

	mount -t union a b
	cd b
	ln foo bar
	ls
1997-04-15 12:56:57 +00:00
KATO Takenori
6db918e371 Fix `lockmgr: locking against myself' panic by multi union mount of
same directory pair.

If we do:
    mount -t union a b
    mount -t union a b
then, (1) namei tries to lock fs which has been already locked by
first union mount and (2) union_root() tries to lock locked fs.  To
avoid first deadlock condition, unlock vnode if lowerrootvp is union
node, and to avoid second case, union_mount returns EDEADLK when multi
union mount is detected.
1997-04-14 10:52:25 +00:00
KATO Takenori
ee582cdff0 Fix locking violation when accessing `..'.
Obtained from:	NetBSD
1997-04-14 05:13:55 +00:00
KATO Takenori
3a946335ae Access correct union mount point in union_access. 1997-04-13 13:12:12 +00:00
Poul-Henning Kamp
363ad70091 The function union_fsync tries to lock overlaying vnode object when
dolock is not set (that is, targetvp == overlaying vnode object).
Current code use FIXUP macro to do this, and never unlocks overlaying
vnode object in union_fsync.  So, the vnode object will be locked
twice and never unlocked.

PR:		3271
Submitted by:	kato
1997-04-13 06:29:13 +00:00
Poul-Henning Kamp
b422956c56 The path name buffer, cn->cn_pnbuf, is FREEed by VOP_MKDIR when
relookup() in union_relookup() is succeeded.  However, if relookup()
returns non-zero value, that is relookup fails, VOP_MKDIR is never
called (c.f. union_mkshadow).  Thus, pathname buffer is never FREEed.

Reviewed by:	phk
Submitted by:	kato
PR:		3262
1997-04-13 06:27:09 +00:00
Poul-Henning Kamp
9fa6ee7671 Though malloc allocates only cn.cn_namelen bytes for cn.cn_pnbuf in
union_vn_create(), following bcopy copies cn.cn_namlen + 1 bytes to
cn.cn_pnbuf

PR:		3255
Reviewed by:	phk
Submitted by:	kato
1997-04-13 06:25:03 +00:00
KATO Takenori
ae9d2b47e0 Removed libc stuffs. Lite/2 merged libc contains unionfs support, and
we don't have to use the libc related files in sys/misc/unionfs
directory.
1997-04-13 06:12:13 +00:00
Bruce Evans
c90607ba7f Get the declaration of `struct dirent' from <sys/dirent.h>, not from
<sys/dir.h>, and use the new macro GENERIC_DIRSIZ() instead of DIRSIZ().

Removed unused #includes.
1997-04-10 15:05:38 +00:00
Bruce Evans
1a2efb7550 Removed unused or apparently-unused #includes, especially of the
deprecated header <sys/dir.h>.
1997-04-10 14:35:32 +00:00
John Dyson
a04c970a7a Fix the gdb executable modify problem. Thanks to the detective work
by Alan Cox <alc@cs.rice.edu>, and his description of the problem.

The bug was primarily in procfs_mem, but the mistake likely happened
due to the lack of vm system support for the operation.  I added
better support for selective marking of page dirty flags so that
vm_map_pageable(wiring) will not cause this problem again.

The code in procfs_mem is now less bogus (but maybe still a little
so.)
1997-04-06 02:29:45 +00:00
Bruce Evans
71455815cc Don't include <sys/ioctl.h> in the kernel. Stage 3: include
<sys/filio.h> instead of <sys/ioctl.h> in non-network non-tty files.
1997-03-24 11:37:53 +00:00
Bruce Evans
fce002fdef Don't include <sys/ioctl.h> in the kernel. Stage 1: don't include
it when it is not used.  In most cases, the reasons for including it
went away when the special ioctl headers became self-sufficient.
1997-03-24 11:25:10 +00:00
Bruce Evans
3ac4d1ef0c Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.
Fixed everything that depended on getting fcntl.h stuff from the wrong
place.  Most things don't depend on file.h stuff at all.
1997-03-23 03:37:54 +00:00
Bruce Evans
90106ad38b Fixed missing initialisation of vp->v_type for types Pfile and Pmem
in procfs_allocvp().  This fixes at least stat() of /proc/*/mem.

stat() of /proc/*/file already worked.  I think procfs_allocvp() isn't
actually called for type Pfile.
1997-03-08 16:06:34 +00:00
Bruce Evans
9135a51377 Use Lite2's stub locking vops instead of nullop. 1997-02-24 17:08:49 +00:00
Bruce Evans
a3d13e5054 Fixed procfs's locking vops. They were missed in the Lite2 merge,
partly because the #define's for them were moved to a different
file.  At least the null VOP_LOCK() no longer works, since vclean()
expects VOP_LOCK( ..., LK_DRAIN | LK_INTERLOCK, ...) to clear the
interlock.  This probably only matters when simple_lock() is not
null, i.e., when there are multiple CPUs or SIMPLELOCK_DEBUG is
defined.
1997-02-24 16:44:11 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
Mike Pritchard
f3a778f288 Eliminate the last of the compile warnings in this module by
correctly casting the arguments to all of the null_bypass() calls.
1997-02-12 18:06:08 +00:00
Mike Pritchard
fdc0430e50 Restore of #include <sys/kernel.h> so that this compiles without
warnings again.
1997-02-12 17:47:28 +00:00
Mike Pritchard
10546e217e Rstored #include of <sys/kernel.h> so that this compiles
without warnings again.

Submitted by:	bde
1997-02-12 16:26:37 +00:00
Mike Pritchard
fd7a659f2f Make this compile again after the Lite2 merge.
Call vget/VOP_UNLOCK with the correct number of
arguments.  Call vn_lock where appropriate.
vfs_goneall is now replaced by VOP_REVOKE.

Submitted by:	bde
1997-02-12 16:19:11 +00:00
Mike Pritchard
63f50488b0 Make this compile again after the Lite2 merge.
Also add missing function prototypes.
1997-02-12 14:55:01 +00:00
Mike Pritchard
aae8d53e0e Add missing function prototypes. 1997-02-12 14:54:14 +00:00
Bruce Evans
938958b97f Added parameter names to prototypes that were added in the last commit to
match nearby style.
1997-02-12 14:45:23 +00:00
Bruce Evans
9e67ea79f0 Restored #include of <sys/kernel.h> so that this compiles again. 1997-02-12 14:31:11 +00:00
Mike Pritchard
72a5ee14de Add function protypes for the new Lite2 unionfs functions. 1997-02-12 07:54:22 +00:00
Mike Pritchard
724ab19569 Add function prototypes for most of the new Lite2 functions.
Also made a few of the miscfs routines static to be
consistent.  Some modules simply required some additional
#includes to remove -Wall warnings.
1997-02-12 06:52:51 +00:00
John Dyson
996c772f58 This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.

The system boots and can mount UFS filesystems.

Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
		Mount_std mounts will not work until the getfsent
		library routine is changed.

Reviewed by:	various people
Submitted by:	Jeffery Hsu <hsu@freebsd.org>
1997-02-10 02:22:35 +00:00
John Dyson
afa07f7e83 Change the map entry flags from bitfields to bitmasks. Allows
for some code simplification.
1997-01-16 04:16:22 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bruce Evans
bb65f5a1cc Fixed lseek() on named pipes. It always succeeded but should always fail.
Broke locking on named pipes in the same way as locking on non-vnodes
(wrong errno).  This will be fixed later.

The fix involves negative logic.  Named pipes are now distinguished from
other types of files with vnodes, and there is additional code to handle
vnodes and named pipes in the same way only where that makes sense (not
for lseek, locking or TIOCSCTTY).
1996-12-19 19:42:37 +00:00
Bruce Evans
2cec12807d Fixed errno for unsupported advisory locks. The errno is now EINVAL
fcntl() and EOPNOTSUPP for flock().  POSIX specifies the weaker EINVAL
errno and the man page agrees.

Not fixed:
deadfs: always returns wrong EBADF
devfs, msdosfs: always return sometimes-wrong EINVAL
cd9660, fdesc, kernfs, portal: always return sometimes-wrong EOPNOTSUPP
procfs: always returns wrong EIO
mfs: panic?!
nfs: fudged

NetBSD uses a generic file system genfs to do return the sometimes-wrong
EOPNOTSUPP more consistently :-)(.

Found by:	NIST-PCTS
1996-12-19 18:16:33 +00:00
Julian Elischer
acdbeb6b1c changes to make devfs more 'normal'
also fixes a bug I've been chasing for a LONG TIME,
due to the fact that spec_bwrite is a NOP and I didn't realise it..

old symptom:
mount -t devfs devfs /mnt
mount /mnt/wd0e /mnt/mnt2
umount /mnt2 <process hangs>

there are some pretty large structural differences internal to devfs
but outwards it should look the same.
I have not yet tested extensively but will do so and fix 3 warnings tomorrow.
1996-11-21 07:19:00 +00:00
John Dyson
d700038439 Fix a potential deadlock from the previous commit. 1996-10-30 03:52:57 +00:00
John Dyson
56673451a7 Fix the /proc/???/map file so that it is possible to read an arbitrarily
large process map.  Another commit will follow to fix a problem just found
during this one... Sorry!!! :-(.
1996-10-30 03:45:00 +00:00
Poul-Henning Kamp
7f6a56eff7 devfs_tree.c: improve our bdevvp() function.
devfs_vnops.c:	move a debug printf to be consistent.
1996-10-28 11:36:06 +00:00
John Dyson
c864a7c0a9 Fix setting breakpoints in shared regions. 1996-10-24 02:47:05 +00:00
Julian Elischer
24b3bdfe8d Just because something doesn't make sense doesn't mean it should be illegal..
just ignore it instead.
===================================================================
RCS file: /home/ncvs/src/sys/miscfs/devfs/devfs_vnops.c,v
retrieving revision 1.30
diff -r1.30 devfs_vnops.c
631d630
<           (vap->va_size != VNOVAL) || /* doesn't make sense in devfs */
1996-10-17 22:47:23 +00:00
Julian Elischer
138e4d769c actually impliment permissions for teh chown/chmod/etc functions
that resemble what the man pages say.
also fix braino (type last week)
1996-10-16 23:14:00 +00:00
Julian Elischer
336cf5014e Allow the utimes call to work on devfs nodes. 1996-10-16 18:02:53 +00:00
Julian Elischer
1737b9d383 reads and writes to devices update m and a times
add some security onn the chmod/chown operations
should now be root or owner
(still needs more thought but kinda-plugs tow holes pointed out by bde)
1996-10-12 00:07:53 +00:00
John Dyson
66166d45de Substitution of a long divide by a shift. Other cosmetic improvements.
Submitted by:	bde
1996-10-06 21:19:33 +00:00
Bruce Evans
dc927d0c6b Started unspamming <sys/systm.h>. Don't include <machine/stdarg.h>
to get the declaration of va_list; just use _BSD_VA_LIST.  Fixed
the 2 places that need <machine.stdarg.h> but didn't include it
explicitly.
1996-09-29 15:00:37 +00:00
Nate Williams
d977b72dbd Whoops, I should've used the LINT config file. More ts -> tv changes
for timespec structure.
1996-09-20 05:56:36 +00:00
Julian Elischer
99892d2317 fix the ability of the VFS to reclaim devfs nodes correctly..
(was resulting in panics, especially when DIAGNOSTIC was set.)
1996-09-11 07:52:18 +00:00
Bruce Evans
f313170d3c Updated #includes to 4.4Lite style. 1996-09-10 08:32:01 +00:00
Bruce Evans
b71fec07db Eliminated nested include of <sys/unistd.h> in <sys/file.h> in the kernel.
Include it directly in the few places where it is used.

Reduced some #includes of <sys/file.h> to #includes of <sys/fcntl.h> or
nothing.
1996-09-03 14:25:27 +00:00
Bruce Evans
e0c95ed947 Fixed the easy cases of const poisoning in the kernel. Cosmetic. 1996-08-31 16:52:44 +00:00
John Dyson
6476c0d204 Even though this looks like it, this is not a complex code change.
The interface into the "VMIO" system has changed to be more consistant
and robust.  Essentially, it is now no longer necessary to call vn_open
to get merged VM/Buffer cache operation, and exceptional conditions
such as merged operation of VBLK devices is simpler and more correct.

This code corrects a potentially large set of problems including the
problems with ktrace output and loaded systems, file create/deletes,
etc.

Most of the changes to NFS are cosmetic and name changes, eliminating
a layer of subroutine calls.  The direct calls to vput/vrele have
been re-instituted for better cross platform compatibility.

Reviewed by: davidg
1996-08-21 21:56:23 +00:00
Julian Elischer
def534af64 Submitted by: doug Rabson (dfr@render.com)
cleaning up some of the vnode usage..

(I'm sure it still needs more..)
where can one find out what each vfs call expects to be locked
on completion, and how can one find out what each layer expects
to be freed on error.?
1996-08-13 19:48:41 +00:00
Julian Elischer
ed9a71b7fc symlink support in devfs.
it only barely works so don't get too carried away..
I noticed that teh symlink is length 0..
I guess I'll fix that tomorrow..
it also sometimes panics with "cleaned vnode isn't" but it's not more
broken than it was before.. I really want to go over it with someone
who understands the lifecycle of a vnode better than I do..

terry?
kirk?
david?
john?
1996-08-13 07:21:45 +00:00
Bruce Evans
8c2ff39670 Only use the special bdevvp() for DEVFS if DEVFS_ROOT is defined. This
makes option DEVFS safe to use again (although mounting devfs is unsafe).
1996-07-30 18:00:32 +00:00
John Dyson
3c087a2f30 Modify slightly the output from the map file in /proc. Now the
executable bit is shown.
1996-07-27 19:47:04 +00:00
John Dyson
34e95a26ec Under certain circumstances, reading the /proc/*/map file can
crash the system.  Nonexistant objects were not handled correctly.
1996-07-27 18:28:10 +00:00
John Dyson
29387b7bb6 Remove a totally unneeded (and as of the last VM commit, incorrect) call
to pmap_clear_modify.
1996-07-27 03:50:31 +00:00
Poul-Henning Kamp
c74bb98638 DEVFS needs a special bdevvp().
I just noticed some junk in my patch.  I'll remove that in a sec.
1996-07-24 21:22:36 +00:00
Poul-Henning Kamp
41e4eb70b4 Comment out rootdev & rrootdev so a ls -l doesn't panic the machine. 1996-07-03 03:48:46 +00:00
John Dyson
688bbd5b76 Implement locking for pfs nodes, when at the leaf. Concurrent access
to information from a single process causes hangs.  Specifically, this
fixes problems (hangs) with concurrent ps commands, when the system is under
heavy memory load.
Reviewed by:	davidg
1996-07-02 13:38:10 +00:00
John Dyson
c6c4b08e59 Fix a serious problem, with a window where an object lock is needed,
but not there.  The extent of the object lock is expanded to be over the
range that it is needed.  Additionally, clean up the code so that it conforms
to better coding style.
1996-07-02 01:40:52 +00:00
John Dyson
32acf9a16a Add procfs_type.c to the repository. 1996-06-18 05:22:45 +00:00
John Dyson
6ead3edd9c Clean-up the new VM map procfs code, and also add support for executable
format file "etype".  It contains a description of the binary type for
a process.
1996-06-18 05:16:00 +00:00
John Dyson
975dcaa94f This file is the "meat" of the process address space capability. If you
would like other things added, just ask!!!  It might be pretty easy to add.
1996-06-17 22:53:27 +00:00
John Dyson
9353aadd89 Add a feature to procfs to allow display of the process address map
with multiple entries as follows:

	start address, end address, resident pages in range, private pages
		in range, RW/RO, COW or not, (vnode/device/swap/default).
1996-06-17 22:43:36 +00:00
Gary Palmer
75cc5f07de Cosmetic change: make the ``ready to run'' line match the
``ready for devices'' printed out earlier by changing `devs '
to be `DEVFS: '
1996-06-15 20:37:22 +00:00
Gary Palmer
c23670e294 Clean up -Wunused warnings.
Reviewed by:		bde
1996-06-12 05:11:41 +00:00
Gary Palmer
1409e0b384 Clean up -Wunused warnings. Julian asked me to just ifdef
out unused code as this is still work in progress.

Reviewed by:		bde
1996-06-12 05:08:34 +00:00
David Greenman
2f9bae59d6 Moved the fsnode MALLOC to before the call to getnewvnode() so that the
process won't possibly block before filling in the fsnode pointer (v_data)
which might be dereferenced during a sync since the vnode is put on the
mnt_vnodelist by getnewvnode.

Pointed out by Matt Day <mday@artisoft.com>
1996-06-12 03:37:57 +00:00
John Dyson
dc48d43a6c Properly lock the vm space when accessing the memory in a process. This
fix could solve some "interesting" problems that could happen during
process rundown.
1996-06-11 23:52:27 +00:00
Joerg Wunsch
cbe4630780 Fix the reproto.sh script that was broken after my KNFification.
Pointed out by: bde
1996-04-07 01:15:03 +00:00
Joerg Wunsch
d9fb9dd03e KNFify the function definitions. It's harder to grep around when the
function names don't start in column 1.
1996-04-06 13:34:37 +00:00
Marc G. Fournier
ad98bd0b24 Merged devfs_add_devsw() into devfs_add_devswf() 1996-04-03 03:03:27 +00:00
Marc G. Fournier
2523e82c8b Made the src code match the man page.
Removed dev_link() and dev_linkf(), replacing dev_linkf() with devfs_link()
1996-04-02 04:53:05 +00:00
Marc G. Fournier
0d5b12e38e Added dev_linkf() function (dev_link() + printf-style arguments)
Reviewed by:	julian@freebsd.org
1996-03-28 14:32:27 +00:00
Julian Elischer
54a5291b37 Submitted by: "Marc G. Fournier" <scrappy@ki.net>
allows correct creation of subdirectories in devfs_add_devswf()
1996-03-25 21:56:59 +00:00
John Dyson
ad5dd2341c Fix the problem that unmounting filesystems that are backed by a VMIO
device have reference count problems.  We mark the underlying object
ono-persistent, and account for the reference count that the VM system
maintainsfor the special device close.  This should fix the removable
device problem.
1996-03-19 05:13:22 +00:00
Peter Wemm
89be462c47 This commit was generated by cvs2svn to compensate for changes in r14557,
which included commits to RCS files with non-trunk default branches.
1996-03-11 19:29:25 +00:00
Peter Wemm
5e5861b9c6 Import 4.4BSD-Lite2 onto the vendor branch, note that in the kernel, all
files are off the vendor branch, so this should not change anything.

A "U" marker generally means that the file was not changed in between
the 4.4Lite and Lite-2 releases, and does not need a merge.  "C" generally
means that there was a change.
[two new auxillary files in miscfs/union]
1996-03-11 19:29:25 +00:00
Jeffrey Hsu
5a18c60a63 For Lite2: proc LIST changes.
Reviewed by:	davidg & bde
1996-03-11 06:13:09 +00:00