Commit Graph

3894 Commits

Author SHA1 Message Date
Tom Hukins
ba719a0fec Fix "version introduced" in numerous manual pages
MFC after:	1 week
Pull request:	https://github.com/freebsd/freebsd-src/pull/853
2024-01-08 11:35:16 -05:00
rilysh
4d8d9111a4 bin/timeout: remove unreachable break after usage()
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872
2024-01-03 12:05:50 -07:00
rilysh
8312a902f9 bin/setfacl: remove unreachable break after usage()
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872
2024-01-03 12:05:50 -07:00
rilysh
e9910377a7 bin/cp: remove unreachable break
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872
2024-01-03 12:05:50 -07:00
Pierre Pronchery
19bb1886be bsdinstall: rename "Live CD" to "Live System"
This uses more generic wording in the FreeBSD installer, when offering
the user to use the system booted without running the installer.

The updated wording is also reflected in freebsd-version(1).

Reviewed by:		emaste
Sponsored by:		The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43233
2023-12-29 15:24:25 -05:00
Zhan-Wei
10b84b88f0 cat: Use present tense
Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp, lwhsu
Pull Request: https://github.com/freebsd/freebsd-src/pull/923
2023-12-26 16:53:40 -07:00
Elyes Haouas
fd4fafa873 timeout_test.sh: Fix typo
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/906
2023-12-26 16:41:15 -07:00
Kai-Yang Chen
c1b12377a6 cat(1): Fix typo
Fix type: rebiuld -> rebuild in Makefile

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/933
2023-12-26 10:44:38 -07:00
Pei-Ju Chien
c38fe1d282 sh(1): Fix typo
Remove extra 'ing' from 'bookinging.'

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/934
2023-12-26 10:44:35 -07:00
Kai-Yang Chen
b6ae2ec7b0 sh(1): Fix typo
Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, @rilysh on github
Pull Request: https://github.com/freebsd/freebsd-src/pull/935
2023-12-26 10:44:33 -07:00
WEININGCHIU
878bf23d37 sh(1): Fix typo
nozero -> non-zero

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/936
2023-12-26 10:33:14 -07:00
Zhan-Wei
f0d6447c0b pax: Add missing 'for' in comment.
Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/941
2023-12-26 10:24:24 -07:00
Zhan-Wei
ebb1fe4006 mv: Improve comment
Fix typo/grammar error: Use the singlar verb ending on exists.

Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/940
2023-12-26 10:24:22 -07:00
Pin-Yi Kuo
e3d3e1ff7e df(1): fix a typo
On the manpage of df(1), "according" is mistyped into "acccording"

