Commit Graph

469 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
886a6f6fca Add /proc/<pid>/status and /proc/<pid>/stat (the latter being mostly
zeroes for the time being).

Prompted by:	Nathan Boeger <nathan@khmere.com>
2000-10-25 22:12:59 +00:00
Andrew Gallatin
242fae60f0 Some linux apps, such as IBM's JDK 1.3, will attempt to mmap thread
stacks near the top of their address space.  If their TOS is greater
than vm_maxsaddr, vm_map_growstack() will confuse the thread stack
with the process stack and deliver a SEGV if they attempt to grow the
thread stack past their current stacksize rlimit.  To avoid this,
adjust vm_maxsaddr upwards to reflect the current stacksize rlimit
rather than the maximum possible stacksize.  It would be better to
adjust the mmap'ed region, but some apps (again, IBM's JDK 1.3) do not
check mmap's return value..

This commit (in conjunction with setting MINSIGSTKSZ to 2048 &
rebuilding your kernel and modules) will get IBM's JDK 1.3 working
with FreeBSD at least well enough to run many of the example applets.

Reviewed by: marcel
Tested by:   sto@stat.duke.edu, many others on freebsd-java@
2000-10-17 00:25:43 +00:00
Andrew Gallatin
21b0b22ce3 regen after addition of linux_rt_sigreturn 2000-10-17 00:03:02 +00:00
Andrew Gallatin
7936339495 A start at an implemention of linux_rt_sendsig & linux_rt_sigreturn
and associated user-level signal trampoline glue.

Without this patch, an SA_SIGINFO style handler can be installed by a linux
app, but if the handler accesses its sip argument, it will get a garbage
pointer and likely segfault.

We currently supply a valid pointer, but its contents are mainly
garbage.  Filling this in properly is future work.

This is the second of 3 commits that will get IBM's JDK 1.3 working with
FreeBSD ...
2000-10-17 00:00:20 +00:00
Andrew Gallatin
931a725809 This is the first of 3 commits that will get IBM's JDK 1.3 working
with FreeBSD (not including the MINSIGSTKSZ issue, which belongs to
Marcel).  Due to time constraints, I'm going to space them out over a
few days.

This fixes two problems with linux_sigaltstack()

o ss == 0 is perfectly valid use, so do not fail in this case.

o Fix flag handling:
 - Our SS_DISABLE is 4, linux's is 2, so we need conversion routines.
	These conversion routines will be needed by linux_rt_sendsig()
	and linux_rt_sigreturn (forthcoming), so they are not static.
 - Linux's flag 0 historically meant SS_ONSTACK according to a comment
	in their linux/kernel/signal.c file.

Among other things, this fixes a warning from Sun's JDK 1.3:
"Java HotSpot(TM) Client VM warning: cannot uninstall alt signal stack"

Reviewed by: marcel
Tested by:   sto@stat.duke.edu, many others on freebsd-java@
2000-10-13 01:57:43 +00:00
Dag-Erling Smørgrav
e57416dc56 Mark directories as directories, not as regular files. 2000-10-10 12:32:44 +00:00
Dag-Erling Smørgrav
cd595ef506 Fix cut'n'paste bogon.
Submitted by:	Jim Pirzyk <Jim.Pirzyk@disney.com>
2000-09-18 17:46:01 +00:00
Dag-Erling Smørgrav
fecfecfbd0 Remove unused variables. 2000-09-09 14:35:35 +00:00
Dag-Erling Smørgrav
ddc0b9925d Add stat, uptime and version.
Note that version currently returns the first line of the version string
from vers.c, which is not quite what a Linux system would return.
2000-09-09 11:44:58 +00:00
Dag-Erling Smørgrav
81dc16f619 Pierre Beyssac originally derived linprocfs from procfs, and I've made (and
will keep making) significant modifications, so I'm adding both our copyrights
to the top of these files.
2000-09-07 16:44:26 +00:00
Marcel Moolenaar
dee4ec33cf When sigaltstack is called with a stack size that's not smaller
than LINUX_MINSIGSTKSZ but smaller than MINSIGSTKSZ, cheat and
pass MINSIGSTKSZ to the kernel. This is a workaround.

Submitted through: nate
2000-09-06 06:08:54 +00:00
Dag-Erling Smørgrav
9acf7ab9bc Remove obsolete comment (see rev 1.84 of procfs_vnops.c) 2000-09-04 18:19:04 +00:00
Robert Watson
c0ea0959b8 o Synchronize linprocfs authorization with procfs authorization improvements
(better hiding of hidden processes, more access checks, use vaccess(), et
  al)

Approved by:	des
Obtained from:	TrustedBSD Project
2000-09-01 18:40:52 +00:00
Robert Watson
9cd5f4c13b o Update linprocfs to include similar changes as those in procfs, fixing
the build (oops!): replace calls to p_trespass() and PRISON_CHECK()
  with p_can(..., {P_CAN_SEE, P_CAN_DEBUG}, NULL)
o Remove volatile usage from procfs_readdir() to remove warnings
o Apply bp's CREATE fix to linprocfs, causing EROFS to be returned on
  CREATE calls to procfs_lookup()
o Some further synchronization still needs to occur: only existing
  access checks were replaced, to fix the build--the new ones were not
  added.  I'll do this later today, this is a "fix the build quickly"
  commit.  This means that, in the interim, some information leakage
  can still occur via linprocfs when using jail or kern.ps_showallprocs

Submitted by:	knu
Approved by:	des
Obtained from:	TrustedBSD Project
2000-08-30 13:23:19 +00:00
Marcel Moolenaar
bc34729c47 Fix typo in license. 2000-08-25 07:32:24 +00:00
Marcel Moolenaar
3ed7f6a56f Finish the Linuxulator MD/MI split.
In summary:
o  This file has been moved to sys/compat/linux,
o  Any MD syscalls in this file are moved to
   linux_machdep.c in sys/i386/linux,
o  Include directives, makefiles and config files
   have been updated.
2000-08-22 07:08:33 +00:00
Marcel Moolenaar
322bfdc330 Update include directives for Linuxulator headers after the
MD/MI split.
2000-08-22 05:57:55 +00:00
Marcel Moolenaar
146aad745b Collect the MD syscalls from /sys/compat/linux here. Since this
is a new file, fix most of the style bugs at the same time.
2000-08-22 02:24:02 +00:00
Bruce Evans
c6e4d7c5ba Fixed null pointer panic for accessing "meminfo" when there is no swap. 2000-08-12 21:08:42 +00:00
Peter Wemm
3a285cc807 Regen. (Fix SYS_exit) 2000-07-29 10:07:38 +00:00
Peter Wemm
4e0f152bbe Sigh. Fix SYS_exit problems. I misunderstood the significance of these
trailing options.
2000-07-29 10:05:25 +00:00
Peter Wemm
69065e880a Regenerate with makesyscalls.sh 2000-07-29 00:21:50 +00:00
Peter Wemm
ac2b067b9a Change the 'exit()' system call to 'sys_exit()'. This avoids overlapping
gcc's internal exit() prototypes and the (futile) hackery that we did to
try and avoid warnings.  main() was renamed for similar reasons.
Remove an exit related hack from makesyscalls.sh.
2000-07-29 00:16:28 +00:00
Marcel Moolenaar
4c02bded00 Remove the only use of SCARG and perform dead code elimination. 2000-07-27 01:22:24 +00:00
Marcel Moolenaar
03567510a8 Add bounds checking to stackgap_alloc. Previously it was possible
to construct a path that was long enough (ie longer than
SPARE_USRSPACE bytes) and trash the stack.

