OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.124 / (download) - annotate - [select for diffs], Wed May 17 12:59:37 2023 UTC (12 months, 3 weeks ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.123: +4 -4 lines
Diff to previous 1.123 (colored)

Make function and symmetry obvious by renaming PRT_make() to
PRT_prt_to_dp() and PRT_parse() to PRT_dp_to_prt().

No functional change.

Revision 1.123 / (download) - annotate - [select for diffs], Mon Mar 6 13:24:40 2023 UTC (15 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.122: +14 -8 lines
Diff to previous 1.122 (colored)

Use nitems() of source and destination partition arrays
rather than assuming they are the same size. Zero
destination entries when no source partition available.

No intentional functional change.

Revision 1.122 / (download) - annotate - [select for diffs], Sat Mar 4 21:22:51 2023 UTC (15 months ago) by krw
Branch: MAIN
Changes since 1.121: +4 -4 lines
Diff to previous 1.121 (colored)

Use nitems() in the simple iterations over mbr->mbr_prt[].

No intentional functional change.

Revision 1.121 / (download) - annotate - [select for diffs], Tue Jul 26 14:30:37 2022 UTC (22 months, 2 weeks ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.120: +11 -2 lines
Diff to previous 1.120 (colored)

Allow editing of an MBR of all zeros.

Fallout from regress failure spotted by anton@.

Revision 1.120 / (download) - annotate - [select for diffs], Mon Jul 25 17:45:16 2022 UTC (22 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.119: +21 -1 lines
Diff to previous 1.119 (colored)

Only MBR and GPT structures can be edited by fdisk.

If neither are found, restrict user actions to printing basic
information on the disk, reading the man page, initializing an
MBR or GPT, or terminating fdisk without changing anything.

Feedback on earlier attempt by miod@ and brynet@.

Revision 1.119 / (download) - annotate - [select for diffs], Mon Apr 25 17:10:09 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.118: +3 -17 lines
Diff to previous 1.118 (colored)

Push DISK_[read|write]sectors() down to disk.c local functions
and expose new DISK_[read|write]bytes() functions.

Eliminates many bytes <-> sector i/o dances and makes the code
much easier to understand.

Be a bit more careful to consistently write only bytes that
checksums are calculated over.

No intentional functional change.

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

Wrap some annoyingly long lines.

Revision 1.117 / (download) - annotate - [select for diffs], Fri Feb 4 18:21:33 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.116: +2 -2 lines
Diff to previous 1.116 (colored)

%llu should be enough for anybody, no need to use %lld/(long long) for
uint64_t values.

Revision 1.116 / (download) - annotate - [select for diffs], Fri Feb 4 14:07:56 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.115: +1 -4 lines
Diff to previous 1.115 (colored)

Remove CHS information from internal representation of MBR  partitions. Generate
CHS information as required when writing MBR to disk, editing a partition in CHS
mode or printing MBR.

No intentional functional change.

Revision 1.115 / (download) - annotate - [select for diffs], Fri Jan 21 17:29:24 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.114: +3 -3 lines
Diff to previous 1.114 (colored)

Split PRT_print() into PRT_print_parthdr() and PRT_print_part()
to align with GPT functions. Simplifies logic and eliminates the
magic invocations to print the header.

No functional change.

Revision 1.114 / (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.113: +15 -11 lines
Diff to previous 1.113 (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.113 / (download) - annotate - [select for diffs], Tue Dec 7 14:58:32 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.112: +3 -6 lines
Diff to previous 1.112 (colored)

Don't truncate the default OpenBSD partition at the end of the
last full cylinder. Let it extend to the end of the disk.

Revision 1.112 / (download) - annotate - [select for diffs], Wed Dec 1 22:37:30 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.111: +7 -14 lines
Diff to previous 1.111 (colored)

Remove the MBR_init() "#ifdef defined(__macppc__) ||
defined(__mips__)" chunk that rounded the start of the default
OpenBSD partition to a cylinder boundary. The value has been
immediately re-rounded to a power of 2 block since r1.25 in 2009.

Eliminates wasted space when no /usr/mdec/mbr partition
0 information is available.

'-b' becomes available to architectures other than amd64 and
i386, taking precedence over /usr/mdec/mbr partition 0
information. The latter being present only in macppc and loongson
/usr/mdec/mbr files.

Revision 1.111 / (download) - annotate - [select for diffs], Thu Nov 25 15:40:26 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.110: +4 -6 lines
Diff to previous 1.110 (colored)

Honour /usr/mdec/mbr or -f partition 0 information even outside
of _powerpc__ and __mips__, preventing the possible creation of
MBRs with overlapping partitions 0 and 3.

Don't set bootprt DOSACTIVE flag if no partition 0 information
was provided via /usr/mdec/mbr or -f. Lets octeon fdisk(8) set
DOSACTIVE on the OpenBSD partition in the default MBR like
every other fdisk(8) does.

Revision 1.110 / (download) - annotate - [select for diffs], Sat Nov 20 21:35:52 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.109: +11 -8 lines
Diff to previous 1.109 (colored)

Gather the setup of the initial OpenBSD MBR partition into one
location within MBR_init(), ensuring that MBR_init() creates an
OpenBSD MBR partition only when there is space for it.

No functional change.

Revision 1.109 / (download) - annotate - [select for diffs], Sat Nov 20 18:35:55 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.108: +5 -8 lines
Diff to previous 1.108 (colored)

No need for intermediate 'adj' variable. Add 'disksz'
intermediate variable to make MBR_init() code clearer and lay
more groundwork for upcoming functional enhancements.

No functional change.

Revision 1.108 / (download) - annotate - [select for diffs], Sat Nov 20 15:29:45 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.107: +3 -4 lines
Diff to previous 1.107 (colored)

Sectors-per-cylinder (spc) is a constant value, so make it const
and use it instead of calculating it twice in MBR_init().

No functional change.

Revision 1.107 / (download) - annotate - [select for diffs], Sun Nov 14 17:28:29 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.106: +17 -35 lines
Diff to previous 1.106 (colored)

Calculate initial OpenBSD partition start/size using LBA values
instead of CHS values. Shorter, easier to follow.

No intentional functional change.

Revision 1.106 / (download) - annotate - [select for diffs], Wed Nov 10 13:01:08 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.105: +2 -2 lines
Diff to previous 1.105 (colored)

Set correct prt_flag to 0.

Revision 1.105 / (download) - annotate - [select for diffs], Tue Nov 9 14:02:09 2021 UTC (2 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.104: +46 -39 lines
Diff to previous 1.104 (colored)

Try this again, with (__powerpc__ || __mips__) chunk actually
compiling.

Use a couple of local 'struct prt' variables to make MBR_init()
easier to read.

No functional change.

Revision 1.104 / (download) - annotate - [select for diffs], Tue Nov 9 01:50:11 2021 UTC (2 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.103: +38 -45 lines
Diff to previous 1.103 (colored)

no, that breaks architectures

Revision 1.103 / (download) - annotate - [select for diffs], Mon Nov 8 22:47:47 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.102: +46 -39 lines
Diff to previous 1.102 (colored)

Use a couple of local 'struct prt' variables to make MBR_init()
easier to read.

No functional change.

Revision 1.102 / (download) - annotate - [select for diffs], Fri Oct 29 18:38:19 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.101: +8 -13 lines
Diff to previous 1.101 (colored)

Tweak code to make it clear that MBR_init() uses just the boot code and
partition 0 information from the default MBR.

loongson and macppc provide partition 0 information but no boot code.

amd64, i386, landisk provide boot code but no partition 0 information.

Other arch's get by w/o a default MBR (a.k.a. /usr/mdec/mbr).

No functional change.

Revision 1.101 / (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.100: +1 -3 lines
Diff to previous 1.100 (colored)

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

Revision 1.100 / (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.99: +3 -1 lines
Diff to previous 1.99 (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.99 / (download) - annotate - [select for diffs], Fri Sep 10 15:26:36 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.98: +2 -2 lines
Diff to previous 1.98 (colored)

Stop using NULL as a synonym for "s" (SECTORS). Just use "s".
Remove now pointless NULL check in unit_lookup().

No intentional functional change.

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

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

Revision 1.97 / (download) - annotate - [select for diffs], Sat Aug 7 12:51:30 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.96: +2 -2 lines
Diff to previous 1.96 (colored)

Comment typo 'mmbr' -> 'mbr'.

Revision 1.96 / (download) - annotate - [select for diffs], Fri Aug 6 10:41:31 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.95: +26 -11 lines
Diff to previous 1.95 (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.95 / (download) - annotate - [select for diffs], Mon Jul 26 13:05:14 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.94: +11 -7 lines
Diff to previous 1.94 (colored)

Report write() and ioctl() errors encountered when writing GPT or MBR to disk.

Consolidate GPT/MBR read()/write() operations into DISK_writesectors() and
DISK_readsectors(), producing clearer logic and consistent handling of i/o and
errors.

Add some DPRINTF() and #ifdef DEBUG sections to allow more detailed error
reporting when desired.

Revision 1.94 / (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.93: +2 -76 lines
Diff to previous 1.93 (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.93 / (download) - annotate - [select for diffs], Mon Jul 19 23:24:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.92: +2 -2 lines
Diff to previous 1.92 (colored)

Tweak one comment and nuke a bunch of pointless ones.

Revision 1.92 / (download) - annotate - [select for diffs], Mon Jul 19 19:30:35 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.91: +2 -2 lines
Diff to previous 1.91 (colored)

MBR_protective_mbr() can take a const struct mbr *.

No functional change.

Revision 1.91 / (download) - annotate - [select for diffs], Mon Jul 19 19:23:50 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.90: +8 -5 lines
Diff to previous 1.90 (colored)

An MBR knows (mbr_lba_self) where it is supposed to go, no
need to pass the value to MBR_write().

Let MBR_write() do the translation from struct mbr to the
struct dos_mbr that will be written to the disk. Thus
eliminating unnecessary struct dos_mbr variables and the
parsing thereof.

No intentional functional change.

Revision 1.90 / (download) - annotate - [select for diffs], Mon Jul 19 14:30:08 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.89: +9 -7 lines
Diff to previous 1.89 (colored)

Revert incorrect tweaks to disk geometry calculations and
non '-b' MBR disk initialization.

Detected by bluhm@'s ever vigilant regress testing.

Revision 1.89 / (download) - annotate - [select for diffs], Sun Jul 18 21:40:13 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.88: +2 -2 lines
Diff to previous 1.88 (colored)

Don't save the prt_scyl/prt_ecyl values, change them, use them
and then restore them. Just change/use the saved values and skip
the restoring.

Allows PRT_make() to add 'const' to its struct mbr parameter, and
thus allows MBR_make() to add 'const' to its struct mbr
parameter.

No intentional functional change.

Revision 1.88 / (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.87: +7 -4 lines
Diff to previous 1.87 (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.87 / (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.86: +1 -7 lines
Diff to previous 1.86 (colored)

Nuke a bunch of Capt. Obvious or misleading comments.

No functional change.

Revision 1.86 / (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.85: +8 -14 lines
Diff to previous 1.85 (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.85 / (download) - annotate - [select for diffs], Tue Jul 13 15:03:34 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.84: +8 -8 lines
Diff to previous 1.84 (colored)

Disk sector addresses are normally stored/provided in uint64_t
variables/parameters, not off_t.

Adjust various parameters and variables accordingly. A few missed const's
and verbiage tweaks in passing.

No functional change.

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

Toss 'const' in anywhere the compiler doesn't complain about, thus identifying
places that *should* be const but currently aren't and preventing the rot from
spreading further while those issues are dealt with.

No functional change.

Revision 1.83 / (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.82: +7 -7 lines
Diff to previous 1.82 (colored)

Add 'dk_' prefix to struct disk field names.

No functional change.

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

Add 'prt_' prefix to struct prt field names.

Use 'dp' instead of 'prt' for struct dos_partition *
paramters, and 'prt' instead of 'partn' for struct prt *
parameters.

No functional change.

Revision 1.81 / (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.80: +60 -58 lines
Diff to previous 1.80 (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.80 / (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.79: +19 -19 lines
Diff to previous 1.79 (colored)

Add tabs to make variable declarations easier
to read.

No functional change.

Revision 1.79 / (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.78: +9 -9 lines
Diff to previous 1.78 (colored)

'return' is not a function call.

No functional change.

Revision 1.78 / (download) - annotate - [select for diffs], Sun Jul 4 20:37:11 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.77: +1 -3 lines
Diff to previous 1.77 (colored)

Fix legacy booting.

Don't flag the EFI SYS partition "DOSACTIVE". Leave that status
to the OpenBSD partition. Reverts part of r1.77.

Problem reported and fix tested by Mihai Popescu. Thanks!

Cluebats from deraadt@ and code bisecting by dv@.

ok kettenis@

Revision 1.77 / (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.76: +10 -9 lines
Diff to previous 1.76 (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.76 / (download) - annotate - [select for diffs], Wed Jun 16 15:40:47 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.75: +1 -45 lines
Diff to previous 1.75 (colored)

Ensure that the '-i' command line option and the 'reinit [mbr]'
editing commnd completely remove any existing on-disk GPT header
when writing the MBR.

'-ig'/'reinit gpt' must be used to create GPT format.

Previous interactions between '-i', '-b' and overly clever
'reinit' produced surprising, inconsistent and incorrect
behaviour.

ok deraadt@ kettenis@

Revision 1.75 / (download) - annotate - [select for diffs], Thu Jun 10 15:30:49 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.74: +4 -4 lines
Diff to previous 1.74 (colored)

Shift zeroing of gpt header and partition table to top of
MBR_init() from middle of MBR partition flag tweaking.

No functional change.

Revision 1.74 / (download) - annotate - [select for diffs], Thu Jun 10 15:09:16 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.73: +6 -6 lines
Diff to previous 1.73 (colored)

'i' is a silly name for a daddr_t variable, and could be needed
for a future 'for'. Use 'daddr' instead.

No functional change.

Revision 1.73 / (download) - annotate - [select for diffs], Wed Jun 2 22:44:26 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.72: +2 -2 lines
Diff to previous 1.72 (colored)

Use the same logic in all copies of gpt_chk_mbr(), relaxing the
media length check to allow EFI GPT partitions to be smaller that
the entire disk.

Consistently use GPTSECTOR instead of randomly tossing in some
literal '1's.

ok kettenis@

Revision 1.72 / (download) - annotate - [select for diffs], Thu May 27 14:27:41 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.71: +2 -2 lines
Diff to previous 1.71 (colored)

Relax criteria for recognizing GPT formatted media by allowing the
EFI GPT partition (0xEE) in the protective MBR to be smaller that the
actual size of the media.

This allows GPT disk images dd'ed onto larger physical media to be
recognized by fdisk(8) and the kernel.

Feedback from kettenis@ on various earlier versions.

Revision 1.71 / (download) - annotate - [select for diffs], Fri May 21 19:09:46 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.70: +4 -1 lines
Diff to previous 1.70 (colored)

The protective MBR for GPT partitioning must be at
sector 0. No EBR qualifies.

Revision 1.70 / (download) - annotate - [select for diffs], Fri May 14 21:11:15 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.69: +3 -3 lines
Diff to previous 1.69 (colored)

Whitespace tweaks and a couple of stray u_int* in gpt_chk_mbr().

No intentional functional change.

Revision 1.69 / (download) - annotate - [select for diffs], Fri May 14 15:31:01 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.68: +15 -18 lines
Diff to previous 1.68 (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.68 / (download) - annotate - [select for diffs], Fri May 7 22:15:13 2021 UTC (3 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.67: +6 -6 lines
Diff to previous 1.67 (colored)

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

Revision 1.67 / (download) - annotate - [select for diffs], Thu Sep 1 16:17:46 2016 UTC (7 years, 9 months ago) by krw
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, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.66: +1 -5 lines
Diff to previous 1.66 (colored)

Nuke now unused 'sz' variable.

Revision 1.66 / (download) - annotate - [select for diffs], Thu Sep 1 16:14:51 2016 UTC (7 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.65: +9 -6 lines
Diff to previous 1.65 (colored)

EFI firmware has been encountered that is (from our point of view) confused
about the disk size. Making the protective MBR created by fdisk invalid as
fdisk used the 'correct' disk size.

So just do what MS does and put UINT32_MAX into the EE partition size field,
no matter what the disk size is. Lets tom@'s Dell boot.

ok kettenis@ tom@

Revision 1.65 / (download) - annotate - [select for diffs], Wed Dec 30 17:21:39 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.64: +10 -2 lines
Diff to previous 1.64 (colored)

Revert r1.59's over-enthusiatic MBR zero'ing in MBR_init(). It was
killing the macppc MSDOS partition created by '-i'.

Should fix the macppc install problems reported by Brian Conway on
bugs@. Date of breakage found by rpe@.

Revision 1.64 / (download) - annotate - [select for diffs], Sun Dec 27 20:39:51 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.63: +47 -19 lines
Diff to previous 1.63 (colored)

Use 'standard' gpt_chk_mbr() to check for protective MBR.

Revision 1.63 / (download) - annotate - [select for diffs], Thu Nov 19 16:14:08 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.62: +3 -8 lines
Diff to previous 1.62 (colored)

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.62 / (download) - annotate - [select for diffs], Wed Nov 18 17:09:26 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

Change #include <memory.h> to #include <string.h>

Revision 1.61 / (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.60: +1 -23 lines
Diff to previous 1.60 (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.60 / (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.59: +14 -16 lines
Diff to previous 1.59 (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.59 / (download) - annotate - [select for diffs], Thu Nov 12 23:49:37 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.58: +6 -7 lines
Diff to previous 1.58 (colored)

'reinit mbr' must zero existing MBR and GPT partition information
before constructing default MBR.

Change last bzero() to memset().

Revision 1.58 / (download) - annotate - [select for diffs], Thu Nov 12 21:31:36 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.57: +3 -1 lines
Diff to previous 1.57 (colored)

Refresh the in-kernel copy of the disklabel from the disk *after* writing
the new GPT.

Revision 1.57 / (download) - annotate - [select for diffs], Tue Nov 10 18:07:12 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.56: +9 -2 lines
Diff to previous 1.56 (colored)

Use UINT32_MAX for the size of the EFI System partition on disks larger than
UINT32_MAX sectors. i.e. don't use the truncated value aligned to cylinder
size that we use for 'real' MBR partitions.

Makes GPT on large disks work.

Problem found & fix tested by naddy@.

Revision 1.56 / (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.55: +31 -1 lines
Diff to previous 1.55 (colored)

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

Revision 1.55 / (download) - annotate - [select for diffs], Mon Oct 5 01:39:08 2015 UTC (8 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.54: +1 -7 lines
Diff to previous 1.54 (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.54 / (download) - annotate - [select for diffs], Fri Sep 4 19:02:49 2015 UTC (8 years, 9 months ago) by kettenis
Branch: MAIN
Changes since 1.53: +15 -1 lines
Diff to previous 1.53 (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.53 / (download) - annotate - [select for diffs], Thu Aug 27 20:58:27 2015 UTC (8 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.52: +2 -2 lines
Diff to previous 1.52 (colored)

Nuke some trailing whitespace that keeps coming back.

Revision 1.52 / (download) - annotate - [select for diffs], Thu Apr 2 18:00:55 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.51: +2 -1 lines
Diff to previous 1.51 (colored)

Don't printf("offset: ...) before every call to MBR_print(). Do it
once inside MBR_print().

Revision 1.51 / (download) - annotate - [select for diffs], Mon Mar 30 17:11:49 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.50: +8 -8 lines
Diff to previous 1.50 (colored)

Even better -- readsector() and writesector() become DISK_readsector() and
DISK_writesector() and live in disk.[ch].

Revision 1.50 / (download) - annotate - [select for diffs], Sun Mar 29 21:16:39 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.49: +8 -63 lines
Diff to previous 1.49 (colored)

Rename MBR_readsector() and MBR_writesector() to just readsector()
and writesector(). Move them to misc.[ch]. Soon to be used for more
than MBR reading/writing.

No intentional functional change.

Revision 1.49 / (download) - annotate - [select for diffs], Sun Mar 29 19:11:23 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.48: +3 -3 lines
Diff to previous 1.48 (colored)

A couple of letoh64() to make GPTSIGNATURE test work better on
non-amd64 boxen.

Revision 1.48 / (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.47: +3 -1 lines
Diff to previous 1.47 (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.47 / (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.46: +20 -21 lines
Diff to previous 1.46 (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.46 / (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.45: +4 -4 lines
Diff to previous 1.45 (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.45 / (download) - annotate - [select for diffs], Sat Mar 14 16:58:00 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.44: +1 -2 lines
Diff to previous 1.44 (colored)

Zap unused variable.

Diff from chl@. Committing now so it doesn't get lost in upcoming
megachurn.

Revision 1.44 / (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.43: +11 -20 lines
Diff to previous 1.43 (colored)

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

With the permission of Toby.

ok deraadt@

Revision 1.43 / (download) - annotate - [select for diffs], Tue Feb 10 01:20:10 2015 UTC (9 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.42: +105 -47 lines
Diff to previous 1.42 (colored)

If 'write' is issued after a 'reinit' command, and the MBR to be
written does not contain an EFI partition, zap any GPT signature
found on the 2nd (LBA 1) and last sectors on the disk. The install
script uses this sequence.

This is a temporary workaround until more GPT support is imported
post-5.7.

Should fix at least some machines who insist on using the GPT even
after we have overritten the 'protective' MBR.

ok deraadt@ tedu@ beck@ millert@

Revision 1.42 / (download) - annotate - [select for diffs], Fri Jan 16 06:39:57 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.41: +2 -3 lines
Diff to previous 1.41 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.41 / (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.40: +23 -2 lines
Diff to previous 1.40 (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.40 / (download) - annotate - [select for diffs], Wed May 21 15:55:19 2014 UTC (10 years ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.39: +10 -9 lines
Diff to previous 1.39 (colored)

Fix 'fdisk -u', a.k.a. MBR_pcopy(), on sparc64 and possibly others.

gcc's built-in/in-lined memcpy() can't copy elements of a struct
dos_partiton array from inside the __packed struct dos_mbr into an
'unpacked' local variable. But copying the whole array works fine. Be
consistant and use the same idiom in both places the partition table
is parsed.

Leave the landisk workaround/hack in place until it can be confirmed
it is no longer needed.

ok martynas@ after many alternatives crashed and burned.

Revision 1.39 / (download) - annotate - [select for diffs], Mon Mar 31 19:50:52 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.38: +15 -7 lines
Diff to previous 1.38 (colored)

Nuke [get|put][short|long] and just use letoh[16|32] and
htole[16|32]. This is made possible by a) copying unaligned data
(struct dos_partition's) into properly aligned structs and accessing
the fields of the same; and b) realizing that gcc is smart enough to
access fields in packed struct's *if* it knows it is accessing a
packed struct. Even sparc64 finally gave a thumbs up.

After several attempts and feedback from deraadt@ and dlg@, it looks
good to deraadt@.

Revision 1.38 / (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.37: +3 -5 lines
Diff to previous 1.37 (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.37 / (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.36: +6 -6 lines
Diff to previous 1.36 (colored)

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

Revision 1.36 / (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.35: +6 -6 lines
Diff to previous 1.35 (colored)

Revert last -- broke building snaps.

Revision 1.35 / (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.34: +6 -6 lines
Diff to previous 1.34 (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.34 / (download) - annotate - [select for diffs], Sun Mar 9 22:25:06 2014 UTC (10 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.33: +30 -33 lines
Diff to previous 1.33 (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.33 / (download) - annotate - [select for diffs], Fri Mar 7 21:56:13 2014 UTC (10 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.32: +8 -7 lines
Diff to previous 1.32 (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.32 / (download) - annotate - [select for diffs], Wed Feb 5 03:51:07 2014 UTC (10 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.31: +2 -2 lines
Diff to previous 1.31 (colored)

Always set the signature to DOSMBR_SIGNATURE when writing a MBR to
disk. This means skipping the '(U)pdate' command after editing
the MBR will still produce something disklabel(8) will respect in
the morning.

Problem noted by David Vasek.

ok jsing@ toby@. Moral support halex@.

Revision 1.31 / (download) - annotate - [select for diffs], Tue Oct 8 15:45:43 2013 UTC (10 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.30: +3 -4 lines
Diff to previous 1.30 (colored)

Keep disk sector calcuations in u_int64_t as long as possible, and
avoid using a daddr_t variable to hold a disk sector value even
temporarily.

No intentional functional change.

Revision 1.30 / (download) - annotate - [select for diffs], Tue Jun 11 16:42:04 2013 UTC (11 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.29: +2 -2 lines
Diff to previous 1.29 (colored)

final removal of daddr64_t.  daddr_t has been 64 bit for a long enough
test period; i think 3 years ago the last bugs fell out.
ok otto beck others

Revision 1.29 / (download) - annotate - [select for diffs], Thu Mar 21 18:45:58 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.28: +7 -8 lines
Diff to previous 1.28 (colored)

more substantial include cleanup

Revision 1.28 / (download) - annotate - [select for diffs], Wed Apr 4 13:14:44 2012 UTC (12 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.27: +10 -4 lines
Diff to previous 1.27 (colored)

Don't 'reserve' a head/track if there is only only 1 head and 1
cylinder.  If there is only one head but multiple cylinders reserve
one cylinder. Prevents nonsense MBR being created on scsi attached
floppies, which have a 'geometry' of 1/1/2888. No change to less
pathological cases.

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jun 20 19:10:41 2011 UTC (12 years, 11 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored)

MBR_read() can be reading from a file as well as a raw partition.
And files can be smaller (e.g. 512 bytes like /usr/mdec/mbr) than
a disk sector (e.g. 4096 bytes on pirofti's external disk drive).

So relax the length test on the read() result to < DEV_BSIZE (the
amount of data we actually want) instead of < secsize (the minimum
size that read() will accept).

'fdisk -e' and 'fdisk -i' now work on devices with sector sizes
greater than DEV_BSIZE.

Revision 1.26 / (download) - annotate - [select for diffs], Mon Feb 21 19:26:13 2011 UTC (13 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.25: +5 -3 lines
Diff to previous 1.25 (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.25 / (download) - annotate - [select for diffs], Wed Jun 30 22:53:41 2010 UTC (13 years, 11 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.24: +14 -1 lines
Diff to previous 1.24 (colored)

Make 'fdisk -i' start the OpenBSD partition on a power of 2 512-byte
block boundary. In most modern (i.e. 'faked' geometry) situations
this will start it at (0-based) block[64] rather than block[63] as
now. This should help performance on disks which really have 4K
sectors but report 512-byte sectors.

Power of 2 idea from deraadt@.

ok toby@ deraadt@

Revision 1.24 / (download) - annotate - [select for diffs], Sun Feb 8 18:03:18 2009 UTC (15 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.23: +2 -3 lines
Diff to previous 1.23 (colored)

Eliminate excessive verbiage for 'fdisk -i' and 'fdisk -u'. Especially
the multi-line banner announcing that the MBR is being changed.
Also the listing of the partition table in 'fdisk -u'. Display a
consistant message when the MBR is written.

While here cleanup and shrink code without changing any semantics.
Started with a diff posted on tech@ by Tobias Ulmer.

"I like it" marco@ ok jsing@

Revision 1.23 / (download) - annotate - [select for diffs], Sun Dec 10 19:19:32 2006 UTC (17 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.22: +50 -11 lines
Diff to previous 1.22 (colored)

Read/write device sectors rather than assuming sector size ==
DEV_BSIZE. Simply extract/insert the desired MBR from/into the first
DEV_BSIZE bytes of the sector.  Makes fdisk work with devices having a
sector size different from DEV_BSIZE (512 bytes). e.g.  2048 byte
sector MP3 devices. Original diff from weingart@.

ok pedro@ deraadt@ weingart@

Revision 1.22 / (download) - annotate - [select for diffs], Mon May 29 05:09:36 2006 UTC (18 years ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.21: +20 -9 lines
Diff to previous 1.21 (colored)

Change MBR_read() and MBR_write() to return -1 on error and set
errno = EIO for short reads.  This makes it easier to check for
read and write errors.  Much patient tutoring by weingart@, deraadt@,
and cloder@.

Correctly use ssize_t to store read(2) and write(2) return values.

No functional change, since MBR_read() and MBR_write() return values
aren't currently checked.

OK deraadt@

Revision 1.21 / (download) - annotate - [select for diffs], Sat Sep 18 23:22:05 2004 UTC (19 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.20: +7 -8 lines
Diff to previous 1.20 (colored)

some delinting; ok otto

Revision 1.20 / (download) - annotate - [select for diffs], Tue Jul 13 06:00:33 2004 UTC (19 years, 11 months ago) by tom
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.19: +4 -4 lines
Diff to previous 1.19 (colored)

Remove unused argument 'int pn' to PRT_fix_CHS().  The 'int pn'
argument to PRT_parse() then becomes unused, so remove that too.

ok henning@, otto@

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jul 29 18:38:35 2003 UTC (20 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

spaces

Revision 1.18 / (download) - annotate - [select for diffs], Wed Jun 11 06:22:12 2003 UTC (21 years ago) by deraadt
Branch: MAIN
Changes since 1.17: +8 -27 lines
Diff to previous 1.17 (colored)

ansification

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

Nuke terms 3 & 4.

Revision 1.16 / (download) - annotate - [select for diffs], Sun Jun 9 08:13:05 2002 UTC (22 years ago) by todd
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.15: +7 -7 lines
Diff to previous 1.15 (colored)

rm trailing whitespace

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jan 18 08:38:26 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.14: +6 -5 lines
Diff to previous 1.14 (colored)

Allow size values to be displayed in the user's choice of units.
Idea borrowed from disklabel. i.e. Users can now type "print M"
and be rewarded with partition sizes in Megs

Revision 1.14 / (download) - annotate - [select for diffs], Fri Jan 4 08:35:06 2002 UTC (22 years, 5 months ago) by kjell
Branch: MAIN
Changes since 1.13: +3 -7 lines
Diff to previous 1.13 (colored)

Remove references to the NT serial number. Now the first 0x1be
bytes of the MBR are treated as code for the purposes of the
(u)pdate command. This is consistent with the new -u flag.
This means boot managers like BootEasy can now be written
out correctly. Note that rewriting the MBR now whacks the
NT serial number - a behavior that is consistent with
the DOS FDISK /MBR.

Revision 1.13 / (download) - annotate - [select for diffs], Sat Dec 15 02:12:26 2001 UTC (22 years, 5 months ago) by kjell
Branch: MAIN
Changes since 1.12: +27 -1 lines
Diff to previous 1.12 (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.12 / (download) - annotate - [select for diffs], Sun Jan 28 00:51:46 2001 UTC (23 years, 4 months ago) by weingart
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.11: +7 -2 lines
Diff to previous 1.11 (colored)

Quick -Wall fixes, ok niklas@, aaron@

Revision 1.11 / (download) - annotate - [select for diffs], Fri Jul 7 13:37:00 2000 UTC (23 years, 11 months ago) by rahnds
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

On the last commit to fdisk when the prototypes to PRT_fix_CHS and PRT_fix_BN
were made, some code in an ifdefed section was missed. Update that
section of code to have the appropriate added parameter.

Revision 1.10 / (download) - annotate - [select for diffs], Sat Jul 1 21:49:12 2000 UTC (23 years, 11 months ago) by mickey
Branch: MAIN
Changes since 1.9: +3 -4 lines
Diff to previous 1.9 (colored)

be more verbose when warning for partition errors,
print partition number in the message.

Revision 1.9 / (download) - annotate - [select for diffs], Sat Aug 21 22:49:25 1999 UTC (24 years, 9 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

MIPS boxes that use fdisk need an MS-DOS partition

Revision 1.8 / (download) - annotate - [select for diffs], Tue Aug 10 23:10:16 1999 UTC (24 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +3 -1 lines
Diff to previous 1.7 (colored)

call DIOCRLDINFO after writing an MBR

Revision 1.7 / (download) - annotate - [select for diffs], Mon Sep 14 03:54:35 1998 UTC (25 years, 9 months ago) by rahnds
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.6: +46 -3 lines
Diff to previous 1.6 (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.6 / (download) - annotate - [select for diffs], Tue Oct 21 22:49:33 1997 UTC (26 years, 7 months ago) by provos
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.5: +10 -5 lines
Diff to previous 1.5 (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.5 / (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.4: +7 -7 lines
Diff to previous 1.4 (colored)

indent

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

indent

Revision 1.3 / (download) - annotate - [select for diffs], Thu Oct 16 01:47:11 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +3 -4 lines
Diff to previous 1.2 (colored)

a bunch of improvements by weingart & I

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

ID in the first line w/ tabs

Revision 1.1 / (download) - annotate - [select for diffs], Mon Sep 29 22:58:16 1997 UTC (26 years, 8 months ago) by weingart
Branch: MAIN

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.

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.