NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/59956: gpt(8): show human-readable units
The following reply was made to PR bin/59956; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: Martin Husemann <martin%duskware.de@localhost>
Cc: gnats-bugs%netbsd.org@localhost, campbell+netbsd%mumble.net@localhost
Subject: Re: bin/59956: gpt(8): show human-readable units
Date: Wed, 04 Feb 2026 23:46:13 +0700
Date: Wed, 4 Feb 2026 16:26:23 +0100
From: Martin Husemann <martin%duskware.de@localhost>
Message-ID: <aYNlH8DW0HQp-wH-%big-apple.aprisoft.de@localhost>
| Please do not change output format w/o another switch (or add a switch
| to keep the old output format).
At the minute that's more or less what happens, there were just a few
minor (unswitched) differences (if you're relying upon the exact number
of spaces in the show -a output that would be an issue, but I hope things
haven't gotten that horrid - it already varied anyway, the code already
calculates the widths of the start and size columns). Apart from that
one the other minor addition I made (without a switch) can easily be undone.
But:
| Or probably even better: add a switch to get easily readable output
| with a new switch and I'll adapt sysinst to use the new switch and
| format.
I agree, that would be better. Tell me what, in an ideal world, you'd
like the format to be (no need for every detail, just what general form
would be easiest to parse) and I will add a switch to generate that format.
Anything (not requiring data to be invented) is possible there, including
supplying a list of fields that you want the values of, so there's less
junk that you don't need - including headers of course) and/or having the
output in a key=value format or something, with whatever separators make
sense, anything can be done (this kind of output is simple to generate,
it is making it "look nice" for people that causes difficulty).
| Sysinst parses the output of:
|
| gpt.c: if (collect(T_OUTPUT, &textbuf, "gpt -r show -a %s 2>/dev/null", dev)
I will take a look at where that is done, and see if what has currently
changed will affect it, just in case something better doesn't appear, and
either undo my change, or send you a patch for sysinst which will handle
things either way (there's just a little info added, nothing removed).
| gpt.c: "gpt -r show -b %" PRIu64 " %s 2>/dev/null", start, disk) < 1)
That one has currently not changed at all, its output is simple enough
that I couldn't see anything useful to modify in that.
jacaranda$ ./gpt show -b 524288 ld1
Details for index 2:
Start: 524288 (256M)
Size: 12058560 (6G)
Type: ffs (49f48d5a-b10e-11dc-b99b-0019d1879648)
GUID: d4dbbda3-2ee0-4975-a083-c6bea3ada9cb
Label: Backup_Root
Attributes: None
The main modifications have been to "gpt show" when -A -h or -H are used,
and none of -a -b or -i. I don't believe a simple "gpt show device"
has altered at all (regardless of -g -l -u -x which all just do the same
as before).
| All other gpt(8) invocations only care about exit status (and the output
| is ignored/discarded).
Good - aside from the changes to show, the main alteration has been in
some of the error messages -- including not generating 2 messages when
one would do. The old way:
jacaranda$ gpt show /
gpt: /: Cannot get sector size (Inappropriate ioctl for device)
gpt: /: No GPT found (Inappropriate ioctl for device)
and the new:
jacaranda$ ./gpt show /
gpt: /: Not a device or plain file (Block device required)
The "Block device required" is wrong, but something from errno
is always printed for that error, and that's the closest one I
could find to being rational, if anyone has better EXXXX suggestion
which will generate a better message, please, let me know. (note
that errno==0 results in worse output). Perhaps I should change
that to avoid using errno at all:
jacaranda$ ./gpt show /
gpt: /: Not a device or plain file
Yes, that is better. I'll look and see which other errors (I
suspect there are a few) are including errno when they have no
reason to do that.
I can't see that bothering sysint though, I doubt you are likely
to be handing gpt directories, fifos, ... as the "device" to work
with. The exit status is unchanged of course.
kre
Home |
Main Index |
Thread Index |
Old Index