From nobody Sun Jul 20 10:38:11 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4blKkC6MkFz61w3Q; Sun, 20 Jul 2025 10:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4blKkC5TLNz3gtF; Sun, 20 Jul 2025 10:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753007891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=s4eQ6BnUXo9pfYPdVxf5vXlPbKVgLUmtIhUZRO6Pn4I=; b=qk5I5nPdzr70qiNGiCejG0fPcvP0zp9nqN+46L+lgHSgTgi+q+iWnI86FC0RotlP0VKuY9 Xh8E8JN1aOcoUGLahmbyxGlDdtJz5jf1YEmS3NjZadx964tFAS9p3gTvveytmbIIibEkJV DAMMZ2HlBnhn9ugIGn6V/J2+qtcUfDNp2dNcCBMU/k0ffjFSzBNT29AFBwOpJW786BVKd6 eCbteZC9jPBJbspJyhWGHvLjpmd9F/TPIzERBMvC5fb7+AePCeZjL9Vu3pB4X0ouKz9q2a ohCiO1xbGznPBD5CecWPge2knCP2rsag/xUI8El/4WPFTumWEvPAimOmLvDtIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753007891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=s4eQ6BnUXo9pfYPdVxf5vXlPbKVgLUmtIhUZRO6Pn4I=; b=xf1WnnbQYNjz5VnUaJJ3WYfe1ax8mO9ywK9Dpl1n5sCRl26ja0ymOewa8lnNN6S2aMiV6m 4/JkHpMkKgpX6DzN1KUh2AGQAlR5SfP9b3icvhTrSwVK25lPuxfIxTtFbV3V+6Qk73wwjj pHEDcraNmXtB97KKASoYyB4BYAs8wHuZFof5bLnfpQkDRMrreRte+345QEwFWQA2v9wWwW hNOakOAmtR9Dd8/JO8Qeup9OlFPZFCeuN9/0gjogsgVY91LiiZ/KT8YQs9xd6Oe6Q/AL5a tdAjI0IodpAcn2OlTOzxwXbZUAvZwFNrd9QfvivMTszSyTCuRvOmb+nHQIY1jQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753007891; a=rsa-sha256; cv=none; b=lx1cEwrkWEG1KXZ2uNPtu5Qyileke8KVsHj57bWcPz3x5spL6EqairDCsbM5VEtFPo7DV0 ukczsJbvth8obUPu05Wj1bIcZq698sECC7Tt9sug/P0NG2n/Nj1iEoBNr4EpStlbZ+eHph VGNJ0X1H1dtuH2jMzeaFdVBUOa3v87mh0zDhX0rhk7o5C8Ahkm09hceJq80AtCeF3eh83b WUZ8vIsVH7ALO/4JRFUnRJoFcfQwErBmY8SyIAcdJKaFtOrIVHdOvfg9jTSpaFdU7SfnOM UMrTPUUwH+pSpb9o0Nz0XBgEJp8Sw24hiPMpgmIJTJsrtPrfLHnpnZAknvcc1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4blKkC4r4xz17V4; Sun, 20 Jul 2025 10:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56KAcBP3042812; Sun, 20 Jul 2025 10:38:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56KAcBDh042809; Sun, 20 Jul 2025 10:38:11 GMT (envelope-from git) Date: Sun, 20 Jul 2025 10:38:11 GMT Message-Id: <202507201038.56KAcBDh042809@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eugene Grosbein Subject: git: 5d5848648013 - main - trim(8): minor output correction List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5d5848648013a189fc766e4ee3a121362905b836 Auto-Submitted: auto-generated The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=5d5848648013a189fc766e4ee3a121362905b836 commit 5d5848648013a189fc766e4ee3a121362905b836 Author: Eugene Grosbein AuthorDate: 2025-07-20 10:36:33 +0000 Commit: Eugene Grosbein CommitDate: 2025-07-20 10:36:33 +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). --- 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 1ac10d7e3d46..a4874c54c183 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 January 18, 2019 +.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 @@ -68,13 +68,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 @@ -88,12 +88,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..582dc095d642 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|Pt|Ee]] [-r rfile] [-Nfqv] device ...\n", name); exit(EX_USAGE); }