Note that SPARE_USRSPACE is much smaller than MAXPATHLEN so that
the Linuxulator will now return ENAMETOOLONG even if the path
is smaller than MAXPATHLEN.

PR: 12749
2000-07-23 16:54:18 +00:00
Marcel Moolenaar
a603fe5a07 Revert implementation of setfsuid and setfsgid due to security
issues.

Requested by: rwatson
Backed by: kris
2000-07-20 05:37:41 +00:00
Marcel Moolenaar
d5124417a7 Implement pread and pwrite.
PR: 17991
Submitted by: Geoffrey Speicher <geoff@caribbean.sea-incorporated.com>
2000-07-17 00:17:07 +00:00
Marcel Moolenaar
6037da7d24 Add prototypes for linux_pread and linux_pwrite.
PR: 17991
Submitted by: Geoffrey Speicher <geoff@caribbean.sea-incorporated.com>
2000-07-17 00:13:38 +00:00
Marcel Moolenaar
ddb48608ab Implement setfsuid and setfsgid. Implementation derived from patch
in PR.

PR: 16993
Submitted by: Bjoern Groenvall <bg@sics.se>
2000-07-16 21:23:34 +00:00
Marcel Moolenaar
fbdf894562 Simplify the F_GETOWN and F_SETOWN fcntl commands. The workaround
is not needed since the FreeBSD native implementation switched
from TIOC{G|S}PGRP to FIO{G|S}ETOWN (kern_descrip.c rev 1.55).

PR: 16946
Submitted by: Victor Salaman <salaman@teknos.com>
2000-07-15 22:33:24 +00:00
Poul-Henning Kamp
77978ab8bc Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.
Pointed out by:	bde
2000-07-04 11:25:35 +00:00
Poul-Henning Kamp
82d9ae4e32 Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:
Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our
sources:

        -sysctl_vm_zone SYSCTL_HANDLER_ARGS
        +sysctl_vm_zone (SYSCTL_HANDLER_ARGS)
2000-07-03 09:35:31 +00:00
Martin Cracauer
6f6b2cd019 Linux allows to mmap annonymous with a file descriptor passed, FreeBSD
doesn't.  In the Linux emulation layer, ignore the fd passed when
MAP_ANON is specified.

Known application to be fixed: Xanalys/Harlequin Lispworks

Also improve debug output for mmap, now showing what the emulation
layer mapped to what (-DDEBUG).

Reviewed by:	marcel
2000-06-15 09:57:34 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Dag-Erling Smørgrav
ce4e34c875 Make exe a symlink. 2000-05-24 07:37:02 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
David E. O'Brien
589607c435 AT&T asm syntax requires a leading '*' in front of the operand for indirect
calls and jumps.
2000-05-10 01:21:15 +00:00
Bruce Evans
9114579d7a Regenerated (fixed the calculation of sy_nargs in sysent tables). 2000-05-09 21:52:02 +00:00
Bruce Evans
29270d20bc Fixed the return type for exit() and the args struct tag several NOPROTO
syscalls including exit().  These entries were unused, so the bugs had no
effect, but the the args struct tag will be used to calculate sy_nargs
correctly.  exit() was wrong in all emulators.
2000-05-09 18:23:16 +00:00
Peter Wemm
1d91482db9 Add a version tag for the rtc port to depend on. 2000-05-06 01:36:04 +00:00
Poul-Henning Kamp
2c9b67a8df Remove unneeded #include <vm/vm_zone.h>
Generated by:	src/tools/tools/kerninclude
2000-04-30 18:52:11 +00:00
Matthew Dillon
d323ddf317 Fix #! script exec under linux emulation. If a script is exec'd from a
program running under linux emulation, the script binary is checked for
    in /compat/linux first.  Without this patch the wrong script binary
    (i.e. the FreeBSD binary) will be run instead of the linux binary.
    For example, #!/bin/sh, thus breaking out of linux compatibility mode.

    This solves a number of problems people have had installing linux
    software on FreeBSD boxes.
2000-04-26 20:58:40 +00:00
Mike Smith
ce0cdebef3 Fix include paths so that this builds correctly.
Submitted by:	Mike Pritchard <mpp@mppsystems.com>
2000-04-21 05:54:11 +00:00
Mike Smith
06ab4b95d8 Move the linprocfs bits under the rest of the i386 linux compatibility
code.
2000-04-20 03:54:27 +00:00
Poul-Henning Kamp
ed6aff7387 Remove unneeded <sys/buf.h> includes.
Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks
by 924 bytes.
2000-04-18 15:15:39 +00:00
David E. O'Brien
c815a20cb2 Change our ELF binary branding to something more acceptable to the Binutils
maintainers.

After we established our branding method of writing upto 8 characters of
the OS name into the ELF header in the padding; the Binutils maintainers
and/or SCO (as USL) decided that instead the ELF header should grow two new
fields -- EI_OSABI and EI_ABIVERSION.  Each of these are an 8-bit unsigned
integer.  SCO has assigned official values for the EI_OSABI field.  In
addition to this, the Binutils maintainers and NetBSD decided that a better
ELF branding method was to include ABI information in a ".note" ELF
section.

With this set of changes, we will now create ELF binaries branded using
both "official" methods.  Due to the complexity of adding a section to a
binary, binaries branded with ``brandelf'' will only brand using the
EI_OSABI method.  Also due to the complexity of pulling a section out of an
ELF file vs. poking around in the ELF header, our image activator only
looks at the EI_OSABI header field.

Note that a new kernel can still properly load old binaries except for
Linux static binaries branded in our old method.

  *
  * For a short period of time, ``ld'' will also brand ELF binaries
  * using our old method.  This is so people can still use kernel.old
  * with a new world.  This support will be removed before 5.0-RELEASE,
  * and may not last anywhere upto the actual release.  My expiration
  * time for this is about 6mo.
  *
2000-04-18 02:39:26 +00:00
Nick Sayer
c36837a8d8 Fix some style bugs. The long line is in a chunk of code that's
being rewritten, though.

Submitted by:	bde
2000-03-13 15:27:19 +00:00
Marcel Moolenaar
3c1124cfdf Fix bug in linux_wait4 and linux_waitpid where garbage in the status
argument could panic the kernel.

Submitted by: Ian Dowse <iedowse@maths.tcd.ie>
Prompted by: jkh, gallatin
Approved by: prompters
2000-03-09 17:52:01 +00:00
Nick Sayer
9deb82d478 Implement Linux BLKGETSIZE ioctl, and open the door to implementing
other BLK.* ioctls should the desire arize.

Approved by:	jkh (via dufault)
2000-03-09 15:14:14 +00:00
Marcel Moolenaar
dba5ab6662 Fix accept(2) behavior in that accepted sockets don't inherit the
parents flags.