Event: Advanced UNIX Programming Course (Fall'23) at NTHU.
Signed-off-by: Pin-Yi Kuo <kuokuoyiyi@gapp.nthu.edu.tw>
Reviewed by: imp, zlei, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/944
2023-12-26 10:05:29 -07:00
Dag-Erling Smørgrav
53fc8e1902 cp: Move the -N flag in the manual page.
This accidentally got left out of 0f4467ce44.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D43067
2023-12-14 21:02:06 +01:00
Dag-Erling Smørgrav
3850927066 cp: Further simplify the core logic.
If the destination file exists but we decide unlink it, set the dne
flag.  This means we don't need to re-check the conditions that would
have caused us to delete the file when we later need to decide whether
to create or replace it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43064
2023-12-14 17:07:04 +01:00
Dag-Erling Smørgrav
0f4467ce44 cp: Move the flags around a bit.
- The HLPR flags are grouped together at the beginning because they are
  the standard flags for programs using FTS.  Move the N flag out from
  among them to its correct place in the sequence.
- The Pflag variable isn't used outside main(), but moving it out lets
  us skip initialization and keeps it with its friends H, L and R.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43063
2023-12-14 17:07:00 +01:00
Dag-Erling Smørgrav
ac56b9d83c cp: Split the basic_symlink test case in two.
This test case tests two different things: first, that copying a symlink
results in a file with the same contents as the target of the symlink,
rather than a second symlink, and second, that cp will refuse to copy a
file to itself, or to a link to itself, or a link to its target.  Leave
the first part in basic_symlink, move the second part to a new test case
named samefile, and slightly expand both cases.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43062
2023-12-14 17:06:57 +01:00
Dag-Erling Smørgrav
d002316fd7 cp: Refactor the core logic.
Rewrite `copy_file()` so the lflag and sflag are handled as early as
possible instead of constantly checking that they're not set and then
handling them at the end.  This also opens the door to changing the
failure logic at some future point (for instance, we might decide to
fall back to copying if `errno` indicates that the file system does not
support links).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D43055
2023-12-14 00:40:55 +01:00
Dag-Erling Smørgrav
d3a8e9b43b cp: Add tests for symbolic link case.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D43054
2023-12-14 00:33:37 +01:00
Dag-Erling Smørgrav
1fead66b64 cp: Add tests for hard link case.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43052
2023-12-13 22:31:16 +01:00
Warner Losh
3e7e3b5bdf cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0
From NetBSD's utils.c 1.5 importing importing BSDI change, with light
formatting changes:
    Author: cgd <cgd@NetBSD.org>
    Date:   Wed Feb 26 14:40:51 1997 +0000

    Patch from BSDI (via Keith Bostic):
    >NFS doesn't support chflags; ignore errors unless there's reason
    >to believe we're losing bits.  (Note, this still won't be right
    >if the server supports flags and we were trying to *remove* flags
    >on a file that we copied, i.e., that we didn't create.)

    CVS Info: utils.c 1.6

Obtained from:		NetBSD
Sponsored by:		Netflix

Differential Revision:	https://reviews.freebsd.org/D42674
2023-12-07 13:36:44 -07:00
Warner Losh
5a52e3d00d cp: Add -N flag, inspired by NetBSD's similar flag
Add -N to supress copying of file flags when -p is specified (explicitly
or implicitly). Often times we don't care about the flags or wish to be
able to copy to NFS, and this comes in handy for that. FreeBSD's and
NetBSD's cp are somewhat different, so I had to reimplement all but one
of the patch hunks...

Obtained from:		NetBSD (cp.1 1.25, cp.c 1.37, utils.c 1.28 by elad)
Sponsored by:		Netflix

Differential Revision:	https://reviews.freebsd.org/D42673
2023-12-07 13:36:44 -07:00
Mike Karels
1a7c9e1585 pwait.1: add missing prompt and command in examples
Two examples showed '$?' alone on a line, which should be '$ echo $?'.
The third example got it right.  Fix the first two.
2023-11-27 10:59:52 -06:00
Warner Losh
e043f37205 bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh
0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh
90aea514c6 bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Brooks Davis
1818f3fda9 ps: s/kern.max_pid/kern.pid_max/ in a comment
Sponsored by:	DARPA
2023-11-21 22:46:01 +00:00
Martin Matuska
3c773cad57 cat: fallback on EISDIR with copy_file_range(2)
The filesystem may support reading directories directly
when security.bsd.allow_read_dir is set.

MFC after:	1 week
PR:		275099
2023-11-19 02:14:50 +01:00
Thomas Eberhardt
a6ed8c9593 Fix /root permissions after 'make installworld'
According to /etc/mtree/BSD.root.dist /root should have
0750 permissions, but the build target 'make installworld'
changes these to 0755.

This is caused by the installation of the configuration
files of sh(1) and csh(1).

Correct this by specifying the correct default /root permissions.

PR:	273342
Reviewed by:	jilles
Approved by:	jilles
MFC after:	2 weeks
Differential Revision:https://reviews.freebsd.org/D42395
2023-11-16 10:59:38 +01:00
Benedict Reuschling
ba44650a0b ps.1: update regarding -D option and -p x/d interaction
The -p option does not imply -x, it is merely a different mode that ps
uses. Remove that statement from the -p option, effectively rolling back
d6ae056e9d.

pstef@ introduced the -D option in 5c0a1c15ff
which also turns ps into a similar mode. List the -D option along with
the others in the first sentence of the second paragraph of the
DESCRIPTION section for completeness and correctness sake.

Pointed out by:		pstef@
Differential Revision:	https://reviews.freebsd.org/D42552
2023-11-11 19:49:24 +00:00
Emmanuel Vadot
6a804af4c0 pkgbase: Move uuidgen to runtime package
This is useful to have a valid /etc/hostid and /etc/machine-id for
small mfsroot based setup and not needing to install FreeBSD-utilities

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42149
2023-10-11 21:10:14 +02:00
Bojan Novković
128f63cedc (s)tty: add support for IUTF8 input flag
This patch adds the necessary kernel and stty code to support setting
the IUTF8 flag for ttys. It is the first of two patches that fix
backspace behaviour for UTF-8 encoded characters when in canonical mode.

Reported by:	christos
Reviewed by:	christos, imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42066
2023-10-07 20:59:57 +03:00
Benedict Reuschling
d6ae056e9d Extend description of -p to include interactions with -d and implying -x
PR:	268052
Event:	Oslo Hackathon
Differential Revision: https://reviews.freebsd.org/D40595
2023-10-06 14:29:21 +00:00
Mariusz Zaborski
64c6327738 cat: add CAP_SEEK capability
The copy_file_range might require that.

Reviewed by:	emaste, theraven, kib, markj
Differential Revision:	https://reviews.freebsd.org/D41967
2023-09-28 15:38:36 +02:00
Piotr Pawel Stefaniak
a675eaec5a sh: implement PS1 \D to print current time
\D{format} yields the result of calling strftime(3) with the provided
format and the current time.

When PS4 can use this, it will enable us to easily generate timestamps
when tracing script execution.

Differential Revision:	https://reviews.freebsd.org/D35840
2023-09-23 20:26:45 +02:00
Piotr Pawel Stefaniak
8e5c53af83 sh: also auto-complete functions
Differential Revision:	https://reviews.freebsd.org/D40619
2023-09-12 18:40:05 +02:00
Piotr Pawel Stefaniak
bec7b9a219 sh: introduce a function to iterate over all hashed commands
While aliases and built-ins are opportunistically stored in cmdtable, each
function will be added to it immediately on definition.

Factor out the hashing function, write the iterator function and make it use
the hashing function.

Add the cmdname pointer to struct cmdentry so that the command name can be
exposed that way.

Differential Revision:	https://reviews.freebsd.org/D40619
2023-09-12 18:39:54 +02:00
Piotr Pawel Stefaniak
0fd450e289 sh: tab-complete aliases
Differential Revision:	https://reviews.freebsd.org/D40619
2023-09-12 18:39:42 +02:00
Piotr Pawel Stefaniak
2fc4a84ed8 sh: introduce a function to iterate over all aliases
Currently the data structure holding alias information is opaque for
consumers outside alias.c and there is no way to iterate over all
aliases, which will become needed by a future commit.

The new function "iteralias" takes a null pointer to return the first
alias or an existing alias to return the next one, unless there is
no alias to return, in which case it returns a null pointer.

I slightly changed the static function hashalias so that it returns the
index into the array holding link heads, and not the link head directly.
In this form it's easier to use by iteralias and the slight adjustment
in the three existing callers doesn't look too bad.

Differential Revision:	https://reviews.freebsd.org/D40619
2023-09-12 18:39:20 +02:00
Piotr Pawel Stefaniak
63b6e661d2 sh: reindent a for loop in parser.c
Reduce indentation level before a commit that will add new code here.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D37926
2023-09-12 18:36:32 +02:00
Jens Schweikhardt
4fc08109fe Correct the grammo in "will underlined". 2023-09-10 11:00:21 +02:00
Piotr Pawel Stefaniak
5c0a1c15ff ps: add a new option -D to reimplement tree traversal
It takes a non-optional parameter string, one of "up", "down", or "both"
that can request tree traversal in the chosen directions. This adds PIDs
from the paths to the selection of PIDs and can be used together with -d
to draw a subset of the process tree.

Differential Revision:	https://reviews.freebsd.org/D41231
2023-08-24 18:35:56 +02:00
Piotr Pawel Stefaniak
f06e32e9b9 Revert "ps: extend the non-standard option -d (tree view) to work with -p"
This reverts commit ca8c0d5e81.

By commiting ca8c0d5e81 I was hoping that the existing option -d
could just be extended to work with -p to implement a feature that was
and I think is still needed, that is to show all descendant processes
of a given process id or a set of process ids.

After a complaint from -current which may represent a wider
dissatisfaction with this change in the program's behavior, I think it
will be better to revert ca8c0d5e81 and reintroduce this feature
using a separate option -D.
2023-08-24 18:35:50 +02:00
Mark Johnston
c903f66478 sh tests: Update $LINENO tests after $FreeBSD$ removal
Fixes:	d0b2dbfa0e ("Remove $FreeBSD$: one-line sh pattern")
2023-08-23 13:25:35 -04:00
Enji Cooper
22dc8901a7 Use proper convention for relative path linking
The change made in e835ee68e1 did not
follow the convention for relative path symlinks. Per the convention,
paths be prefixed with `${BINDIR}`, not `/bin/`. `${BINDIR}` can be
modified from the Makefile, on the command line, or in the
environment. This convention is the canonically correct way to do
things.

This follows the convention used in `bin/pkill/Makefile`,
`bin/timeout/Makefile`, etc.

MFC after:	1 week
MFC with:	f05948d4e9
MFC with:	e835ee68e1
Requested by:	jrtc27, kevans
2023-08-18 04:20:32 -07:00
Warner Losh
05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh
b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Enji Cooper
e835ee68e1 Link /usr/bin/cpuset to a relative path
This creates an appropriate symlink instead of a potentially incorrect
path pointing to the absolute path for cpuset(8) on the host.

MFC after:	2 weeks
MFC with:	f05948d4e9
Requested by:	imp
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41419
2023-08-11 04:20:16 -07:00
Enji Cooper
f05948d4e9 cpuset(8): move to /bin/
Summary:
This change moves /usr/bin/cpuset to /bin/cpuset so it is more readily
available on hosts where the /usr partition might not be mounted at the
time / has been mounted.

Remove some complexity from rc.subr(8) since /bin is assumed to always
be present if/when / is mounted.

MFC after:	2 weeks
MFC with:	0661f93892, 271d552379af

Test Plan:
- Test out rc.subr change.
- Confirm that the installation logic does what's needed.

Relnotes:	yes (moving cpuset may impact strict file permissions/mode checking)
Reviewers:	kevans
Subscribers:	imp
Differential Revision: https://reviews.freebsd.org/D40057
2023-08-11 00:49:02 -07:00
Minsoo Choo
3bfbb521fe ls: Improve POSIX compatibility for -g and -n.
- Change -g (ignored for BSD 4.3 compatibility since BSD 4.4)
  to use POSIX semantics of implying -l but omitting the owner's
  name.

- Change -n to imply -l.

The -o option remains unchanged (POSIX defines -o as a complement to
-g that implies -l but omits group names whereas BSD defines -o to add
file flags to -l).  This compromise is the same used by both NetBSD
and OpenBSD.

PR:		70813
Reviewed by:	jhb, Pau Amma <pauamma@gundo.com>
Co-authored-by:	John Baldwin <jhb@FreeBSD.org>
Differential Revision:	https://reviews.freebsd.org/D34747
2023-07-18 10:03:09 -07:00
Martin Matuska
055f920ebe cat: fallback on EBADF with copy_file_range(2)
When stdout is opened with O_APPEND, copy_file_range(2) fails with EBADF.
2023-07-09 01:08:46 +02:00
Martin Matuska
8113cc8276 cat: use copy_file_range(2) with fallback to previous behavior
This allows to use special filesystem features like server-side
copying on NFS 4.2 or block cloning on OpenZFS 2.2.

Reviewed by:	imp, rmacklem
Differential revision:	https://reviews.freebsd.org/D40882
2023-07-08 21:51:15 +02:00
Alfonso Gregory
38f57faa06 cat: ensure serrno is always set
Set serrno to errno before the loop begins for the edge case that res0
is immediately NULL.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/724
2023-07-07 15:56:35 -06:00
Alfonso Gregory
e97468063d Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
Pedro F. Giffuni
4ef3964b5f bin/date: Upgrade calculations (take 2)
Use uint64_t instead of long, as this type is not correct for platforms like i386 or armv7.

Pointed out by:	imp
2023-07-03 23:39:00 -05:00
Pedro F. Giffuni
4456846a1a bin/date: Upgrade calculations
Use long instead of int for numerous calculations, fixing a number of
date calculation overflow issues.

Obtained from:	DragonflyBSD
Git log:	4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only partial)
2023-07-03 22:08:01 -05:00
Simon J. Gerraty
fcc8d72702 Separate dependencies on tools built for host.
When generated files depend on tools that need to be built for host,
we need to carefully separate them for the DIRDEPS_BUILD so we
only build them once.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
2023-06-29 23:52:03 -07:00
Tom Hukins
70bc3f4331 timeout(1): link to related manual pages
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/783
2023-06-26 16:36:25 -06:00
Kyle Evans
781624ca2d getfacl: free acl in print_acl error path
Sponsored by:	Klara, Inc.
2023-06-21 23:58:33 -05:00
Piotr Pawel Stefaniak
14dd001235 sh: also auto-complete built-ins
Reported in a comment in PR 261728.

