aboutsummaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* bin/pkill: Fix {pgrep,pkill}-j_test.shAlex Richardson2021-02-132-34/+37
| | | | | | | | | | | | | The POSIX sh case statement does not allow for pattern matching using the regex + qualifier so this case statement never matches. Instead just check for a string starting with a digit followed by any character. While touching these files also fix various shellcheck warnings. `kyua -v parallelism=4 test` failed before, succeeds now. Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D28480
* cp: fix indentationBaptiste Daroussin2021-01-271-1/+1
| | | | No functional changes
* Fix typo in pwait.c introduced in 5bdce6ff546eAlexander V. Chernikov2021-01-211-1/+1
| | | | Reported by: kevans
* Remove deadlock in rc caused by pwait waiting for itself.Alexander V. Chernikov2021-01-212-1/+9
| | | | | | | | | | | | | | | | | | | | The following situation can trigger the deadlock: 1) Long time ago a_service was started through rc.d 2) We want to restart a_service and issue service a_service restart 3) rc.subr reads current process PID (via file or process), sends TERM signal and runs pwait with PID harvested 4) a_service process dies very quickly so it's PID becomes available. It is possible that while original process was running, PID counter overflowed and pwait got assigned a_service's PID. This patch ignores pid(s) to wait that are equal to pwait PID. Reported by: Dan McGregor, Boris Lytochkin Submitted by: Boris Lytochkin <lytboris at gmail.com> Reviewed By: 0mp MFC after: 2 weeks PR: 218598 Differential Revision: https://reviews.freebsd.org/D28240
* cat: style nitsMariusz Zaborski2021-01-201-1/+1
| | | | Pointed out by: jhb
* Remove the unnecessary space before the colonMateusz Piotrowski2021-01-201-2/+1
| | | | MFC after: 3 days
* cat: depend on Makefile to rebuild when WITH_CASPER changesEd Maste2021-01-171-0/+2
| | | | | | | We try to ensure building WITHOUT_CLEAN (or -DNO_CLEAN) works on an ongoing basis. b7ab6832cd98 changed cat to build w/o -DWITH_CASPER by default; add a cat.o dependency on the Makefile so that it gets rebuilt.
* cat: disable building it with CasperMariusz Zaborski2021-01-171-6/+7
| | | | | | | We want to measure what are the actual cost of sandboxing cat(1). Requested by: mjg, cy, Mike Karels Discussed with: rwatson, markj
* cat: style nitsMariusz Zaborski2021-01-161-2/+2
|
* cat: persistent errnoMariusz Zaborski2021-01-161-1/+10
| | | | | | | | | There is no guarantee that after close(2)/free the errno will remain persistent. The caller of the udom_open function depends on the errno for reporting errors. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D28185
* cat: Fix potential memory leakMariusz Zaborski2021-01-151-0/+1
| | | | This was introduced in aefe30c5437159a5399bdbc1974d6fbf40f2ba0f.
* cat: capsicumize itMariusz Zaborski2021-01-152-4/+92
| | | | | Reviewed by: markj, arichardson Differential Revision: https://reviews.freebsd.org/D28083
* 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