summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_misc.c
Commit message (Collapse)AuthorAgeFilesLines
* Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loaderps2001-10-101-1/+1
| | | | | | | tunable. Reviewed by: peter MFC after: 2 weeks
* Remove linux_getpgid(). We map the syscall natively now.marcel2001-09-281-21/+0
| | | | PR: kern/21402
* Add a wrapper for linux_getsid -> getsid Syscall.mr2001-09-151-0/+8
|
* KSE Milestone 2julian2001-09-121-106/+110
| | | | | | | | | | | | | | 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
* Round of cleanups and enhancements. These include (in random order):marcel2001-09-081-652/+657
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Added the linux_sysinfo function to implement sysinfo(2).pirzyk2001-07-231-0/+76
| | | | | | | PR: kern/27759 Reviewed by: marcel Approved by: marcel MFC after: 1 week
* Fix warning:peter2001-06-151-1/+1
| | | | 413: warning: long unsigned int format, vm_offset_t arg (arg 2)
* o Merge contents of struct pcred into struct ucred. Specifically, add therwatson2001-05-251-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | real uid, saved uid, real gid, and saved gid to ucred, as well as the pcred->pc_uidinfo, which was associated with the real uid, only rename it to cr_ruidinfo so as not to conflict with cr_uidinfo, which corresponds to the effective uid. o Remove p_cred from struct proc; add p_ucred to struct proc, replacing original macro that pointed. p->p_ucred to p->p_cred->pc_ucred. o Universally update code so that it makes use of ucred instead of pcred, p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo, cr_{r,sv}{u,g}id instead of p_*, etc. o Remove pcred0 and its initialization from init_main.c; initialize cr_ruidinfo there. o Restruction many credential modification chunks to always crdup while we figure out locking and optimizations; generally speaking, this means moving to a structure like this: newcred = crdup(oldcred); ... p->p_ucred = newcred; crfree(oldcred); It's not race-free, but better than nothing. There are also races in sys_process.c, all inter-process authorization, fork, exec, and exit. o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid; remove comments indicating that the old arrangement was a problem. o Restructure exec1() a little to use newcred/oldcred arrangement, and use improved uid management primitives. o Clean up exit1() so as to do less work in credential cleanup due to pcred removal. o Clean up fork1() so as to do less work in credential cleanup and allocation. o Clean up ktrcanset() to take into account changes, and move to using suser_xxx() instead of performing a direct uid==0 comparision. o Improve commenting in various kern_prot.c credential modification calls to better document current behavior. In a couple of places, current behavior is a little questionable and we need to check POSIX.1 to make sure it's "right". More commenting work still remains to be done. o Update credential management calls, such as crfree(), to take into account new ruidinfo reference. o Modify or add the following uid and gid helper routines: change_euid() change_egid() change_ruid() change_rgid() change_svuid() change_svgid() In each case, the call now acts on a credential not a process, and as such no longer requires more complicated process locking/etc. They now assume the caller will do any necessary allocation of an exclusive credential reference. Each is commented to document its reference requirements. o CANSIGIO() is simplified to require only credentials, not processes and pcreds. o Remove lots of (p_pcred==NULL) checks. o Add an XXX to authorization code in nfs_lock.c, since it's questionable, and needs to be considered carefully. o Simplify posix4 authorization code to require only credentials, not processes and pcreds. Note that this authorization, as well as CANSIGIO(), needs to be updated to use the p_cansignal() and p_cansched() centralized authorization routines, as they currently do not take into account some desirable restrictions that are handled by the centralized routines, as well as being inconsistent with other similar authorization instances. o Update libkvm to take these changes into account. Obtained from: TrustedBSD Project Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-6/+8
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* o Change a suser() call to a suser_xxx(..., PRISON_ROOT) call in therwatson2001-04-241-1/+1
| | | | | | | | | | linuxulator so as to allow privileged processes within a jail() to invoke the Linux initgroups() system call. This allows the Linux "su" to work properly (better) when running a complete Linux environment under jail(). This problem was reported by Attila Nagy <bra@fsn.hu>. Reviewed by: marcel
* Change the pfind() and zpfind() functions to lock the process that theyjhb2001-04-241-2/+3
| | | | | | find before releasing the allproc lock and returning. Reviewed by: -smp, dfr, jake
* Add linux_sched_get_priority_max() and linux_sched_get_priority_min(): Thealc2001-04-011-0/+56
| | | | policy parameter requires translation.
* fix linux_times() to take into account linux's value of CLK_TCK on the alpha.gallatin2001-03-231-0/+5
| | | | | | Previously, results were off by a factor of 10 Tested by: Yoriaki FUJIMORI <fujimori@grafin.fujimori.cache.waseda.ac.jp>
* Allow debugging output to be controlled on a per-syscall granularity.jlemon2001-02-161-49/+72
| | | | | | Also clean up debugging output in a slightly more uniform fashion. The default behavior remains the same (all debugging output is turned on)
* Add mount syscall to linux emulation. Also improve emulation of reboot.jlemon2001-02-161-0/+20
|
* Change and clean the mutex lock interface.bmilekic2001-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Back out proc locking to protect p_ucred for obtaining additionaljhb2001-01-271-17/+5
| | | | references along with the actual obtaining of additional references.
* Protect calcru() with sched_lock.jhb2001-01-231-0/+2
|
* Lock access to proc members.jhb2000-12-151-5/+20
| | | | Glanced over by: marcel
* Don't auto-generate the syscalls.marcel2000-12-031-4/+0
|
* Use callout_reset instead of timeout(9). Most callouts are staticallyjake2000-11-271-2/+2
| | | | | | allocated, 2 have been added to struct proc for setitimer and sleep. Reviewed by: jhb, jlemon
* Revert auto-generation. The Alpha port is broken.marcel2000-11-101-0/+4
| | | | Syncing with it is wrong.
* Sync with Alpha:marcel2000-11-091-4/+0
| | | | | Do not use sysent.c, proto.h and syscall.h in source tree; use auto-generated versions.
* The MI/MD split wasn't perfect and the MI files need hacks for theobrien2000-11-011-7/+33
| | | | | | AlphaLinux compat bits. This will be better cleaned up soon. Agreed to what ever was necessary by: marcel
* Fix bug in previous commit. We need to trim the limits to fitmarcel2000-08-261-0/+5
| | | | | the datatype (= long). Use ULONG_MAX and LONG_MAX to avoid creating MD code.
* Re-implement linux_{g|s}etrlimit in terms of {g|s}etrlimitmarcel2000-08-261-24/+45
| | | | | instead of the o{g|s}etrlimit so that the dependency on COMPAT_43 is removed.
* Update include directives.marcel2000-08-221-381/+5
| | | | | | | | Move linux_select to MD code (i386 compat. syscall). Move linux_fork, linux_vfork, linux_clone, linux_mmap, linux_pipe, linux_ioperm, linux_iopl and linux_modify_ldt to MD code.
* Add bounds checking to stackgap_alloc. Previously it was possiblemarcel2000-07-231-0/+2
| | | | | | | | | | | to construct a path that was long enough (ie longer than SPARE_USRSPACE bytes) and trash the stack. Note that SPARE_USRSPACE is much smaller than MAXPATHLEN so that the Linuxulator will now return ENAMETOOLONG even if the path is smaller than MAXPATHLEN. PR: 12749
* Revert implementation of setfsuid and setfsgid due to securitymarcel2000-07-201-20/+0
| | | | | | | issues. Requested by: rwatson Backed by: kris
* Implement setfsuid and setfsgid. Implementation derived from patchmarcel2000-07-161-0/+20
| | | | | | | in PR. PR: 16993 Submitted by: Bjoern Groenvall <bg@sics.se>
* Linux allows to mmap annonymous with a file descriptor passed, FreeBSDcracauer2000-06-151-2/+10
| | | | | | | | | | | | 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
* Remove unneeded #include <vm/vm_zone.h>phk2000-04-301-1/+0
| | | | Generated by: src/tools/tools/kerninclude
* Fix bug in linux_wait4 and linux_waitpid where garbage in the statusmarcel2000-03-091-0/+2
| | | | | | | | argument could panic the kernel. Submitted by: Ian Dowse <iedowse@maths.tcd.ie> Prompted by: jkh, gallatin Approved by: prompters
* Introduce NDFREE (and remove VOP_ABORTOP)eivind1999-12-151-0/+6
|
* useracc() the prequel:phk1999-10-291-1/+0
| | | | | | | | | | | 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.
* sigset_t change (part 4 of 5)marcel1999-09-291-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ----------------------------- 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.
* Implement linux_ioperm() syscall. Fix linux_iopl() to use the level argument.luoqi1999-09-221-6/+25
| | | | | | SVGAlib should now work. Reviewed by: marcel
* I missed the namechange of field desc in struct i386_ldt_args into descs whilemarcel1999-09-031-2/+2
| | | | | | reviewing luoqi's changes... Pointed out by: luoqi
* Implementation of the modify_ldt syscall. Use the sysarch() interface to domarcel1999-09-021-0/+84
| | | | | | | 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
* Fix a missing '-1' in the size argument of copyout in getgroups. Spotted whilemarcel1999-08-291-6/+6
| | | | reviewing the MFC in -stable.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Add sysctl variables for the Linuxulator. These reside under `compat.linux' asmarcel1999-08-271-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix {g|s}etgroups semantics. We use cr_groups[0] to hold egid. This means thatmarcel1999-08-251-53/+70
| | | | | | | | | 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
* Change all UNIMPL syscalls to STD and add them to linux_dummy. Now we alwaysmarcel1999-08-251-28/+14
| | | | | | | | | | | | 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.
* Fix bug in the debug-printf of the vfork syscall, where the format specifiermarcel1999-08-171-24/+24
| | | | | | | | | | 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
* Implement linux_vfork() syscall by calling vfork(). Analogous to themarcel1999-08-161-1/+18
| | | | linux_fork() implementation.
* Provide wrappers for sched_{s|g}etscheduler. We need to convert the policymarcel1999-08-151-1/+65
| | | | | | | argument. PR: 12006 Originator: Jean-Claude MICHOT <jcmichot@teaser.fr>
* Include opt_compat.h so that COMPAT_43 is defined. This gives us the propermarcel1999-08-151-10/+15
| | | | | | | 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
* Do not map {s|g}etrlimit onto FreeBSD syscalls. The arguments don't match.marcel1999-08-111-1/+52
| | | | | | | | The linux syscalls translate the arguments first before invoking the FreeBSD native syscalls. PR: kern/9591 Originator: John Plevyak <jplevyak@inktomi.com>
* Fix page fault in linux_uselib syscall.marcel1999-08-081-2/+2
| | | | | PR: 12910 Submitted by: Peter Holm <peter@holm.cc>
OpenPOWER on IntegriCloud