OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.44 / (download) - annotate - [select for diffs], Tue Jul 26 14:30:37 2022 UTC (22 months, 1 week 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.43: +2 -1 lines
Diff to previous 1.43 (colored)

Allow editing of an MBR of all zeros.

Fallout from regress failure spotted by anton@.

Revision 1.43 / (download) - annotate - [select for diffs], Mon Jul 25 17:45:16 2022 UTC (22 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.42: +2 -1 lines
Diff to previous 1.42 (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.42 / (download) - annotate - [select for diffs], Mon Oct 25 13:51:25 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.41: +1 -6 lines
Diff to previous 1.41 (colored)

Nuke a bunch of pointless #ifndef _<.h file>/#endif guards.

Revision 1.41 / (download) - annotate - [select for diffs], Fri Aug 6 10:41:31 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.40: +2 -5 lines
Diff to previous 1.40 (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.40 / (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.39: +1 -3 lines
Diff to previous 1.39 (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.39 / (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.38: +2 -2 lines
Diff to previous 1.38 (colored)

MBR_protective_mbr() can take a const struct mbr *.

No functional change.

Revision 1.38 / (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.37: +2 -2 lines
Diff to previous 1.37 (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.37 / (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.36: +2 -2 lines
Diff to previous 1.36 (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.36 / (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.35: +2 -2 lines
Diff to previous 1.35 (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.35 / (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.34: +7 -7 lines
Diff to previous 1.34 (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.34 / (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.33: +6 -5 lines
Diff to previous 1.33 (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.33 / (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.32: +6 -6 lines
Diff to previous 1.32 (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.32 / (download) - annotate - [select for diffs], Sun Jul 11 13:23:18 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.31: +15 -15 lines
Diff to previous 1.31 (colored)

Add tabs to make struct definitions and function prototypes easier
to read.

No functional change.

Revision 1.31 / (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.30: +1 -2 lines
Diff to previous 1.30 (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.30 / (download) - annotate - [select for diffs], Thu May 20 14:27:14 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.29: +1 -2 lines
Diff to previous 1.29 (colored)

Nuke duplicate declaration of MBR_init_GPT().

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

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

Revision 1.28 / (download) - annotate - [select for diffs], Wed Nov 18 15:31:15 2015 UTC (8 years, 6 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, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.27: +1 -2 lines
Diff to previous 1.27 (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.27 / (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.26: +4 -4 lines
Diff to previous 1.26 (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.26 / (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.25: +2 -1 lines
Diff to previous 1.25 (colored)

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

Revision 1.25 / (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.24: +2 -1 lines
Diff to previous 1.24 (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.24 / (download) - annotate - [select for diffs], Wed Aug 19 17:52:10 2015 UTC (8 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.23: +2 -1 lines
Diff to previous 1.23 (colored)

Missing prototypes. Noted by deraadt@

Revision 1.23 / (download) - annotate - [select for diffs], Mon Mar 30 00:39:42 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.22: +1 -2 lines
Diff to previous 1.22 (colored)

Nuke declaration of unused and non-existant function MBR_print_disk().

Revision 1.22 / (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.21: +1 -3 lines
Diff to previous 1.21 (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.21 / (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.20: +3 -1 lines
Diff to previous 1.20 (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.20 / (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.19: +4 -4 lines
Diff to previous 1.19 (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.19 / (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.18: +11 -20 lines
Diff to previous 1.18 (colored)

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

With the permission of Toby.

ok deraadt@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Feb 10 01:20:10 2015 UTC (9 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.17: +4 -1 lines
Diff to previous 1.17 (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.17 / (download) - annotate - [select for diffs], Sun Mar 23 13:56:24 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Change struct mbr signature field type from 'unsigned short' to
'u_int16_t' to be consistant with disklabel.h's struct dos_mbr.

Revision 1.16 / (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.15: +1 -6 lines
Diff to previous 1.15 (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.15 / (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.14: +6 -15 lines
Diff to previous 1.14 (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.14 / (download) - annotate - [select for diffs], Sat Mar 8 01:54:14 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.13: +3 -7 lines
Diff to previous 1.13 (colored)

It's silly to check at compile time for DEV_BSIZE == 512.

ok deraadt@ with gritted teeth on keeping <sys/param.h> for now.

Revision 1.13 / (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.12: +9 -9 lines
Diff to previous 1.12 (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.12 / (download) - annotate - [select for diffs], Thu Mar 21 18:37:07 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.11: +2 -2 lines
Diff to previous 1.11 (colored)

I don't feel great about adding an include for <sys/param.h>, but I feel
great for removing an include of <machine/param.h>
This needs further cleanup if someone has time.

Revision 1.11 / (download) - annotate - [select for diffs], Tue Jun 3 01:13:19 2003 UTC (21 years ago) by weingart
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, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, 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, OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6, OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.10: +1 -6 lines
Diff to previous 1.10 (colored)

Nuke terms 3 & 4.

Revision 1.10 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:34 2002 UTC (22 years, 3 months ago) by millert
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.9: +9 -9 lines
Diff to previous 1.9 (colored)

Part one of userland __P removal.  Done with a simple regexp with some minor hand editing to make comments line up correctly.  Another pass is forthcoming that handles the cases that could not be done automatically.

Revision 1.9 / (download) - annotate - [select for diffs], Fri Jan 18 08:38:26 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (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.8 / (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.7: +2 -6 lines
Diff to previous 1.7 (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.7 / (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.6: +2 -1 lines
Diff to previous 1.6 (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.6 / (download) - annotate - [select for diffs], Sun Aug 12 12:03:01 2001 UTC (22 years, 9 months ago) by heko
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

#(endif|else) foo is incorrect, make it #endif /* foo */
deraadt@ ok

Revision 1.5 / (download) - annotate - [select for diffs], Sun Jan 28 00:51:47 2001 UTC (23 years, 4 months ago) by weingart
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.4: +3 -2 lines
Diff to previous 1.4 (colored)

Quick -Wall fixes, ok niklas@, aaron@

Revision 1.4 / (download) - annotate - [select for diffs], Mon Sep 14 03:54:35 1998 UTC (25 years, 8 months ago) by rahnds
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (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.3 / (download) - annotate - [select for diffs], Tue Oct 21 22:49:34 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.2: +4 -2 lines
Diff to previous 1.2 (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.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:17 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.