aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* Fix all warnings emitted in `make kernel-toolchain`Alex Richardson2021-01-071-1/+5
| | | | | | | | With this change and D27598 make kernel-toolchain no longer emits any warnings for me. Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D27599
* sh/tests: Add a second kind of binary scripts without #!Jilles Tjoelker2021-01-032-0/+11
| | | | | | | | One of the reasons for git commit e0f5c1387df23c8c4811f5b24a7ef6ecac51a71a was to make "actually portable executables" work. Add a test that is more like those. MFC after: 1 week
* cp(1): fix performance issue for large non-sparse file copiesRick Macklem2021-01-031-6/+5
| | | | | | | | | | | | | | | | | | | | PR252358 reported a serious performance problem when copying a large non-sparse file on a UFS file system. This problem seems to have been caused by a large number of SEEK_HOLE operations, with one done for each copy_file_range(2) call. This patch modifies cp(1) to use a large (SSIZE_MAX) len argument, reducing the number of system calls and resolving the performance issue. While here, convert the type of the "rcount" from "int" to "ssize_t" so that it is consistent with that returned by both read(2) and copy_file_range(2). PR: 252358 Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D27937
* Soften caveat about fractional seconds for sleep(1)Benjamin Kaduk2021-01-011-3/+3
| | | | | | | | | Support for fractional seconds has become much more widespread since this text was originally written. Reported by: Mark Eichin Reviewed by: gbe, jilles Differential Revision: https://reviews.freebsd.org/D26208
* Replace sscanf() by strtoul()Stefan Eßer2020-12-271-4/+5
| | | | | | | | | | | This change has been motivated by a mail from bde sent in 2015 in which he mentioned inappropriate use of sscanf() in 3 programs in /bin. This change removes the potential mismatch of the types of the return values and the variable width specified in the scan pattern. While there was no issue with the patterns and types used, the new code is simpler and more efficient.
* Simplify LS_COLWIDTHS processingStefan Eßer2020-12-271-72/+43
| | | | | | | | | | | | | | The previous version normalized the width list (replaced empty fields with "0") just to be able to use sscanf() on the string. It is much simpler to just parse the string as-is. The clearing of f_notabs is preserved for the case that less than 9 width values have been defined, but I do not understand the rationale for this particular condition. E.g., LS_COLWIDTHS="::::::::" will be counted as 9 defined fields (may clear f_notabs) but is no different fron LS_COLWIDTHS="" with regard to the field width (and that does not clear f_notabs, since there are less than 9 fields).
* sh: Explain duplicate tcsetpgrp() callsJilles Tjoelker2020-12-261-1/+6
| | | | This is a comment change only.
* Remove unused includes.Xin LI2020-12-232-4/+0
|
* Remove unused headers.Xin LI2020-12-124-7/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=368574
* Remove unneeded headers.Xin LI2020-12-125-6/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=368573
* fts_read: Handle error from a NULL return better.Bryan Drewery2020-12-086-6/+9
| | | | | | | | | | | | | | | | | | | | This is addressing cases such as fts_read(3) encountering an [EIO] from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be seen as a successful traversal in some of these cases while silently discarding expected work. As noted in r264201, fts_read() does not set errno to 0 on a successful EOF so it needs to be set before calling it. Otherwise we might see a random error from one of the iterations. gzip is ignoring most errors and could be improved separately. Reviewed by: vangyzen Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27184 Notes: svn path=/head/; revision=368467
* bin/setfacl: Little refactoring, no functional change.Gleb Popov2020-11-231-13/+13
| | | | | | | | | | | | | | | The acl_from_stat function accepts a stat_t * argument, but only uses its st_mode field. There is no reason to pass the whole struct, so make it accept a mode_t and rename the function to acl_from_mode. Linux has non-standard acl_from_mode function in its libacl, so naming the function this way may help discovering it during porting efforts. Reviewed by: tsoome, markj Approved by: markj Differential Revision: https://reviews.freebsd.org/D27292 Notes: svn path=/head/; revision=367958
* df: Remove support for mounting devicesMark Johnston2020-11-133-77/+5
| | | | | | | | | | | | This was marked deprecated in r329092, over two and a half years ago. This functionality is also buggy per PR 237368. PR: 237368 Reviewed by: brooks, cem, emaste, imp Differential Revision: https://reviews.freebsd.org/D27197 Notes: svn path=/head/; revision=367642
* Whitespace cleanupLi-Wen Hsu2020-10-291-5/+4
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=367136
* Remove superfluous `this` in commentLi-Wen Hsu2020-10-291-1/+1
| | | | | | | | | PR: 250721 Submitted by: Hiroya EBINE <hebiyan@protonmail.com> MFC after: 3 days Notes: svn path=/head/; revision=367134
* pwd(1): Add EXAMPLES sectionFernando Apesteguía2020-10-241-1/+21
| | | | | | | | | | | | Small EXAMPLES section. Add reference to realpath(1) due to similarity. Approved by: manpages (gbe@) Differential Revision: https://reviews.freebsd.org/D26862 Notes: svn path=/head/; revision=367012
* realpath(1): Add EXAMPLES section.Fernando Apesteguía2020-10-201-0/+8
| | | | | | | | | | Add a small example for this simple command. Approved by: manpages (gbe@) Differential Revision: https://reviews.freebsd.org/D26863 Notes: svn path=/head/; revision=366896
* ls(1): Use \& as an escape character for the ',' optionGordon Bergling2020-10-101-1/+1
| | | | | | | | Reported by: karels@, xtouqh at hotmail dot com MFC after: 1 day Notes: svn path=/head/; revision=366613
* pkill(1): Add EXAMPLES section to man pageFernando Apesteguía2020-10-051-1/+106
| | | | | | | | | | | | Add a dozen of examples to the EXAMPLES section for pgrep(1) and pkill(1). Flags covered: -f, -F, -n, -j, -l, -S, -x Approved by: mandoc (bcr@) Differential Revision: pkill(1): Add EXAMPLES section to man page Notes: svn path=/head/; revision=366448
* kenv(1): Add EXAMPLES to man pageFernando Apesteguía2020-10-051-1/+39
| | | | | | | | | | Add EXAMPLES section covering all the options Approved by: manpages (bcr@) Differential Revision: https://reviews.freebsd.org/D26664 Notes: svn path=/head/; revision=366447
* hostname(1): Add EXAMPLES to man pageFernando Apesteguía2020-10-051-1/+20
| | | | | | | | | | Add a very simple set of examples Approved by: manpages (bcr@) Differential Revision: https://reviews.freebsd.org/D26663 Notes: svn path=/head/; revision=366446
* df(1): Add EXAMPLES section to man pageFernando Apesteguía2020-10-051-11/+51
| | | | | | | | | | | | | * Add EXAMPLES section with four simple examples. * Simplify -H flag description. This makes easy to see the difference between this flag and -h * While here, fix .Tn deprecated macro. Approved by: manpages (bcr@) Differential Revision: https://reviews.freebsd.org/D26662 Notes: svn path=/head/; revision=366445
* pwait(1): Add EXAMPLES section to man pageFernando Apesteguía2020-10-051-2/+50
| | | | | | | | | | | | * Add small EXAMPLES section to the man page showing the different flags and exit codes. * Complete description for -v flag. Approved by: manpages (bcr@) Notes: svn path=/head/; revision=366444
* cp(1): Bugfixes for some issues reported by mandocGordon Bergling2020-10-031-3/+3
| | | | | | | | | - no blank before trailing delimiter MFC after: 1 week Notes: svn path=/head/; revision=366404
* ls(1): Bugfix for an issue reported by mandocGordon Bergling2020-10-031-1/+1
| | | | | | | | | - no blank before trailing delimiter MFC after: 1 week Notes: svn path=/head/; revision=366403
* cp: tests: fix weird 20 insertionKyle Evans2020-09-231-1/+2
| | | | | | | This slipped in at the last moment. =( Notes: svn path=/head/; revision=366060
* cp: add some basic testsKyle Evans2020-09-233-0/+75
| | | | | | | | | | | | | | | | | | | There are some tests available in the NetBSD test suite, but we don't currently pass all of those; further investigation will go into that. For now, just add a basic test as well as a test that copies from /dev/null to a file. The /dev/null test confirms that the file gets created if it's empty, then that it truncates the file if it's non-empty. This matches some usage that was previously employed in the build and was replaced in r366042 by a simpler shell construct. I will also plan on coming back to expand these in due time. MFC after: 1 week Notes: svn path=/head/; revision=366059
* build: provide a default WARNS for all in-tree buildsKyle Evans2020-09-181-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current default is provided in various Makefile.inc in some top-level directories and covers a good portion of the tree, but doesn't cover parts of the build a little deeper (e.g. libcasper). Provide a default in src.sys.mk and set WARNS to it in bsd.sys.mk if that variable is defined. This lets us relatively cleanly provide a default WARNS no matter where you're building in the src tree without breaking things outside of the tree. Crunchgen has been updated as a bootstrap tool to work on this change because it needs r365605 at a minimum to succeed. The cleanup necessary to successfully walk over this change on WITHOUT_CLEAN builds has been added. There is a supplemental project to this to list all of the warnings that are encountered when the environment has WARNS=6 NO_WERROR=yes: https://warns.kevans.dev -- this project will hopefully eventually go away in favor of CI doing a much better job than it. Reviewed by: emaste, brooks, ngie (all earlier version) Reviewed by: emaste, arichardson (depend-cleanup.sh change) Differential Revision: https://reviews.freebsd.org/D26455 Notes: svn path=/head/; revision=365887
* cp: fall back to read/write if copy_file_range failsAlan Somers2020-09-111-4/+35
| | | | | | | | | | | | | | | | Even though copy_file_range has a file-system agnostic version, it still fails on devfs (perhaps because the file descriptor is non-seekable?) In that case, fallback to old-fashioned read/write. Fixes "cp /dev/null /tmp/null" PR: 249248 Reported by: Michael Butler Reviewed by: mjg MFC-With: 365549 Differential Revision: https://reviews.freebsd.org/D26395 Notes: svn path=/head/; revision=365643
* cp: use copy_file_range(2)Alan Somers2020-09-101-21/+10
| | | | | | | | | | | | | | | | | This has three advantages over write(2)/read(2): * Fewer context switches and data copies * Mostly preserves a file's sparseness * On some file systems (currently NFS 4.2) the file system will perform the copy in an especially efficient way. Reviewed by: rmacklem MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D26377 Notes: svn path=/head/; revision=365549
* sh: Write absolute path in command -vV and typeJilles Tjoelker2020-09-015-11/+64
| | | | | | | | | | | | POSIX is pretty clear that command -v, command -V and type shall write absolute pathnames. Therefore, we need to prepend the current directory's name to relative pathnames. This can happen either when PATH contains a relative pathname or when the operand contains a slash but is not an absolute pathname. Notes: svn path=/head/; revision=365037
* ls(1): Update all POSIX references and correct the STANDARDS sectionGordon Bergling2020-08-311-9/+10
| | | | | | | | | | | | | | | - Update the POSIX references for non-standard ls(1) options - Simplify the STANDARDS section by mention both supported POSIX versions Reported by: hrs Reviewed by: hrs, bcr Approved by: hrs, bcr MFC after: 3 days X-MFC-With: r364449 Differential Revision: https://reviews.freebsd.org/D26210 Notes: svn path=/head/; revision=365004
* sh: Keep ignored SIGINT/SIGQUIT after set in a background jobJilles Tjoelker2020-08-285-2/+27
| | | | | | | | | | | | | | | | | | If job control is not enabled, a background job (... &) ignores SIGINT and SIGQUIT, but this can be reverted using the trap builtin in the same shell environment. Using the set builtin to change options would also revert SIGINT and SIGQUIT to their previous dispositions. This broke due to r317298. Calling setsignal() reverts the effect of ignoresig(). Reported by: bdrewery MFC after: 1 week Notes: svn path=/head/; revision=364919
* date.1: note possibly surprising behaviour of -j -fEd Maste2020-08-261-1/+4
| | | | | | | | | PR: 248918 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=364790
* ls(1): Update POSIX conformance from 2001 to 2008Gordon Bergling2020-08-211-10/+10
| | | | | | | | | | | | | | | | | | | - Update the options that are non-existing in POSIX from 2001 to 2008 - Update POSIX conformance in the STANDARDS section from 2001 to 2008 Verified by checking [1]. [1] https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/toc.htm PR: 140435 Submitted by: Dan Lukes <dan at obluda dot cz> Reviewed by: bcr Approved by: bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26096 Notes: svn path=/head/; revision=364449
* ps(1): Fix formatting of the "command" field for kernel threads.Mark Johnston2020-07-281-4/+7
| | | | | | | | | | | | | | | | | | When -H is specified, for kernel threads the command is formatted as "<proc name>/<td name>" and truncated to MAXCOMLEN. But each of the proc name and td name may be up to MAXCOMLEN bytes in length. Also handle the ki_moretdname field to ensure that the full thread name gets printed. This is already handled correctly when formatting for "-o tdname". Reported by: freqlabs Reviewed by: freqlabs MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25840 Notes: svn path=/head/; revision=363649
* sh(1): print a newline when ^D quits shPiotr Pawel Stefaniak2020-07-271-0/+4
| | | | | | | | | | | | | | I've always found this a little bit confusing: > sh $ ^D> sh $ ^D> Reviewed by: 0mp, jilles MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25813 Notes: svn path=/head/; revision=363621
* chio: avoid out of bounds readEd Maste2020-07-261-1/+1
| | | | | | | | | | | ch_ces is alloacated with space for total_elem entries. CID: 1418536 Reported by: Coverity Scan Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=363563
* Update to D25266, bin/ps: Make the rtprio option actually showKirk McKusick2020-07-141-1/+8
| | | | | | | | | | | | | | | | | realtime priorities The current `ps -axO rtprio' show threads running at interrupt priority such as the [intr] thread as '1:48' and threads running at kernel priority such as [pagedaemon] as normal:4294967260. This change shows [intr] as intr:48 and [pagedaemon] as kernel:4. Reviewed by: kib MFC after: 1 week (together with -r362369) Differential Revision: https://reviews.freebsd.org/D25660 Notes: svn path=/head/; revision=363192
* sh: Do not ignore INTOFF during a trapJilles Tjoelker2020-07-091-6/+1
| | | | | | | | | | | | | | | | | | | | INTOFF postpones SIGINT processing and INTON enables it again. This is important so an interactive shell can return to the top level prompt when Ctrl+C is pressed. Given that INTON is automatically done when a builtin completes, the part where onsig() ignores suppressint when in_dotrap is true is both unnecessary and unsafe. If the trap is for some other signal than SIGINT, arbitrary code could have been interrupted. Historically, INTOFF remained in effect for longer. Reviewed by: bdrewery MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D25270 Notes: svn path=/head/; revision=363057
* Fix description of the "\$" sequence for PS1Mateusz Piotrowski2020-07-061-3/+3
| | | | | | | | | | | | The manual page documents "\$" to expand to either "$" or "#" followed by a single space. In reality, the single space character is not appended. PR: 247791 Submitted by: kd-dev@pm.me MFC after: 7 days Notes: svn path=/head/; revision=362957
* sh/tests: Re-enable bin.sh.execution.functional_test.bg12.0Jilles Tjoelker2020-06-281-15/+1
| | | | | | | | | | This reverts r362646. PR: 247559 MFC after: 1 week Notes: svn path=/head/; revision=362738
* sh/tests: Fix flaky execution/bg12.0Jilles Tjoelker2020-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | When job control is not enabled, the shell ignores SIGINT while waiting for a foreground process unless that process exits on SIGINT. In this case, the foreground process is sleep and it does not exit on SIGINT because the signal is only sent to the shell. Depending on order of events, this could cause the SIGINT to be unexpectedly ignored. On lightly loaded bare metal, the chance of this happening tends to be less than 0.01% but with higher loads and/or virtualization it becomes more likely. Starting the sleep in background and using the wait builtin ensures SIGINT will not be ignored. PR: 247559 Reported by: lwhsu MFC after: 1 week Notes: svn path=/head/; revision=362737
* ps(1): don't try to handle non-SMP systemsPiotr Pawel Stefaniak2020-06-273-19/+1
| | | | | | | | | | As reported by kib, sysctl machdep.smp_active doesn't exist and on UP we return CPU 0 for all threads anyway. Reported by: kib Notes: svn path=/head/; revision=362707
* ps(1): reuse keyword "cpu" to show CPU numberPiotr Pawel Stefaniak2020-06-275-5/+37
| | | | | | | | | | | | | | | | | | | | | | | This flag will now show the processor number on which a process is running. This change was inspired by PR129965. Initially I didn't think that the patch attached to it was correct -- it sacrificed ki_estcpu use in "cpu" for ki_lastcpu and I thought that the old functionality should be kept and the new (cpu#) one added to it. But I've since discovered that ki_estcpu is sched_4bsd-specific. What's worse, it represents the same thing as ki_pctcpu, except ki_pctcpu is universal -- so "%cpu" has been using it successfully. Therefore, I've decided to replace information based on ki_estcpu with information based on ki_oncpu/ki_lastcpu. Key parts of the code and manual changes were borrowed from top(1). PR: 129965 Reported by: Nikola Knežević MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25377 Notes: svn path=/head/; revision=362705
* Temporarily skip flakey bin.sh.execution.functional_test.bg12 in CILi-Wen Hsu2020-06-261-1/+15
| | | | | | | | PR: 238870 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=362646
* bin/ps: Make the rtprio option actually show realtime prioritiesLorenzo Salvadore2020-06-192-10/+11
| | | | | | | | | | | | | | | | | | | | | Fix the rtprio option that for some reason was progessively becoming an option showing the priority class of threads. In particular: - use the constants defined in sys/sys/rtprio.h instead of those defined in sys/sys/priority.h: this helps making clearer that the code actually is about realtime priorities and not standard scheduler priorities; - remove the PRI_ITHD case that has nothing to do with realtime priorities; - convert the priority levels to realtime priority levels using the same formulas used for pri_to_rtp function in sys/kern/kern_resource.c. - remove outdated note "101 = not a realtime process" in the man page and replace it with a more useful reference to man 1 rtprio. Approved by: src (mckusick), manpages (bcr), gerald (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D25266 Notes: svn path=/head/; revision=362369
* sh/tests: Add tests for SIGINT in non-jobc background commandsJilles Tjoelker2020-06-143-0/+30
| | | | | | | | | | If job control is not enabled, background commands shall ignore SIGINT and SIGQUIT, and it shall be possible to override that ignore in the same shell. MFC after: 1 week Notes: svn path=/head/; revision=362182
* ps: remove xo_no_setlocale() callYuri Pankov2020-06-091-1/+0
| | | | | | | | | | Apparently libxo was fixed to do the right thing on FreeBSD, and calling xo_no_setlocale() is no longer needed. Reported by: phil Notes: svn path=/head/; revision=361962
* ps: use %hs instead of %s format specifiersYuri Pankov2020-06-073-5/+6
| | | | | | | | | | | | | Use %hs (locale-based encoding) instead of %s (UTF-8) format for strings that are expected to be in current locale encoding (date/time, process names/argument list). PR: 241491 Reviewed by: phil Differential Revision: https://reviews.freebsd.org/D22160 Notes: svn path=/head/; revision=361887