Note on the PR:
The PR contains another patch that's not being committed without
further background information. The PR stays open for now.

PR: 16946 (Victor A. Salaman <salaman@teknos.com>)
Prompted by: msmith
Indirect/implicit approval: jkh (shoot me if I'm wrong :-)
2000-02-28 18:58:59 +00:00
Nick Sayer
651e921455 Avoid passing an uninitialized structure member to the real
READSUBCHANNEL ioctl. This makes vmware work with SCSI CDROM
drives.

Approved by:	jkh
2000-02-01 16:20:24 +00:00
Peter Wemm
edfd254255 Regen after pointing to the real setres[ug]id(). Remove dummy function.
(Note: getres[ug]id is still a dummy as it returns via pointers to a
 different sized integer and does need real wrappers.)
2000-01-29 12:45:36 +00:00
Peter Wemm
11247956d8 Use the real setres[ug]id(2) rather than dummy stubs. Newer glibc's
call this.
2000-01-29 12:43:29 +00:00
Marcel Moolenaar
0484ef81d9 Update syscalls to Linux kernel 2.3.38. These syscalls are
implemented as dummies to ease problem solving.
2000-01-10 22:19:06 +00:00
Marcel Moolenaar
20ebea30eb Update the syscalls to Linux kernel 2.3.38. 2000-01-10 22:16:35 +00:00
Marcel Moolenaar
759eb4613e Return Linux kernel version 2.2.12 by default. This is in line
with linux_base-6.1.
2000-01-10 13:09:08 +00:00
Marcel Moolenaar
dca60efcc9 Convert the filesystem type returned in struct statfs by syscalls
linux_statfs and linux_fstatfs. Linux binaries testing this expect
the filesystem's magic number and not our vnode's tag.

PR: 15425
Tested by: Vladimir N. Silyaev <vsilyaev@mindspring.com>
2000-01-08 21:09:41 +00:00
Bruce Evans
7eed718873 Include <stddef.h> here so that <sys/assym.h> can be unpolluted.
Include <sys/param.h> before <sys/assym.h> in case any of the magic
in the former is ever needed in the latter.
2000-01-08 19:53:18 +00:00
Marcel Moolenaar
e8c295abe6 Make offsetof equivalent with <stddef.h>. This paves the way for
further enhancements/reorganisations.

Discussed with: bde
2000-01-03 16:49:39 +00:00
Bruce Evans
654f6be1c8 Changed the type used to represent the user stack pointer from `long *'
to `register_t *'.  This fixes bugs like misplacement of argc and argv
on the user stack on i386's with 64-bit longs.  We still use longs to
represent "words" like argc and argv, and assume that they are on the
stack (and that there is stack).  The suword() and fuword() families
should also use register_t.
1999-12-27 10:42:55 +00:00
Marcel Moolenaar
00d6d49adc Use genassym(1) and <sys/assym.h> to generate assembler symbols. 1999-12-23 19:59:47 +00:00
Eivind Eklund
762e6b856c Introduce NDFREE (and remove VOP_ABORTOP) 1999-12-15 23:02:35 +00:00
Marcel Moolenaar
af3a75ec0d Remove unused includes.
Found by: phk-scan
1999-12-10 12:36:20 +00:00
Archie Cobbs
7ec7564af4 Fix LINT breakage. 1999-12-05 18:49:09 +00:00
Marcel Moolenaar
43bef51567 Implement pluggable ioctl handlers.
Other modules can register and unregister ioctl handlers to extend the
ioctls known by the Linuxulator. A recent application is the vmware
port. The Linuxulator itself uses the new interface to register its
handlers as well. Handlers for the following types of ioctls have been
defined:
	cdrom
	console (=keyboard and VT handling)
	socket
	sound
	termio

All ioctl related defines and declarations have been moved to a new
file (linux_ioctl.h), except for the pluggable ioctl handler interface
definition.

While there, cleanup linux.h some more.

linux.h and linux_ioctl.[ch] have been made to conform to style(9) as
much as possible.

Inspired and reviewed by: Vladimir N. Silyaev
1999-12-04 11:10:22 +00:00
Marcel Moolenaar
ec99e32256 Implement linux_sigaltstack. 1999-11-30 15:02:28 +00:00
Marcel Moolenaar
56d6dc1d34 Implement sigaltstack. 1999-11-30 15:00:17 +00:00
Alfred Perlstein
fac9a03b4e add linuxulator wrapper for SNDCTL_DSP_GETODELAY 1999-11-29 23:03:34 +00:00
Marcel Moolenaar
408da11907 Implement linux_ustat.
Reviewed by: bde
1999-11-27 16:55:14 +00:00
Marcel Moolenaar
c48ba18b4a Change prototype of linux_ustat. 1999-11-27 16:50:54 +00:00
Marcel Moolenaar
25e5bdab9e Implement fdatasync in terms of fsync. The regeneration of proto.h,
syscall.h and sysent.h was probably forgotten after the last change
syscalls.master.
1999-11-26 10:20:10 +00:00
Poul-Henning Kamp
3e30338edd simplify check for device. 1999-11-08 09:59:17 +00:00
Peter Wemm
53c2c4e22b Use fo_stat() rather than Yet Another duplication of kern_descrip.c's stat
code.
1999-11-08 03:33:21 +00:00
Poul-Henning Kamp
02c58685a4 Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for the
"rw" argument, rather than hijacking B_{READ|WRITE}.

Fix two bugs (physio & cam) resulting by the confusion caused by this.

Submitted by:   Tor.Egge@fast.no
Reviewed by:    alc, ken (partly)
1999-10-30 06:32:05 +00:00
Poul-Henning Kamp
923502ff91 useracc() the prequel:
Merge the contents (less some trivial bordering the silly comments)
of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>.  This puts
the #defines for the vm_inherit_t and vm_prot_t types next to their
typedefs.

This paves the road for the commit to follow shortly: change
useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE}
as argument.
1999-10-29 18:09:36 +00:00
Marcel Moolenaar
5a02dbe45a Fix the duplicate filenames that are the result of using getdents.
glibc2 defines struct dirent differently than the Linux kernel does.
The getdents function therefore needs to read a heuristically defined
number of kernel dirents to satisfy the request. In case where too
many kernel dirents have been read, the function lseeks on the
directory so that a next call will start with the right dirent. The
offset used in lseeking is the offset-field in the last dirent passed
to the application. This can only mean that the offset-field holds
the offset of the next dirent and not the offset of the dirent itself.
1999-10-21 09:14:49 +00:00
Luoqi Chen
645682fd40 Add a per-signal flag to mark handlers registered with osigaction, so we
can provide the correct context to each signal handler.

Fix broken sigsuspend(): don't use p_oldsigmask as a flag, use SAS_OLDMASK
as we did before the linuxthreads support merge (submitted by bde).

Move ps_sigstk from to p_sigacts to the main proc structure since signal
stack should not be shared among threads.

Move SAS_OLDMASK and SAS_ALTSTACK flags from sigacts::ps_flags to proc::p_flag.
Move PS_NOCLDSTOP and PS_NOCLDWAIT flags from proc::p_flag to procsig::ps_flag.

