Commit Graph

2352 Commits

Author SHA1 Message Date
Bruce Evans
e7ba67f274 Removed all traces of `p_switchtime'. The relevant timestamp is per-cpu,
not per-process.  Keep it in `switchtime' consistently.

It is now clear that the timestamp is always valid in fork_trampoline()
except when the child is running on a previously idle cpu, which
can only happen if there are multiple cpus, so don't check or set
the timestamp in fork_trampoline except in the (i386) SMP case.
Just remove the alpha code for setting it unconditionally, since
there is no SMP case for alpha and the code had rotted.

Parts reviewed by:	dfr, phk
1999-02-28 10:53:29 +00:00
Julian Elischer
1871f6cdd2 Fix code for union mounts
Accidentally deleted by peter when he extracted the unionfs stuff in 1.109

Submitted by: Tony Finch <dot@dotat.at>
1999-02-27 07:06:05 +00:00
Tor Egge
79a7a64b85 Don't call assign_apic_irq with a value for irq that is out of range. 1999-02-26 03:42:50 +00:00
Bruce Evans
a5c9bce777 Added a used #include (don't depend on "vnode_if.h" including <sys/buf.h>). 1999-02-25 15:54:06 +00:00
Bruce Evans
1b0b259ed2 Don't forget to update `switchticks' in corner cases (except for
the alpha fork_trampoline(), forget it because it I believe it is
only necessary for the unsupported SMP case).
1999-02-25 11:03:08 +00:00
Matthew Dillon
155f87daf2 Reviewed by: Julian Elischer <julian@whistle.com>
Add d_parms() to {c,b}devsw[].  If non-NULL this function points to
    a device routine that will properly fill in the specinfo structure.
    vfs_subr.c's checkalias() supplies appropriate defaults.  This change
    should be fully backwards compatible with existing devices.
1999-02-25 05:22:30 +00:00
Bruce Evans
3965f8d8bb The previous commit also fixed a possibly-wrong (too high) priority
for the rescheduled process.
1999-02-22 18:39:49 +00:00
Bruce Evans
554dedb3c9 Improved scheduling in uiomove(), etc. resched_wanted() is true too
often for it to be a good criterion for switching kernel cpu hogs --
it is true after most wakeups.  Use the criterion "has been running
for >= 2 quanta" instead.
1999-02-22 16:57:48 +00:00
John Polstra
c33fe77954 If you merge this into -stable, please increment __FreeBSD_version
in "src/sys/sys/param.h".

Fix the ELF image activator so that it can handle dynamic linkers
which are executables linked at a fixed address.  This improves
compliance with the ABI spec, and it opens the door to possibly
better dynamic linker performance in the future.  I've experimented
a bit with a fixed-address dynamic linker, and it works fine.  But
I don't have any measurements yet to determine whether it's
worthwhile.

Also, remove a few calculations that were never used for anything.

I will increment __FreeBSD_version, since this adds a new capability
to the kernel that the dynamic linker might some day rely upon.
1999-02-20 23:52:34 +00:00
Doug Rabson
75e08a5e7e A correction to the code which attempts to prevent the same module
being loaded twice.  It used rindex() to strip the pathname but failed
to account for the fact that rindex() will return a pointer to the '/',
not the first character of the filename.

Submitted by: Nick Hibma <hibma@skylink.it>
1999-02-20 21:22:00 +00:00
Luoqi Chen
1c6d46f93c Introduce machine-dependent macro pgtok() to convert page count to number
of kilobytes. Its definition for each architecture could be optimized to
avoid potential numerical overflows.
1999-02-19 19:34:49 +00:00
Matthew Dillon
42e26d47bd Protect vn worklist and vn->v_{clean,dirty}blkhd at splbio().
Get rid of extra LIST_REMOVE()

Reviewed by:	hsu@FreeBSD.ORG (Jeffrey Hsu), mckusick@McKusick.COM
Submitted by:	hsu@FreeBSD.ORG (Jeffrey Hsu), dillon@backplane.com ( Matthew Dillon )
1999-02-19 17:36:58 +00:00
Luoqi Chen
b1028ad122 Hide access to vmspace:vm_pmap with inline function vmspace_pmap(). This
is the preparation step for moving pmap storage out of vmspace proper.

Reviewed by:	Alan Cox	<alc@cs.rice.edu>
		Matthew Dillion	<dillon@apollo.backplane.com>
1999-02-19 14:25:37 +00:00
Luoqi Chen
75ffaf5939 Initialize procsig0.ps_refcnt to 1 (instead of 2), this would silence
complaints about ps_refcnt greater than two when we try to fork() a
kthread from proc0 with RFSIGSHARE flag set.

Noticed by:	Tor Egge <tegge@fast.no>
Reviewed by:	Richard Seaman, Jr. <dick@tar.com>
1999-02-17 21:03:14 +00:00
Doug Rabson
ce02431ffa * Change sysctl from using linker_set to construct its tree using SLISTs.
This makes it possible to change the sysctl tree at runtime.

* Change KLD to find and register any sysctl nodes contained in the loaded
  file and to unregister them when the file is unloaded.

Reviewed by: Archie Cobbs <archie@whistle.com>,
	Peter Wemm <peter@netplex.com.au> (well they looked at it anyway)
1999-02-16 10:49:55 +00:00
Matthew Dillon
ef528b292a Only needed to cast array index from char to unsigned char, did not
also have to cast it to int.  (int)(unsigned char)char_exp ->
    (unsigned char)char_exp.
1999-02-14 20:58:21 +00:00
Kenneth D. Merry
2a888f938e Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed.  The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order.  So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers.  For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it.  Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by:	bde, obrien
1999-02-10 00:04:13 +00:00
John Polstra
47633640aa Change the load address of the ELF dynamic linker from "2L*MAXDSIZ"
to an architecture-specific value defined in <machine/elf.h>.  This
solves problems on large-memory systems that have a high value for
MAXDSIZ.

The load address is controlled by a new macro ELF_RTLD_ADDR(vmspace).
On the i386 it is hard-wired to 0x08000000, which is the standard
SVR4 location for the dynamic linker.

On the Alpha, the dynamic linker is loaded MAXDSIZ bytes beyond
the start of the program's data segment.  This is the same place
a userland mmap(0, ...) call would put it, so it ends up just below
all the shared libraries.  The rationale behind the calculation is
that it allows room for the data segment to grow to its maximum
possible size.

These changes have been tested on the i386 for several months
without problems.  They have been tested on the Alpha as well,
though not for nearly as long.  I would like to merge the changes
into 3.1 within a week if no problems have surfaced as a result of
them.
1999-02-07 23:49:56 +00:00
Matthew Dillon
9fdfe602fc Remove MAP_ENTRY_IS_A_MAP 'share' maps. These maps were once used to
attempt to optimize forks but were essentially given-up on due to
    problems and replaced with an explicit dup of the vm_map_entry structure.
    Prior to the removal, they were entirely unused.
1999-02-07 21:48:23 +00:00
John Polstra
6f8126face Correct an "&" operator which should have been "&&".
Submitted by:	mjacob
1999-02-05 22:24:26 +00:00
Mark Newton
3b351cc1d3 Additional note on last rev: The rationale for this is to allow you
to run Solaris executables (or executables from any other ELF system)
directly off the CD-ROM without having to waste megabytes of disk
by copying them to another filesystem just to brand them.
1999-02-05 03:47:47 +00:00
Mark Newton
f8b3601e08 Created sysctl kern.fallback_elf_brand. Defaults to "none", which will
give the same behaviour produced before today.  If sysadmin sets it
to a valid ELF brand, ELF image activator will attempt to run unbranded
ELF exectutables as if they were branded with that value.

