Commit Graph

342 Commits

Author SHA1 Message Date
jhb
44b0453b59 Grab the process lock while calling psignal and before calling psignal. 2001-03-07 03:37:06 +00:00
jhb
f315adf3e2 Just hold the proc lock while getting the parent's PID rather than a
proctree lock.
2001-03-07 03:21:26 +00:00
jhb
6b3e8d1743 - Hold both an exclusive proctree lock and the proc lock when reparenting
a traced process during exit.
- Lock the parent process while sending it SIGCHLD.
2001-03-07 02:17:43 +00:00
jlemon
5e247a977d Only pick up so_error the first time through with EISCONN, as advertised.
The sense of the test was reversed, so we were returning EISCONN, then 0.

Pointed out and tested by: Martin Blapp <mb@imp.ch>
2001-03-02 19:29:53 +00:00
jlemon
8b825e95f3 Correctly emulate linux_connect. For nonblocking sockets, the behavior
is to return EINPROGRESS, EALREADY, (so_error ONCE), EISCONN.  Certain
linux applications rely on the so_error (normally 0) being returned in
order to operate properly.

Tested by:	Thomas Moestl <tmoestl@gmx.net>
2001-03-01 21:44:40 +00:00
adrian
8650fa6cdb Reviewed by: jlemon
An initial tidyup of the mount() syscall and VFS mount code.

This code replaces the earlier work done by jlemon in an attempt to
make linux_mount() work.

* the guts of the mount work has been moved into vfs_mount().

* move `type', `path' and `flags' from being userland variables into being
  kernel variables in vfs_mount(). `data' remains a pointer into
  userspace.

* Attempt to verify the `type' and `path' strings passed to vfs_mount()
  aren't too long.

