summaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_misc.c
Commit message (Collapse)AuthorAgeFilesLines
* Rework how we store process times in the kernel such that we always storeJohn Baldwin2004-10-051-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month Notes: svn path=/head/; revision=136152
* Fix the 'DEBUG' argument code to unbreak the amd64 LINT build.David E. O'Brien2004-08-161-2/+2
| | | | Notes: svn path=/head/; revision=133845
* Fix the 'DEBUG' argument code to unbreak the LINT build.David E. O'Brien2004-08-161-2/+2
| | | | Notes: svn path=/head/; revision=133840
* Changes to MI Linux emulation code necessary to run 32-bit Linux binariesTim J. Robbins2004-08-161-6/+29
| | | | | | | | | | | | | | | | | | on AMD64, and the general case where the emulated platform has different size pointers than we use natively: - declare certain structure members as l_uintptr_t and use the new PTRIN and PTROUT macros to convert to and from native pointers. - declare some structures __packed on amd64 when the layout would differ from that used on i386. - include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h> if compiling with COMPAT_LINUX32. This will need to be revisited before 32-bit and 64-bit Linux emulation support can coexist in the same kernel. - other small scattered changes. This should be a no-op on i386 and Alpha. Notes: svn path=/head/; revision=133816
* Replace linux_getitimer() and linux_setitimer() with implementationsTim J. Robbins2004-08-151-24/+77
| | | | | | | | based on those in freebsd32_misc.c, removing the assumption that Linux uses the same layout for struct itimerval as we use natively. Notes: svn path=/head/; revision=133749
* Avoid assuming that l_timeval is the same as the native struct timevalTim J. Robbins2004-08-151-2/+7
| | | | | | | in linux_select(). Notes: svn path=/head/; revision=133747
* Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL. This isColin Percival2004-07-261-1/+1
| | | | | | | | | | | | | | somewhat clearer, but more importantly allows for a consistent naming scheme for suser_cred flags. The old name is still defined, but will be removed in a few days (unless I hear any complaints...) Discussed with: rwatson, scottl Requested by: jhb Notes: svn path=/head/; revision=132653
* Deorbit COMPAT_SUNOS.Poul-Henning Kamp2004-06-111-1/+1
| | | | | | | | We inherited this from the sparc32 port of BSD4.4-Lite1. We have neither a sparc32 port nor a SunOS4.x compatibility desire these days. Notes: svn path=/head/; revision=130344
* - Replace wait1() with a kern_wait() function that accepts the pid,John Baldwin2004-03-171-32/+15
| | | | | | | | | | | | | | | | | | options, status pointer and rusage pointer as arguments. It is up to the caller to copyout the status and rusage to userland if needed. This lets us axe the 'compat' argument and hide all that functionality in owait(), by the way. This also cleans up some locking in kern_wait() since it no longer has to drop locks around copyout() since all the copyout()'s are deferred. - Convert owait(), wait4(), and the various ABI compat wait() syscalls to use kern_wait() rather than wait1() or wait4(). This removes a bit more stackgap usage. Tested on: i386 Compiled on: i386, alpha, amd64 Notes: svn path=/head/; revision=127140
* Locking for the per-process resource limits structure.John Baldwin2004-02-041-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64 Notes: svn path=/head/; revision=125454
* Lock the traversal of the vm object list. Use TAILQ_FOREACH consistently.Alan Cox2004-01-021-2/+3
| | | | Notes: svn path=/head/; revision=124082
* Pull latest changes from OpenBSD:Maxim Sobolev2003-11-161-3/+13
| | | | | | | | | | | | | | - improve sysinfo(2) syscall; - add dummy fadvise64(2) syscall; - add dummy *xattr(2) family of syscalls; - add protos for the syscalls 222-225, 238-249 and 253-267; - add exit_group(2) syscall, which is currently just wired to exit(2). Obtained from: OpenBSD MFC after: 2 weeks Notes: svn path=/head/; revision=122802
* Reject negative ngrp arguments in linux_setgroups() and linux_setgroups16();Tim J. Robbins2003-10-211-1/+1
| | | | | | | | stops users being able to cause setgroups to clobber the kernel stack by copying in data past the end of the linux_gidset array. Notes: svn path=/head/; revision=121302
* Restored a non-egregious cast so that this file compiles on i386'sBruce Evans2003-09-071-1/+1
| | | | | | | | | | | | | | | | with 64-bit longs again. This was fixed in rev.1.42 but the fix rotted non-fatally in rev.1.105 and fatally in rev.1.137. Many more non-egregrious casts are strictly required for conversions from semi-opaque types to pointers, but we avoid most of them by using types that are almost certain to be compatible with uintptr_t for representing pointers (e.g., vm_offset_t). Here we don't really want the u_longs, but we have them because a.out.h and its support code doesn't use typedefs (it uses unsigned in V7 and unsigned long in FreeBSD) and is too obsolete to fix now. Notes: svn path=/head/; revision=119839
* Try to make 'uname -a' look more like it does on Linux:Dag-Erling Smørgrav2003-07-291-0/+30
| | | | | | | | | | | | | - cut the version string at the newline, suppressing information about who built the kernel and in what directory. Most of this information was already lost to truncation. - on i386, return the precise CPU class (if known) rather than just "i386". Linux software which uses this information to select which binary to run often does not know what to make of "i386". Notes: svn path=/head/; revision=118149
* Add a "int fd" argument to VOP_OPEN() which in the future willPoul-Henning Kamp2003-07-261-1/+1
| | | | | | | | | | | | contain the filedescriptor number on opens from userland. The index is used rather than a "struct file *" since it conveys a bit more information, which may be useful to in particular fdescfs and /dev/fd/* For now pass -1 all over the place. Notes: svn path=/head/; revision=118047
* Add a new function swap_pager_status() which reports the total size of thePoul-Henning Kamp2003-07-181-8/+4
| | | | | | | | | | paging space and how much of it is in use (in pages). Use this interface from the Linuxolator instead of groping around in the internals of the swap_pager. Notes: svn path=/head/; revision=117723
* Use __FBSDID().David E. O'Brien2003-06-101-2/+3
| | | | Notes: svn path=/head/; revision=116173
* Deprecate machine/limits.h in favor of new sys/limits.h.Alexander Kabaev2003-04-291-2/+1
| | | | | | | | | | Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com> Notes: svn path=/head/; revision=114216
* Use local struct proc variables to reduce repeated td->td_proc dereferencesJohn Baldwin2003-04-171-10/+14
| | | | | | | and improve readability. Notes: svn path=/head/; revision=113613
* Explicitly cast a l_ulong to an unsigned long to make all arch's happyJohn Baldwin2003-04-161-1/+1
| | | | | | | with the printf format. Notes: svn path=/head/; revision=113579
* Fix printf format in a debug printf.John Baldwin2003-04-161-1/+1
| | | | Notes: svn path=/head/; revision=113577
* - Change the linux_[gs]et_os{name, release, s_version}() functions toJohn Baldwin2003-03-131-2/+2
| | | | | | | | | | | | | | | | take a thread instead of a proc for their first argument. - Add a mutex to protect the system-wide Linux osname, osrelease, and oss_version variables. - Change linux_get_prison() to take a thread instead of a proc for its first argument and to use td_ucred rather than p_ucred. This is ok because a thread's prison does not change even though it's ucred might. - Also, change linux_get_prison() to return a struct prison * instead of a struct linux_prison * since it returns with the struct prison locked and this makes it easier to safely unlock the prison when we are done messing with it. Notes: svn path=/head/; revision=112206
* Clean up whitespace and remove register keyword.Dag-Erling Smørgrav2003-03-031-7/+7
| | | | Notes: svn path=/head/; revision=111798
* More caddr_t removal, in conjunction with copy{in,out}(9) this time.Dag-Erling Smørgrav2003-03-031-24/+19
| | | | | | | Also clean up some egregious casts and incorrect use of sizeof. Notes: svn path=/head/; revision=111797
* Use the proc lock to protect p_realtimer instead of Giant, and obtainTim J. Robbins2003-02-171-3/+2
| | | | | | | | | sched_lock around accesses to p_stats->p_timer[] to avoid a potential race with hardclock. getitimer(), setitimer() and the realitexpire() callout are now Giant-free. Notes: svn path=/head/; revision=111034
* Obtain proc lock around modification of p_siglist in linux_wait4().Tim J. Robbins2003-02-141-0/+2
| | | | Notes: svn path=/head/; revision=110848
* - Use strlcpy() rather than strncpy() to copy NUL terminatedRobert Drehmel2002-10-171-6/+6
| | | | | | | | strings. - Pass the correct buffer size to getcredhostname(). Notes: svn path=/head/; revision=105359
* Back our kernel support for reliable signal queues.Juli Mallett2002-10-011-2/+1
| | | | | | | Requested by: rwatson, phk, and many others Notes: svn path=/head/; revision=104306
* First half of implementation of ksiginfo, signal queues, and such. ThisJuli Mallett2002-09-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | gets signals operating based on a TailQ, and is good enough to run X11, GNOME, and do job control. There are some intricate parts which could be more refined to match the sigset_t versions, but those require further evaluation of directions in which our signal system can expand and contract to fit our needs. After this has been in the tree for a while, I will make in kernel API changes, most notably to trapsignal(9) and sendsig(9), to use ksiginfo more robustly, such that we can actually pass information with our (queued) signals to the userland. That will also result in using a struct ksiginfo pointer, rather than a signal number, in a lot of kern_sig.c, to refer to an individual pending signal queue member, but right now there is no defined behaviour for such. CODAFS is unfinished in this regard because the logic is unclear in some places. Sponsored by: New Gold Technology Reviewed by: bde, tjr, jake [an older version, logic similar] Notes: svn path=/head/; revision=104233
* - Hold the vn lock over vm_mmap().Jeff Roberson2002-09-251-4/+4
| | | | Notes: svn path=/head/; revision=103941
* Pass flags to msync() accounting for differences in the definition ofMatthew N. Dodd2002-09-191-1/+5
| | | | | | | | | MS_SYNC on FreeBSD and Linux. Submitted by: Christian Zander <zander@minion.de> Notes: svn path=/head/; revision=103652
* Do not cast from a pointer to an integer of a possibly different size.Bruce Evans2002-09-051-1/+1
| | | | | | | This fixes a warning on i386's with 64-bit longs. Notes: svn path=/head/; revision=102963
* Include <sys/malloc.h> instead of depending on namespace pollution 2Bruce Evans2002-09-051-5/+4
| | | | | | | | | layers deep in <sys/proc.h> or <sys/vnode.h>. Removed unused includes. Sorted includes. Notes: svn path=/head/; revision=102954
* Use the new kern_* functions to avoid the need to store argumentsIan Dowse2002-09-011-90/+57
| | | | | | | | | | | in the stack gap. This converts most VFS and signal related system calls, as well as select(). Discussed on: -arch Approved by: marcel Notes: svn path=/head/; revision=102814
* - Replace v_flag with v_iflag and v_vflagJeff Roberson2002-08-041-1/+2
| | | | | | | | | | | | | | | | | | - v_vflag is protected by the vnode lock and is used when synchronization with VOP calls is needed. - v_iflag is protected by interlock and is used for dealing with vnode management issues. These flags include X/O LOCK, FREE, DOOMED, etc. - All accesses to v_iflag and v_vflag have either been locked or marked with mp_fixme's. - Many ASSERT_VOP_LOCKED calls have been added where the locking was not clear. - Many functions in vfs_subr.c were restructured to provide for stronger locking. Idea stolen from: BSD/OS Notes: svn path=/head/; revision=101308
* Introduce support for Mandatory Access Control and extensibleRobert Watson2002-08-011-1/+8
| | | | | | | | | | | | | | | kernel access control. Invoke appropriate MAC entry points for a number of VFS-related operations in the Linux ABI module. In particular, handle uselib in a manner similar to open() (more work is probably needed here), as well as handle statfs(), and linux readdir()-like calls. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=101189
* Add a comment about how we should use vn_open() here instead of directlyRobert Watson2002-06-141-0/+4
| | | | | | | | invoking VOP_OPEN(). This would reduce code redundancy with the rest of the kernel, and also is required for MAC to work properly. Notes: svn path=/head/; revision=98209
* Fix typo in the BSD copyright: s/withough/without/Jens Schweikhardt2002-06-021-1/+1
| | | | | | | | Spotted and suggested by: des MFC after: 3 weeks Notes: svn path=/head/; revision=97748
* Zap some stale unused headers, including one machine/psl.h (which isPeter Wemm2002-05-011-6/+0
| | | | | | | a stub on alpha). Compile tested on alpha and x86. Notes: svn path=/head/; revision=95837
* Add an XXX: linux_uselib() should be using vn_open() rather than invokingRobert Watson2002-04-201-0/+4
| | | | | | | | | | | | | | VOP_OPEN() and doing lots of manual checking. This would further centralize use of the name functions, and once the MAC code is integrated, meaning few extraneous MAC checks scattered all over the place. I don't have time to fix this now, but want to make sure it doesn't get forgotten. Anyone interested in fixing this should feel free. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=95130
* Rework logic of syscalls that modify process credentials as described inJohn Baldwin2002-04-131-13/+19
| | | | | | | rev 1.152 of sys/kern/kern_prot.c. Notes: svn path=/head/; revision=94621
* Use td_ucred in a few spots.John Baldwin2002-04-111-3/+3
| | | | Notes: svn path=/head/; revision=94454
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-04-011-1/+1
| | | | | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@ Notes: svn path=/head/; revision=93593
* Remove references to vm_zone.h and switch over to the new uma API.Jeff Roberson2002-03-201-1/+0
| | | | Notes: svn path=/head/; revision=92787
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-3/+3
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* Use the updated getcredhostname() function.Robert Drehmel2002-02-271-2/+1
| | | | Notes: svn path=/head/; revision=91392
* Use the getcredhostname function to fill the hostname intoRobert Drehmel2002-02-271-1/+3
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=91385
* Linux/alpha uses the same BSDish return mechanism we do forAndrew Gallatin2002-01-231-0/+4
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=89717
* o Introduce pr_mtx into struct prison, providing protection for theRobert Watson2001-12-031-3/+4
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=87275