Suggested by: Dima Ruban <dima@best.net>
1999-02-05 03:43:18 +00:00
Matthew Dillon
e198079da2 Fix race in pipe read code whereby a blocked lock can allow another
process to sneak in and write to or close the pipe.  The read code
    enters a 'piperd' state after doing the lock operation without
    checking to see if the state changed, which can cause the process
    to wait forever.

    The code has also been documented more.
1999-02-04 23:50:49 +00:00
Matthew Dillon
82b23b5384 vp->v_object must be valid after normal flow of vfs_object_create()
completes, change if() to KASSERT().  This is not a bug, we are
    simplify clarifying and optimizing the code.

    In if/else in vfs_object_create(), the failure of both conditionals
    will lead to a NULL object.  Exit gracefully if this case occurs.
    ( this case does not normally occur, but needed to be handled ).

Obtained from: Eivind Eklund <eivind@FreeBSD.org>
1999-02-04 18:25:39 +00:00
Mark Newton
096977fae7 Provide elf_brand_inuse() as a method an emulator can use to find out
whether it is currently in use (which is kinda useful when it's about
to unload itself:  Lockups are never very much fun, are they?).
1999-02-04 12:42:39 +00:00
Bruce Evans
8b6ca0359b Switch context before doing some i/o operations that might block if
context would be switched on return to user mode.  This fixes some
denial of service problems.
1999-02-02 12:11:01 +00:00
Bill Fenner
8f70ac3e02 Fix the port of the NetBSD 19990120-accept fix. I misread a piece of
code when examining their fix, which caused my code (in rev 1.52) to:
- panic("soaccept: !NOFDREF")
- fatal trap 12, with tracebacks going thru soclose and soaccept
1999-02-02 07:23:28 +00:00
Mark Newton
9cbac9cee4 Moved prototypes for soo_{read,write,close} into socketvar.h where they
belong.

Suggested by: bde
1999-02-01 21:16:31 +00:00
Mark Newton
c4ca2670b8 Fix bogus line breaks in declarations for soo_read() and soo_write()
Suggested by: Pedant Central :-)
1999-02-01 13:24:39 +00:00
Mark Newton
ba198b1c45 Added comments about non-staticization so it doesn't get un-done next
time someone goes on a staticization binge.

Suggested by: eivind
1999-01-31 03:15:13 +00:00
Mike Smith
e25810a699 Remove unused "kern.shutdown_timeout" sysctl node. 1999-01-30 19:36:02 +00:00
Mike Smith
5c40906f11 An error in the last commit; the changes were submitted by, not reviewed by,
"D. Rock" <rock@cs.uni-sb.de>
1999-01-30 19:29:10 +00:00
Mike Smith
db82a982a7 Add a new sysctl node kern.shutdown, off which shutdown-related things
can be hung.

Add a tunable delay at the beginning of the SHUTDOWN_FINAL at_shutdown
queue, allowing time to settle before we launch into the list of things
that are expected to turn the system off.

Fix a bug in at_shutdown_pri() where the second insertion always put
the item in second position in the queue.

Reviewed by:	"D. Rock" <rock@cs.uni-sb.de>
1999-01-30 19:28:30 +00:00
Poul-Henning Kamp
4e48a6bfe0 Use suser() to determine super-user-ness.
Collapse some duplicated checks.

Reviewed by:	bde
1999-01-30 12:27:00 +00:00
Poul-Henning Kamp
57c90d6fcd Use suser() to determine super-user-ness, don't examine cr_uid directly. 1999-01-30 12:21:49 +00:00
Poul-Henning Kamp
4e2d2aa1cd Use suser() to check for super user rather than examining cr_uid directly.
Use TTYDEF_SPEED rather than 9600 a couple of places.

Reviewed by:	bde, with a few grumbles.
1999-01-30 12:17:38 +00:00
Mark Newton
69a6f20bc8 Unstaticized routines which are needed by the svr4 KLD and the streams
garbage needed to support SysVR4 networking.
1999-01-30 06:25:00 +00:00
Matthew Dillon
bc81493155 More const fixes for -Wall, -Wcast-qual 1999-01-29 23:18:50 +00:00
Matthew Dillon
820ca326e1 *_execsw static structures cannot be const due to the way they interact
with EXEC_SET, DECLARE_MODULE, and module_register.  Specifically,
    module_register.  We may eventually be able to make these const, but
    not now.
1999-01-29 22:59:43 +00:00
Bruce Evans
cacd1f6aa9 Cast to `const char *' instead of to c_caddr_t. This is part of
terminating c_caddr_t with extreme prejudice.  Here we depended
on the "opaque" type c_caddr_t being precisely `const char *'
to do unportable pointer arithmetic.
1999-01-29 09:04:27 +00:00
Matthew Dillon
3cfc69e6c2 More -Wall / -Wcast-qual cleanup. Also, EXEC_SET can't use
C_DECLARE_MODULE due to the linker_file_sysinit() function
    making modifications to the data.
1999-01-29 08:36:45 +00:00
Bruce Evans
9e26dd2a54 Removed bogus casts to c_caddr_t. This is part of terminating
c_caddr_t with extreme prejudice.  Here the original casts to
caddr_t were to support K&R compilers (or missing prototypes),
but the relevant source files require an ANSI compiler.
1999-01-29 08:29:05 +00:00
Bruce Evans
425c50cf51 Removed a bogus cast to c_caddr_t. This is part of terminating
c_caddr_t with extreme prejudice.  Here the point of the original
cast to caddr_t was to break the warning about the const mismatch
between write(2)'s `const void *buf' and `struct uio's `char
*iov_base' (previous bitrot gave a gratuitous dependency on caddr_t
being char *).  Compiling with -Wcast-qual made the cast a full
no-op.

This change has no effect on the warning for discarding `const'
on assignment to iov_base.  The warning should not be fixed by
splitting `struct iovec' into a non-const version for read()
and a const version for write(), since correct const poisoning
would affect all pointers to i/o addresses.  Const'ness should
probably be forgotten by not declaring it in syscalls.master.
1999-01-29 08:10:35 +00:00
Matthew Dillon
f01a9dd520 cleanup warnings by propogating const char pointers properly. 1999-01-29 08:09:32 +00:00
Matthew Dillon
697457a133 Fix warnings related to -Wall -Wcast-qual 1999-01-28 17:32:05 +00:00
Matthew Dillon
0a5e03dda5 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile
1999-01-28 01:59:53 +00:00
Matthew Dillon
8aef171243 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile
1999-01-28 00:57:57 +00:00
Matthew Dillon
fe08c21a53 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile.

    This commit includes significant work to proper handle const arguments
    for the DDB symbol routines.
