Commit graph

3933 commits

Author SHA1 Message Date
Ed Maste
ed8b456f82 csh: Remove gethost dependency on tc.const.h
gethost is a build tool built in stage 2.3, but it had a dependency on
tc.const.h, which requires target headers (that are not installed until
stage 4.1).  The build falls back to the host's headers if the target
headers don't yet exist, which may result in a build failure if the
host's headers don't match the target.

As gethost.c doesn't actually require the definitions in tc.const.h, add
a hack to skip the include of tc.const.h and remove the dependency.

PR:		283273
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Fixes: e754e5f361 ("Upgrade to 6.10")
Differential Revision: https://reviews.freebsd.org/D48880
2025-02-08 19:30:55 -05:00
Piotr Pawel Stefaniak
6ba2f08cea ls: --group-directories requires stat information
Fixes:	8b92977857
2025-01-22 08:29:29 +01:00
artembunichev
d6c2d4fe97 kill.1: mention special meaning of PGID as a PID
PR:	 284158
MFC after:	3 days
2025-01-19 15:31:36 +02:00
artembunichev
f5cf173de0 kill.1: mention special PID 0
PR:	 284158
MFC after:	3 days
2025-01-19 15:29:27 +02:00
Piotr Pawel Stefaniak
4ed2448a4f ls.1: bump date after 82fa7f83b5 and 8b92977857 2025-01-16 17:05:43 +01:00
Piotr Pawel Stefaniak
8b92977857 ls: implement --group-directories-first for compatibility with GNU ls
Also implement --group-directories which takes a parameter.
"first" is equivalent to --group-directories-first, "last" gives
reversed sorting.

Changes in sorting between elements of the same type (files,
directories) are not intended.

Differential Revision:	https://reviews.freebsd.org/D48347
2025-01-16 17:00:17 +01:00
Piotr Pawel Stefaniak
82fa7f83b5 ls -lh: humanize the total
Before this change, the total printed on the first line was always in
blocks.

Now the long format with -h will print the "humanized number" instead.

`ls -sh` never provided sizes in anything other than blocks, total or
individual, and this commit doesn't change that.

The total number of blocks is a sum of fts_statp->st_blocks, so it's
multiplied by 512 and not by blocksize.

$ ls -lh /usr/bin | head -n 2
total 442 MB
-r-xr-xr-x 1 root wheel 70B Dec 20 21:06 CC

Differential Revision:	https://reviews.freebsd.org/D48329
2025-01-16 17:00:17 +01:00
Mark Johnston
e6c9c46338 ls: Release resources before returning from traverse()
PR:		278476
MFC after:	2 weeks
Reported by:	valgrind
2025-01-14 14:20:26 +00:00
Gordon Bergling
d633a7d121 timeout(1): Add -v/--verbose option to show diagnosis info
The -v/--verbose option enables this utility to show diagnosis
info to stderr about any signal sent on timeout.

This implementation refers to GNU coreutils's timeout(1).

Reviewed by:	bapt, Alexander Ziaee (manpages)
Approved by:	bapt (src)
Obtained from:	DragonFlyBSD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48225
2025-01-04 09:52:56 +01:00
Gordon Bergling
06690044da timeout(1): Some minor tweaks and improvements
- Define exit status and macros and use them
- Improve the second kill logic by setting 'do_second_kill = false'
  after configuring the second kill
- Minor style tweaks
- Reorder options in the man page, as well as the usage help
- Reorder the exit status in the man page
- Enhance the HISTORY section in the man page (obtained from NetBSD)

Reviewed by:	bapt, Alexander Ziaee (manpages)
Approved by:	bapt (src)
Obtained from:	DragonFlyBSD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47866
2024-12-28 08:13:22 +01:00
Olivier Certner
09290c3a0c
cred: Hide internal flag CRED_FLAG_CAPMODE
This flag is used in field 'cr_flags', which is never directly visible
outside the kernel.  That field is however exported through 'struct
kinfo_proc' objects (field 'ki_cr_flags'), either from the kernel via
sysctls or from libkvm, and is supposed to contain exported flags
prefixed with KI_CRF_ (currently, KI_CRF_CAPABILITY_MODE and
KI_CRF_GRP_OVERFLOW, this second one being a purely userland one
signaling overflow of 'ki_groups').

