Commit Graph

1157 Commits

Author SHA1 Message Date
cgd acad90d846 * (slight) general cleanup
* change in-kernel syscall prototypes to match user-land prototypes in
  the following ways:
    + add 'const' where appropriate.
    + make the following "safe" type changes where appropriate:
	caddr_t -> struct msghdr *
	caddr_t -> struct sockaddr *
	caddr_t -> void *
	char * -> void *
	int -> uid_t (safe because uid_t not used as index/count)
	int -> gid_t (safe because gid_t not used as index/count)
	u_int -> size_t
    + change "int" to "u_long" in flags arguments to chflags() and
      fchflags().  This is safe because the arguments are used as
      flag bits and there's nothing that would cause the top bit
      of the int to be set yet, and because the user-land definitions
      already specified u_long, so a u_long's worth of argument was
      already being passed in.
1996-12-22 08:04:06 +00:00
cgd 997ec138ad change ntp_gettime's struct ntptimeval *'s name to match kern_ntptime.c 1996-12-22 07:47:43 +00:00
cgd c99936a735 * fix return types. previously, most things returned 'int.' which was
wrong for a bunch of functions:
	void:		sys_exit, sys_sync
	ssize_t:	sys_read, sys_write, sys_recvmsg, sys_sendmsg,
			sys_recvfrom, sys_readv, sys_writev, sys_sendto
	long:		sys_pathconf, sys_fpathconf
	void *:		sys_shmat

* Note that sys_open, sys_ioctl, and sys_fcntl are defined such that their
  last argument is optional.

These changes should not have any real effect, because right now this
information is not actually used for anything.
1996-12-22 07:00:57 +00:00
cgd 8fac03afc3 regen for syscalls.master and makesyscalls.sh changes 1996-12-22 06:48:18 +00:00
cgd 747448fc3e mark syscall() and __syscall() as INDIR syscalls 1996-12-22 06:46:50 +00:00
cgd 0e9ddb9039 * Don't actually output args structure definitions for INDIR syscalls (typo).
* Don't output prototypes for INDIR syscalls (since they always show up as
  sys_nosys() in the syscall table).
* Add "indir" to the comment for INDIR syscalls in the syscalls table, so
  it's more obvious why they call sys_nosys().
