OpenBSD CVS

CVS log for src/sbin/fdisk/fdisk.c


[BACK] Up to [local] / src / sbin / fdisk

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.146 / (download) - annotate - [select for diffs], Sun Jul 17 12:53:19 2022 UTC (22 months, 2 weeks ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, HEAD
Changes since 1.145: +2 -2 lines
Diff to previous 1.145 (colored)

Modernize and cleanse fdisk.8, making it more concise and
aligned with the code. Tweak usage() to stay in step.

Usual cogent feedback, tweaks and ok jmc@

Revision 1.145 / (download) - annotate - [select for diffs], Thu May 12 11:04:27 2022 UTC (2 years ago) by krw
Branch: MAIN
Changes since 1.144: +3 -1 lines
Diff to previous 1.144 (colored)

Prevent '-u' when operating on GPT formatted disks, as the
equivalent 'update' editing command already is.

Avoids the destruction of the GPT when the preventative MBR
is overwritten with the default MBR.

ok deraadt@

Revision 1.144 / (download) - annotate - [select for diffs], Sun Apr 24 12:13:37 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.143: +3 -3 lines
Diff to previous 1.143 (colored)

Use warnx() if errno is not relevant. close() after errno of
interest is checked, not before.

Less confusing error messages.

Revision 1.143 / (download) - annotate - [select for diffs], Fri Mar 11 22:29:55 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.142: +5 -3 lines
Diff to previous 1.142 (colored)

Simple hack to preserve the EFI System partition when
auto-allocating the space on a disk whose GPT contains
any of the magic Apple partitions.

One step towards saving the firmware files on Apple
M1 machines when installing OpenBSD.

Tested & ok kettenis@

Revision 1.142 / (download) - annotate - [select for diffs], Fri Feb 4 23:32:17 2022 UTC (2 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.141: +5 -4 lines
Diff to previous 1.141 (colored)

Wrap some annoyingly long lines.

Revision 1.141 / (download) - annotate - [select for diffs], Sat Dec 11 20:09:28 2021 UTC (2 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.140: +3 -1 lines
Diff to previous 1.140 (colored)

Start the default OpenBSD partition either immediately following
any boot partition specified via '-b' or /usr/mdec/mbr; at the
power of 2 block after the first track; or immediately following
the MBR if there is only one track.

Mark any non-EFISYS boot partition created by -b as DOSACTIVE.
Suggested by kettenis@, better than a separate new option.

Brings -b behaviour into line with many uses of -e to create boot
partitions, allowing for the eventual elimination of said -e uses
in the creation of the various boot media and in the install
scripts.

Revision 1.140 / (download) - annotate - [select for diffs], Tue Oct 19 19:38:10 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.139: +9 -5 lines
Diff to previous 1.139 (colored)

Move get_default_mbr() invocation before DISK_open() invocation and remove
"rpath wpath" from the pledge() invocation. Makes default_dmbr information
available to DISK_open().

No intentional functional change.

Revision 1.139 / (download) - annotate - [select for diffs], Wed Oct 13 13:18:57 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.138: +26 -31 lines
Diff to previous 1.138 (colored)

Nuke builtin_mbr.

Those architectures needing either MBR boot code (amd64, i386,
landisk) or special boot partitions (macppc, loongson) have long
used /usr/mdec/mbr to provide that information.

Other architectures should not blindly write i386/amd64 boot code
into the MBR.

Fail quickly if the desired default MBR file is missing.

Prompted by deraadt@, tweak from kettenis@.

Revision 1.138 / (download) - annotate - [select for diffs], Wed Sep 29 22:55:40 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.137: +6 -7 lines
Diff to previous 1.137 (colored)

Don't constrain -b specified block count or block size to be greater than 63.
Allow any value from 1 to UINT32_MAX.

MBR boot partition sizes/offsets are completely machine dependent.

Pointed out by loongson.

Revision 1.137 / (download) - annotate - [select for diffs], Sun Sep 26 13:13:16 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.136: +1 -2 lines
Diff to previous 1.136 (colored)

Revert '-b' change. Forgot required bsd.rd tweak.

Revision 1.136 / (download) - annotate - [select for diffs], Sun Sep 26 12:24:53 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.135: +2 -1 lines
Diff to previous 1.135 (colored)

MBR partitions created with '-b' should be marked DOSACTIVE.
That's what 'bootable' means in the MBR world. GPT
partitions created by '-b' are unaffected.

Pointed out by kettenis@, obviating need for new option.

Revision 1.135 / (download) - annotate - [select for diffs], Sat Aug 28 11:55:17 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.134: +5 -6 lines
Diff to previous 1.134 (colored)

Add hex_octet() so the strtol(..,16) dance is done in just one
place.

Allows single-digit partition id's in '-b' as a side benefit.

Revision 1.134 / (download) - annotate - [select for diffs], Tue Aug 10 18:17:48 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.133: +6 -5 lines
Diff to previous 1.133 (colored)

Go back to using Xwrite() during initialization phase to make
sure the same verbiage is emitted as previously. i.e. "Writing
MBR at offset 0". Fixes regress complaints.

Revision 1.133 / (download) - annotate - [select for diffs], Sat Aug 7 17:48:31 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.132: +28 -30 lines
Diff to previous 1.132 (colored)

style(9) says sort getopt() options and the following switch {}
cases. Make it so.

In passing nuke a single use 'error' variable and move an *errstr
declaration nearer to its friends.

No intentional functional change.

Revision 1.132 / (download) - annotate - [select for diffs], Sat Aug 7 13:33:12 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.131: +2 -3 lines
Diff to previous 1.131 (colored)

Nuke unneeded #include's, one param.h -> types.h.

Revision 1.131 / (download) - annotate - [select for diffs], Sat Aug 7 12:57:48 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.130: +2 -2 lines
Diff to previous 1.130 (colored)

Nuke 'p' that r1.97 snuck into getopt() invocation back in 2015.

Revision 1.130 / (download) - annotate - [select for diffs], Fri Aug 6 10:41:31 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.129: +51 -48 lines
Diff to previous 1.129 (colored)

Cleanup, clarify and generally polish the MBR/GPT initialization
code.

'-g' is promoted to be independant of '-i'. This makes it clearer
that there are four mutually exclusive initialization options.

'-i' puts the default MBR on disk, '-g' puts the default GPT on
disk, '-u' updates the MBR boot code on disk and '-A' puts a new
set of GPT partitions on disk without overwriting 'protected'
partitions.

The last initialization option specified is the one executed, so
existing '-i -g' finger memory, etc. continue to work as before.

man page/usage feedback/tweaks from jmc@

Revision 1.129 / (download) - annotate - [select for diffs], Thu Jul 22 18:54:17 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.128: +3 -3 lines
Diff to previous 1.128 (colored)

mbrfile can be const.

Revision 1.128 / (download) - annotate - [select for diffs], Wed Jul 21 12:22:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.127: +4 -6 lines
Diff to previous 1.127 (colored)

Use a dedicated struct mbr to hold the GPT protective MBR,
either the one read from disk or the default one created
when initializing GPT.

Simplifies logic, eliminates MBR_init_GPT() and demotes
MBR_protective_mbr() to a helper function called from
GPT_read().

Nuke an unused variable in passing.

No intentional functional change.

Revision 1.127 / (download) - annotate - [select for diffs], Mon Jul 19 19:46:20 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.126: +33 -25 lines
Diff to previous 1.126 (colored)

Abstract reading the built-in MBR or MBR file into
a separate function.

No functional change.

Revision 1.126 / (download) - annotate - [select for diffs], Sun Jul 18 15:28:37 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.125: +2 -7 lines
Diff to previous 1.125 (colored)

Make GPT_read() obtain and validate the on-disk MBR itself, via
MBR_read(), and report success/failure.

Simplifies logic and makes clearer that the protective MBR is a
required part of a GPT.

With the standardization on 0/-1 return values for helper
functions, rename 'valid' to 'error' in GPT_read() to make logic
less mind bending.

No functional change.

Revision 1.125 / (download) - annotate - [select for diffs], Sun Jul 18 12:41:00 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.124: +3 -4 lines
Diff to previous 1.124 (colored)

Put MBR_parse() invocation inside MBR_read() instead of always
following an invocation of MBR_read() with a call to MBR_parse().

No functional change.

Revision 1.124 / (download) - annotate - [select for diffs], Sat Jul 17 21:47:56 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.123: +1 -2 lines
Diff to previous 1.123 (colored)

The first think MBR_init() does is memset(0) the gpt header and gpt
partition array. So no need to memset(0) the gpt header before each
MBR_init() invocation.

No functional change.

Revision 1.123 / (download) - annotate - [select for diffs], Sat Jul 17 14:16:34 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.122: +1 -2 lines
Diff to previous 1.122 (colored)

Nuke a bunch of Capt. Obvious or misleading comments.

No functional change.

Revision 1.122 / (download) - annotate - [select for diffs], Thu Jul 15 23:25:46 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.121: +1 -2 lines
Diff to previous 1.121 (colored)

Nuke unused variable.

Revision 1.121 / (download) - annotate - [select for diffs], Thu Jul 15 21:58:02 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.120: +16 -30 lines
Diff to previous 1.120 (colored)

No need for separate b_sectors, b_offset and b_type variables. We have struct
prt to hold this info in one place.

Construct a struct prt to hold the boot partition information and stash it in
the struct disk for both MBR and GPT to access as needed.

Move the blocks to sectors conversions into DISK_open() with all of its
geometry friends.

No intentional functional change.

Revision 1.120 / (download) - annotate - [select for diffs], Thu Jul 15 21:23:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.119: +22 -32 lines
Diff to previous 1.119 (colored)

Consolidate disk geometry fiddling, turning -l/-c/-h/-s values into MBR
partition geometry info, into DISK_open(). Resulting in clearer logic.

No intentional functional change.

Revision 1.119 / (download) - annotate - [select for diffs], Mon Jul 12 14:06:19 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.118: +17 -17 lines
Diff to previous 1.118 (colored)

Add 'dk_' prefix to struct disk field names.

No functional change.

Revision 1.118 / (download) - annotate - [select for diffs], Sun Jul 11 19:43:19 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.117: +3 -2 lines
Diff to previous 1.117 (colored)

Add 'mbr_' prefix to struct mbr field names.

Change 'offset' to mbr_lba_self and 'reloffset'
to mbr_lba_firstembr to make their use more evident.
Adjust a few parameter names to match.

Change 'part[]' to mbr_prt[] to reflect that it is an
array of struct prt.

No functional change.

Revision 1.117 / (download) - annotate - [select for diffs], Sun Jul 11 13:51:42 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.116: +54 -1 lines
Diff to previous 1.116 (colored)

Move ask_cmd(), ask_num(), ask_pid(), ask_string(), parse_b()
and crc32().

No functional change.

Revision 1.116 / (download) - annotate - [select for diffs], Sun Jul 11 13:38:27 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.115: +19 -19 lines
Diff to previous 1.115 (colored)

Add tabs to make variable declarations easier
to read.

No functional change.

Revision 1.115 / (download) - annotate - [select for diffs], Sun Jul 11 12:51:36 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.114: +2 -2 lines
Diff to previous 1.114 (colored)

'return' is not a function call.

No functional change.

Revision 1.114 / (download) - annotate - [select for diffs], Mon Jun 28 19:50:30 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.113: +4 -4 lines
Diff to previous 1.113 (colored)

Add another epicycle to -A processing that ensures ONLY the
partition table is changed. Not the GPT header. Not the MBR. And
only write back as much partition table information as the header
claims to have room for.

At a minimum should make -A safer when operating on the Apple M1
GPT.

A major overhaul of this code is urgently needed before someone
sneezes too hard in its vicinity.

Feedback kettenis@ & ok deraadt@

Revision 1.113 / (download) - annotate - [select for diffs], Fri Jun 25 19:24:53 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.112: +8 -8 lines
Diff to previous 1.112 (colored)

Replace instances of the magic number '64' with a nice #define
BLOCKALIGNMENT. This will make it more obvious where this
512-byte block count could/should be converted to a disk sector
count.

No functional change.

Revision 1.112 / (download) - annotate - [select for diffs], Wed Jun 23 13:07:13 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.111: +10 -1 lines
Diff to previous 1.111 (colored)

The value of -l should be treated as a 512-byte block count.

Tweak man page.

Revision 1.111 / (download) - annotate - [select for diffs], Tue Jun 22 14:01:58 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.110: +12 -2 lines
Diff to previous 1.110 (colored)

The values for blocks and offset in -b should be treated as 512-byte block
counts.

Tweak man page accordingly.

Requested by deraadt@ and kettenis@.

Revision 1.110 / (download) - annotate - [select for diffs], Mon Jun 21 02:05:30 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.109: +21 -20 lines
Diff to previous 1.109 (colored)

Add -A option to "safely" initialize a GPT without removing
special boot partitions needed by some hardware. Make it
difficult to add, delete or modify those partitions with 'fdisk
-e'.

Trim back and correct syntax in usage(). Whack at man page
verbiage.

Suggestions and ok deraadt@

Revision 1.109 / (download) - annotate - [select for diffs], Sun Jun 20 18:44:19 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.108: +6 -8 lines
Diff to previous 1.108 (colored)

Make -b available to architectures other than amd64 and i386.

Extend the syntax to allow the boot partition offset and boot
partition type to be specified if needed.

ok deraadt@ kettenis@

Revision 1.108 / (download) - annotate - [select for diffs], Mon Jun 14 17:34:06 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.107: +1 -2 lines
Diff to previous 1.107 (colored)

Only use of 'reinited' died in cmd.c r1.100. It is now set in a
couple of places but never checked. Retire it.

No functional change.

Revision 1.107 / (download) - annotate - [select for diffs], Fri May 14 15:31:01 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.106: +4 -3 lines
Diff to previous 1.106 (colored)

Tweak the two copies of gpt_chk_mbr() to return the index of the MBR
0xEE (DOSPTYP_EFI) partition, or -1 no usable such partition is found.

Adopt a consistent idiom to capture the index for future use.

Clean up the gpt_chk_mbr() logic to make it clearer what constraints
are being applied when looking for the DOSTYP_EFI partition.

No intentional functional change.

Revision 1.106 / (download) - annotate - [select for diffs], Mon May 10 17:16:01 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.105: +4 -4 lines
Diff to previous 1.105 (colored)

Replace some magic numbers with #define's. Rename GPT_get_gpt() to
GPT_read() to match MBR_read().

No intentional functional change.

Revision 1.105 / (download) - annotate - [select for diffs], Fri May 7 22:15:13 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.104: +3 -3 lines
Diff to previous 1.104 (colored)

Replace random mix of u_int* and uint* types with consistent uint* types.

Revision 1.104 / (download) - annotate - [select for diffs], Sun May 2 20:07:14 2021 UTC (3 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.103: +2 -1 lines
Diff to previous 1.103 (colored)

Try harder to ensure there are no GPT revenants after
choosing MBR partitioning.

Revision 1.103 / (download) - annotate - [select for diffs], Thu Apr 26 15:55:14 2018 UTC (6 years, 1 month ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.102: +2 -2 lines
Diff to previous 1.102 (colored)

Prefer <fcntl.h> over <sys/fcntl.h> in userland
While here, delete some extra #includes and apply style(9) sort rules.

ok deraadt@ krw@ mpi@

Revision 1.102 / (download) - annotate - [select for diffs], Tue Dec 27 15:01:03 2016 UTC (7 years, 5 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.101: +1 -7 lines
Diff to previous 1.101 (colored)

The "disk too large" and "only LBA values saved" messages are more
often confusing than useful these days. Stop emitting them.

Prompted by bugs@ report of the 8TB disk travails of Jiri.

ok deraadt@ tom@

Revision 1.101 / (download) - annotate - [select for diffs], Sat Jun 25 17:03:22 2016 UTC (7 years, 11 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.100: +5 -5 lines
Diff to previous 1.100 (colored)

Move pledge after opendev and DIOCGPDINFO. Fixes e.g. fdisk /dev/tty.
This diff by deraadt was overlooked far too many times, mostly by me.
It's the original fix of the pledge disklabel breakage found by espie.

diff by deraadt; ok semarie, tb.

Revision 1.100 / (download) - annotate - [select for diffs], Mon Mar 28 16:55:09 2016 UTC (8 years, 2 months ago) by mestre
Branch: MAIN
Changes since 1.99: +2 -3 lines
Diff to previous 1.99 (colored)

Remove unused variables

OK krw@

Revision 1.99 / (download) - annotate - [select for diffs], Sat Dec 12 04:14:36 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.98: +3 -3 lines
Diff to previous 1.98 (colored)

In olden times (i + u + e) was considered a clever way to 'or'
together three boolean values. In today's englightened world we
know about '||'.

Pointed out by naddy@

Revision 1.98 / (download) - annotate - [select for diffs], Sat Dec 12 02:49:50 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.97: +2 -2 lines
Diff to previous 1.97 (colored)

Open disk READONLY if none of i, e or u are specified.

Suggestion, original diff and ok naddy@

Revision 1.97 / (download) - annotate - [select for diffs], Fri Dec 11 21:57:31 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.96: +11 -6 lines
Diff to previous 1.96 (colored)

Add '-v' flag that forces the display of both GPT's and the MBR.
Useful for seeing exactly what is currently on the disk. Suggested
by a request from kettenis@.

Man page & usage ok jmc@

Revision 1.96 / (download) - annotate - [select for diffs], Tue Dec 1 06:25:43 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.95: +2 -1 lines
Diff to previous 1.95 (colored)

Make '-i' set 'reinited' flag so that the initial Xwrite() will zap
any undesirable GPT hanging around. i.e. same as 'reinit' from the
fdisk(8) command line. Noticed now that install media relies on
'-i' rather than issuing 'reinit' in a script.

Revision 1.95 / (download) - annotate - [select for diffs], Tue Nov 24 01:01:56 2015 UTC (8 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.94: +5 -1 lines
Diff to previous 1.94 (colored)

pledge "stdio rpath wpath disklabel proc exec" throughout, after
krw's refactorings which hoisted disk-opening to the top.
tested by krw

Revision 1.94 / (download) - annotate - [select for diffs], Thu Nov 19 17:52:56 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.93: +5 -4 lines
Diff to previous 1.93 (colored)

Oops. Missed a file.

Reduce overburden of unnecessary #include's. Note that param.h is
included only for DEV_BSIZE.  Use INT64_MAX instead of LLONG_MAX
so stdint.h is enough.  General tidying up of #include sections.

ok GCC

Revision 1.93 / (download) - annotate - [select for diffs], Wed Nov 18 15:31:15 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.92: +5 -4 lines
Diff to previous 1.92 (colored)

Parse the original on-disk MBR into a local variable. Use the
partition table in this variable when doing an 'u'pdate of the MBR.
Remove now superfluous MBR_pcopy() and its re-read of the on-disk MBR.

Revision 1.92 / (download) - annotate - [select for diffs], Wed Nov 18 15:10:43 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.91: +2 -4 lines
Diff to previous 1.91 (colored)

g_flag does not need to be a global. Move it inside main().

Revision 1.91 / (download) - annotate - [select for diffs], Wed Nov 18 02:32:56 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.90: +16 -21 lines
Diff to previous 1.90 (colored)

Rejig the MBR file reading logic so

1) If mbr_file is NULL use built-in mbr for -i, -u and 'reinit'.
2) If mbr_file cannot be opened issue a warning and use built-in mbr for -i,
   -u, and 'reinit'.
3) If mbr_file can't be read, bail out of fdisk.
4) Use the mbr read from mbr_file for -i, -u, and 'reinit'.

Remove inappropriate GPT dancing.

This restores pre-GPT-editing mbr_file handling and makes the logic
clearer at the expense of a tiny bit of duplication.

Revision 1.90 / (download) - annotate - [select for diffs], Wed Nov 18 01:53:12 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.89: +8 -9 lines
Diff to previous 1.89 (colored)

Read MBR immediately, and only read the GPT if the MBR is a
protective MBR.

Revision 1.89 / (download) - annotate - [select for diffs], Sun Nov 15 01:22:39 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.88: +6 -5 lines
Diff to previous 1.88 (colored)

Move zapping of invalid GPT data into GPT_get_gpt() rather than
returning a value to tell callers to zap it. Use consistant idiom
to check for the presence of a GPT (check gh.gh_sig). When zapping
GPT, always zap both the header and partition table just for
paranoia's sake.

Revision 1.88 / (download) - annotate - [select for diffs], Sat Nov 14 21:17:08 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.87: +15 -22 lines
Diff to previous 1.87 (colored)

Since -l is ignored if -c/-h/-s are specified, make that combination
invalid and mention the constraint in usage(). Modify the appropriate
field(s) of the global 'disk' as -l/-c/-h/-s are encountered. As a
result use the disklabel information to populate the global 'disk'
only when it has not already been populated. Move test for 'disk'
validity into DISK_open().

Revision 1.87 / (download) - annotate - [select for diffs], Sat Nov 14 17:42:31 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.86: +8 -11 lines
Diff to previous 1.86 (colored)

Consolidate usage() checking for -c/-h/-s with other checks. Tweak
usage() verbiage a bit so it's clear all of '-c -h -s' are required
if any are used.

Revision 1.86 / (download) - annotate - [select for diffs], Sat Nov 14 00:20:59 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.85: +3 -1 lines
Diff to previous 1.85 (colored)

pledge("stdio", NULL) for code path that just prints the MBR or GPT. i.e.
when none of -i, -e or -u are specified.

Prodded by deraadt@

Revision 1.85 / (download) - annotate - [select for diffs], Sat Nov 14 00:13:47 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.84: +5 -3 lines
Diff to previous 1.84 (colored)

If none of -i, -u or -e are specified exit immediately after the
MBR or GPT is printed. Do not attempt to read the MBR template file,
construct an initial mbr, etc.

Revision 1.84 / (download) - annotate - [select for diffs], Fri Nov 13 22:27:35 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.83: +4 -14 lines
Diff to previous 1.83 (colored)

No need to supplement usage() with extra messages about -b needing -i, or
-g needing -i. The usage() text is quite clear.

usage() doesn't return so eliminate unneeded 'else'.

Revision 1.83 / (download) - annotate - [select for diffs], Fri Nov 13 21:54:10 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.82: +1 -3 lines
Diff to previous 1.82 (colored)

No need to zero a global variable before use.

Revision 1.82 / (download) - annotate - [select for diffs], Fri Nov 13 15:32:36 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.81: +7 -7 lines
Diff to previous 1.81 (colored)

Make usage() output fit on a 'normal' 80-character line. Tweak some
verbiage in the usage() output.

Revision 1.81 / (download) - annotate - [select for diffs], Fri Nov 13 02:27:17 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.80: +5 -6 lines
Diff to previous 1.80 (colored)

Move from opening/closing disk for every i/o to opening the disk once
and saving the fd in the global 'disk' structure. Stop passing around
fd's and just use the global.

Makes pledge() feasible.

Prompted by and ok deraadt@

Revision 1.80 / (download) - annotate - [select for diffs], Wed Nov 11 15:39:18 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.79: +4 -1 lines
Diff to previous 1.79 (colored)

Display full disk size when editing GPT, not the truncated MBR size. Display
'disk too large' message only when no GPT is found.

Problems found, fix tested and ok naddy@.

Revision 1.79 / (download) - annotate - [select for diffs], Mon Oct 26 15:08:26 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.78: +34 -19 lines
Diff to previous 1.78 (colored)

Add GPT editing. Based on GSOC 2014 work by Markus Muller.

Revision 1.78 / (download) - annotate - [select for diffs], Mon Oct 5 01:39:08 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.77: +19 -4 lines
Diff to previous 1.77 (colored)

Enhance '-g' to create a default GPT label in addition to the protective
MBR. If '-b' is specified an EFI System partition of the requested size is
created. All remaining space is put into an OpenBSD partition.

Minimal enhancement necessary for upcoming UEFI install support.
Committed first to flush out any unexpected impacts on 'normal' MBR
operation and install media.

ok deraadt@

Revision 1.77 / (download) - annotate - [select for diffs], Sun Sep 6 09:06:23 2015 UTC (8 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.76: +3 -3 lines
Diff to previous 1.76 (colored)

correct a mistake in my previous commit;

Revision 1.76 / (download) - annotate - [select for diffs], Fri Sep 4 21:19:45 2015 UTC (8 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.75: +8 -8 lines
Diff to previous 1.75 (colored)

shuffle -b into place; while there, do some general tidy up
of SYNOPSIS and usage();

Revision 1.75 / (download) - annotate - [select for diffs], Fri Sep 4 19:02:49 2015 UTC (8 years, 8 months ago) by kettenis
Branch: MAIN
Changes since 1.74: +16 -3 lines
Diff to previous 1.74 (colored)

Add a -b option, to be used together with -i, that tells fdisk to add a
special boot partition on architectures that need it.

For now those architectures are amd64 and i386, where this option will
create an EFI system partition to store our new UEFI bootloader.

ok deraadt@, krw@

Revision 1.74 / (download) - annotate - [select for diffs], Thu Jul 9 19:48:36 2015 UTC (8 years, 10 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.73: +2 -2 lines
Diff to previous 1.73 (colored)

Nuke unused variable.

Revision 1.73 / (download) - annotate - [select for diffs], Wed Jul 8 23:44:56 2015 UTC (8 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.72: +8 -4 lines
Diff to previous 1.72 (colored)

Do not attempt to read a disk sector worth of data from the file
containing the MBR template. Most especially don't get upset when
the 512-byte file does not contain a full 4096 byte disk sector.

Allows 4096-byte disks to be fdisk'ed once more.

Problem reported and fix tested by Gerald Hanuer via bugs@.

ok deraadt@

Revision 1.72 / (download) - annotate - [select for diffs], Thu Mar 19 15:44:12 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.71: +1 -2 lines
Diff to previous 1.71 (colored)

Nuke now unused variable.

Revision 1.71 / (download) - annotate - [select for diffs], Wed Mar 18 14:46:59 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.70: +7 -7 lines
Diff to previous 1.70 (colored)

Stop passing around little used 'struct mbr tt' parameter.  Just
make the initial mbr that tt pointed at a global that can be directly
accessed in the couple of places it is needed.

Fewer parameters, less confusion, no functional change.

Revision 1.70 / (download) - annotate - [select for diffs], Tue Mar 17 21:42:15 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.69: +2 -2 lines
Diff to previous 1.69 (colored)

Stop passing around little used and superfluous 'offset' parameter.
Just use the offset recorded/parsed in the struct mbr being used.

Can still traverse/edit extended MBRs so offset really wasn't needed.

Fewer parameters, less confusion, no functional change.

Revision 1.69 / (download) - annotate - [select for diffs], Mon Mar 16 23:51:50 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.68: +8 -9 lines
Diff to previous 1.68 (colored)

Stop passing around a pointer to the stack variable 'disk' in main().
There is only one disk being worked on, so just make it a global.

Fewer parameters, less confusion, no functional change.

Revision 1.68 / (download) - annotate - [select for diffs], Mon Mar 16 18:45:51 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.67: +15 -6 lines
Diff to previous 1.67 (colored)

Document that -i/-u are mutually exclusive and clean up the related
code a bit.

ok deraadt@ igor@ (with suggested tweak that is coming)

Revision 1.67 / (download) - annotate - [select for diffs], Sat Mar 14 18:32:29 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.66: +3 -4 lines
Diff to previous 1.66 (colored)

Whitespace & KNF tweaks. Change functions whose return values are
not checked to void. Use continue inside a do loop instead of a
goto to the top. Move a #define/#undef more local to use. Eliminate
some lint.

General cleanup of things noticed preparing the big churn.

No intentional functional change.

Revision 1.66 / (download) - annotate - [select for diffs], Sat Mar 14 15:21:53 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.65: +11 -20 lines
Diff to previous 1.65 (colored)

Switch all the license blocks to the standard OpenBSD/ISC license.

With the permission of Toby.

ok deraadt@

Revision 1.65 / (download) - annotate - [select for diffs], Mon Feb 9 04:27:15 2015 UTC (9 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.64: +6 -6 lines
Diff to previous 1.64 (colored)

Rename 'm_flag' to 'e_flag' since it's '-e' that sets it. Rename
'User_modify' to 'USER_edit' for the same reason.

Revision 1.64 / (download) - annotate - [select for diffs], Sat Jan 3 15:50:50 2015 UTC (9 years, 5 months ago) by jsing
Branch: MAIN
Changes since 1.63: +14 -3 lines
Diff to previous 1.63 (colored)

Add support for creating a protective MBR for GPT.

Part of a diff by Markus Mueller, which was derived from Bitrig during
Google Summer of Code, with further tweaks by me.

ok krw@ miod@

Revision 1.63 / (download) - annotate - [select for diffs], Thu Mar 20 13:18:21 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.62: +2 -1 lines
Diff to previous 1.62 (colored)

Add back various #includes of err.h, unistd.h, ctype.h, ioctl.h to
eliminate multiple 'implicit' declarations introduced by the previous
over-zealous #include cleanup.

Thanks to to tedu@ for pointing out how -Wall reveals all.

Revision 1.62 / (download) - annotate - [select for diffs], Mon Mar 17 16:40:00 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.61: +4 -2 lines
Diff to previous 1.61 (colored)

Nuke pointless blank lines, defines, comments and casts. Eliminate
#include in *.h files in favour of listing them as required in the *.c
files. Fix error message to correctly state that 64 is the minimum
value for -l. Use errx() where errno is not relevant. Use 'continue'
rather than a label to go back to start of a loop.

No intentional functional change.

Revision 1.61 / (download) - annotate - [select for diffs], Mon Mar 17 13:15:44 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.60: +26 -29 lines
Diff to previous 1.60 (colored)

Un-revert, being careful to not break snap building. Add paranoia check
for any missing geometry.

Revision 1.60 / (download) - annotate - [select for diffs], Fri Mar 14 15:41:33 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.59: +28 -25 lines
Diff to previous 1.59 (colored)

Revert last -- broke building snaps.

Revision 1.59 / (download) - annotate - [select for diffs], Thu Mar 13 12:02:28 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.58: +25 -28 lines
Diff to previous 1.58 (colored)

Merge 'struct DISK_metrics' and 'struct disk' into one, since we don't
need to record two sets of metric/geometry data. Use 'geometry'
instead of 'metrics' in names and comments. Eliminate
DISK_getmetrics().

While here, make 64 the minimal valid value for '-l' instead of 1. This
avoids the possibility of having 0 cylinders.

No intentional functional change.

Feedback & tweak from chris@

Revision 1.58 / (download) - annotate - [select for diffs], Sun Mar 9 22:25:06 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.57: +6 -7 lines
Diff to previous 1.57 (colored)

Instead of passing around 'char buf[DEV_BSIZE]' buffers, pass around
'struct dos_mbr' variables, since that is what the buffers were used
for. Removes need to know about DEV_BSIZE and thus include param.h
from all files but one so move the param.h #include to that file
(mbr.c).

Nuke a bunch of local MBR #defines in favour of the disklabel.h ones.

Remove a bunch of unneeded #includes, replace the odd malloc/bzero
with calloc, replace equally odd bcopy's with memcpy, remove a stray
duplicate MBR parsing in MBR_pcopy().

No intentional functional change.

Revision 1.57 / (download) - annotate - [select for diffs], Fri Mar 7 21:56:13 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.56: +6 -6 lines
Diff to previous 1.56 (colored)

Relieve the code of an overburden of unnecessary typedef
abstraction. Call a 'struct' a 'struct' and not a pony.

No functional change.

idea ok deraadt@

Revision 1.56 / (download) - annotate - [select for diffs], Thu Mar 6 17:39:23 2014 UTC (10 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.55: +2 -2 lines
Diff to previous 1.55 (colored)

tweak previous;

Revision 1.55 / (download) - annotate - [select for diffs], Sun Mar 2 15:41:28 2014 UTC (10 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.54: +21 -3 lines
Diff to previous 1.54 (colored)

-l disksize code, to force LBA mode.  code by chris, after I suggested
wrapping rows of echo's via fdisk was silly.
ok kettenis krw

Revision 1.54 / (download) - annotate - [select for diffs], Thu Mar 21 18:45:58 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.53: +4 -4 lines
Diff to previous 1.53 (colored)

more substantial include cleanup

Revision 1.53 / (download) - annotate - [select for diffs], Sun Dec 25 19:13:51 2011 UTC (12 years, 5 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.52: +3 -5 lines
Diff to previous 1.52 (colored)

printf("msg")/return 1 -> err(1, "msg"), which will also show relevant
errno string. Since we are err()'ing out, don't worry about closing
MBR fd first.

Revision 1.52 / (download) - annotate - [select for diffs], Mon Feb 21 19:26:12 2011 UTC (13 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.51: +7 -3 lines
Diff to previous 1.51 (colored)

Honour MBR_read() results and don't pretend we can parse blocks we
did not successfully read. Tweak some casts.

Fixes infinite loop problem noted by jeremy@ while installing on
boxen with 'random' garbage in MBR. General loop detection may
follow post-4.9.

Tested by jeremy@ and ok miod@

Revision 1.51 / (download) - annotate - [select for diffs], Tue May 25 18:51:02 2010 UTC (14 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.50: +2 -2 lines
Diff to previous 1.50 (colored)

match usage to the manual page, and borrow the description of 'disk'
from disklabel(8), since it describes the effect of using opendev()

Revision 1.50 / (download) - annotate - [select for diffs], Mon Mar 22 15:25:47 2010 UTC (14 years, 2 months ago) by otto
Branch: MAIN
Changes since 1.49: +2 -3 lines
Diff to previous 1.49 (colored)

introduce HAS_MBR and let make define it for the right machines;
requested by miod@; ok miod@ krw@

Revision 1.49 / (download) - annotate - [select for diffs], Wed Feb 17 20:19:05 2010 UTC (14 years, 3 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

loongson has mbr as well; ok miod@ (but he made me promise to make
a -DHAVE_MBR diff after release)

Revision 1.48 / (download) - annotate - [select for diffs], Sun Dec 30 13:20:13 2007 UTC (16 years, 5 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

sort flags in both synopsis and usage

ok jmc@

Revision 1.47 / (download) - annotate - [select for diffs], Thu Apr 26 23:39:01 2007 UTC (17 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.46: +2 -2 lines
Diff to previous 1.46 (colored)

lint says: fdisk.c:160: warning: operator '==' found where '=' was expected
yet gcc happily ate it... see, lint is useful

Revision 1.46 / (download) - annotate - [select for diffs], Thu Nov 9 00:01:10 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

oops

Revision 1.45 / (download) - annotate - [select for diffs], Wed Nov 8 23:57:05 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.44: +3 -2 lines
Diff to previous 1.44 (colored)

sh machines also have a /usr/mdec/mbr

Revision 1.44 / (download) - annotate - [select for diffs], Wed Nov 8 23:22:26 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.43: +9 -3 lines
Diff to previous 1.43 (colored)

add a -y flag, for non-interactive use

Revision 1.43 / (download) - annotate - [select for diffs], Thu Jul 27 04:53:27 2006 UTC (17 years, 10 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.42: +13 -13 lines
Diff to previous 1.42 (colored)

Change some obvious atoi() to strtonum().

OK tedu@

Revision 1.42 / (download) - annotate - [select for diffs], Thu Jul 27 04:06:13 2006 UTC (17 years, 10 months ago) by ray
Branch: MAIN
Changes since 1.41: +3 -2 lines
Diff to previous 1.41 (colored)

Add checks to each write(2) attempt and try to keep fdisk in a
consistent state upon write failure.

OK krw@ and deraadt@.

Revision 1.41 / (download) - annotate - [select for diffs], Sun Jul 9 21:19:41 2006 UTC (17 years, 10 months ago) by miod
Branch: MAIN
Changes since 1.40: +9 -2 lines
Diff to previous 1.40 (colored)

Do not try and read /usr/mdec/mbr in ``fdisk -e'' unless the architecture
really provides it.

Revision 1.40 / (download) - annotate - [select for diffs], Sun May 1 20:53:38 2005 UTC (19 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.39: +2 -2 lines
Diff to previous 1.39 (colored)

- better synopsis
- sync usage()
- add fstab(5) to SEE ALSO
- NOTES -> CAVEATS and improve

bits ok deraadt@
improvements and ok tom@

Revision 1.39 / (download) - annotate - [select for diffs], Tue Aug 3 09:22:03 2004 UTC (19 years, 10 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.38: +7 -4 lines
Diff to previous 1.38 (colored)

Handle geometry parameters as unsigned quantities, getting rid of negative
number of sectors on large disks and other similar problems.

ok toby@ tom@ deraadt@

Revision 1.38 / (download) - annotate - [select for diffs], Wed Jan 7 16:28:52 2004 UTC (20 years, 4 months ago) by tom
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Better diagnostic message if we can't open the external MBR file

ok weingart@, tedu@

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jul 2 21:44:57 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.36: +2 -3 lines
Diff to previous 1.36 (colored)

missing protos

Revision 1.36 / (download) - annotate - [select for diffs], Wed Jun 11 06:22:12 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.35: +4 -5 lines
Diff to previous 1.35 (colored)

ansification

Revision 1.35 / (download) - annotate - [select for diffs], Tue Jun 3 01:13:19 2003 UTC (21 years ago) by weingart
Branch: MAIN
Changes since 1.34: +1 -6 lines
Diff to previous 1.34 (colored)

Nuke terms 3 & 4.

Revision 1.34 / (download) - annotate - [select for diffs], Sat Dec 15 02:12:26 2001 UTC (22 years, 5 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.33: +11 -11 lines
Diff to previous 1.33 (colored)

Get this damn diff out of my tree. ok from weingart@, deraadt@ and others.
Add a -u flag to fdisk which updates MBR code, but leaves the partition
table intact. There are still issues with 'update' having different behavior,
but I'll resolve those shortly

Revision 1.33 / (download) - annotate - [select for diffs], Mon Jul 2 13:51:17 2001 UTC (22 years, 11 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.32: +2 -1 lines
Diff to previous 1.32 (colored)

#include <string.h> to get mem* prototypes.

Revision 1.32 / (download) - annotate - [select for diffs], Sat Jun 23 01:54:38 2001 UTC (22 years, 11 months ago) by kjell
Branch: MAIN
Changes since 1.31: +12 -5 lines
Diff to previous 1.31 (colored)

Changes from Toby. Make error tests explicit (against -1), remove one big
hurdle to partitions over 8G. Include the default MBR in a header file.

Revision 1.31 / (download) - annotate - [select for diffs], Sat Jan 8 04:51:16 2000 UTC (24 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.30: +7 -12 lines
Diff to previous 1.30 (colored)

support LBA-mapped extended partitions too; sigh@kuzirabekon.econ.nagasaki-u.ac.jp

Revision 1.30 / (download) - annotate - [select for diffs], Mon Sep 14 03:54:34 1998 UTC (25 years, 8 months ago) by rahnds
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.29: +2 -2 lines
Diff to previous 1.29 (colored)

Since on the powerpc, the system does not supply the user with
bios valid cyl,head,sector information (the information comes from the
sd driver) I have made some changes to fdisk to do the following.

Allow the powerpc to specify values larger than the bios limits.

All platforms now have code that will translate the LBA values
in the mbr into CHS values according to the disk geometry.
This occurs if the start and ending CHS values have been stored as
0xffffff.

If writing to the disk and one of the values of a partition violates
the bios limits, it writes the requested values in the LBA fields ,
and stores 0xffffff for the starting and ending CHS values.

This should not change the default formatting of any existing system
other than the CHS and LBA values should always match given the detected
geometry of the disk.

Revision 1.29 / (download) - annotate - [select for diffs], Tue Oct 28 03:12:14 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.28: +6 -6 lines
Diff to previous 1.28 (colored)

if printing, we do not need to read the mbr first

Revision 1.28 / (download) - annotate - [select for diffs], Tue Oct 21 22:49:33 1997 UTC (26 years, 7 months ago) by provos
Branch: MAIN
Changes since 1.27: +3 -3 lines
Diff to previous 1.27 (colored)

make fdisk grok extended partitions again. we have to keep track of the
absolute offset of the current mbr and its relative position. because:
the starting sector of the first mbr entry in an extended partition is relative
to the starting offset of the whole mbr itself. the starting offset of a new
extended partition is relative to the offset of the very first extended
partition.

Revision 1.27 / (download) - annotate - [select for diffs], Sun Oct 19 23:30:47 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored)

indent

Revision 1.26 / (download) - annotate - [select for diffs], Sun Oct 19 23:29:36 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.25: +58 -59 lines
Diff to previous 1.25 (colored)

indent

Revision 1.25 / (download) - annotate - [select for diffs], Thu Oct 16 01:47:10 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.24: +24 -20 lines
Diff to previous 1.24 (colored)

a bunch of improvements by weingart & I

Revision 1.24 / (download) - annotate - [select for diffs], Tue Oct 14 21:21:33 1997 UTC (26 years, 7 months ago) by pefo
Branch: MAIN
Changes since 1.23: +2 -2 lines
Diff to previous 1.23 (colored)

Be a little more informative.

Revision 1.23 / (download) - annotate - [select for diffs], Mon Sep 29 23:33:35 1997 UTC (26 years, 8 months ago) by mickey
Branch: MAIN
Changes since 1.22: +1 -2 lines
Diff to previous 1.22 (colored)

ID in the first line w/ tabs

Revision 1.22 / (download) - annotate - [select for diffs], Mon Sep 29 23:16:59 1997 UTC (26 years, 8 months ago) by mickey
Branch: MAIN
Changes since 1.21: +10 -7 lines
Diff to previous 1.21 (colored)

better usage()

Revision 1.21 / (download) - annotate - [select for diffs], Mon Sep 29 22:58:16 1997 UTC (26 years, 8 months ago) by weingart
Branch: MAIN
Changes since 1.20: +118 -831 lines
Diff to previous 1.20 (colored)

New fdisk code with interactive (command line type)
editing code.  Rewrite from the ground up, save about
20 lines of code.  Seems to create valid partition
tables on i386 and alphas.

Revision 1.20 / (download) - annotate - [select for diffs], Mon Sep 29 22:50:06 1997 UTC (26 years, 8 months ago) by weingart
Branch: MAIN
Changes since 1.19: +3 -3 lines
Diff to previous 1.19 (colored)

Clean up junk before commit of new fdisk

Revision 1.19 / (download) - annotate - [select for diffs], Sun Jul 6 18:19:29 1997 UTC (26 years, 11 months ago) by niklas
Branch: MAIN
Changes since 1.18: +6 -6 lines
Diff to previous 1.18 (colored)

Explicit typing

Revision 1.18 / (download) - annotate - [select for diffs], Thu Apr 17 12:31:46 1997 UTC (27 years, 1 month ago) by provos
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.17: +6 -15 lines
Diff to previous 1.17 (colored)

fix start address for first extended filesystem

Revision 1.17 / (download) - annotate - [select for diffs], Tue Apr 15 09:02:54 1997 UTC (27 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.16: +8 -9 lines
Diff to previous 1.16 (colored)

indent

Revision 1.16 / (download) - annotate - [select for diffs], Mon Apr 14 22:18:57 1997 UTC (27 years, 1 month ago) by provos
Branch: MAIN
Changes since 1.15: +42 -24 lines
Diff to previous 1.15 (colored)

works a bit better with extended partitions. hack.

Revision 1.15 / (download) - annotate - [select for diffs], Fri Apr 11 10:01:31 1997 UTC (27 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.14: +83 -25 lines
Diff to previous 1.14 (colored)

add more partition types. add (non-functional) Extended partition support
which can be finished by someone who has Extended partitions (HINT: I
would really like to see this working for 2.1)

Revision 1.14 / (download) - annotate - [select for diffs], Sun Apr 6 23:54:44 1997 UTC (27 years, 2 months ago) by downsj
Branch: MAIN
Changes since 1.13: +3 -2 lines
Diff to previous 1.13 (colored)

Add partition type 0x12.

Revision 1.13 / (download) - annotate - [select for diffs], Wed Apr 2 05:30:05 1997 UTC (27 years, 2 months ago) by mickey
Branch: MAIN
Changes since 1.12: +4 -4 lines
Diff to previous 1.12 (colored)

fix bios geometry calculation

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jan 31 11:59:05 1997 UTC (27 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.11: +10 -4 lines
Diff to previous 1.11 (colored)

avoid some division by zero in hackish ways

Revision 1.11 / (download) - annotate - [select for diffs], Mon Jan 27 21:57:36 1997 UTC (27 years, 4 months ago) by rahnds
Branch: MAIN
Changes since 1.10: +63 -18 lines
Diff to previous 1.10 (colored)

Support fdisk on bigendian systems. Does the necessary byte swabbing to
read and write the fdisk label. Added powerpc to systems to build this for.
Currently uses local functions getshort, putshort, getlong, and putlong.
These functions probably should be moved and renamed. Something like
htoles, letohs, htolel, letohl, or htole16, htole32 should be used instead.

Revision 1.10 / (download) - annotate - [select for diffs], Fri Jan 10 19:09:58 1997 UTC (27 years, 4 months ago) by jkatz
Branch: MAIN
Changes since 1.9: +3 -2 lines
Diff to previous 1.9 (colored)

one-line fix so fdisk knows that partitions marked 0x0B are Win95/FAT32

Revision 1.9 / (download) - annotate - [select for diffs], Mon Sep 30 12:08:17 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

signature is 16 bits

Revision 1.8 / (download) - annotate - [select for diffs], Fri Sep 27 15:36:09 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +6 -5 lines
Diff to previous 1.7 (colored)

even better

Revision 1.7 / (download) - annotate - [select for diffs], Fri Sep 27 15:34:49 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.6: +4 -2 lines
Diff to previous 1.6 (colored)

installing people do not have man pages; better usage

Revision 1.6 / (download) - annotate - [select for diffs], Fri Sep 27 15:27:03 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.5: +5 -3 lines
Diff to previous 1.5 (colored)

make -m also act like -i/-u

Revision 1.5 / (download) - annotate - [select for diffs], Fri Sep 27 14:32:07 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +4 -4 lines
Diff to previous 1.4 (colored)

nicer errors

Revision 1.4 / (download) - annotate - [select for diffs], Wed Sep 25 11:24:13 1996 UTC (27 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.3: +153 -178 lines
Diff to previous 1.3 (colored)

permit loading of a special MBR bootblock -- do not encode a fake MBR
bootblock inside the program. cleanup printed output. do not assume 'd'
partition.  Solves a whole bunch of other interaction problems with
disklabel.  Has been tested a fair bit, but will endure more testing
(at the hands of the users! Hahahaha!)

Revision 1.3 / (download) - annotate - [select for diffs], Mon Jun 17 08:27:26 1996 UTC (27 years, 11 months ago) by downsj
Branch: MAIN
Changes since 1.2: +4 -1 lines
Diff to previous 1.2 (colored)

Switched to generic opendev(3)

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jun 3 07:54:34 1996 UTC (28 years ago) by deraadt
Branch: MAIN
Changes since 1.1: +1 -1 lines
Diff to previous 1.1 (colored)

openbsd, not netbsd

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Wed Oct 18 08:43:31 1995 UTC (28 years, 7 months ago) by deraadt
CVS Tags: netbsd_1_1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

initial import of NetBSD tree

Revision 1.1 / (download) - annotate - [select for diffs], Wed Oct 18 08:43:31 1995 UTC (28 years, 7 months ago) by deraadt
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.