* rework mount() and linux_mount() to take the userland parameters
  (besides data, as mentioned) and pass kernel variables to vfs_mount().
  (linux_mount() already did this, I've just tidied it up a little more.)

* remove the copyin*() stuff for `path'. `data' still requires copyin*()
  since its a pointer into userland.

* set `mount->mnt_statf_mntonname' in vfs_mount() rather than in each
  filesystem.  This variable is generally initialised with `path', and
  each filesystem can override it if they want to.

* NOTE: f_mntonname is intiailised with "/" in the case of a root mount.
2001-03-01 21:00:17 +00:00
obrien
1994d0af7f MFS: bring the consistent `compat_3_brand' support into -CURRENT
(the work was first done in the RELENG_4 branch near a release
	 during a MFC to make the code cleaner and more consistent)
2001-02-24 22:20:11 +00:00
rwatson
d221b0006a o Move per-process jail pointer (p->pr_prison) to inside of the subject
credential structure, ucred (cr->cr_prison).
o Allow jail inheritence to be a function of credential inheritence.
o Abstract prison structure reference counting behind pr_hold() and
  pr_free(), invoked by the similarly named credential reference
  management functions, removing this code from per-ABI fork/exit code.
o Modify various jail() functions to use struct ucred arguments instead
  of struct proc arguments.
o Introduce jailed() function to determine if a credential is jailed,
  rather than directly checking pointers all over the place.
o Convert PRISON_CHECK() macro to prison_check() function.
o Move jail() function prototypes to jail.h.
o Emulate the P_JAILED flag in fill_kinfo_proc() and no longer set the
  flag in the process flags field itself.
o Eliminate that "const" qualifier from suser/p_can/etc to reflect
  mutex use.

Notes:

o Some further cleanup of the linux/jail code is still required.
o It's now possible to consider resolving some of the process vs
  credential based permission checking confusion in the socket code.
o Mutex protection of struct prison is still not present, and is
  required to protect the reference count plus some fields in the
  structure.

Reviewed by:	freebsd-arch
Obtained from:	TrustedBSD Project
2001-02-21 06:39:57 +00:00
jlemon
c50375af66 Allow debugging output to be controlled on a per-syscall granularity.
Also clean up debugging output in a slightly more uniform fashion.

The default behavior remains the same (all debugging output is turned on)
2001-02-16 16:40:43 +00:00
jlemon
f14626c607 Add mount syscall to linux emulation. Also improve emulation of reboot. 2001-02-16 14:42:11 +00:00
bmilekic
e67bcfcaf3 Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:

mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)

similarily, for releasing a lock, we now have:

mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.

The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.

Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:

MTX_QUIET and MTX_NOSWITCH

The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:

mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.

Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.

Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.

Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.

Finally, caught up to the interface changes in all sys code.

Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
asmodai
79d2ee04e3 Fix typo: seperate -> separate.
Seperate does not exist in the english language.
2001-02-06 11:21:58 +00:00
asmodai
2023a68909 Fix typo: wierd -> weird.
There is no such thing as wierd in the english language.
2001-02-06 09:25:10 +00:00
jhb
6f36272449 Back out proc locking to protect p_ucred for obtaining additional
references along with the actual obtaining of additional references.
2001-01-27 00:01:31 +00:00
jhb
12f0c46097 - Back out over-aggressive locking of p->p_cred.
- Back out locking ucred's and bumping refcounts for vnode operations.
2001-01-26 23:54:40 +00:00
jhb
6a6543f69a Use queue macros. 2001-01-24 00:01:42 +00:00
jhb
3ebca2f4c3 - Proc locking.
- Use queue macros.
- Use NULL instead of 0 for pointers.

Reviewed by:	des
2001-01-23 22:13:07 +00:00
jhb
55e163980d Argh, atomic_store_rel -> atomic_store_rel_int. 2001-01-23 21:40:07 +00:00
jhb
b12abb0009 Woops, add in missing headers. 2001-01-23 21:39:15 +00:00
jhb
a3ac657f1f Proc locking. 2001-01-23 21:33:55 +00:00
jhb
7e8797a19c Use queue macros. 2001-01-23 21:32:02 +00:00
jhb
c339c345f5 - Add proc locking.
- Fix several bugs in the wait syscall, including freeing the actual
  proc start, freeing the args, freeing the prison, and other minor
  nits.
- Use appropriate queue(3) macros.
- Use zpfind() instead of walking zombproc ourselves.
2001-01-23 21:30:25 +00:00
jhb
a6a7540093 - Use proper atomic operations to make the run time initialization
controlled by svr_str_initialized be MP safe.
2001-01-23 21:07:16 +00:00
jhb
9dcfcfc840 FreeBSD doesn't have p_emuldata, and our stackgap_init() doesn't take an
argument.
2001-01-23 21:02:44 +00:00
jhb
ec1d1e9e28 Use proc lock to safely obtain references to p_ucred before vnode
operations.
2001-01-23 20:52:50 +00:00
jhb
729766c296 Protect calcru() with sched_lock. 2001-01-23 20:50:40 +00:00
takawata
0d758740be Map BSS section in PECOFF executable.
Submitted by:	 KUROSAWA Takahiro <fwkg7679@mb.infoweb.ne.jp>
2001-01-23 16:19:37 +00:00
wollman
603fb7f029 Finish deprecating <sys/select.h> in favor of <sys/selinfo.h> in kernel code. 2001-01-20 02:24:07 +00:00
joe
d73659400d Instead of hard coding the major numbers for IDE and SCSI disks
look in the device's cdevsw for the D_DISK flag.
2001-01-14 23:33:50 +00:00
jake
2cfc65e106 Protect proc.p_pptr with the proctree lock. 2001-01-10 15:41:26 +00:00
green
7afbe44fc0 Take 10 seconds to actually fix the chgproccnt rather than just make it
explicitly error.  If the module is horribly broken, it should be
temporarily removed from src/sys/modules.
2001-01-09 04:55:37 +00:00
wollman
8456343ffc With some trepidation, add a `#error' directive to this module. It was
broken and not fixed by whoever changed the interface of chgproccnt();
in the state it is in it could not possibly work (dereferencing an integer).
2001-01-09 04:27:09 +00:00
paul
5f23d12edc Map FreeBSD character device hard disks to Linux block device hard disks.
This fixes the problem with VMWARE not being able to use raw disks.
2000-12-29 00:44:42 +00:00
jake
2a7c5bd038 Protect proc.p_pptr and proc.p_children/p_sibling with the
proctree_lock.

linprocfs not locked pending response from informal maintainer.

Reviewed by:	jhb, -smp@
2000-12-23 19:43:10 +00:00
takawata
9935fe89e0 Add PECOFF (WIN32 Execution file format) support.
To use it, some dll is needed. And currently, the dll is only for NetBSD.
So one more kernel module is needed.
For more infomation,
http://chiharu.haun.org/peace/ .

Reviewed by:	bp
2000-12-20 12:51:08 +00:00
assar
8315fb22d1 translate the flags in recvfrom and recvmsg from linux to bsd ones
Approved by:	marcel
2000-12-19 00:24:25 +00:00
jhb
f7995323db Lock access to proc members.
Glanced over by:	marcel
2000-12-15 19:41:27 +00:00
des
1a07b2fbc9 Use kinfo_proc instead of eproc (which Kirk deep-sixed earlier this week)
Generate a version string that looks just like a real Linux one - almost :)