1996-12-22 06:45:14 +00:00
cgd ba32ea9a68 update copyright date 1996-12-22 06:33:46 +00:00
cgd 286395d1b3 * remember (i.e. don't throw away) system call return types.
* Deal with multi-word system call return types (i.e. foo *, or
  struct foo *, or struct foo, etc.).
* Add a new class of system calls "INDIR" (for "indirect"), which
  is to be used to represent indirect syscalls like syscall() and
  __syscall() which are implemented in MD code and which don't want
  args structures defined.  (The old way of declaring this type of
  syscalls still works.)
* Allow system calls to be marked as having a variable number of
  arguments, by inserting "..." (no trailing comma) before the
  first hf the optional arguments in the syscall definition.  Because
  of the way syscall arguments are handled by MI code, _ALL_ syscall
  arguments must actually be included in the definition, i.e.
  "optional" arguments are either "are there or aren't," i.e. these
  aren't really varargs functions.  Therefore, for normal syscalls,
  there _must_ be arguments listed after the "...".  For INDIR
  syscalls, which really do have a variable number of arguments and
  which aren't handled via the normal mechanism, that requirement is
  not in force.
* output primitive (machine-parsable) syscall descriptions as comments
  in <sys/syscall.h>.  These can be used to easily build real function
  prototypes, or to build stub functions for use by lint.
1996-12-22 06:33:16 +00:00
cgd e9a07759c9 ntp_gettime()'s argument is a struct ntptimeval *, not a struct timex * 1996-12-22 06:23:38 +00:00
gwr 6dba055937 Move `static' to the beginning of the storage class specifiers. 1996-12-18 20:24:50 +00:00
gwr e2c836939b As discussed, replace KERNBASE with kernel_text. 1996-12-18 20:12:58 +00:00
cgd 60faf5d2ae always provide at least a minimal aux vector. (The minimal version
is one entry long, with the entry's id being AUX_null.)
1996-12-17 22:04:20 +00:00
thorpej 2ac210b6e3 Call device_register() if __alpha__ || hp300 1996-12-17 08:59:15 +00:00
thorpej 8606b2f1d3 In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.
1996-12-09 23:50:57 +00:00
thorpej ff392f324b Back out this piece of revision 1.3:
>- Optional systems calls are "UNIMPL" if the support is not being
>  compiled into the kernel.

It had implications that didn't occurr to me at the time.  *sigh*
1996-12-06 20:10:51 +00:00
thorpej 5c4caca2d5 syscalls.master changed; regen. 1996-12-06 20:06:35 +00:00
thorpej 49989d779a Back out this piece of revision 1.38:
>- Optional systems calls are "UNIMPL" if the support is not being
>  compiled into the kernel.

It had implications that didn't occur to me at the time.  *sigh*
1996-12-06 20:05:31 +00:00
cgd 66764a1a2f Check for a new definition, __BROKEN_INDIRECT_CONFIG, and if it is _not_
defined:
	define match functions to take a struct cfdata * as their second
	argument, config_search() to take a struct cfdata * as its second
	argument, and config_{root,}search() to return struct cfdata *.

	remove 'cd_indirect' cfdriver element.

	remove config_scan().

	remove config_make_softc() as a seperate function, reintegrating
	its functionality into config_attach().

Ports will define __BROKEN_INDIRECT_CONFIG until their drivers prototypes
are updated to work with the new definitions, and until it is sure that
their indirect-config drivers do not assume that they have a softc
in their match routine.
1996-12-05 00:09:10 +00:00
thorpej 6aaaad08d2 syscalls.master changed; regen. 1996-12-03 00:30:59 +00:00
thorpej f85bef61f1 Include sys_getfh() if NFSSERVER || NFSCLIENT. 1996-12-03 00:28:31 +00:00
thorpej f02e8b3cf0 Make NFSSERVER work without NFSCLIENT. This is achieved by splitting
the client and server/shared data initialization into separate functions,
and calling the server/shared initialization directly from main().
Problem noted in PR #1308 (Kenneth Stailey) and PR #1780 (Chris Demetriou).
Fix suggested in PR #1780 by Chris Demetriou, and munged a bit by me,
and OK'd by Frank van der Linden <fvdl@netbsd.org>.
1996-12-03 00:22:43 +00:00
thorpej f8ae3272b9 Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.
1996-11-26 23:24:04 +00:00
cgd 3340f02c2b fix two problems with shutdown hook code:
(1) after removing a shutdown hook (in shutdownhook_disestablish()),
    free it.  We created it, we have to free it.  Without this,
    shutdownhook_disestablish() leaks memory.
(2) in doshutdownhooks(), before running each hook, remove it from the
    shutdown hook list.  This makes sure that every hook is tried once
    (because doshutdownhooks() is called from before rebooting, and
    a fault in a shutdown hook will cause doshutdownhooks() to be called
    again), but prevents the hooks from potentially being run infinitely
    (as used to be possible, in the above-mentioned situation).
1996-11-24 00:42:31 +00:00
fvdl ee489171ee Make previous change in interpreter entry point calculation dependant on
a 'mips' define. XXX

Just a temporary patch to get things going again for Linux ELF binaries,
needs to be solved properly.
1996-11-23 11:46:34 +00:00
cgd e77b6879f7 Feature:
If not compiled with -D_KERNEL, include different includes and
do so macro magic so that this will fit sanely into test harnesses.
When used in user-land, this should be compiled with -D_EXTENT_TESTING.

Bug fixes:
(extent_insert_and_optimize) You can't do things like:
	LIST_REMOVE(elem->...le_next, ...);
	free(elem->...le_next, ...);
They just don't work (and will corrupt your list and/or malloc free list).

(extent_alloc_region_descriptor) Unless you wait, malloc can fail.
Don't accidentally deref a potentially-NULL pointer.
1996-11-21 18:46:34 +00:00
cgd 9ed8ce3b8f clean up a few spaces vs. tabs and KNF bogons. Make this compile
cleanly with -Wall -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual.
1996-11-15 23:53:32 +00:00
cgd 30ca7eaa8d clean up a few spaces vs. tabs bogons 1996-11-15 23:51:23 +00:00
jtc d22cdecb45 Add clock_gettime, clock_settime, and clock_getres 1996-11-15 22:44:25 +00:00
thorpej 621d9e4932 Regen. 1996-11-14 04:52:30 +00:00
thorpej 9d9479eb2f Make ntp_gettime() and ntp_adjtime() like other system calls:
- The functions that implement them and the argument names are
  prepended with "sys_".
- Optional systems calls are "UNIMPL" if the support is not being
  compiled into the kernel.
1996-11-14 04:51:09 +00:00
thorpej 82b23eb20c Only call sysctl_ntptime() if NTP is compiled into the kernel. 1996-11-14 04:47:45 +00:00
thorpej 156e926117 Implement bitmask_snprintf(), which takes a value and a string
representing the names of those bits, prints them into a buffer
provided by the caller, and returns a pointer to that buffer.
Functionality is identical to that of the (non-standard) `%b' printf()
format, which will be deprecated.

Rename the non-exported function ksprintn() to ksnprintn(), and change
it to use a buffer provided by the caller, rather than at static
buffer.
1996-11-13 06:06:05 +00:00
jonathan bbcd2bb1ef Elf32 fixes for mips shared libraries:
* handle interpreters with nonzero virtual address of entry-point:
   subtract p_vaddr from computed entrypoint, as the mips elf exec did.

 * Add #ifdef ELF_INTERP_NON_RELOCATABLE/#endif around the code
   that tries to choose a `good' address at which to load an interpreter,
   if none was set by the emul probe  function.
   (the address chosen could be improved to avoid  fragmenting the
    process virtual address space).

 * define ELF_INTERP_NON_RELOCATABLE in machine/elf_machdep.h for mips CPUs,
   which currently use a GNU-derived ld.so.

ELF_INTERP_NON_RELOCATABLE is not necessary for native NetBSD/alpha ELF
binaries. It may be required for GNU-derived ELF dynamic loaders (Linux/i386?)
1996-11-11 20:33:10 +00:00
thorpej 26a25a87b2 Optimization of soqinsque() and soqremque():
Keep queue of pending sockets in a double linked list.  Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)
1996-11-10 05:58:37 +00:00
cgd 8a3333b2a9 Fix an inconsistency that came in with Lite: setrq() was renamed to
setrunqueue(), but remrq() was never renamed.  Rename remrq() to
remrunqueue().
1996-11-06 20:19:19 +00:00
gwr f5927ca260 Minor nit in my change regarding const and non-ansi code... 1996-10-27 21:50:33 +00:00
gwr 2ada6af51b Oops, part of that last commit was not meant to go in.
The definitions of va_alist, va_dcl belong elsewhere.
1996-10-27 20:50:00 +00:00
gwr a0d9bd5bb2 The hack-ish tricks to make the ANSI-style va_start macro work in
non-ANSI mode were not quite complete.  This makes non-ANSI work.
Perhaps it would be better to eliminate this hack altogether...
1996-10-27 20:30:52 +00:00
cgd ce53653783 make the namei struct members ni_dirp and ni_next, and the componentname
struct member cn_nameptr 'const', since they should never be used to
modify the path name.  (Only the pathname buffer, cn_pnbuf, should be
modified.)  Propagate the const poisoning to code that uses the namei
and componentname structs.
1996-10-25 23:13:58 +00:00
cgd 9fa0b6391e don't thow away char_type's 'const'ness via a cast when passing it to scanc().
(1) that causes -Wcast-qual to be unhappy, and (2) the cast is unnecessary!
1996-10-25 22:11:39 +00:00
cgd ca829ca73c don't assign non-const pointers from const pointers; make the appropriate
pointers 'const'.  (-Wcast-qual)
1996-10-25 22:01:44 +00:00
cgd ef6504281a remove duplicate prototypes from tty_subr.c (ndqb, putc, b_to_q), and
make the first arg of b_to_q (the u_char * that points to data to be
stuffed into the queue) const, since it's not modified.
1996-10-25 21:20:29 +00:00
cgd 574f71ab26 replace a construction in sys_setitimer() that was too tricky for its
(and my!) own good with a more straightforward one that is equally (and
more apparently) correct.
1996-10-24 04:35:33 +00:00
cgd 8595fc3073 make coredump() use more sensible error returns (even though they're
not used by anything, for now), and implement MNT_NOCOREDUMP by checking
whether or not MNT_NOCOREDUMP is set on the file system where the dump
would land (i.e. the file system of the process's current working
directory), and disallowing the core dump if it's set.
1996-10-23 23:13:19 +00:00
cgd 6d3337bdf6 permit MNT_NOCOREDUMP as a generic mount flag. 1996-10-23 23:07:08 +00:00
matthias a587cc60a0 * In dosetrlimit ensure that rlim_cur and rlim_max are >0. Otherwise
the kernel might crash due to invalid values passed to setrlimit.
1996-10-23 07:19:38 +00:00
jtc 4039b6bcba Return ESPIPE when filedes is associated with a FIFO. 1996-10-21 17:42:48 +00:00
mrg 8fd70c1fe1 in coredump(), check the SUGID bit rather than testing various parts
of the cred structures.  this prevents a previously set[gu]id process
from generating a core file.
1996-10-18 08:39:34 +00:00
perry 8a0600b163 removed #ifdef tahoe 1996-10-17 16:31:54 +00:00
thorpej 52c0d38a1a Several changes:
- Rename EX_NOBLOB to EX_NOCOALESCE; it's much more descriptive of
  what's going on.
- In extent_free_region_descriptor(), if we're a fixed extent,
  freeing a dynamically allocated region descriptor, and someone
  is waiting on the freelist, let the waiter have it, rather than
  free'ing it back to the system.
- Use ALIGN(), rather than our homegrown EXTENT_ALIGN(), when dealing
  with map overhead.  Privatize the EXTENT_ALIGN() macro; there's no need
  to export it.
- Implement EX_BOUNDZERO flag.  This changes the boundary line policy in
  extent_alloc() and extent_alloc_subregion(); boundary lines are
  computed relative to 0, rather then the start of the extent.
- Fix a nasty race between multiple participants doing region and
  descriptor allocation.
- Add a new flag to specify that it's ok to wait for space in the
  extent: EX_WAITSPACE.
- Blow away an unnecessary splhigh()/splx().
- Put a bunch of sanity code inside #ifdef DIAGNOSTIC/#endif.
1996-10-17 08:27:35 +00:00
ws 31bdb14ed5 Rename recently checked in KGDB to IPKDB to resolve conflicts with older KGDB 1996-10-16 19:32:08 +00:00
cgd c8e4c454f2 curproc was being used directly for ru_{in,ou}block counting. Instead
of using it directly, use a local, and set that local to be curproc
if curproc is not NULL else a pointer to process 0's proc struct.
If syncing disks while handling a panic that occurred while 'curproc'
was NULL, the old code would dereference NULL and die.
1996-10-15 23:06:27 +00:00
cgd 279c087328 reorganize tsleep() so the (cold || panicstr) test is done before the
ktrace context switch checking.  If syncing disks while handling a panic
that occurred while 'curproc' was NULL, the old code would dereference
NULL and die.  The (slight) reorganization was done so that space (one extra
splhigh()), rather than time (one extra comparison), would be wasted.
1996-10-15 23:00:10 +00:00
cgd 709ebdf6ab panic must print a newline 1996-10-15 21:35:56 +00:00
cgd 0e4ddf059b deal more sanely with ELF binaries with only a single program header
section.  Patch come up with by Bob Baron <rvb+@cs.cmu.edu> and myself.
This entire bit of code (the code which sets daddr/dsize and taddr/tsize)
is very bogus, but it's not clear what the 'right' way to fix it is
and this patch fixes a problem preventing some ELF executables from
being run.
1996-10-13 22:54:52 +00:00
christos f443b89c92 backout previous kprintf change 1996-10-13 02:32:29 +00:00
christos ee3d88fbdf fix uiomove's first argument and remove unnecessary casts 1996-10-13 02:27:52 +00:00
cgd 4431ea58a9 replace ELF_ALIGN with ELF_TRUNC (round to lower alignment boundary) and
ELF_ROUND (round to higher alignment boundary), and use them properly.
Also, change a bit of code in elf_load_psection to use the next ELF_ROUND
macro.  This fixes a bug found by Robert Baron <rvb+@cs.cmu.edu> where
elf_load_psection, if given a properly aligned address at which to load
the section, would round actually load it at the next highest alignment
boundary.
1996-10-11 19:44:02 +00:00
christos 60d201973e printf -> kprintf, sprintf -> ksprintf 1996-10-10 22:46:11 +00:00
christos 153ead2dff - Use debugging printf - macros instead if #ifdef #endif everywhere
- printf -> kprintf, sprintf -> ksprintf
1996-10-10 22:43:21 +00:00
thorpej 4a23efc7bc Fix botch in netbsd-1-2 merge (multiple inclusion of <sys/tty.h>),
pointed out by Jonathan Stone <jonathan@DSG.Standford.EDU>.
1996-10-10 00:27:41 +00:00
thorpej f2e79979ad Merge the netbsd-1-2 branch back into the mainline. 1996-10-09 00:59:15 +00:00
mycroft 02ee12e4ba Use PHOLD() and PRELE() rather than frobbing p_holdcnt directly. 1996-10-09 00:04:39 +00:00
cgd 1878cacd45 KNF, de-static the functions that were static (so they'll show up
in ddb, etc.)
1996-10-08 03:40:40 +00:00
cgd 6ab18a1959 don't include <machine/exec.h> explicitly. No other changes needed, since
<sys/exec.h> was already being included.
1996-10-07 21:43:02 +00:00
cgd cd3ab82ec2 clean up a comment added in the last commit 1996-10-07 18:29:24 +00:00
cgd 5d4cf83257 when loading interpreter: check its vnode type, check its mount point
for NOEXEC and NOSUID, and make sure the interpreter file is executable.
The mount point checks are done because, even though the interpreter
is not the program being 'executed', code from the interpreter is being
executed, and so the mount point's flags should be respected.
1996-10-07 18:24:48 +00:00
scottr d2be4a69c2 Expand tab in copyright message; it loses on some consoles. 1996-10-05 06:32:43 +00:00
ws 2da166f660 Fix p_nice vs. NZERO code.
Change NZERO to 20 to always make p_nice positive.
On Christos' suggestion make p_nice explicitly u_char.
1996-10-02 18:04:56 +00:00
cgd cc06b3f10f Remove the implicit inclusion of EXEC_ELF32 when COMPAT_LINUX and/or
COMPAT_SVR4 is included.
1996-10-02 05:30:29 +00:00
cgd ccd26363f6 allow a.out executable support to be optional (conditioned on EXEC_AOUT),
and shell script support to be optional (conditioned on EXEC_SCRIPT).
Remove the implicit inclusion of EXEC_ECOFF when COMPAT_OSF1 and/or
COMPAT_ULTRIX is included, and of EXEC_ELF32 when COMPAT_LINUX and/or
COMPAT_SVR4 is included.
1996-10-02 05:29:29 +00:00
cgd 60b9a20b61 initialize vnode_free_list and mountlist at compile time with the new
queue.h list/queue head initializer macros.  mountlist was converted so
that panics (or other reboots) early on in kernel startup don't cause
sys_sync() to croak.  vnode_free_list was converted because it was nearby.
1996-10-01 22:49:11 +00:00
cgd 3b34cba879 exec vnode locking protocol changes: in a nutshell, don't keep vnodes
locked for any longer than we have to.
1996-09-30 23:18:43 +00:00
cgd 6f5b5cefc7 make the check_header and load_file functions static 1996-09-30 23:02:14 +00:00
ws 0d59d2eb20 Enter new KGDB on panic just like other kernel debuggers 1996-09-30 17:32:01 +00:00
cgd fea9aa2096 clean up a comment (in code derived from the a.out code, where i cleaned
up the comment earlier).
1996-09-27 03:38:27 +00:00
cgd 2f42e5b8ed fix some typos and clean up some comments. 1996-09-26 23:34:46 +00:00
cgd 0e097578a2 add and use a machine-dependent header, which currently defines some
macros to use to remove #ifdefs from the machine ID case check.
Eventually, these headers will contain other information, e.g.
machine-dependent relocation information, etc.
1996-09-26 21:50:55 +00:00
cgd 79bd41b179 add support and reorganize for 64-bit ELF, included by EXEC_ELF64
option.  (Also, make EXEC_ELF32 option a way to explicitly include
32-bit ELF support.)
1996-09-26 20:51:03 +00:00
christos 3f15a06497 Recognize %.2x as %02x 1996-09-25 21:03:06 +00:00
cgd 80c82b8766 rename exec_elf.c to exec_elf32.c, since it execs 32-bit ELF. exec_elf32.c
was copied from exec_elf.c on the CVS server to keep the logs intact.
1996-09-20 22:33:23 +00:00
jtc 16fe807b60 renamed sys_getlogin to sys___getlogin. required by libc namespace conventions 1996-09-19 04:52:12 +00:00
thorpej 0d3a57ea3f Add COMPAT_M68K4K to the exec switch. 1996-09-10 22:05:03 +00:00
mycroft 7cbc74f45c Use INFTIM, not -1. 1996-09-07 21:47:23 +00:00
mycroft 1449e67e30 Modify poll(2) prototype. 1996-09-07 14:20:09 +00:00
mycroft 07d2eae876 Regen. 1996-09-07 14:18:04 +00:00
mycroft cdd2b02b50 Modify poll(2) prototype. 1996-09-07 14:16:42 +00:00
mycroft 264dd4757c Regen. 1996-09-07 12:56:49 +00:00
mycroft 2bc736661a Implement poll(2). 1996-09-07 12:40:22 +00:00
mycroft 59f71c45fc Clean up sys_select() slightly. 1996-09-05 15:32:52 +00:00
mycroft af113f915d Use SET(), CLR(), ISSET(). 1996-09-05 15:31:40 +00:00
mycroft b3eac79b64 tty stop functions really should return void, not int, and certainly not both. 1996-09-02 06:43:16 +00:00
christos da17295d91 Calling shmdt(2) before calling shmat(2) would crash the system because
p->p_vmspace->vm_shm would be NULL. Protected the rest of the cases where
that might happen too. This was the reason why sunxdoom would panic the
system in SVR4 emulation.
1996-09-01 22:53:06 +00:00
mycroft de1c962824 Don't core dump if ruid != euid or rgid != egid. 1996-09-01 01:56:10 +00:00
cgd f8ed933394 implement realloc(), just like the user-land version, except it takes
"type" and "flags" arguments a la kernel malloc().
1996-08-27 20:01:42 +00:00
cgd d7083cda8d update so that SYSCALL_DEBUG works again. s/nosys/sys_nosys/g.
(It must not have been used for a long time!)
1996-08-20 22:00:36 +00:00
explorer a9ef8aef84 This fixes a nasty little bug where traceroute (and other raw-ip sending
programs which attach their own header) can crash the machine.  The problem
in this case was:
	a variable "space" was set to the total data to copy,
	len was used to remember how much to copy in this chunk (mbuf),
	in one case, len = min(MCLBYTES - max_hdr, resid) but
		size -= MCLBYTES;
	 instead of
		size -= len;

Note that userland programs can still crash the machine by providing
bogus data in the ip->ip_len field I suspect.  I haven't verified this,
but will soon be doing so and applying a fix of some sort.  Probably
clamping the ip->ip_len value to the true packet size will be ok.
1996-08-14 05:53:18 +00:00
explorer 1177a1fc69 formatting fix only 1996-08-14 05:43:35 +00:00
explorer 13659c5c84 spelling error only 1996-08-14 05:43:19 +00:00
thorpej d719cb7901 Inside some DIAGNOSTIC code, cast some pointer arithmetic results
to long to quiet the compiler.
1996-08-13 23:25:10 +00:00