Commit Graph

302 Commits

Author SHA1 Message Date
Bruce Evans
4292735db9 Fixed some style bugs in the removal of __P(()). Tabs before "__P(("
were not removed.
2002-03-24 04:04:50 +00:00
Jeff Roberson
851031501a Remove references to vm_zone.h and switch over to the new uma API. 2002-03-20 10:35:22 +00:00
Alfred Perlstein
b63dc6ad47 Remove __P. 2002-03-20 05:48:58 +00:00
John Baldwin
a854ed9893 Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.
2002-02-27 18:32:23 +00:00
Robert Drehmel
668ae58863 Use the updated getcredhostname() function. 2002-02-27 16:47:27 +00:00
Robert Drehmel
5597f0ccf2 Use the getcredhostname function to fill the hostname into
the linux_newuname_args structure.  This should fix the case
of jailed linux processes not using the jail's hostname.

PR:		35336
Reviewed by:	phk
2002-02-27 15:06:33 +00:00
Seigo Tanimura
f591779bb5 Lock struct pgrp, session and sigio.
New locks are:

- pgrpsess_lock which locks the whole pgrps and sessions,
- pg_mtx which protects the pgrp members, and
- s_mtx which protects the session members.

Please refer to sys/proc.h for the coverage of these locks.

Changes on the pgrp/session interface:

- pgfind() needs the pgrpsess_lock held.

- The caller of enterpgrp() is responsible to allocate a new pgrp and
  session.

- Call enterthispgrp() in order to enter an existing pgrp.

- pgsignal() requires a pgrp lock held.

Reviewed by:	jhb, alfred
Tested on:	cvsup.jp.FreeBSD.org
		(which is a quad-CPU machine running -current)
2002-02-23 11:12:57 +00:00
Alfred Perlstein
2335a944a8 fix file descriptor leak.
Submitted by: Mark Santcroos <marks@ripe.net>
2002-02-20 17:06:37 +00:00
Bruce Evans
039b360dac Garbage collect options AVM_A1_PCI, AVM_A1_PCMCIA, DEBUG_LINUX, DEV_APM,
GUS_DMA, GUS_DMA2, GUS_IRQ, OLTR_NO_BULLSEYE_MAC, OLTR_NO_HAWKEYE_MAC,
OLTR_NO_TMS_MAC and PCIC_RESUME_RESET.
2002-02-15 10:19:39 +00:00
Marcel Moolenaar
75387a278e Have SIOCGIFCONF return all (if any) AF_INET addresses for the
interfaces we encounter. In Linux, all addresses are returned for
which gifconf handlers are installed. This boils down to AF_DECnet
and AF_INET. We care mostly about AF_INET for now. Adding additional
families is simple enough.

Returning the addresses is important for RPC clients to function
properly. Andrew found in some reference code that the logic that
handles the retransmission looks for an interface that's up and has
an AF_INET address. This obviously failed as we didn't return any
addresses at all.

Note also that with this change we don't return interfaces that don't
have AF_INET addresses, whereas before we returned any interface
present in the system. This is in line with what Linux does (modulo
interfaces with only AF_DECnet addresses of course :-)

Reported by: "Andrew Atrens" <atrens@nortelnetworks.com>
MFC after: 1 week
2002-01-29 06:00:11 +00:00
Andrew Gallatin
21e06996e4 Linux/alpha uses the same BSDish return mechanism we do for
getpid, getuid, getgid and pipe, since they bootstrapped from
OSF/1 and never cleaned up.  Switch to the native syscalls
on alpha so that the above functions work

MFC after: 7 days
2002-01-23 22:46:14 +00:00
Marcel Moolenaar
bea90c29cf Reinstate linux_ifname. Although the Linuxulator doesn't use it
itself, it's used outside the Linuxulator. Reimplement the
function so that its behaviour matches the current renaming
scheme. It's probably better to formalize these interdependencies.
2002-01-15 03:10:33 +00:00
Alfred Perlstein
a4db49537b Replace ffind_* with fget calls.
Make fget MPsafe.

Make fgetvp and fgetsock use the fget subsystem to reduce code bloat.

Push giant down in fpathconf().
2002-01-14 00:13:45 +00:00
Alfred Perlstein
21f633c5c2 Remove unused variable. 2002-01-13 14:12:16 +00:00
Alfred Perlstein
426da3bcfb SMP Lock struct file, filedesc and the global file list.
Seigo Tanimura (tanimura) posted the initial delta.

I've polished it quite a bit reducing the need for locking and
adapting it for KSE.

Locks:

1 mutex in each filedesc
   protects all the fields.
   protects "struct file" initialization, while a struct file
     is being changed from &badfileops -> &pipeops or something
     the filedesc should be locked.