Reviewed by:	marcel, jdp, bde
1999-10-11 20:33:17 +00:00
John Hay
5cdfd8f709 Swap IOC_OUT and IOC_IN for the SETDIR macro. The linux ioctl read and
write bits are swapped.

Reviewed by:	luoqi, marcel
1999-10-06 19:51:37 +00:00
Marcel Moolenaar
956d3333ca sigset_t change (part 4 of 5)
-----------------------------

The compatibility code and/or emulators have been updated:

iBCS2 now mostly uses the older syscalls. SVR4 now properly
handles all signals. This has been achieved by using the
new sigset_t throughout the emulator. The Linuxulator has
been severely updated. Internally the new Linux sigset_t is
made the default. These are then mapped to and from the
new FreeBSD sigset_t.

Also, rt_sigsuspend has been implemented in the Linuxulator.
Implementing this syscall basicly caused all this sigset_t
changing in the first place and the syscall has been used
throughout the change as a means for testing. It basicly is
too much work to undo the implementation so that it can
later be added again.

A special note on the use of sv_sigtbl and sv_sigsize in
struct sysentvec:
Every signal larger than sv_sigsize is not translated and is
passed on to the signal handler unmodified. Signals in the
range 1 upto and including sv_sigsize are translated.
The rationale is that only the system defined signals need to
be translated.

The emulators also have been updated so that the translation
tables are only indexed for valid (system defined) signals.
This change also fixes the translation bug already in the
SVR4 emulator.
1999-09-29 15:12:18 +00:00
Poul-Henning Kamp
ae8e1d08d7 This patch clears the way for removing a number of tty related
fields in struct cdevsw:

        d_stop          moved to struct tty.
        d_reset         already unused.
        d_devtotty      linkage now provided by dev_t->si_tty.

These fields will be removed from struct cdevsw together with
d_params and d_maxio Real Soon Now.

The changes in this patch consist of:

        initialize dev->si_tty in *_open()
        initialize tty->t_stop
        remove devtotty functions
        rename ttpoll to ttypoll
        a few adjustments to these changes in the generic code
        a bump of __FreeBSD_version
        add a couple of FreeBSD tags
1999-09-25 16:21:39 +00:00
Marcel Moolenaar
1beb0dc732 Linux doesn't complain if you remove a msg queue that doesn't exist
(given the proper permissions).
1999-09-23 09:57:45 +00:00
Luoqi Chen
f581b15f47 Regeneration. 1999-09-22 22:05:37 +00:00
Luoqi Chen
2323686abc Implement linux_ioperm() syscall. Fix linux_iopl() to use the level argument.
SVGAlib should now work.

Reviewed by:	marcel
1999-09-22 22:01:51 +00:00
Brian Feldman
13ccadd4b0 This is what was "fdfix2.patch," a fix for fd sharing. It's pretty
far-reaching in fd-land, so you'll want to consult the code for
changes.  The biggest change is that now, you don't use
	fp->f_ops->fo_foo(fp, bar)
but instead
	fo_foo(fp, bar),
which increments and decrements the fp refcount upon entry and exit.
Two new calls, fhold() and fdrop(), are provided.  Each does what it
seems like it should, and if fdrop() brings the refcount to zero, the
fd is freed as well.

Thanks to peter ("to hell with it, it looks ok to me.") for his review.
Thanks to msmith for keeping me from putting locks everywhere :)

Reviewed by:	peter
1999-09-19 17:00:25 +00:00
Marcel Moolenaar
13d9e61a67 Fix getcwd. It must return the length of the path including the terminating 0.
While I'm here, fix style and debug printf.

Fix derived from patch by: Darryl Okahata <darrylo@sr.hp.com>
1999-09-17 08:35:08 +00:00
Peter Wemm
5a90d999a9 <machine/soundcard.h> -> <sys/soundcard.h>, since it's an exported API
that's arch neutral and OSS API and Linux API compatable.
1999-09-04 14:15:26 +00:00
Marcel Moolenaar
6771d80337 I missed the namechange of field desc in struct i386_ldt_args into descs while
reviewing luoqi's changes...

Pointed out by: luoqi
1999-09-03 06:18:39 +00:00
Marcel Moolenaar
ff78e85043 Implementation of the modify_ldt syscall. Use the sysarch() interface to do
the actual work. When USER_LDT is not defined for a kernel, sysarch returns
EOPNOTSUPP. Display a message in that case and return ENOSYS to userland.

Reviewed by: luoqi
1999-09-02 21:50:42 +00:00
Marcel Moolenaar
e459b442df Fix a braino: Linux minor device numbers are 8 bits wide and not 10. 1999-08-29 11:47:01 +00:00
Marcel Moolenaar
d4c45842d7 Fix a missing '-1' in the size argument of copyout in getgroups. Spotted while
reviewing the MFC in -stable.
1999-08-29 08:52:38 +00:00
Marcel Moolenaar
86f95e6b6d Implement the OSS_GETVERSION ioctl. The version returned can be changed through
the sysctl variable `compat.linux.oss_version'.

PR: 12917
Originator: Dean Lombardo <dlombardo@excite.com>
1999-08-28 08:43:03 +00:00
Peter Wemm
2185977908 Regen after Id->FreeBSD 1999-08-28 02:35:56 +00:00
Peter Wemm
280652828b $Id$ -> $FreeBSD$ 1999-08-28 02:16:32 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Marcel Moolenaar
c6dfea0ebd Add sysctl variables for the Linuxulator. These reside under `compat.linux' as
discussed on current.

The following variables are defined (for now):

    osname (defaults to "Linux")
        Allow users to change the name of the OS as returned by uname(2),
        specially added for all those Linux Netscape users and statistics
        maniacs :-) We now have what we all wanted!

    osrelease (defaults to "2.2.5")
        Allow users to change the version of the OS as returned by uname(2).
        Since -current supports glibc2.1 now, change the default to 2.2.5
        (was 2.0.36).

    oss_version (defaults to 198144 [0x030600])
        This one will be used by the OSS_GETVERSION ioctl (PR 12917) which I
        can commit now that we have the MIB. The default version number is the
        lowest version possible with the current 'encoding'.

A note about imprisoned processes (see jail(2)):
  These variables are copy-on-write (as suggested by phk). This means that
  imprisoned processes will use the system wide value unless it is written/set
  by the process. From that moment on, a copy local to the prison will be
  used.

A note about the implementation:
  I choose to add a single pointer to struct prison, because I didn't like the
  idea of changing struct prison every time I come up with a new variable. As
  a side effect, the extra storage is only needed when a variable is set from
  within the prison. This also minimizes kernel bloat when the Linuxulator is
  not used; both compiled in or as a module.

Reviewed by: bde (first version only) and phk
1999-08-27 19:47:41 +00:00
Marcel Moolenaar
ae4ea3eed4 Use ALIGN_TEXT macro for alignment to avoid ambiguity.
Pointed out by: bde
1999-08-25 19:04:39 +00:00
Marcel Moolenaar
4e0eaf6924 Fix linux_newlstat in that it doesn't return the attributes of its containing
directory. Also, update arguments of NDINIT for both newstat and newlstat.

