History log of /src/sbin/fdisk/
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.45 03-Jan-2025 rillig

fdisk: remove unreachable options 'T' and 't', fix lint warnings


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.44 03-Jun-2023 lukem

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


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.43 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."


Revision tags: netbsd-8-3-RELEASE netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
1.42 05-May-2012 tsutsui

branches: 1.42.32;
Don't use "#if defined(__i386__) || defined(__x86_64__)" conditionals
in C source file to define option features.
Define proper options in each Makefile per ${MACHINE_ARCH} variable instead.

Previously if a host is x86 and it has /usr/mdec/mbr file in its system,
tools fdisk implicitly installs it as mbr bootcode even for !x86 targets.


Revision tags: yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
1.41 27-Nov-2009 tsutsui

branches: 1.41.6; 1.41.8;
Remove fdisk/mbr for macppc which was blindly pulled from OpenBSD.
It just fakes MBR partition map which contains 1MB FAT16B partition
and ~1GB OpenBSD partition, and we can always create necessary
MBR partitions for OpenFirmware by the fdisk(8) command itself.


1.40 01-Jun-2009 christos

Delete GPT partitions if we overwrite with MBR to avoid confusion with disks
that have both MBR and a secondary left over GPT partition signature. From
Mike M. Volokhov


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
1.39 06-Apr-2009 lukem

remove mispelt WARNS. (it will be set in ../Makefile.inc "soon")


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

branches: 1.38.2; 1.38.16;
Make this compile without -Wno-pointer-sign
(Needs updated bootblock.h)


Revision tags: matt-armv6-prevmlocking matt-mips64-base
1.37 10-Mar-2007 apb

branches: 1.37.4;
WARNS= 4


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
1.36 12-May-2006 mrg

don't do the -Wno-pointer-sign dance for host programs.


1.35 11-May-2006 mrg

sprinkle some -fno-strict-aliasing and -Wno-pointer-sign with GCC4.


1.34 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.33 12-Jun-2005 dyoung

Turn fdisk(8) into a host tool. Still todo: commit the host-tool
build infrastructure to src/tools/fdisk/.


1.32 22-May-2005 lukem

Make fdisk(8) available on all platforms, since MS-DOS partitioning
is the de-facto standard for many removable media types.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
1.31 20-Jan-2005 xtraeme

WARNS=2 is the default defined in sbin/Makefile.inc. (thanks wiz)


1.30 20-Jan-2005 xtraeme

Remove main() prototype; WARNS=2


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


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
1.28 30-Apr-2003 dsl

Don't descend into mbr_bootsel.
i386/and64 mbr code is built in arch i386/stand/mbr


1.27 26-Apr-2003 fvdl

x86_64 -> amd64


Revision tags: fvdl_fs64_base
1.26 23-Nov-2002 fvdl

Compile mbr and mbr_bootsel on x86_64


1.25 26-Jul-2002 manu

Added fdisk on hpcarm


1.24 17-Jun-2002 itojun

fdisk is now useful for macppc, build it


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
1.23 09-May-2002 uch

add hpcsh


1.22 03-Apr-2002 thorpej

Build fdisk(8) on netwinder.


1.21 27-Feb-2002 scw

fdisk(8) is needed on mvmeppc since PPCBUG uses PeeCee-style MBR
partition info when booting from disk.


1.20 15-Oct-2001 uch

playstation2 support


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
1.19 02-May-2000 nonaka

also install on prep.


1.18 19-Mar-2000 soren

Also install on cobalt.


1.17 31-Jan-2000 soda

Build fdisk also on arc


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
1.16 25-Sep-1999 enami

Oops, needs an operator.


1.15 25-Sep-1999 enami

Build fdisk also on hpcmips.


1.14 25-Sep-1999 enami

Don't decend into the subdirectory mbr_bootsel except i386,
since it currently doesn't contain MI thing and not compile
on ofppc box (thanks Wolfgang) and probably on bebox box.


1.13 02-Jul-1999 sakamoto

branches: 1.13.2;
Build fdisk on bebox and ofppc(replaced powerpc).


1.12 02-May-1999 ross

Since fdisk/mbr contains a man page, we need to descend into it regardless
of which ${MACHINE} we are.


1.11 15-Apr-1999 fvdl

Add and build a bootselecting MBR (i386).


Revision tags: netbsd-1-4-base
1.10 15-Oct-1998 ws

branches: 1.10.2;
Separate master bootcode from fdisk.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
1.9 25-Sep-1997 lukem

switch to using opendisk(3) from libutil


1.8 15-Sep-1997 lukem