Reported by:	Oleg
Reviewed by:	jilles (previous version), bapt
Differential Revision:	https://reviews.freebsd.org/D39839
2023-06-19 19:27:20 +02:00
Daniel Kolesa
2178e8c27a sh: make smark a static variable instead of a local in main()
We are modifying it after setjmp and then accessing it after the jump,
so it cannot be a local.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D40415
2023-06-08 23:01:43 +02:00
Daniel Kolesa
fa6fa98ac7 sh(1): initialize smark to zero in main()
As popstackmark may be called on this without pushstackmark having
been called, we need to initialize it so that we don't get a bogus
comparison inside popstackmark, which would have resulted in a
NULL pointer dereference.

MFC After:	3 days
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D40413
2023-06-03 23:09:31 +02:00
Konstantin Belousov
8dad5ece49 dd(1): neutralize SIGINT while non-async-signal safe code is executing
making the SIGINT handler (the terminate() function) safe to execute at
any interruption moment.  This fixes a race in
5807f35c54 where SIGINT delivered right
after the check_terminate() but before a blocking syscall would not
cause abort.

Do it by setting the in_io flag around potentially blocking io syscalls.
If handler sees the flag, it terminates the program.  Otherwise,
termination is delegated to the before_io/after_io fences.

Reviewed by:	Andrew Gierth <andrew@tao146.riddles.org.uk>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40281
2023-06-03 01:06:27 +03:00
Mateusz Piotrowski
1e078fb602 nproc.1: Fix "first appeared in" details
nproc(1) has been MFC'ed into 13-STABLE and made it into 13.2-RELEASE.