While I'm at it, fix style bugs in all {s|ls|fs}tat syscalls.

Reported by: bde
1999-08-25 15:23:54 +00:00
Marcel Moolenaar
c85f67175f Fix {g|s}etgroups semantics. We use cr_groups[0] to hold egid. This means that
egid will be twice in the set and that setting cr_groups[0] will change egid.
This is simply solved by ignoring cr_groups[0]. That is; linux_getgroups does
not return cr_groups[0] and linux_setgroups does not touch it.

Noticed by: bde
Brought to my attention by: sheldonh
1999-08-25 14:11:01 +00:00
Marcel Moolenaar
296f7267f3 Fix lingo: 'is not implemented or obsoleted' is not the same as 'is obsoleted
or not implemented'.
1999-08-25 13:17:05 +00:00
Marcel Moolenaar
2fdc82e093 Change all UNIMPL syscalls to STD and add them to linux_dummy. Now we always
know if and when an unimplemented or obsoleted syscall is being used. Make the
message more end-user friendly.

And as long as we're here, rename some unimplemeted syscalls (linux_phys ->
linux_umount2, linux_vm86 -> linux_vm86old, linux_new_vm86 -> linux_vm86).

Change prototype for linux_newuname from `struct linux_newuname_t *' into
`struct linux_new_utsname *'. This change is reflected in linux.h and
linux_misc.c.
1999-08-25 11:19:03 +00:00
Marcel Moolenaar
fc4529a0d1 Change all UNIMPL syscalls to STD and add them to linux_dummy. Now we always
know if and when an unimplemented or obsoleted syscall is being used. Make the
message more end-user friendly.

And as long as we're here, rename some unimplemeted syscalls (linux_phys ->
linux_umount2, linux_vm86 -> linux_vm86old, linux_new_vm86 -> linux_vm86).

Change prototype for linux_newuname from `struct linux_newuname_t *' into
`struct linux_new_utsname *'. This change is reflected in linux.h and
linux_misc.c.

