Home | History | Annotate | Download | only in disklabel
History log of /src/sbin/disklabel/main.c
RevisionDateAuthorComments
 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

RSS XML Feed