MFC after:	3 days
2023-06-02 18:53:55 +02:00
Mike Karels
1082307434 pwd.1: replace /home with /sys in example
The default location for home directories is moving from /usr/home
to /home, and the /home symlink will no longer exist.  Switch to
another example that is in base, /sys.

Reviewed by:	fernape
Differential Revision:	<https://reviews.freebsd.org/D40204
2023-05-23 07:21:50 -05:00
Baptiste Daroussin
31edf56b15 date: add -z output_zone option
Inpired by OpenBSD date(1), this option allows to do timezone conversion
via the date(1) command.

For example, to determine when the BSDCan livestream begins for me:

$ env -i TZ=EST5EDT date -z Europe/Paris -j 0900

MFC After:		1 week
Reviewed by:		kib, bcr (manpage)
Differential Revision:	https://reviews.freebsd.org/D40159
2023-05-19 21:09:40 +02:00
Piotr Pawel Stefaniak
43489c142e sh: improve style 2023-05-13 21:57:27 +02:00
Warner Losh
b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD 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
2023-05-12 10:44:04 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
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
2023-05-12 10:44:03 -06:00
Dag-Erling Smørgrav
5807f35c54 dd: Fix SIGINT handling.
Currently, we handle SIGINT by calling summary() and _exit() directly from the signal handler, which we install after setup().  There are several issues with this:

