Commit Graph

441 Commits

Author SHA1 Message Date
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
Seigo Tanimura
af46379bcb Lock the caller process if the pid passed to getsid() or getpgid()
equals to zero.
2002-01-19 06:34:58 +00:00
Seigo Tanimura
a6fccfb5f2 For getsid(), return the sid stored in struct session. This prevents
panic in case where a session has no session leader.

Inspired by:	Solaris 8
2002-01-19 05:31:51 +00:00
Alfred Perlstein
441e1e6a49 Make compile, remove extra fdrop() calls.
Change name of function to what it's supposed to be (s/sys/do)
2002-01-19 03:52:17 +00:00
Alfred Perlstein
7e9aab77c5 make compile, add missing { and variable declaration. 2002-01-19 03:48:38 +00:00
Alfred Perlstein
083f6f9711 Semi-backout previous fgetvp change, we need the struct file pointer
to perform relative offset calculations, so use fget instead.
2002-01-19 03:45:14 +00:00
Alfred Perlstein
8868a7d8a2 fix typo, there's uap, just fd 2002-01-16 01:31:19 +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
da10530228 Some of the KSE stuff was accidentally reverted by file locking,
fix it.

Pointed out by: jhb
2002-01-13 12:07:15 +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
Mike Smith
0f04c2b207 Gut this header; since physio_proc_init is never called, the code never does
anything more than multiply declare some unused variables.
2002-01-08 10:26:44 +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
Dag-Erling Smørgrav
157b65ae7f Pull in more stuff from procfs now that it's been pseudofsized. 2001-12-09 00:38:59 +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
Matthew Dillon
b1e4abd246 Give struct socket structures a ref counting interface similar to
vnodes.  This will hopefully serve as a base from which we can
expand the MP code.  We currently do not attempt to obtain any
mutex or SX locks, but the door is open to add them when we nail
down exactly how that part of it is going to work.
2001-11-17 03:07:11 +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
Matthew Dillon
59ea846905 promote tv_sec in printf to make it type agnostic 2001-10-29 02:17:41 +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
Poul-Henning Kamp
71ab1fa5df Reporting device drivers by traversing cdevsw[] is at best a hack
which may or may not return something which is partially right.

Disable the "devices" file until we find out what this is needed for,
and what exactly those apps need.

This will allow cdevsw to become static again.

Approved by:	DES
2001-10-26 15:30:44 +00:00
Dag-Erling Smørgrav
7936569b00 Add proc/mtab which simulates a Linux system's /etc/mtab. 2001-10-21 15:56:46 +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
a55f7148f1 #if 0 out some code that depends on other uncommitted patches. 2001-10-19 01:52:13 +00:00
Dag-Erling Smørgrav
1c0bfd6e3a Adapt to pseudofs changes (dynamic initialization, not static).
Use the new linux_ifname() function from the linuxulator rather than roll
our own interface name translation.
2001-10-19 01:45:03 +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
John Baldwin
7106ca0d1a Add missing includes of sys/lock.h. 2001-10-11 17:52:20 +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
Dag-Erling Smørgrav
e4fea9d1dd Catch up with the visibility callback stuff, and give up trying to keep the
file definitions on single lines.
2001-10-01 04:31:05 +00:00
Dag-Erling Smørgrav
a73a153aff Specify readability and / or writeability for all nodes that need it. 2001-09-30 19:42:41 +00:00
Dag-Erling Smørgrav
2bb3ce0c47 Adapt to pseudofs version 2. Sorry about the breakage - I had this ready
to commit along with the pseudofs patches, but just plain forgot.
2001-09-29 22:07:13 +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