1 mutex in each struct file
   protects the refcount fields.
   doesn't protect anything else.
   the flags used for garbage collection have been moved to
     f_gcflag which was the FILLER short, this doesn't need
     locking because the garbage collection is a single threaded
     container.
  could likely be made to use a pool mutex.

1 sx lock for the global filelist.

struct file *	fhold(struct file *fp);
        /* increments reference count on a file */

struct file *	fhold_locked(struct file *fp);
        /* like fhold but expects file to locked */

struct file *	ffind_hold(struct thread *, int fd);
        /* finds the struct file in thread, adds one reference and
                returns it unlocked */

struct file *	ffind_lock(struct thread *, int fd);
        /* ffind_hold, but returns file locked */

I still have to smp-safe the fget cruft, I'll get to that asap.
2002-01-13 11:58:06 +00:00
Marcel Moolenaar
217bab1e77 Further fixes related to the interface renaming. Now that we
properly translate the interface name passed to us, make sure
we also translate correctly before we return the list of
interfaces with the SIOCGIFCONF ioctl. It is common to use
the interface names returned by that ioctl in further ioctls,
such as SIOCGIFFLAGS.

Remove linux_ifname as it is no longer used. Also remove
ifname_bsd_to_linux as it cannot be used anymore now that
linux_ifname is removed (was deadcode anyway).

Reported and tested by: Andrew Atrens <atrens@nortelnetworks.com>
2002-01-10 05:36:36 +00:00
David E. O'Brien
6e551fb628 Update to C99, s/__FUNCTION__/__func__/,
also don't use ANSI string concatenation.
2001-12-10 08:09:49 +00:00
Marcel Moolenaar
53b9d88fc4 When translating the interface name when "eth?" is given, do not
use the internal index number as the unit number to compare with.
The first ethernet interface in Linux is called "eth0", whereas
our internal index starts wth 1 and is not unique to ethernet
interfaces (lo0 has index 1 for example). Instead, use a function-
local index number that starts with 0 and is incremented only
for ethernet interfaces. This way the unit number will match the
n-th ethernet interface in the system, which is exactly what it
means in Linux.

Tested by: Glenn Johnson <gjohnson@srrc.ars.usda.gov>
MFC after: 3 days
2001-12-04 03:55:10 +00:00
Robert Watson
011376308f o Introduce pr_mtx into struct prison, providing protection for the
mutable contents of struct prison (hostname, securelevel, refcount,
  pr_linux, ...)
o Generally introduce mtx_lock()/mtx_unlock() calls throughout kern/
  so as to enforce these protections, in particular, in kern_mib.c
  protection sysctl access to the hostname and securelevel, as well as
  kern_prot.c access to the securelevel for access control purposes.
o Rewrite linux emulator abstractions for accessing per-jail linux
  mib entries (osname, osrelease, osversion) so that they don't return
  a pointer to the text in the struct linux_prison, rather, a copy
  to an array passed into the calls.  Likewise, update linprocfs to
  use these primitives.
o Update in_pcb.c to always use prison_getip() rather than directly
  accessing struct prison.

Reviewed by:	jhb
2001-12-03 16:12:27 +00:00
Dag-Erling Smørgrav
c798b36242 Revert incorrect KSEfication: realitexpire expects a struct proc *, not a
struct thread *.
2001-11-24 14:09:50 +00:00
Ian Dowse
b0cb4883b1 Deal with a few issues that cropped up following the recent changes
to the code for translating socket and private ioctls:

- Only perform socket ioctl translation if the file descriptor is a
  socket.
- Treat socket ioctls on non-sockets specially, and for now assume
  that these are directed at a tap/vmnet device, so translate the
  ioctl numbers as appropriate (the way if_tap abuses some socket
  ioctls to pass non-ifreq data is utterly bogus, but this is how
  VMware on FreeBSD has always "worked"; I will deal with this
  later).
- Add (untested) support for translating SIOCSIFADDR.
- In all cases where we fail to translate an ioctl, return ENOIOCTL
  so that other handlers have a chance to do the translation.

This should fix the "/dev/vmnet1: Invalid argument" errors that
users of VMware were experiencing, though I have only verified this
on RELENG_4.

