History log of /src/sbin/gpt/
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.19 25-Jun-2019 jnemeth

Add an "uuid" command to generate a new UUID for a portion. The
primary intention is for use for after cloning disks to prevent
collisions.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.18 03-Dec-2015 christos

branches: 1.18.16;
WARNS=6


1.17 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.16 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.15 29-Nov-2015 christos

Remove getdisksize support; we either have the ioctls (current/-7) or we
don't (non-netbsd-current/7+tools).


1.14 03-Nov-2015 jnemeth

Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists.


1.13 29-Dec-2014 christos

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.12 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.11 29-Sep-2014 christos

more toolification


1.10 28-Sep-2014 jnemeth

PR/44218 - David Young -- add "type" subcommand to change a partition type


1.9 23-Sep-2014 jnemeth

- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT


Revision tags: netbsd-7-base tls-maxphys-base
1.8 10-Aug-2014 jnemeth

branches: 1.8.2;
Add restore subcommand.

XXX It does not actually work yet. It is being committed now to make
later pullups easier.


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.7 19-Dec-2013 jnemeth

Add the backup subcommand. It dumps the contents of the partition
tables as a plist, which is readable by the restore subcommand.

XXX restore subcommand forthcoming


1.6 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


1.5 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.4 06-Jan-2011 jakllsch

branches: 1.4.6; 1.4.12;
Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.


Revision tags: matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.3 11-Apr-2009 lukem

Enable WARNS=4 by default except for:
dump dump_lfs fsck_ffs fsck_lfs fsdb mount_smbfs
newfs_ext2fs newfs_lfs resize_lfs setkey


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base mjf-devfs-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
1.2 15-Oct-2006 christos

branches: 1.2.28;
Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.48 17-Dec-2025 nia

gpt(8): Fix "useless use of <sys/param.h>" antipattern.


1.47 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.46 23-Feb-2025 christos

Pass some lint.


1.45 02-Nov-2024 kre

PR bin/58806 Never create a partition with a null guid

If a new partition entry being added doesn't already have a guid,
make one for it.


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.44 03-Jul-2018 jnemeth

branches: 1.44.2; 1.44.10; 1.44.12;
Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.43 29-Dec-2015 christos

branches: 1.43.14; 1.43.16;
- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.42 03-Dec-2015 christos

CID 1341561: Argument memory leak


1.41 03-Dec-2015 christos

CID 1341560: Free arg.


1.40 03-Dec-2015 christos

CID 1341548: Check error returns


1.39 03-Dec-2015 christos

WARNS=6


1.38 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.37 02-Dec-2015 jnemeth

hrmm...

i386devel: {245} ./gpt add -b 1000 -s 1000 disk
Segmentation fault (core dumped)

Where's my flyswatter? .......zzzzzzzap


1.36 02-Dec-2015 christos

refactor the utf code so that it does not leak memory.


1.35 02-Dec-2015 christos

- write a function to set the entity, so that we don't reset to guid.
- entry 0 means create entry.


1.34 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.33 01-Dec-2015 christos

refactor more duplicated code.


1.32 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.31 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.30 01-Dec-2015 christos

- use gpt_msg to print informational messages (perhaps these should be printed
only with -v)
- don't print any messages with gpt_msg if quiet
- print a message if we didn't reconfigure the wedges


1.29 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.28 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.27 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.26 30-Sep-2014 christos

remove compat defines.


1.25 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.24 10-Dec-2013 jnemeth

branches: 1.24.4;
Explicitly state which partition was added/modified.


1.23 08-Dec-2013 jnemeth

For the add and resize subcommands, change the -s option. If there is
no suffix, or the suffix is 's' or 'S', size is in sectors (as before)
otherwise size is in bytes.


1.22 06-Dec-2013 jnemeth

Don't attempt to create/resize an unaligned partition if the attempt
to create/resize an aligned one failed. This simplifies the code
and prevents surprises. If the user wants an unaligned partition
in the case where an aligned one fails, they can simply retry the
command without the "-a" option. This change was requested by
wiz@, and after some thought I agree with it.


1.21 28-Nov-2013 jnemeth

when calling dehumanize_number() make sure the resulting number is >= 1


1.20 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.19 22-Nov-2013 jnemeth

change the "-b blocknr" parameter to accept a "human number"


1.18 22-Nov-2013 jnemeth

In the manpage:
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/

In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/

This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.


1.17 19-Nov-2013 jnemeth

delete an errant where it is obvious what the code is doing


1.16 19-Nov-2013 jnemeth

When setting a label on the new partition, be sure to set the label
in the secondary partition table as well.


1.15 19-Nov-2013 jnemeth

Add two new options to the "add" subcommand:

-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition

These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.14 26-May-2013 wiz

Instead of 'no space', say 'not enough space' in error message.


1.13 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.12 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.11 27-Aug-2011 joerg

branches: 1.11.2; 1.11.8;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.10 06-Jan-2011 riz

Clarify the 'dkctl addwedge' usage message after creating a GPT
partition.


1.9 06-Jan-2011 jakllsch

UFS is called FFS in the NetBSD case. Display as such and accept as input.


Revision tags: matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.8 07-Feb-2009 uebayasi

Let 'gpt add' suggest a collect device name so that opendisk(3) called by
dkctl(8) succeeds.


1.7 07-Feb-2009 uebayasi

Make manual and usage consistent. No functional changes.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
1.6 28-Dec-2007 riz

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.5 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...


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
1.4 16-Feb-2007 riz

branches: 1.4.4; 1.4.6;
Use strtoll() when converting a 64-bit quantity. This makes "gpt add"
work with an offset of more than 2147483647 sectors. While I'm here,
use strtoul() when converting an unsigned quantity.


Revision tags: netbsd-4-base
1.3 17-Oct-2006 he

branches: 1.3.2;
Add initialization of a variable where gcc for some archs thinks
that it may be used un-initialized. From cursory inspection it is
not obvious that gcc is wrong.


1.2 15-Oct-2006 christos

Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.22 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.21 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.20 08-Jun-2020 thorpej

branches: 1.20.8;
When we add "entries", "index", and "sector_size" values to the dictionary,
add them as signed valaues, rather than unsigned (which is how we keep them
in memory). This causes them be serialized in base-10 (rather than base-16,
which is the default for unsigned). This behavior is documented in
prop_number(3). Fixes t_gpt::backup_2part unit test.


1.19 07-Jun-2020 thorpej

Update for proplib(3) API changes.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.18 07-Sep-2017 christos

use __arraycount


1.17 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.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.16 03-Dec-2015 christos

branches: 1.16.8;
CID 1341558: Fix proplib memory leaks


1.15 03-Dec-2015 christos

compare to stdout, thanks kre


1.14 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.13 02-Dec-2015 christos

Allow backup and restore to operate on files.


1.12 02-Dec-2015 christos

split out into smaller functions.


1.11 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.10 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.9 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.8 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.7 30-Sep-2014 christos

remove compat defines.


1.6 29-Sep-2014 christos

more toolification changes


1.5 29-Sep-2014 christos

more toolification


1.4 29-Sep-2014 christos

minor toolification: need libprop...


1.3 10-Sep-2014 jnemeth

- 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.


1.2 09-Sep-2014 jnemeth

- record the sector size of the disk
- correct confusion with end_cylinder and end_sector in MBRs


Revision tags: tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.1 19-Dec-2013 jnemeth

branches: 1.1.4; 1.1.6; 1.1.8;
Add the backup subcommand. It dumps the contents of the partition
tables as a plist, which is readable by the restore subcommand.

XXX restore subcommand forthcoming


1.36 17-Dec-2025 nia

gpt(8): Fix "useless use of <sys/param.h>" antipattern.


1.35 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.34 23-Feb-2025 christos

Pass some lint.


1.33 13-Sep-2024 mlelstv

Don't use kernel type daddr_t for disk offsets.


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.32 20-Jun-2019 martin

branches: 1.32.2; 1.32.10; 1.32.12;
When biosboot is used on an existing wedge and we are switching to
the gpt of the parent device, do not pass the size of the wedge to
gpt_open, it certainly is smaller than the whole device.
Fixes bin/54312.


Revision tags: phil-wifi-20190609
1.31 04-Apr-2019 martin

Allow specifying the partition via -b startsec for the biosboot cmd.


Revision tags: pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.30 07-Sep-2017 christos

branches: 1.30.4;
use __arraycount


1.29 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.


Revision tags: perseant-stdc-iso10646-base
1.28 03-Jul-2017 mrg

only do wedges if not the tools version. fixes build on netbsd-4,
and any other place that might have the same ioctl name while having
something not quite right (in this case, cpuid_t in headers not
working properly..)