Lastly, make line-continuation and indentation more uniform.
1999-08-25 11:17:36 +00:00
Marcel Moolenaar
8ebe972975 Fix stack misalignment for Linux binaries caused by `linux_sigcode' not being
a multiple of 4 bytes in size. This solves the recent SIGBUS errors for
glibc2.1 configurations.

Explained by: bde
1999-08-25 09:05:29 +00:00
Marcel Moolenaar
4c60745daf Fix a bug in debug-printfs of struct linux_termios fields, where I forgot to
change the format specifier after changing the definition of the structure.

Submitted by: billf
Commented on by: bde
1999-08-17 10:27:55 +00:00
Marcel Moolenaar
ce2b2a92fc Fix bug in the debug-printf of the vfork syscall, where the format specifier
didn't match the argument (p->p_pid).

While I'm at it, also fix the dupo in the format string and fix the annoying
inconsistency in all the debug-printfs wrt p_pid arguments. Change all of them
to use the %ld format specifier and cast the p_pid arguments to long.

Submitted by: billf
1999-08-17 10:09:06 +00:00
Marcel Moolenaar
42035021f5 Implement linux_vfork() syscall by calling vfork(). Analogous to the
linux_fork() implementation.
1999-08-16 11:49:30 +00:00
Marcel Moolenaar
405f64d439 Implement vfork() syscall. 1999-08-16 11:47:21 +00:00
Marcel Moolenaar
878c351a1c Major rewrite.
The first reason for this rewrite is KNF conformance.

The second reason is to avoid redundancy. Each function printed the same
string, with only the syscall name being different. The actual printing is now
performed by a single function, which gets the syscall name as an argument.

The third reason is that of convenience. It's now very easy to add a new
dummy implementation. Just add ``DUMMY(foo);'' to the file. It's also a lot
easier now to see if a syscall has a dummy implementation or not.

The dummies are ordered on syscall number. Please maintain this when adding
new dummies (there're 32 candidates at the time of writing :-)

Reviewed by: bde
1999-08-15 18:59:44 +00:00
Marcel Moolenaar
a171f5adb6 Provide wrappers for sched_{s|g}etscheduler. We need to convert the policy
argument.

PR: 12006
Originator: Jean-Claude MICHOT <jcmichot@teaser.fr>
1999-08-15 17:28:40 +00:00
Marcel Moolenaar
e4accff654 Provide wrappers for sched_{s|g}etscheduler. We need to convert the policy
argument.

PR: 12006
1999-08-15 17:25:56 +00:00
Marcel Moolenaar
dc6f939870 Fix bug in the fcntl syscall where 'arg' was not set properly.
PR: 12147
Submitted by: Allan Saddi <asaddi@philosophysw.com>
1999-08-15 14:22:30 +00:00
Marcel Moolenaar
20c661befb Include opt_compat.h so that COMPAT_43 is defined. This gives us the proper
prototypes of o{s|g}etrlimit (from sys/sysproto.h). Update linux_{s|g}etrlimit
so that the arguments to o{s|g}etrlimit are corresponding the prototypes.

Pointed out by: bde
1999-08-15 13:28:35 +00:00
Marcel Moolenaar
81d960fa6d Implementation of the linux_getcwd syscall. 1999-08-14 18:20:44 +00:00
Marcel Moolenaar
e000c53684 Extend the number of syscalls to include those present in Linux 2.2.10. These
are syscalls 183 to 190. Also implement syscall 183: linux_getcwd. This is
needed to support a RH 6.0 environment.
1999-08-14 18:19:00 +00:00
Marcel Moolenaar
06ebbe77ed Implementation of linux_rt_sigaction and linux_rt_sigprocmask syscalls. Both
functions use the new sigset_t and sigaction_t which allows support for more
than 32 signals. Only the lower 32 signals are supported for now.

linux_rt_sigaction, linux_sigaction and linux_signal use linux_do_sigaction
to do the actual work. That way unnecessary redundancy is avoided. The same
has been done for linux_rt_sigprocmask and linux_sigprocmask. They call
linux_do_sigprocmask to do the actual work.
1999-08-14 17:28:46 +00:00
Marcel Moolenaar
68293b42c1 Implementation of linux_rt_sigaction and linux_rt_sigprocmask syscalls. These
syscalls are needed to support a RH 6.0 environment.
1999-08-14 17:14:13 +00:00
Marcel Moolenaar
3bde119b1e Fix LINUX_TIOC{S|G}SERIAL implementation. Both do not copy data in or out
of kernel space. Remove the ioctl supporting functions, and move the actual
code to the switch-statement. Now everybody can clearly see that the
implementation is really poor.

Also fix a typo in LINUX_TIOCGETD. The underlying function was given command
TIOCSETD instead op TIOCGETD...
1999-08-14 13:26:44 +00:00
Marcel Moolenaar
86cfb28d8d Fix the LINUX_TCSET{A|AW|AF} and LINUX_TCSET{S|SW|SF} ioctls. These all suffer
from the same bug in that the argument is not first copied from user space
before it is used. This is part 2 (of 2) of the termios fixes.
1999-08-14 10:30:38 +00:00
Marcel Moolenaar
432d528c8d Fix a couple of termio/termios conversion bugs/typos/dupos/brainos and other
changes. This is part 1 of the complete termios ioctl fixes.

o  change type of c_{i|o|c|l}flag in struct termios from unsigned long to
   unsigned int. The type now matches the Linux definitions.
o  replaced constants by the corresponding defines in sptab[] for clarity.
   Since there's no define for 135 baud, its mapping has been dropped.

function bsd_to_linux_termios:
o  Fix typo IXON -> IXANY.
o  Remove bogus assignment to c_cc[LINUX_VSWTC].

function linux_to_bsd_termios:
o  Fix dupo LINUX_IXON -> LINUX_IXANY.
o  Add LINUX_CREAD mapping.
o  Fix typo IEXTEN -> LINUX_IEXTEN.

function linux_to_bsd_termio:
o  Small optimization: Don't preset the complete c_cc array when we next
   assign to the first LINUX_NCC entries.
1999-08-14 10:05:50 +00:00
Marcel Moolenaar
7636612d50 Implementation of the CDROMSUBCHNL ioctl. 1999-08-13 14:44:13 +00:00
Marcel Moolenaar
0839a7e83d In doing lock type conversion (struct flock), make sure that carbage in results
in deterministic behaviour. In this case known garbage out.
The fix is different than suggested in the PR.

PR: 12749
Originator: Boris Nikolaus <boris@cs.tu-berlin.de>
1999-08-13 09:27:54 +00:00
Marcel Moolenaar
00d3c51669 Use a wrapper for the link syscall that does name translations.
PR: 12749
Submitted by: Boris Nikolaus <boris@cs.tu-berlin.de>
1999-08-12 19:53:33 +00:00
Marcel Moolenaar
175db64b3e Do not map {s|g}etrlimit onto FreeBSD syscalls. The arguments don't match.
The linux syscalls translate the arguments first before invoking the
FreeBSD native syscalls.

PR: kern/9591
Originator: John Plevyak <jplevyak@inktomi.com>
1999-08-11 13:34:31 +00:00
Marcel Moolenaar
10ef1b2aae Do not map {s|g}etrlimit onto the FreeBSD syscalls. The arguments do not
match.

PR: kern/9591
Originator: John Plevyak <jplevyak@inktomi.com>
1999-08-11 13:29:48 +00:00
Marcel Moolenaar
6a6ea79ac8 Fix page fault in linux_uselib syscall.
PR: 12910
Submitted by: Peter Holm <peter@holm.cc>
1999-08-08 11:26:46 +00:00
Brian Feldman
942fd180df We don't end up checking for a return value of EFAULT from the copyinstr()
in the pathname translation procedure. This proves fatal, and can be
easily fixed. This or a similar change needs to be committed to svr4_util.h
and ibcs2_util.h. I will update ibcs2_util.h, if noone else thinks of a
better way to do this, in the same manner. I will leave svr4 to the
respective maintainer.

This closes the problem of the only crash I've been able to produce as
a user recently, except for (currently not-in-the-source tree) fd
table sharing fixes. Thanks goes to pho for his stress-testers.
1999-08-07 05:33:35 +00:00
Poul-Henning Kamp
684adedee4 Use the vn_todev() function, rather than VOP_GETATTR 1999-07-18 14:31:01 +00:00
Marcel Moolenaar
3cef63a1f6 Implementation of TCXONC.
Reviewed by: bde
1999-07-17 08:24:57 +00:00
Marcel Moolenaar
68875907c6 Implement VT_RELDISP ioctl
Submitted by: Kazutaka Yokota <yokota@FreeBSD.org>
1999-07-08 16:15:19 +00:00
Marcel Moolenaar
4cf8b502c3 Trivial implementation of TIOCM{S|G}ET and TIOCMBI{S|C} ioctls. No need
to convert the arguments.
1999-07-06 11:41:48 +00:00
Martin Cracauer
8f437f4439 Rename struct members sa_siginfo. POSIX reserves identifiers starting
with sa_ when <signal.h> is included. They would conflict with the
upcoming SA_SIGINFO implementation.

Reviewed by:	BDE
1999-07-06 06:55:29 +00:00
Marcel Moolenaar
19e520961c Let newuname return "Linux" as the OS name and not "FreeBSD". Also, return a
more sensible (for Linux applications) release number. Hardcoding a release
number has its drawbacks, but it will do for now.
1999-07-05 19:18:03 +00:00
Peter Wemm
75f83872e2 Tweak include ordering so sys/systm.h is before sys/buf.h to keep buf.h's
inlines happy.
1999-06-28 09:12:46 +00:00
Poul-Henning Kamp
bfbb9ce670 Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.

Provide functions to manipulate both types:
        major()         umajor()
        minor()         uminor()
        makedev()       umakedev()
        dev2udev()      udev2dev()

For now they're functions, they will become in-line functions
after one of the next two steps in this process.

Return major/minor/makedev to macro-hood for userland.

Register a name in cdevsw[] for the "filedescriptor" driver.

In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.

In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits.  This will essentially
replace the current "alias" check code (same buck, bigger bang).

A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference.  If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.

Without DEVT_FASCIST I belive this patch is a no-op.

Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.

Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).
1999-05-11 19:55:07 +00:00
Peter Wemm
e37622b251 Fix a couple of warnings and some bitrot in comments. 1999-05-09 16:04:14 +00:00
Poul-Henning Kamp
90fb336860 Yet another place which knew too much. Still not sure how much
good this does in the end.
1999-05-09 10:25:30 +00:00
Poul-Henning Kamp
4be2eb8c49 I got tired of seeing all the cdevsw[major(foo)] all over the place.
Made a new (inline) function devsw(dev_t dev) and substituted it.

Changed to the BDEV variant to this format as well: bdevsw(dev_t dev)

DEVFS will eventually benefit from this change too.
1999-05-08 06:40:31 +00:00
Peter Wemm
d5558c001a Fix up a few easy 'assignment used as truth value' and 'suggest parens
around && within ||' type warnings.  I'm pretty sure I have not masked
any problems here, I've committed real problem fixes seperately.
1999-05-06 18:44:42 +00:00
Luoqi Chen
9debe21353 - Handle mixer read ioctls correctly. They have the same group, number and
argument size as their write counterparts and were handled as write ioctls.
- Emulate some cdrom ioctls.
1999-04-29 04:37:57 +00:00
Luoqi Chen
5206bca10a Enable vmspace sharing on SMP. Major changes are,
- %fs register is added to trapframe and saved/restored upon kernel entry/exit.
- Per-cpu pages are no longer mapped at the same virtual address.
- Each cpu now has a separate gdt selector table. A new segment selector
  is added to point to per-cpu pages, per-cpu global variables are now
  accessed through this new selector (%fs). The selectors in gdt table are
  rearranged for cache line optimization.
- fask_vfork is now on as default for both UP and SMP.
- Some aio code cleanup.

Reviewed by:	Alan Cox	<alc@cs.rice.edu>
		John Dyson	<dyson@iquest.net>
		Julian Elischer	<julian@whistel.com>
		Bruce Evans	<bde@zeta.org.au>
		David Greenman	<dg@root.com>
1999-04-28 01:04:33 +00:00
Poul-Henning Kamp
1c308b817a Change suser_xxx() to suser() where it applies. 1999-04-27 12:21:16 +00:00
Poul-Henning Kamp
f711d546d2 Suser() simplification:
1:
  s/suser/suser_xxx/

2:
  Add new function: suser(struct proc *), prototyped in <sys/proc.h>.

3:
  s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/

The remaining suser_xxx() calls will be scrutinized and dealt with
later.

There may be some unneeded #include <sys/cred.h>, but they are left
as an exercise for Bruce.

More changes to the suser() API will come along with the "jail" code.
1999-04-27 11:18:52 +00:00
Peter Wemm
db42d90829 unifdef -DVM_STACK - it's been on for a while for x86 and was checked
and appeared to be working for the Alpha some time ago.
1999-04-19 14:14:14 +00:00
Julian Elischer
4ac9ae7083 Fix thread/process tracking and differentiation for Linux threads emulation.
Submitted by:	Richard Seaman, Jr." <dick@tar.com>

Also clean some compiler warnings in surrounding code.
1999-03-02 00:28:09 +00:00
Mark Newton
d27583423e Added call to elf_brand_inuse() to prevent you from cutting your own
legs out from under you.
1999-02-04 21:20:13 +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
Peter Wemm
1e65ef01b0 Minor cleanup; no more references to LKM's. 1999-01-17 20:36:14 +00:00
Mike Smith
096d55fc13 Fix linux sendmsg() emulation
Submitted by:	Brian Feldman <green@unixhelp.org>
1999-01-11 05:28:44 +00:00
Eivind Eklund
dcda29feba Use truncate() instead of otruncate() - step on the way to stopping
the linulator from depending on COMPAT_43.
1999-01-10 23:15:35 +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
Søren Schmidt
e76bba09e3 Commit patch in
PR: 9232
Submitted by:	marcel@scc.nl <Marcel Moolenaar>
1998-12-30 21:20:00 +00:00
Søren Schmidt
397e476030 Commit #2 of
PR: 9235
Submitted by:	marcel@scc.nl <Marcel Moolenaar>
1998-12-30 21:01:34 +00:00
Søren Schmidt
abbc72c904 Commit #1 of:
PR: 9235
1998-12-30 20:58:28 +00:00
Julian Elischer
1b88e5d756 According to the author..
"I've been having a problem running the patches [committed to current]
installed with the COMPAT_LINUX_THREADS option along
with the VM_STACK patches I did.  I'm not sure what
the problem is, since it seemed to work before.

In any event, the attached patch fixes the problem for
me.  While I've had no report of problems from anyone
else, possibly it would be wise to commit the patch
until the problem is found.

Also, there was some left-over junk in the linux_misc.c
file from some earlier work I did.  The attached patch
cleans that up too."

Submitted by: "Richard Seaman, Jr." <dick@tar.com>
1998-12-24 21:21:20 +00:00
Søren Schmidt
5b3c791070 The result of running make linux_sysent.c on the new syscalls.master 1998-12-22 09:00:47 +00:00
Søren Schmidt
ec4e636d4c Fix NOIMPL -> NOPROTO as per bruce. 1998-12-22 08:59:19 +00:00
Søren Schmidt
bfc338e0bb The result of running make linux_sysent.c on the new syscall.master file 1998-12-21 19:31:57 +00:00
Søren Schmidt
81bca0e98c Syscall 168 (poll) is not implemented in the Linux emulator. This
syscall is used by Oracle.

PR:		9154
Submitted by:	Marcel Moolenaar <marcel@scc.nl>
1998-12-21 19:28:13 +00:00
Søren Schmidt
c26abb753a Kill(pid, 0) normally returns 0 on both FreeBSD and Redhat after having
performed all sorts of sanity checks. The FreeBSD linux emulator returns
EINVAL in such a case.
Allowing signal 0 to be passed to kill will result in compatible behaviour.

PR:	9082
Submitted by:	Marcel Moolenaar <marcel@scc.nl>
1998-12-21 19:21:36 +00:00
Søren Schmidt
9073a41122 Make it compile again.
I have no idea if the new stuff works though.

Broken by: Julian
1998-12-19 19:05:57 +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
Dmitrij Tejblum
85f118c801 Added 3 new errno values, requred by various standards: EOVERFLOW,
ECANCELED, EILSEQ.

Fixed ibcs2 and especially linux EIDRM and ENOMSG errno mapping.
Reviewed by:	Dan Nelson <dnelson@emsphone.com>
1998-12-14 18:54:04 +00:00
Jordan K. Hubbard
57da30bfc9 linux_pipe does not preserve the edx register. Linux and
programs using glibc expect edx to be preserved accross syscalls.
As a result, linux programs running in emulation mode can
have whatever value may be represented by edx clobbered.

PR:		9038
Submitted-By:	Richard Seaman, Jr. <dick@tar.com>
1998-12-10 13:47:18 +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
Bruce Evans
c25ded316f Finished updating module event handlers to be compatible with
modeventhand_t.
1998-11-15 15:33:52 +00:00
Jordan K. Hubbard
845491fe8d MF22: Bring in some linux sound ioctl support which I committed to 2.2
for PR 7792 but did not bring forward.

Submitted by:	Avatar Liang <avatar@www.mmlab.cse.yzu.edu.tw>
PR:		8656
1998-11-12 00:42:08 +00:00
Peter Wemm
aa855a598d *gulp*. Jordan specifically OK'ed this..
This is the bulk of the support for doing kld modules.  Two linker_sets
were replaced by SYSINIT()'s.  VFS's and exec handlers are self registered.
kld is now a superset of lkm.  I have converted most of them, they will
follow as a seperate commit as samples.
This all still works as a static a.out kernel using LKM's.
1998-10-16 03:55:01 +00:00
Alexander Langer
514058dc0d Unregister the glibc2 brand at module unload time.
Change the ELF registration/unregistration scheme to be less error prone.
Adding a new brand requires a single addition to linux_brandlist instead of
modifying linux_load(), linux_unload(), and linux_elf_init().

Approved by:	jkh
Reviewed by:	msmith
1998-10-11 21:08:02 +00:00
John Polstra
2116e6ab2f Fix a couple of out-of-bounds array references in mapping between
Linux and FreeBSD signal numbers.  Also, check signal numbers passed
in from application programs for validity.  Without these checks,
it is trivial to panic the system from a Linux program.
1998-10-11 04:54:16 +00:00
John Fieber
98fd9ce8c9 Make async I/O on a socket work.
Although the current Sybase license does not permit running under
emulation, FreeBSD 3.0 is now "Sybase Ready" should the license change.
1998-10-05 16:37:36 +00:00
Søren Schmidt
5dd99c3bce In linux_newuname bzero the right type of struct (linux_newuname_t). 1998-10-05 12:40:42 +00:00
John Fieber
f18bad6e73 Add several missing ioctl handlers. One needed by Sybase, the others
found while looking for the one.
1998-09-30 01:42:53 +00:00
Jordan K. Hubbard
9587f05dcb MF22: revert time bogon. 1998-09-24 13:25:43 +00:00
Jordan K. Hubbard
c9297a7328 return time in proper format for linux. 1998-09-23 14:50:26 +00:00
Mike Smith
4e138a28a0 Add support for glibc consumers using the new ld-linux.so.2 linker.
I can't say this was the most inspired fix, but it matches the design OK.
1998-09-17 22:08:34 +00:00
John Polstra
22d4b0fb41 Add provisions for variant core dump file formats, depending on the
object format of the executable being dumped.  This is the first
step toward producing ELF core dumps in the proper format.  I will
commit the code to generate the ELF core dumps Real Soon Now.  In
the meantime, ELF executables won't dump core at all.  That is
probably no less useful than dumping a.out-style core dumps as they
have done until now.

Submitted by:	Alex <garbanzo@hooked.net> (with very minor changes by me)
1998-09-14 05:36:51 +00:00
Jordan K. Hubbard
e11952d397 Argh! *Now* the correct 3.0 fix is committed. 1998-08-31 10:53:33 +00:00
Jordan K. Hubbard
51509b513f Whoops! Stamp out a 2.2-ism that snuck between branches here. 1998-08-31 10:51:19 +00:00
Jordan K. Hubbard
2394cd9adb Initial support for using linux X servers under emulation - to use an
XFree86 server, users need to create the following links in their
/compat/linux/dev directory (assuming kernel configured with 4 VTs).

lrwxrwxrwx  1 root  wheel  7 Aug 30 22:59 tty0 -> console
lrwxrwxrwx  1 root  wheel  5 Aug 30 22:45 tty1 -> ttyv0
lrwxrwxrwx  1 root  wheel  5 Aug 30 22:45 tty2 -> ttyv1
lrwxrwxrwx  1 root  wheel  5 Aug 30 22:45 tty3 -> ttyv2
lrwxrwxrwx  1 root  wheel  5 Aug 30 22:45 tty4 -> ttyv3

VT switching is still not yet supported. Attempting to switch VT
currently will cause Xserver bus error.

Submitted by:	Chain Lee <chain@110.net>
1998-08-31 06:55:02 +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
24382fa41f Oops, the previous fix confused Linux's sigset_t with a pointer type.
It can be integral or a struct in POSIX, so it is difficult to print,
but it is actually declared as unsigned long.  Assume that it is
unsigned integral.
1998-08-15 22:29:43 +00:00
Bruce Evans
882fdeae66 Converted the second last instance of hzto() to tvtohz().
Fixed nearby bugs (in linux_alarm()):
- the itimer for the alarm was relative to the epoch instead of relative
  to the boot time.  This was harmless because the itimer's interval is 0.
- the seconds arg was not checked for validity before converting it to a
  possibly different value.
- printf format errors.

Improvements:
Don't use splclock().  splsoftclock() suffices.  Don't complicate things
by micro-optimizing interrupt latency.

Minor improvements:
Various micro-optimizations to exploit the specialness of the alarm itimer
and the value 0.
1998-08-05 16:44:30 +00:00
Bruce Evans
e4e6ae1366 Fixed print format errors. 1998-07-29 16:43:00 +00:00
Bruce Evans
e33e271f08 Fixed printf format errors.
Use offsetof() instead of null pointer hacks.  Use a home made offsetof()
because including <stddef.h> is not permitted in LKMs.
1998-07-29 15:50:41 +00:00
Jordan K. Hubbard
d14897d381 Quick and dirty support for Linux's mremap. Not used by anything
but quake2 AFAIK.

Submitted by:   Luoqi Chen <luoqi@watermarkgroup.com>
1998-07-10 22:30:08 +00:00
John-Mark Gurney
b039fc4c34 remove option LINUX as it did nothing, add DEBUG_LINUX to debug the
linux emulation...

(actually moved LINUX to opt_dontuse.h)
1998-06-30 08:40:33 +00:00
Bruce Evans
39b14624c5 Updated generated files. 1998-06-09 03:36:59 +00:00
Bruce Evans
9ae58db7a3 Include "opt_compat.h" explicitly instead of depending on
makesyscalls.sh generating it as pollution.

Don't attempt to separate the includes by newlines.  makesyscalls.sh
just ignores newlines.
1998-06-09 03:28:14 +00:00
Bruce Evans
414c93f3aa Updated generated files. 1998-06-08 11:08:35 +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
Jordan K. Hubbard
ba98833992 ".. x11amp appears to be calling shmctl(id, IPC_RMID, 0) and the emulation
layer does not like the null shmid_ds buffer pointer.  The emulation layer
returned an error without ever calling FreeBSD's shmctl, so the segments
were not being deleted when the reference count went to zero."

Submitted by:	Kevin Street <street@iname.com>
1998-06-02 12:38:31 +00:00
Poul-Henning Kamp
c21410e119 s/nanoruntime/nanouptime/g
s/microruntime/microuptime/g

Reviewed by:	bde
1998-05-17 11:53:46 +00:00
Eivind Eklund
d563a53a79 Unbotch whitespace and change switch with two cases to if.
Noticed by:	bde
1998-05-07 00:42:25 +00:00
Eivind Eklund
288078be0f Translate T_PROTFLT to SIGSEGV instead of SIGBUS when running under
Linux emulation.  This make Allegro Common Lisp 4.3 work under
FreeBSD!

Submitted by: Fred Gilham <gilham@csl.sri.com>
Commented on by: bde, dg, msmith, tg
Hoping he got everything right:  eivind
1998-04-28 18:15:08 +00:00
Søren Schmidt
958a082931 Added EIDRM & ENOMSG to errno translation table. 1998-04-13 17:49:51 +00:00
Poul-Henning Kamp
4cf41af3d4 Make a kernel version of the timer* functions called timerval* to be
more consistent.

OK'ed by:	bde
1998-04-06 08:26:08 +00:00
Poul-Henning Kamp
cc6447a365 Use microruntime() rather than doing it by hand. 1998-04-04 18:56:54 +00:00
Poul-Henning Kamp
227ee8a188 Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed
around any access to it, unless you just wanted the seconds part.

Most uses of time.tv_sec now uses the new variable time_second instead.

gettime() changed to getmicrotime(0.

Remove a couple of unneeded splfoo() protections, the new getmicrotime()
is atomic, (until Bruce sets a breakpoint in it).

A couple of places needed random data, so use read_random() instead
of mucking about with time which isn't random.

Add a new nfs_curusec() function.

Mark a couple of bogosities involving the now disappeard time variable.

Update ffs_update() to avoid the weird "== &time" checks, by fixing the
one remaining call that passwd &time as args.

Change profiling in ncr.c to use ticks instead of time.  Resolution is
the same.

Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call
hzto() which subtracts time" sequences.

Reviewed by:	bde
1998-03-30 09:56:58 +00:00
Peter Wemm
00d21a1337 regenerate 1998-03-29 08:04:49 +00:00
Peter Wemm
1e8dabab3f The linux chown syscall is more like lchown, a new chown syscall that
follows links was added.
1998-03-29 07:59:10 +00:00