aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* If copy_file_range(2) fails with EXDEV, use fall-back.Poul-Henning Kamp2023-04-041-1/+1
|
* fs/msdosfs: add tracking of free root directory entriesStefan Eßer2023-03-291-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D38987
* pkill: tests: do a pass for case-sensitive conflictsKyle Evans2023-03-209-8/+8
| | | | | | | | As in 76b6a59f9d30a5a39a5ed, encode upper-case flag tests with a leading underbar to avoid collisions (thus, erroneously dirty git repos) on case-sensitive filesystems. Sponsored by: Klara, Inc.
* pkill: use an ARG_MAX size buffer for argument matchingKyle Evans2023-03-204-5/+220
| | | | | | | | | | Right now pkill/pgrep cut off at _POSIX2_LINE_MAX (2048), but argument strings can be much larger (ARG_MAX is 256K/512K). Stop arbitrarily cutting the search off at 2K, rather than documenting the limit. Reviewed by: allanjude (earlier version), des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38663
* sh(1): fix history file write checkingDaniel Kolesa2023-03-201-1/+1
| | | | | | | | | | | We cannot just compare histsizeval() against 0, since that returns a string pointer, which is always non-zero (non-null). The logic in sethistsize() initializes the history size to 100 with values that are non-number, and an empty string counts as that. Therefore, the only time we want to not write into history with HISTSIZE val set is when it's explicitly 0. MFC after: 2 weeks
* uuidgen(1): fix another typoBaptiste Daroussin2023-03-061-1/+1
|
* uuidgen(1): back to the past and fix typoBaptiste Daroussin2023-03-021-2/+2
| | | | Reported by: ceri
* uuidgen: add -c for compact uuidBaptiste Daroussin2023-03-012-3/+35
| | | | | | | | It generates the uuid string but without the hyphen MFC After: 3 days Reviews by: tcberner Differential Revision: https://reviews.freebsd.org/D38820
* date.1: Examples: Use syntax that is also compatible with cshMateusz Piotrowski2023-02-271-2/+2
| | | | | MFC after: 1 month Sponsored by: Klara Inc.
* nproc: denote an incompatiblity with LinuxMateusz Guzik2023-02-152-2/+7
| | | | | | | | | On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel, while it does not on FreeBSD. Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting the same value, it will automagically unbreak should someone change the above.
* man: some typesetting and style fixes for recent additionsKonstantin Belousov2023-02-111-1/+2
| | | | | | | | | Mostly start each sentence from a new line. Also add more pretty typesetting to cdce(4). Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D38501
* Add nproc(1)Mateusz Guzik2023-02-084-0/+191
| | | | | | | | | | | This program prints the number of CPU threads it can run on, while respecting cpusets (or not, depending on switches). It aims to be compatible with nproc as found in GNU coreutils. Reviewed by: des Reviewed by: pstef Differential Revision: https://reviews.freebsd.org/D38386
* cp: Adjust the sparse file tests.Dag-Erling Smørgrav2023-02-083-23/+98
| | | | | | | | | | | * The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness. * Some of the seq commands were missing an argument. * Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem. Increase the hole size to 16 MB. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: cracauer Differential Revision: https://reviews.freebsd.org/D38414
* cp: Minor code cleanup.Dag-Erling Smørgrav2023-02-032-5/+3
| | | | | | | | | | | * Fix includes in utils.c, cf. style(9). * Fix type mismatch: readlink(2) returns ssize_t, not int. * It is not necessary to set errno to 0 as fts_read(3) already does it. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D38369
* timeout: Move from /usr/bin to /binMateusz Piotrowski2023-02-028-0/+828
| | | | | | | | | | | | | | | | | | | | | timeout(1) is used by /etc/rc.d/zfskeys. Unfortunately, having timeout(1) installed in /usr/bin causes problems when /usr is an encrypted ZFS partition. Implementing timeout(1) in sh(1) is not trivial. A more elegant solution is to move timeout(1) to /bin so that it is available to early services in the boot process. PR: 265221 Reviewed by: allanjude, des, imp Approved by: allanjude, des, imp Reported by: Ivan <r4@sovserv.ru> Fixes: 33ff39796ffe Add zfskeys rc.d script for auto-loading encryption keys MFC after: 1 week Relnotes: yes Sponsored by: Modirum MDPay Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D38344
* cp: Simplify the common case.Dag-Erling Smørgrav2023-02-022-90/+34
| | | | | | | | | | | | | | | | | | | * The allocated buffer is only used in the fallback case, so move it there. The argument for passing it in from the caller was that if malloc(3) were to fail, we'd want it to fail before we started copying anything, but firstly, it was already not in the right place to ensure that, and secondly, malloc(3) never fails (except in very contrived circumstances, such as an unreasonable RLIMIT_AS or RLIMIT_DATA). * Remove the mmap(2) option. It is almost never beneficial, especially when the alternative is copy_file_range(2), and it adds needless complexity and indentation. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: rmacklem, mav Differential Revision: https://reviews.freebsd.org/D38291
* cp: Add tests involving sparse files.Dag-Erling Smørgrav2023-02-021-0/+90
| | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38290
* df: Return non-zero status on write failure.Dag-Erling Smørgrav2023-01-171-8/+8
| | | | | | | | While here, complete the libxo conversion and switch return value to standard constants. MFC after: 1 week Sponsored by: Klara, Inc. Differential revision: https://reviews.freebsd.org/D38097
* sh(1): Allow non-printing characters in prompt stringsJuraj Lutter2022-12-223-10/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce new prompt format characters: - '\[' starts the sequence of non-printing chatacters - '\]' ends the sequence of non-printing characters Within these sequences, the following characters are now supported: - '\a' emits ASCII BEL (0x07, 007) character - '\e' emits ASCII ESC (0x1b, 033) character - '\r' emits ASCII CR (0x0d, 015) character - '\n' emits ASCII CRLF sequence These can be used to embed ANSI sequences into prompt strings. Example in .shrc: PS1="\[\e[7m\]\u@\h\[\e[0m\]:\w \\$ " This tries to maintain some degree of compatibility with GNU bash, that uses GNU readline library (which behaves slightly different from BSD editline): It has two "non-printing boundary" characters: - RL_PROMPT_START_IGNORE (\001) - RL_PROMPT_END_IGNORE (\002) while BSD editline only has one (when using EL_PROMPT_ESC setting), so for this purpose, ASCII \001 was chosen and both \[ and \] emits this character. And while here, enlarge PROMPTLEN from 128 to 192 characters. Reviewed by: jilles Approved by: jilles Differential Revision: https://reviews.freebsd.org/D37701
* bin/uuidgen: add support for v4 uuidsTobias C. Berner2022-12-172-12/+67
| | | | | | | | | | | | | | The version 4 UUID is meant for generating UUIDs from truly-random or pseudo-random numbers. [1] bin/uuidgen gained the new flag '-r' to create version 4 UUID. [1] RFC 4122, https://www.rfc-editor.org/rfc/rfc4122#section-4.4 Reviewed by: pstef Approved by: bapt MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D37695
* csh: install hard link with same mode as targetEd Maste2022-11-291-1/+4
| | | | | | | | | | | | | Previously when using NO_ROOT we recorded METALOG entries for the /.cshrc hard link with a different file mode than the link target, which is not permitted. We cannot just set LINKMODE here as it would also apply to the hard link for the tcsh binary. Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37499
* sh: install hard link with same mode as targetEd Maste2022-11-231-0/+1
| | | | | | | | | | Previously when using NO_ROOT we recorded a METALOG entry for the /.profile hard link with a different mode than the link target, which is not permitted. Reviewed by: bapt Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37476
* ls(1): add a -v flag to sort naturallyAymeric Wibo2022-10-306-12/+67
| | | | | | | | | | | | Add a -v flag for ls which sorts entries following a natural ordering using strverscmp(3) (e.g. "bloem1 bloem9 bloem10" as opposed to "bloem1 bloem10 bloem9"). Update the manual page and add a test case. Reviewed by: pauamma, bcr Tested by: pstef Differential Revision: https://reviews.freebsd.org/D36407
* chio: Mark some arguments as unused.Warner Losh2022-10-251-2/+2
| | | | Sponsored by: Netflix
* sh: when loading profile, read only .sh files.Dag-Erling Smørgrav2022-10-221-8/+3
| | | | | | | | Reviewers: jilles, eugen_grosbein.net, cy Subscribers: imp Differential Revision: https://reviews.freebsd.org/D37034
* pax: update date parsing code (from OpenBSD)Dag-Erling Smørgrav2022-10-193-65/+78
| | | | | Sponsored by: Klara, Inc. MFC after: 1 week
* sh: when loading profile, skip obvious scratch files.Dag-Erling Smørgrav2022-10-031-0/+5
| | | | Differential Revision: https://reviews.freebsd.org/D36856
* stty(1): provide details about interaction with job controlKonstantin Belousov2022-10-021-1/+27
| | | | | | | | | | | | Describe a shell trick to do non-blocking modification of the terminal settings, by ignoring job control signals with trap built-in. PR: 266627 With input from: jilles Reviewed by: pauamma Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36745
* sh: read more profile files.Dag-Erling Smørgrav2022-10-011-0/+20
| | | | | Differential Revision: https://reviews.freebsd.org/D36505 MFC after: 1 month
* sh: Fix mismatch in array bounds for vforkexecshell().John Baldwin2022-09-281-1/+1
| | | | | | Reviewed by: imp, jilles, emaste Reported by: GCC -Warray-parameter Differential Revision: https://reviews.freebsd.org/D36760
* pax: name all supported formats.Dag-Erling Smørgrav2022-09-131-2/+3
| | | | Sponsored by: Klara, Inc.
* pax: comment typo fixes from NetBSD / OpenBSD.Dag-Erling Smørgrav2022-09-1310-31/+32
| | | | Sponsored by: Klara, Inc.
* pax: remove 4.4BSD compatibilityDag-Erling Smørgrav2022-09-1312-245/+0
| | | | Sponsored by: Klara, Inc.
* Handle NULL return from localtime(3) in ls(1) and find(1)Kirk McKusick2022-09-091-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ls(1) (with -l option) and find(1) (with -ls option) utilties segment fault when operating on files with very large modification times. A recent disk corruption set a spurious bit in the mtime field of one of my files to 0x8000000630b0167 (576460753965089127) which is in year 18,266,940,962. I discovered the problem when running fsck_ffs(8) which uses ctime(3) to convert it to a readable format. Ctime cannot fit the year into its four character field, so returns ??? ??? ?? ??:??:?? ???? (typically Thu Nov 24 18:22:48 2021). With the filesystem mounted, I used `ls -l' to see how it would report the modification time and it segment faulted. The find(1) program also segment faulted (see script below). Both these utilities call the localtime(3) function to decode the modification time. Localtime(3) returns a pointer to a struct tm (which breaks things out into its component pieces: year, month, day, hour, minute, second). The ls(1) and find(1) utilities then print out the date based on the appropriate fields in the returned tm structure. Although not documented in the localtime(3) manual page, localtime(3) returns a NULL pointer if the passed in time translates to a year that will not fit in an "int" (which if "int" is 32-bits cannot hold the year 18,266,940,962). Since ls(1) and find(1) do not check for a NULL struct tm * return from localtime(3), they segment fault when they try to dereference it. When localtime(3) returns NULL, the attached patches produce a date string of "bad date val". This string is chosen because it has the same number of characters (12) and white spaces (2) as the usual date string, for example "Sep 3 22:06" or "May 15 2017". The most recent ANSI standard for localtime(3) does say that localtime(3) can return NULL (see https://pubs.opengroup.org/onlinepubs/9699919799/ and enter localtime in the search box). Our localtime(3) man page should be updated to indicate that NULL is a possible return. More importantly, there are over 100 uses of localtime(3) in the FreeBSD source tree (see Differential Revision D36474 for the list). Most do not check for a NULL return from localtime(3). Reported by: Peter Holm Reviewed by: kib, Chuck Silvers, Warner Losh MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36474
* cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.Alexander Motin2022-08-301-10/+9
| | | | | | | It allows to not use mmap() for small files, which is not helpful in case of ZFS. Should be no functional change. MFC after: 1 week
* sh: nullify ENV in testsPiotr Pawel Stefaniak2022-08-203-3/+3
| | | | | | | | This is to avoid loading .shrc which may contain commands that would result in output different than expected. Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D35876
* sh: accept fc options grouped behind one '-'Piotr Pawel Stefaniak2022-08-206-21/+41
| | | | | | | | | | | | | | | As per Utility Syntax Guidelines, accept both forms: -l -n and -ln. To do that, anticipate the source string for the next option that will be parsed by nextopt(). It's not always *argptr, sometimes it is nextopt_optptr. To simplify the check for not_fcnumber, slightly modify nextopt() to always nullify nextopt_optptr in cases where it would have been set to point to a NUL character. Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D35836
* For man page references found in ports, indicate the respective port.Jens Schweikhardt2022-08-143-8/+8
|
* sh.1: Fix a mandoc warningGordon Bergling2022-07-311-1/+2
| | | | | | - new sentence, new line MFC after: 3 days
* date: remove some ambiguity in tzdata referencesKyle Evans2022-07-281-10/+8
| | | | | | | | | | | The use of 'package' in this could be understood to mean a FreeBSD package provided by pkg, rather than the fact that we use data provided by IANA. Re-word it to clearly identify `tzdata` as the IANA Time Zone Database on first use, then drop subsequent uses of the word 'package'. Reviewed by: 0mp, pauamma, philip Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35966
* date: attempt to more accurately describe year limitations with -vKyle Evans2022-06-281-2/+10
| | | | | | | | | | | The previous description was both incorrect and incomplete in its description -- the 2038 limit doesn't apply on !i386 platforms, and it didn't note that values above 100 are accepted and interpreted differently. Further, it didn't note that absolute years are accepted. Reviewed by: pauamma_gundo.com (manpages) Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35360
* sleep.1: Fix mdoc styleMateusz Piotrowski2022-05-251-6/+7
| | | | | Fixes: be038c3afcae bin/sleep: add support for multiple delay values MFC after: 1 week
* stty: Remove stray '-'.Warner Losh2022-05-241-2/+2
| | | | | | | | There's a stray '-' that causes Fl to double the dash, but that's not how the command works. MFC After: 2 days Sponsored by: Netflix
* bin/sleep: document more non-standard featuresStefan Eßer2022-05-241-3/+4
| | | | | | | Add support of other time units than seconds to the IMPLEMENTATION NOTES section of the man page. MFC after: 1 week
* bin/sleep: add support for multiple delay valuesStefan Eßer2022-05-242-26/+40
| | | | | | | | | The sleep time is calculated as the sum of all arguments passed. This makes the FreeBSD version of sleep functionally compatible with the version in GNU coreutils. MFC after: 1 week
* bin/sleep: add support for units other than secondsA. Mallory2022-05-242-5/+25
| | | | | | | | | | | | | | | | The coreutils version of this command accepts a unit designation of s, m, h, or d (for seconds, minutes, hours, days) immediately following the number of (fractional) units to delay. The submitted patch has been modified in one detail: the test meant to detect the presence of the unit modified was not specific (!= 1) and would have accepted a non-numeric initial element or extra characters following the union. The committed version accepts only the number immediately followed by one of the defined unit designators and no further characters. PR: 264162 MFC after: 1 week
* pax(1): Remove a few double words in source code commentsGordon Bergling2022-04-091-4/+4
| | | | | | - s/an an/an/ MFC after: 3 days
* cp: fix -R recursion detectionKyle Evans2022-04-062-42/+57
| | | | | | | | | | | | | | | | | | | | | | The correct logic is a lot simpler than the previous iteration. We record the base fts_name to avoid having to worry about whether we needed the root symlink name or not (as applicable), then we can simply shift all of that logic to after path translation to make it less fragile. If we're copying to DNE, then we'll have swapped out the NULL root_stat pointer and then attempted to recurse on it. The previously nonexistent directory shouldn't exist at all in the new structure, so just back out from that tree entirely and move on. The tests have been amended to indicate our expectations better with subdirectory recursion. If we copy A to A/B, then we expect to copy everything from A/B/* into A/B/A/B, with exception to the A that we create in A/B. Reviewed by: bapt Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34655
* Correct source markup. No change to output.Greg Lehey2022-03-301-8/+8
| | | | Reported by: 0mp@
* Remove reference to kernel clock time zone.Greg Lehey2022-03-301-2/+8
| | | | | | Add references. Reported by: philip@