Make sure that KI_CRF_CAPABILITY_MODE is the flag actually exported and
tested by userland programs, and hide the internal CRED_FLAG_CAPMODE.
As both flags are currently defined to the same value, this doesn't
change the KBI, but of course does change the KPI.  A code search via
GitHub and Google fortunately doesn't reveal any outside uses for
CRED_FLAG_CAPMODE.

While here, move assignment of 'ki_uid' to a more logical place in
kvm_proclist(), and definition of XU_NGROUPS as well in 'sys/ucred.h'
(no functional/interface changes intended).

Reviewed by:    mhorne
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46909
2024-12-16 15:42:29 +01:00
Kyle Evans
86b4df97d0 cat: report copy_file_range() errors with the read filename
The error may be due to an error while writing, but it's more helpful to
report what we were trying to from rather than "stdout" for these
errors.  Noticed because of what happens now when `cat` gets an EISDIR
for reading from a dirfd:

kevans@ifrit:~$ cat /etc
cat: stdout: Is a directory

which, after this change, becomes:

kevans@aarch64-dev:~$ cat /etc
cat: /etc: Is a directory

Reviewed by:	allanjude, des, mm
Differential Revision:	https://reviews.freebsd.org/D41784
2024-12-13 22:32:54 -06:00
Alexander Ziaee
e2a72442bd sh.1: update history + spdx + linter error
+ increase history consistency by adding "first appeared"
+ remove a skipped new paragraph macro to quiet linter
+ tag spdx

MFC after:	3 days
History source:	www.in-ulm.de/~mascheck/various/ash/#bsd

Reviewed by: mhorne,imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1440
2024-11-29 14:38:35 -07:00
Baptiste Daroussin
0df81552d7 sh(1): -l is only valid in cli option not as set -l 2024-11-20 14:15:41 +01:00
Baptiste Daroussin
65f5dd42f1 sh(1): add -l option
-l is required by LSB for login shell, all other shells: bash, zsh,
oksh, mksh, ... implements it.

with -l sh will act as a login shell and read the profile.

MFC After: 	1 week
Obtained From:	dash (3b7c8442bfe7c2fd0a6b0415df6ddf66a399fd55)
Reviewed by:	kib, lme
Differential Revision:	https://reviews.freebsd.org/D47681
2024-11-20 13:57:18 +01:00
Dag-Erling Smørgrav
d4fb5984ab mv: Add test cases for command-line options.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D47582
2024-11-19 10:29:15 +01:00
Dag-Erling Smørgrav
2822a79533 mv: Convert tests to ATF.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers, markj
Differential Revision:	https://reviews.freebsd.org/D47569
2024-11-19 10:29:11 +01:00
Dag-Erling Smørgrav
dc6105ebed mv: More style nits.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47568
2024-11-19 10:29:05 +01:00
Konstantin Belousov
645f8bcba9 ps.1: remove stray tab which breaks columns alignment
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-11-18 14:23:43 +02:00
Mark Johnston
aab7f19974 sh tests: Fix ktrace usage now that envvars are traced by default
Some sh tests use ktrace to see whether a particular file, specified in
the environment, was accessed by the shell.  After commit 65a4daeaf3,
this test matches the ktrace record generated by execve.

Use ktrace to only log name lookups, to avoid such false matches.

Fixes:	65a4daeaf3 ("ktrace: log execve(2) arguments and environment")
2024-11-17 17:37:34 +00:00
Konstantin Belousov
092e2ff33b ps.1: restore always true if predicate
Fixes:	62e6ca0f07
Reported and reviewed by:	jlduran
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D47561
2024-11-14 04:41:42 +02:00
Dag-Erling Smørgrav
b210c33a91 mv: Type and style nits.
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D47537
2024-11-13 14:47:29 +01:00
Konstantin Belousov
62e6ca0f07 ps(1): clean up after swapout removal
The process flag P_INMEM is always set.  Eliminate all checks for the
bit.  Also eliminate LAZY_PS define and code covered by it: we  do not
have an u-area for long time, and it cannot be swapped out.

Also eliminate setting controlled by the '-f' switch, but accept it for
backward compatibility.

