git: f0a6e0a8dcf5 - stable/14 - trim(8): minor output correction
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Feb 2026 07:10:11 UTC
The branch stable/14 has been updated by eugen:
URL: https://cgit.FreeBSD.org/src/commit/?id=f0a6e0a8dcf5a49b9df1f5c9314cb2755c97f5e5
commit f0a6e0a8dcf5a49b9df1f5c9314cb2755c97f5e5
Author: Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2025-07-20 10:36:33 +0000
Commit: Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2026-02-23 07:09:24 +0000
trim(8): minor output correction
"trim /dev/da*" would print the following line multiple times
when given multiple agruments:
dry run: add -f to actually perform the operation
Print it once before looping over arguments.
Also, note possible suffixes P and E after offset/length
as per expand_number(3).
(cherry picked from commit 5d5848648013a189fc766e4ee3a121362905b836)
(cherry picked from commit f1b934c8138cfd98a70e305d54b2b431c842ec21)
---
usr.sbin/trim/trim.8 | 18 ++++++++++--------
usr.sbin/trim/trim.c | 11 ++++++-----
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/usr.sbin/trim/trim.8 b/usr.sbin/trim/trim.8
index b4799399e110..e7fc9da1a740 100644
--- a/usr.sbin/trim/trim.8
+++ b/usr.sbin/trim/trim.8
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 9, 2025
+.Dd July 20, 2025
.Dt TRIM 8
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Bk -words
.Sm off
.Ar offset
-.Op Cm K | k | M | m | G | g | T | t ]
+.Op Cm K | k | M | m | G | g | T | t | P | p | E | e ]
.Sm on
.Xc
.Ek
@@ -85,13 +85,13 @@ Overrides
.It Fl l Xo
.Sm off
.Ar offset
-.Op Cm K | k | M | m | G | g | T | t
+.Op Cm K | k | M | m | G | g | T | t | P | p | E | e
.Sm on
.Xc
.It Fl o Xo
.Sm off
.Ar offset
-.Op Cm K | k | M | m | G | g | T | t
+.Op Cm K | k | M | m | G | g | T | t | P | p | E | e
.Sm on
.Xc
Specify the length
@@ -105,12 +105,14 @@ unless one or both of these options are presented.
The argument may be suffixed with one of
.Cm K ,
.Cm M ,
-.Cm G
+.Cm G ,
+.Cm T ,
+.Cm P
or
-.Cm T
+.Cm E
(either upper or lower case) to indicate a multiple of
-Kilobytes, Megabytes, Gigabytes or Terabytes
-respectively.
+Kilobytes, Megabytes, Gigabytes, Terabytes, Petabytes or
+Exabytes, respectively.
.It Fl q
Do not output anything except of possible error messages (quiet mode).
Overrides
diff --git a/usr.sbin/trim/trim.c b/usr.sbin/trim/trim.c
index 3e187faa0fb3..27f57ac2fb72 100644
--- a/usr.sbin/trim/trim.c
+++ b/usr.sbin/trim/trim.c
@@ -114,7 +114,7 @@ main(int argc, char **argv)
*
* trim -f -- /dev/da0 -r rfile
*/
-
+
if (strcmp(argv[optind-1], "--") != 0) {
for (ch = optind; ch < argc; ch++)
if (argv[ch][0] == '-')
@@ -127,6 +127,9 @@ main(int argc, char **argv)
if (argc < 1)
usage(name);
+ if (dryrun)
+ printf("dry run: add -f to actually perform the operation\n");
+
while ((fname = *argv++) != NULL)
if (trim(fname, offset, length, dryrun, verbose) < 0)
error++;
@@ -213,10 +216,8 @@ trim(const char *path, off_t offset, off_t length, bool dryrun, bool verbose)
printf("trim %s offset %ju length %ju\n",
path, (uintmax_t)offset, (uintmax_t)length);
- if (dryrun) {
- printf("dry run: add -f to actually perform the operation\n");
+ if (dryrun)
return (0);
- }
fd = opendev(path, O_RDWR | O_DIRECT);
arg[0] = offset;
@@ -237,7 +238,7 @@ static void
usage(const char *name)
{
(void)fprintf(stderr,
- "usage: %s [-[lo] offset[K|k|M|m|G|g|T|t]] [-r rfile] [-Nfqv] device ...\n",
+ "usage: %s [-[lo] offset[K|k|M|m|G|g|T|t|P|p|E|e]] [-r rfile] [-Nfqv] device ...\n",
name);
exit(EX_USAGE);
}