Submitted by:	des (mostly)
MFC after:	3 days
2001-11-19 15:43:50 +00:00
Marcel Moolenaar
9d2ff92851 Implement DVD-ROM ioctls.
PR: 26955
Submitted by: Boris Nikolaus (email unknown)
2001-11-18 18:49:07 +00:00
Marcel Moolenaar
33b3cce08c Implement missing SOUND_MIXER_WRITE_RECSRC ioctl.
PR: 22971
Tested by: dougb
2001-11-18 06:36:18 +00:00
Matthew Dillon
39c95b8377 Fix missing holdsock()->fgetsock()
Submitted by:	Hisashi Hiramoto <hiramoto@phys.chs.nihon-u.ac.jp>
2001-11-17 18:43:13 +00:00
Peter Wemm
50fa1aaaa7 Forward declare struct ifnet - this fixes a warning in tdfx_pci.c 2001-11-17 01:22:07 +00:00
Peter Wemm
1cf2b66500 Fix printf warnings (int/long)
#if 0 around unused ifname_bsd_to_linux() function
2001-11-17 01:20:02 +00:00
Peter Wemm
170a2c575c Fix warning in debug printf. This is a long on alpha, and int on i386,
but printed with %ld always.
2001-11-17 01:16:10 +00:00
Robert Watson
ce17880650 o Replace reference to 'struct proc' with 'struct thread' in 'struct
sysctl_req', which describes in-progress sysctl requests.  This permits
  sysctl handlers to have access to the current thread, permitting work
  on implementing td->td_ucred, migration of suser() to using struct
  thread to derive the appropriate ucred, and allowing struct thread to be
  passed down to other code, such as network code where td is not currently
  available (and curproc is used).

o Note: netncp and netsmb are not updated to reflect this change, as they
  are not currently KSE-adapted.

Reviewed by:		julian
Obtained from:	TrustedBSD Project
2001-11-08 02:13:18 +00:00
Michael Reifenberger
491dec936c Introduce [IPC|SHM]_[INFO|STAT] to shmctl to make
`/compat/linux/usr/bin/ipcs -m` happy.
2001-10-28 09:29:10 +00:00
Dag-Erling Smørgrav
a08d68de5b Eliminate the prefix parameter to linux_emul_find(), which was always
linux_emul_path anyway.  Linux_emul_find() has interesting bugs in its
prefix handling (which luckily are not currently exploitable); this
commit is preliminary to an attempt at cleaning it up.

Approved by:	marcel
2001-10-27 11:15:19 +00:00
Bill Fenner
4730796ca1 Force the length of the sockaddr to be correct for AF_INET and AF_INET6
in bind() and connect().  Linux doesn't care if the length of the
sockaddr matches its address family; FreeBSD does.  This fixes the
known issues with the resolver in linux_base-7.
2001-10-26 23:10:08 +00:00
Dag-Erling Smørgrav
82835638e1 Tweak the way we determine if an interface needs to have its name translated.
Add some missing break statements in the socket ioctl switch.
Check the return value from copyin() / copyout().
Fix some disorderings and misindentations.
Support a couple more socket ioctls.
Add missing break statements.
2001-10-20 00:01:26 +00:00
Marcel Moolenaar
3c7b85d4f0 Fix Alpha related brokenness. We used to have a MD linux_ioctl.h
that appeared to be very different from the MI version. These
differences were mostly bogus and caused by copying octal
definitions and write them as hexadecimal values without doing
any base conversion (ie 010 was copied to 0x10). After filtering
out these differences, any remaining (real) incompatibilities
have been merged into the MI header file to make them more visible.

While here, fix the termios <-> termio conversion WRT to the c_cc
field for Alpha. The termios values do not match the termio values
and thus prevents us from copying.

By eliminating the Alpha MD copy of linux_ioctl.h we also fixed
the recent build breakage caused by putting new bits in the MI
header and not in the MD header.
2001-10-19 08:18:31 +00:00
Dag-Erling Smørgrav
b51cc76c45 Add support for the "device private" ioctls soon to be used by the an driver.
Also slightly change the name translation policy - only rename interfaces
that have the IFF_BROADCAST flag set.  This is not perfect, but is closer to
how Linux names network interfaces.
2001-10-19 01:38:10 +00:00
Dag-Erling Smørgrav
55a9c3ad8f Whitespace fix. 2001-10-19 00:46:17 +00:00
Marcel Moolenaar
4c1e3817c4 Implement linux_chown and linux_lchown. The fchown syscall maps
directly to the native syscall, because no filename handling
needs to be done.

Tested by: Martin Blapp <mb@imp.ch>
2001-10-16 06:15:36 +00:00
Dag-Erling Smørgrav
8cdcad811c Try to make Linux socket ioctls work. Up until now they've only *pretended*
to work, but haven't really due to subtle differences in structs etc.