1999-01-27 23:45:44 +00:00
Matthew Dillon
d254af07a1 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile
1999-01-27 21:50:00 +00:00
Matthew Dillon
598217c491 Fix array index of signed char to cast to unsigned char and then to int.
Also general const cleanup.
1999-01-27 21:36:14 +00:00
Matthew Dillon
a06791bc90 Fix getenv() comparison against '=' ... was *cp = '=' instead of
*cp == '='.
1999-01-27 21:24:50 +00:00
Bruce Evans
fea579e94e Don't forget to count context switches in yield(). 1999-01-27 10:14:05 +00:00
Bruce Evans
dc34e67676 Include <sys/select.h> -- don't depend on pollution in <sys/proc.h>. 1999-01-27 10:10:03 +00:00
Matthew Dillon
56319e3a58 Ok, people didn't like kern.conf_dir. Poof, backed out. 1999-01-26 07:37:11 +00:00
Julian Elischer
88c5ea4574 Enable Linux threads support by default.
This takes the conditionals out of the code that has been tested by
various people for a while.
ps and friends (libkvm) will need a recompile as some proc structure
changes are made.

Submitted by:	"Richard Seaman, Jr." <dick@tar.com>
1999-01-26 02:38:12 +00:00
Matthew Dillon
b1cba377b0 Add kern.conf_dir sysctl. This is a R+W string used to specify the
directory containing rc.conf.local and rc.local, and possibly other
    things in the future.

    This sysctl is used by the diskless startup code and new rc.conf.  If
    it cannot be found or is empty, the system should revert to using /etc.
1999-01-25 18:26:09 +00:00
Bill Fenner
527b7a14a5 Port NetBSD's 19990120-accept bug fix. This works around the race condition
where select(2) can return that a listening socket has a connected socket
queued, the connection is broken, and the user calls accept(2), which then
blocks because there are no connections queued.

