aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_util.c
Commit message (Collapse)AuthorAgeFilesLines
* Move V4L feature declarations and DTrace provider definitions fromTijl Coosemans2020-12-061-0/+18
| | | | | | | | | | | | | | | | | linux_common.c to linux_util.c so they become available on i386. linux_common.c defines the linux_common kernel module but this module does not exist on i386 and linux_common.c is not included in the linux module. linux_util.c is included in the linux_common module on amd64 and the linux module on i386. Remove linux_common.c from files.i386 again. It was added recently in r367433 when the DTrace provider definitions were moved. The V4L feature declarations were moved to linux_common in r283423. Notes: svn path=/head/; revision=368384
* - add more linux socket options (sorted by value)Alexander Leidinger2020-11-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - map those IPv4 / IPv6 socket options which exist in FreeBSD + most of them visually verified to have the same type/layout of arguments + not tested with linux programs to behave as intended - be more human readable for known options which are not handled - be more verbose for unhandled socket message flags we know about - print the jail ID in linux_msg if run in a jail - add possibility to print debug message about known missing parts only once - add multiple levels of sysctl linux.debug: 1: print debug messages, tell about unimplemented stuff (only once) 2: like 1, but also print messages about implemented but not tested stuff (only once) 3+: like 2, but no rate limiting of messages - increase default linux debug level from 1 to 3 We are a lot more verbose in as we need to be (e.g. some of the IP socket options which are the same, and share the same memory layout, and are believed to work). The reason is that we have no good testsuite to test those linux-bits. The LTP or other test suites like the python one, are not fully up to the task we need. As such the excessive messages about emulated but not tested socket options. IMO any MFC (possible, but most probably not by me) should set the default debug level to 1. Discussed with: trasz Notes: svn path=/head/; revision=367481
* Fix potential race condition in linux stat(2).Edward Tomasz Napierala2020-10-201-0/+19
| | | | | | | | | | Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25618 Notes: svn path=/head/; revision=366899
* Add compat.linux.debug sysctl, to make it possible to silence downEdward Tomasz Napierala2020-06-121-0/+3
| | | | | | | | | | | | the debug messages. While here, clean up some variable naming. Reviewed by: bcr (manpages), emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25230 Notes: svn path=/head/; revision=362104
* Add compat.linux.emul_path, so it can be set to something otherEdward Tomasz Napierala2019-12-161-1/+7
| | | | | | | | | | | | | | than "/compat/linux". Useful when you have several compat directories with different Linux versions and you don't want to clash with files installed by linux-c7 packages. Reviewed by: bcr (manpages) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22574 Notes: svn path=/head/; revision=355818
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* Linuxulator: apply style(9) to returnEd Maste2018-03-121-2/+2
| | | | | | | Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=330798
* sys/compat: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326266
* Add special handling for current in-tree drm devices, like r323692 addedTijl Coosemans2017-10-151-0/+21
| | | | | | | for drm-next. Notes: svn path=/head/; revision=324629
* Use sizeof instead of strlen on string constants. The compiler doesn'tTijl Coosemans2017-10-151-8/+7
| | | | | | | optimise the strlen calls away with -ffreestanding. Notes: svn path=/head/; revision=324628
* linsysfs(5): Add support for recent libdrmConrad Meyer2017-09-171-2/+10
| | | | | | | | | | | | | | | Expose more information about PCI devices (and GPUs in particular) via linsysfs to libdrm. This allows unmodified modern 64-bit Linux libdrm to work, which allows modern Linux Mesa to work. The submitter reports that he tested the change with an Ubuntu 16.04 chroot + amdgpu from graphics/drm-next-kmod. PR: 222375 Submitted by: Greg V <greg AT unrelenting.technology> Notes: svn path=/head/; revision=323692
* Implement epoll family system calls. This is a tiny wrapperDmitry Chagin2015-05-241-0/+1
| | | | | | | | | | | | | | | around kqueue() to implement epoll subset of functionality. The kqueue user data are 32bit on i386 which is not enough for epoll user data, so we keep user data in the proc emuldata. Initial patch developed by rdivacky@ in 2007, then extended by Yuri Victorovich @ r255672 and finished by me in collaboration with mjg@ and jillies@. Differential Revision: https://reviews.freebsd.org/D1092 Notes: svn path=/head/; revision=283441
* Where possible we will use M_LINUX malloc(9) type.Dmitry Chagin2015-05-241-0/+2
| | | | | | | | | | Move M_FUTEX defines to the linux_common.ko. Differential Revision: https://reviews.freebsd.org/D1077 Reviewed by: emaste Notes: svn path=/head/; revision=283427
* Introduce a new module linux_common.ko which is intended for theDmitry Chagin2015-05-241-101/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | following primary purposes: 1. Remove the dependency of linsysfs and linprocfs modules from linux.ko, which will be architecture specific on amd64. 2. Incorporate into linux_common.ko general code for platforms on which we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit). 3. Move malloc(9) declaration to linux_common.ko, to enable getting memory usage statistics properly. Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c and linprocfs, linsysfs and linux kernel modules depend on linux_common.ko. Temporarily remove dtrace garbage from linux_mib.c and linux_util.c Differential Revision: https://reviews.freebsd.org/D1072 In collaboration with: Vassilis Laganakos. Reviewed by: trasz Notes: svn path=/head/; revision=283421
* - For kernel compiled only with KDTRACE_HOOKS and not any lock debuggingAttilio Rao2013-11-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | option, unbreak the lock tracing release semantic by embedding calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined version of the releasing functions for mutex, rwlock and sxlock. Failing to do so skips the lockstat_probe_func invokation for unlocking. - As part of the LOCKSTAT support is inlined in mutex operation, for kernel compiled without lock debugging options, potentially every consumer must be compiled including opt_kdtrace.h. Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES is linked there and it is only used as a compile-time stub [0]. [0] immediately shows some new bug as DTRACE-derived support for debug in sfxge is broken and it was never really tested. As it was not including correctly opt_kdtrace.h before it was never enabled so it was kept broken for a while. Fix this by using a protection stub, leaving sfxge driver authors the responsibility for fixing it appropriately [1]. Sponsored by: EMC / Isilon storage division Discussed with: rstone [0] Reported by: rstone [1] Discussed with: philip Notes: svn path=/head/; revision=258541
* - >500 static DTrace probes for the linuxulatorAlexander Leidinger2012-05-051-16/+106
| | | | | | | | | | | | | | | | | | | | | - DTrace scripts to check for errors, performance, ... they serve mostly as examples of what you can do with the static probe;s with moderate load the scripts may be overwhelmed, excessive lock-tracing may influence program behavior (see the last design decission) Design decissions: - use "linuxulator" as the provider for the native bitsize; add the bitsize for the non-native emulation (e.g. "linuxuator32" on amd64) - Add probes only for locks which are acquired in one function and released in another function. Locks which are aquired and released in the same function should be easy to pair in the code, inter-function locking is more easy to verify in DTrace. - Probes for locks should be fired after locking and before releasing to prevent races (to provide data/function stability in DTrace, see the man-page of "dtrace -v ..." and the corresponding DTrace docs). Notes: svn path=/head/; revision=235063
* Remove direct access to si_name.Ed Schouten2012-02-101-1/+1
| | | | | | | | | | | Code should just use the devtoname() function to obtain the name of a character device. Also add const keywords to pieces of code that need it to build properly. MFC after: 2 weeks Notes: svn path=/head/; revision=231378
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-231-6/+6
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Push down the major/minor conversion for pts/%u to improve consistency.Ed Schouten2008-06-021-0/+16
| | | | | | | | | | | | | | | | | | | | | In the mpsafetty branch, Linux sshd seems to work properly inside a jail. Some small modifications had to be made to the Linux compatibility layer. The Linux PTY routines always expect the device major number to be 136 or higher. Our code always set the major/minor number pair to 136:0. This makes routines like ttyname() and ptsname() fail, because we'll end up having ambiguous device numbers. The conversion was not performed on all *stat() routines, which meant in some cases the numbers didn't get transformed. By pushing the conversion into linux_driver_get_major_minor(), the transformation will take place on all calls. Approved by: philip (mentor), rdivacky Notes: svn path=/head/; revision=179486
* Implement the linux syscallsKonstantin Belousov2008-04-081-3/+4
| | | | | | | | | | | | openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat, renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat. Submitted by: rdivacky Sponsored by: Google Summer of Code 2007 Tested by: pho Notes: svn path=/head/; revision=177997
* Add the support for the AT_FDCWD and fd-relative name lookups to theKonstantin Belousov2008-03-311-0/+1
| | | | | | | | | | | | namei(9). Based on the submission by rdivacky, sponsored by Google Summer of Code 2007 Reviewed by: rwatson, rdivacky Tested by: pho Notes: svn path=/head/; revision=177785
* Partial MFp4 of 114977:Alexander Leidinger2007-02-241-5/+4
| | | | | | | | | Whitespace commit: Fix grammar, spelling and punctuation. Submitted by: "Scot Hetzel" <swhetzel@gmail.com> Notes: svn path=/head/; revision=166944
* Add the linux 2.6.x stuff (not used by default!):Alexander Leidinger2006-08-151-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - TLS - complete - pid/tid mangling - complete - thread area - complete - futexes - complete with issues - clone() extension - complete with some possible minor issues - mq*/timer*/clock* stuff - complete but untested and the mq* stuff is disabled when not build as part of the kernel with native FreeBSD mq* support (module support for this will come later) Tested with: - linux-firefox - works, tested - linux-opera - works, tested - linux-realplay - doesnt work, issue with futexes - linux-skype - doesnt work, issue with futexes - linux-rt2-demo - works, tested - linux-acroread - doesnt work, unknown reason (coredump) and sometimes issue with futexes - various unix utilities in linux-base-gentoo3 and linux-base-fc4: everything tried worked On amd64 not everything is supported like on i386, the catchup is planned for later when the remaining bugs in the new functions are fixed. To test this new stuff, you have to run sysctl compat.linux.osrelease=2.6.16 to switch back use sysctl compat.linux.osrelease=2.4.2 Don't switch while running a linux program, strange things may or may not happen. Sponsored by: Google SoC 2006 Submitted by: rdivacky Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild Notes: svn path=/head/; revision=161310
* Enhance the Linux emulation layer to make MegaRAID SAS managements tool happy.Doug Ambrisko2006-05-051-0/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add back in a scheme to emulate old type major/minor numbers via hooks into stat, linprocfs to return major/minors that Linux app's expect. Currently only /dev/null is always registered. Drivers can register via the Linux type shim similar to the ioctl shim but by using linux_device_register_handler/linux_device_unregister_handler functions. The structure is: struct linux_device_handler { char *bsd_driver_name; char *linux_driver_name; char *bsd_device_name; char *linux_device_name; int linux_major; int linux_minor; int linux_char_device; }; Linprocfs uses this to display the major number of the driver. The soon to be available linsysfs will use it to fill in the driver name. Linux_stat uses it to translate the major/minor into Linux type values. Note major numbers are dynamically assigned via passing in a -1 for the major number so we don't need to keep track of them. This is somewhat needed due to us switching to our devfs. MegaCli will not run until I add in the linsysfs and mfi Linux compat changes. Sponsored by: IronPort Systems Notes: svn path=/head/; revision=158311
* Remove linux_emul_find() and the CHECKALT*() macros as they are no longerJohn Baldwin2005-03-011-33/+0
| | | | | | | used. Notes: svn path=/head/; revision=142939
* Make linux_emul_convpath() a simple wrapper for kern_alternate_path().John Baldwin2005-02-071-98/+3
| | | | Notes: svn path=/head/; revision=141472
* Start each of the license/copyright comments with /*-Warner Losh2005-01-051-1/+1
| | | | Notes: svn path=/head/; revision=139743
* Include <sys/mutex.h> and its prerequisite <sys/lock.h> instead ofBruce Evans2004-06-231-2/+4
| | | | | | | | | | depending on namespace pollution in <sys/vnode.h> for the definition of GIANT_REQUIRED. Sorted includes. Notes: svn path=/head/; revision=130959
* Mark linux_emul_convpath() as GIANT_REQUIRED.Robert Watson2004-06-221-0/+2
| | | | Notes: svn path=/head/; revision=130902
* VOP_GETATTR() wants the vnode passed to it to be locked. InsteadDon Lewis2004-01-141-13/+1
| | | | | | | | | | | of adding the code to lock and unlock the vnodes and taking care to avoid deadlock, simplify linux_emul_convpath() by comparing the vnode pointers directly instead of comparing their va_fsid and va_fileid attributes. This allows the removal of the calls to VOP_GETATTR(). Notes: svn path=/head/; revision=124537
* Use __FBSDID().David E. O'Brien2003-06-101-1/+3
| | | | Notes: svn path=/head/; revision=116173
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-1/+1
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-1/+1
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Add function linux_msg() for regulating output from the linux emulationAlfred Perlstein2003-01-021-0/+16
| | | | | | | | | | | | | | code, make the emulator use it. Rename unsupported_msg() to unimplemented_syscall(). Rename some arguments for clarity Fixup grammar. Requested by: bde Notes: svn path=/head/; revision=108541
* Add a new function linux_emul_convpath(), which is a version ofIan Dowse2002-09-011-32/+48
| | | | | | | | | | | linux_emul_find() that does not use stack gap storage but instead always returns the resulting path in a malloc'd kernel buffer. Implement linux_emul_find() in terms of this function. Also add LCONVPATH* macros that wrap linux_emul_convpath in the same way that the CHECKALT* macros wrap linux_emul_find(). Notes: svn path=/head/; revision=102803
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-2/+2
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* Eliminate the prefix parameter to linux_emul_find(), which was alwaysDag-Erling Smørgrav2001-10-271-3/+3
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=85599
* KSE Milestone 2Julian Elischer2001-09-121-7/+7
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=83366
* Fix typo: seperate -> separate.Jeroen Ruigrok van der Werven2001-02-061-1/+1
| | | | | | | Seperate does not exist in the english language. Notes: svn path=/head/; revision=72091
* Back out proc locking to protect p_ucred for obtaining additionalJohn Baldwin2001-01-271-10/+3
| | | | | | | references along with the actual obtaining of additional references. Notes: svn path=/head/; revision=71699
* Lock access to proc members.John Baldwin2000-12-151-3/+10
| | | | | | | Glanced over by: marcel Notes: svn path=/head/; revision=70061
* Update include directives.Marcel Moolenaar2000-08-221-2/+1
| | | | Notes: svn path=/head/; revision=64913
* Add bounds checking to stackgap_alloc. Previously it was possibleMarcel Moolenaar2000-07-231-1/+4
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=63778
* Remove unneeded #include <vm/vm_zone.h>Poul-Henning Kamp2000-04-301-1/+0
| | | | | | | Generated by: src/tools/tools/kerninclude Notes: svn path=/head/; revision=59794
* Introduce NDFREE (and remove VOP_ABORTOP)Eivind Eklund1999-12-151-1/+9
| | | | Notes: svn path=/head/; revision=54655
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Removed unused #includes.Bruce Evans1997-07-201-5/+1
| | | | Notes: svn path=/head/; revision=27557
* Don't include <sys/ioctl.h> in the kernel. Stage 1: don't includeBruce Evans1997-03-241-2/+1
| | | | | | | | it when it is not used. In most cases, the reasons for including it went away when the special ioctl headers became self-sufficient. Notes: svn path=/head/; revision=24203
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673