XXX: pullup-8


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.27 16-Feb-2017 christos

branches: 1.27.4;
Add -T timestamp for reproducible builds.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.26 09-Jun-2016 christos

branches: 1.26.2; 1.26.4;
Rename 'a' to set the active PMBR flag to 'A'


1.25 09-Jun-2016 christos

PR/51230: Add the ability to set the active flag in the PMBR.


1.24 29-Dec-2015 christos

- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.23 03-Dec-2015 christos

more leak


1.22 03-Dec-2015 christos

WARNS=6


1.21 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.20 02-Dec-2015 christos

don't advertise stuff we don't support.


1.19 02-Dec-2015 christos

refactor the utf code so that it does not leak memory.


1.18 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.17 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.16 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.15 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.14 03-Oct-2014 christos

provide a copy of the kernel uuid generator (with portable API calls) for
tools.


1.13 02-Oct-2014 joerg

Fix tools build on !NetBSD.


1.12 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.11 29-Sep-2014 christos

more toolification


1.10 29-Sep-2014 christos

minor toolification: need libprop...


1.9 29-Sep-2014 jnemeth

PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option


1.8 26-Sep-2014 jnemeth

no C99isms in tool code


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.7 27-Nov-2013 jnemeth

branches: 1.7.4;
Remove FreeBSD specific code as per message to tech-userlevel.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.6 13-Apr-2013 jakllsch

drop trailing whitespace


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.5 27-Aug-2011 joerg

branches: 1.5.2; 1.5.8;
Use __dead


1.4 17-Aug-2011 martin

Fix sign compare bugs


1.3 17-Aug-2011 jakllsch

Ajdust bootcode file name from mbr_gpt to gptmbr.bin.


1.2 17-Aug-2011 jakllsch

Switch 'gpt biosboot' to support T13 EDD-4 annex A GPT hybrid MBR instead
of a home-grown MBR/VBR hand off protocol.

'biosboot' now will set the legacy BIOS boot flag instead of patching a
GUID into the MBR.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.1 06-Jan-2011 jakllsch

Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.


1.26 17-Dec-2025 nia

gpt(8): Fix "useless use of <sys/param.h>" antipattern.


1.25 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.24 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-8-3-RELEASE netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104
1.23 23-Sep-2016 christos

branches: 1.23.26;
PR/51497: Clare: Allow gpt -p <n> create to work.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.22 09-Jun-2016 christos

branches: 1.22.2;
Rename 'a' to set the active PMBR flag to 'A'


1.21 09-Jun-2016 christos

PR/51230: Add the ability to set the active flag in the PMBR.


1.20 29-Dec-2015 christos

- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.19 03-Dec-2015 christos

CID 1341556: Don't leak map info


1.18 03-Dec-2015 christos

WARNS=6


1.17 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.16 01-Dec-2015 christos

refactor more duplicated code.


1.15 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.14 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.13 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.12 03-Oct-2014 christos

provide a copy of the kernel uuid generator (with portable API calls) for
tools.


1.11 03-Oct-2014 jnemeth

"0" is not guaranteed to be unique


1.10 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.9 30-Sep-2014 christos

remove compat defines.


1.8 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.7 04-Dec-2013 jakllsch

branches: 1.7.4;
Use MBR_PTYPE_ defines from <sys/bootblock.h>.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.6 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.5 27-Aug-2011 joerg

branches: 1.5.2; 1.5.8;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.4 06-Jan-2011 jakllsch

Use less bogus CHS addresses in PMBR.
With the ending head set at 0xff one machine I have will never leave
the initial startup screen if such a disk is present. Additionally,
Wikipedia suggests without citiation that 254 is the maximium allowable
value for the head, and this seems to be the case.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
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...


Revision tags: netbsd-4-0-1-RELEASE matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-4-base
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


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.15 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.14 20-Nov-2022 mlelstv

branches: 1.14.4;
Fix destroying and moving GPT header also for truncated/extended
images.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.13 16-Oct-2019 jnemeth

Do the 'dkctl makewedges' dance to drop any wedges assoicated the
destroyed GPT.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609
1.12 04-Apr-2019 martin

PR bin/54088: make "destroy" remove the protective MBR too.
We could make this optional if someone comes up with a good reason
to leave it intact.


1.11 04-Apr-2019 martin

Ignore -f with the "destroy" command completely (it was effectively
ignored already, so no functional change). Leave it as valid option
for compatibility.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.10 03-Dec-2015 christos

branches: 1.10.16;
eliminate static globals so that commands can be re-used.


1.9 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.8 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.7 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.6 29-Sep-2014 christos

more toolification


1.5 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.4 27-Aug-2011 joerg

branches: 1.4.20;
Use __dead


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
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...


Revision tags: netbsd-4-0-1-RELEASE matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-4-base
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


Revision tags: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base perseant-stdc-iso10646-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.2 29-Nov-2015 christos

Remove getdisksize support; we either have the ioctls (current/-7) or we
don't (non-netbsd-current/7+tools).


1.1 29-Dec-2014 christos

branches: 1.1.2;
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.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.86 09-Feb-2025 pgoyette

Minor cleanups.


1.85 12-Jan-2025 christos

Add missing "to" (Anon Ymous)


1.84 04-Nov-2024 christos

Additions to guid printing and an option to print start/size in hex
(from Anon Ymous)


1.83 19-Aug-2024 christos

Add -U option to specify new UUID
Add OpenBSD
from Anon Ymous


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.82 10-Jun-2024 kre

branches: 1.82.2;

Revert unintended commit.


1.81 10-Jun-2024 kre

Note need to deal with old libarchive.so files in cdrom images when doing
an update build.


1.80 07-Nov-2023 gutteridge

gpt.8: fix grammar in a sentence


1.79 31-Oct-2023 martin

Apply patch from Thierry Laronde: add missing suffixes for size values
and clarify that they are case independant.


1.78 15-Jul-2023 gutteridge

gpt.8: fix some grammar

(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)


1.77 15-Jul-2023 gutteridge

gpt.8: drop cross-reference to cvs(1)

It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.


Revision tags: netbsd-10-base
1.76 07-Apr-2022 kre

branches: 1.76.2;

Note that biosboot without -A clears the PMBR "active" flag.
While here, fix some grammar and make the selection options
for biosboot a little clearer.

Ride nia@'s Dd bump.


1.75 07-Apr-2022 nia

gpt.8: Clarify that "windows" partition types are also used for FAT32
("msdos" in NetBSD terms), and UDF partitions. Use the same name as
Wikipedia, "Microsoft basic data".


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.74 27-Jul-2020 christos

catch up with source rename of fbsd-zfs -> zfs


1.73 24-May-2020 wiz

Fix typo in macro. Sort option descriptions.


1.72 24-May-2020 jmcneill

Add -H flag to ignore existing MBR (Hybrid MBR/GPT mode).


1.71 24-May-2020 jmcneill

Exit gracefully when auto-expanding a partition and it is already the
correct size. Add a -q flag to "resize" and "resizedisk" commands to skip
printing warnings in the already resize paths.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.70 26-Jul-2019 martin

Remove outdated note about sysinst restrictions


1.69 25-Jun-2019 jnemeth

Add an "uuid" command to generate a new UUID for a portion. The
primary intention is for use for after cloning disks to prevent
collisions.


Revision tags: phil-wifi-20190609
1.68 04-Apr-2019 martin

Allow specifying the partition via -b startsec for the biosboot cmd.


1.67 26-Mar-2019 martin

Allow -b to specify a partition for "gpt unset" as well.


1.66 25-Mar-2019 martin

Allow -b startsec to specify the partition to change for the set subcommand
as well.
Add another option, -N, as a quick way to remove all attributes.


1.65 24-Mar-2019 martin

Make the "show" subcommand accept -b startsec to identify a partition
(very usefull for scripts and other robotic callers).


1.64 24-Mar-2019 martin

Add support for specifying the partition to resize via -b startsec
(similar to label and other subcommands). Do not fully add gpt_find
functionality here, as resizing multiple partitions in one go does not
make sense.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
1.63 01-May-2018 kre

branches: 1.63.2;

Spello. (it is "existence").

ispell also says that we should s/parseable/parsable/ but I'm
not sure about that one, so I left it.

I also left a correct spelling that no-one has bothered to mangle!


1.62 01-May-2018 wiz

Bump date for new EXIT STATUS section.


1.61 01-May-2018 wiz

Sort sections.


1.60 01-May-2018 martin

Make the "gpt header" command return EXIT_FAILURE when no GPT is present.
This helps sysinst to tell a GPT labeled disk from others.
Very lazy version of a change proposed by kre.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415
1.59 11-Apr-2018 mrg