* summary() is not signal safe;
* the parent is not informed about the signal;
* setup() can block on open(), and catching SIGINT at that stage will produce the correct exit status but will not print anything to stderr as POSIX demands.

Fix this by making SIGINT non-restartable, changing our signal handler to only set a flag, installing it before setup(), and checking the termination flag before and after every blocking operation, i.e. open(), read(), write().

Also add two test cases, one for catching SIGINT while opening the input and one for catching it while reading.  I couldn't think of an easy way to test catching SIGINT while writing (it's certainly feasible, but perhaps not from a shell script).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	cracauer, ngie, imp
Differential Revision:	https://reviews.freebsd.org/D39641
2023-05-05 12:42:32 +00:00
Dag-Erling Smørgrav
dabef9818f dd: Tidy up the tests.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D39711
2023-05-05 12:42:32 +00:00
Ceri Davies
fef74e99fc setfacl.1: correct reference to a trailing comma, should read "colon"
PR:		271063
Reported by:	rdd@rdd.nu
2023-04-29 12:22:52 +01:00
Mateusz Piotrowski
820ac12679 ps: Add libxo to usage message
MFC after:	1 week
Sponsored by:	Klara Inc.
2023-04-25 17:23:07 +02:00
Mateusz Piotrowski
3f46bf40a1 ps: Fix synopsis
In the -L mode, the -L flag is not optional.

