aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/truss/syscalls.c
Commit message (Collapse)AuthorAgeFilesLines
* truss: Add AIO syscalls.Thomas Munro2020-12-101-0/+166
| | | | | | | | | | | | Display the arguments of aio_read(2), aio_write(2), aio_suspend(2), aio_error(2), aio_return(2), aio_cancel(2), aio_fsync(2), aio_mlock(2), aio_waitcomplete(2) and lio_listio(2) in human-readable form. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D27518 Notes: svn path=/head/; revision=368500
* kdump/truss: decode new _umtx_op flagsKyle Evans2020-12-091-3/+17
| | | | | | | | | | | | | | | | | | | | In both cases, print the flag bits first followed by the command. Output now looks something like this: (ktrace) _umtx_op(0x8605f7008,0xf<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0) _umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,0x1,0,0) (truss) _umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) _umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D27325 Notes: svn path=/head/; revision=368481
* Enable iterating all sysctls, even ones with CTLFLAG_SKIPRyan Moeller2020-10-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Add an "nextnoskip" sysctl that allows for listing of sysctls intended to be normally skipped for cost reasons. This makes it so the names/descriptions of those sysctls can be discovered with sysctl -aN/sysctl -ad/sysctl -at. It also makes it so children are visited when a node flagged with CTLFLAG_SKIP is explicitly requested. The intended use case is to mark the root "kstat" node with CTLFLAG_SKIP so that the extensive and expensive stats are skipped by default but may still be easily obtained without having to know them all (which may not even be possible) and request each one-by-one. Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D26560 Notes: svn path=/head/; revision=366465
* truss: print more information about traced sysctlsPawel Biernacki2020-07-051-24/+42
| | | | | | | | MFC after: 2 weeks Sponsored by: Mysterious Code Ltd. Notes: svn path=/head/; revision=362947
* Decode the file descriptor argument to closefrom(2) as an Integer.Christian S.J. Peron2020-05-211-0/+2
| | | | | | | | | | | | This is consistent with what we are doing for close(2) and it makes it a bit easier to follow when debugging file descriptor operations. i.e. many other syscalls are decoding fds as integers rather than base 16 numbers. MFC after: 1 week Notes: svn path=/head/; revision=361316
* vfs: add realpathat syscallMateusz Guzik2020-02-201-0/+3
| | | | | | | | | | | | | | | | | | realpath(3) is used a lot e.g., by clang and is a major source of getcwd and fstatat calls. This can be done more efficiently in the kernel. This works by performing a regular lookup while saving the name and found parent directory. If the terminal vnode is a directory we can resolve it using usual means. Otherwise we can use the name saved by lookup and resolve the parent. See the review for sample syscall counts. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23574 Notes: svn path=/head/; revision=358172
* truss: fix shm_open2 oversight (BinString -> Name)Kyle Evans2020-02-191-1/+1
| | | | | | | | BinString assumes a length in the next argument; Name is more appropriate for the final argument. Notes: svn path=/head/; revision=358118
* truss: decode shm_open2Kyle Evans2020-02-191-0/+6
| | | | | | | | | | | | | | | shm_open2 is similar to shm_open, except it also takes shmflags and optional name to label the anonymous region for, e.g., debugging purposes. The appropriate support for decoding shmflags was added to libsysdecode in r358115. This is a part of D23733. Reviewed by: kaktus Notes: svn path=/head/; revision=358116
* Miscellaneous typo fixesEd Maste2020-02-071-1/+1
| | | | | | | | Submitted by: Gordon Bergling <gbergling_gmail.com> Differential Revision: https://reviews.freebsd.org/D23453 Notes: svn path=/head/; revision=357664
* truss: centralize pointer-constructing casts.Brooks Davis2019-10-311-107/+104
| | | | | | | | | | | | | | | In nearly all cases, the caller has a uintptr_t compatible argument so this eliminates a large number of casts. Add a print_pointer function to centralize printing pointers. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22212 Notes: svn path=/head/; revision=354232
* Fix a typo in a comment.John Baldwin2019-10-031-1/+1
| | | | Notes: svn path=/head/; revision=353058
* Add an shm_rename syscallDavid Bright2019-09-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add an atomic shm rename operation, similar in spirit to a file rename. Atomically unlink an shm from a source path and link it to a destination path. If an existing shm is linked at the destination path, unlink it as part of the same atomic operation. The caller needs the same permissions as shm_unlink to the shm being renamed, and the same permissions for the shm at the destination which is being unlinked, if it exists. If those fail, EACCES is returned, as with the other shm_* syscalls. truss support is included; audit support will come later. This commit includes only the implementation; the sysent-generated bits will come in a follow-on commit. Submitted by: Matthew Bryan <matthew.bryan@isilon.com> Reviewed by: jilles (earlier revision) Reviewed by: brueffer (manpages, earlier revision) Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21423 Notes: svn path=/head/; revision=352747
* truss: decode sysctl names.Konstantin Belousov2019-09-181-0/+72
| | | | | | | | | Submitted by: Pawel Biernacki MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21688 Notes: svn path=/head/; revision=352488
* Use PT_GET_SC_ARGS and PT_GET_SC_RET in truss.John Baldwin2019-07-161-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes all of the architecture-specific functions from truss. A per-ABI structure is still needed to map syscall numbers to names and FreeBSD errno values to ABI error values as well as hold syscall counters. However, the linker set of ABI structures is now replaced with a simple table mapping ABI names to structures. This approach permits sharing the same ABI structure among separate names such as i386 a.out and ELF binaries as well as ELF v1 vs ELF v2 for powerpc64. A few differences are visible due to using PT_GET_SC_RET to fetch the error value of a system call. Note that ktrace/kdump have had the "new" behaviors for a long time already: - System calls that return with EJUSTRETURN or ERESTART will now be noticed and logged as such. Previously sigreturn (which uses EJUSTRETURN) would report whatever random value was in the register holding errno from the previous system call for example. Now it reports EJUSTRETURN. - System calls that return errno as their error value such as posix_fallocate() and posix_fadvise() now report non-zero return values as errors instead of success with a non-zero return value. Reviewed by: kib MFC after: 1 month Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D20963 Notes: svn path=/head/; revision=350069
* truss: Add support for fsync(2) and fdatasync(2).Thomas Munro2019-02-281-0/+4
| | | | | | | | | | | | | The default handling showed the argument as hex. Add explicit handling so we can show it as decimal, since that's how we show file descriptors everywhere else. Approved by: mjg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D19295 Notes: svn path=/head/; revision=344656
* truss: Fix display of shm_open(SHM_ANON, ...).Thomas Munro2018-10-281-1/+9
| | | | | | | | | | | | | Currently truss(1) shows shm_open(SHM_ANON, ...) as shm_open("(null)", ...). Detect the special value and display it by name. Reviewed by: jhb, allanjude, tuexen Approved by: mjg (mentor) MFC with: r339224 Differential Revision: https://reviews.freebsd.org/D17461 Notes: svn path=/head/; revision=339840
* Teach truss how to display shm_open(2), shm_unlink(2)Allan Jude2018-10-071-0/+4
| | | | | | | | | | | Submitted by: Thomas Munro <munro@ip9.org> Reviewed by: tuexen, kib Approved by: re (rgrimes) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D17457 Notes: svn path=/head/; revision=339224
* Make timespecadd(3) and friends publicAlan Somers2018-07-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725 Notes: svn path=/head/; revision=336914
* Rename ClouduABIFDSFlags to CloudABIFDSFlags.John Baldwin2018-03-291-2/+2
| | | | Notes: svn path=/head/; revision=331715
* Implement getrandom(2) and getentropy(3)Conrad Meyer2018-03-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The general idea here is to provide userspace programs with well-defined sources of entropy, in a fashion that doesn't require opening a new file descriptor (ulimits) or accessing paths (/dev/urandom may be restricted by chroot or capsicum). getrandom(2) is the more general API, and comes from the Linux world. Since our urandom and random devices are identical, the GRND_RANDOM flag is ignored. getentropy(3) is added as a compatibility shim for the OpenBSD API. truss(1) support is included. Tests for both system calls are provided. Coverage is believed to be at least as comprehensive as LTP getrandom(2) test coverage. Additionally, instructions for running the LTP tests directly against FreeBSD are provided in the "Test Plan" section of the Differential revision linked below. (They pass, of course.) PR: 194204 Reported by: David CARLIER <david.carlier AT hardenedbsd.org> Discussed with: cperciva, delphij, jhb, markj Relnotes: maybe Differential Revision: https://reviews.freebsd.org/D14500 Notes: svn path=/head/; revision=331279
* Add missing assignment to make sure non-first cmsgs are handled as such.Michael Tuexen2018-01-171-0/+1
| | | | Notes: svn path=/head/; revision=328081
* Improve the printing of cmgs when the length is 0. Fix error handling.Michael Tuexen2018-01-161-0/+5
| | | | Notes: svn path=/head/; revision=328059
* Using %p already prints "0x", so don't do it explicitly.Michael Tuexen2018-01-161-6/+6
| | | | Notes: svn path=/head/; revision=328058
* Rename 'recv' to 'receive' to appease shadow warnings from GCC.John Baldwin2018-01-161-8/+8
| | | | Notes: svn path=/head/; revision=328037
* Keep list sorted. Thanks to jhb@ to pointing out that I put it at theMichael Tuexen2018-01-151-2/+2
| | | | | | | wrong place in r327919. Notes: svn path=/head/; revision=328034
* Decode msghdr argument of sendmsg() and recvmsg().Michael Tuexen2018-01-151-129/+396
| | | | | | | Sponsored by: Netflix, Inc. Notes: svn path=/head/; revision=328015
* Improve support for sctp_generic_recvmsg() and sctp_generic_sendmsg()Michael Tuexen2018-01-141-5/+37
| | | | | | | | | | and add support for sctp_generic_sendmsg_iov(). Handle the struct iovec argument and the struct sctp_sndrcvinfo arguments. Notes: svn path=/head/; revision=327967
* Mark the iovec parameters of writev() and readv() as IN and OUT.Michael Tuexen2018-01-141-2/+2
| | | | | | | This makes truss work on readv() as expected. Notes: svn path=/head/; revision=327961
* Fix a typo introduced in r327919.Michael Tuexen2018-01-131-1/+1
| | | | Notes: svn path=/head/; revision=327921
* Add support for readv() and writev() to truss.Michael Tuexen2018-01-131-0/+66
| | | | | | | Sponsored by: Netflix, Inc. Notes: svn path=/head/; revision=327919
* Decode kevent structures logged via ktrace(2) in kdump.John Baldwin2017-11-251-75/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a new KTR_STRUCT_ARRAY ktrace record type which dumps an array of structures. The structure name in the record payload is preceded by a size_t containing the size of the individual structures. Use this to replace the previous code that dumped the kevent arrays dumped for kevent(). kdump is now able to decode the kevent structures rather than dumping their contents via a hexdump. One change from before is that the 'changes' and 'events' arrays are not marked with separate 'read' and 'write' annotations in kdump output. Instead, the first array is the 'changes' array, and the second array (only present if kevent doesn't fail with an error) is the 'events' array. For kevent(), empty arrays are denoted by an entry with an array containing zero entries rather than no record. - Move kevent decoding tables from truss to libsysdecode. This adds three new functions to decode members of struct kevent: sysdecode_kevent_filter, sysdecode_kevent_flags, and sysdecode_kevent_fflags. kdump uses these helper functions to pretty-print kevent fields. - Move structure definitions for freebsd11 and freebsd32 kevent structures to <sys/event.h> so that they can be shared with userland. The 32-bit structures are only exposed if _WANT_KEVENT32 is defined. The freebsd11 structures are only exposed if _WANT_FREEBSD11_KEVENT is defined. The 32-bit freebsd11 structure requires both. - Decode freebsd11 kevent structures in truss for the compat11.kevent() system call. - Log 32-bit kevent structures via ktrace for 32-bit compat kevent() system calls. - While here, constify the 'void *data' argument to ktrstruct(). Reviewed by: kib (earlier version) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D12470 Notes: svn path=/head/; revision=326184
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-1/+3
| | | | | | | | | | | | | | | | | | | | 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* Import the latest CloudABI definitions, version 0.16.Ed Schouten2017-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The most important change in this release is the removal of the poll_fd() system call; CloudABI's equivalent of kevent(). Though I think that kqueue is a lot saner than many of its alternatives, our experience is that emulating this system call on other systems accurately isn't easy. It has become a complex API, even though I'm not convinced this complexity is needed. This is why we've decided to take a different approach, by looking one layer up. We're currently adding an event loop to CloudABI's C library that is API compatible with libuv (except when incompatible with Capsicum). Initially, this event loop will be built on top of plain inefficient poll() calls. Only after this is finished, we'll work our way backwards and design a new set of system calls to optimize it. Interesting challenges will include integrating asynchronous I/O into such a system call API. libuv currently doesn't aio(4) on Linux/BSD, due to it being unreliable and having undesired semantics. Obtained from: https://github.com/NuxiNL/cloudabi Notes: svn path=/head/; revision=324727
* Merge pipes and socket pairs.Ed Schouten2017-09-051-4/+3
| | | | | | | | | | | | | | | Now that CloudABI's sockets API has been changed to be addressless and only connected socket instances are used (e.g., socket pairs), they have become fairly similar to pipes. The only differences on CloudABI is that socket pairs additionally support shutdown(), send() and recv(). To simplify the ABI, we've therefore decided to remove pipes as a separate file descriptor type and just let pipe() return a socket pair of type SOCK_STREAM. S_ISFIFO() and S_ISSOCK() are now defined identically. Notes: svn path=/head/; revision=323177
* Decode pathconf() names, *at() flags, and sysarch() numbers in libsysdecode.John Baldwin2017-09-041-33/+4
| | | | | | | | | | Move tables that were previously in truss over to libsysdecode. truss output is unchanged, but kdump has been updated to decode these fields. In addition, sysdecode_sysarch_number() should support all platforms whereas the old table in truss only supported x86. Notes: svn path=/head/; revision=323151
* Decode signal information returned by system calls.John Baldwin2017-08-301-4/+28
| | | | | | | | | Specifically, decode the siginfo structure returned by sigtimedwait(), sigwaitinfo(), and wait6(). While here, also decode the signal number returned in the second argument to sigwait(). Notes: svn path=/head/; revision=323021
* Complete the CloudABI networking refactoring.Ed Schouten2017-08-301-49/+0
| | | | | | | | | | | | | | Now that all of the packaged software has been adjusted to either use Flower (https://github.com/NuxiNL/flower) for making incoming/outgoing network connections or can have connections injected, there is no longer need to keep accept() around. It is now a lot easier to write networked services that are address family independent, dual-stack, testable, etc. Remove all of the bits related to accept(), but also to getsockopt(SO_ACCEPTCONN). Notes: svn path=/head/; revision=323015
* Decode arguments passed to thr_set_name().John Baldwin2017-08-251-0/+2
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=322899
* Sync CloudABI compatibility against the latest upstream version (v0.13).Ed Schouten2017-08-251-6/+0
| | | | | | | | | | | | | | | | | | | With Flower (CloudABI's network connection daemon) becoming more complete, there is no longer any need for creating any unconnected sockets. Socket pairs in combination with file descriptor passing is all that is necessary, as that is what is used by Flower to pass network connections from the public internet to listening processes. Remove all of the kernel bits that were used to implement socket(), listen(), bindat() and connectat(). In principle, accept() and SO_ACCEPTCONN may also be removed, but there are still some consumers left. Obtained from: https://github.com/NuxiNL/cloudabi MFC after: 1 month Notes: svn path=/head/; revision=322885
* Upgrade to the latest sources generated from the CloudABI specification.Ed Schouten2017-07-261-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CloudABI specification has had some minor changes over the last half year. No substantial features have been added, but some features that are deemed unnecessary in retrospect have been removed: - mlock()/munlock(): These calls tend to be used for two different purposes: real-time support and handling of sensitive (cryptographic) material that shouldn't end up in swap. The former use case is out of scope for CloudABI. The latter may also be handled by encrypting swap. Removing this has the advantage that we no longer need to worry about having resource limits put in place. - SOCK_SEQPACKET: Support for SOCK_SEQPACKET is rather inconsistent across various operating systems. Some operating systems supported by CloudABI (e.g., macOS) don't support it at all. Considering that they are rarely used, remove support for the time being. - getsockname(), getpeername(), etc.: A shortcoming of the sockets API is that it doesn't allow you to create socket(pair)s, having fake socket addresses associated with them. This makes it harder to test applications or transparently forward (proxy) connections to them. With CloudABI, we're slowly moving networking connectivity into a separate daemon called Flower. In addition to passing around socket file descriptors, this daemon provides address information in the form of arbitrary string labels. There is thus no longer any need for requesting socket address information from the kernel itself. This change also updates consumers of the generated code accordingly. Even though system calls end up getting renumbered, this won't cause any problems in practice. CloudABI programs always call into the kernel through a kernel-supplied vDSO that has the numbers updated as well. Obtained from: https://github.com/NuxiNL/cloudabi Notes: svn path=/head/; revision=321514
* Decode FreeBSD11 fstatat calls.Mark Johnston2017-07-191-0/+3
| | | | Notes: svn path=/head/; revision=321258
* Sort the compat11.* syscalls I added. Remove duplicate compat11.stat.Warner Losh2017-06-261-8/+6
| | | | | | | Submitted by: jhb@ Notes: svn path=/head/; revision=320389
* Decode FreeBSD 11 compat stat, fstat and lstat calls.Warner Losh2017-06-231-0/+26
| | | | Notes: svn path=/head/; revision=320279
* Add abstime kqueue(2) timers and expand struct kevent members.Konstantin Belousov2017-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This change implements NOTE_ABSTIME flag for EVFILT_TIMER, which specifies that the data field contains absolute time to fire the event. To make this useful, data member of the struct kevent must be extended to 64bit. Using the opportunity, I also added ext members. This changes struct kevent almost to Apple struct kevent64, except I did not changed type of ident and udata, the later would cause serious API incompatibilities. The type of ident was kept uintptr_t since EVFILT_AIO returns a pointer in this field, and e.g. CHERI is sensitive to the type (discussed with brooks, jhb). Unlike Apple kevent64, symbol versioning allows us to claim ABI compatibility and still name the new syscall kevent(2). Compat shims are provided for both host native and compat32. Requested by: bapt Reviewed by: bapt, brooks, ngie (previous version) Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D11025 Notes: svn path=/head/; revision=320043
* Decode arguments to sched_* family of system calls.John Baldwin2017-06-161-0/+29
| | | | | | | | | | This includes decoding both scheduler policy constants and the sched_param structure for sched_get_priority_max(), sched_get_priority_min(), sched_getparam(), sched_getscheduler(), sched_rr_get_interval(), sched_setparam(), and sched_setscheduler(). Notes: svn path=/head/; revision=320010
* Decode arguments to rtprio() and rtprio_thread().John Baldwin2017-06-101-0/+8
| | | | Notes: svn path=/head/; revision=319768
* Decode the 'howto' argument to reboot().John Baldwin2017-06-101-0/+5
| | | | Notes: svn path=/head/; revision=319766
* Decode the arguments to quotactl().John Baldwin2017-06-101-0/+6
| | | | Notes: svn path=/head/; revision=319764
* Decode the arguments to ptrace().John Baldwin2017-06-101-0/+6
| | | | | | | This does not decode structures returned by ptrace(). Notes: svn path=/head/; revision=319763
* Decode arguments to getpriority() and setpriority().John Baldwin2017-06-101-0/+7
| | | | Notes: svn path=/head/; revision=319762