add information about how to boot from gpt. mostly taken from the wiki.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.58 19-Mar-2018 mlelstv

Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
1.57 15-Jan-2018 sborrill

branches: 1.57.2;
Explain what suffixes are accepted when specifying a size.


1.56 03-Oct-2017 mlelstv

clarify that alignment is the number of bytes to align to.


1.55 05-Aug-2017 wiz

Use Fx/Nx.


1.54 04-Aug-2017 kre

Fix a typo, and make a couple of minor wording improvements.
I resisted the (very weak) impulse to Americanise some spellings ...


1.53 03-Aug-2017 msaitoh

Add note about bootme flag:

The bootme flag is used to indicate which partiotion should be booted
by UEFI boot code.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.52 16-Feb-2017 christos

branches: 1.52.4;
Add -T timestamp for reproducible builds.


1.51 27-Jan-2017 abhinav

Fix spelling of partition.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104
1.50 01-Nov-2016 jdolecek

branches: 1.50.2;
remove dup line


Revision tags: localcount-20160914
1.49 11-Sep-2016 sevan

Document the version gpt first appeared.
Replace contractions.
Bump date.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.48 09-Jun-2016 christos

branches: 1.48.2;
Rename 'a' to set the active PMBR flag to 'A'


1.47 09-Jun-2016 kre

Fix rendering of biosboot command synopsis.


1.46 09-Jun-2016 christos

PR/51230: Add the ability to set the active flag in the PMBR.


1.45 25-Dec-2015 wiz

Simplify usage for gpt show.


1.44 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.43 06-Dec-2015 wiz

Bump date for previous.
Remove trailing whitespace.


1.42 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.41 02-Dec-2015 christos

Allow backup and restore to operate on files.


1.40 01-Dec-2015 christos

Reflect reality better; we don't handle multiple devices anymore, and
the partitions option is only for the commands that support it.


1.39 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.38 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.37 03-Nov-2015 jnemeth

Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists.


1.36 06-Dec-2014 wiz

Bump date for previous.


1.35 06-Dec-2014 mlelstv

Add some more common partition types.


1.34 04-Oct-2014 wiz

Remove trailing whitespace.


1.33 04-Oct-2014 christos

Allow specifying sector and media size on the command line.


1.32 29-Sep-2014 jnemeth

PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option


1.31 28-Sep-2014 jnemeth

PR/44218 - David Young -- add "type" subcommand to change a partition type


1.30 23-Sep-2014 jnemeth

- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT


1.29 20-Sep-2014 jnemeth

document the new restore subcommand


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.28 19-Dec-2013 wiz

branches: 1.28.4;
Bump date for previous.


1.27 19-Dec-2013 jnemeth

Add the backup subcommand. It dumps the contents of the partition
tables as a plist, which is readable by the restore subcommand.

XXX restore subcommand forthcoming


1.26 09-Dec-2013 wiz

Fix typo.


1.25 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


1.24 09-Dec-2013 jnemeth

For the "show -i <entry>" subcommand, print Start and Size both in
terms of number of sectors and bytes.


1.23 08-Dec-2013 jnemeth

For the add and resize subcommands, change the -s option. If there is
no suffix, or the suffix is 's' or 'S', size is in sectors (as before)
otherwise size is in bytes.


1.22 06-Dec-2013 jnemeth

Don't attempt to create/resize an unaligned partition if the attempt
to create/resize an aligned one failed. This simplifies the code
and prevents surprises. If the user wants an unaligned partition
in the case where an aligned one fails, they can simply retry the
command without the "-a" option. This change was requested by
wiz@, and after some thought I agree with it.


1.21 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.20 22-Nov-2013 jnemeth

bump date


1.19 22-Nov-2013 jnemeth

In the manpage:
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/

In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/

This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.


1.18 20-Nov-2013 wiz

shrunk.


1.17 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


1.16 19-Nov-2013 jnemeth

update synopsis for add subcommand


1.15 19-Nov-2013 jnemeth

Add two new options to the "add" subcommand:

-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition

These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.


1.14 24-Oct-2013 jnemeth

- markup
- typo; the label command labels partitions, not remove them
- migrate -s isn't applicable to NetBSD
- add information about the space required for migration
- add a "gpt show -l" example


1.13 20-Oct-2013 jnemeth

revert typo fix; teach me to blindly take changes from upstream


1.12 19-Oct-2013 jnemeth

type fix: accommodate. -> accomodate.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5
1.11 02-May-2012 jakllsch

branches: 1.11.2;
Bump date to date of previous change.


Revision tags: yamt-pagecache-base4
1.10 09-Mar-2012 drochner

fix a path


Revision tags: netbsd-6-base
1.9 11-Nov-2011 wiz

branches: 1.9.2;
Add an EXAMPLE section showing how to add a swap file system using gpt. Bump date.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.8 19-Sep-2011 wiz

branches: 1.8.2;
Minimally document gpt recover. Bump date.


Revision tags: cherry-xenmp-base
1.7 27-Mar-2011 jym

Document biosboot. Xref boot(8) and installboot(8).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
1.6 09-Feb-2011 schnoebe

List all the aliases supported for GPT partition types.


Revision tags: matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.5 11-Mar-2009 joerg

branches: 1.5.2;
Don't workaround ancient macro argument limit with .Xo/.Xc.


1.4 09-Mar-2009 joerg

Fix preamble to match order set out by mdoc(7). Discussed with wiz.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base mjf-devfs-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
1.3 24-Nov-2006 christos

branches: 1.3.28;
fix spelling of accommodate; from Zapher.


1.2 17-Oct-2006 wiz

Serial comma. Add RCS Id. Remove superfluous quotes.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.93 17-Dec-2025 nia

gpt(8): Fix "useless use of <sys/param.h>" antipattern.


1.92 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.91 23-Feb-2025 christos

Pass some lint.


1.90 20-Oct-2024 mlelstv

When generating timestamp based GUIDs for reproducable builds
- increment timestamp by 100ns for each partition.
- use the standard time-based UUID format (type 1) and don't
pretend it's a random number (type 4).
- make the -T option actually work for the uuid command.

Random GUIDs:
start size index contents
34 1000 1 GPT part - d93ba067-a788-4ce0-99b8-0ead51f00215
1034 2000 2 GPT part - bebba77a-7fdc-4ca0-a1bf-7450aa871d41

d93ba067-a788-4ce0-99b8-0ead51f00215:
Version 4 Random
Variant 2 RFC 4122
Data D9 3B A0 67 A7 88 4C E0 99 B8 0E AD 51 F0 02 15

bebba77a-7fdc-4ca0-a1bf-7450aa871d41:
Version 4 Random
Variant 2 RFC 4122
Data BE BB A7 7A 7F DC 4C A0 A1 BF 74 50 AA 87 1D 41

Timestamp based GUIDs:
start size index contents
34 1000 1 GPT part - 0a524600-8eba-11ef-8000-000000000000
1034 2000 2 GPT part - 0a524601-8eba-11ef-8000-000000000000

0a524600-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.0Z

0a524601-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.1Z

Node (host MAC address) and clock (sequence number incremented whenever
the time went backwards) are left undefined (all zero) for our purpose.


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.89 10-Jun-2024 kre

branches: 1.89.2;

Revert unintended commit.


1.88 10-Jun-2024 kre

Note need to deal with old libarchive.so files in cdrom images when doing
an update build.


1.87 13-Dec-2023 mrg

avoid use after free. skip the QUIET check already in gpt_warn().


1.86 11-Dec-2023 mlelstv

Be verbose about errors.


1.85 26-Sep-2023 kre

When extracting the attributes (to printable form), avoid simply ignoring
any attribute bits which are unknown, print them as a hex value. This
avoids "Attributes: " for most windows filesystem types, which all seem
to have but 63 set (which is supposed to mean "don't assign a drive letter"
which is akin to "noauto" in fstab - except it is set even on partitions
which do get mounted, so must mean something subtly different).

These upper 16 attribute bits are supposed to be file system type speficic
(in practice, they seem to be common to all filesystem types from one vendor)
but we don't have the info (yet anyway) to treat them like that.

ChromeOS seems to treat some of the bits as bit fields containing numeric
values - add #if 0'd (but compile tested) code to deal with those (maybe,
compile tested - but not execution tested) should someone ever get an
environment where these things occur, and could add the missing definitions
to actually test this.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.84 22-Nov-2022 mlelstv

Big-Endian fixes.


1.83 20-Nov-2022 mlelstv

Fix destroying and moving GPT header also for truncated/extended
images.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.82 24-May-2020 jmcneill

Add -H flag to ignore existing MBR (Hybrid MBR/GPT mode).


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.81 11-Oct-2019 christos

gpt_uuid_parse does not set errno ...


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
1.80 25-Jun-2019 jnemeth

Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.