define WARNS?=1 for all of sbin/*


1.7 14-Sep-1997 lukem

* support ``short'' names of disks (e.g, ``sd0'') instead of requiring
the full name (e.g, ``/dev/rsd0d'') a la disklabel(8) (where the code
was effectively lifted from ;-)
* prefix hexadecimal numbers in output with '0x'


1.6 05-Sep-1997 phil

-- add -b flag for setting fdisk's idea of BIOS geometry from command line
-- cleanup so WARNS=1 works
-- man page updated to reality.


1.5 23-Jun-1997 mrg

move man pages into share/man.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
1.4 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


1.3 22-Dec-1994 cgd

specify man pages the new way.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
1.2 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
1.1 09-Apr-1993 cgd

added a 386bsd fdisk program, by julian elischer. (patch 111)


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.93 03-Jan-2025 rillig

fdisk: remove unreachable options 'T' and 't', fix lint warnings


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

branches: 1.92.8;
Use Nx, fix formatting nit.


1.91 24-May-2020 jmcneill

Add -g flag to preserve GPT headers when updating MBR.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
1.90 15-Dec-2019 wiz

Fix xrefs.


1.89 14-Dec-2019 christos

PR/54756: germain: Avoid confusion caused by overuse of the word "file" both
as a noun and an argument name.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
1.88 09-Apr-2019 tnn

mention that -B is used to set the timeout for mbr_bootsel


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

branches: 1.87.12;
Fix spelling of simultaneous.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
1.86 11-Sep-2016 sevan

branches: 1.86.2;
- Document the HISTORY of fdisk based on the original post to comp.unix.bsd by
Julian Elischer [1] and the Mach 2.5 Installation notes [2].
I was unable to pin point the exact version of Mach the fdisk utility appeared
as I didn't find documentation older than version 2.5 & no source code or repo
history. fdisk utility appears as a separate utility[3] in v2.5. Due to this,
I've avoided stating the exact version fdisk first appeared in Mach.
- Make correction pointed by textproc/igor
- Bump date

[1] https://groups.google.com/forum/#!searchin/comp.unix.bsd/14-Dec-89$20Robert$20Baron$20(rvb)$20at$20Carnegie-Mellon$20University%7Csort:relevance/comp.unix.bsd/Hhi45vAHxDg

[2] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_install.ps
[3] ftp://ftp.mcs.vuw.ac.nz/doc/misc/mach-i386-doc/i386_manpages.ps


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
1.85 04-Apr-2014 wiz

branches: 1.85.8;
-s:
If the optional arguments are not provided, they stay as before or
use the same defaults as the interactive mode, if new.

(feel free to improve)


1.84 04-Apr-2014 wiz

Fix a bug in previous and update detailed -s description.


1.83 03-Apr-2014 wiz

Update SYNOPSIS.
Christos, please check.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
1.82 31-Mar-2014 martin

Bring back the playstation2 port - now that a toolchain for it is
available again.


Revision tags: riastradh-drm2-base3
1.81 06-Oct-2013 apb

Suggest using -b 1023/255/63 for modern disks where the BIOS is
configured to use LBA-Assisted translation.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
1.80 06-Oct-2012 wiz

Revert my previous commit, I misunderstood the intention.
Noted by njoly.


1.79 05-Oct-2012 wiz

Previous slightly more consistently.


1.78 05-Oct-2012 njoly

Fix indented blocks rendering with mandoc. Switch from .in unsupported
macro to .Bd/.Ed ones. While here kill some unneeded .Pp/.br macros.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
1.77 08-Apr-2012 wiz

branches: 1.77.2;
Remove unnecessary Bk/Ek pairs from SYNOPSIS.
No effective change except where I used the opportunity to sort options
and/or option descriptions.


1.76 06-Apr-2012 christos

support sector sizes > 512.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
1.75 04-Jan-2012 wiz

Remove trailing whitespace.


1.74 31-Dec-2011 riz

According to most other OSes and documentation sources, an MBR has
one "extended" partition and the partitions inside that are "logical"
partitions. Make fdisk(8) man page follow suit.

Patch from Julian Fagir in PR#45695.


1.73 01-Dec-2011 wiz

Remove trailing whitespace.


1.72 01-Dec-2011 christos

Add a flag to support writing overlapping partitions and explain why.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
1.71 25-Apr-2011 wiz

branches: 1.71.4;
Use Nx.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
1.70 07-Apr-2010 wiz

Minor punctuation fixes, improve and sort SYNOPSIS, sort flag descriptions.
From Bug Hunting in PR 43130.


1.69 23-Dec-2009 dsl

Add info for -A ptn_alignment[/ptn_0_offset]


1.68 17-Dec-2009 pooka

Use implicit -F for regular files, much like disklabel(8).


Revision tags: matt-premerge-20091211
1.67 05-Dec-2009 pooka

Remove support for NetBSD/playstation2.


Revision tags: playstation2-eol-2009
1.66 29-Nov-2009 tsutsui

Add a bunch of useful typical examples. Also use appropriate markup there.


1.65 28-Nov-2009 tsutsui

Update -u usage to follow changes in fdisk.c rev 1.125:
>> Allow MB, GB and CYL (not just M, G and C) and lower case.
>> Don't output a splurious 'd' before "cyl".
>> Fixes PR/37414.

XXX "NNcy" is also allowed?


1.64 28-Nov-2009 tsutsui

Clarify description of -f and -u options.
(-u means updating partition data, not interactive mode)


1.63 14-Oct-2009 joerg

Do not use .Xo / .Xc without a good reason.


1.62 10-Aug-2009 yamt

an example.


1.61 02-Jul-2009 snj

Small grammar tweak.


1.60 01-Jun-2009 christos

Delete GPT partitions if we overwrite with MBR to avoid confusion with disks
that have both MBR and a secondary left over GPT partition signature. From
Mike M. Volokhov


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

Note the existance of mbr_com0 and mbr_com0_9600.


Revision tags: matt-armv6-base
1.58 23-Dec-2007 apb

Remove note about the first track being reserved for the BIOS (it's
not), and replace it with a note about the first partition traditionally
beginning in the second track of the first cylinder.


1.57 23-Dec-2007 apb

Report the first active partition.


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
1.56 20-May-2007 wiz

branches: 1.56.4; 1.56.6;
Plural fix.


1.55 11-Mar-2007 apb

Bump date for previous.


1.54 10-Mar-2007 apb

Document the new checks for whether a PBR is bootable.
Also add more detail in the introduction, and a few
more references.


Revision tags: netbsd-4-base
1.53 24-Sep-2006 wiz

branches: 1.53.2;
Use more macros. New sentence, new line.


1.52 24-Sep-2006 jmcneill

PR# 28660: how to remove bootmenu text from some partition


Revision tags: abandoned-netbsd-4-base
1.51 07-Apr-2005 dsl

Allow partition sizes to be input in GB


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
1.50 13-Jul-2004 uwe

s/Nm/Nx/, as it's NetBSD that has ports, not fdisk.


1.49 13-Jul-2004 wiz

Bump date for previous; new sentence, new line;
sort list of ports where fdisk is available.


1.48 13-Jul-2004 darcy

Add note top man page explaining that fdisk is not used on all platforms
and list the ones that is is.

Partial fix to PR#25943


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
1.47 22-Mar-2004 lukem

Use .Pp instead of .br as appropriate.
(This needs more work)


1.46 20-Mar-2004 wiz

Nm needs no argument; also, correct wrong Nm usage.


1.45 19-Mar-2004 snj

Bump date for last. Use Sq for single quotes. Drop trailing space.
New sentence, new line. Sort xrefs. Fix a spelling error.


1.44 19-Mar-2004 dyoung

Add flag -F, options -t disktab and -T disktype to fdisk. Flag -F
indicates that the target of the fdisk operation is a file, not a
disk. With -t and -T, the user tells fdisk the geometry for the
file If the default geometry that fdisk will "fake up" for a file
are not satisfactory, the user may tell the geometry to fdisk using
-t disktab -T disktype.


1.43 06-Oct-2003 lukem

be consistent about "MS-DOS"


1.42 03-Jun-2003 joda

add missing . before Fl


1.41 06-May-2003 wiz

MBR, not mbr.


1.40 01-May-2003 dsl

Change a couple of .Em to .Ar


1.39 01-May-2003 wiz

Replace some raw roff with mdoc.


1.38 01-May-2003 wiz

Improve formatting for [/bootmenu], requested by dsl; add some commas.


1.37 01-May-2003 dsl

a mbr -> an mbr


1.36 01-May-2003 wiz

Drop trailing space.


1.35 30-Apr-2003 dsl

Rototilled fdisk that supports:
- editing of the extended partition list
- user friendly default start/size for new partitions
- partition start/size input in sectors, cylinders or MB
- bootsel menu names configured with paritition bounds
- partition update loop asks used which partition to change
(instead of asking about each partition in turn).
- detection (and erroring) of overlapped partitions.
- automatic installation of correct mbr_xxx code (after prompting user)


1.34 25-Feb-2003 wiz

.Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.


1.33 09-Feb-2003 wiz

Drop trailing space (in last).


1.32 09-Feb-2003 perry

Slightly clarify/improve the documentation for the -B (boot selector)
option


Revision tags: fvdl_fs64_base
1.31 01-Oct-2002 wiz

New sentence, new line. By Robert Elz with minimal fixes.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
1.30 26-Mar-2002 christos

PR/16073: Jachym _Freza_ Holecek: Add the ability to list known partition types.
While I am here, KNF a bit.


1.29 05-Mar-2002 wiz

Drop duplicate .Pp.


1.28 08-Feb-2002 ross

Generate <>& symbolically. I'm avoiding .../dist/... directories for now.


1.27 13-Jan-2002 fair

Cross-link fdisk(8), mbr(8), and mbrlabel(8) in the SEE ALSO sections,
as suggested in PR 14288. Also add a little white space to mbr(8) to
make it a little more readable.


1.26 16-Nov-2001 wiz

Whitespace nits


1.25 05-Jun-2001 wiz

Drop arguments of .Os.


1.24 18-Dec-2000 lukem

list the options in a specific options list (as per the `traditional'
man page). i find this much easier to read than option descriptions
scattered amongst paragraphs of text.


1.23 14-Nov-2000 abs

xref (disklabel.8, fdisk.8, mbrlabel.8) as appropriate


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
1.22 07-Jun-2000 augustss

Note that sysid 0 marks a partition as unused.


Revision tags: minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
1.21 11-Oct-1999 hubertf

branches: 1.21.4;
Add note that "fdisk -i" is the same as "fdisk /mbr" on MSDOS.


1.20 21-Sep-1999 simonb

branches: 1.20.2;
Fix tyop and clean up usage of commas a little.


1.19 02-May-1999 fvdl

Remove confusing entry about cylinder boundaries.


1.18 17-Apr-1999 fvdl

Make the bootselector configurable by fdisk. Add a -B flag to this
effect (i386 only of course). Also change one branch in the
bootselector code to an explicit 16 bit one, and check both
the boot menu and partition tables to see if the partition
requested by the user should be booted. This check just in case,
should the bootselector menu and partition table get out of sync
somehow. (mmm, bytesqueezing)


Revision tags: netbsd-1-4-base
1.17 07-Mar-1999 mycroft

branches: 1.17.2;
Clean up SYNOPSIS formatting.


1.16 15-Oct-1998 ws

Separate master bootcode from fdisk.


1.15 28-Sep-1998 ws

Automagically initialize boot code and partition table if not yet valid.
Don't touch the partition table on -i, if previously valid.


1.14 19-Feb-1998 drochner

update for new partition ID


1.13 06-Feb-1998 perry

macroize BSD, NetBSD, FreeBSD and misc cleanup


1.12 26-Nov-1997 ross

Typos, English.


Revision tags: netbsd-1-3-base
1.11 14-Sep-1997 lukem

branches: 1.11.2;
correct use of various mdoc macros to cleanup resultant man page


1.10 05-Sep-1997 phil

-- add -b flag for setting fdisk's idea of BIOS geometry from command line
-- cleanup so WARNS=1 works
-- man page updated to reality.


1.9 11-Aug-1997 phil

Upgrade for non-interactive use. Interactive use is nearly unchanged.
-i no longer implies -u, -i now does not use the entire first track
because some BIOSes refuse to boot from a partition in the first track.
-s renamed to -S, new -s for non-interactive setting of a partition's
id, offset and size. Updated documentation to match.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
1.8 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


1.7 23-Sep-1994 mycroft

Clean up a bit more.


1.6 23-Sep-1994 mycroft

Clean this up a bit.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
1.5 28-Jan-1994 jtc

More spelling errors.


1.4 14-Jan-1994 jtc

Fix spelling errors


1.3 06-Dec-1993 cgd

386bsd -> NetBSD


1.2 02-Aug-1993 mycroft

Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
1.1 09-Apr-1993 cgd

added a 386bsd fdisk program, by julian elischer. (patch 111)


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.163 24-Feb-2025 andvar

s/sightly/slightly/ and s/sligtly/slightly/ in documentation and comment.


1.162 03-Jan-2025 rillig

fdisk: remove unreachable options 'T' and 't', fix lint warnings


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.161 02-Apr-2022 mlelstv

branches: 1.161.4;
Avoid crashes with invalid or tiny sector sizes.


1.160 03-Nov-2021 nia

fdisk(8): Convert realloc(x * y) to reallocarr. Eliminate temp variables.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.159 24-May-2020 wiz

Add -g to usage.


1.158 24-May-2020 jmcneill

Add -g flag to preserve GPT headers when updating MBR.


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

print the name of the disk causing the error.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
1.156 14-Nov-2018 mlelstv

In validate_bootsel, the code assumed that arr[j][i] can be accessed
with something like arr[0][j*ARRAYWIDTH+i]. gcc no longer allows such
hacks and discards the code silently because of undefined behaviour.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
1.155 27-Aug-2018 sevan

Add missing -z flag to usage()


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.154 02-Oct-2017 joerg

branches: 1.154.2; 1.154.4;
Really don't include ioctl code for tools build.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.153 22-Nov-2015 christos

branches: 1.153.8;
explain how to clear an entry (without reading the source)


1.152 16-Jun-2015 christos

a few more \n's in errors


1.151 16-Jun-2015 christos

fix error messages containing \n


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
1.150 04-Apr-2014 christos

remove debugging.


1.149 03-Apr-2014 christos

instead of using ugly -1's make args optional


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15
1.148 01-Apr-2014 christos

default to something reasonable (like the interactive mode does) instead
of 0 when -1 is specified for the start or size.


1.147 30-Mar-2014 christos

Allow -1 values in the -s <sysid>/<start>/<size> indicate use the previous
values. For example:
fdisk -f -i /dev/rsd0d # initialize mbr and create an msdos partition.
fdisk -f -u -0 -a -s 169/-1/-1 /dev/rsd0d # converts the msdos partition
to a netbsd one, and makes it active.


Revision tags: riastradh-drm2-base3
1.146 10-Mar-2014 jakllsch

Always print the MBR drive serial number, even if it's 0.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
1.145 14-Apr-2013 jakllsch

Improve support for logical sector sizes greater than 512.


Revision tags: agc-symver-base
1.144 13-Feb-2013 christos

Don't produce spurious errors when creating labels on files.


1.143 09-Feb-2013 christos

CID/979997: missing va_end()


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
1.142 05-Jun-2012 tsutsui

branches: 1.142.2;
Use ${DESTDIR}/usr/mdec for DEFAULT_BOOTDIR on tools fdisk(8)
rather than unknown build host's /usr/mdec directory.

XXX: no option to leave MBR bootcode empty on x86 targets


Revision tags: yamt-pagecache-base5
1.141 05-May-2012 tsutsui

Don't use "#if defined(__i386__) || defined(__x86_64__)" conditionals
in C source file to define option features.
Define proper options in each Makefile per ${MACHINE_ARCH} variable instead.

Previously if a host is x86 and it has /usr/mdec/mbr file in its system,
tools fdisk implicitly installs it as mbr bootcode even for !x86 targets.


Revision tags: yamt-pagecache-base4
1.140 06-Apr-2012 christos

support sector sizes > 512.


1.139 15-Mar-2012 joerg

Add __printflike attribution to use vprintf and friends with an argument
as format string.


Revision tags: netbsd-6-base
1.138 02-Dec-2011 christos

branches: 1.138.2;
Also ignore out of space conditions for -I so we can create overlapping
partitions on a full disk. Document and add it to the options.


1.137 02-Dec-2011 enami

Add missing -F flag and -I flag in usage. Sort the order to match
manpage.


1.136 02-Dec-2011 christos

put the error check in the conditional where it belongs.


1.135 01-Dec-2011 christos

Add a flag to support writing overlapping partitions and explain why.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
1.134 28-Aug-2011 gson

branches: 1.134.2;
fix the sparc build


1.133 27-Aug-2011 christos

one static is enough, otherwise you risk zapping yourself.


1.132 27-Aug-2011 joerg

staticfy. __dead.


Revision tags: cherry-xenmp-base
1.131 08-May-2011 pgoyette

Fix parsing of -A option so that the [/ptn_0_offset] part is optional, as
described in the man page.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
1.130 23-Dec-2009 dsl

Put #endif in correct place - fixes PR/42500
Update usage() for -A, and rename one of the variables for clarity.


1.129 22-Dec-2009 dsl

Add support for partition being aligned on non-cylinder boundaries.
Info can be specified with -A parameter.
Default is based on how the first partition is defined.
For empty disks larger than 128GB (arbitrary figure) use 1MB alignment.


1.128 22-Dec-2009 dsl

Editing partitions larger than 1TB works better if 'decimal' returns
64 bit integer values!


1.127 20-Dec-2009 dsl

Add a large comment about disk geometries.
Rename (with #defines) the variables use for aligning partitions to
separate them from the bios geometry.
All in advance of allowing other partition alignments (eg 2048 sectors).


1.126 17-Dec-2009 pooka

Use implicit -F for regular files, much like disklabel(8).


Revision tags: matt-premerge-20091211
1.125 04-Nov-2009 dsl

Allow MB, GB and CYL (not just M, G and C) and lower case.
Don't output a splurious 'd' before "cyl".
Fixes PR/37414.
Patch in PR is wrong!


1.124 31-Oct-2009 dsl

Make absence of /usr/mdec/mbr only a warning.
Fixes PR/26510


1.123 05-Aug-2009 dsl

Change arguments to decimal() to be int64_t.
They need to be able to hold disk sector numbers > 2^31 and also -1.
Should fix PR/34807


1.122 02-Jun-2009 christos

make this compile one non mbr machines (move #define to the general section)


1.121 01-Jun-2009 christos

Delete GPT partitions if we overwrite with MBR to avoid confusion with disks
that have both MBR and a secondary left over GPT partition signature. From
Mike M. Volokhov


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
1.120 20-Apr-2009 drochner

also fix a comment wrt use of the csysid/cstart/csize vars


1.119 20-Apr-2009 sborrill

When using -s flag, read start and size as unsigned to allow for larger
disks. (Thanks to drochner@ for catching it).


1.118 06-Apr-2009 lukem

fix sign-compare issues


1.117 18-Jan-2009 apb

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


Revision tags: netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase
1.116 09-Mar-2008 tnn

branches: 1.116.6;
mbr_dsn is unsigned, print it as such.


Revision tags: mjf-devfs-base hpcarm-cleanup-base
1.115 25-Jan-2008 dsl

branches: 1.115.2; 1.115.4;
Add support for mbr code with ascii keycodes


1.114 20-Jan-2008 tsutsui

- add a sanity check to avoid possible division by zero
- adjust sector numbers _after_ "Sanity check the data against all zeroes"

Should close PR bin/37656.


Revision tags: matt-armv6-base
1.113 23-Dec-2007 apb

Track zero is not strictly reserved for the BIOS, that's just a
convention, so don't make it an error in check_overlap(). Sector 0 is
reserved for the MBR, so make that an error in check_overlap().


1.112 23-Dec-2007 apb

Report the first active partition.


1.111 23-Dec-2007 apb

If the partition is unused, then attempting to decode the PBR would
actually decode the MBR from sector 0 of the disk. Don't do it if
v_flag < 3.


Revision tags: cube-autoconf-base
1.110 29-Nov-2007 dsl

branches: 1.110.2;
Make this compile without -Wno-pointer-sign
(Needs updated bootblock.h)


1.109 29-Nov-2007 dsl

Change -F to not use opendisk().
Don't change default to the boot volume until after we've found we aren't
doing -F.
For tool-fdisk enforce -F and use #defines to make code that can no
longer possibly execute compile.


1.108 18-Nov-2007 apb

Remove unwanted ">" from a printed message.


1.107 28-Oct-2007 tsutsui

Don't print Drive serial number if -S (setting shell variables) is specified.


1.106 04-Sep-2007 tls

This program is a host tool, so when we use newfangled C features like
PRIxyz we have to ensure it still builds on hosts with Old compilers.
Noticed while building a cross-toolchain on FreeBSD 4.


Revision tags: matt-mips64-base
1.105 05-Jul-2007 dsl

branches: 1.105.4;
Preserve the mbr 'driver serial number' when copying in the netbsd
mbr code. Should leave windows vista bootable.
Print the dsn from the mbr, not each pbr.


1.104 26-Apr-2007 christos

PR/36223: Milos Negovanovic: Don't ask if we want to install mbr_bootselect
with -f.


1.103 10-Mar-2007 apb

Try to check whether each partition is bootable. If not,
always print an error message. If bootable and -v flag was
specified, print a success message. If -v flag was specified
more than once, also try to decode more information from
the PBR.

Input from dsl and bad.


Revision tags: netbsd-4-base
1.102 25-Nov-2006 dsl

branches: 1.102.2;
Report the last sector number of a partition, instead of that of the first
of the next - with appropriate discarding of the head/sector values
if the partition is cylinder aligned.
Fixes PR 26921


Revision tags: abandoned-netbsd-4-base
1.101 02-Jun-2006 christos

PR/33633: Yoshito Komatsu: /sbin/fdisk does not work
Downgrade error getting heads to a warning.


1.100 21-May-2006 christos

PR/33522: Peter Bex: Sanity checks to avoid zerodivide.


1.99 18-Mar-2006 dsl

Appease Coverty CID 7449. Avoid close(-1) in error path.


1.98 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


1.97 14-Feb-2006 dyoung

So that we can build a full-featured fdisk cross-tool with -DBOOTSEL,
condition the definition of DEFAULT_BOOTxxx variables and SCAN_xxx
on defined(BOOTSEL), instead of defined(__i386__) || defined(__x86_64__).

While I'm here, only build get_diskname in the same conditions as
get_geometry is built, since only the latter calls the former.


1.96 29-Jan-2006 dsl

Byteswap the constant MBR_{BS_}MAGIC throughout, should genetate better code.
Except that non all architectures have that optimisation :-(


1.95 07-Oct-2005 uwe

PRI* macros should not contain percent sign.
While here, conditionalise use of "lld" for PRId64 on HAVE_LONG_LONG.


1.94 07-Oct-2005 dogcow

Fix cross-compilation on FreeBSD 4.x (and other OSes) where PRId64 isn't
defined.


1.93 27-Aug-2005 uwe

When building as host tool don't include "../../include/util.h".

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


1.92 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.91 12-Jun-2005 dyoung

Turn fdisk(8) into a host tool. Still todo: commit the host-tool
build infrastructure to src/tools/fdisk/.


1.90 12-Jun-2005 dyoung

For portability, use standard types: s/uint/unsigned int/,
s/ulong/unsigned long/, s/u_int8_t/uint8_t/.


1.89 07-Apr-2005 dsl

Allow partition sizes to be input in GB


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
1.88 20-Jan-2005 xtraeme

branches: 1.88.2;
Remove main() prototype; WARNS=2


1.87 18-Nov-2004 wiz

Fix typo in error message, reported by Nicolas Joly in PR 28347.


1.86 15-Nov-2004 christos

Use the 1st element's size as the argument to bsearch.


1.85 12-Nov-2004 christos

Use ptype table from <sys/bootblock.h>


1.84 10-Nov-2004 christos

Add 0xBF for Solaris. From Larry Lee <lclee at west.sun.com>


1.83 28-Oct-2004 dsl

Add (unsigned char) to isdigit() calls


1.82 12-Sep-2004 dsl

Fix intuit_translated_geometry() calculation.
From Izumi Tsutsui in PR bin/26917


1.81 30-Jul-2004 dbj

check sysctl error return on both calls.
this prevents sysctl from coredumping if the second call fails while the
first succeeds. This isn't supposed to happen, but there is another bug
in the i386 kernel implementation of sysctl machdep.diskinfo that excites this


1.80 19-May-2004 dyoung

Insert missing space so fdisk prints "primary partition table
invalid, no magic in sector 0", not "primarypartition ...".


1.79 10-May-2004 dsl

Use the disk size from the device driver, not the bios when checking
whether partitions are valid.
Stops problems with broken BIOS, fixes PR bin/25491


1.78 08-May-2004 dsl

Don't output the 'Installed bootfile doesn't support required options'
message when we are updating the mbr code because the user did fdisk -i ...


Revision tags: netbsd-2-0-base
1.77 24-Mar-2004 lukem

branches: 1.77.2;
Only examine mbr_bootsel* #ifdef BOOTSEL.
Noted on current-users@ by Markus Hennecke.


1.76 22-Mar-2004 lukem

Move mbr_bootsel from offset 404 to offset 400 in struct mbr_sector to
leave 4 bytes for the Windows NT Drive Serial Number (DSN) at 440-443
(as mbr_sector.mbr_dsn).

Ensure that all the MBR & PBR code reserves space for mbr_sector.mbr_dsn.

Leave the bootsel magic number at 444-445 as mbr_sector.mbr_bootsel_magic
(instead of mbr_sector.mbr_bootsel.mbrbs_magic), but use 0xb5e1 (MBR_BS_MAGIC)
instead of 0xaa55 (MBR_MAGIC) to indicate that this change has occurred.

Rework MBR_BS_NEWMBR to mean "mbr_bootsel has moved to 400".

Modify fdisk(8) to automatically relocate the mbr_bootsel from 404 to 400
if mbr_bootsel_magic is the old value (0xaa55), and unset MBR_BS_NEWMBR
to flag that new mbr_bootsel code must be used if updating the MBR.


These changes fixes a problem where Windows 2000 or Windows XP would corrupt
the last 3 bytes + NUL of MBR partition 3's bootsel name if the bootsel name
was 5 characters long, replacing bytes 6-9 with the DSN.
Also, by explicitly reserving the space for the DSN we prevent problems in the
future if non bootsel MBR or PBR code had other information at bytes 440-443.


1.75 19-Mar-2004 dyoung

Add flag -F, options -t disktab and -T disktype to fdisk. Flag -F
indicates that the target of the fdisk operation is a file, not a
disk. With -t and -T, the user tells fdisk the geometry for the
file If the default geometry that fdisk will "fake up" for a file
are not satisfactory, the user may tell the geometry to fdisk using
-t disktab -T disktype.


1.74 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.73 21-Nov-2003 lukem

Add "DISK" to -S output.


1.72 11-Oct-2003 lukem

unconditionally #define DEFAULT_BOOTDIR. should fix non-x86 builds


1.71 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.70 19-Sep-2003 itojun

realloc pedant


1.69 29-Aug-2003 dsl

Define and use PRIdaddr for printing disk block numbers.
Should fix bin/22638 for compilation on amd64.


1.68 10-Aug-2003 dsl

Put cylinder number 1023 into the mbr for sectors beyond the CHS limit
(rather than encoding the highest CHS addressable sector).


1.67 14-Jul-2003 dsl

Fix code that detects bios geometry from mbr table.


1.66 07-Jul-2003 dsl

Only look at each pair of CHS values once when trying to guess geometry.


1.65 17-May-2003 itojun

asprintf is easier


1.64 14-May-2003 dsl

delete a diagnostic printf that was accidentally left in


1.63 01-May-2003 bjh21

Remove some unused variabled from get_params_to_use() in the !i386 && !amd64
case.


1.62 30-Apr-2003 dsl

Rototilled fdisk that supports:
- editing of the extended partition list
- user friendly default start/size for new partitions
- partition start/size input in sectors, cylinders or MB
- bootsel menu names configured with paritition bounds
- partition update loop asks used which partition to change
(instead of asking about each partition in turn).
- detection (and erroring) of overlapped partitions.
- automatic installation of correct mbr_xxx code (after prompting user)


1.61 30-Apr-2003 dsl

Move some definitions from fdisk.c to disklabel_mbr.h so they don't have
to be duplicated elsewhere (eg in mbr.S).
Modify fdisk.c so that it builds with the new disklabel.h


1.60 01-Apr-2003 fvdl

Fix range check for the default boot option case.


1.59 10-Jan-2003 jmmv

Print missing newline in two bootselector-related messages. Approved by wiz.


Revision tags: fvdl_fs64_base
1.58 30-Nov-2002 fvdl

Enable bootselector code for x86_64.
XXX the ifdef-ed parts should be split off into a seperate file.


1.57 24-Nov-2002 fvdl

Avoid format warning for off_t printf.


1.56 08-Oct-2002 jdarrow

Make the -l flage more useful, by actually printing the systype number
alongside the sysid string (instead of just the array index of the
struct part_type they are found in).

Now fdisk -l shows the familiar 169 for NetBSD, 165 for FreeBSD or
386BSD or old NetBSD, and other possibly-familiar (131 for Linux native,
015 for Ext. Partition - LBA) values in with their correct numbers.


1.55 27-Sep-2002 dbj

add partition type 0xaf for Apple HFS.


1.54 08-Aug-2002 soren

Clean up printf->err conversions.


1.53 05-Jun-2002 yamt

exit on EOF from stdin.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
1.52 03-Apr-2002 thorpej

branches: 1.52.2;
Build fdisk(8) on netwinder.


1.51 26-Mar-2002 christos

nicer printing.


1.50 26-Mar-2002 christos

PR/16073: Jachym _Freza_ Holecek: Add the ability to list known partition types.
While I am here, KNF a bit.


1.49 04-Mar-2002 dbj

add "Apple UFS" and "Apple Boot" partition ids used by Darwin


1.48 07-Nov-2001 lukem

if sysctl kern.root_device is availalbe, use that the default device
(rather than /dev/rwd0d). display the disk device used when printing
the partition table.


1.47 01-Nov-2001 lukem

opendisk(3) checks the device type for us


1.46 16-Apr-2001 lukem

add fix by Minoura Makoto to correctly support recursive extended partitions.
the offset of an extended sub-partition is the offset of the top-level
extended partition, not the partition before it (this is annoying, and
makes `clean' recursive mbr descent difficult). fixes PRs 11829 and 12677.


1.45 24-Dec-2000 lukem

use MBR_IS_EXTENDED() instead of local test (which was missing a test case)


1.44 19-Dec-2000 lukem

* Recursively print out extended partition entries. An extended partition is
effectively an MBR with it's own partition table which contains another
4 `slots', each of which can be another extended partition...
This involved reworking some of the internal functions.
* Use off_t appropriately (so we can manipulate sectors past 4GB).
* Tweak to compile with WARNS=2


1.43 19-Dec-2000 lukem

convert to ANSI KNF


1.42 06-Jul-2000 thorpej

When fetching the disk's hardware geometry, first attempt the
DIOCGDEFLABEL ioctl, then fall back onto the DIOCGDINFO ioctl
if that fails. This ensures that we will get the actual hardware
geometry info rather than any bogus info that might have been
previously written to the disk's label area.


Revision tags: netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
1.41 14-Jun-2000 wiz

branches: 1.41.2;
Fix QNX partition IDs, confirmed by looking at FreeBSD's fdisk.
Note: 77 == 0x4d


1.40 27-May-2000 fvdl

Truncate the CHS values correctly in case a partition boundary exceeds
their range.


Revision tags: minoura-xpg4dl-base
1.39 31-Jan-2000 soda

branches: 1.39.2;
Build fdisk also on arc


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
1.38 06-Sep-1999 soren

Update usage().
Prevent buffer overflows when configuring boot selector.
Cycle through partitions when entering boot names.
Use '<UNUSED>' consistently.

Reviewed by: fvdl


1.37 04-Jun-1999 thorpej

Make sure the boot selector actually gets updated if you only change
the timeout and/or the default menu choice.


1.36 02-May-1999 fvdl

Make check if we need int13 extensions for the bootselector more correct.


1.35 28-Apr-1999 fvdl

Only use int13 extensions if the sectors can not be read through the
older CHS interface. This works around stupid BIOSs who report that
int13 extensions are present and functional, but fail when you actually
use them. Like Adaptec SCSI BIOSs.

For the bootselector, there was no space to get the CHS info from
the BIOS. Instead, use a flag that can be set by fdisk. fdisk will
set it if one of the partitions on the disk is out of CHS reach
for this disk/BIOS, so that the bootselector will use int13 extensions.
This isn't so bad, because it needs to be configured via fdisk anyway.

Change the mbr manualpage to reflect some shorter error messages.


1.34 17-Apr-1999 fvdl

Make the bootselector configurable by fdisk. Add a -B flag to this
effect (i386 only of course). Also change one branch in the
bootselector code to an explicit 16 bit one, and check both
the boot menu and partition tables to see if the partition
requested by the user should be booted. This check just in case,
should the bootselector menu and partition table get out of sync
somehow. (mmm, bytesqueezing)


Revision tags: netbsd-1-4-base
1.33 09-Feb-1999 perry

branches: 1.33.2;
add BeOS entry, from URA Hiroshi, PR 6974


1.32 27-Jan-1999 thorpej

Use <sys/disklabel_mbr.h>.


1.31 08-Nov-1998 jonathan

Set otherwise-unused global variable `disksectors' to disklabel.d_secperunit.
Change fdisk -S to emit disksectors as DLSIZE (for benefit of sysinst.)


1.30 15-Oct-1998 ws

Separate master bootcode from fdisk.


1.29 02-Oct-1998 ws

Completely zero out a partition table entry,
if type, start and size are given as zero.


1.28 28-Sep-1998 ws

Automagically initialize boot code and partition table if not yet valid.
Don't touch the partition table on -i, if previously valid.


1.27 10-Aug-1998 rvb

Dont report more than 1023 cylinders for DOS/BIOS because
the code below will truncate to a 10 bit field. This
can cause major problems later for DOS.


1.26 25-Feb-1998 drochner

Use the new NetBSD partition ID for first time setup of an MBR.


1.25 19-Feb-1998 drochner

Add new NetBSD partition ID.
Update information about partition types - add missing types, insert
"reserved" for IDs which are marked as "officially reserved" in other
lists.
Sources of information:
-"How it Works -- Partition Tables" by Hale Landis <hlandis@ibm.net>
-Ralph Brown's interrupt list


1.24 07-Feb-1998 ghudson

When estimating the number of cylinders in the BIOS geometry, use the
total number of sectors as reported by disklabel.d_secperunit rather
than multiplying out the disklabel geometry, which is less accurate.


1.23 02-Feb-1998 mikel

Don't print "DOS partition initialized" if -S set; from Nathan
Williams in PR bin/4893.


1.22 22-Dec-1997 enami

Add missing cast. This is a minimum fix to avoid overflow which causes
core dumps with some disk geometry.


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
1.21 30-Sep-1997 phil

branches: 1.21.2;
Backout the prototype of opendisk().


1.20 30-Sep-1997 phil

Prototype opendisk().


1.19 25-Sep-1997 lukem

switch to using opendisk(3) from libutil


1.18 14-Sep-1997 lukem

* support ``short'' names of disks (e.g, ``sd0'') instead of requiring
the full name (e.g, ``/dev/rsd0d'') a la disklabel(8) (where the code
was effectively lifted from ;-)
* prefix hexadecimal numbers in output with '0x'


1.17 11-Sep-1997 phil

Don't print some things if -f flag given.


1.16 05-Sep-1997 phil

-- add -b flag for setting fdisk's idea of BIOS geometry from command line
-- cleanup so WARNS=1 works
-- man page updated to reality.


1.15 11-Aug-1997 phil

Upgrade for non-interactive use. Interactive use is nearly unchanged.
-i no longer implies -u, -i now does not use the entire first track
because some BIOSes refuse to boot from a partition in the first track.
-s renamed to -S, new -s for non-interactive setting of a partition's
id, offset and size. Updated documentation to match.


1.14 29-Jul-1997 phil

Add code for a -s flag where the output is a series of VAL=xyz lines
so /bin/sh can "eval `fdisk -s`" and get variables defined with the
fdisk information.


1.13 24-Jun-1997 perry

Add a whole lot of MBR partition types, derived from a couple of sources
including Linux.
Is there a master list of this somewhere?


1.12 29-Mar-1997 thorpej

Make this work on big-endian systems, such as the PowerPC. From
Wolfgang Solfrank <ws@tools.de>


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
1.11 04-Oct-1995 ghudson

Add code to look at the existing partition entries to deduce the
translated geometry of the disk. This code will only change the
disk geometry if it can find a geometry which is consistent with
all partition entries, so it's very conservative about choosing
a new disk geometry. Under some circumstances, it will choose a
number of cylinders which is a little lower than it needs to be,
but this code is enough so that you can create new partitions
with the correct physical addresses.

The right solution to this problem is to have the boot loader
communicate the BIOS geometry of each disk to the kernel, in a
manner similar to the symbol table, and then provide a kernel
interface to get at that information. I'm unfortunately not
really qualified to make such a change, and I want something
that works better than the status quo.


1.10 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


1.9 13-Jan-1995 mycroft

Recognize Linux file systems correctly.


1.8 05-Dec-1994 cgd

more cleanups from Jim Jegers, passed over by me.


1.7 20-Oct-1994 mycroft

Allow `partitioning' of a regaular file.


1.6 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


1.5 23-Sep-1994 mycroft

Clean up a bit more.


1.4 23-Sep-1994 mycroft

Clean this up a bit.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
1.3 06-Dec-1993 cgd

386bsd -> NetBSD


1.2 02-Aug-1993 mycroft

Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
1.1 09-Apr-1993 cgd

added a 386bsd fdisk program, by julian elischer. (patch 111)