Reviewed by:	wollman
Obtained from:	NetBSD
(ftp://ftp.NetBSD.ORG/pub/NetBSD/misc/security/patches/19990120-accept)
1999-01-25 16:58:56 +00:00
Bill Fenner
ec42cbfc24 Don't free the socket address if soaccept() / pru_accept() doesn't
return one.
1999-01-25 16:53:53 +00:00
Doug Rabson
149a155c3b Don't try to call SYSUNINIT functions if there was a link error.
Reviewed by: Peter Wemm <peter@netplex.com.au>
1999-01-25 08:42:24 +00:00
Bruce Evans
73a6265d68 Go back to only supporting revoke() for bdevs and cdevs. It is very
buggy for fifos, and no one seems to have investigated its behaviour
on other types of files.  It has been broken since the Lite2 merge
in rev.1.54.

Nagged about by:	Brian Feldman (green@unixhelp.org)
1999-01-24 06:28:37 +00:00
Matthew Dillon
257aefa704 Addendum: The original code that the last commit 'fixed' actually did
not have a bug in it, but the last commit did make it more readable so
    we are keeping it.
1999-01-24 03:49:58 +00:00
Matthew Dillon
89600e8663 There was a situation where sendfile() might attempt to initiate I/O
on a PG_BUSY page, due to a bug in its sequencing of a conditional.
1999-01-24 01:15:58 +00:00
Matthew Dillon
377f9b28a6 Don't try to calculate B_CACHE for an NFS related bp that has a
> 0 b_validend.  This will screw up small-writes, causing lots of
    little writes out the network.

    We will assume that NFS handles B_CACHE properly.
1999-01-24 00:51:11 +00:00
Matthew Dillon
fae1f2e045 Fix an expression parenthesization typo in a conditional. It should not
have any operational effects other then to make the code in question
     a little faster.  Also added a more involved comment.
1999-01-23 06:36:15 +00:00
Peter Wemm
461b36ab54 Update userref handling after discussion with submitter of previous
patch.  lf can't be dereferenced after the unload attempt, in case it
was freed.  Instead, decrement first and back it out if the unload failed.
This should be relatively immune to races caused by the user since the
userref count will be zero for the duration of the actual unloading and
will stop further kldunload attempts.

Submitted by:   Ustimenko Semen <semen@iclub.nsu.ru>
1999-01-23 03:45:22 +00:00
David Greenman
33ce4218c6 Don't throw away the buffer contents on a fatal write error; just mark
the buffer as still being dirty. This isn't a perfect solution, but
throwing away the buffer contents will often result in filesystem
corruption and this solution will at least correctly deal with transient
errors.
Submitted by:	Kirk McKusick <mckusick@mckusick.com>
1999-01-22 08:59:05 +00:00
Mike Smith
8de6e8e102 Allow VM_KMEM_SIZE to be tuned from the kernel environment. This tuning
value *completely* overrides any value precalculated by the kernel.
1999-01-21 21:54:32 +00:00
Matthew Dillon
8618c644e4 The main operational changes are in getblk()'s handling of the
B_DELWRI and B_CACHE flags, fixing a bug that showed up with NFS.
    Also, a number of cases where manually inserted code has been removed
    and replaced with an inline function call giving us better functional
    isolation in the source.
1999-01-21 09:19:33 +00:00
Matthew Dillon
39ebd17269 The code that reclaims descriptors from in-transit unix domain
descriptor-passing messages was calling sorflush() without checking
    to see if the descriptor was actually a socket.  This can cause a
    crash by exiting programs that use the mechanism under certain
    circumstances.
1999-01-21 09:02:18 +00:00
Matthew Dillon
0069f505eb Fixed a potential bug ( but maybe not ), where sendfile() clears PG_BUSY
on a page without testing for waiters.  Also collapsed busy wait into
    new vm_page_sleep_busy() inline ( see vm/vm_page.h )
1999-01-21 09:00:26 +00:00
Matthew Dillon
3701b35988 This module was used only by the old swapper and has been #if'd out,
and will be eventually removed if no other use is found for it.
1999-01-21 08:58:41 +00:00
Matthew Dillon
1c7c3c6a86 This is a rather large commit that encompasses the new swapper,
changes to the VM system to support the new swapper, VM bug
    fixes, several VM optimizations, and some additional revamping of the
    VM code.  The specific bug fixes will be documented with additional
    forced commits.  This commit is somewhat rough in regards to code
    cleanup issues.

Reviewed by:	"John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>
1999-01-21 08:29:12 +00:00
Matthew Dillon
7090df5aed Add new blist module - radix tree based bitmap allocator with
size hinting.  Will be used by the new swapper.
1999-01-21 08:11:06 +00:00
Julian Elischer
ea5f0893fd Minor rearranging of code to allow simple protocol domains to be
added as KLDs.
1999-01-21 00:26:41 +00:00
Bill Fenner
7b1777101c Also consider the space left in the socket buffer when deciding whether
to set PRUS_MORETOCOME.
1999-01-20 17:45:22 +00:00
Bill Fenner
b0acefa8d4 Add a flag, passed to pru_send routines, PRUS_MORETOCOME. This
flag means that there is more data to be put into the socket buffer.
Use it in TCP to reduce the interaction between mbuf sizes and the
Nagle algorithm.

Based on:	"Justin C. Walker" <justin@apple.com>'s description of Apple's
		fix for this problem.
1999-01-20 17:32:01 +00:00
Eivind Eklund
15a1057c46 Add 'options DEBUG_LOCKS', which stores extra information in struct
lock, and add some macros and function parameters to make sure that
the information get to the point where it can be put in the lock
structure.

While I'm here, add DEBUG_VFS_LOCKS to LINT.
1999-01-20 14:49:12 +00:00
Jordan K. Hubbard
c71d51c375 Make more messages conditional on bootverbose 1999-01-20 04:24:22 +00:00
Peter Wemm
d7dfdda203 Relax linkage symbol scope restrictions to be more compatable with that
of shared libraries.
1999-01-19 22:26:46 +00:00
Peter Wemm
e75a9dc0b6 Don't decrement userrefs unless the file was actually was unloaded.
Submitted by:	Ustimenko Semen <semen@iclub.nsu.ru>
1999-01-19 16:26:32 +00:00
Matthew Dillon
ba2871b74c Obtained from: Luoqi
Fix NFS file corruption problem introduced in 1.188.  The valid range
    was not being set properly, causing a later reference to the buffer
    to clear the B_CACHE bit.
1999-01-19 08:00:51 +00:00
Peter Wemm
87acc0db42 - Move lkmnosys() to kern_syscall.c
- Have the VFS lkm support use vfs_register() etc rather than having it's
  own version.
- Have the syscall lkm support use syscall_register() etc rather than
  having it's own verison.
- Convert the lkm driver to a module.
1999-01-17 19:00:58 +00:00
Peter Wemm
46db48360d Move lkmnosys() from kern_lkm.c to here. 1999-01-17 18:58:04 +00:00
Peter Wemm
e99f57c354 Try and clean up the multiple formal loading support a bit, based on
suggestions from Greg Lehey some time ago.  In the face of multiple
potential file formats, try and give a more sensible error than just
ENOEXEC.

XXX a good case can be made that the loading process is wrong - the linker
should locate the file first (using the search paths etc), then run the
loaders to see if they recognize it.  While the present system allows for
the possibility of different search paths for different formats, we do not
use it and it just makes things more complicated than they need to be.
1999-01-17 17:58:52 +00:00
Doug Rabson
c3654b5c4d A few small improvements to the bus code:
* A function device_printf() to make pretty-printing driver messages easier.
* A function device_get_children() to query the children of a device.
* Generic implementations of BUS_ALLOC_RESOURCE and BUS_RELEASE_RESOURCE.
* Change bus_generic_print_child() so that it is actually useful.
1999-01-16 17:44:09 +00:00
Mike Smith
2084f96c7f Add getenv_int(), specifically for retrieving integer values from kernel
environment variables.  This makes it easy to pass tuning parameters
in from the bootloader.
1999-01-15 17:25:02 +00:00
Mike Smith
118537f287 Add sscanf/vsscanf/strtoq/strtouq to the kernel. Initially these will be used
for parsing kernel environment values, although they have utility elsewhere.
1999-01-15 00:03:39 +00:00
Julian Elischer
d8c85307b2 Re-enable the options in ps(1) that were disabled with the Linux
threads support.

Submitted by:	"Richard Seaman, Jr." <dick@tar.com>
1999-01-13 03:11:43 +00:00
Eivind Eklund
a32c99f35e Silence warnings. 1999-01-12 11:59:34 +00:00
Eivind Eklund
1950f59007 Silence warnings. 1999-01-12 00:19:33 +00:00
Nick Hibma
181aa362df Remove warning 1999-01-10 22:04:05 +00:00
Poul-Henning Kamp
86415b71f9 Back out last change to sysctl.
It was nay'ed before committing on the grounds that this is not
the way to do it, and has been decided as such several times in
the past.

There is not point in loading gobs of ascii into the kernel when
the only use of that ascii is presentation to the user.

Next thing we'd be adding all section 4 man pages to the loaded
kernel as well.

The argument about KLD's is bogus, klds can store a file in
/usr/share/doc/sysctl/dev/foo/thisvar.txt with a description and
sysctl or other facilities can pick it up there.

Proper documentation will take several K worth of text for many
sysctl variables, we don't want that in the kernel under any
circumstances.

I will welcome any well thought out attempt at improving the
situation wrt. sysctl documentation, but this wasn't it.
1999-01-10 07:45:33 +00:00
Dag-Erling Smørgrav
302a110207 Add kernel support for sysctl descriptions. The NO_SYSCTL_DESCRIPTIONS option
disables them if they're not wanted; in that case, sysctl_sysctl_descr will
always return an empty string.

Apporved by:	jkh
1999-01-10 05:33:43 +00:00
Eivind Eklund
219cbf59f2 KNFize, by bde. 1999-01-10 01:58:29 +00:00
Doug Rabson
f8047d25cc Remove a diagnostic message left in by mistake. 1999-01-09 16:50:04 +00:00
Doug Rabson
a35261ef91 Implement a mechanism for a module to report a small amount of module
specific data back to the user via kldstat(2).  Use that mechanism in
the syscall handler to report the syscall number used.
1999-01-09 14:59:50 +00:00
Doug Rabson
4c3df79450 Implement support for adding syscalls in KLD modules.
Submitted by: Assar Westerlund <assar@sics.se>
1999-01-09 14:15:41 +00:00
Eivind Eklund
5526d2d920 Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT as
discussed on -hackers.

Introduce 'KASSERT(assertion, ("panic message", args))' for simple
check + panic.

Reviewed by:	msmith
1999-01-08 17:31:30 +00:00
Julian Elischer
dc9c271aa1 Changes to the LINUX_THREADS support to only allocate extra memory for
shared signal handling when there is shared signal handling being
used.

This removes the main objection to making the shared signal handling
a standard ability in rfork() and friends and 'unconditionalising'
this code. (i.e. the allocation of an extra 328 bytes per process).

Signal handling information remains in the U area until such a time as
it's reference count would be incremented to > 1. At that point a new
struct is malloc'd and maintained in KVM so that it can be shared between
the processes (threads) using it.

A function to check the reference count and move the struct back to the U
area when it drops back to 1 is also supplied. Signal information is
therefore now swapable for all processes that are not sharing that
information with other processes. THis should addres the concerns raised
by Garrett and others.

Submitted by:	"Richard Seaman, Jr." <dick@tar.com>
1999-01-07 21:23:50 +00:00
Kazutaka YOKOTA
fc847f6651 Remove a hard-coded table of kernel console I/O functions exported
from sc, vt and sio drivers.  Use instead a linker_set to collect them.

Staticize ??cngetc(), ??cnputc(), etc functions in sc and vt drivers.
We must still have siocngetc() and siocnputc() as globals because they
are directly referred to by i386-gdbstub.c :-(

Oked by: bde
1999-01-07 14:14:24 +00:00
Julian Elischer
2267af789e Add (but don't activate) code for a special VM option to make
downward growing stacks more general.
Add (but don't activate) code to use the new stack facility
when running threads, (specifically the linux threads support).
This allows people to use both linux compiled linuxthreads, and also the
native FreeBSD linux-threads port.

The code is conditional on VM_STACK. Not using this will
produce the old heavily tested system.

Submitted by: Richard Seaman <dick@tar.com>
1999-01-06 23:05:42 +00:00
Mike Smith
f1b265228c Don't allow more than one module with the same name to be loaded.
Make kldfind ignore the path when searching for a loaded module.

Submitted by:	John Birrell (jb@freebsd.org)
1999-01-05 20:24:28 +00:00
Eivind Eklund
fb1167777a Remove the 'waslocked' parameter to vfs_object_create(). 1999-01-05 18:50:03 +00:00
Eivind Eklund
0df45b5a31 Finish staticization. 1999-01-05 18:12:29 +00:00
Bruce Evans
289bdf33d3 Ifdefed conditionally used simplock variables. 1999-01-02 11:34:57 +00:00
Bruce Evans
9fe425981b Fixed bitrot in a comment. Fixed some style bugs. 1999-01-01 14:41:51 +00:00
Peter Wemm
a13ddfb633 When loading something that has undefined symbols, it would be helpful to
know what they were..
1998-12-31 09:17:20 +00:00
Doug Rabson
9c0fed3dcf Various changes to support OSF1 emulation:
* Move the user stack from VM_MAXUSER_ADDRESS to a place below the 32bit
  boundary (needed to support 32bit OSF programs).  This should also save
  one pagetable per process.
* Add cvtqlsv to the set of instructions handled by the floating point
  software completion code.
* Disable all floating point exceptions by default.
* A minor change to execve to allow the OSF1 image activator to support
  dynamic loading.
1998-12-30 10:38:59 +00:00
Mike Smith
9959b1a882 Improved DDB_UNATTENDED behaviour. From the submitter:
There's something that's been bugging me for a while, so I decided to fix it.
FreeBSD now will DTRT WRT DDB and DDB_UNATTENDED (!debugger_on_panic), at least
in my opinion. The behavior change is such that:

	1. Nothing changes when debugger_on_panic != 0.
	2. When DDB_UNATTENDED (!debugger_on_panic), if a panic occurs, the
		machine will reboot. Also, if a trap occurs, the machine will
		panic and reboot, unlike how it broke to DDB before. HOWEVER,
		a trap inside DDB will not cause a panic, allowing full use
		of DDB without having to worry about the machine being stuck
		at a DDB prompt if something goes wrong during the day.
		Patches for this behavior follow my signature, and it would
		be a boon to anyone (like me) who uses DDB_UNATTENDED, but
		actually wants the machine to panic on a trap (otherwise,
		what's the use, if the machine causes a fatal trap rather than
		a true panic, of debugger_on_panic?). The changes cause no
		adverse behavior, but do involve two symbols becoming global

Submitted by:	Brian Feldman <green@unixhelp.org>
1998-12-28 23:03:00 +00:00
Doug Rabson
486bddb033 Fix some 64bit truncation problems which crept into SYSCTL_LONG() with the
last cleanup.  Since the oid_arg2 field of struct sysctl_oid is not wide
enough to hold a long, the SYSCTL_LONG() macro has been modified to only
support exporting long variables by pointer instead of by value.

Reviewed by: bde
1998-12-27 18:03:29 +00:00
Doug Rabson
dae6345236 Tweak ptrace(PT_READ_U) so that the last alpha register can be read. 1998-12-26 17:14:37 +00:00
Bruce Evans
4d94881342 Restored rev.1.31 which was clobbered by rev.1.69 (the big Lite2
merge).  This fixes at least hanging in revoke(2) when a somewhat
active slave pty is revoked.  The hang made the window for the
null pointer bug in ufsspec_{read,write} much larger.

There are many other bugs in this area (revoke of an active fifo
at best leaks memory...).
1998-12-24 12:07:16 +00:00
Matthew Dillon
e6ee8e16e0 Adjust some comments to prevent future confusion on the implementation.
Also add a reference to the buf(9) manual page.
1998-12-22 18:57:30 +00:00
Luoqi Chen
1a551e9808 Correctly handle misaligned VMIO buffer (whose start or end offset in the VM
object are not page aligned). This should fix the mount_msdos panic after a
failed attemp to mount as ffs.

Reviewed By:	Matthew Dillon	<dillon@apollo.backplane.com>
		Archie Cobbs	<archie@whistle.com>
		Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
1998-12-22 14:43:58 +00:00
Eivind Eklund
29c98cd8bf Check return value of tsleep(). I've checked of all call points -
there does not seem to be a problem with this.

PR:		kern/8732
Analysis by:	David G Andersen <danderse@cs.utah.edu>
Tested by:	Alfred Perlstein <bright@hotjobs.com>
1998-12-22 00:44:11 +00:00
Eivind Eklund
db878ba480 Staticize. 1998-12-21 23:38:33 +00:00
Matthew Dillon
a1d6c3ec87 Add asleep() and await() support. Currently highly experimental. A
small support structure had to be added to the proc structure, and
    a few minor conditional panics no longer apply.
1998-12-21 07:41:51 +00:00
Julian Elischer
39fb8e6b3e Fix two bogons created by 'patch(1)' in my last commit. 1998-12-19 08:23:31 +00:00
Julian Elischer
6626c6045c Reviewed by: Luoqi Chen, Jordan Hubbard
Submitted by:	 "Richard Seaman, Jr." <lists@tar.com>
Obtained from:	linux :-)

Code to allow Linux Threads to run under FreeBSD.

By default not enabled
This code is dependent on the conditional
COMPAT_LINUX_THREADS (suggested by Garret)
This is not yet a 'real' option but will be within some number of hours.
1998-12-19 02:55:34 +00:00
Bruce Evans
4c56fcdead Removed the cast to a pointer in the definition of PS_STRINGS and
adjusted related casts to match (only in the kernel in this commit).
The pointer was only wanted in one place in kern_exec.c.  Applications
should use the kern.ps_strings sysctl instead of PS_STRINGS, so they
shouldn't notice this change.
1998-12-16 16:28:58 +00:00
Bruce Evans
2caecceeb5 Removed all traces of SYSCTL_INTPTR(). Pointers can't really be passed
across the kernel -> application interface, and for the one sysctl where
they were passed and actually used (kern.ps_strings), the applications
want addresses represented as u_longs anyway (the other sysctl that
passed them, kern.usrstack, has never been used).

Agreed to by:	dfr, phk
1998-12-16 16:06:29 +00:00
Bruce Evans
4f2129fa86 Removed bogus casts of USRSTACK and/or the other operand in binary
expressions involving USRSTACK.
1998-12-16 15:21:51 +00:00
Dag-Erling Smørgrav
e3b3ba2d79 Wrap two macros into do { ... } while (0), and fix the way they're used
in the kernel.

Reviewed by: bde
1998-12-15 17:38:33 +00:00
Matthew Dillon
fe523aa107 fix intermediate overflow in 'quad = int * int' situation by casting
the arguments to the multiply to a quad equivalent.  In this case,
    vm_ooffset_t.

Reviewed by:	Archie Cobbs <archie@whistle.com>
1998-12-14 21:17:37 +00:00
Matthew Dillon
3ea57f9da2 Fixed problems with kernel config file overrides of sysv semaphore
parameters.  Prior to this fix a kernel config override would effect
only some of the kernel files, resulting in panics.

PR:	kern/9068
1998-12-14 08:34:55 +00:00
Matthew Dillon
f7bb75c92a Fix -Wuninitialized warning regarding zero-length var-args ctl element.
( this isn't really an error, but I think it is important to fix the
    warning ).
1998-12-14 05:37:37 +00:00
Don Lewis
2b648ac0a1 Add a generic flag, CTLFLAG_SECURE, which can be used to mark a sysctl
variable unwriteable when securelevel > 0.
Reviewed by: jdp, eivind
1998-12-13 07:19:13 +00:00
Don Lewis
65de0c7a93 getpgid() and getsid() were doing a comparision rather than an assignment,
which is fortunate, because otherwise another bug would allow them to be
used to stomp on the syscall return value of another process.
1998-12-13 07:07:51 +00:00
Matthew Dillon
4c01697599 PR: kern/8965
Obtained from: Stephen Clawson <sclawson@cs.utah.edu>

    Wakeup anyone waiting on a mount point prior to returning from umount,
    whether an error occurs or not.  Fixes a stat/NFS-umount race and other
    potential future problems.  Fix taken from bug/pr which also indicated
    that the same fix has already been applied to OpenBSD and NetBSD.
1998-12-12 21:07:09 +00:00
Nick Hibma
b3f65f42c0 When no driver was found for a device, the message 'not probed' appeared
This is odd, especially in the case of USB where the driver is found
in several tries: vendor specific, class specific, interface specific.
The mouse driver is found at the interface specific level...
Reviewed by:	Doug Rabson (dfr@freebsd.org)
1998-12-12 11:30:04 +00:00
Eivind Eklund
2ae353f9a7 Rename one of the two devfs_link's to devfs_makelink. 1998-12-10 19:57:01 +00:00
Jordan K. Hubbard
337c96916f poll(2) sets POLLNVAL for descriptors passed in that are less than
0.  This makes it difficult to do efficient manipulation of the
struct pollfd since you can't leave a slot empty.

PR:		8599
Submitted-by:	Marc Slemko <marcs@znep.com>
1998-12-10 01:53:26 +00:00
Robert V. Baron
efb73e5aca In ktrwrite, use uio_procp = curproc vs 0 1998-12-10 01:47:41 +00:00
Eivind Eklund
d51523c6c9 Get rid of CTLTYPE_OPAQUE in a SYSCTL_OPAQUE - it is added my the
SYSCTL_OPAQUE macro.
1998-12-09 02:26:45 +00:00
Bruce Evans
e1501bb6eb Backed out the FIOASYNC fix in rev.1.108. fcntl(fd, F_SETFL, flags)
depends on the bug.  It does an FIOASYNC ioctl to sync the setting
of the O_ASYNC "file" flag with drivers even if the setting hasn't
changed.

PR:		9003
1998-12-08 10:22:07 +00:00
Archie Cobbs
f1d19042b0 The "easy" fixes for compiling the kernel -Wunused: remove unreferenced static
and local variables, goto labels, and functions declared but not defined.
1998-12-07 21:58:50 +00:00
Eivind Eklund
4979978b8d Fix grouping of statements. This remove a potential panic in the soft
updates code.  While I'm here, remove an unintended trigraph.

Reviewed by:	Kirk McKusick <kirk@freebsd.org>
1998-12-07 17:23:45 +00:00
Andrey A. Chernov
8e3c23be56 Move stime declaration to main block, otherwise can left uninitialized
in rare cases.
Found by: Eivind Eklund <eivind@yes.no>
1998-12-07 07:59:20 +00:00
Archie Cobbs
2326715f79 Avoid compiler warning (printf arg type mismatch) when compiling #ifdef DEBUG 1998-12-06 00:03:30 +00:00
Kirk McKusick
fcdfed00d5 Even the most recently allocated buffer may not have its b_blkno
field properly filled in, so we must do a VOP_BMAP on that buffer
as well if it is not resolved.
Submitted by: Luoqi Chen <luoqi@watermarkgroup.com>
1998-12-05 06:12:14 +00:00
Archie Cobbs
2127f26023 Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by:	Bruce Evans <bde@zeta.org.au>
Reviewed by:	Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by:	Mike Spengler <mks@networkcs.com>
1998-12-04 22:54:57 +00:00
David Greenman
911e8dbc2a Fixed broken code in sendfile(2) when using file offsets. 1998-12-03 12:35:47 +00:00
Archie Cobbs
8245f3f5b4 Add snprintf(3) and vsnprintf(3) capability to the kernel.
Reviewed by:	bde
1998-12-03 04:45:57 +00:00
KATO Takenori
9ad861edee - For some old Cyrix CPUs, %cr2 is clobbered by interrupts. This
problem is worked around by using an interrupt gate for the page
   fault handler.  This code was originally made for NetBSD/pc98 by
   Naofumi Honda <honda@kururu.math.sci.hokudai.ac.jp> and has already
   been in PC98 tree.  Because of this bug, trap_fatal cannot show
   correct page fault address if %cr2 is obtained in this function.
   Therefore, trap_fatal uses the value from trap() function.
-  The trap handler always enables interruption when buggy application
   or kernel code has disabled interrupts and then trapped.  This code
   was prepared by Bruce Evans <bde@FreeBSD.org>.

Submitted by:	Bruce Evans <bde@FreeBSD.org>
		Naofumi Honda <honda@kururu.math.sci.hokudai.ac.jp>
1998-12-02 08:15:17 +00:00
Eivind Eklund
0bfe299097 Check return value of malloc() in expand_name.
Reviewed by:	sef
1998-12-02 01:53:48 +00:00
Poul-Henning Kamp
510eb5b9db Make the previous behaviour the default, add a sysctl which you
can set if your hw/sw produces the "calcru negative..." message.

Setting the alternate method (sysctl -w kern.timecounter.method=1)
makes the the get{nano|micro}*() functions call the real thing at
resulting in a measurable but minor overhead.

I decided to NOT have the "calcru" change the method automatically
because you should be aware of this problem if you have it.

The problems currently seen, related to usleep and a few other corners
are fixed for both methods.
1998-11-29 20:31:02 +00:00
David Greenman
f2b678d4cb Compare p_cpulimit with RLIM_INFINITY before comparing it with the process
runtime. p_runtime is unsigned while p_cpulimit is not, so this avoids the
nasty side effect of the process getting killed when the runtime comes up
"negative" due to other bugs.
1998-11-27 11:44:22 +00:00
Tor Egge
18830dba83 Don't forget to update the pmap associated with aio daemons when adding
new page directory entries for a growing kernel virtual address space.
1998-11-27 01:14:21 +00:00
Tor Egge
f0ac792bec Attempt to handle interrupts delivered to all IO APICs by using the first
IO APIC with a sufficient number of pins.
1998-11-26 23:14:23 +00:00
Eivind Eklund
9fcdafaefc Staticize. 1998-11-26 18:50:24 +00:00
Bruce Evans
e7414d1bfa Fixed the previous fix - stathz doesn't give the statclock frequency
when it is 0.

Submitted by:	mostly by Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
1998-11-26 16:49:55 +00:00
Bruce Evans
44f05f9c92 Oops, yet again back out some local changes that shouldn't have been
in the previous commit.
1998-11-26 14:05:58 +00:00
Bruce Evans
e4d0e37b33 Fixed scaling of p_pctcpu. It was wrong by a factor of stathz/hz.
Until recently, this was half compensated for in at least ps and top
by multiplying by 100/stathz to get a better wrong factor of 100/hz.
1998-11-26 14:00:08 +00:00
Poul-Henning Kamp
c2906d55d0 Make timecounters more resistant to badly behaved SW/HW which locks
out interrupts for too long.  If you still see the "calcru: negative
time..." message you can increase NTIMECOUNTER (see LINT).

Sideeffect is that a timecounter is required to not wrap around in
less than (1 + delta) seconds instead of the (1/hz + delta) required
until now.

Many thanks to: msmith, wpaul, wosch & bde
1998-11-23 09:59:02 +00:00
Søren Schmidt
8843cc3508 Add a kludge to prevent panicing when using VM86 and hitting here
with a NULL curproc.

Originally by: Tor Egge (IIRC)
1998-11-23 09:34:19 +00:00
Bruce Evans
f6233520ce Fixed a missing include. `SYSININT(...);' garbage in gave null garbage out. 1998-11-23 09:33:35 +00:00
Don Lewis
9d2b090975 We can't call fsetown() from sonewconn() because sonewconn() is be called
from an interrupt context and fsetown() wants to peek at curproc, call
malloc(..., M_WAITOK), and fiddle with various unprotected data structures.
The fix is to move the code that duplicates the F_SETOWN/FIOSETOWN state
of the original socket to the new socket from sonewconn() to accept1(),
since accept1() runs in the correct context.  Deferring this until the
process calls accept() is harmless since the process can't do anything
useful with SIGIO on the new socket until it has the descriptor for that
socket.

One could make the case for not bothering to duplicate the
F_SETOWN/FIOSETOWN state and requiring the process to explicitly make the
fcntl() or ioctl() call on the new socket, but this would be incompatible
with the previous implementation and might break programs which rely on
the old semantics.

This bug was discovered by Andrew Gallatin <gallatin@cs.duke.edu>.
1998-11-23 00:45:39 +00:00
Bruce Evans
7dd89537f1 Fixed some missing cases in the check for ioctls that involve modification.
Many (mostly machine-dependent ones) are still missing.  NIST-PCTS found
this bug for all the ioctls used to implement the POSIX tc* functions
(TIOCCBRK, TIOCDRAIN, TIOCSPGRP, TIOCSBRK, TIOCSTART and TIOCSTOP), and
I found FIOASYNC, TIOCCONS, TIOCEXCL, TIOCHPCL, TIOCNXCL, TIOCSCTTY and
TIOCSDRAINWAIT by inspection.  TIOCSPGRP was ifdefed out for some reason.

Handle tcsetattr()'s historical speed conversions correctly and more
centrally:
- don't store speeds of 0 in the final termios struct.  Drivers can now
  depend on tp->t_ispeed and tp->t_ospeed giving the actual speed.
  Applications can now depend on tcgetattr() being POSIX.1 conformant.
- convert from a proposed input speed of 0 to the proposed output speed
  (except if that is 0, convert to the current output speed).  Drivers
  can now depend on the proposed input speed being nonzero.
- don't reject negative speeds.  Negative speeds can't happen now that
  speed_t is unsigned, and rejecting invalid speeds is a bug - tcsetattr()
  is supposed to succeed if it can "perform any of the requested actions",
  so it shouldn't fail in practice.
1998-11-22 09:04:09 +00:00
David Greenman
4f699173cb Closed a very narrow and rare race condition that involved net interrupts,
bio interrupts, and a truncated file that along with the precise alignment
of the planets could result in a page being freed multiple times or a
just-freed page being put onto the inactive queue.
1998-11-18 09:00:47 +00:00
Kirk McKusick
96334b8fc8 Because buffers may be tossed and recreated at will under the new VM
system, the mapping from logical to physical block number may be lost.
Hence we have to check for a reconstituted buffer and redo the call to
VOP_BMAP if the physical block number has been lost.
1998-11-17 00:31:12 +00:00
Kenneth D. Merry
d9e371b995 Now that the wd driver is fixed (Thanks Bruce!), re-enable the
devstat_end_transaction error message that gets printed whenever the
busy count is < 0.

This will help catch drivers that improperly implement devstat(9) support.
1998-11-15 23:57:22 +00:00
Doug Rabson
921433915d A couple of minor sanity checks.
Submitted by: Nick Hibma <nick.hibma@jrc.it>
1998-11-15 18:11:21 +00:00
David Greenman
efac52b4ab In sendfile(2), check against sb_lowat when filling the socket buffer,
rather than 0.
1998-11-15 16:55:09 +00:00
Bruce Evans
4ae860afde Fixed the type of vfs_modevent (a little late, to match the corresponding
change in sys/mount.h).
1998-11-15 15:18:30 +00:00
Bruce Evans
14fddaf97a Fixed a missing include. <sys/kernel.h> is needed by the new
MALLOC_DEFINE() and MALLOC_DEFINE() is needed by the recently
reenabled "reallocblks" code, but <sys/kernel.h> was only included
if CLUSTERDEBUG was defined.  This was too harmless.  gcc only
warns about garbage like `SYSINIT(blech);' at file scope ...
1998-11-15 14:11:06 +00:00
David Greenman
f2efb8e4c8 Fixed a couple of nits in sendfile(2): clear PG_ZERO before unbusying
the page, and use passed-in "p" rather than curproc in uio struct.
1998-11-14 23:36:17 +00:00
Garrett Wollman
14177d72cd My changes to the new device interface:
- Interface wth the new resource manager.
	- Allow for multiple drivers implementing a single devclass.
	- Remove ordering dependencies between header files.
	- Style cleanup.
	- Add DEVICE_SUSPEND and DEVICE_RESUME methods.
	- Move to a single-phase interrupt setup scheme.

Kernel builds on the Alpha are brken until Doug gets a chance to incorporate
these changes on that side.

Agreed to in principle by: dfr
1998-11-14 21:58:51 +00:00
Mike Smith
d02d6d040a Don't count non-local dirty buffers as outstanding when shutting down.
This avoids the fsck-on-reboot symptoms if you're shutting down with a
hung or unreachable NFS server mounted.  Also remove non-local
filesystems from the mount list to prevent the system hanging when it tries
to unmount them (for the same reason).

Drew points out that there's a good argument for forcibly removing all
"non syncable" filesystems from the mount list (eg. NFS mounts, disks
that aren't responding, etc.) as this then allows you to sync and
cleanly unmount their parents.  No such change is included in this
patch.

Submitted by:	Andrew Gallatin <gallatin@cs.duke.edu>
1998-11-13 22:40:37 +00:00
Doug Rabson
92c6ae04da A couple of fixes to device_delete_child() to delete all children of
the device and to free the device which is being deleted (not its
parent - oops).

Submitted by: Nick Hibma <nick.hibma@jrc.it>
1998-11-13 09:39:37 +00:00
David Greenman
1c680b45a2 Restored the "reallocblks" code to its former glory. What this does is
basically do a on-the-fly defragmentation of the FFS filesystem, changing
file block allocations to make them contiguous. Thanks to Kirk McKusick
for providing hints on what needed to be done to get this working.
1998-11-13 01:01:44 +00:00
Peter Wemm
ba031106b1 kldsym(2) prototype implementation 1998-11-11 13:04:40 +00:00
Peter Wemm
de8a10f07a regenerate (+kldsym) 1998-11-11 12:57:05 +00:00
Peter Wemm
325e13dd19 A kldsym(2) syscall prototype for extracting information from the in-kernel
linker.  This is intended to replace kvm_mkdb etc.  The first version
only does name->value lookups, but it's open ended.  value->name lookups
would probably be a good thing to do too.

It's been suggested to try and connect the symbol tables to sysctl (which
is probably a more flexible way of doing it if it's done right), but that
is far more complex and difficult than I was ready to have a shot at.
1998-11-11 12:45:14 +00:00
Don Lewis
62d6ce3af2 I got another batch of suggestions for cosmetic changes from bde. 1998-11-11 10:56:07 +00:00
Don Lewis
831d27a9f5 Installed the second patch attached to kern/7899 with some changes suggested
by bde, a few other tweaks to get the patch to apply cleanly again and
some improvements to the comments.

This change closes some fairly minor security holes associated with
F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN
had on tty devices.  For more details, see the description on the PR.

Because this patch increases the size of the proc and pgrp structures,
it is necessary to re-install the includes and recompile libkvm,
the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w.

PR:		kern/7899
Reviewed by:	bde, elvind
1998-11-11 10:04:13 +00:00
Peter Wemm
1c5bb3eaa1 add #include <sys/kernel.h> where it's needed by MALLOC_DEFINE() 1998-11-10 09:16:29 +00:00
Peter Wemm
c6105dce78 Register and unregister vnodeops the new way rather than leaking on
unload.
1998-11-10 09:12:40 +00:00
Peter Wemm
5ad3d2212f kzipboot uses kern/inflate.c outside the kernel by providing its own
minimal malloc/free implementation.  Stop passing M_GZIP to it.
1998-11-10 09:08:49 +00:00
Peter Wemm
4e61198e8f Make the vnode opv vector construction fully dynamic. Previously we
leaked memory on each unload and were limited to items referenced in
the kernel copy of vnode_if.c.  Now a kernel module is free to create
it's own VOP_FOO() routines and the rest of the system will happily
deal with it, including passthrough layers like union/umap/etc.

Have VFS_SET() call a common vfs_modevent() handler rather than
inline duplicating the common code all over the place.

Have VNODEOP_SET() have the vnodeops removed at unload time (assuming a
module) so that the vop_t ** vector is reclaimed.

Slightly adjust the vop_t ** vectors so that calling slot 0 is a panic
rather than a page fault.  This could happen if VOP_something() was called
without *any* handlers being present anywhere (including in vfs_default.c).
slot 1 becomes the default vector for the vnodeop table.

TODO: reclaim zones on unload (eg: nfs code)
1998-11-10 09:04:09 +00:00
Peter Wemm
edfbe15080 Arrange for unload-time linker set hooks to be called. While cut/pasting
some code, I changed the original to be consistant with the rest of the
file rather than duplicating the problems.
1998-11-10 08:49:28 +00:00
Peter Wemm
db66937855 Have MALLOC_DECLARE() initialize malloc types explicitly, and have them
removed at module unload (if in a module of course).
However; this introduces a new dependency on <sys/kernel.h> for things
that use MALLOC_DECLARE().  Bruce told me it is better to add sys/kernel.h
to the handful of files that need it rather than add an extra include to
sys/malloc.h for kernel compiles. Updates to follow in subsequent commits.
1998-11-10 08:46:24 +00:00
Don Lewis
643a8daaaf If the session leader dies, s_leader is set to NULL and getsid() may
dereference a NULL pointer, causing a panic.  Instead of following
s_leader to find the session id, store it in the session structure.

Jukka found the following info:

	BTW - I just found what I have been looking for. Std 1003.1
	Part 1: SYSTEM API [C LANGUAGE] section 2.2.2.80 states quite
	explicitly...

	Session lifetime: The period between when a session is created
	and the end of lifetime of all the process groups that remain
	as members of the session.

	So, this quite clearly tells that while there is any single
	process in any process group which is a member of the session,
	the session remains as an independent entity.

Reviewed by:	peter
Submitted by:	"Jukka A. Ukkonen" <jau@jau.tmt.tele.fi>
1998-11-09 15:08:04 +00:00
Nicolas Souchu
31a7daae9e Add semicolon to INTERFACE declaration. 1998-11-08 18:51:38 +00:00
Nicolas Souchu
7a8ecb9e64 Add semicolon to INTERFACE declarations 1998-11-08 18:35:53 +00:00
Nicolas Souchu
1864a32626 "Here is the most recent version of makedevops.pl. I've made the parsing
of the input file more strict and the error messages more elaborate.
Second, the output file has slightly improved looks when >80 character
lines are concerned (I needed a 80 character line formatter anyway for
work...)."

Submitted by: Nick Hibma <nick.hibma@jrc.it>
1998-11-08 18:33:11 +00:00
Doug Rabson
7095ee912b * Fix a couple of places in the device pager where an address was
truncated to 32 bits.
* Change the calling convention of the device mmap entry point to
  pass a vm_offset_t instead of an int for the offset allowing
  devices with a larger memory map than (1<<32) to be supported
  on the alpha (/dev/mem is one such).

These changes are required to allow the X server to mmap the various
I/O regions used for device port and memory access on the alpha.
1998-11-08 12:39:07 +00:00
David Greenman
bd81f199b5 Added support for non-blocking sockets to sendfile(2). 1998-11-06 19:16:30 +00:00
Peter Wemm
caab6e909e Don't put aggregate structs 4K large on the kernel stack, especially when
we can recurse when loading dependencies and that the kstack is limited
to something like 6 or 7KB.  Having a single dependency caused an instant
double panic, and I stronly suspect some of the other strange "events"
that I have seen are possibly as a result of taking a couple of interrupts
with a large chunk of the stack already in use.

While here, fix a minor logic hiccup in a sanity check.
1998-11-06 15:16:07 +00:00
Peter Wemm
21ce23eb91 Define the kld_debug variable if KLD_DEBUG is enabled 1998-11-06 15:10:17 +00:00
Peter Wemm
f9d919e98f put a \n on an error message printf 1998-11-06 02:18:57 +00:00
David Greenman
dd0b2081f4 Implemented zero-copy TCP/IP extensions via sendfile(2) - send a
file to a stream socket. sendfile(2) is similar to implementations in
HP-UX, Linux, and other systems, but the API is more extensive and
addresses many of the complaints that the Apache Group and others have
had with those other implementations. Thanks to Marc Slemko of the
Apache Group for helping me work out the best API for this.
Anyway, this has the "net" result of speeding up sends of files over
TCP/IP sockets by about 10X (that is to say, uses 1/10th of the CPU
cycles) when compared to a traditional read/write loop.
1998-11-05 14:28:26 +00:00
Bill Fenner
0931333f8d Fix sbcheck() to check all packets on socket buffer.
Also fix data types and printf formats while I'm here.

PR:	misc/8494

Panic instead of looping forever in sbflush().  If sb_mbcnt counts
more mbufs than sb_cc counts bytes, the original code can turn into an
infinite loop of removing 0 bytes from the socket buffer until it's empty.
1998-11-04 20:22:11 +00:00
Peter Wemm
84e40f5627 The handle for the kernel is common. With this fix, ELF kernels can load
a.out kld modules, and a.out kernels can load ELF kld modules.
1998-11-04 15:20:58 +00:00
Peter Wemm
ee9d248c5f General tidy up: remove more unused code, update comments, simplify some
routines a little.
1998-11-04 03:18:10 +00:00
Peter Wemm
02fc72dbe5 make mount(2) automatically kldload modules if the requested filesystem
isn't present.
1998-11-03 14:29:09 +00:00
Peter Wemm
7837745438 Have the in-kernel linker try a default extension of .ko. This means that
"kldload nfs" works.  We use the same default extension in the /boot/loader
system.
1998-11-03 14:27:05 +00:00
Peter Wemm
e91a7f30cf Initialize the a.out kld loader after elf, so that elf gets first shot at
a kldload attempt.
1998-11-03 14:25:21 +00:00
Peter Wemm
b913711e0c Use the kvm space pathname that we copied in, not the one in user space. 1998-11-03 13:09:31 +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
f3d6ee090e Only do one VOP_ACCESS() per open() instead of two. This should reduce
the NFSv3 ACCESS RPC problems a little for busy clients that do a lot of
open/close.  The nfs code could probably cache the results, but I'm not
sure whether this would be legal or useful.  The problem is that with
a CPU farm, on each open there would be a lookup, getattr then access RPC
then the read/write RPC activity.  Caching the access results probably
isn't going to help much if the clients access lots of files.  Having the
nfs_access() routine interpret the getattr results is a bit of a hack, but
it's how NFSv2 is done and it might be OK for a mount attribute for v3.
1998-11-02 02:36:16 +00:00