The 'W' process secondary state (swapped out) is impossible, stop
calculating it.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D47492
2024-11-09 19:22:42 +02:00
Konstantin Belousov
4c367bc90b ps.1: document rest of flag2 bits
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47492
2024-11-09 19:22:29 +02:00
Konstantin Belousov
cd9e781e76 ps.1: visually align process flags hex values by filling leading zeroes
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D47492
2024-11-09 19:22:22 +02:00
Igor Ostapenko
68e0137837 tests: Switch bin/hostname/hostname_test to execenv=jail
Kyua skips tests based on the jail execution environment if a system is
built WITHOUT_JAIL. Thus, the test case does not need to handle it.

Reviewed by:	markj
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D47334
2024-10-31 17:44:49 +00:00
Graham Percival
6e1fc01180 manuals: Fix "unusual .Xr" warnings with a script
These were reported by `mandoc -T lint ...` as warnings:
- unusual Xr order
- unusual Xr punctuation

Fixes made by script in https://github.com/Tarsnap/freebsd-doc-scripts

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com>
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1464
2024-10-15 17:18:14 -03:00
Simon J. Gerraty
a64729f507 Update Makefile.depend files
After building packages we have a number of new
and updated Makefile.depend files

Reviewed by:	stevek
2024-10-14 10:26:17 -07:00
Yan-Hao Wang
e17a2944a6
ps(1): Complete libxo transition
Reviewed by:	des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41422
2024-10-13 02:21:46 +08:00
Graham Percival
c013ca2cf7 manuals: Fix typos in -offset for .Bd and .Bl
The intended value is:
    -offset indent
If there's any typo such that the value doesn't match the pre-defined
strings, then the offset is the same width as the value.  So by chance,
"-offset -ident" ended up being a standard-width indent (since the
default indent is 6 chars, and "-ident" also has 6 chars), whereas
"-offset -indent" had a longer indent, and "-offset ident" had a shorter
one.

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com>
MFC after:	3 days
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1436
2024-10-03 14:49:31 -03:00
Gordon Bergling
044f94adff timeout(1): Update STANDARDS section
Update the STANDARDS section for timeout(1) to
POSIX 1003.1-2024.

Update mandoc to be able to render the
new POSIX macro.

Reviewed by:	bapt, bcr
Approved by:	bapt
Obtained from:	OpenBSD
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45691
2024-09-24 18:42:18 +02:00
Konstantin Belousov
5d92f20c7d bin/sh: support RLIMIT_PIPEBUF
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D46619
2024-09-20 09:46:07 +03:00
Dag-Erling Smørgrav
355ebf80b1 date: Documentation nits.
* Fix spurious capitalization.
* Fix inconsistent quoting.
* Use `Dq` rather than ASCII double quotes.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	0mp
Differential Revision:	https://reviews.freebsd.org/D46622
2024-09-10 14:29:14 +02:00
Dag-Erling Smørgrav
a8ddd1926a date: Fix a few nits.
* Don't use `asprintf()` when `strdup()` can do the job just as well.
* Fix a couple of typos in a comment.

Fixes:		eeb04a736c
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D46533
2024-09-04 19:32:23 +02:00
Fernando Apesteguía
5ab6ed93cd faccessat(2): Honor AT_SYMLINK_NOFOLLOW
Make the system call honor `AT_SYMLINK_NOFOLLOW`.

Also enable this from `linux_faccessat2` where the issue arised the first time.
Update manual pages accordingly.