1.79 21-Jun-2019 jnemeth

Add a third argument to the "cfn" function that is an argument to
gpt_change_ent(). The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry. It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


1.78 20-Jun-2019 martin

Do not try to close a NULL gpt. Fixes the core dump part of PR bin/54312


Revision tags: phil-wifi-20190609
1.77 27-Jan-2019 martin

Fix three MBR extended partition related bugs:
1) when walking an extended MBR chain, do not assign duplicate indices
2) the pointer to the next MBR may be any of the MBR_PTYPE_EXT* variants
3) the ext MBR chain links are relative to the primary extended partition,
unlike the contained partitions which are relative to the extended MBR
block address.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
1.76 14-Oct-2018 mlelstv

When changing entries skip those that do not match the -L option.
Should fix PR 53668.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.75 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.74 13-Feb-2018 sevan

branches: 1.74.2; 1.74.4;
Spelling


1.73 07-Sep-2017 christos

use __arraycount


1.72 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.71 05-Sep-2017 christos

PR/52522: Piotr Meyer: Don't NUL terminate the gpt label name.
XXX: pullup-8


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.70 16-Feb-2017 christos

branches: 1.70.4;
Add -T timestamp for reproducible builds.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104
1.69 24-Sep-2016 christos

branches: 1.69.2;
say that you need to destroy it first.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.68 09-Jun-2016 christos

branches: 1.68.2;
PR/51230: Add the ability to set the active flag in the PMBR.


1.67 08-Jan-2016 joerg

gpt_vwarnx is printf-like.


1.66 29-Dec-2015 christos

- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.65 26-Dec-2015 jnemeth

pretty up attribute display a bit


1.64 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.63 04-Dec-2015 christos

Fix resizedisk.


1.62 04-Dec-2015 christos

don't print dkctl message for files
fix typo


1.61 03-Dec-2015 christos

CID 1341556: Don't leak map info


1.60 03-Dec-2015 christos

Add a space.


1.59 03-Dec-2015 christos

WARNS=6


1.58 02-Dec-2015 christos

annotate map additions with non-allocated memory.


1.57 02-Dec-2015 christos

- check errors from map allocation
- make map_resize return -1 instead of 0, and handle errors locally
explaining what's going wrong


1.56 02-Dec-2015 christos

Always set NOSYNC if regular file, even if we got the size from the command
line.


1.55 02-Dec-2015 jnemeth

- dereferencing NULL is generally bad, found by visual inspection
- automatically set nosync when opening a file to avoid spurious errors


1.54 02-Dec-2015 christos

print the old and the new style usage.


1.53 02-Dec-2015 christos

refactor the utf code so that it does not leak memory.


1.52 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.51 01-Dec-2015 christos

refactor more duplicated code.


1.50 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.49 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.48 01-Dec-2015 christos

- use gpt_msg to print informational messages (perhaps these should be printed
only with -v)
- don't print any messages with gpt_msg if quiet
- print a message if we didn't reconfigure the wedges


1.47 01-Dec-2015 christos

only update the wedge information if it is supported.


1.46 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.45 29-Nov-2015 christos

Do division once


1.44 29-Nov-2015 christos

Only use the ioctl's if we have them.


1.43 29-Nov-2015 jnemeth

fix build breakage for systems that do not have DIOCG{SECTOR,MEDIA}SIZE


1.42 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.41 03-Nov-2015 jnemeth

Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists.


1.40 29-Dec-2014 christos

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.39 17-Nov-2014 mlelstv

handle constness better


1.38 17-Nov-2014 mlelstv

handle constness


1.37 17-Nov-2014 mlelstv

Report the argument instead of (null) when opendisk fails.


1.36 04-Oct-2014 christos

Allow specifying sector and media size on the command line.


1.35 02-Oct-2014 joerg

Fix tools build on !NetBSD.


1.34 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.33 30-Sep-2014 christos

remove compat defines.


1.32 29-Sep-2014 christos

more toolification


1.31 29-Sep-2014 christos

minor toolification: need libprop...


1.30 28-Sep-2014 jnemeth

PR/44218 - David Young -- add "type" subcommand to change a partition type


1.29 23-Sep-2014 jnemeth

- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT


Revision tags: netbsd-7-base tls-maxphys-base
1.28 10-Aug-2014 jnemeth

branches: 1.28.2;
Add restore subcommand.

XXX It does not actually work yet. It is being committed now to make
later pullups easier.


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.27 19-Dec-2013 jnemeth

Add the backup subcommand. It dumps the contents of the partition
tables as a plist, which is readable by the restore subcommand.

XXX restore subcommand forthcoming


1.26 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


1.25 04-Dec-2013 jakllsch

Use MBR_PTYPE_ defines from <sys/bootblock.h>.


1.24 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.23 23-Nov-2013 jnemeth

Only skip past _PATH_DEV if it is actually present.


1.22 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


1.21 19-Nov-2013 jnemeth

Add two new options to the "add" subcommand:

-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition

These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.20 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.19 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.


Revision tags: agc-symver-base yamt-pagecache-base8
1.18 18-Jan-2013 jakllsch

Now that GPT_ENT_TYPE_LINUX_DATA is diffrent from the Windows one, use it.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
1.17 30-Jul-2012 matt

branches: 1.17.2;
Fix a few straggling BE/LE problems.


1.16 25-Jul-2012 matt

Make sure utf-16 strings are written as little endian words.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.15 27-Aug-2011 joerg

branches: 1.15.2; 1.15.4;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.14 06-Jan-2011 jakllsch

UFS is called FFS in the NetBSD case. Display as such and accept as input.


1.13 06-Jan-2011 jakllsch

Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.


Revision tags: matt-mips64-premerge-20101231
1.12 02-Apr-2010 christos

fix printf format.


1.11 02-Apr-2010 christos

PR/43105: Peter Kerwien: Destroying a GPT partition with dd will cause gpt
destroy / create to fail. When reading the GPT label from the end of the disk
ignore errors if the GPT label at the beginning of the disk was not found.


1.10 20-Feb-2010 mlelstv

Initialize device_name before opendisk to avoid
"unable to open device '(null)'" error messages
when the opendisk fails.


Revision tags: matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.9 07-Feb-2009 uebayasi

Let 'gpt add' suggest a collect device name so that opendisk(3) called by
dkctl(8) succeeds.


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
1.8 24-Feb-2008 christos

branches: 1.8.6;
PR/38094: Robert Millan: support "BIOS Boot" partition type in gpt(8)


Revision tags: mjf-devfs-base matt-armv6-base
1.7 28-Dec-2007 riz

branches: 1.7.2; 1.7.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.6 19-Dec-2007 dogcow

Your friendly neighborhood 64-bit architecture here to remind you that
strlen returns size_t, and printf's precision specifier uses int.


1.5 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...


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
1.4 11-Jun-2007 dyoung

branches: 1.4.4; 1.4.6;
Produce more useful error messages.


1.3 16-Feb-2007 riz

Use strtoll() when converting a 64-bit quantity. This makes "gpt add"
work with an offset of more than 2147483647 sectors. While I'm here,
use strtoul() when converting an unsigned quantity.


Revision tags: netbsd-4-base
1.2 15-Oct-2006 christos

branches: 1.2.2;
Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.45 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.44 20-Nov-2022 mlelstv

branches: 1.44.4;
Fix destroying and moving GPT header also for truncated/extended
images.


1.43 16-Jul-2022 mlelstv

Whitespace


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.42 24-May-2020 jmcneill

Add -H flag to ignore existing MBR (Hybrid MBR/GPT mode).


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.41 30-Jun-2019 sevan

Add rcsid


1.40 25-Jun-2019 jnemeth

Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.


1.39 21-Jun-2019 jnemeth

Add a third argument to the "cfn" function that is an argument to
gpt_change_ent(). The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry. It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.38 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.37 19-Mar-2018 mlelstv

branches: 1.37.2;
Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
1.36 06-Sep-2017 christos

branches: 1.36.2;
- 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.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.35 16-Feb-2017 christos

branches: 1.35.4;
allow 0 timestamp


1.34 16-Feb-2017 christos

Add -T timestamp for reproducible builds.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.33 09-Jun-2016 christos

branches: 1.33.2; 1.33.4;
PR/51230: Add the ability to set the active flag in the PMBR.


1.32 29-Dec-2015 christos

- add more informational messages
- handle case where last argument is an option not a device (set -l)


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 resizedisk.


1.29 04-Dec-2015 christos

don't print dkctl message for files
fix typo


1.28 03-Dec-2015 christos

WARNS=6


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 more duplicated code.


1.24 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.23 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.22 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.21 29-Nov-2015 christos

Remove getdisksize support; we either have the ioctls (current/-7) or we
don't (non-netbsd-current/7+tools).


1.20 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.19 03-Nov-2015 jnemeth

Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists.


1.18 29-Dec-2014 christos

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.17 17-Nov-2014 mlelstv

handle constness better


1.16 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.15 30-Sep-2014 christos

remove compat defines.


1.14 29-Sep-2014 christos

more toolification changes


1.13 28-Sep-2014 jnemeth

PR/44218 - David Young -- add "type" subcommand to change a partition type


1.12 23-Sep-2014 jnemeth

- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT


Revision tags: netbsd-7-base tls-maxphys-base
1.11 10-Aug-2014 jnemeth

branches: 1.11.2;
Add restore subcommand.

XXX It does not actually work yet. It is being committed now to make
later pullups easier.


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.10 19-Dec-2013 jnemeth

Add the backup subcommand. It dumps the contents of the partition
tables as a plist, which is readable by the restore subcommand.

XXX restore subcommand forthcoming


1.9 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


1.8 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.7 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.6 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.5 06-Jan-2011 jakllsch

branches: 1.5.6; 1.5.12;
Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.


Revision tags: matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.4 07-Feb-2009 uebayasi

Let 'gpt add' suggest a collect device name so that opendisk(3) called by
dkctl(8) succeeds.


Revision tags: mjf-devfs2-base
1.3 12-Nov-2008 thorpej

Don't use sizeof(struct gpt_hdr). It will pad the structure on x86-64,
which causes some systems to reject the GPT.

kern/38997


Revision tags: netbsd-5-base matt-mips64-base2 netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base mjf-devfs-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
1.2 15-Oct-2006 christos

branches: 1.2.18; 1.2.26;
Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.4 20-Oct-2024 mlelstv

When generating timestamp based GUIDs for reproducable builds
- increment timestamp by 100ns for each partition.
- use the standard time-based UUID format (type 1) and don't
pretend it's a random number (type 4).
- make the -T option actually work for the uuid command.

Random GUIDs:
start size index contents
34 1000 1 GPT part - d93ba067-a788-4ce0-99b8-0ead51f00215
1034 2000 2 GPT part - bebba77a-7fdc-4ca0-a1bf-7450aa871d41

d93ba067-a788-4ce0-99b8-0ead51f00215:
Version 4 Random
Variant 2 RFC 4122
Data D9 3B A0 67 A7 88 4C E0 99 B8 0E AD 51 F0 02 15

bebba77a-7fdc-4ca0-a1bf-7450aa871d41:
Version 4 Random
Variant 2 RFC 4122
Data BE BB A7 7A 7F DC 4C A0 A1 BF 74 50 AA 87 1D 41

Timestamp based GUIDs:
start size index contents
34 1000 1 GPT part - 0a524600-8eba-11ef-8000-000000000000
1034 2000 2 GPT part - 0a524601-8eba-11ef-8000-000000000000

0a524600-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.0Z

0a524601-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.1Z

Node (host MAC address) and clock (sequence number incremented whenever
the time went backwards) are left undefined (all zero) for our purpose.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.3 30-Jun-2019 sevan

branches: 1.3.12;
Add rcsid


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.2 16-Feb-2017 christos

branches: 1.2.12; 1.2.14;
Add -T timestamp for reproducible builds.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.1 01-Dec-2015 christos

branches: 1.1.2; 1.1.4;
Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.26 11-Oct-2025 thorpej

Add a couple of GPT partition type GUIDs one might encounter when
fiddling around with RISC-V systems (Linux XBOOTLDR, SiFive BBL).


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.25 23-Feb-2025 christos

Pass some lint.


1.24 18-Dec-2024 andvar

s/reproducable/reproducible/ in comment.


1.23 20-Oct-2024 mlelstv

When generating timestamp based GUIDs for reproducable builds
- increment timestamp by 100ns for each partition.
- use the standard time-based UUID format (type 1) and don't
pretend it's a random number (type 4).
- make the -T option actually work for the uuid command.

Random GUIDs:
start size index contents
34 1000 1 GPT part - d93ba067-a788-4ce0-99b8-0ead51f00215
1034 2000 2 GPT part - bebba77a-7fdc-4ca0-a1bf-7450aa871d41

d93ba067-a788-4ce0-99b8-0ead51f00215:
Version 4 Random
Variant 2 RFC 4122
Data D9 3B A0 67 A7 88 4C E0 99 B8 0E AD 51 F0 02 15

bebba77a-7fdc-4ca0-a1bf-7450aa871d41:
Version 4 Random
Variant 2 RFC 4122
Data BE BB A7 7A 7F DC 4C A0 A1 BF 74 50 AA 87 1D 41

Timestamp based GUIDs:
start size index contents
34 1000 1 GPT part - 0a524600-8eba-11ef-8000-000000000000
1034 2000 2 GPT part - 0a524601-8eba-11ef-8000-000000000000

0a524600-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.0Z

0a524601-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.1Z

Node (host MAC address) and clock (sequence number incremented whenever
the time went backwards) are left undefined (all zero) for our purpose.


1.22 19-Aug-2024 christos

Add -U option to specify new UUID
Add OpenBSD
from Anon Ymous


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.21 27-Sep-2023 riastradh

branches: 1.21.2;
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal 2023-09-26 15:48:30.000000000 +0000
+++ /tmp/check.sc6ylB/stdout 2023-09-26 23:30:42.388157924 +0000
@@ -3,6 +3,6 @@
1 1 Pri GPT header
2 32 Pri GPT table
34 1024 1 GPT part - EFI System
- 1058 9150 2 GPT part - NetBSD FFSv1/FFSv2
+ 1058 9150 2 GPT part - NetBSD Cryptographic Disk
10208 32 Sec GPT table
10240 1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


1.20 26-Sep-2023 kre

Recognise Windows Recovery partitions.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406
1.19 30-Mar-2020 martin

Now that we use the same UUID for ZFS as FreeBSD, drop the FreeBSD marker
from the description.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE is-mlppp-base netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.18 25-Jun-2019 jnemeth

adjust gpt_uuid_generate() to accept gpt==NULL


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
1.17 20-Dec-2018 martin

Add a query function (for external code) to enumerate the know guids.
Add recently added VMware GUIDs to the internal enum type.
Fix some short names (bogus + duplicate).


Revision tags: pgoyette-compat-1126
1.16 06-Nov-2018 mrg

add support to detect the 3 vmware GPT partition types:

- VMKcore (dump partition)
- VMFS
- VMware reserved

this enables vmkcore partitions for netbsd swap or dump, as well
as naming all of them.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.15 16-Feb-2017 christos

branches: 1.15.10; 1.15.12;
allow 0 timestamp


1.14 16-Feb-2017 christos

Add -T timestamp for reproducible builds.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.13 06-Dec-2015 christos

branches: 1.13.2; 1.13.4;
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.12 03-Dec-2015 christos

WARNS=6


1.11 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.10 06-Dec-2014 mlelstv

branches: 1.10.2;
Add some more common partition types.


1.9 04-Oct-2014 riastradh

Paranoia: choke noisily on EOF from /dev/urandom.


1.8 04-Oct-2014 riastradh

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


1.7 03-Oct-2014 christos

provide a copy of the kernel uuid generator (with portable API calls) for
tools.


1.6 03-Oct-2014 jnemeth

"0" is not guaranteed to be unique


1.5 02-Oct-2014 apb

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.


1.4 01-Oct-2014 apb

It's HAVE_NBTOOL_CONFIG_H, not HAVE_NBTOOLS_CONFIG_H


1.3 01-Oct-2014 jnemeth

actually return the uuid when parsing one that is in numeric format


1.2 30-Sep-2014 jnemeth

correctly show partition type in the new world order


1.1 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.12 11-Oct-2025 thorpej

Add a couple of GPT partition type GUIDs one might encounter when
fiddling around with RISC-V systems (Linux XBOOTLDR, SiFive BBL).


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.11 19-Aug-2024 christos

Add -U option to specify new UUID
Add OpenBSD
from Anon Ymous


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.10 27-Sep-2023 riastradh

branches: 1.10.2;
gpt(8): Make gpt type array and enum match again.

Add cross-referencing comment to reduce the probability of these
getting out of sync again.

Should fix a slew of failing tests since kre's recent change to add
windows-recovery to the array but not to the enum:

sbin/gpt/t_gpt:create_2part
sbin/gpt/t_gpt:migrate_disklabel
sbin/gpt/t_gpt:recover_backup
sbin/gpt/t_gpt:recover_primary
sbin/gpt/t_gpt:remove_2part
sbin/gpt/t_gpt:resize_2part
sbin/gpt/t_gpt:restore_2part

Fail: stdout does not match golden output
--- /usr/tests/sbin/gpt/gpt.2part.show.normal 2023-09-26 15:48:30.000000000 +0000
+++ /tmp/check.sc6ylB/stdout 2023-09-26 23:30:42.388157924 +0000
@@ -3,6 +3,6 @@
1 1 Pri GPT header
2 32 Pri GPT table
34 1024 1 GPT part - EFI System
- 1058 9150 2 GPT part - NetBSD FFSv1/FFSv2
+ 1058 9150 2 GPT part - NetBSD Cryptographic Disk
10208 32 Sec GPT table
10240 1 Sec GPT header

https://releng.netbsd.org/b5reports/i386/commits-2023.09.html#build-2023.09.26.15.47.11


Revision tags: netbsd-10-1-RELEASE netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.9 30-Jun-2019 sevan

Add rcsid


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
1.8 20-Dec-2018 martin

Add a query function (for external code) to enumerate the know guids.
Add recently added VMware GUIDs to the internal enum type.
Fix some short names (bogus + duplicate).


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.7 06-Dec-2015 christos

branches: 1.7.14; 1.7.16;
remove more duplicated code.


1.6 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.5 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.4 04-Sep-2015 mlelstv

A change to the GPT_TYPE list also requires a change to the GPT_TYPE
index constants.


1.3 03-Oct-2014 christos

branches: 1.3.2;
provide a copy of the kernel uuid generator (with portable API calls) for
tools.


1.2 03-Oct-2014 jnemeth

"0" is not guaranteed to be unique


1.1 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.12 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.11 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.10 14-Mar-2019 mlelstv

branches: 1.10.12;
print little-endian header fields correctly.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
1.9 01-May-2018 martin

branches: 1.9.2; 1.9.4;
Make the "gpt header" command return EXIT_FAILURE when no GPT is present.
This helps sysinst to tell a GPT labeled disk from others.
Very lazy version of a change proposed by kre.


Revision tags: pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.8 24-Dec-2015 martin

branches: 1.8.8; 1.8.14;
Fix output in an error case


1.7 03-Dec-2015 christos

WARNS=6


1.6 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.5 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.4 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.3 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.2 16-Nov-2015 jnemeth

correctly print the gpt header revision as a "float"


1.1 03-Nov-2015 jnemeth

Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.31 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.30 21-Jun-2019 jnemeth

branches: 1.30.12;
Add a third argument to the "cfn" function that is an argument to
gpt_change_ent(). The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry. It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.29 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.28 04-Dec-2015 christos

branches: 1.28.14; 1.28.16;
put back usage from kre


1.27 03-Dec-2015 christos

CID 1341564: Arg memory leak


1.26 03-Dec-2015 christos

CID 1341563: fix leak


1.25 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.24 02-Dec-2015 christos

refactor the utf code so that it does not leak memory.


1.23 01-Dec-2015 christos

merge command line parsers and check all memory allocations.


1.22 01-Dec-2015 christos

refactor more duplicated code.


1.21 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.20 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.19 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.18 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.17 30-Sep-2014 christos

remove compat defines.


1.16 29-Sep-2014 christos

minor toolification: need libprop...


1.15 29-Sep-2014 jnemeth

PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.14 28-Nov-2013 jnemeth

branches: 1.14.4;
when calling dehumanize_number() make sure the resulting number is >= 1


1.13 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.12 22-Nov-2013 jnemeth

change the "-b blocknr" parameter to accept a "human number"


1.11 22-Nov-2013 jnemeth

In the manpage:
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/

In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/

This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.10 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.9 13-Apr-2013 jakllsch

Use correct spelling of "secondary" in comments.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.8 27-Aug-2011 joerg

branches: 1.8.2; 1.8.8;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.7 12-Mar-2009 dyoung

Fix spelling: s/parition/partition/.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
1.6 19-Dec-2007 dogcow

branches: 1.6.12;
Your friendly neighborhood 64-bit architecture here to remind you that
strlen returns size_t, and printf's precision specifier uses int.


1.5 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...


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
1.4 16-Feb-2007 riz

branches: 1.4.4; 1.4.6;
Use strtoll() when converting a 64-bit quantity. This makes "gpt add"
work with an offset of more than 2147483647 sectors. While I'm here,
use strtoul() when converting an unsigned quantity.


Revision tags: netbsd-4-base
1.3 15-Oct-2006 christos

branches: 1.3.2;
add casts


1.2 15-Oct-2006 christos

Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.15 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.14 24-May-2020 jmcneill

branches: 1.14.8;
Add -H flag to ignore existing MBR (Hybrid MBR/GPT mode).


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.13 25-Jun-2019 jnemeth

Add an "uuid" command to generate a new UUID for a portion. The
primary intention is for use for after cloning disks to prevent
collisions.


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
1.12 27-Aug-2018 sevan

Add the -T flag to usage()


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.11 19-Mar-2018 mlelstv

branches: 1.11.2; 1.11.4;
Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.10 16-Feb-2017 christos

branches: 1.10.4; 1.10.10;
allow 0 timestamp


1.9 16-Feb-2017 christos

Add -T timestamp for reproducible builds.


1.8 12-Feb-2017 aymeric

Make gpt(8) work when compiled on a glibc-based OS.

This restores the ability to build amd64 install-image's under Linux.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.7 29-Dec-2015 christos

branches: 1.7.2; 1.7.4;
- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.6 03-Dec-2015 christos

WARNS=6


1.5 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.4 01-Dec-2015 christos

automatically enforce readonly for the commands that don't need to write.


1.3 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.2 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.1 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.16 05-Dec-2023 tsutsui

Fix an incorrect comment.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.15 24-May-2020 jmcneill

Exit gracefully when auto-expanding a partition and it is already the
correct size. Add a -q flag to "resize" and "resizedisk" commands to skip
printing warnings in the already resize paths.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
1.14 11-Apr-2018 mrg

if a new map entry doesn't fit, be more verbose about the sizes.


Revision tags: netbsd-8-0-RC1 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.13 03-Dec-2015 christos

branches: 1.13.8; 1.13.14;
CID 1341556: Don't leak map info


1.12 02-Dec-2015 christos

- check errors from map allocation
- make map_resize return -1 instead of 0, and handle errors locally
explaining what's going wrong


1.11 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.10 29-Nov-2015 christos

Add some debugging.


1.9 29-Nov-2015 christos

print the current map type.


1.8 29-Nov-2015 christos

- use snprintf
- fix bogus logic on map_type


1.7 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.6 27-Nov-2013 christos

branches: 1.6.4;
CID 1132762: Add error check for negative, to make zero-divide in module
impossible.


1.5 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


1.4 19-Nov-2013 jnemeth

Add two new options to the "add" subcommand:

-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition

These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.


1.3 26-Oct-2013 jnemeth

cosmetic fix from drochner@


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 netbsd-5-2-RELEASE netbsd-5-2-RC1 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 netbsd-4-0-1-RELEASE wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-fixsa-newbase wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base mjf-devfs-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base netbsd-4-base
1.2 15-Oct-2006 christos

branches: 1.2.42; 1.2.48;
Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.7 30-Jun-2019 sevan

Add rcsid


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.6 03-Dec-2015 christos

branches: 1.6.16;
CID 1341556: Don't leak map info


1.5 02-Dec-2015 christos

- check errors from map allocation
- make map_resize return -1 instead of 0, and handle errors locally
explaining what's going wrong


1.4 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.3 20-Nov-2013 jnemeth

branches: 1.3.4;
Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


1.2 19-Nov-2013 jnemeth

Add two new options to the "add" subcommand:

-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition

These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.37 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.36 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.35 03-Mar-2019 jnemeth

branches: 1.35.12;
add some more FAT file system types


1.34 10-Feb-2019 martin

Make "gpt migrate" work for disks with FAT32 and NTFS partitions


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.33 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.32 09-Jun-2016 christos

branches: 1.32.14; 1.32.16;
Rename 'a' to set the active PMBR flag to 'A'


1.31 09-Jun-2016 christos

PR/51230: Add the ability to set the active flag in the PMBR.


1.30 29-Dec-2015 christos

- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.29 06-Dec-2015 christos

remove more duplicated code.


1.28 05-Dec-2015 christos

Add debugging and more to migration


1.27 03-Dec-2015 christos

WARNS=6


1.26 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.25 01-Dec-2015 christos

refactor more duplicated code.


1.24 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.23 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.22 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.21 03-Oct-2014 christos

provide a copy of the kernel uuid generator (with portable API calls) for
tools.


1.20 03-Oct-2014 jnemeth

"0" is not guaranteed to be unique


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

more toolification


1.15 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.14 04-Dec-2013 jakllsch

branches: 1.14.4;
Use MBR_PTYPE_ defines from <sys/bootblock.h>.


1.13 04-Dec-2013 jakllsch

Mirror my changes of src/sbin/gpt/create.c 1.4 in migrate.c;

Use less bogus CHS addresses in PMBR.
With the ending head set at 0xff one machine I have will never leave
the initial startup screen if such a disk is present. Additionally,
Wikipedia suggests without citiation that 254 is the maximium allowable
value for the head, and this seems to be the case.


1.12 13-Nov-2013 christos

CID 1125874: Fix memory leak


1.11 22-Oct-2013 jnemeth

In a NetBSD disklabel, p_offset is from the beginning of the disk,
not the beginning of the NetBSD partition.


1.10 19-Oct-2013 jnemeth

Convert FreeBSD numeric FS_<type>s to labels by request.


1.9 19-Oct-2013 jnemeth

- convert FreeBSD FS_<type> to numbers where they don't match NetBSD
- add support for migrating NetBSD disklabel'ed disks (only 7 years late)
- use labels for partition types


1.8 19-Oct-2013 jnemeth

Add code for detecting FreeBSD ZFS partitions.

XXX Need to add code for migrating NetBSD disklabel'ed disks.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.7 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.6 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.5 27-Aug-2011 joerg

branches: 1.5.2; 1.5.8;
Use __dead


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
1.4 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...


Revision tags: netbsd-4-0-1-RELEASE matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-4-base
1.3 17-Oct-2006 he

branches: 1.3.2; 1.3.4; 1.3.8; 1.3.10;
Some of our ports want <sys/param.h> in order to have DEV_BSIZE defined,
needed for LABELSECTOR expansion.


1.2 15-Oct-2006 christos

Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.23 17-Dec-2025 nia

gpt(8): Fix "useless use of <sys/param.h>" antipattern.


1.22 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.21 24-Feb-2025 christos

remove getopt call (noted by rillig@)


1.20 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.19 13-Dec-2020 jnemeth

branches: 1.19.8;
PR/55875 - Valentin -- "gpt recover -r" does nothing

Delete do nothing undocumented option, that was there from initial
import. No idea what it was intended to do and there is no longer
an "upstream".


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.18 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
1.17 22-Mar-2017 martin

branches: 1.17.10; 1.17.12;
Add missing endianes swap to make the "recover" command work on big endian
machines.


Revision tags: pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.16 12-Jun-2016 jnemeth

branches: 1.16.2; 1.16.4;
- fix setting of hdr_lba_alt which was broken in revision 1.10 on 2015/12/2
- switch to using gpt_last
- PR/51230 -- recreate the PMBR if it was lost


1.15 04-Dec-2015 christos

Fix resizedisk.


1.14 03-Dec-2015 christos

CID 1341556: Don't leak map info


1.13 03-Dec-2015 christos

WARNS=6


1.12 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.11 02-Dec-2015 christos

don't hard-code the program name


1.10 02-Dec-2015 christos

merge duplicated code and check allocations.


1.9 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.8 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.7 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.6 18-Jun-2015 jnemeth

Instruct user to use resizedisk if media size has changed, as
resizedisk will adjust the media size in the headers, whereas
recover simply copies the existing header over the missing one.

XXX recover and resizedisk should probably be merged (even if just
partially, so that recover can properly handle media size changes).
Also, reading in the GPT should probably be centralised so that
error handling can be centralised, and users aren't given misleading
messages (i.e. they aren't told to run recover when they should be
running resizedisk). However, something that can be quickly pulled
up to netbsd-7 was needed, and there isn't time for a major overhaul
or rewrite.


1.5 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.4 27-Aug-2011 joerg

branches: 1.4.20;
Use __dead


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
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...


Revision tags: netbsd-4-0-1-RELEASE matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-4-base
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


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.24 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.23 21-Jun-2019 jnemeth

branches: 1.23.12;
Add a third argument to the "cfn" function that is an argument to
gpt_change_ent(). The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry. It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.22 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.21 03-Dec-2015 christos

branches: 1.21.14; 1.21.16;
eliminate static globals so that commands can be re-used.


1.20 01-Dec-2015 christos

refactor more duplicated code.


1.19 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.18 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.17 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.16 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.15 30-Sep-2014 christos

remove compat defines.


1.14 29-Sep-2014 christos

minor toolification: need libprop...


1.13 29-Sep-2014 jnemeth

PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.12 28-Nov-2013 jnemeth

branches: 1.12.4;
when calling dehumanize_number() make sure the resulting number is >= 1


1.11 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.10 22-Nov-2013 jnemeth

change the "-b blocknr" parameter to accept a "human number"


1.9 22-Nov-2013 jnemeth

In the manpage:
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/

In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/

This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.8 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.7 13-Apr-2013 jakllsch

Use correct spelling of "secondary" in comments.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.6 27-Aug-2011 joerg

branches: 1.6.2; 1.6.8;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
1.5 07-Feb-2009 uebayasi

Make manual and usage consistent. No functional changes.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
1.4 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...


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
1.3 16-Feb-2007 riz

branches: 1.3.4; 1.3.6;
Use strtoll() when converting a 64-bit quantity. This makes "gpt add"
work with an offset of more than 2147483647 sectors. While I'm here,
use strtoul() when converting an unsigned quantity.


Revision tags: netbsd-4-base
1.2 15-Oct-2006 christos

branches: 1.2.2;
Make this work under NetBSD.


1.1 15-Oct-2006 christos

branches: 1.1.1;
Initial revision


1.27 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.26 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.25 24-May-2020 jmcneill

branches: 1.25.8;
Exit gracefully when auto-expanding a partition and it is already the
correct size. Add a -q flag to "resize" and "resizedisk" commands to skip
printing warnings in the already resize paths.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.24 24-Mar-2019 martin

Add support for specifying the partition to resize via -b startsec
(similar to label and other subcommands). Do not fully add gpt_find
functionality here, as resizing multiple partitions in one go does not
make sense.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.23 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.22 04-Dec-2015 christos

branches: 1.22.14; 1.22.16;
Kill newline


1.21 03-Dec-2015 christos

WARNS=6


1.20 03-Dec-2015 christos

remove extra assignment


1.19 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.18 02-Dec-2015 christos

- check errors from map allocation
- make map_resize return -1 instead of 0, and handle errors locally
explaining what's going wrong


1.17 01-Dec-2015 christos

refactor more duplicated code.


1.16 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.15 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.14 01-Dec-2015 christos

- use gpt_msg to print informational messages (perhaps these should be printed
only with -v)
- don't print any messages with gpt_msg if quiet
- print a message if we didn't reconfigure the wedges


1.13 30-Nov-2015 christos

- automatically sync the wedge information unless -n is specified.
- document the general options in the traditional way.
- split the main program into a separate file.


1.12 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.11 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.10 30-Sep-2014 christos

remove compat defines.


1.9 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.8 10-Dec-2013 jnemeth

branches: 1.8.4; 1.8.6; 1.8.8;
Explicitly state which partition was added/modified.


1.7 08-Dec-2013 jnemeth

For the add and resize subcommands, change the -s option. If there is
no suffix, or the suffix is 's' or 'S', size is in sectors (as before)
otherwise size is in bytes.


1.6 06-Dec-2013 jnemeth

Don't attempt to create/resize an unaligned partition if the attempt
to create/resize an aligned one failed. This simplifies the code
and prevents surprises. If the user wants an unaligned partition
in the case where an aligned one fails, they can simply retry the
command without the "-a" option. This change was requested by
wiz@, and after some thought I agree with it.


1.5 28-Nov-2013 jnemeth

when calling dehumanize_number() make sure the resulting number is >= 1


1.4 27-Nov-2013 christos

CID 1132764: Bogus test


1.3 27-Nov-2013 jnemeth

Remove FreeBSD specific code as per message to tech-userlevel.


1.2 22-Nov-2013 jnemeth

In the manpage:
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/

In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/

This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.


1.1 20-Nov-2013 jnemeth

Add a resize command. This command was inspired by FreeBSD's gpart(8),
but the code was written by myself.


1.23 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.22 23-Feb-2025 christos

Pass some lint.


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.21 06-Feb-2024 christos

branches: 1.21.2;
check the right variable


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.20 22-Nov-2022 mlelstv

Big-Endian fixes.


1.19 20-Nov-2022 mlelstv

Fix destroying and moving GPT header also for truncated/extended
images.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.18 24-May-2020 jmcneill

Exit gracefully when auto-expanding a partition and it is already the
correct size. Add a -q flag to "resize" and "resizedisk" commands to skip
printing warnings in the already resize paths.


Revision tags: netbsd-8-3-RELEASE netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.17 04-Dec-2015 christos

type confusion


1.16 04-Dec-2015 christos

Fix resizedisk.


1.15 03-Dec-2015 christos

CID 1341556: Don't leak map info


1.14 03-Dec-2015 christos

Fix stray paste, noted by kre.


1.13 03-Dec-2015 christos

WARNS=6


1.12 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.11 02-Dec-2015 christos

check allocations


1.10 01-Dec-2015 christos

refactor more duplicated code.


1.9 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.8 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.7 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.6 01-Oct-2014 jnemeth

branches: 1.6.2;
oops, forgot to update end of data area


1.5 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.4 30-Sep-2014 christos

remove compat defines.


1.3 29-Sep-2014 christos

minor toolification: need libprop...


1.2 23-Sep-2014 msaitoh

Fix compile error observed on i386. Use PRIu64.


1.1 23-Sep-2014 jnemeth

- make gpt_gpt() available for use directly by subcommands
- create new resizedisk disk subcommand for relocating backup GPT


1.22 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.21 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.20 07-Jun-2020 thorpej

branches: 1.20.8;
Update for proplib(3) API changes.


1.19 14-May-2020 msaitoh

Remove extra semicolon.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.18 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.17 07-Sep-2017 christos

branches: 1.17.2; 1.17.4;
use __arraycount


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.16 03-Dec-2015 christos

branches: 1.16.8;
WARNS=6


1.15 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.14 02-Dec-2015 christos

- factor out into smaller separate functions
- fix signed/unsigned confusion
- do proper write checks
- fix some memory leaks


1.13 02-Dec-2015 christos

Allow backup and restore to operate on files.


1.12 02-Dec-2015 christos

refactor the utf code so that it does not leak memory.


1.11 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.10 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.9 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.8 16-Jun-2015 christos

fix error messages containing \n


1.7 01-Oct-2014 jnemeth

using random values for hdr->hdr_guid does not work very well


1.6 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.5 30-Sep-2014 christos

remove compat defines.


1.4 29-Sep-2014 christos

minor toolification: need libprop...


1.3 26-Sep-2014 jnemeth

- 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


1.2 20-Sep-2014 jnemeth

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.


Revision tags: tls-maxphys-base netbsd-7-base
1.1 10-Aug-2014 jnemeth

branches: 1.1.2; 1.1.4;
Add restore subcommand.

XXX It does not actually work yet. It is being committed now to make
later pullups easier.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.16 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.15 25-Mar-2019 martin

branches: 1.15.12;
Allow -b startsec to specify the partition to change for the set subcommand
as well.
Add another option, -N, as a quick way to remove all attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.14 19-Mar-2018 mlelstv

branches: 1.14.2;
Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.13 29-Dec-2015 christos

branches: 1.13.8; 1.13.14;
- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.12 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.11 03-Dec-2015 christos

WARNS=6


1.10 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.9 01-Dec-2015 christos

refactor more duplicated code.


1.8 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.7 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.6 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.5 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.4 30-Sep-2014 christos

remove compat defines.


1.3 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.2 10-Dec-2013 jnemeth

branches: 1.2.4; 1.2.6; 1.2.8;
Explicitly state which partition was added/modified.


1.1 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


1.48 17-Dec-2025 nia

gpt(8): Don't assume transclusion of <sys/endian.h> via <sys/types.h>

Prompted by PR pkg/59839


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
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.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
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.


Revision tags: pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
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.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104
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.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
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...


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
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.


Revision tags: agc-symver-base yamt-pagecache-base8
1.8 18-Jan-2013 jakllsch

Now that GPT_ENT_TYPE_LINUX_DATA is diffrent from the Windows one, use it.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.7 27-Aug-2011 joerg

branches: 1.7.2; 1.7.8;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.6 06-Jan-2011 jakllsch

UFS is called FFS in the NetBSD case. Display as such and accept as input.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
1.5 24-Feb-2008 christos

PR/38094: Robert Millan: support "BIOS Boot" partition type in gpt(8)


Revision tags: mjf-devfs-base matt-armv6-base
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...


Revision tags: netbsd-4-0-1-RELEASE matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base netbsd-4-base
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


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.17 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.16 21-Jun-2019 jnemeth

branches: 1.16.12;
Add a third argument to the "cfn" function that is an argument to
gpt_change_ent(). The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry. It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728
1.15 03-Jul-2018 jnemeth

Not all things that write to the disk do something that dk(4) will
be interested in. Let individual commands decide if ioctl(DIOCMWEDGES)
should be done. I was conservative and set the flag on any command
that might create/modify/delete partitions in any way.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.14 19-Mar-2018 mlelstv

branches: 1.14.2;
Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.13 06-Dec-2015 christos

branches: 1.13.8; 1.13.14;
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.12 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.11 02-Dec-2015 christos

use the utility function.


1.10 01-Dec-2015 christos

refactor more duplicated code.


1.9 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.8 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.7 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.6 07-Dec-2014 mlelstv

branches: 1.6.2;
Fix handling of -t option for the type command.
Match any type, when no option is given, just like for the label command.


1.5 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.4 30-Sep-2014 christos

remove compat defines.


1.3 29-Sep-2014 christos

minor toolification: need libprop...


1.2 29-Sep-2014 jnemeth

PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option


1.1 28-Sep-2014 jnemeth

PR/44218 - David Young -- add "type" subcommand to change a partition type


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.16 23-Feb-2025 christos

Pass some lint.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.15 26-Mar-2019 martin

branches: 1.15.12;
Allow -b to specify a partition for "gpt unset" as well.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
1.14 19-Mar-2018 mlelstv

branches: 1.14.2;
Check device parameter to avoid segfaults. Agument synopsis for -l option.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.13 29-Dec-2015 christos

branches: 1.13.8; 1.13.14;
- add more informational messages
- handle case where last argument is an option not a device (set -l)


1.12 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.11 03-Dec-2015 christos

WARNS=6


1.10 03-Dec-2015 christos

eliminate static globals so that commands can be re-used.


1.9 01-Dec-2015 christos

refactor more duplicated code.


1.8 01-Dec-2015 christos

Refactor the command dispatching and help printing logic.


1.7 01-Dec-2015 christos

Firs step of refactoring, remove all globals, factor out some common code,
handle alternate usage but not advertise it.


1.6 29-Nov-2015 christos

merge the create errors in one place and fix them.


1.5 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.4 30-Sep-2014 christos

remove compat defines.


1.3 29-Sep-2014 christos

minor toolification: need libprop...


Revision tags: tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.2 10-Dec-2013 jnemeth

branches: 1.2.4; 1.2.6; 1.2.8;
Explicitly state which partition was added/modified.


1.1 09-Dec-2013 jnemeth

Add two new subcommands, "set" and "unset". These were inspired by
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.4 23-Feb-2025 christos

Pass some lint.


1.3 20-Oct-2024 mlelstv

When generating timestamp based GUIDs for reproducable builds
- increment timestamp by 100ns for each partition.
- use the standard time-based UUID format (type 1) and don't
pretend it's a random number (type 4).
- make the -T option actually work for the uuid command.

Random GUIDs:
start size index contents
34 1000 1 GPT part - d93ba067-a788-4ce0-99b8-0ead51f00215
1034 2000 2 GPT part - bebba77a-7fdc-4ca0-a1bf-7450aa871d41

d93ba067-a788-4ce0-99b8-0ead51f00215:
Version 4 Random
Variant 2 RFC 4122
Data D9 3B A0 67 A7 88 4C E0 99 B8 0E AD 51 F0 02 15

bebba77a-7fdc-4ca0-a1bf-7450aa871d41:
Version 4 Random
Variant 2 RFC 4122
Data BE BB A7 7A 7F DC 4C A0 A1 BF 74 50 AA 87 1D 41

Timestamp based GUIDs:
start size index contents
34 1000 1 GPT part - 0a524600-8eba-11ef-8000-000000000000
1034 2000 2 GPT part - 0a524601-8eba-11ef-8000-000000000000

0a524600-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.0Z

0a524601-8eba-11ef-8000-000000000000:
Version 1 Time and MAC based
Variant 2 RFC 4122
Node 00:00:00:00:00:00
Clock 0
Time 2024-10-20T08:05:16.000000.1Z

Node (host MAC address) and clock (sequence number incremented whenever
the time went backwards) are left undefined (all zero) for our purpose.


1.2 19-Aug-2024 christos

Add -U option to specify new UUID
Add OpenBSD
from Anon Ymous


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
1.1 25-Jun-2019 jnemeth

branches: 1.1.6; 1.1.14;
Add an "uuid" command to generate a new UUID for a portion. The
primary intention is for use for after cloning disks to prevent
collisions.