Use sbufs everywhere instead of sprintf(). Note that this is still imperfect,
as the code does not check whether the sbuf overflowed - but it'll still
work better than before, since if the sbuf overflows, the code now simply
copies out 0 bytes instead of causing a trap (or worse, corrupting kernel
structures)
2000-12-13 20:22:24 +00:00
des
5a046c3b64 Add dependency on linux, which is needed for proc/version. 2000-12-13 20:19:06 +00:00
jake
642b119420 Lock the allproc list.
Approved by:	DES
2000-12-13 09:05:45 +00:00
jake
518b4c0aea - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), instead
of explicit calls to lockmgr.  Also provides macros for the flags
  pased to specify shared, exclusive or release which map to the
  lockmgr flags.  This is so that the use of lockmgr can be easily
  replaced with optimized reader-writer locks.
- Add some locking that I missed the first time.
2000-12-13 00:17:05 +00:00
des
582cf6df76 Point #includes at compat/linprocfs instead of i386/linux/linprocfs. 2000-12-12 22:06:05 +00:00
des
92bedf9d12 Add proc/<pid>/cmdline. 2000-12-09 16:20:48 +00:00
des
3207db6509 Add a dependency on procfs. 2000-12-09 16:20:35 +00:00
des
73d8342016 A bunch of fixes that have been rotting in my tree for a month or two
waiting for procfs to get fixed:

  - Use fill_eproc() to obtain correct VM stats. Attempt to compute VmLib.

  - Fill some more fields in proc/<pid>/stat, and add four (unimplemented)
    fields after studying a recent Linux kernel.

  - Compute CPU frequency only once instead of twice.

  - Fix some comments that were OBE.

  - Fix indentation except where it makes the code less readable.
2000-12-09 13:25:54 +00:00
marcel
ae80563f38 Remove call to bzero after MALLOC and instead add M_ZERO
to MALLOC.
2000-12-05 06:44:22 +00:00
marcel
131c610840 Include machine/cpu.h for cpu_getstack().
Spotted by: jake
2000-12-03 01:56:15 +00:00
marcel
3e304e6b3a Don't auto-generate the syscalls. 2000-12-03 01:30:31 +00:00
jhb
d7d51daa94 Protect access to p_stat with sched_lock. 2000-12-01 06:34:19 +00:00
marcel
519f275c1f Don't use p->p_sigstk.ss_flags to keep state of whether the
process is on the alternate stack or not. For compatibility
with sigstack(2) state is being updated if such is needed.

We now determine whether the process is on the alternate
stack by looking at its stack pointer. This allows a process
to siglongjmp from a signal handler on the alternate stack
to the place of the sigsetjmp on the normal stack. When
maintaining state, this would have invalidated the state
information and causing a subsequent signal to be delivered
on the normal stack instead of the alternate stack.

PR: 22286
2000-11-30 05:23:49 +00:00