PR:			275295
Reported by:		kenrap@kennethraplee.com
Approved by:		kib@
Differential Revision:	https://reviews.freebsd.org/D46267
2024-08-11 17:49:06 +02:00
Daniel Tameling
5f659bb0b6 test(1): quote closing bracket in error message
If test is called as [ and one forgets to close the bracket, the error
message is currently
[: missing ]

To make it obvious that this is not something printed in brackets,
quote the closing bracket in the message, which is what everybody else
is doing:
[: missing ']'

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1346
2024-07-29 14:08:33 -06:00
Dag-Erling Smørgrav
f890020d43 pax: Clear arcn in each read function.
Instead of initializing individual fields to zero, clear the entire
struct prior to populating it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	0mp, markj
Differential Revision:	https://reviews.freebsd.org/D46097
2024-07-24 22:07:06 +02:00
Dag-Erling Smørgrav
647d4a8caf ls: Make -, apply to -s as well as -l.
While here, remove a bogus comment about a gcc bug.  The bug was in ls,
which used an incorrect format string, and in libc, which accepted it.

MFC after:	1 week
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D46067
2024-07-24 22:07:06 +02:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Ganael Laplanche
681fd2bed8 pax: Terminate loop for empty directory names
Pax can sometimes loop forever. For example:

$ mkdir -p /tmp/src/foo/bar
$ rm -rf /tmp/dst ; mkdir -p /tmp/dst
$ cd /tmp/src
$ echo 'foo/bar/' | /bin/pax -r -w -d -pe "/tmp/dst"
<looping infinitely>

Here, pax(1) infinitely deletes and re-creates /tmp/dst/foo/bar/.

The problem is that chk_path() (bin/pax/file_subs.c), called from
node_creat() also creates the leaf directory when a trailing '/' appears
in the directory name to create. When the execution goes back from
chk_path() to node_creat(), the function still cannot create the leaf
directory (it has been created by chk_path()), so it unlinks it and
calls node_creat() again. The function re-creates it, and so on...

In node_creat() detect trailing slashes and not create a leaf directory,
but only intermediate ones.

PR: 277060
Reviewed by: imp
2024-06-21 10:39:09 -06:00
Emmanuel Vadot
dcb65c5a94 csh: Remove hardlink /.cshrc
Remove this historical artifact.
csh will try to use /.csrch if the user has no home directory defined which
is rather unlikely (To be exact if the concatenation of $HOME and "/.cshrc"
fail which is the same thing).

Also, with this change pkg will happily handle 3way merge for /root/.cshrc

Differential Revision:	https://reviews.freebsd.org/D45382
Reviewed by:		emaste, imp
Sponsored by:		Beckhoff Automation GmbH & Co. KG
2024-05-29 09:56:58 +02:00
Pierre Pronchery
3d7c8f0887 cp: avoid a resource leak
In copy_file(), make sure the from_fd file descriptor is closed even
when the operation failed early.

Reported by:	Coverity Scan
CID:		1545036
Sponsored by:	The FreeBSD Foundation

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1238
2024-05-23 12:04:43 -06:00
Alexander Ziaee
1a720cbec5 man filesystems: fix xrefs after move to section 4
Reviewed by: des, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1077
2024-05-16 10:25:29 -06:00
Henrich Hartzer
9bcc1b18c1 /bin/rmdir: Exit with status 2 for invalid arguments
PR: 277677

Signed-off-by: Henrich Hartzer <henrichhartzer@tuta.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1161
2024-05-11 13:13:28 -06:00
Dag-Erling Smørgrav
ad4f3bdf73 cat: Missed a couple.
MFC after:	3 days
Sponsored by:	Klara, Inc.
2024-05-10 13:05:45 +02:00
Dag-Erling Smørgrav
c6f9df7064 cat: Check for lack of success rather than a specific failure.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D45149
2024-05-10 12:59:30 +02:00
Jamie Landeg-Jones
3f0b80bc15 ps: handle incorrect -D values
I just noticed a slight issue with the '-D' option. Basically,
I accidentally typed something along the lines of:

ps -Dboth-p303

I.E. missing out the "space". Instead of giving an error, it behaved as
if I'd just typed "ps".

Looking at bin/ps/ps.c, where the -D option is parsed, it doesn't
error-out if there is no valid match.

This commit fixes the bug.
2024-05-06 19:13:35 +02:00
Mateusz Piotrowski
c40e0bff72 date.1: Note that nanosecond support is to appear first in 14.1
Sponsored by:	Klara, Inc.
2024-05-02 22:48:08 +02:00
Dag-Erling Smørgrav
dafb424b8d date: Correctly check outcome of mktime().
X-MFC-With:	7b390cb636
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44982
2024-04-28 19:12:58 +02:00
Fernando Apesteguía
6e74b603fc uuidgen(1): Add EXAMPLES to manual page
Approved by:		manpages@ (gbe@)
Reviewed by:		gbe@, pauamma
Differential Revision:	https://reviews.freebsd.org/D43494
2024-04-27 20:53:59 +02:00