aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys
Commit message (Collapse)AuthorAgeFilesLines
* file: Add a fd flag with O_RESOLVE_BENEATH semanticsMark Johnston2026-02-091-20/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | The O_RESOLVE_BENEATH openat(2) flag restricts name lookups such that they remain under the directory referenced by the dirfd. This commit introduces an implicit version of the flag, FD_RESOLVE_BENEATH, stored in the file descriptor entry. When the flag is set, any lookup relative to that fd automatically has O_RESOLVE_BENEATH semantics. Furthermore, the flag is sticky, meaning that it cannot be cleared, and it is copied by dup() and openat(). File descriptors with FD_RESOLVE_BENEATH set may not be passed to fchdir(2) or fchroot(2). Various fd lookup routines are modified to return fd flags to the caller. This flag will be used to address a case where jails with different root directories and the ability to pass SCM_RIGHTS messages across the jail boundary can transfer directory fds in such as way as to allow a filesystem escape. PR: 262180 Reviewed by: kib MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D50371 (cherry picked from commit f35525ff2053e026a423e852136d73ed93c95803)
* stat(2): Document the st_rdev fieldDag-Erling Smørgrav2025-08-271-1/+4
| | | | | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D51946 (cherry picked from commit 4eaa7f66620c33957ff9a929820cb791f7fe5578)
* Canonicalize the name of the FreeBSD FoundationLi-Wen Hsu2025-02-1910-10/+10
| | | | | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation (cherry picked from commit dab59af3bcc7cb7ba01569d3044894b3e860ad56) (cherry picked from commit ef3ed0726f2230e38df76a32a3b9ff145147af65)
* munmap.2: Remove EINVAL for negative lenEd Maste2025-01-201-1/+1
| | | | | | | | | len is unsigned (it is size_t), so cannot be negative. Sponsored by: The FreeBSD Foundation (cherry picked from commit fab411c4fd5224e3dd44e0eb288d60b27480e2d1) (cherry picked from commit e2cbfa1f5045019d34eb0091db7755c151ea06d5)
* munmap.2: Unaligned addresses do not return errorEd Maste2025-01-201-4/+1
| | | | | | | | | | | | | | We previously claimed that non-page-aligned addresses would return EINVAL, but the address is in fact rounded down to the page boundary. Reported by: Harald Eilertsen <haraldei@anduin.net> Reviewed by: brooks Sponsored by: The FreeBSD Foundation Fixes: dabee6fecc67 ("kern_descrip.c: add fdshare()/fdcopy()") Differential Revision: https://reviews.freebsd.org/D48465 (cherry picked from commit 9e36aaf0c24cf158e83c69c1d2312c000c3c36f3) (cherry picked from commit 61c50909354ace6f07d0b2113f10965f4546e0ed)
* procctl.2: Editing passJohn Baldwin2024-12-271-168/+244
| | | | | | | | | | | | | | | - Add some missing .Pp macros after the end of literal blocks and some lists to ensure there is a blank line before the following text. - Use an indent of Ds for nested lists to reduce excessive indentation and make the bodies of the nested list items easier to read. - Various and sundry rewordings and clarifications. Reviewed by: kib, emaste Differential Revision: https://reviews.freebsd.org/D47782 (cherry picked from commit 8277c790179304159c2e4dcb1d99552518d5be8e)
* manuals: Misc macro typosGraham Percival2024-12-273-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were reported by `mandoc -T lint` as ERROR: skipping unknown macro When these pages were rendered with `man`, the "unknown macro" meant that the entire line was omitted from the output. Obvious typos in: lib/libsys/swapon.2 lib/libsys/procctl.2 share/man/man9/firmware.9 lib/libcasper/services/cap_net/cap_net.3: 'mode' describes a function argument. lib/libsys/statfs.2: there's no .Tm command ("trademark?"), and .Tn ("tradename") is deprecated, so remove the macro entirely. usr.sbin/mfiutil/mfiutil.8: man was interpreting '/dev/' as a macro (which it didn't recognize). share/man/man4/qat.4: same issue as above, but with '0'. In this case, given the context of the previous line, rewriting as "Value '0'" seemed more appropriate. usr.sbin/mlx5tool/mlx5tool.8: typo in .Xr Signed-off-by: Graham Percival <gperciva@tarsnap.com> Sponsored by: Tarsnap Backup Inc. Reviewed by: concussious, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1417 (cherry picked from commit 2878d99dfcfbdd7a415a7f31cf95fbd53fc8e581)
* manuals: Fix errors in .2 pagesGraham Percival2024-12-276-6/+6
| | | | | | | | | | | | | | | | | | | | | | These were reported by `mandoc -T lint ...` as errors. fhlink.2, fhreadlink.2: remove unneeded block closing. getfh.2, procctl.2: add necessary block closing. ptrace.2: -width only takes one argument. swapon.2: <sys/vmparam.h> and <vm/swap_pager.h> weren't being displayed, because .It is for a list item whereas .In is for included files. Also, we want a blank line between <sys/ > headers and the other one. Signed-off-by: Graham Percival <gperciva@tarsnap.com> PR: 281597 Reviewed by: mhorne Sponsored by: Tarsnap Backup Inc. (cherry picked from commit 650056363baddb83c61c85b0539ee536f3d4b56c)
* access(2): Discourage use of these system calls.Dag-Erling Smørgrav2024-05-231-55/+50
| | | | | | | | | | Fixes: 421025a274fb PR: 262895 MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45240 (cherry picked from commit a4be1eb21165d7aedae9dc6634528619ff10d025)
* access.2: Mention that lstat(2) should be used for symbolic linksGordon Bergling2024-05-231-1/+10
| | | | | | | | | | | | | | | access(), eaccess() and faccessat() will always dereference symbolic links. So add a note in the manual page, that lstat(2) should be used in the case of symbolic links. PR: 262895 Reviewed by: gbe, pauamma_gundo.com MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44890 (cherry picked from commit 421025a274fb5759b3ecc8bdb30b24db830b45ae)
* clock_gettime.2: fix markupEd Maste2024-05-131-20/+20
| | | | | | | | | | | | The CLOCK_* constants are "defined variable or preprocessor constants" and so use .Dv. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45106 (cherry picked from commit 2d29d2ecebf8ea19221995b3ea2e3a7ac700bf81) (cherry picked from commit 0e0220d11addc60fe7ed6fca79aefac2a3a9af27)
* clock_gettime.2: Clarify CLOCK_*Mateusz Piotrowski2024-05-131-3/+12
| | | | | | | | Clarify that CLOCK_* (e.g., CLOCK_REALTIME) do not necessarily default to CLOCK_*_FAST. PR: 259642 (cherry picked from commit 16e4487e5f82e1ff501fe5af6afbfbd0435a1cbf)
* gettimeofday.2: Do mention improbable future removalMateusz Piotrowski2024-05-041-5/+3
| | | | | | | | | | | | | As kib@ noted: > Obviously gettimeofday(2) is not going to be removed > even in the far future. Reported by: kib Fixes: 4395d3ced5cf Document that gettimeofday() is obsolescent MFC after: 3 days (cherry picked from commit 6662c2312e956439652ce2d06b42753b6a78fc61)
* Document that gettimeofday() is obsolescentMateusz Piotrowski2024-05-041-1/+24
| | | | | | | | | Reported by: kaktus Reviewed by: kaktus, pstef MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D23942 (cherry picked from commit 4395d3ced5cfa46df400b5bb9996f9d74476997e)
* read.2: Describe debug.iosize_max_clampKonstantin Belousov2024-02-141-5/+14
| | | | | | PR: 276937 (cherry picked from commit 3e9515846f8cbff0ecccaab65d9f70890d04429e)
* Add kcmp(2) userspace bitsKonstantin Belousov2024-02-111-0/+4
| | | | (cherry picked from commit 211bdd601ee51f90da9b123807ef68ac122116b9)
* open(2): describe *at behavior for dirfd opened without O_SEARCHKonstantin Belousov2024-02-011-14/+24
| | | | (cherry picked from commit a570fe4d0dd979ce099374259ffc45d56ae4e471)
* _umtx_op.2: Fix a typo in the manual pageGordon Bergling2024-01-231-1/+1
| | | | | | - s/interpeted/interpreted/ (cherry picked from commit b2ec175fcaac90fc6a1caf066656eaa092f32611)
* sigfastblock.2: Fix a typo in the manual pageGordon Bergling2024-01-231-1/+1
| | | | | | - s/successfull/successful/ (cherry picked from commit a70008e95b907336bddbcc2aa9d567df6e3a41b6)
* Remove _POSIX_PRIORITIZED_IO references from man pagesAlan Somers2024-01-193-28/+2
| | | | | | | | | | | | | We don't support it, so there's no need to tell readers what would happen if we did. Also, don't remind the user that a certain field is ignored by aio_read. Mentioning every ignored field would make the man pages too verbose. Sponsored by: Axcient Reviewed by: Pau Amma <pauamma@gundo.com> Differential Revision: https://reviews.freebsd.org/D42622 (cherry picked from commit 18e2c4175f78f1aaa648dd7fb7530220aed23671)
* sigaction.2: clarify that fork isn't async-signal-safe, but _Fork isAlan Somers2024-01-191-2/+2
| | | | | | | | | | [skip ci] Sponsored by: Axcient Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D42865 (cherry picked from commit c2ed7a63604fc86244adee2966e19f8aba2a07cb)
* setfib.2: Consistently capitalize "FIB"Mark Johnston2024-01-111-4/+4
| | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. (cherry picked from commit ee7d5ba1b55441476643983d3f70df5ee9ea97c4)
* copy_file_range.2: Clarify that only regular files workRick Macklem2024-01-111-5/+13
| | | | | | | | | | | | | | | | | | | PR#273962 reported that copy_file_range(2) did not work on shared memory objects and returned EINVAL. Although the reporter felt this was incorrect, it is what the Linux copy_file_range(2) syscall does. Since there was no collective agreement that the FreeBSD semantics should be changed to no longer be Linux compatible, copy_file_range(2) still works on regular files only. This man page update clarifies that. If, someday, copy_file_range(2) is changed to support non-regular files, then the man page will need to be updated to reflect that. PR: 273962 (cherry picked from commit 84b4342c0d7ac8a3187309a978d41e6765154cc1)
* ptrace(2): Disabling: Describe influence of security.bsd.see_jail_procOlivier Certner2023-12-211-15/+21
| | | | | | | | | | Reviewed by: mhorne, emaste, pauamma_gundo.com Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D41109 (cherry picked from commit d952820105d6a2ad87ddf3bdc6c5fc5215d13b87) Approved by: markj (mentor)
* aio_read.2: correct the description of aio_bufAlan Somers2023-11-301-2/+2
| | | | | | | | | | | | | Looks like a copypasta from aio_write.2. [skip ci] Reported by: Paul Floyd <pjfloyd@wanadoo.fr> Sponsored by: Axcient Reviewed by: jilles (manpages) Differential Revision: https://reviews.freebsd.org/D42621 (cherry picked from commit 04cfe6c12ccc75624dc87ab8f44c4852b16f0c4f)
* procctl.2: improve phrasing for ASLR disableBrooks Davis2023-11-131-3/+3
| | | | | | | | Reported by: jrtc27 Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D42364 (cherry picked from commit 4894205482555447c6b3372598c7589a66596724)
* Add membarrier(2)Konstantin Belousov2023-10-261-0/+1
| | | | (cherry picked from commit 4a69fc16a583face922319c476f3e739d9ce9140)
* ktrace.2: correct kern.ktrace.genio_size sysctl nameEd Maste2023-10-131-1/+1
| | | | | | | | | | | | The man page had `kern.ktrace.geniosize` but the sysctl node contains an underscore. PR: 274274 Reported by: Ivan Rozhuk Sponsored by: The FreeBSD Foundation (cherry picked from commit a572dfa1bfe00cec93b27d8848ca49562cab5e3c) (cherry picked from commit 2fe06dda0a8abced5851188ed2cb76d1759efa19)
* clock_gettime.2: Add cross references and fix linter warningsMateusz Piotrowski2023-10-041-3/+7
| | | | | | MFC after: 3 days (cherry picked from commit 13a9da7d5550392a754fcc72d8ec74c0ddbec26f)
* Remove "All Rights Reserved" from Foundation copyrightsEd Maste2023-09-2551-51/+0
| | | | | | | | Sponsored by: The FreeBSD Foundation (cherry picked from commit 7fde0187cc443468561f0a30d589ff0cfe45eef5) (cherry picked from commit 560e22c8fe460e00d16e5268fe1fbb316ad81101) (cherry picked from commit 5b5fa75acff11d871d0c90045f8c1a58fed85365)
* swapon.2: correct FreeBSD release that introduced swapoffEd Maste2023-09-211-1/+1
| | | | | | | | It was introduced in 92da00bb245b, after 5.0 and beforen 5.1. Reported in https://github.com/ziglang/zig/issues/16590. (cherry picked from commit b15f6400376a90d3b00aa3ac00666f683f975376) (cherry picked from commit f4bb052a789eae8ddcbfa7a9c00bc781b54e13c4)
* getdirentries.2: Reference dir(5)Mateusz Piotrowski2023-09-121-1/+2
| | | | | | | | | As a note, parts of manual pages getdirentries(2) and dir(5) should probably be consolidated. MFC after: 3 days (cherry picked from commit 5b7a776f481891f10820a0b4838d0e0feb60b8ad)
* getdirentries.2: Improve readability of dirent membersMateusz Piotrowski2023-09-121-6/+6
| | | | | | MFC after: 3 days (cherry picked from commit 52d374a067002fc42409b32059ec8b8506a70429)
* getdirentries.2: Reference directory(3)Mateusz Piotrowski2023-09-121-2/+3
| | | | | | MFC after: 3 days (cherry picked from commit 3a02df5e27d2eeabffd761ff5cb79496a6d796ea)
* lio_listio(2): Allow LIO_READV and LIO_WRITEV.Thomas Munro2023-09-061-1/+15
| | | | | | | | | | | | | | | Allow multiple vector IOs to be started with one system call. aio_readv() and aio_writev() already used these opcodes under the covers. This commit makes them available to user space. Being non-standard extensions, they're only visible if __BSD_VISIBLE is defined, like the functions. Reviewed by: asomers, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31627 (cherry picked from commit f30a1ae8d5290a52e898279bafc38556bf16bed8)
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-23113-113/+0
| | | | | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b2c76c41be32)
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-2396-192/+0
| | | | | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit fa9896e082a1)
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit d0b2dbfa0ecf)
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-2359-118/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in main: (cherry picked from commit 1d386b48a555)
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit 42b388439bd3)
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-234-8/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b3e7694832e8)
* libc vdso time functions: correctly convert errors into errnosKonstantin Belousov2023-08-192-2/+10
| | | | (cherry picked from commit 41acfee690da6289d570338e6365c1d7ef61dad5)
* man: Link _Fork(2) man pageDmitry Chagin2023-08-071-0/+1
| | | | | | | | Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D41221 MFC after: 1 week (cherry picked from commit 03eab865aabab1e6737ad0fd1537f7d0a8c3ee02)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-258-8/+8
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* open(2): fix typoKonstantin Belousov2023-06-051-1/+1
| | | | (cherry picked from commit 1fc174cba6e0b949f7499d195dc36bf8df15df4f)
* __acl_get_fd(2), __acl_aclcheck_fd(2): enable for O_PATH filedescriptorsKonstantin Belousov2023-06-051-1/+2
| | | | | | PR: 271704 (cherry picked from commit 7a292504bad8467915f072f0576b2a07c76de1f5)
* MFC: listen(2): improve administrator control over loggingEugene Grosbein2023-05-301-2/+13
| | | | | | | | | | | | | | | | | | | As documented in listen.2 manual page, the kernel emits a LOG_DEBUG syslog message if a socket listen queue overflows. For some appliances, it may be desirable to change the priority to some higher value like LOG_INFO while keeping other debugging suppressed. OTOH there are cases when such overflows are normal and expected. Then it may be desirable to suppress overflow logging altogether, so that dmesg buffer is not flooded over long run. In addition to existing sysctl kern.ipc.sooverinterval, introduce new sysctl kern.ipc.sooverprio that defaults to 7 (LOG_DEBUG) to preserve current behavior. It may be changed to any value in a range of 0..7 for corresponding priority or to -1 to suppress logging. Document it in the listen.2 manual page. (cherry picked from commit 4824d788725987bccff53dec8c103cbac455b3ed)
* msdosfs: fix debug print format and parameterStefan Eßer2023-05-011-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Building with -DMSDOSFS_DEBUG failed due to a format mismatch and a variable that has been renamed but not updated in the printf() parameter list. (cherry picked from commit 2d8cf575d5778781928699f9b7cfb448bd2f1f8e) fs/msdosfs: add tracking of free root directory entries This update implements tallying of free directory entries during create, delete, or rename operations on FAT12 and FAT16 file systems. Prior to this change, the total number of root directory entries was reported as number of inodes, but 0 as the number of free inodes, causing system health monitoring software to warn about a suspected disk full issue. The FAT12 and FAT16 file systems provide a limited number of root directory entries, e.g. 512 on typical hard disk formats. The valid range of values is 1 to 65535, but the msdosfs code will effectively round up "odd" values to the next multiple of 16 (e.g. 513 would allow for 528 root directory entries). This update implements tracking of directory entries during create, delete, or rename operations, with initial values determined by scanning the directory when the file system is mounted. Total and free directory entries are reported in the f_files and f_ffree elements of struct statfs, despite differences in semantics of these values: - There is no limit on the number of files and directories that can be created on a FAT file system. Only the root directory of FAT12 and FAT16 file systems is limited, any number of files can still be created in sub-directories, even when 0 free "inodes" are reported. - A single file can require 1 to 21 directory entries, depending on the character set, structure, and length of the name. The DOS 8.3 style file name takes up 1 entry, and if the name does not comply with the syntax of a DOS 8.3 file name, 1 additional entry is used for each 13 characters of the file name. Since all these entries have to be contiguous, it is possible that a file or directory with a long name can not be created, despite a sufficient total number of free directory entries. - Renaming a file can require more directory entries than currently allocated to store its long name, which may prevent an in-place update of the name if more entries are needed. This may cause a rename operation to fail if no contiguous range of free entries for the new name can be found. - The volume label is stored in a directory entry. An empty FAT file system with a volume label will therefore show 1 used "inode" in df. - The perceentage of free inodes shown in df or monitoring tools does only represent the state of the root directory of a FAT12 or FAT16 file system. Neither does a reported value of 0% free inodes does prevent files from being created in sub-directories, nor does a value of 50% free inodes guarantee that even a single file with a "long" name can be created in the root directory (if every other directory entry is occupied and there are no 2 contiguous entries). The statfs(2) and df(1) man pages have been updated with a notice regarding the possibly different semantics of values reported as total and free inodes for non-Unix file systems. PR: 270053 Reported by: Ben Woods <woodsb02@freebsd.org> Approved by: mckusick Differential Revision: https://reviews.freebsd.org/D38987 (cherry picked from commit c33db74b5323480fba7adef58e8aa88f6091d134) fs/msdosfs: Fix potential panic and size calculations Some combinations of FAT12 file system parameters could cause a kernel panic due to an unmapped access if the size of the FAT was larger than the CPU page size. The reason is that FAT12 uses 3 bytes to store 2 FAT pointers, leading to partial FAT pointers at the end of buffers of a size that is not a multiple of 3. With a typical page size of 4 KB, this caused the FAT entry at byte offsets 4095 and 4096 to cross the page boundary, with only the first page mapped. This was fixed by adjusting the mapping to always cover both bytes of each FAT entry. Testing revealed 2 other inconsistencies that are fixed by this commit: 1) The calculation of the size of the data area did not take into account the fact that the first two data block numbers are reserved and that the data area starts with block 2. This could cause a FAT12 file system created with the maximum supported number of blocks to be incorrectly identified as FAT16. 2) The root directory does not take up space in the data area of a FAT12 or FAT16 file system, since it is placed into a reserved area outside of that data area. This commits makes stat() report the logical size of the root directory, but with 0 blocks allocated from the data area. PR: 270587 Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D39386 (cherry picked from commit 0728695c63efda298feccefb3615c23cb6682929)
* umtx: allow to configure minimal timeout (in nanoseconds)Konstantin Belousov2023-04-251-0/+11
| | | | | | PR: 270785 (cherry picked from commit 93ca6ff2958cace3b7b883ed797ea6539881a6a2)
* procctl: add state flags to PROC_REAP_GETPIDS reportsVal Packett2023-04-231-2/+8
| | | | (cherry picked from commit 77f0e198d9134b6ca2650d3a84d7db2d786ec0c0)