realpath: Belatedly document POSIX conformance
We've been mostly POSIX-conforming since r236400 and fully since r240410,
which fixed a corner case where a missing non-leaf directory would be
reported as ENOTDIR instead of ENOENT.
Approved by: re (cperciva)
Sponsored by: Klara, Inc.
Fixes: 7877ed7ce33e ("Avoid mapping ENOENT to ENOTDIR for non-existent path components.")
Reviewed by: ziaee, markj
Differential Revision: https://reviews.freebsd.org/D53027
(cherry picked from commit 7c66667d45e95af59f59e41ef169119a974a6be1)
(cherry picked from commit 50d6a56a198c7c3961313a933f54eea94ffa4b5f)
realpath: Report correct path on failure
If lstat() fails with EACCES or ENOTDIR, the path we need to return in
the caller-provided buffer is that of the parent directory (which is
either unreadable or not a directory; the latter can only happen in the
case of a race) rather than that of the child we attempted to stat.
Approved by: re (cperciva)
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53025
(cherry picked from commit 1406de21e176d8700240ac9e473df007cd41eec1)
(cherry picked from commit 6c9b25246d4408eced73886d0b58feef7bff25c6)
realpath: Additional test cases
* Passing NULL should result in EINVAL
* Passing an empty path should result in ENOENT
* Failure with a non-null buffer should leave a partial result. As
pointed out in a comment in the test case, this reveals a discrepancy
between the documentation and reality.
Approved by: re (cperciva)
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53024
(cherry picked from commit f3386dfeb429faaa30a915a4a422a25e07c8bf39)
(cherry picked from commit 5debbcb6b7a5a25511e8d63142fbc5e8498a8f46)
quot: Add tests
To facilitate the task, we change the comparison function so that users
with equal filesystem usage are sorted by UID, and add an undocumented
option that prevents quot from replacing numerical UIDs with names. We
also switch from getfsfile(3) to getmntpoint(3) so the first line is
identical regardless of whether we pass quot a mountpoint or a device.
Approved by: re (cperciva)
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53133
(cherry picked from commit aa870a1935bccb66e02c4c31630706768a3e7d74)
(cherry picked from commit b5f3f1a661ab69986c3379fa4c9c2b38785933db)
quot: Drop the -h option
There was probably a time, more than 30 years ago, when the actual
size of a file had to be calculated and this option saved time, but
all it does today is give incorrect results for no benefit.
Approved by: re (cperciva)
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D53132
(cherry picked from commit 8209311c51d34c81edec8d09778201cb6e67c6a5)
(cherry picked from commit c0d4bbcb8069bd64f6ad070c099ebcf7cfde3e72)
quot: Clean up
* Fix numerous style violations.
* Modernize somewhat.
* Don't bother examining errno after calling get_inode(), as it always
exits on error.
* Fix confusing wording in the manual page.
The code remains somewhat idiosyncratic, e.g. in its insistance on
counting down rather than up in simple for loops, but in the absence
of comprehensive automated tests, the risk of introducing bugs exceeds
the benefit of rewriting these into more idiomatic forms.
Approved by: re (cperciva)
Reviewed by: obiwac
Differential Revision: https://reviews.freebsd.org/D53130
(cherry picked from commit 195b00ec45e55c38da13d1bcd2d7eb6614abec59)
(cherry picked from commit 68911bf64eb5f6a99dd1fa7e2b6eaee1d27d8f1a)
quot: Fix benign buffer overflow
If it encounters an inode whose owner does not have a pw entry, quot
allocates a 7-byte buffer (8 in practice, since that is the minimum
allocation size) and uses it to store the numeric uid preceded by a
hash character. This will overflow the allocated buffer if the UID
exceeds 6 decimal digits. Avoid this by using asprintf() instead.
While here, simplify the common case as well using strdup().
Approved by: re (cperciva)
Reported by: Igor Gabriel Sousa e Souza <igor at bsdtrust.com>
MFC after: 3 days
Reviewed by: obiwac, emaste
Differential Revision: https://reviews.freebsd.org/D53129
(cherry picked from commit 5854d1cbab1073d78519e7ad9a6eb5726341d587)
(cherry picked from commit 3d680881f6ed2f55079aac26cf0ded307c282563)
w: Trim whitespace and commas from time and uptime
When producing formatted output, trim leading whitespace and trailing
commas from the human-readable time and uptime before emitting them.
The text output remains unchanged.
Approved by: re (cperciva)
PR: 290089
Fixes: 6e6febb54da9 ("w: Fix idle time in json output, add login/idle times to json output")
Reviewed by: marius.h_lden.org
Differential Revision: https://reviews.freebsd.org/D53167
(cherry picked from commit 4d5789532a940144c869d66505e756ce816f8a50)
(cherry picked from commit ca16a115a0fa4da67b153d0b90c9ec08adc9b2fb)
pwait: Add an option to print remaining processes
* On startup, insert all valid PIDs into a tree.
* In our main loop, whenever a process terminates, remove its PID
from the tree.
* On exit, if the -p flag was specified, print the remaining PIDs.
Approved by: re (cperciva)
MFC after: 3 days
Reviewed by: bcr, markj
Differential Revision: https://reviews.freebsd.org/D53293
(cherry picked from commit 3d73146baeb933fe955c7496572b483a9f92914c)
(cherry picked from commit 955650f1814257070f8414b6b6e8f42496f26409)
pkg: Die if make -V BRANCH fails
If build logic breaks such that we can't figure out which branch we're
on, we should error out rather than shipping a default (and probably
wrong) /etc/pkg/FreeBSD.conf
Approved by: re (cperciva)
Reviewed by: ivy
MFC after: 5 minutes
Suggested by: ivy
Differential Revision: https://reviews.freebsd.org/D53487
(cherry picked from commit 0837b2ebd570ea092353aa3c46e374f7a1533a1d)
(cherry picked from commit 1f528e32f5098c5aaca9bd2fb6473631c3831fbf)
release: Only check no-root/no-qemu when building
Building VMs as non-root requires no-QEMU code paths (installing
packages from outside the VM image rather than inside it) and vice
versa; we have a check for broken combinations.
Unfortunately that check was breaking
make -C src/usr.sbin/pkg NO_ROOT=YES -V PKGCONFBRANCH
because that code reaches into src/release to determine the branch
name (which is then used to determine which /etc/pkg/FreeBSD.conf to
install).
Wrap the no-root/no-qemu check in an .if to only run when we've
asked for VM and/or CLOUD building to be enabled.
Approved by: re (cperciva)
Reviewed by: ivy
MFC after: 5 minutes
Sponsored by: https://www.patreon.com/cperciva
[4 lines not shown]
ipfw: Retire obsolete compat code
The current IPFW version 3 dates to 2010 (commit cc4d3c30ea28, "Bring in
the most recent version of ipfw and dummynet, developed").
The compat code for FreeBSD 8 and earlier has a number of issues and is
no longer needed, so remove it.
Approved by: re (cperciva)
Reported by: Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by: ae, glebius
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53343
(cherry picked from commit c59aab9a5b3970b3ccec744f759e6cb87e938dbe)
(cherry picked from commit 9657c50cdd7741404d99881fdd9243175086ede1)
pmcstat: Remove no-op -k option
Commit 53d0b9e438bc ("pmc: Provide full path to modules from kernel
linker") made pmcstat's -k option have no effect, but the option was
retained for backwards compatibility (while emitting a warning that
-k is not in FreeBSD 15).
Approved by: re (cperciva)
Reviewed by: jrtc27
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53397
(cherry picked from commit c6b156e360fc5b18ee20bae0fc0c4188c3aadea6)
(cherry picked from commit 958659dc9410f332ce0a028d2d5fdc82da8a03dd)
release: Only check no-root/no-qemu when building
Building VMs as non-root requires no-QEMU code paths (installing
packages from outside the VM image rather than inside it) and vice
versa; we have a check for broken combinations.
Unfortunately that check was breaking
make -C src/usr.sbin/pkg NO_ROOT=YES -V PKGCONFBRANCH
because that code reaches into src/release to determine the branch
name (which is then used to determine which /etc/pkg/FreeBSD.conf to
install).
Wrap the no-root/no-qemu check in an .if to only run when we've
asked for VM and/or CLOUD building to be enabled.
Reviewed by: ivy
MFC after: 5 minutes
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D53486
[2 lines not shown]
pkg: Die if make -V BRANCH fails
If build logic breaks such that we can't figure out which branch we're
on, we should error out rather than shipping a default (and probably
wrong) /etc/pkg/FreeBSD.conf
Reviewed by: ivy
MFC after: 5 minutes
Suggested by: ivy
Differential Revision: https://reviews.freebsd.org/D53487
(cherry picked from commit 0837b2ebd570ea092353aa3c46e374f7a1533a1d)
pkg: Die if make -V BRANCH fails
If build logic breaks such that we can't figure out which branch we're
on, we should error out rather than shipping a default (and probably
wrong) /etc/pkg/FreeBSD.conf
Reviewed by: ivy
MFC after: 5 minutes
Suggested by: ivy
Differential Revision: https://reviews.freebsd.org/D53487
release: Only check no-root/no-qemu when building
Building VMs as non-root requires no-QEMU code paths (installing
packages from outside the VM image rather than inside it) and vice
versa; we have a check for broken combinations.
Unfortunately that check was breaking
make -C src/usr.sbin/pkg NO_ROOT=YES -V PKGCONFBRANCH
because that code reaches into src/release to determine the branch
name (which is then used to determine which /etc/pkg/FreeBSD.conf to
install).
Wrap the no-root/no-qemu check in an .if to only run when we've
asked for VM and/or CLOUD building to be enabled.
Reviewed by: ivy
MFC after: 5 minutes
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D53486
pjdfstest: Avoid needless use of expr
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53443
pjdfstest: Fix link count test
This UFS-only test verifies that attempting to create more links than
permitted by the file system returns EMLINK, but has been broken ever
since UFS_LINK_MAX was increased because a) it hardcodes the previous
value of UFS_LINK_MAX, and b) the new value requires more space than
the test allocates, so it ends up getting ENOSPC instead of EMLINK.
* Switch to retrieving {PC_LINK_MAX} at runtime.
* Stop the test when we reach {PC_LINK_MAX} links. This ensures that
we don't go on for hours if the actual limit turns out to be much
higher than we anticipated (e.g. INT64_MAX on ZFS).
* Double the size of the test filesystem.
MFC after: 3 days
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
[3 lines not shown]
pmcstat: Remove no-op -k option
Commit 53d0b9e438bc ("pmc: Provide full path to modules from kernel
linker") made pmcstat's -k option have no effect, but the option was
retained for backwards compatibility (while emitting a warning that
-k is not in FreeBSD 15).
Reviewed by: jrtc27
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53397
(cherry picked from commit c6b156e360fc5b18ee20bae0fc0c4188c3aadea6)
bsdlabel: Bump removal to FreeBSD 16.0.
It is deprecated but was not removed prior to 15.0.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 9447a4078121fd1ce961fed33dd0099040d0dac9)
ipfw: Retire obsolete compat code
The current IPFW version 3 dates to 2010 (commit cc4d3c30ea28, "Bring in
the most recent version of ipfw and dummynet, developed").
The compat code for FreeBSD 8 and earlier has a number of issues and is
no longer needed, so remove it.
Reported by: Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by: ae, glebius
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53343
(cherry picked from commit c59aab9a5b3970b3ccec744f759e6cb87e938dbe)