Commit Graph

289 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Bruce Evans
08637435f2 Moved some #includes from <sys/param.h> nearer to where they are actually
used.
1998-03-28 10:33:27 +00:00
Bruce Evans
770a5f7ec9 Removed redundant test against MAXDSIZ (the rlimit test is stronger). 1998-02-25 05:33:06 +00:00
Mike Smith
dad3b88ae3 In the words of the submitter:
----
I've worked to enhance the connect() patches.

I've just tested this with the Linux JDK appletviewer on an applet
that does a lot of connects, and it works as well as during my
previous tests.

The connect() patch is now a merge between my older patch and the
OpenBSD stuff. It ensures that any async error is returned by
connect() instead of getsockopt(SOL_SOCKET, SO_ERROR) as reasonnable
systems do.

There are also minor patches to implement IPPROTO_TCP for
get/setsocktopt(). These are also tested (with Linux Apache).
----

I would appreciate any feedback regarding these changes, as they'd
be very useful in 2.2.6.

Submitted by:	pb@fasterix.freenix.org (Pierre Beyssac)
1998-02-07 02:13:27 +00:00
Jonathan M. Bresler
080ea93df2 sigh....forgot to update the DEBUG printf
to show both the path and the length args
	to linux emulation truncate()

Submitted by:		jmb
1998-01-05 01:17:42 +00:00
Jonathan M. Bresler
1c4faf8bb9 length argument to truncate() in linux emulation
was not being set copied to the bsd arguments..
	frequently, resulting in files of over 100MB of NULs

PR:	386/5044
Reviewed by:		jmb
Submitted by:		(Richard Winkel) rich@math.missouri.edu
1998-01-05 01:05:15 +00:00
Eivind Eklund
8438b90fd3 Make hidden COMPAT_43 dependencies explict. Options in headers is a
pain in the backside.
1997-12-16 18:49:23 +00:00
Eivind Eklund
5591b823d1 Make COMPAT_43 and COMPAT_SUNOS new-style options. 1997-12-16 17:40:42 +00:00
Mike Smith
7ebfc603cf As described by the submitter:
These patches enables us to play quake2 .

Support linux keyboard ioctl for setting RAW, MEDIUMRAW and XLATE.

Support linux virtual terminal operations:
 OPENQRY, GETMODE, SETMODE, GETSTATE, ACTIVATE, and WAITACTIVE.

Submitted by:	Amancio Hasty <hasty@rah.star-gate.com>
1997-12-15 06:09:11 +00:00
Mike Smith
f2477ae13d As described by the submitter:
- emulate Linux IP_HDRINCL behaviour in sendto(): byte order fixed
	  Note that we do an extra getsockopt() on every sendto()
	  to check if the option is set because we don't keep state
	  in the emulator code. Is there a better way to implement
	  this?
	- correct a bug (value of "name" not passed) with
	  getsockopt()

Submitted by:	pb@fasterix.freenix.org (Pierre Beyssac)
1997-12-14 03:17:54 +00:00
Bruce Evans
1cd52ec333 Don't include <sys/lock.h> in headers when only `struct simplelock' is
required.  Fixed everything that depended on the pollution.
1997-12-05 19:55:52 +00:00
Amancio Hasty
53eaeb96ba Added support for linux sound ioctls:
LINUX_SNDCTL_DSP_GETOPTR
LINUX_SNDCTL_DSP_GETIPTR
LINUX_SNDCTL_DSP_SETTRIGGER
LINUX_SNDCTL_DSP_GETCAPS

With this rev level the linux realaudio player 5 and xquake should work.
1997-11-17 04:00:32 +00:00
Poul-Henning Kamp
cb226aaa62 Move the "retval" (3rd) parameter from all syscall functions and put
it in struct proc instead.

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

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