MFC after:	3 days
Sponsored by:	Klara Inc.
2023-04-25 17:23:07 +02:00
Mateusz Guzik
c5b5f2d808 cp: Revert "If copy_file_range(2) fails with EXDEV, use fall-back."
This reverts commit 6433365490.

The error is not valid per api contract, it showed up as a regression
after 15f0b8c309

15f0b8c309 ("zfs: merge openzfs/zfs@9cd71c860 (master)") and was
subsequently in d012836fb6 ("zfs: fix up EXDEV handling for
clone_range").

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-24 16:04:53 +00:00
Simon J. Gerraty
8fe4f8f7a7 Fix building host tools for host
Several makefile depend on tools built for host.
At least when using DIRDEPS_BUILD we can build these for the
pseudo machine "host" to facilitate building on older host versions.

Ideally we would build these tools in their own directories to avoid
building more than needed.

For now, setting an appropriate default for BTOOLSPATH will suffice

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D39708
2023-04-20 10:05:43 -07:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
John Baldwin
525438ea71 sendmail: Silence -Wdeprecated-non-prototype warnings.
These will hopefully be fixed upstream eventually, but silence the
warnings until then.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39518
2023-04-18 11:19:48 -07:00
Mateusz Piotrowski
8688532f07 date.1: Make sure that the example works in any locale 2023-04-13 13:02:20 +02:00
Poul-Henning Kamp
6433365490 If copy_file_range(2) fails with EXDEV, use fall-back. 2023-04-04 07:39:59 +00:00
Stefan Eßer
c33db74b53 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
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D38987
2023-03-29 08:46:01 +02:00
Kyle Evans
822057bfbb pkill: tests: do a pass for case-sensitive conflicts
As in 76b6a59f9d, 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.
2023-03-20 14:54:54 -05:00
Kyle Evans
3610bffd28 pkill: use an ARG_MAX size buffer for argument matching
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
2023-03-20 14:19:36 -05:00
Daniel Kolesa
3ce64010f8 sh(1): fix history file write checking
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
2023-03-20 17:56:56 +01:00
Baptiste Daroussin
4cd30c640d uuidgen(1): fix another typo 2023-03-06 09:03:52 +01:00
Baptiste Daroussin
0ba66872be uuidgen(1): back to the past and fix typo
Reported by:	ceri
2023-03-02 09:37:03 +01:00
Baptiste Daroussin
b2b294f27c uuidgen: add -c for compact uuid
It generates the uuid string but without the hyphen

MFC After:		3 days
Reviews by:		tcberner
Differential Revision:	https://reviews.freebsd.org/D38820
2023-03-01 19:16:25 +01:00
Mateusz Piotrowski
de7a6b6fd0 date.1: Examples: Use syntax that is also compatible with csh
MFC after:	1 month
Sponsored by:	Klara Inc.
2023-02-27 17:37:28 +01:00
Mateusz Guzik
059320b8c8 nproc: denote an incompatiblity with Linux
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.
2023-02-15 20:43:46 +00:00
Konstantin Belousov
6957cd86d9 man: some typesetting and style fixes for recent additions
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
2023-02-11 19:23:54 +02:00
Mateusz Guzik
48bfd35976 Add nproc(1)
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
2023-02-08 19:47:33 +00:00
Dag-Erling Smørgrav
8b418c83d1 cp: Adjust the sparse file tests.
* 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
2023-02-08 16:49:50 +00:00
Dag-Erling Smørgrav
cb96a0ef00 cp: Minor code cleanup.
* 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
2023-02-03 16:37:37 +01:00