This is still not perfect (some ioctls are still known not to work, while
others haven't been tested at all), but it's enough to get Debian's ifconfig
to produce relatively sane output.

More work will be needed to get all ioctls (or at least a reasonable subset)
working, and to support the Cisco Aironet config tool mentioned in the PR.

PR:		26546
Submitted by:	Doug Ambrisko <ambrisko@ambrisko.com>
2001-10-15 20:52:17 +00:00
Marcel Moolenaar
c640a5f5f2 When casting from uid16/gid16 to uid/gid respectively, make sure
that "no change" (ie 0xFFFF) is properly cast to (int)-1 for those
syscalls that set uids and/or gids.

Verified by: LTP
2001-10-14 03:56:53 +00:00
Paul Saab
cbc89bfbfe Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loader
tunable.

Reviewed by:	peter
MFC after:	2 weeks
2001-10-10 23:06:54 +00:00
Marcel Moolenaar
9b130a99cf Remove linux_getpgid(). We map the syscall natively now.
PR: kern/21402
2001-09-28 01:40:51 +00:00
Marcel Moolenaar
ac23cf236b Swap the src and dst arguments of the bcopy added in the
previous commit. It ain't memcpy... *cough*
2001-09-28 01:15:30 +00:00
Marcel Moolenaar
b18013f823 The arg parameter is passed by value in Linux, but not in FreeBSD.
We still have to account for a copyin. Make sure the copyin will
succeed by passing the FreeBSD syscall a pointer to userspace,
albeit one that's automagically mapped into kernel space.

Reported by: mr, Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
Tested by: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
2001-09-26 05:39:59 +00:00
Maxim Sobolev
962cf4203d Fix abuse of vtagtype. In addition, after this the linux programs will be
able correctly distinguish ext2fs from the ufs filesystem (previously ext2fs
was indistinguishable from the ufs).

Reviewed by:	phk, marcel
2001-09-19 12:35:51 +00:00
Michael Reifenberger
b8febfd1f2 Add a wrapper for linux_getsid -> getsid Syscall. 2001-09-15 09:57:30 +00:00
Michael Reifenberger
a6e5348e22 Implement LINUX_[SEM|IPC]_[STAT|INFO]
to make /compat/linux/usr/bin/ipcs -s happy.

PR:		kern/29698 (part)
Reviewed by:	audit
2001-09-15 09:50:38 +00:00
Marcel Moolenaar
b7a81e06aa Fix off by one error introduced by the use of the ifnet_byindex()
macro. The commit log clearly states that the index given to the
macro is one higher than previously used to index the array. This
wasn't represented in the code and resulted in kernel page faults.

Reported by: Andrew Atrens <atrens@nortelnetworks.com>
2001-09-14 08:04:25 +00:00
John Baldwin
198faf627d Whitespace fix. 2001-09-12 22:16:18 +00:00
Julian Elischer
b40ce4165d KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after:    ha ha ha ha
2001-09-12 08:38:13 +00:00
Marcel Moolenaar
5002a60f9b Round of cleanups and enhancements. These include (in random order):
o  Introduce private types for use in linux syscalls for two reasons:
   1. establish type independence for ease in porting and,
   2. provide a visual queue as to which syscalls have proper
      prototypes to further cleanup the i386/alpha split.
   Linuxulator types are prefixed by 'l_'. void and char have not
   been "virtualized".

o  Provide dummy functions for all syscalls and remove dummy functions
   or implementations of truely obsolete syscalls.

o  Sanitize the shm*, sem* and msg* syscalls.

o  Make a first attempt to implement the linux_sysctl syscall. At this
   time it only returns one MIB (KERN_VERSION), but most importantly,
   it tells us when we need to add additional sysctls :-)

o  Bump the kenel version up to 2.4.2 (this is not the same as the
   KERN_VERSION MIB, BTW).

o  Implement new syscalls, of which most are specific to i386. Our
   syscall table is now up to date with Linux 2.4.2. Some highlights:
   -  Implement the 32-bit uid_t and gid_t bases syscalls.
   -  Implement a couple of 64-bit file size/offset bases syscalls.

o  Fix or improve numerous syscalls and prototypes.

o  Reduce style(9) violations while I'm here. Especially indentation
   inconsistencies within the same file are addressed. Re-indenting
   did not obfuscate actual changes to the extend that it could not
   be combined.

NOTE: I spend some time testing these changes and found that if there
      were regressions, they were not caused by these changes AFAICT.
      It was observed that installing a RH 7.1 runtime environment
      did make matters worse. Hangs and/or reboots have been observed
      with and without these changes, so when it failed to make life
      better in cases it doesn't look like it made it worse.
2001-09-08 19:07:04 +00:00
Jonathan Lemon
f9132cebdc Wrap array accesses in macros, which also happen to be lvalues:
ifnet_addrs[i - 1]  -> ifaddr_byindex(i)
        ifindex2ifnet[i]    -> ifnet_byindex(i)

This is intended to ease the conversion to SMPng.
2001-09-06 02:40:43 +00:00