libkvm, ps and other userland struct proc frobbing programs will need
recompiled.
1997-11-06 19:29:57 +00:00
KATO Takenori
1d07b128d5 Securelevel and formatting fixes, and trapframe simplification.
Reviewed by:	sos
Submitted by:	bde
1997-10-30 10:53:30 +00:00
KATO Takenori
404c835d69 Implement linux_iopl and linux_nice. 1997-10-29 08:17:14 +00:00
KATO Takenori
9b86a4168f Implement linux_semop, linux_semget and linux_semctl.
PR:		4355
1997-10-28 10:50:02 +00:00
Justin T. Gibbs
3544218335 Update for changes in the callout interface. 1997-09-21 21:43:54 +00:00
Søren Schmidt
3c3549f6e7 Ops the arguments to copyin was in the wrong order..
This has survived since the first version, sigh.
1997-08-10 18:15:20 +00:00
Bruce Evans
293a9e510c Removed unused #includes. 1997-07-20 16:06:08 +00:00
Doug Rabson
50ef24000a Make this thing actually compile. 1997-06-02 10:43:41 +00:00
Mike Smith
88e2b22c9f Oops, remove some bogus debugging code that crept in with the last commit. 1997-06-02 06:33:22 +00:00
Mike Smith
3713cbff75 Add support for the SIOCGIFHWADDR ioctl, commonly used by
license managers to obtain the host's ethernet address as
a key.

Note that this implementation takes the first hardware address for
the first ethernet interface found, and disregards the interface name
that may be passed in, as linux ethernet devices are all "ethX".
1997-06-02 06:31:49 +00:00
Mike Smith
28f6972b6e Always include PROT_READ for Linux mmap operations.
Submitted by:	Hannu Savolainen <hannu@voxware.pp.fi> via jkh
1997-04-28 02:53:17 +00:00
Doug Rabson
c9e191b82a Remove dependancy on UFS' DIRBLKSIZ definition.
2.2 candidate.

Submitted by:	bde
1997-04-06 10:10:50 +00:00
Doug Rabson
d41979a063 Fix linux_getdents so that it can cope with filesystems which translate
the directory format (ext2fs, cd9660).  For these filesystems, it must use
cookies to find the correct offset to use for subsequent reads.  Without it,
linux /bin/ls tends to loop re-reading the same block over and over again.

2.2 candidate.
1997-04-05 14:50:56 +00:00
Bruce Evans
3f39dbc52d Removed potentially harmful garbage <vm/lock.h> and fixed bogus
use of it.  It was actually harmless because the use was null due
to fortuitous include orders and identical (wrong) idempotency
macros.
1997-04-01 08:39:07 +00:00
Bruce Evans
71455815cc Don't include <sys/ioctl.h> in the kernel. Stage 3: include
<sys/filio.h> instead of <sys/ioctl.h> in non-network non-tty files.
1997-03-24 11:37:53 +00:00
Bruce Evans
fce002fdef Don't include <sys/ioctl.h> in the kernel. Stage 1: don't include
it when it is not used.  In most cases, the reasons for including it
went away when the special ioctl headers became self-sufficient.
1997-03-24 11:25:10 +00:00
Bruce Evans
3ac4d1ef0c Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.
Fixed everything that depended on getting fcntl.h stuff from the wrong
place.  Most things don't depend on file.h stuff at all.
1997-03-23 03:37:54 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
Mike Pritchard
b49b12158f Make this compile again after the Lite2 merge.
VOP_UNLOCK was being called with the wrong mumber of arguments.

Also silenced a -Wall warning.
1997-02-10 16:34:16 +00:00
John Dyson
996c772f58 This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.

The system boots and can mount UFS filesystems.

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

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

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

The fix involves negative logic.  Named pipes are now distinguished from
other types of files with vnodes, and there is additional code to handle
vnodes and named pipes in the same way only where that makes sense (not
for lseek, locking or TIOCSCTTY).
1996-12-19 19:42:37 +00:00
Bill Fenner
66ff6a3c1b Add IP_OPTIONS and the multicast-related setsockopts to the
list of IP setsockopts the Linux emulator recognizes.

Explicitly disallow IP_HDRINCL since Linux's handling of
raw output is different than BSD's.

Closes PR#kern/2111.

Submitted by:	y-nakaga@ccs.mt.nec.co.jp (Yoshihisa NAKAGAWA)
1996-12-03 02:52:29 +00:00
Sujal Patel
e89054370f Add audio mixer ioctls.
Only writing to the mixer is implemented.
1996-11-05 02:04:37 +00:00