aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_file.c
Commit message (Collapse)AuthorAgeFilesLines
* kern_linkat: modify to accept AT_ flags instead of FOLLOW/NOFOLLOWEdward Tomasz Napierala2021-04-251-7/+8
| | | | | | | | This makes this API match other kern_xxxat() functions. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29776
* linux: support AT_EMPTY_PATH flag in fchownat(2)Edward Tomasz Napierala2021-04-161-2/+7
| | | | | | | | This fixes rsyslog package installation scripts in Bionic. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29108
* linux: implement O_PATHEdward Tomasz Napierala2021-04-151-0/+2
| | | | | | Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29773
* linux: remove spurious newline.Edward Tomasz Napierala2021-01-191-1/+1
| | | | Sponsored by: The FreeBSD Foundation
* linux(4): Implement name_to_handle_at(), open_by_handle_at()Conrad Meyer2020-11-171-6/+110
| | | | | | | | | They are similar to our getfhat(2) and fhopen(2) syscalls. Differential Revision: https://reviews.freebsd.org/D27111 Notes: svn path=/head/; revision=367773
* Make it possible to mount a fuse filesystem, such as squashfuse,Edward Tomasz Napierala2020-11-091-8/+36
| | | | | | | | | | | | from a Linux binary. Should come handy for AppImages. Reviewed by: asomers MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26959 Notes: svn path=/head/; revision=367517
* linux: silence renameat2 flags warningMateusz Guzik2020-10-261-0/+8
| | | | | | | Hogs the console while building the Linux kernel in a Ubuntu Focal jail. Notes: svn path=/head/; revision=367066
* linux: add missing conversions for compat.linux.use_emul_path handlingMateusz Guzik2020-10-261-44/+107
| | | | Notes: svn path=/head/; revision=367065
* compat: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+0
| | | | Notes: svn path=/head/; revision=365080
* linux: add sysctl compat.linux.use_emul_pathMateusz Guzik2020-08-181-31/+71
| | | | | | | | | | | | | | | | This is a step towards facilitating jails with only Linux binaries. Supporting emul_path adds path lookups which are completely spurious if the binary at hand runs in a Linux-based root directory. It defaults to on (== current behavior). make -C /root/linux-5.3-rc8 -s -j 1 bzImage: use_emul_path=1: 101.65s user 68.68s system 100% cpu 2:49.62 total use_emul_path=0: 101.41s user 64.32s system 100% cpu 2:45.02 total Notes: svn path=/head/; revision=364366
* Make linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,Edward Tomasz Napierala2020-07-181-1/+1
| | | | | | | | | | as documented in the man page. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=363307
* Add a trivial linux(4) splice(2) implementation, which simplyEdward Tomasz Napierala2020-07-181-0/+14
| | | | | | | | | | | | | | returns EINVAL. Fixes grep (grep-3.1-2build1). PR: kern/218699 Reported by: avos Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25636 Notes: svn path=/head/; revision=363304
* memfd_create: turn on SHM_GROW_ON_WRITEKyle Evans2020-07-101-1/+1
| | | | | | | | | | | memfd_create fds will no longer require an ftruncate(2) to set the size; they'll grow (to the extent that it's possible) upon write(2)-like syscalls. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D25502 Notes: svn path=/head/; revision=363066
* linuxolator: implement memfd_create syscallKyle Evans2020-06-291-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This effectively mirrors our libc implementation, but with minor fudging -- name needs to be copied in from userspace, so we just copy it straight into stack-allocated memfd_name into the correct position rather than allocating memory that needs to be cleaned up. The sealing-related fcntl(2) commands, F_GET_SEALS and F_ADD_SEALS, have also been implemented now that we support them. Note that this implementation is still not quite at feature parity w.r.t. the actual Linux version; some caveats, from my foggy memory: - Need to implement SHM_GROW_ON_WRITE, default for memfd (in progress) - LTP wants the memfd name exposed to fdescfs - Linux allows open() of an fdescfs fd with O_TRUNC to truncate after dup. (?) Interested parties can install and run LTP from ports (devel/linux-ltp) to confirm any fixes. PR: 240874 Reviewed by: kib, trasz Differential Revision: https://reviews.freebsd.org/D21845 Notes: svn path=/head/; revision=362769
* Make linux(4) warn about unsupported fcntls.Edward Tomasz Napierala2020-06-121-2/+3
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25231 Notes: svn path=/head/; revision=362102
* Replace LINUX_FASYNC with LINUX_O_ASYNC; no functional changes.Edward Tomasz Napierala2020-06-111-3/+3
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25218 Notes: svn path=/head/; revision=362055
* Add kern_unmount() and use in Linuxulator. No functional changes.Edward Tomasz Napierala2020-01-241-9/+9
| | | | | | | | | | Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22646 Notes: svn path=/head/; revision=357075
* Fix 64-bit syscall argument fetching in 32-bit Linux syscall handlers.Mark Johnston2020-01-211-17/+81
| | | | | | | | | | | | | | | | | | | | | | | | The Linux32 system call argument fetcher places each argument (passed in registers in the Linux x86 system call convention) into an entry in the generic system call args array. Each member of this array is 8 bytes wide, so this approach is broken for system calls that take off_t arguments. Fix the problem by splitting l_loff_t arguments in the 32-bit system call descriptions, the same as we do for FreeBSD32. Change entry points to handle this using the PAIR32TO64 macro. Move linux_ftruncate64() into compat/linux. PR: 243155 Reported by: Alex S <iwtcex@gmail.com> Reviewed by: kib (previous version) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23210 Notes: svn path=/head/; revision=356945
* Properly translate MNT_FORCE flag to Linux umount2(2). PreviouslyEdward Tomasz Napierala2020-01-201-1/+6
| | | | | | | | | | it worked by accident. MFC after: 2 weeks Sponsored by: DARPA Notes: svn path=/head/; revision=356912
* linux(4): implement copy_file_range(2)Pawel Biernacki2019-12-301-0/+41
| | | | | | | | | | | | copy_file_range(2) is implemented natively since r350315, make it available for Linux binaries too. Reviewed by: kib (mentor), trasz (previous version) Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D22959 Notes: svn path=/head/; revision=356206
* Make linux mount(2) tolerate NULL 'from' argument, and fix flagEdward Tomasz Napierala2019-12-281-17/+19
| | | | | | | | | | | | | handling. This should unbreak access04, acct01, chmod06, creat06, and fchmod06 LTP tests. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=356147
* Don't use K&R definitions. No functional changes.Edward Tomasz Napierala2019-12-161-6/+2
| | | | | | | | | Reported by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=355807
* Add sync_file_range(2) implementation to linux(4); it's a thin wrapperEdward Tomasz Napierala2019-12-141-0/+16
| | | | | | | | | | | | | | over the usual fsync(2). This silences some warnings when running "apt-get upgrade". Reviewed by: brooks, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22371 Notes: svn path=/head/; revision=355754
* linux: avoid overhead of P_CONTROLT checks if possibleMateusz Guzik2019-11-201-0/+2
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=354891
* Make linux(4) open(2)/openat(2) return ELOOP instead of EMLINK,Edward Tomasz Napierala2019-11-181-1/+4
| | | | | | | | | | | | when being passed O_NOFOLLOW. This fixes LTP testcase openat02:5. Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22384 Notes: svn path=/head/; revision=354805
* Support O_CLOEXEC in linux(4) open(2) and openat(2).Edward Tomasz Napierala2019-11-151-0/+2
| | | | | | | | | | Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21966 Notes: svn path=/head/; revision=354732
* linux_renameat2: improve flag checksEd Maste2019-11-071-0/+7
| | | | | | | | | | | | | In the cases where Linux returns an error (e.g. passing in an undefined flag) there's no need for us to emit a message. (The target of this message is a developer working on the linuxulatorm, not the author of presumably broken Linux software). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21606 Notes: svn path=/head/; revision=354447
* linux_renameat2: don't add extra \n on error.Pawel Biernacki2019-09-301-1/+1
| | | | | | | | | | | linux_msg() already adds \n at the end of all messages. Reported by: emaste, kib (mentor), mjg (mentor) Reviewed by: kib (mentor), mjg (mentor) Differential Revision: https://reviews.freebsd.org/D21852 Notes: svn path=/head/; revision=352914
* linux: add trivial renameat2 implementationEd Maste2019-09-111-0/+20
| | | | | | | | | | | | | | | | Just return EINVAL if flags != 0. The Linux man page documents one case of EINVAL as "The filesystem does not support one of the flags in flags." After r351723 userland binaries will try using new system calls. Reported by: mjg Reviewed by: mjg, trasz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21590 Notes: svn path=/head/; revision=352210
* Linuxulator depends on a fundamental kernel settings such as SMP. ManyDmitry Chagin2019-05-131-175/+3
| | | | | | | | | | | | | | | | | | | | | | of them listed in opt_global.h which is not generated while building modules outside of a kernel and such modules never match real cofigured kernel. So, we should prevent our users from building obviously defective modules. Therefore, remove the root cause of the building of modules outside of a kernel - the possibility of building modules with DEBUG or KTR flags. And remove all of DEBUG printfs as it is incomplete and in threaded programms not informative, also a half of system call does not have DEBUG printf. For debuging Linux programms we have dtrace, ktr and ktrace ability. PR: 222861 Reviewed by: trasz MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20178 Notes: svn path=/head/; revision=347538
* Introduce funlinkat syscall that always us to check if we are removingMariusz Zaborski2019-04-061-4/+5
| | | | | | | | | | | | the file associated with the given file descriptor. Reviewed by: kib, asomers Reviewed by: cem, jilles, brooks (they reviewed previous version) Discussed with: pjd, and many others Differential Revision: https://reviews.freebsd.org/D14567 Notes: svn path=/head/; revision=345982
* Implement O_BENEATH and AT_BENEATH.Konstantin Belousov2018-10-251-4/+4
| | | | | | | | | | | | | | Flags prevent open(2) and *at(2) vfs syscalls name lookup from escaping the starting directory. Supposedly the interface is similar to the same proposed Linux flags. Reviewed by: jilles (code, previous version of manpages), 0mp (manpages) Discussed with: allanjude, emaste, jonathan Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D17547 Notes: svn path=/head/; revision=339748
* linuxulator: do not include legacy syscalls on arm64Ed Maste2018-06-151-1/+34
| | | | | | | | | | | | | | | | | Existing linuxulator platforms (i386, amd64) support legacy syscalls, such as non-*at ones like open, but arm64 and other new platforms do not. Wrap these in #ifdef LINUX_LEGACY_SYSCALLS, #defined in the MD linux.h files. We may need finer grained control in the future but this is sufficient for now. Reviewed by: andrew Sponsored by: Turing Robotic Industries Differential Revision: https://reviews.freebsd.org/D15237 Notes: svn path=/head/; revision=335201
* Correct debug control for linuxulator faccessatEd Maste2018-06-151-1/+1
| | | | | | | | | | | | The Linuxulator provides per-syscall debug control via the compat.linux.debug sysctl. There's generally a 1:1 mapping between sysctl setting and syscall, but faccessat was controlled by the access setting, perhaps due to copy-paste. Sponsored by: Turing Robotic Industries Notes: svn path=/head/; revision=335200
* Eliminate the overhead of gratuitous repeated reinitialization of cap_rightsMatt Macy2018-05-091-9/+4
| | | | | | | | | | | | | | | - Add macros to allow preinitialization of cap_rights_t. - Convert most commonly used code paths to use preinitialized cap_rights_t. A 3.6% speedup in fstat was measured with this change. Reported by: mjg Reviewed by: oshogbo Approved by: sbruno MFC after: 1 month Notes: svn path=/head/; revision=333425
* Correct proper nouns in the LinuxulatorEd Maste2018-02-221-3/+3
| | | | | | | | | | | - Capitalize Linux - Spell FreeBSD out in full - Address some style(9) on changed lines Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=329794
* Rationalize license text on Linuxolator filesEd Maste2018-02-161-15/+13
| | | | | | | | | | | | | | | Many licenses on Linuxolator files contained small variations from the standard FreeBSD license text. To avoid license proliferation switch to the standard 2-clause FreeBSD license for those files where I have permission from each of the listed copyright holders. Additional files waiting on permission from others are listed in review D14210. Approved by: kan, marcel, sos, rdivacky MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=329370
* 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
* Update comment to match r177997 & r178036 changes.David E. O'Brien2017-10-271-1/+1
| | | | Notes: svn path=/head/; revision=325043
* linux_getdents, linux_readdir: fix mismatch between malloc and free tagsAndriy Gapon2017-06-261-4/+4
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=320353
* Remove the outdated definition.Dmitry Chagin2017-06-121-2/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=319851
* Since r318735 (ino64 project) the size of the native struct dirent isDmitry Chagin2017-06-121-15/+2
| | | | | | | | equal or greater than the size of Linux struct dirent or struct dirent64. So, remove LINUX_RECLEN_RATIO magic as useless. Notes: svn path=/head/; revision=319849
* Commit the 64-bit inode project.Konstantin Belousov2017-05-231-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439 Notes: svn path=/head/; revision=318736
* Fix symlinkat() which use the newdfd argument to look up the old path,Dmitry Chagin2017-04-301-1/+1
| | | | | | | | | | while it should use it for the new path instead. Reported by: trasz@ MFC after: 1 month Notes: svn path=/head/; revision=317601
* Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.Mahdi Mokhtari2017-02-241-0/+56
| | | | | | | | | | Reviewed by: dchagin Approved by: dchagin, trasz (src committers) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9722 Notes: svn path=/head/; revision=314219
* Revert r314217. Commit is not match that I have approved.Dmitry Chagin2017-02-241-46/+0
| | | | Notes: svn path=/head/; revision=314218
* Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.Mahdi Mokhtari2017-02-241-0/+46
| | | | | | | | | | Reviewed by: dchagin Approved by: dchagin, trasz (src committers) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D9722 Notes: svn path=/head/; revision=314217
* Replace Linuxulator implementation of readdir(), getdents() andDmitry Chagin2017-02-141-203/+204
| | | | | | | | | | | | | | | | | | | | | | | | getdents64() with wrapper over kern_getdirentries(). The patch was originally written by emaste@ and then adapted by trasz@ and me. Note: 1. I divided linux_getdents() and linux_readdir() as in case when the getdents() called with count = 1 (readdir() case) it can overwrite user stack (by writing to user buffer pointer more than 1 byte). 2. Linux returns EINVAL in case when user supplied buffer is not enough to contain fetched dirent. 3. Linux returns ENOTDIR in case when fd points to not a directory. Reviewed by: trasz@ MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D2210 Notes: svn path=/head/; revision=313740
* Fix linux_pipe() and linux_pipe2() to close file descriptors on copyoutEdward Tomasz Napierala2017-02-051-6/+16
| | | | | | | | | | | | error. Reviewed by: dchagin MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9425 Notes: svn path=/head/; revision=313283
* Add kern_pread() and kern_pwrite(), and use it in compats insteadEdward Tomasz Napierala2017-01-311-18/+4
| | | | | | | | | | | | of their sys_*() counterparts. The svr4 is left unchanged. Reviewed by: kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9379 Notes: svn path=/head/; revision=313018