Home | History | Annotate | Download | only in gpt
History log of /src/sbin/gpt/show.c
RevisionDateAuthorComments
 1.47  23-Feb-2025  christos Pass some lint.
 1.46  04-Nov-2024  christos Additions to guid printing and an option to print start/size in hex
(from Anon Ymous)
 1.45  13-Sep-2024  mlelstv Use destination variable also to determine size. No binary change, both
buffers are of the same size.
 1.44  26-Mar-2019  martin branches: 1.44.12;
When displaying a single partition (gpt show -i ...) display offset
and size in sectors (instead of the totally confusing bytes),
followed by the humanized byte offset/size.

This makes the numbers match the "gpt show" or "gpt show -a"
output.
 1.43  24-Mar-2019  martin Make the "show" subcommand accept -b startsec to identify a partition
(very usefull for scripts and other robotic callers).
 1.42  03-Mar-2019  jnemeth Make it clear when displaying data from the MBR.
 1.41  07-Sep-2017  christos branches: 1.41.4;
use __arraycount
 1.40  06-Sep-2017  christos - make sure that the utf16 string is padded with 0's where needed.
- since the utf16 string is not 0 terminated, pass the size of the string.
 1.39  05-Oct-2016  kre branches: 1.39.6;

Avoiding having parameter name shadow its own function's name.
Strictly this shouldnt be (and hasn't been for almost a year) a problem,
but there are compilers that warn about locals shadowing globals (which
this is/was) and it is easy to avoid, so ... No functinal difference.
 1.38  09-Jun-2016  kre branches: 1.38.2;

Make "gpt show" add an "(active)" annotation to the PMBR output line
when it has been marked active for legacy (non UEFI) booting.
This was (kind of obviously) intended by the previous commit, but...
 1.37  09-Jun-2016  christos PR/51230: Add the ability to set the active flag in the PMBR.
 1.36  31-May-2016  dholland PR 50756 David Binderman: avoid running off the end of an array in case
thing we're looking for isn't there. Which is probably impossible, but
that's not obvious.
 1.35  29-Dec-2015  christos - add more informational messages
- handle case where last argument is an option not a device (set -l)
 1.34  26-Dec-2015  martin Improve "show -a" display: split human readable Type: field from the Type-GUID
to avoid wrapping in the common case; add a human readable Size: display.
 1.33  25-Dec-2015  wiz Simplify usage for gpt show.
 1.32  25-Dec-2015  martin Add a -a flag to the show command, so we can display the full GPT with
all information in one go.
 1.31  06-Dec-2015  christos Add listing commands for type, set and unset.
Add help and formatting for set and unset.
Change show to print all the attribute info in one line.
 1.30  04-Dec-2015  christos fix label printing.
 1.29  03-Dec-2015  christos WARNS=6
 1.28  03-Dec-2015  christos eliminate static globals so that commands can be re-used.
 1.27  02-Dec-2015  christos refactor the utf code so that it does not leak memory.
 1.26  01-Dec-2015  christos merge command line parsers and check all memory allocations.
 1.25  01-Dec-2015  christos Refactor the command dispatching and help printing logic.
 1.24  01-Dec-2015  christos Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.
 1.23  29-Nov-2015  christos Add the missing cases.
 1.22  29-Nov-2015  christos merge the create errors in one place and fix them.
 1.21  30-Sep-2014  jnemeth correctly show partition type in the new world order
 1.20  30-Sep-2014  jnemeth Check size of correct buffer. Note, just being pedantic as the buffer
being checked is the same size as the one that should have been checked.
 1.19  30-Sep-2014  christos Add internal uuid support, since the linux+macos versions of the library
are different than than *bsd ones, and others might not have it at all.
 1.18  30-Sep-2014  christos remove compat defines.
 1.17  29-Sep-2014  christos more toolification changes
 1.16  29-Sep-2014  christos minor toolification: need libprop...
 1.15  18-Dec-2013  jnemeth branches: 1.15.4;
If we want to GUIDs to display with correct endian, it helps to decode it first.
 1.14  09-Dec-2013  jnemeth For the "show -i <entry>" subcommand, print Start and Size both in
terms of number of sectors and bytes.
 1.13  08-Dec-2013  jnemeth fix off-by-one error
 1.12  30-Nov-2013  jnemeth Add two new options:

-g which shows the GUID for a partition
-i which shows all the gory details for a particular option

XXX the output format of -i is subject to change
 1.11  19-Oct-2013  jnemeth recognize FreeBSD ZFS partition
 1.10  13-Apr-2013  jakllsch Make pre-initialized partition type uuid_t symbols 'static const'.

This conserves a few hundred bytes of total program size by
allowing the linker to merge duplicates.
 1.9  13-Apr-2013  jakllsch Clean up gpt(8) a bit more

uuid_create_nil(3) and uuid_is_nil(3) take a uuid_t*, not a pointer to
an array of bytes merely casted to compatible type.

Additonally, there no need for extra casts and address-of operations when
using le_uuid_*() functions.

Furthermore, le_uuid_*() are identical to uuid_*_le functions in
libc/libuuid, so use those instead on NetBSD.
 1.8  18-Jan-2013  jakllsch Now that GPT_ENT_TYPE_LINUX_DATA is diffrent from the Windows one, use it.
 1.7  27-Aug-2011  joerg branches: 1.7.2; 1.7.8;
Use __dead
 1.6  06-Jan-2011  jakllsch UFS is called FFS in the NetBSD case. Display as such and accept as input.
 1.5  24-Feb-2008  christos PR/38094: Robert Millan: support "BIOS Boot" partition type in gpt(8)
 1.4  28-Dec-2007  riz branches: 1.4.2; 1.4.4;
As discussed on tech-userlevel, add NetBSD GPT partition types for
swap, ffs, lfs, raidframe, ccd and cgd. gpt(8) now defaults to
NetBSD ffs if no type is given, but previous FreeBSD types are
still recognized in the DKWEDGE_AUTODISCOVER code.
 1.3  18-Dec-2007  riz Fix the usage strings for each command, and print them all for the
"global" usage. It's still a little ugly, but hopefully not as
fantastically confusing as before...
 1.2  15-Oct-2006  christos branches: 1.2.2; 1.2.4; 1.2.8; 1.2.10;
Make this work under NetBSD.
 1.1  15-Oct-2006  christos branches: 1.1.1;
Initial revision
 1.1.1.1  15-Oct-2006  christos Import the gpt tool from FreeBSD
 1.2.10.2  18-Feb-2008  mjf Sync with HEAD.
 1.2.10.1  27-Dec-2007  mjf Sync with HEAD.
 1.2.8.2  23-Mar-2008  matt sync with HEAD
 1.2.8.1  09-Jan-2008  matt sync with HEAD
 1.2.4.1  03-Jun-2008  skrll Sync with netbsd-4.
 1.2.2.2  08-Apr-2008  jdc Pull up revisions:
src/sbin/gpt/add.c 1.6
src/sbin/gpt/gpt.c 1.7
src/sbin/gpt/show.c 1.4
src/sys/dev/dkwedge/dkwedge_gpt.c 1.7
src/sys/sys/disk.h 1.47
src/sys/sys/disklabel_gpt.h 1.4
(requested by riz in ticket #1119).

As discussed on tech-userlevel, add NetBSD GPT partition types for
swap, ffs, lfs, raidframe, ccd and cgd. gpt(8) now defaults to
NetBSD ffs if no type is given, but previous FreeBSD types are
still recognized in the DKWEDGE_AUTODISCOVER code.
 1.2.2.1  08-Apr-2008  jdc Pull up revisions:
src/sbin/gpt/add.c 1.5
src/sbin/gpt/create.c 1.3
src/sbin/gpt/destroy.c 1.3
src/sbin/gpt/gpt.c 1.4-1.6
src/sbin/gpt/label.c 1.5-1.6
src/sbin/gpt/migrate.c 1.4
src/sbin/gpt/recover.c 1.3
src/sbin/gpt/remove.c 1.4
src/sbin/gpt/show.c 1.3
(requested by riz in ticket #1117).

Produce more useful error messages.

Fix the usage strings for each command, and print them all for the
"global" usage. It's still a little ugly, but hopefully not as
fantastically confusing as before...

Your friendly neighborhood 64-bit architecture here to remind you that
strlen returns size_t, and printf's precision specifier uses int.
 1.4.4.1  03-Apr-2008  mjf Sync with HEAD.
 1.4.2.1  24-Mar-2008  keiichi sync with head.
 1.7.8.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.8.2  23-Jun-2013  tls resync from head
 1.7.8.1  25-Feb-2013  tls resync with head
 1.7.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.2.1  23-Jan-2013  yamt sync with head
 1.15.4.2  13-Aug-2018  martin Catch up to current for the following, requested by sborrill in ticket #1629:

sbin/gpt/gpt_private.h up to 1.2
sbin/gpt/header.c up to 1.9
sbin/gpt/main.c up to 1.11
sbin/gpt/drvctl.c delete
sbin/gpt/Makefile up to 1.18
sbin/gpt/add.c up to 1.44
sbin/gpt/backup.c up to 1.18
sbin/gpt/biosboot.c up to 1.30
sbin/gpt/create.c up to 1.23
sbin/gpt/destroy.c up to 1.10
sbin/gpt/gpt.8 up to 1.63
sbin/gpt/gpt.c up to 1.75
sbin/gpt/gpt.h up to 1.38
sbin/gpt/gpt_uuid.c up to 1.15
sbin/gpt/gpt_uuid.h up to 1.7
sbin/gpt/label.c up to 1.29
sbin/gpt/map.c up to 1.14
sbin/gpt/map.h up to 1.6
sbin/gpt/migrate.c up to 1.33
sbin/gpt/recover.c up to 1.18
sbin/gpt/remove.c up to 1.22
sbin/gpt/resize.c up to 1.23
sbin/gpt/resizedisk.c up to 1.17
sbin/gpt/restore.c up to 1.18
sbin/gpt/set.c up to 1.14
sbin/gpt/show.c up to 1.41
sbin/gpt/type.c up to 1.15
sbin/gpt/unset.c up to 1.14

Many changes including:
- Significant refactoring
- PR/51230: Add the ability to set the active flag in the PMBR
- Let individual commands decide if ioctl(DIOCMWEDGES) should be done
- Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists
- Add listing commands for type, set and unset
- Add help and formatting for set and unset
- Change show to print all the attribute info in one line.
- Improve documentation, including booting and exit status
- Check device parameter to avoid segfaults
 1.15.4.1  02-Jun-2015  snj Pull up following revision(s) (requested by jnemeth in ticket #774):
sbin/gpt/Makefile: revisions 1.9-1.13
sbin/gpt/add.c: revisions 1.25-1.27
sbin/gpt/backup.c: revisions 1.2-1.8
sbin/gpt/biosboot.c: revisions 1.8-1.14
sbin/gpt/create.c: revisions 1.8-1.12
sbin/gpt/destroy.c: revisions 1.5-1.6
sbin/gpt/drvctl.c: revision 1.1
sbin/gpt/gpt.8: revisions 1.29-1.36
sbin/gpt/gpt.c: revisions 1.29-1.40
sbin/gpt/gpt.h: revisions 1.12-1.18
sbin/gpt/gpt_uuid.c: revisions 1.1-1.10
sbin/gpt/gpt_uuid.h: revisions 1.1-1.3
sbin/gpt/label.c: revisions 1.15-1.18
sbin/gpt/map.c: revision 1.7
sbin/gpt/migrate.c: revisions 1.15-1.21
sbin/gpt/recover.c: revision 1.5
sbin/gpt/remove.c: revisions 1.13-1.16
sbin/gpt/resize.c: revisions 1.9-1.11
sbin/gpt/resizedisk.c: revisions 1.1-1.6
sbin/gpt/restore.c: revisions 1.2-1.7
sbin/gpt/set.c: revisions 1.3-1.5
sbin/gpt/show.c: revision 1.16-1.21
sbin/gpt/type.c: revisions 1.1-1.6
sbin/gpt/unset.c: revisions 1.3-1.5
- record the sector size of the disk
- correct confusion with end_cylinder and end_sector in MBRs
--
- dump all partitions, not just ones that are in use
- while here, squash a memory leak
It shouldn't be necessary to backup unused partitions, however
the partition GUID is created at the time the GPT is created and
is never changed. It shouldn't matter if the GUID of an unused
partition changes, but there may be some special case where it
does. Since it isn't a big deal to record the unused partitions,
might as well do it.
--
Initial cut of gpt restore. This functions correctly in testing,
but isn't all that pretty. It has minimal error testing and may
leak memory. It also only works with empty disks. If passed "-F"
flag, it will blank the disk for you.
--
document the new restore subcommand
--
- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT
--
Fix compile error observed on i386. Use PRIu64.
--
no C99isms in tool code
--
- handle a GPT that isn't an exact multiple of a sector
- adjust PMBR size, in case new disk is a different size
- don't leak as much memory
- clean up error handling somewhat
--
PR/44218 - David Young -- add "type" subcommand to change a partition type
--
PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option
--
minor toolification: need libprop...
--
more toolification
--
more toolification changes
--
remove compat defines.
--
Add internal uuid support, since the linux+macos versions of the library
are different than than *bsd ones, and others might not have it at all.
--
Check size of correct buffer. Note, just being pedantic as the buffer
being checked is the same size as the one that should have been checked.
--
correctly show partition type in the new world order
--
actually return the uuid when parsing one that is in numeric format
--
using random values for hdr->hdr_guid does not work very well
--
oops, forgot to update end of data area
--
It's HAVE_NBTOOL_CONFIG_H, not HAVE_NBTOOLS_CONFIG_H
--
Fix tools build on !NetBSD.
--
include <sys/endian.h> for both the non-tools build,
and the tools build on a host where the file exists.
Fixes a build problem on FreeBSD, reported by Herbert J. Skuhra, where
tools/compat's configure detected that be32dec() and friends were
available in the host's <sys/endian.h>, so tools/compat did not provide
its own versions.
--
"0" is not guaranteed to be unique
--
provide a copy of the kernel uuid generator (with portable API calls) for
tools.
--
Allow specifying sector and media size on the command line.
--
Remove trailing whitespace.
--
Make gpt(8) generate v4 (random) uuids.
Don't needlessly leak your date/time and MAC address when you edit
the disk.
Read from /dev/urandom rather than calling arc4random or anything,
since this is a tool. (Cygwin seems to have /dev/urandom, but yell
if this breaks the build on your exotic platform because it lacks
/dev/urandom.)
ok apb
--
Paranoia: choke noisily on EOF from /dev/urandom.
--
Report the argument instead of (null) when opendisk fails.
--
handle constness
--
handle constness better
--
Add some more common partition types.
--
Bump date for previous.
--
Fix handling of -t option for the type command.
Match any type, when no option is given, just like for the label command.
--
Factor out the getdisksize() drvctl method, and provide an alternative that
directly uses the disk ioctl's instead of relying on the drvctl device driver
which is currently not mandatory.
 1.38.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.39.6.1  12-Feb-2018  snj Pull up following revision(s) (requested by christos in ticket #545):
sbin/gpt/backup.c: 1.17-1.18
sbin/gpt/biosboot.c: 1.29-1.30
sbin/gpt/gpt.c: 1.71-1.73
sbin/gpt/gpt.h: 1.36
sbin/gpt/restore.c: 1.17
sbin/gpt/show.c: 1.40-1.41
sys/dev/dkwedge/dkwedge_gpt.c: 1.19-1.20
PR/52522: Piotr Meyer: Don't NUL terminate the gpt label name.
--
- make sure that the utf16 string is padded with 0's where needed.
- since the utf16 string is not 0 terminated, pass the size of the string.
--
use __arraycount
--
PR/52522: ent_name is not necessarily 0 terminated, so check bounds.
--
use arraycount.
 1.41.4.1  10-Jun-2019  christos Sync with HEAD
 1.44.12.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed