Home | History | Annotate | only in /src/sbin/disklabel
History log of /src/sbin/disklabel
RevisionDateAuthorComments
 1.75 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.74 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.73 24-Jan-2018  skrll branches: 1.73.4;
Remove port-acorn26

OK core@
 1.72 31-Jan-2016  christos fix broken patch
 1.71 31-Jan-2016  christos PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8)
 1.70 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.69 30-Aug-2011  bouyer branches: 1.69.2; 1.69.8;
Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.68 18-Aug-2011  phx Define USE_MBR for ofppc.
 1.67 12-Feb-2011  dholland Disable COMPAT_386BSD_MBRPART. The code is still here if anyone needs it
for some reason. (But I have no idea why that would be -- if you have one
of these really ancient partitions and you're about to run disklabel, you
can easily run fdisk first and change the partition type to NetBSD.)

As it stands, the code will munch FreeBSD installs under some
circumstances, which is really not acceptable behavior.

The code, along with the kernel support that's been disabled by
default for several years, and some related but less dangerous code in
sysinst, should prboably be removed entirely after -6 is branched.

Discussed on tech-kern and tech-userlevel; closes PR 44496.

This is also almost certainly the cause of PR 42521 and PR 38841.
 1.66 13-Dec-2009  nakayama branches: 1.66.2;
System utilities, boot programs and kernel modules are machine
(port) specific not CPU, so use MACHINE not MACHINE_ARCH.
 1.65 05-Dec-2009  pooka Remove support for NetBSD/playstation2.
 1.64 28-Nov-2009  tsutsui Don't use #ifdef __${MACHINE_ARCH}__ to enable machine dependent features.
Instead, use proper macro defined in Makefile per ${MACHINE_ARCH}.

__${MACHINE_ARCH}__ doesn't represent an architecture of tool's target
but an architecture of binaries being compiled, so required features
are not prolery enabled or unintentionally enabled on certain host
and target combinations during src/tools build.
 1.63 28-Nov-2009  tsutsui Make dreamcast, evbsh3, and mmeye use -DUSE_MBR.
All of these ports use src/sys/arch/sh3/sh3/disksubr.c
which is MBR aware.
 1.62 14-Feb-2009  abs Convert more MACHINE tests to MACHINE_ARCH
 1.61 11-Mar-2008  aymeric branches: 1.61.6; 1.61.8;
The hpcsh kernel does for sure USE_MBR. Make disklabel use it too on hpcsh.
With this, it is possible to bootstrap a MBR partitioned CF card without
partitioning and disklabelling it first on another platform.
 1.60 18-Dec-2006  nonaka branches: 1.60.4; 1.60.10; 1.60.12;
zaurus use MBR partition info.
 1.59 01-Sep-2006  uwe New NetBSD/landisk port uses MBR too.
 1.58 19-Oct-2005  dsl Rototil the way disklabel -r reads and writes labels.
In particular the 'read' part plays 'hunt the disklabel' in order to get a
label into a local buffer - from where it can be displayed/edited.
The 'write' part makes a separate scan of the disk looking for places to
write the label.
The main changes are:
- It can no longer write the first 8k of the mbr to the pbr (or v.v.)
- All labels on the disk (that it can find) get updated during a write
- With -A all the labels are displayed (inc. those deleted by -D)
- Addition of -D which will delete (by one's complimenting dk_magic{2}) and
existing labels before writing labels to the expected locations.
- -v gives some verbose output to stderr, -vv more etc
A better basis for processing incorrect endian labels, or labels from other
architectures.
 1.57 23-Jun-2005  fvdl If HOSTPROG is empty, do not pull in libutil, since we do not need it in that
case, and several host platforms do not have libutil. Fixes the build of
these programs as host tools on platforms without libutil.
 1.56 17-Jun-2005  dsl Rip out the support for writing bootstrap code. installboot(8) contains
support for hp300, hp700 and vax, $MACHINE is never arm32.
Fix usage output to only contain progname() once - bug introduced in rev 1.89
 1.55 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.54 20-Jan-2005  xtraeme WARNS=2 is the default defined in sbin/Makefile.inc. (thanks wiz)
 1.53 20-Jan-2005  xtraeme WARNS=2
 1.52 13-Oct-2004  gavan Initial import of iyonix port.

The Iyonix is a desktop machine from Castle Technology, based on a 600MHz
XScale[tm] 80321 processor.

* Uses the bootloader from NetBSD/acorn32, which is now 32-bit compatible.
* Currently boots multiuser with a serial console.
* Device support is not yet complete.

With help from abs.
 1.51 28-Jun-2004  jkunz Add hp700 MD options for proper boot code handling.
 1.50 18-Jan-2004  lukem * Enable SAVEBOOTAREA on i386 and amd64 (by merging the Makefile
controls with the section for the other MBR-using platforms that
already enable this)
* Don't prompt the user to "erase the previous contents of the disk"
when there's no NetBSD MBR partition; SAVEBOOTAREA is sufficient.

These fixes mean that you can create a disklabel (on an i386/amd64) on a disk
that doesn't have a NetBSD MBR partition without trashing the existing MBR.
The previous behaviour was extremely annoying when working with media such
as FAT-formatted CF cards, and didn't really protect people with such from
accidentally trashing part of sector 1 of such disks, and made it extremely
easy to trash sectors 0..15 of those disks instead.
 1.49 10-Nov-2003  fvdl Bring back disklabel -B for now, since hp300 installboot isn't ready
for prime time yet.
 1.48 08-Nov-2003  dsl Rip out all the '-B bootblock' support, everything should use installboot(8).
(can only affect arm32, hp300 and vax ports, and doesn't affect sysinst).
 1.47 02-Nov-2003  shin playstation2 needs MBR support in disklabel(8).
 1.46 26-Apr-2003  fvdl x86_64 -> amd64
 1.45 11-Dec-2002  fvdl Handle MBRs for x86_64.
 1.44 28-Jul-2002  manu Enable USE_MBR for all arm ports.
 1.43 18-Jun-2002  itojun USE_MBR on macppc too
 1.42 24-Mar-2002  bjh21 Rename arm26 -> acorn26.
 1.41 29-Nov-2001  bjh21 Rather than making FileCore boot block support conditional on __arm32__, make
it conditional on USE_ACORN, and define that if MACHINE is arm26 or acorn32.
This is less than optimal, and maybe we should define it for all ARM systems,
but then disklabel handling across architectures is generally a mess at the
moment.
 1.40 19-Nov-2001  minoura Preserve the boot area on x68k.
 1.39 24-Dec-2000  lukem move showinfo() and showpartition() into separate file, for use by
other programs. slightly change argument signature so that globals
aren't depended upon.
 1.38 02-May-2000  soren branches: 1.38.4;
MBR on cobalt too.
 1.37 02-May-2000  nonaka also use mbr partition table on prep.
 1.36 31-Jan-2000  soda - use MBR partition table also on arc.
- use defined(USE_MBR) instead of defined(__i386__), like hpcmips and arc.
 1.35 09-Jan-2000  shin Add '-DSAVEBOOTAREA' to keep MBR partition information
when NetBSD partition starts at sector 0.
Closes PR:port-hpcmips/9146.
 1.34 11-Oct-1999  shin add hpcmips support (MBR)
 1.33 03-Jun-1999  cgd branches: 1.33.2;
On NetBSD/alpha, go out of the way to read the boot area's contents if -r
is specified, so that the boot blocks aren't clobbered when writing labels.
 1.32 09-Apr-1999  kleink Update a pasto-ed comment.
 1.31 21-Jan-1999  pk branches: 1.31.2;
Enable non-cylinder-aligned partition warning on sparc[64] & sun3.
See also PR#6853.
 1.30 02-Mar-1998  drochner Handle new MBR partition ID on i386. Put all code which decides about
usability of an entry to one place, use same algorithm as kernel (ie,
check signature).
 1.29 18-Oct-1997  mark branches: 1.29.2;
Define NUMBOOT=1 for the arm32 port.
 1.28 10-Oct-1997  christos CFLAGS->CPPFLAGS
 1.27 25-Sep-1997  lukem switch to using opendisk(3) from libutil
 1.26 15-Sep-1997  lukem define WARNS?=1 for all of sbin/*
 1.25 30-Jun-1997  christos Fix warnings.
 1.24 07-Jun-1997  perry i386 now uses "installboot" for installing boot blocks. Comment out
the CFLAGS+= -DNUMBOOT=2 for now.
 1.23 18-Mar-1997  christos Remove -g
 1.22 18-Mar-1997  christos Off by one.
 1.21 14-Mar-1997  perry Nuke obsolete special case .if for amigas.
 1.20 09-Mar-1997  christos Jason says: Use getmaxpartitions(3) to determine the number of partitions
allowed in this architecture.
 1.19 08-Mar-1997  christos Add -i (interactive mode to create/edit labels) inspired by the SunOS/Solaris
format/partition command.
 1.18 17-Oct-1995  cgd don't define NUMBOOT on the alpha, any more. boot block installation
is now done by /usr/mdec/installboot.
 1.17 23-Apr-1995  ragge Changed to use only one bootblock file on VAX.
 1.16 18-Apr-1995  ragge Added vax for 2-file boot blocks.
 1.15 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.14 11-Feb-1995  cgd NUMBOOT == 2 on the alpha, too.
 1.13 22-Dec-1994  cgd kill unnecessary .include.
 1.12 22-Dec-1994  cgd specify man pages the new way.
 1.11 20-Dec-1994  cgd pull in bsd.own.mk by hand, early, so NOMAN= can be defined there.
 1.10 22-Sep-1994  mycroft Finish 4.4-Lite merge, and convert to use err(3)/warn(3) functions.
 1.9 24-Jun-1994  hpeyerl disklabel(8) from 4.4 merged with our old disklabel(8) by John Brezak
(brezak@apollo.hp.com). hp300's can now disklabel by themselves.
 1.8 12-Feb-1994  chopps added -D${MACHINE} for amiga's becuase of differing sizeof (struct disklabel)
 1.7 01-Aug-1993  mycroft Add RCS identifiers.
 1.6 18-Jul-1993  mycroft Use ${COPY}, not -c for install.
 1.5 25-Apr-1993  mycroft Don't build man page if NOMAN set.
 1.4 10-Apr-1993  cgd make user the cat5 dir exists before trying to install man page there.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.29.2.1 23-Nov-1998  cgd pull up rev 1.30 from trunk (jonathan)
 1.31.2.1 21-Jun-1999  perry pullup 1.32->1.33 (cgd)
 1.33.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.38.4.1 26-Feb-2001  he Pull up revision 1.39 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.60.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.60.10.1 24-Mar-2008  keiichi sync with head.
 1.60.4.1 23-Mar-2008  matt sync with HEAD
 1.61.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.61.6.1 08-Mar-2011  riz Pull up following revision(s) (requested by dholland in ticket #1561):
sbin/disklabel/Makefile: revision 1.67
Disable COMPAT_386BSD_MBRPART. The code is still here if anyone needs it
for some reason. (But I have no idea why that would be -- if you have one
of these really ancient partitions and you're about to run disklabel, you
can easily run fdisk first and change the partition type to NetBSD.)
As it stands, the code will munch FreeBSD installs under some
circumstances, which is really not acceptable behavior.
The code, along with the kernel support that's been disabled by
default for several years, and some related but less dangerous code in
sysinst, should prboably be removed entirely after -6 is branched.
Discussed on tech-kern and tech-userlevel; closes PR 44496.
This is also almost certainly the cause of PR 42521 and PR 38841.
 1.66.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.69.8.1 23-Jun-2013  tls resync from head
 1.69.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.73.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 31-Jan-2016  christos PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8)
 1.4 18-Jul-2015  htodd Fix build.
 1.3 17-Jul-2015  tsutsui Fix botch in "make disklabel a MI tool" changes in rev 1.2.

After that chanage, "MAXPARTITIONS" constant is not for the target port.
If host's MAXPARTITIONS is larger than a value of the target label and
target endianness is different from the build host, bswaplabel() could
overwrite data beyond the disklabel and primary boot stored after
LABELSECTOR in images might be corrupted.

This fixes boot failure of sun2 liveimage built by
"build.sh -U -m sun2 release live-image"
on TME.

Should be pulled up to netbsd-7.
 1.2 03-May-2013  matt branches: 1.2.6;
Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.1 05-Jan-2010  tsutsui branches: 1.1.6; 1.1.12;
Add necessary byteswap ops for tools disklabel(8) used with -F option
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.

Closes PR toolchain/42357.
 1.1.12.1 23-Jun-2013  tls resync from head
 1.1.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.1 30-Jul-2015  martin Pull up following revision(s) (requested by tsutsui in ticket #891):
sbin/disklabel/bswap.c: revision 1.3-1.4

Fix botch in "make disklabel a MI tool" changes in rev 1.2.

After that chanage, "MAXPARTITIONS" constant is not for the target port.
If host's MAXPARTITIONS is larger than a value of the target label and
target endianness is different from the build host, bswaplabel() could
overwrite data beyond the disklabel and primary boot stored after
LABELSECTOR in images might be corrupted.

This fixes boot failure of sun2 liveimage built by
"build.sh -U -m sun2 release live-image"
on TME.

Fix build.
 1.3 31-Jan-2016  christos PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8)
 1.2 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.1 05-Jan-2010  tsutsui branches: 1.1.6; 1.1.12;
Add necessary byteswap ops for tools disklabel(8) used with -F option
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.

Closes PR toolchain/42357.
 1.1.12.1 23-Jun-2013  tls resync from head
 1.1.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31 28-Aug-2022  hgutch Change back various occurrences of \*[Le], \*[Ge] (less/greater equal)
and \*(ua (upwards arrow) to literal "<=", ">=" and "^" whenever
appropriate (e.g., in code examples).
 1.30 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.29 15-Oct-2016  snj revert part of revision 1.28. "e.g." is correct. bad igor!
 1.28 11-Sep-2016  sevan Grammar fix suggested by textproc/igor.
Syntax fix highlighted by mandoc -Tlint.
Bump date.
 1.27 25-Feb-2006  christos branches: 1.27.68;
mark vinum as obsolete.
 1.26 21-Sep-2005  tsutsui Sync DK types and FS types with <sys/disklabel.h>.

XXX: More other stuff should be sync'ed?
 1.25 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.24 13-Jul-2003  lukem xref dkctl(8)
 1.23 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.22 12-Dec-2002  scw Use getlabel{sector,offset}() instead of LABEL{SECTOR,OFFSET}.
 1.21 02-Oct-2002  wiz partition, not parition (by Adrian Mrva). file system instead of filesystem.
 1.20 28-Sep-2002  dbj add FS_APPLEUFS
part of PR #17345
 1.19 28-Sep-2002  dbj tweak indentation on FS_JFS2 comment
 1.18 28-Sep-2002  dbj add DTYPE_JFS2 and FS_JFS2 for IBM Journaled File System
this is to match FreeBSD's disklabel.h revision 1.73
FreeBSD change was requested by Hiten Pandya <hiten@uk.FreeBSD.org>
 1.17 28-Sep-2002  dbj fix DTYPE_LD comment
 1.16 28-Sep-2002  dbj add DTYPE_LD to match disklabel.h
 1.15 08-Feb-2002  ross branches: 1.15.2;
Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.14 16-Nov-2001  wiz Use .Pp for new paragraphs.
 1.13 06-Jan-2001  cgd #warn is _not_ the GCC CPP directive that gives a warning, #warning is.
(this code has, apparently, always been wrong, but current GCC is kind
enough to warn about unknown CPP directives.)
 1.12 13-Jul-2000  msaitoh s/ ar / are /
 1.11 05-Apr-2000  enami branches: 1.11.4;
Introduce new filesystem type FS_CCD so that an operator can mark the
ccd component partition. Note that the ccd driver still allows partitions
of any types as components since an on-disk BSD disklabel isn't available
on some port.
 1.10 16-Mar-2000  enami Sync disklabel.5 with disklabel.h and dkio.h more closely.
 1.9 11-Feb-2000  oster Note the "RAID" partition type.
 1.8 13-Aug-1999  bouyer Sync with sys/disklabel.h
 1.7 29-Apr-1998  fair fix bad .Xr references
 1.6 28-Apr-1998  fair Principally, change foo(N) to .Xr foo N
Also, do some other mdoc tagging.
 1.5 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.4 03-Jul-1996  pk Update.
 1.3 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.2 05-Feb-1995  cgd docs follow code.
 1.1 22-Dec-1994  cgd specify man pages the new way.
 1.11.4.2 26-Feb-2001  he Pull up revision 1.13 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.11.4.1 21-Sep-2000  msaitoh pullup revision 1.12 (approved by releng-1.5):

s/ ar / are /
 1.15.2.3 09-Sep-2003  tron Pull up revision 1.18 (requested by tv in ticket #1454):
add DTYPE_JFS2 and FS_JFS2 for IBM Journaled File System
this is to match FreeBSD's disklabel.h revision 1.73
FreeBSD change was requested by Hiten Pandya <hiten@uk.FreeBSD.org>
 1.15.2.2 09-Sep-2003  tron Pull up revision 1.17 (requested by tv in ticket #1454):
fix DTYPE_LD comment
 1.15.2.1 09-Sep-2003  tron Pull up revision 1.16 (requested by tv in ticket #1454):
add DTYPE_LD to match disklabel.h
 1.27.68.1 04-Nov-2016  pgoyette Sync with HEAD
 1.6 22-Dec-1994  mycroft Clean up deleted files.
 1.5 24-Jun-1994  hpeyerl disklabel(8) from 4.4 merged with our old disklabel(8) by John Brezak
(brezak@apollo.hp.com). hp300's can now disklabel by themselves.
 1.4 01-Aug-1993  mycroft Add RCS indentifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.70 02-Jul-2019  wiz Sort and unify a bit. Add more macros.
 1.69 02-Jul-2019  mlelstv Add options to define labelsector and -offset and number of slices.
Make options to chose alternate label position for systems using MBR
more intuitive. -m now selects mode with MBR, -n selects mode without,
independent of the machine defaults.
 1.68 03-Jul-2017  wiz branches: 1.68.6;
Remove workaround for ancient HTML generation code.
 1.67 11-Sep-2016  sevan Remove ignored Pp macro, highlighted by mandoc -Tlint.
 1.66 11-Sep-2016  sevan Document the version disklabel first appeared.
Fix spelling mistakes.
Replace contraction.
Bump date.
 1.65 29-Apr-2015  christos Add missing doc flags (B,M,m)
 1.64 02-Aug-2011  wiz Sort sections. Remove comma in enumeration of two items.
 1.63 25-Jul-2011  christos mention that we don't handle more than 2TB disks/partitions.
 1.62 28-Nov-2009  abs Shuffle the order of examples to put the interactive option (-i) ahead
of $EDITOR and "disklabel -w -r /dev/rsd0c sd2212 foo"
 1.61 27-Jan-2007  perry As pointed out by James Wetterau, we wish to complement, as in the
logical operation, rather than compliment, as in praise, the magic
number of the disk.

There are probably other instances of this in the tree. We should fix
them.
 1.60 26-Nov-2006  jmmv Add a '-l' flag and a 'L' command to interactive mode to list all known
file system types. (Similar to what fdisk does for partition types.)

Closes PR bin/12954.
 1.59 04-Feb-2006  wiz Use more markup, fix xref, serial comma, other misc. fixes.
 1.58 29-Jan-2006  dsl Update/rewrite to match reality and in a muchmore succinct format.
 1.57 19-Jun-2005  wiz Quote Fr so options are sorted properly.
 1.56 17-Jun-2005  dsl Rip out the support for writing bootstrap code. installboot(8) contains
support for hp300, hp700 and vax, $MACHINE is never arm32.
Fix usage output to only contain progname() once - bug introduced in rev 1.89
 1.55 15-Jun-2005  dsl Rip out the references to the installation of more than one bootstrap file.
Only arm32 needs the -B stuff at all, all other ports use installboot(8).
 1.54 28-May-2004  snj Bump date for last. Put the exit EXIT STATUS section in the right place.
New sentence, new line. Correct two typos.
 1.53 28-May-2004  erh Make it possible to distinguish between exit values that indicate errors,
and those that are warnings. Document the exit statuses in the man page.
 1.52 20-Mar-2004  wiz Single-letter options do not need a line each; add more
commas; drop trailing whitespace; use Pa where appropriate.
 1.51 19-Mar-2004  dyoung Add flag -F to disklabel. Flag -F indicates that the target of the
disklabel operation is a file, not a disk. With -t disktab and -T
disktype, the user may tell disklabel the "geometry" for the file.
 1.50 18-Mar-2004  wiz Add Xref to mscdlabel, bump date.
 1.49 10-Nov-2003  fvdl Bring back disklabel -B for now, since hp300 installboot isn't ready
for prime time yet.
 1.48 08-Nov-2003  dsl Rip out all the '-B bootblock' support, everything should use installboot(8).
(can only affect arm32, hp300 and vax ports, and doesn't affect sysinst).
 1.47 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.46 13-Jul-2003  lukem xref dkctl(8)
 1.45 06-May-2003  wiz Bump date for last.
 1.44 02-May-2003  gmcgarry Document -I option. From Richard Rauch <rauch@math.rice.edu>
in PR#11890.
 1.43 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.42 21-Oct-2002  rtr Removed "disklabel -I [-r] [-C] disk" from SYNOPSIS.

The code does not permit usage of the -I flag without either -e or -i.
 1.41 28-Sep-2002  wiz mdoc nits. New sentence, new line. Remove a comment about tahoe.
 1.40 19-Aug-2002  enami Fix an argument to -width option of .Bl macro.
 1.39 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.38 14-Dec-2001  fredette The sun2 also requires partitions in integer cylinders.
 1.37 24-Nov-2001  perry Note in far more places that -B is only supported on some platforms.
 1.36 16-Nov-2001  wiz Simplify markup in one place, and sort sections and SEE ALSO.
 1.35 05-Jun-2001  wiz Drop arguments of .Os.
 1.34 14-Nov-2000  abs xref (disklabel.8, fdisk.8, mbrlabel.8) as appropriate
 1.33 08-Oct-2000  christos allow -I -i to install a new label interactively.
 1.32 12-Aug-2000  jhawk "boostrap" => "bootstrap"
 1.31 13-Jul-2000  hubertf 'disklabel -i' on a disk without a label recommends to use -I. Document
that in the usage.
 1.30 31-May-2000  fvdl branches: 1.30.2;
Add a -I flag which, combined with -e, gives the user the opportunity
to edit and create a new label on a virgin disk.
 1.29 09-Mar-2000  hubertf branches: 1.29.2;
s/comprised/composed/, per PR 9586 by Seebs <seebs@ged.plethora.net>
 1.28 31-Jan-2000  soda mention that hpcmips and arc use `d' as RAW_PART.
 1.27 03-Jun-1999  cgd kill some bogus comments about -r: it _does not_ cause the boot area to
be clobbered. since 4.4-Lite(?) disklabel.c has gone to extra effort
to avoid clobbering the boot area when using -r, but the 4.4-Lite manual
pages were apparently not updated to note that!
 1.26 09-Apr-1999  kleink Update for sparc64.
 1.25 07-Mar-1999  mycroft branches: 1.25.2;
Clean up SYNOPSIS formatting.
 1.24 19-Jan-1999  abs Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
 1.23 27-Apr-1998  fair Clarify the documentation of the "-B" option, inspired by PR#5262.
Contrary to the PR, the "-B" option does work, but not on all platforms.
 1.22 01-Jan-1998  enami Add missing -C flag in SYNOPSIS
 1.21 01-Jan-1998  enami Fix typo; the flag for interactive disklabel creation is not -e but -i.
Also, make the description of -C flag into separate paragraph.
 1.20 18-Oct-1997  fair additional sun3/sparc warning about the "-r" option.
 1.19 14-Oct-1997  fair add a warning about sun3 and sparc systems requiring partitions in integer cylinders or the boot ROMs get upset, per PR#3267. Is that it?
 1.18 11-Oct-1997  enami - Use .Nm "" instead of .Nm disklabel in SYNOPSIS.
- Do a trick to remove whitespace before close paren from generated output.
- Delete space at the end of line.
 1.17 10-Oct-1997  lukem all but the first .Nm in SYNOPSIS need to be spelt out. [bin/4256]
 1.16 14-Sep-1997  lukem - cleanup use of .Nm
- xref installboot(8)
- deprecate register
 1.15 02-Jul-1997  mikel s/except/accept/, from John F. Woods in PR bin/3802
 1.14 29-May-1997  cgd Fix broken uses of Dd. Both the mdoc and mdoc.samples pages agree:
.Dd is supposed to be invoked like:
.Dd month day, year
e.g. ".Dd January 25, 1989", rather than:
.Dd "month day, year"
which is what these pages did.
 1.13 08-Mar-1997  christos Add -i (interactive mode to create/edit labels) inspired by the SunOS/Solaris
format/partition command.
 1.12 02-Oct-1996  christos PR/1551: clarify usage in manual page
PR/2452: add -t option to print label in disktab(5) format.
Misc cleanups...
 1.11 29-Jun-1996  pk Allow display and editing of partition size & offset fields in
<cyl/track/sector> format. This format is always excepted on input
(`-e' and `-R'); to display it use `-C'.
 1.10 16-Jan-1996  hpeyerl PR487. From John Kohl. (more examples and some corrections)
 1.9 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8 22-Sep-1994  mycroft Finish 4.4-Lite merge, and convert to use err(3)/warn(3) functions.
 1.7 24-Jun-1994  hpeyerl disklabel(8) from 4.4 merged with our old disklabel(8) by John Brezak
(brezak@apollo.hp.com). hp300's can now disklabel by themselves.
 1.6 14-Jan-1994  jtc Fix spelling errors
 1.5 05-Aug-1993  jtc Update to -mandoc macros
 1.4 01-Aug-1993  mycroft Add RCS indentifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25.2.1 21-Jun-1999  perry pullup 1.26->1.27 (cgd): Kill bogus comments about -r
 1.29.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.30.2.4 26-Feb-2001  he Pull up revision 1.34 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.30.2.3 18-Oct-2000  tv Pullup 1.30-1.33 [christos]:
typo and new doc for -I usage
 1.30.2.2 12-Aug-2000  jhawk Pullup rev 1.32, approved by thorpej:
"boostrap" => "bootstrap"
 1.30.2.1 13-Jul-2000  hubertf Pull up into 1.5, approved by thorpej:
Documenting where to use disklabel -I

disklabel.8: 1.30 -> 1.31
disklabel.c: 1.85 -> 1.86
 1.68.6.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.136 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.135 12-Nov-2004  hubertf Translate an error message from C to english.

Before: disklabel: warning, partition g: offset % cylinder-size != 0
After: disklabel: warning, partition g: not starting on cylinder boundary
 1.134 13-Jul-2004  enami Warn overlapping partitions (except the one marked as FS_UNUSED).
Address PR#10777.
 1.133 24-Jun-2004  enami A variable referenced isn't `write only'.
Wrap long line and fix some indent while here.
 1.132 22-Jun-2004  abs Fix some interesting disklabel lossage:

If the input to 'disklabel' (non -i) referenced a partition two or more
larger than that permitted by npartitions it would error out with 'bad
partition name' (and the option given to re-edit if -e). If a partition one
larger was used it would be dropped from the disklabel with a warning and the
label written anyway! The (off by one) check for a bad partition name was
against npartitions anyway, rather than MAXPARTITIONS. npartitions was just
read from the disklabel and could have been set to an arbitrary value.

Given 'disklabel -i' sets npartitions automatically, make the normal case
check partition names against MAXPARTITIONS, and if necessary increase
npartitions to the size needed to hold the last partition used.

While here remove two 'write only' uses of a 'part' variable.
 1.131 28-May-2004  erh Make it possible to distinguish between exit values that indicate errors,
and those that are warnings. Document the exit statuses in the man page.
 1.130 19-Mar-2004  dyoung branches: 1.130.2;
Add flag -F to disklabel. Flag -F indicates that the target of the
disklabel operation is a file, not a disk. With -t disktab and -T
disktype, the user may tell disklabel the "geometry" for the file.
 1.129 14-Mar-2004  christos Fix remaining issues:
- use getulong everywhere for proper range checking
- fix error checking in getulong
 1.128 13-Mar-2004  dsl Fix breakage of last commit (disklabel -R just plain didn't work!)
Convert two large nasty #defines into much smaller (still nasty) #defines
that call proper functions.
Fixes PR 24765
 1.127 29-Feb-2004  itojun use strtoul() instead of atoi(). have proper range check for each fields.
 1.126 18-Jan-2004  lukem * Enable SAVEBOOTAREA on i386 and amd64 (by merging the Makefile
controls with the section for the other MBR-using platforms that
already enable this)
* Don't prompt the user to "erase the previous contents of the disk"
when there's no NetBSD MBR partition; SAVEBOOTAREA is sufficient.

These fixes mean that you can create a disklabel (on an i386/amd64) on a disk
that doesn't have a NetBSD MBR partition without trashing the existing MBR.
The previous behaviour was extremely annoying when working with media such
as FAT-formatted CF cards, and didn't really protect people with such from
accidentally trashing part of sector 1 of such disks, and made it extremely
easy to trash sectors 0..15 of those disks instead.
 1.125 18-Jan-2004  dsl Use correct sector number when the netbsd partition is in the extended
partition chain (and not the first extended partition).
 1.124 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.123 11-Dec-2003  dyoung fix spelling, s/extented/extended/
 1.122 15-Nov-2003  bouyer Commit changes proposed on tech-kern Thu, 6 Nov 2003
- factor out disksubr.c between sun3, sparc and sparc64. Keep the sun3
groveling code to find a NetBSD disklabel in the first sector (so that it
can find a label at the old sun3 LABELOFFSET) as a fallback is not
label at LABELOFFSET, or sun label is present.
- Fix the sun3 LABELOFFSET (was 64, but the kernel wrote the NetBSD label at
128)
- Make next68k disksubr.c always write a next-compatible disklabel.
- remove #ifdef __sparc__ hack from disklabel(8), and change it to issue
a DIOCWDINFO after writing the disklabel to the raw partition in the
-r/-I case (so that the kernel can convert the label if needed).
 1.121 10-Nov-2003  fvdl Bring back disklabel -B for now, since hp300 installboot isn't ready
for prime time yet.
 1.120 08-Nov-2003  dsl Rip out all the '-B bootblock' support, everything should use installboot(8).
(can only affect arm32, hp300 and vax ports, and doesn't affect sysinst).
 1.119 08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 1.118 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.117 04-Aug-2003  dsl Read correct sector when following extended partition chain.
Require extended partition chain to be through increasing sector numbers
in order to abort loops.
 1.116 13-Jul-2003  itojun use bounded copy (a few unbounded copy remains - need work)
 1.115 07-Jul-2003  dsl Allow for the netbsd partition being in the extended partition list.
 1.114 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.113 16-Jan-2003  kleink Rename `sigset' locals to avoid symbol shadowing warning.
 1.112 06-Jan-2003  wiz writable, not writeable.
 1.111 12-Dec-2002  scw Use getlabel{sector,offset}() instead of LABEL{SECTOR,OFFSET}.
 1.110 11-Dec-2002  fvdl Handle MBRs for x86_64.
 1.109 05-Dec-2002  jonb While cleaning up other places that invoked $EDITOR, noticed that
this one had all the infrastructure of fork/exec/wait, like the
others, but called system instead of exec creating an extra PID
and associated memory usage during the edit.
 1.108 18-Nov-2002  rtr Fix bug causing segmentation fault when no fs type specified
 1.107 28-Sep-2002  dbj add FS_APPLEUFS
part of PR #17345
 1.106 18-Jun-2002  itojun need disklabel_mbr.h for USE_MBR build
 1.105 27-May-2002  drochner display / read the p_cdsession field in the FS_ISO9660 case
 1.104 14-May-2002  thorpej Alpha boot block stuff has moved to <sys/bootblock.h>
 1.103 09-Apr-2002  mycroft Make this build again after the alpha/disklabel.h and dev/dec/dec_boot.h
changes.
 1.102 14-Feb-2002  kleink When accessing the MBR magic as a 16-bit value, consider its on-disk
layout would be little-endian, too.
 1.101 13-Dec-2001  reinoud Remove `const' attribute from writelabel prototype and function to make it
compile again on Alpha.
 1.100 29-Nov-2001  bjh21 Rather than making FileCore boot block support conditional on __arm32__, make
it conditional on USE_ACORN, and define that if MACHINE is arm26 or acorn32.
This is less than optimal, and maybe we should define it for all ARM systems,
but then disklabel handling across architectures is generally a mess at the
moment.
 1.99 19-Oct-2001  lukem minor WARNS=2 stuff
 1.98 15-Jun-2001  nonaka Fix big-endian vs. MBR parameters.
 1.97 29-Mar-2001  drochner Don't error out if the mbr cannot be read.
This makes "disklabel cd0" working also on platforms with MBR support.
 1.96 19-Feb-2001  cgd convert to use getprogname()
 1.95 08-Jan-2001  fvdl When -I is specified, we mean to initialize the label if it's not there
already. So, don't fail if there appears to be a corrupt label or
no 'fake' label; get the 'default' label (which is generated
from DIOCGDEFLABEL) instead.
 1.94 03-Jan-2001  enami Test read(2) failure by read(..., sizeof(n)) != sizeof(n) instead of
< sizeof(n) to avoid unwanted type promotion.
 1.93 03-Jan-2001  enami Kill whitespace at the end of line.
 1.92 24-Dec-2000  lukem move showinfo() and showpartition() into separate file, for use by
other programs. slightly change argument signature so that globals
aren't depended upon.
 1.91 24-Dec-2000  lukem - convert to KNF ANSI style guide
- reorder arguments of runcmd(), getnum(), defnum() to be consistent
with other functions (pass struct disklabel * first)
 1.90 27-Nov-2000  perseant Change "cpg" to "cpg/sgs" in the printed partition table header, in an
attempt to avoid confusion. (PR #9230)
 1.89 10-Oct-2000  is Format string cleanups by Bill Sommerfeld.
 1.88 08-Oct-2000  christos allow -I -i to install a new label interactively.
 1.87 14-Aug-2000  lukem * use strcasecmp() instead of strcmp() so that filesystem type and disk type
searchs (amongst others) are case insensitive.
* in interactive mode (-i), when editing entries display supported disk types
and filesystem types when given `?' (when ``[?]'' appears in the prompt
this feature is supported for the question).
* support `m' as a suffix equivalent to `M'
* in interactive mode, be a bit more sensible about handling errors and EOF
* implement dumpnames(), which takes a char ** and size, and displays
as per ls -F (sorted, listed vertically) but indented by one tab
* don't assume d_typename and d_packname are NUL terminated
* fix up some comments and some warning messages (bad cut & pastos :)
* deprecate deffstypename() and getfstypename()
* be consistent when using sizeof()
 1.86 13-Jul-2000  hubertf 'disklabel -i' on a disk without a label recommends to use -I. Document
that in the usage.
 1.85 07-Jul-2000  itojun warnx?/errx? audit. don't pass variable/function return value alone.
use with "%s". from openbsd.
 1.84 31-May-2000  fvdl branches: 1.84.2;
Add a -I flag which, combined with -e, gives the user the opportunity
to edit and create a new label on a virgin disk.
 1.83 27-May-2000  jdolecek add system(3) for spawning the editor - this is handy when EDITOR is set to
something like 'editor arg1 arg2 ...'
 1.82 25-May-2000  thorpej branches: 1.82.2;
Provide some information when confirming "Write outside MBR partition".
 1.81 31-Jan-2000  soda - use MBR partition table also on arc.
- use defined(USE_MBR) instead of defined(__i386__), like hpcmips and arc.
 1.80 18-Jan-2000  perseant disklabel now understands the p_sgs partition field (shift to compute
segment size from block size).

newfs_lfs now reads the disklabel to find segment, block, and fragment
sizes. Because reading this info from the wrong fs type could result in
very poor fs layout (e.g. ffs has "16" where the segshift would go,
resulting in 512-*megabyte* segments for 8K blocks), newfs_lfs refuses
to create a filesystem on a partition not labeled "4.4LFS".

Man pages for newfs_lfs updated to reflect this change.
 1.79 20-Dec-1999  fair change "millisecond" to "microsecond" for headswitch and track seek
comments, to resolve PR 8189. This makes the documentation for these
fields consistent. Not that it matters - a grep of syssrc shows that
these fields aren't actually used for anything and should probably be
GC'd.
 1.78 26-Nov-1999  mrg allow changing partition info from inside the interactive handler.
 1.77 12-Oct-1999  shin Fix typo. ('_i386__' -> '__i386__')
Pointed by D'Arcy J.M. Cain, thanks.
 1.76 11-Oct-1999  shin add hpcmips support (MBR)
 1.75 17-Sep-1999  ross branches: 1.75.2;
don't unbalance { } pairs with #ifdefs or ctags(1) gets confused
 1.74 21-Jul-1999  kleink Try $TMPDIR before resorting to _PATH_TMP.
 1.73 04-Jun-1999  is Make BSDLFS a EXT2FS-like filesystem, that is, dont print or parse the cpg
field.
According to disklabel.h, its LFS semantics are "segment shift" (log2(segment
size)), but in the code it is used nowhere, and there are even plans to
allow non-poweroftwo segment sizes, so it won't ever work.
While at this, simplify the disktab-like output routine... here, currently,
BSDFFS, BSDLFS, EX2FS and ADOS do the same, so don't duplicate the code.
 1.72 03-Jun-1999  is Print bsize and fsize in disktab-format output also for LFS and ADOS.
 1.71 03-Jun-1999  is Print/parse block size, fragment size and cpg for FS_BSDLFS and FS_ADOS.
(cpg has different semantics for LFS and ADOS, but is in use.)
XXX The disktab reading/disktab format output writing needs still to be done.
 1.70 03-Jun-1999  cgd On NetBSD/alpha, go out of the way to read the boot area's contents if -r
is specified, so that the boot blocks aren't clobbered when writing labels.
 1.69 03-May-1999  christos Add a 'chain' command in interactive mode that allows you to vary the
size of the partitions, while the starting point gets adjusted automagically.
This chaining works for partitions that are not 'unused'.
 1.68 30-Apr-1999  abs STRICT_ALIGNMENT only applies to the start of partitions, not length.
 1.67 29-Apr-1999  wrstuden Fix disklabel -t to work with disks that don't end on a cylinder. Before it
wasn't adding a "su" entry, so when the disktab was read, the sectors per
unit was initialized to "nc"*"sc" which was wrong.

Fixes PR/7446 reported by Matthias Buelow <mkb@altair.mayn.de>.
 1.66 26-Apr-1999  abs Allow partitions to extend to the end of the disk, even when
STRICT_CYLINDER_ALIGNMENT defined. This allows existing valid disklabels
to work (including those generated by sysinst).
 1.65 09-Apr-1999  bouyer If checklabel() failed, the label has not been written, so exit(1).
 1.64 05-Apr-1999  cgd instead of coding an alpha boot block checksum routine here, use
the macro now provided by disklabel.h
 1.63 27-Jan-1999  thorpej branches: 1.63.2;
Use <sys/disklabel_mbr.h>
 1.62 21-Jan-1999  pk Enable non-cylinder-aligned partition warning on sparc[64] & sun3.
See also PR#6853.
 1.61 19-Jan-1999  abs Add '-f disktab' option to disklabel, via lib/6623 from
Greg A. Woods <woods@most.weird.com>. (Very) slightly tweaked disklabel.8
 1.60 12-Nov-1998  christos Adjust for DKTYPENAME changes.
 1.59 10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.58 04-Aug-1998  drochner -fix some lint warnings
-fix overflow conditions (PR bin/5534, Zdenek Salvet <salvet@ics.muni.cz>)
(+ one more: can VAX SMD drives be >4G?)
-fix output of "*" at odd end cylinder number (not odd size)
-break some lines >80 cols
 1.57 27-Jul-1998  mycroft Shift column headers into the right position.
 1.56 26-Jul-1998  mycroft const poisoning.
 1.55 07-Jun-1998  mark Fix from Chris Demetriou to modify the way in which arm32 filecore
checksums are calculated paying attention to the fact that the way
the checksum works a sectors filled with a single byte value will
always checksum correctly.
 1.54 26-Mar-1998  cgd when reading the MBR, seek to DOSBBSECTOR * DEV_BSIZE rather than just
DOSBBSECTOR. DOSBBSECTOR is 0 so it doesn't really matter, but the former
is what was really intended.
 1.53 26-Mar-1998  cgd in makebootarea() (if NUMBOOT is nonzero), before reading the contents
of the old boot area so that 'disklabel -r -w' won't clobber anything,
be sure to seek to the offset of the boot area (like readlabel() does).
Otherwise, if the machine has code which looks up machine-dependent label
bits, the offset read from will be incorrect, and disklabel will end up
secretly replacing the boot area with other data (which probably doesn't
look like a boot block). The only port this currently affects is
NetBSD/arm32, because it's the only one of the three ports that use
NUMBOOT > 0 that has MD label grovelling code.
 1.52 25-Mar-1998  cgd factor out some more common bits into 'confirm', and make it a bit more
bullet-proof. also, make the arm32 #ifdefs a bit more consistent with
the i386 #ifdefs (without actually changing the behaviour of the code).
 1.51 24-Mar-1998  cgd use warnx when warning about an old BSD partition ID (i386 MBR code),
since err/warn seem to be used consistently throughout the code, rather
than fprintf.
 1.50 24-Mar-1998  cgd KNF arm32-specific label-grovelling code. Also, clean up error messages
(errx instead of err, kill bogus newlines, make error messages look more
"normal").
 1.49 02-Mar-1998  drochner Handle new MBR partition ID on i386. Put all code which decides about
usability of an entry to one place, use same algorithm as kernel (ie,
check signature).
 1.48 01-Jan-1998  enami Fix usage; -i and -C flags are alway effective regardless of NUMBOOT.
 1.47 19-Oct-1997  pk branches: 1.47.2;
On the sparc, do not write to the raw disk at all if `-r' is on.
 1.46 17-Oct-1997  mark Added support for filecore partitions on arm32 platforms.
 1.45 13-Oct-1997  bouyer The number of fs types is FSMAXTYPES not DKMAXTYPES.
Correct read of formatted file (used with -e or -R) so that fstype with
spaces will work. Also enlarge the fstype field by 2 chars so that
"Linux Ext2" will not be truncated.
 1.44 30-Sep-1997  phil Backout prototype of opendisk.
 1.43 30-Sep-1997  phil Add a prototype for opendisk().
 1.42 25-Sep-1997  lukem switch to using opendisk(3) from libutil
 1.41 16-Sep-1997  lukem fix sccsid conflict
 1.40 10-Jul-1997  veego Define boot1 if NUMBOOT > 1.
Noticed in pr#3850, but fixed differently.
 1.39 30-Jun-1997  christos Fix warnings.
 1.38 16-Mar-1997  lukem use mkstemp() instead of mktemp()
 1.37 08-Mar-1997  christos Add -i (interactive mode to create/edit labels) inspired by the SunOS/Solaris
format/partition command.
 1.36 20-Oct-1996  thorpej Add missing '}', from David Carrel <carrel@ipsec.com>, PR #2873.
 1.35 02-Oct-1996  christos PR/1551: clarify usage in manual page
PR/2452: add -t option to print label in disktab(5) format.
Misc cleanups...
 1.34 10-Aug-1996  explorer Fix disklabel to deal with some syntax errors a little better.

Mostly, when someone specifies a partition entry like:

c: 1295850 0
or
g: 1295850 0 4.2BSD

disklabel would dump core. Now it generates a warning like it should
in the first case and complains about too few fields in the second.

Perhaps I should just default to unused in the first case, but this prevents
core dumps. (pr bin/2659)
 1.33 10-Aug-1996  explorer Don't display cylinder comments if the number of cylinders is zero. This
closes pr bin/2683.
 1.32 29-Jun-1996  pk On the sparc on an extra DIOCWDINFO after writing to the raw device.
 1.31 29-Jun-1996  pk Allow display and editing of partition size & offset fields in
<cyl/track/sector> format. This format is always accepted on input
(`-e' and `-R'); to display it use `-C'.
 1.30 14-Mar-1996  ghudson Include the total number of sectors in the text representation of
the label; calculating based on the disk geometry is not always
accurate (notably, for SCSI disks). Also be a bit more careful
about printing out fixed-width types.
 1.29 26-Jun-1995  jtc sys/errno.h -> errno.h
sys/signal.h -> signal.h
 1.28 29-Apr-1995  mycroft Make sure to reset signal mask on errors.
 1.27 22-Mar-1995  cgd make sure that the alpha boot block is checksummed in a way more
acceptable to charles; #ifdef it, and do it explicitly here, rather
than doing a WDINFO ioctl for the -r case.
 1.26 22-Mar-1995  mycroft Don't do a DIOCWDINFO after already writing the label.
 1.25 21-Mar-1995  mycroft Use POSIX signals.
 1.24 19-Mar-1995  cgd re-order the DIOCWLABEL in the rflag case, so it actually works right.
 1.23 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.22 10-Feb-1995  cgd do the DIOCWDINFO in writelabel() even if -r is specified.
On most machines it's redundant, but it gives others the chance to
take special actions, e.g. updating a checksum.
 1.21 30-Jan-1995  mycroft Fix typos, and minor cosmetic changes.
 1.20 12-Jan-1995  mycroft Change the magic question to an absolute, flat lie that should hopefully make
people think twice before toying with it. B-P
 1.19 05-Dec-1994  cgd more cleanups from Jim Jegers, passed over by me.
 1.18 30-Sep-1994  mycroft Clean up this festering pile of rotten code a bit. To wit:
* Add prototypes.
* Remove a strange and apparently pointless bit of code propagated
from 386BSD.
* Collapse NOWRITE and WRITEABLE into one.
* Use the same algorithm as the kernel for finding the label.
* Redo some of the parsing more sanely.
 1.17 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.16 22-Sep-1994  mycroft Finish 4.4-Lite merge, and convert to use err(3)/warn(3) functions.
 1.15 20-Jul-1994  brezak Fix i386 disklabel bug
 1.14 05-Jul-1994  deraadt branches: 1.14.2;
usage message with less surprise
 1.13 24-Jun-1994  hpeyerl disklabel(8) from 4.4 merged with our old disklabel(8) by John Brezak
(brezak@apollo.hp.com). hp300's can now disklabel by themselves.
 1.12 13-Jun-1994  cgd fix include file
 1.11 21-Mar-1994  cgd don't core so easily
 1.10 06-Dec-1993  cgd 386BSD -> NetBSD and/or i386
 1.9 02-Dec-1993  mycroft We said we're going to default to `n', now do it!
 1.8 13-Oct-1993  mycroft Check boundary of *c* partition against the DOS partition table, not the *a*
partition, as we might want the latter to not necessarily be at the beginning
of the NetBSD section.
 1.7 07-Aug-1993  cgd merge in changes from netbsd-0-9-ALPHA2
 1.6 01-Aug-1993  mycroft Add RCS identifiers.
 1.5 18-Apr-1993  mycroft branches: 1.5.2;
Cleanup for GCC 2.
 1.4 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.3 22-Mar-1993  cgd added rcs ids to all files
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 04-Aug-1993  cgd patch from terry@uieosa.csl.uiuc.edu to deal with an uninitialized
pointer bug.
 1.14.2.2 20-Jul-1994  cgd update from trunk; better fix.
 1.14.2.1 20-Jul-1994  cgd don't clobber i386 BIOS labels. from tim@introl.introl.com.
a bit of a hack -- a better fix will go in the trunk in a day or two.
 1.47.2.2 20-Jan-1999  cgd pull up rev 1.48 from trunk (via patch). (drochner)
 1.47.2.1 23-Nov-1998  cgd pull up rev 1.49 from trunk (jonathan)
 1.63.2.6 10-Oct-2000  he Pull up revision 1.89 (via patch, requested by is):
Format string cleanup.
 1.63.2.5 22-Jun-1999  perry pullup 1.70->1.73 (is)
 1.63.2.4 21-Jun-1999  perry pullup 1.69->1.70 (cgd)
 1.63.2.3 30-Apr-1999  perry pullup 1.67->1.68 (David Brownlee)
 1.63.2.2 29-Apr-1999  perry pullup 1.65->1.66 (abs), 1.66->1.67 (wrstuden)
 1.63.2.1 09-Apr-1999  bouyer Pull up 1.64->1.65: If we didn't write the label because checklabel() failed,
exit with a non-zero status.
 1.75.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.82.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.84.2.7 16-Aug-2001  tv Pullup [drochner]:

sbin/disklabel/disklabel.c 1.97

Make disklabel viewing work on platforms that use MBR, for devices
without a valid MBR (such as CD-ROMs).
 1.84.2.6 26-Feb-2001  he Pull up revisions 1.90-1.95 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.84.2.5 18-Oct-2000  tv Pullup 1.84-1.87 [christos]:
cleanup c syntax (sizeof parentheses)
 1.84.2.4 18-Oct-2000  tv Pullup 1.88 (with 1.89) [christos]:
Allow -i with -I.
 1.84.2.3 18-Oct-2000  tv Pullup sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.84.2.2 27-Jul-2000  itojun pullup (approved by releng-1-5)
printf-like format pedant. do not pass string variable alone. use "%s".
from openbsd.

/cvsroot/basesrc/sbin/swapctl/swapctl.c 1.14 -> 1.15
/cvsroot/basesrc/sbin/ping6/ping6.c 1.15 -> 1.16
/cvsroot/basesrc/sbin/disklabel/disklabel.c 1.84 -> 1.85
/cvsroot/basesrc/sbin/ccdconfig/ccdconfig.c 1.30 -> 1.31
 1.84.2.1 13-Jul-2000  hubertf Pull up into 1.5, approved by thorpej:
Documenting where to use disklabel -I

disklabel.8: 1.30 -> 1.31
disklabel.c: 1.85 -> 1.86
 1.130.2.1 11-Sep-2004  he Pull up revisions 1.132-1.133 (requested by abs in ticket #825):
Fix an off-by-one error in calculating how many partitions
are allowed, and also fix which value we use to compare the
maximum number of partitions against.
 1.14 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.13 05-Jan-2010  tsutsui branches: 1.13.6; 1.13.12;
Add necessary byteswap ops for tools disklabel(8) used with -F option
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.

Closes PR toolchain/42357.
 1.12 24-Oct-2009  tsutsui - u_short -> uint16_t
- KNF a bit
 1.11 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.9 24-Dec-2000  lukem - convert to KNF ANSI style guide
- reorder arguments of runcmd(), getnum(), defnum() to be consistent
with other functions (pass struct disklabel * first)
 1.8 14-Sep-1997  lukem branches: 1.8.12;
- cleanup use of .Nm
- xref installboot(8)
- deprecate register
 1.7 30-Jun-1997  christos Fix warnings.
 1.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 22-Sep-1994  mycroft Finish 4.4-Lite merge, and convert to use err(3)/warn(3) functions.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.12.1 26-Feb-2001  he Pull up revision 1.9 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.5 05-Jan-2010  tsutsui branches: 1.5.6; 1.5.12;
Add necessary byteswap ops for tools disklabel(8) used with -F option
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.

Closes PR toolchain/42357.
 1.4 24-Oct-2009  tsutsui - u_short -> uint16_t
- KNF a bit
 1.3 24-Dec-2000  lukem - convert to KNF ANSI style guide
- reorder arguments of runcmd(), getnum(), defnum() to be consistent
with other functions (pass struct disklabel * first)
 1.2 09-Jan-1998  perry branches: 1.2.10;
RCS Id Police.
 1.1 30-Jun-1997  christos Fix warnings.
 1.2.10.1 26-Feb-2001  he Pull up revision 1.3 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.5.12.1 23-Jun-2013  tls resync from head
 1.5.6.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.12 17-Jan-2013  christos move dk_ioctl to a header file for the benefit of x-building.
 1.11 21-Oct-2009  snj branches: 1.11.6; 1.11.12;
Remove 3rd and 4th clauses in christos' license. OK christos.
 1.10 26-Nov-2006  jmmv Add a '-l' flag and a 'L' command to interactive mode to list all known
file system types. (Similar to what fdisk does for partition types.)

Closes PR bin/12954.
 1.9 19-Oct-2005  dsl Rototil the way disklabel -r reads and writes labels.
In particular the 'read' part plays 'hunt the disklabel' in order to get a
label into a local buffer - from where it can be displayed/edited.
The 'write' part makes a separate scan of the disk looking for places to
write the label.
The main changes are:
- It can no longer write the first 8k of the mbr to the pbr (or v.v.)
- All labels on the disk (that it can find) get updated during a write
- With -A all the labels are displayed (inc. those deleted by -D)
- Addition of -D which will delete (by one's complimenting dk_magic{2}) and
existing labels before writing labels to the expected locations.
- -v gives some verbose output to stderr, -vv more etc
A better basis for processing incorrect endian labels, or labels from other
architectures.
 1.8 13-Dec-2001  reinoud Remove `const' attribute from writelabel prototype and function to make it
compile again on Alpha.
 1.7 26-May-2001  christos - KNF printlabel.c
- add a function to print only one partition's info.
- print the partition information if it was modified in interactive mode.
- improve on the chaining code. [still assumes that partition offsets increase
monotonically]. We could check for overlap too.
 1.6 24-Dec-2000  lukem move showinfo() and showpartition() into separate file, for use by
other programs. slightly change argument signature so that globals
aren't depended upon.
 1.5 24-Dec-2000  lukem - convert to KNF ANSI style guide
- reorder arguments of runcmd(), getnum(), defnum() to be consistent
with other functions (pass struct disklabel * first)
 1.4 26-Nov-1999  mrg branches: 1.4.4;
allow changing partition info from inside the interactive handler.
 1.3 03-May-1999  christos branches: 1.3.4;
Add a 'chain' command in interactive mode that allows you to vary the
size of the partitions, while the starting point gets adjusted automagically.
This chaining works for partitions that are not 'unused'.
 1.2 30-Jun-1997  christos Fix warnings.
 1.1 08-Mar-1997  christos Add -i (interactive mode to create/edit labels) inspired by the SunOS/Solaris
format/partition command.
 1.3.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.4.1 26-Feb-2001  he Pull up revisions 1.5-1.6 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.11.12.2 23-Jun-2013  tls resync from head
 1.11.12.1 25-Feb-2013  tls resync with head
 1.11.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.6.1 23-Jan-2013  yamt sync with head
 1.40 03-Nov-2021  nia disklabel(8): convert malloc(x * y) to reallocarr
 1.39 31-Jan-2016  christos PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8)
 1.38 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.37 17-Jan-2013  christos move dk_ioctl to a header file for the benefit of x-building.
 1.36 15-Jan-2013  christos - simplify getinput.
- add adjust command.
 1.35 06-Jan-2011  apb branches: 1.35.6; 1.35.12;
Change printf formats to match the data type of the values being
printed. There's now a lot of PRIu16 and PRIu32, some PRIu8, some
SCNu32, and a few cases where %u and %d were reversed. Multiplication
of 32-bit and 8-bit values is cast to uint64_t and printed with PRIu64.

Inspired by a report from Patrick Welche on current-users.
 1.34 28-May-2010  dholland Change getnum() to use intmax_t instead of int, so it doesn't overflow
between 2^31 and 2^32. Adjust call sites accordingly. PR 43354.
 1.33 28-Nov-2009  abs - Display "Enter '?' for help" when starting interactive mode
- Use %.40g rather than %g when printing sectors and MB for existing
partition size/offset.
Changes [1.93802e+06c, 1953525105s, 953870M]:
to: [1938021c, 1953525105s, 953869.6875M]:
 1.32 21-Oct-2009  snj Remove 3rd and 4th clauses in christos' license. OK christos.
 1.31 16-Mar-2009  lukem fix sign-compare issues
 1.30 26-Nov-2006  jmmv branches: 1.30.26; 1.30.28; 1.30.32;
Add a '-l' flag and a 'L' command to interactive mode to list all known
file system types. (Similar to what fdisk does for partition types.)

Closes PR bin/12954.
 1.29 18-Mar-2006  dsl Avoid indexing beyond the end of a malloced array.
Rework loop to be less confusing.
Coverty 519 made me read this code, but this isn't the 'bug' it found.
 1.28 17-Mar-2006  rumble Gracefully handle out of memory condition.
 1.27 19-Oct-2005  dsl Rototil the way disklabel -r reads and writes labels.
In particular the 'read' part plays 'hunt the disklabel' in order to get a
label into a local buffer - from where it can be displayed/edited.
The 'write' part makes a separate scan of the disk looking for places to
write the label.
The main changes are:
- It can no longer write the first 8k of the mbr to the pbr (or v.v.)
- All labels on the disk (that it can find) get updated during a write
- With -A all the labels are displayed (inc. those deleted by -D)
- Addition of -D which will delete (by one's complimenting dk_magic{2}) and
existing labels before writing labels to the expected locations.
- -v gives some verbose output to stderr, -vv more etc
A better basis for processing incorrect endian labels, or labels from other
architectures.
 1.26 27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.25 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.24 07-Apr-2005  christos Recognize more units and be more helpful when we enter bad units.
 1.23 29-Dec-2003  jdc Add missing ' in prompt text.
Pointed out by Allen Briggs.
 1.22 29-Dec-2003  jdc Add the ability to define a partition as starting after another partition.
If chaining is on, display all changed partitions (not just this one).

OK'ed by Christos.
 1.21 20-Oct-2003  pooka Handle partition offset and size as unsigned entities.
 1.20 29-Jun-2002  grant disallow creation of partitions which start beyond (or extend beyond)
the end of the disk.
 1.19 19-Oct-2001  lukem branches: 1.19.2;
minor WARNS=2 stuff
 1.18 26-May-2001  christos - KNF printlabel.c
- add a function to print only one partition's info.
- print the partition information if it was modified in interactive mode.
- improve on the chaining code. [still assumes that partition offsets increase
monotonically]. We could check for overlap too.
 1.17 24-Dec-2000  lukem move showinfo() and showpartition() into separate file, for use by
other programs. slightly change argument signature so that globals
aren't depended upon.
 1.16 24-Dec-2000  lukem - convert to KNF ANSI style guide
- reorder arguments of runcmd(), getnum(), defnum() to be consistent
with other functions (pass struct disklabel * first)
 1.15 04-Sep-2000  lukem in cmd_name(), put the default prompt into a temporary buffer rather
than overwrite the existing d_packname. noted by enami@.
 1.14 14-Aug-2000  lukem * use strcasecmp() instead of strcmp() so that filesystem type and disk type
searchs (amongst others) are case insensitive.
* in interactive mode (-i), when editing entries display supported disk types
and filesystem types when given `?' (when ``[?]'' appears in the prompt
this feature is supported for the question).
* support `m' as a suffix equivalent to `M'
* in interactive mode, be a bit more sensible about handling errors and EOF
* implement dumpnames(), which takes a char ** and size, and displays
as per ls -F (sorted, listed vertically) but indented by one tab
* don't assume d_typename and d_packname are NUL terminated
* fix up some comments and some warning messages (bad cut & pastos :)
* deprecate deffstypename() and getfstypename()
* be consistent when using sizeof()
 1.13 17-Dec-1999  abs branches: 1.13.4;
Use '$' instead of '-' to select remainder of disk interactively
 1.12 17-Dec-1999  abs When setting size of partitions interactively allow '-' for remainder of disk
 1.11 26-Nov-1999  mrg allow changing partition info from inside the interactive handler.
 1.10 05-Sep-1999  abs branches: 1.10.4;
Accept 'Y' for label disk as well as 'y'
 1.9 03-May-1999  christos Add a 'chain' command in interactive mode that allows you to vary the
size of the partitions, while the starting point gets adjusted automagically.
This chaining works for partitions that are not 'unused'.
 1.8 12-Nov-1998  christos branches: 1.8.2;
Adjust for DKTYPENAME changes.
 1.7 13-Oct-1997  bouyer The number of fs types is FSMAXTYPES not DKMAXTYPES.
Correct read of formatted file (used with -e or -R) so that fstype with
spaces will work. Also enlarge the fstype field by 2 chars so that
"Linux Ext2" will not be truncated.
 1.6 18-Sep-1997  enami Don't pass return value of writelabel() to strerror(), since
the value is not a errno but just 0 or 1.
 1.5 30-Jun-1997  christos Fix warnings.
 1.4 18-Mar-1997  christos Off by one.
 1.3 09-Mar-1997  christos fix reversed test for maxpartitions.
 1.2 09-Mar-1997  christos Jason says: Use getmaxpartitions(3) to determine the number of partitions
allowed in this architecture.
 1.1 08-Mar-1997  christos Add -i (interactive mode to create/edit labels) inspired by the SunOS/Solaris
format/partition command.
 1.8.2.2 17-Dec-1999  he Pull up revisions 1.12-1.13 (requested by abs):
When setting size of partitions interactively, allow '$'
for the remainder of the disk.
 1.8.2.1 10-Sep-1999  he Pull up revision 1.10:
'Label disk?' prompt should check for 'Y' as well as 'y'. (abs)
 1.10.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.13.4.2 26-Feb-2001  he Pull up revisions 1.16-1.17 (requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.13.4.1 18-Oct-2000  tv Pullup 1.13-1.15 [christos]:
supported disk types printout, sizeof parentheses, better error messages.
 1.19.2.1 29-Jun-2002  lukem Pull up revision 1.20 (requested by grant in ticket #402):
disallow creation of partitions which start beyond (or extend beyond)
the end of the disk.
 1.30.32.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.30.28.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.30.26.1 12-Jun-2010  riz Pull up following revision(s) (requested by dholland in ticket #1410):
sbin/disklabel/interact.c: revision 1.34
Change getnum() to use intmax_t instead of int, so it doesn't overflow
between 2^31 and 2^32. Adjust call sites accordingly. PR 43354.
 1.35.12.2 23-Jun-2013  tls resync from head
 1.35.12.1 25-Feb-2013  tls resync with head
 1.35.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.35.6.1 23-Jan-2013  yamt sync with head
 1.59 19-Jan-2025  tsutsui Add an entry of (belated) virt68k. Required to build live-image.

XXX: should be added to https://www.netbsd.org/developers/new-port.html
 1.58 15-May-2024  tsutsui branches: 1.58.2;
Fix an old bug in NATIVELABEL_ONLY case in PR/50729 by me. (sigh)

'disklabel -r -w' writes a disklabel at a wrong sector in
NATIVELABEL_ONLY && !LABELUSESMBR && LABELSECTOR != 0 case
if the target disk doesn't have a valid disklabel, due to
incorrect LABEL_OFFSET value.

Found and investigated on NetBSD/hp300 bootable CD tests.
Maybe this affects ports that use distrib/utils/x_disklabel
but have no MBR support, i.e. only NetBSD/hp300 10.0 and
NetBSD/ews4800mips 9.0 and later.

Should be pulled up to netbsd-10 and netbsd-9.
 1.57 03-Nov-2021  nia branches: 1.57.2;
disklabel(8): convert malloc(x * y) to reallocarr
 1.56 29-May-2021  christos first check, then copy
 1.55 29-Sep-2020  msaitoh branches: 1.55.2;
s/occurence/occurrence/
 1.54 29-Sep-2020  msaitoh s/parition/partition/
 1.53 03-Aug-2019  isaki Fix a trivial wrong comment. x68k's arch is not m68010.
 1.52 03-Jul-2019  mlelstv branches: 1.52.2;
Fix NATIVELABEL_ONLY build.
 1.51 02-Jul-2019  mlelstv Add options to define labelsector and -offset and number of slices.
Make options to chose alternate label position for systems using MBR
more intuitive. -m now selects mode with MBR, -n selects mode without,
independent of the machine defaults.
 1.50 27-Jun-2018  kamil branches: 1.50.2;
Avoid misaligned access in disklabel(8) in find_label()

Introduce a new helper variable tlp and use it for memory access.

Detected with MKSANITIZER/UBSan

A patch by <christos>
 1.49 01-Apr-2018  ryo Add initial support for ARMv8 (AARCH64) (by nisimura@ and ryo@)

- sys/arch/evbarm64 is gone and integrated into sys/arch/evbarm. (by skrll@)
- add support fdt. evbarm/conf/GENERIC64 fdt (bcm2837,sunxi,tegra) based generic 64bit kernel config. (by skrll@, jmcneill@)
 1.48 24-Jan-2018  skrll branches: 1.48.2;
Remove port-acorn26

OK core@
 1.47 09-Mar-2017  chs use warnx() rather than warn() in a case where errno is not relevant.
 1.46 31-Jan-2016  christos branches: 1.46.2; 1.46.4;
PR/50729: Izumi Tsutsui: Add "SMALLPROG"-like options to disklabel(8)
 1.45 27-Apr-2015  christos fix mistake in previous
 1.44 25-Apr-2015  christos make table smaller in size.
 1.43 02-Jan-2015  christos Fix the 3 programs that use DTYPE_ (disklabel disk types) constants from the
kernel. Two of them are inside ifdefs.
 1.42 19-Sep-2014  matt Add OpenRISC 1000 & UCB RISC-V platform support.
 1.41 10-Aug-2014  apb Fix typo in "dreamcast" port name.
 1.40 10-Aug-2014  matt Changes to existing files to enable building AARCH64 userland.
evbarm64-el
This is clang only. While gcc4.8 supports aarch64, no netbsd support has
been written for aarch64 with gcc4.8.
 1.39 15-Jul-2014  joerg Print uint32_t field as such.
 1.38 24-Feb-2014  skrll branches: 1.38.2;
Rename NetBSD/hp700 to NetBSD/hppa.

Unfortunately our VCS isn't very helpful here.
 1.37 22-Aug-2013  matt Add m68000/coldfire.
Add evbcf.
 1.36 11-Aug-2013  riz A number of new earm MACHINE_ARCH have shown up recently; make sure
we can deduce their endianness.
 1.35 15-May-2013  christos %td is for ptrdiff_t not for off_t
 1.34 13-May-2013  christos CVE 1020933: Prevent integer overflow by using wider type
 1.33 13-May-2013  christos CVE 1020935: Prevent overflow
 1.32 05-May-2013  skrll Add an arch_endian entry for x86_64.
 1.31 03-May-2013  matt Make sure to initialize byteorder if native.
 1.30 03-May-2013  matt Fix tpyos.
 1.29 03-May-2013  matt Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.
 1.28 17-Jan-2013  christos move dk_ioctl to a header file for the benefit of x-building.
 1.27 08-Apr-2012  cyber branches: 1.27.2;
PR bin/45744
from Julian Fagir
Removing options that have had implementations removed.

-b: removed in -r1.4
-s: removed in -r1.2
 1.26 30-Aug-2011  bouyer branches: 1.26.2;
Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html
This is used by disk tools such as disklabel(8) to dynamically decide is
the undelyling platform uses a disklabel-in-mbr-partition or not
(instead of using a compile-time list of ports).
getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the
machdep #define LABELUSESMBR.
For evbmips, make LABELUSESMBR 1 if the platform uses pmon
as bootloader, and 0 (the previous value) otherwise.
 1.25 29-Aug-2011  joerg Use __dead
 1.24 06-Jan-2011  apb Change printf formats to match the data type of the values being
printed. There's now a lot of PRIu16 and PRIu32, some PRIu8, some
SCNu32, and a few cases where %u and %d were reversed. Multiplication
of 32-bit and 8-bit values is cast to uint64_t and printed with PRIu64.

Inspired by a report from Patrick Welche on current-users.
 1.23 06-Jan-2011  christos match printf formats and types from Patrick Welche
 1.22 05-Jan-2010  tsutsui Add necessary byteswap ops for tools disklabel(8) used with -F option
(treating a target disk as a regular file and suppressing ioctl(2)s)
on reading/writing disklabel in a target file.
This allows cross build enviroment creating bootable disk images
for targets in different endian.
No functional changes to native (non-tools) disklabel(8) command.

Closes PR toolchain/42357.
 1.21 28-Nov-2009  tsutsui Don't use #ifdef __${MACHINE_ARCH}__ to enable machine dependent features.
Instead, use proper macro defined in Makefile per ${MACHINE_ARCH}.

__${MACHINE_ARCH}__ doesn't represent an architecture of tool's target
but an architecture of binaries being compiled, so required features
are not prolery enabled or unintentionally enabled on certain host
and target combinations during src/tools build.
 1.20 04-May-2009  mhitch fix sign-compare issues in vax-specific code.
 1.19 20-Jul-2008  lukem branches: 1.19.4;
Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.18 28-Apr-2008  martin branches: 1.18.2;
Remove clause 3 and 4 from TNF licenses
 1.17 05-Jun-2007  dyoung branches: 1.17.12; 1.17.14;
Let the operator use the DISKLABELSECTOR and DISKLABELOFFSET
environment variables to override the sector number, and the
bytes-offset in the sector, where disklabel(8) writes a disklabel.

If disklabel(8) was compiled as a host tool, then the defaults
still come from the port's LABELOFFSET and LABELSECTOR #defines.
Otherwise, the defaults still come from the sysctls, kern.labelsector
and kern.labeloffset.

This change helps me create a bootable CompactFlash image with both
a Master Boot Record (MBR) and a BSD disklabel for the RouterBOARD
153. The RB 153 is an evbmips board with a CompactFlash slot. It
searches the MBR on a CompactFlash card for a partition containing
an ELF kernel. When disklabel(8) is built for evbmips, it will
ordinarily overwrite an MBR with the BSD disklabel.
 1.16 12-Apr-2007  matt Remove defunct B from getopt string.
 1.15 08-Feb-2007  drochner include <signal.h> where signal(3) is used
 1.14 17-Jan-2007  hubertf Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>
 1.13 26-Nov-2006  jmmv Add a '-l' flag and a 'L' command to interactive mode to list all known
file system types. (Similar to what fdisk does for partition types.)

Closes PR bin/12954.
 1.12 25-Jun-2006  christos GCC4 fixes from Mike Pumford
 1.11 11-Jun-2006  christos PR/33695: Arnaud Lacombe: Add compatibility syntax for FreeBSD interoperability.
 1.10 07-Jun-2006  christos fix gcc warning.
 1.9 18-Mar-2006  dsl Coverty 521: fclose() temporary file used when editing label.
 1.8 07-Dec-2005  jmc Fix acorn builds
 1.7 20-Oct-2005  dsl Fix alpha build - pointed out by Kurt Schreiner on port-alpha
 1.6 19-Oct-2005  dsl Rototil the way disklabel -r reads and writes labels.
In particular the 'read' part plays 'hunt the disklabel' in order to get a
label into a local buffer - from where it can be displayed/edited.
The 'write' part makes a separate scan of the disk looking for places to
write the label.
The main changes are:
- It can no longer write the first 8k of the mbr to the pbr (or v.v.)
- All labels on the disk (that it can find) get updated during a write
- With -A all the labels are displayed (inc. those deleted by -D)
- Addition of -D which will delete (by one's complimenting dk_magic{2}) and
existing labels before writing labels to the expected locations.
- -v gives some verbose output to stderr, -vv more etc
A better basis for processing incorrect endian labels, or labels from other
architectures.
 1.5 27-Aug-2005  uwe When building as host tool don't include "../../include/util.h".

getlabel{offset,sector} and opendisk functions declared in that file
are not used in this case anyway, and <util.h> pulls in unwatned
includes (e.g. <utmpx.h> doesn't exist on FreeBSD 4.*).

XXX: We can probably undo the #if !HAVE_NBTOOL_CONFIG_H kludge in
<util.h> now.
 1.4 17-Jun-2005  dsl Rip out the support for writing bootstrap code. installboot(8) contains
support for hp300, hp700 and vax, $MACHINE is never arm32.
Fix usage output to only contain progname() once - bug introduced in rev 1.89
 1.3 15-Jun-2005  dsl Remove the never changed 'bootxx' variable
 1.2 15-Jun-2005  dsl Remove all the code that was under 'NUMBOOT > 1' nothing has set that for
a long time.
 1.1 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.17.14.1 18-May-2008  yamt sync with head.
 1.17.12.2 28-Sep-2008  mjf Sync with HEAD.
 1.17.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.19.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.26.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.2.2 23-Jan-2013  yamt sync with head
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.27.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.2.2 23-Jun-2013  tls resync from head
 1.27.2.1 25-Feb-2013  tls resync with head
 1.38.2.1 10-Aug-2014  tls Rebase.
 1.46.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.46.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.48.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.48.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.50.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.52.2.1 17-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #1841):

sbin/disklabel/main.c: revision 1.58

Fix an old bug in NATIVELABEL_ONLY case in PR/50729 by me. (sigh)
'disklabel -r -w' writes a disklabel at a wrong sector in
NATIVELABEL_ONLY && !LABELUSESMBR && LABELSECTOR != 0 case
if the target disk doesn't have a valid disklabel, due to
incorrect LABEL_OFFSET value.

Found and investigated on NetBSD/hp300 bootable CD tests.
Maybe this affects ports that use distrib/utils/x_disklabel
but have no MBR support, i.e. only NetBSD/hp300 10.0 and
NetBSD/ews4800mips 9.0 and later.
 1.55.2.1 31-May-2021  cjep sync with head
 1.57.2.1 17-Jun-2024  martin Pull up following revision(s) (requested by tsutsui in ticket #692):

sbin/disklabel/main.c: revision 1.58

Fix an old bug in NATIVELABEL_ONLY case in PR/50729 by me. (sigh)
'disklabel -r -w' writes a disklabel at a wrong sector in
NATIVELABEL_ONLY && !LABELUSESMBR && LABELSECTOR != 0 case
if the target disk doesn't have a valid disklabel, due to
incorrect LABEL_OFFSET value.

Found and investigated on NetBSD/hp300 bootable CD tests.
Maybe this affects ports that use distrib/utils/x_disklabel
but have no MBR support, i.e. only NetBSD/hp300 10.0 and
NetBSD/ews4800mips 9.0 and later.
 1.58.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.7 21-Jul-1999  kleink Try $TMPDIR before resorting to _PATH_TMP.
 1.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 22-Sep-1994  mycroft Finish 4.4-Lite merge, and convert to use err(3)/warn(3) functions.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16 06-Jan-2011  apb Change printf formats to match the data type of the values being
printed. There's now a lot of PRIu16 and PRIu32, some PRIu8, some
SCNu32, and a few cases where %u and %d were reversed. Multiplication
of 32-bit and 8-bit values is cast to uint64_t and printed with PRIu64.

Inspired by a report from Patrick Welche on current-users.
 1.15 18-Jan-2009  apb Remove local definitions of PRIxxxx macros in favour of the
centralised definitions from tools/compat/compat_defs.h, which
are included via nbtool_config.h.
 1.14 27-Aug-2005  uwe Oops, brain fart. PRIu32 should be "u", not "d".
 1.13 27-Aug-2005  uwe Define PRIu32 in host environments that don't have it defined.
Define it to "d", as we are unlikely to support hosts where int is
smaller than 32 bits anyway :).
 1.12 12-Jun-2005  dyoung Make disklabel(8) into a host-tool, "nbdisklabel." Move disklabel.c
to main.c to avoid a name collision with lib/libc/gen/disklabel.c
when we build nbdisklabel. Still todo: commit host-tool build
infrastructure to src/tools/disklabel/.
 1.11 28-Feb-2004  dsl Print everything unsigned - helps a bit for disks with [2^31..2^32) sectors.
 1.10 29-Dec-2003  jdc If a partition is adjusted so that it falls off the end of the disk, display
a '+' character (aka the '*').

OK'ed by Christos.
 1.9 20-Oct-2003  pooka Partition size and offset inside the disklabel are unsigned. Print
them as unsigned so that we don't print negative values when we're
halfway through.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.7 04-Aug-2003  dsl Make output fit into 80 columns when a partition doesn't end on a cylinder
boundary.
 1.6 01-Jul-2003  simonb Line up the cylinder numbers in the printlabel output a bit better.
 1.5 28-Sep-2002  dbj add FS_APPLEUFS
part of PR #17345
 1.4 27-May-2002  drochner display / read the p_cdsession field in the FS_ISO9660 case
 1.3 19-Oct-2001  lukem minor WARNS=2 stuff
 1.2 26-May-2001  christos - KNF printlabel.c
- add a function to print only one partition's info.
- print the partition information if it was modified in interactive mode.
- improve on the chaining code. [still assumes that partition offsets increase
monotonically]. We could check for overlap too.
 1.1 24-Dec-2000  lukem branches: 1.1.2;
move showinfo() and showpartition() into separate file, for use by
other programs. slightly change argument signature so that globals
aren't depended upon.
 1.1.2.2 26-Feb-2001  he Pull up revision 1.1 (new, requested by lukem):
Several fixes and enhancements:
o with ``-I'', initialize the label if it's not there, it's
corrupt, or there's no ``fake'' label.
o correct partition table header
o move some functions into a separate file for other programs
to use
o fix examples and cross references
o various cleanups
 1.1.2.1 24-Dec-2000  he file printlabel.c was added on branch netbsd-1-5 on 2001-02-26 22:25:44 +0000

RSS XML Feed