OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.164 / (download) - annotate - [select for diffs], Mon Jun 19 23:11:57 2023 UTC (11 months, 2 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.163: +2 -3 lines
Diff to previous 1.163 (colored)

"%-Ns\n" is more appropriately "%s\n" to avoid adding extraneous
blanks to the end of the line.

Unexpected line wrapping noticed by kettenis@, cause spotted by deraadt@

Nuke an unused variable in passing.

Revision 1.163 / (download) - annotate - [select for diffs], Sun May 21 17:29:33 2023 UTC (12 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.162: +28 -20 lines
Diff to previous 1.162 (colored)

If an MBR partition start or end can be represented by CHS, set
both CHS and LBA values in the MBR partition.

Restores pre-7.0 initialization of MBR partition start/end, using
slightly less opaque code that retains the slightly different
initialization required by GPT protective MBR's.

Fixes booting from disks >8G on systems where the BIOS uses CHS.

Encountered by Paul de Weerd on his Alix.2 using BIOS 0.99.

Much diagnosis and testing by Paul of various iterations. Thanks!

Revision 1.162 / (download) - annotate - [select for diffs], Wed May 17 12:59:37 2023 UTC (12 months, 3 weeks ago) by krw
Branch: MAIN
Changes since 1.161: +3 -3 lines
Diff to previous 1.161 (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.161 / (download) - annotate - [select for diffs], Wed May 10 13:45:49 2023 UTC (13 months ago) by krw
Branch: MAIN
Changes since 1.160: +2 -2 lines
Diff to previous 1.160 (colored)

Display correct type name for Microsoft basic data GPT
partitions. Inadvertantly lost in transition to new menu logic.

Revision 1.160 / (download) - annotate - [select for diffs], Wed Apr 12 13:11:37 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.159: +12 -22 lines
Diff to previous 1.159 (colored)

Simplify code by folding uuid_attr() into PRT_protected_uuid().

No functional change.

Revision 1.159 / (download) - annotate - [select for diffs], Wed Apr 12 12:35:30 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.158: +8 -12 lines
Diff to previous 1.158 (colored)

Clarify logic in PRT_uuid_to_menudflt() by using find_gpt_menuitem().

No functional change.

Revision 1.158 / (download) - annotate - [select for diffs], Tue Apr 11 21:14:19 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.157: +43 -13 lines
Diff to previous 1.157 (colored)

Abstract find_[gpt|mbr]_menuitem() to simplify code and
prepare for future uses.

No functional change.

Revision 1.157 / (download) - annotate - [select for diffs], Tue Apr 11 17:26:59 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.156: +7 -11 lines
Diff to previous 1.156 (colored)

Simplify code by passing pointers to the appropriate type to
find_gpt_desc() and find_mbr_desc().

No functional change.

Revision 1.156 / (download) - annotate - [select for diffs], Tue Apr 11 16:34:51 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.155: +28 -26 lines
Diff to previous 1.155 (colored)

Shuffle mbr and gpt function prototypes and declarations together.

No functional change.

Revision 1.155 / (download) - annotate - [select for diffs], Mon Apr 10 19:44:43 2023 UTC (13 months, 4 weeks ago) by krw
Branch: MAIN
Changes since 1.154: +2 -2 lines
Diff to previous 1.154 (colored)

Make GPT display of menu hex octet the same as the MBR display.
i.e.  two digits.

Revision 1.154 / (download) - annotate - [select for diffs], Sun Apr 9 17:19:59 2023 UTC (14 months ago) by krw
Branch: MAIN
Changes since 1.153: +22 -23 lines
Diff to previous 1.153 (colored)

Refactor and simplify GPT menu selection logic.

No intentional functional change.

Revision 1.153 / (download) - annotate - [select for diffs], Sat Apr 8 15:25:47 2023 UTC (14 months ago) by krw
Branch: MAIN
Changes since 1.152: +5 -5 lines
Diff to previous 1.152 (colored)

A bit more guid vs uuid naming consistency.

No functional change.

Revision 1.152 / (download) - annotate - [select for diffs], Fri Apr 7 14:42:51 2023 UTC (14 months ago) by krw
Branch: MAIN
Changes since 1.151: +78 -52 lines
Diff to previous 1.151 (colored)

Add helper functions find_mbr_desc() and find_gpt_desc() to allow
checking mbr_type[N].mt_desc and gpt_type[N].gt_desc before using
name on menu when printing out partition tables.

Tweak logic in find_mbr_type() and find_gpt_type() to be a bit
more paranoid.

Tweak function/variable names to be more in line to usage.

No functional change as all mt_desc and gt_desc are currently
NULL.

Revision 1.151 / (download) - annotate - [select for diffs], Wed Apr 5 14:07:08 2023 UTC (14 months ago) by krw
Branch: MAIN
Changes since 1.150: +400 -1 lines
Diff to previous 1.150 (colored)

Add (inside #if 0 blocks) #define's and gpt_types[] entries for
all the GPT partition types known to mankind. a.k.a. Wikipedia,
Linux, and various BSD's.

Makes it easier to discuss/add/remove/check GUID's known to
fdisk(8).

No functional change.

Revision 1.150 / (download) - annotate - [select for diffs], Tue Apr 4 21:43:06 2023 UTC (14 months ago) by krw
Branch: MAIN
Changes since 1.149: +28 -69 lines
Diff to previous 1.149 (colored)

Adopt a more compact idiom when initializing gpt_types[]. Group
entries with attributes together.

No intentional functional change.

Revision 1.149 / (download) - annotate - [select for diffs], Sun Apr 2 18:44:13 2023 UTC (14 months, 1 week ago) by miod
Branch: MAIN
Changes since 1.148: +25 -25 lines
Diff to previous 1.148 (colored)

Use #define instead of `char * const' for the repeated GUID strings. Ugly,
but restores compilability with older compilers such as gcc.

No intentional functional change.

Revision 1.148 / (download) - annotate - [select for diffs], Sat Apr 1 14:18:29 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.147: +70 -48 lines
Diff to previous 1.147 (colored)

Use char * const for the rest of the repeated GUID strings. More
readable, less prone to typos.

No intentional functional change.

Revision 1.147 / (download) - annotate - [select for diffs], Fri Mar 31 19:12:32 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.146: +378 -204 lines
Diff to previous 1.146 (colored)

Refactor partition type menu code, disentangling mbr and gpt
partition types from menu building and display.

Some GPT partition names change to match their MBR bretheren.

No intentional functional change.

Revision 1.146 / (download) - annotate - [select for diffs], Fri Mar 31 14:41:08 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.145: +2 -2 lines
Diff to previous 1.145 (colored)

Oops. Missed eliminating unneeded double quotes in previous.

Revision 1.145 / (download) - annotate - [select for diffs], Fri Mar 31 13:11:41 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.144: +5 -7 lines
Diff to previous 1.144 (colored)

Be more consistent in function naming. Functions taking or
returning struct uuid's use 'uuid' in their names.

Lengthen a pointlessly short line.

No functional change.

Revision 1.144 / (download) - annotate - [select for diffs], Thu Mar 30 22:53:39 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.143: +5 -6 lines
Diff to previous 1.143 (colored)

Use 'char * const' instead of #define for repeated
GUID strings. Consistently use strcasecmp() when comparing
GUID's, allowing use of simple 'char *' for gt_guid.

No intentional functional change.

Revision 1.143 / (download) - annotate - [select for diffs], Thu Mar 30 14:38:26 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.142: +7 -11 lines
Diff to previous 1.142 (colored)

Remove needless memset() call, 'entries' variable and
limit check in PRT_menuid_to_guid().

No functional change.

Revision 1.142 / (download) - annotate - [select for diffs], Wed Mar 29 19:34:49 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.141: +8 -8 lines
Diff to previous 1.141 (colored)

Change 'type' to 'menuid' in various struct's, functions and
variables related to gpt partitions. Makes it clear that there is
no required tie between mbr partition types and gpt partition
types.

No functional change.

Revision 1.141 / (download) - annotate - [select for diffs], Wed Mar 29 15:55:34 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.140: +2 -2 lines
Diff to previous 1.140 (colored)

No need to assume a nil GUID can be found at gpt_types[0]. Just
use uuid_create_nil().

No functional change.

Revision 1.140 / (download) - annotate - [select for diffs], Wed Mar 29 14:20:50 2023 UTC (14 months, 1 week ago) by krw
Branch: MAIN
Changes since 1.139: +2 -2 lines
Diff to previous 1.139 (colored)

Simplify code by having PRT_uuid_to_type() return -1 when
no type can be found. 0 is a valid type!

No functional change.

Revision 1.139 / (download) - annotate - [select for diffs], Sun Mar 26 16:23:58 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.138: +7 -3 lines
Diff to previous 1.138 (colored)

Pass lbuf/lbuflen to PRT_print_[mbr|gpt]_menu() to allow changes
to the original input. Just zap it for now.

No functional change.

Revision 1.138 / (download) - annotate - [select for diffs], Sun Mar 26 13:12:33 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.137: +5 -4 lines
Diff to previous 1.137 (colored)

Add EFI_SYSTEM_PARTITION_GUID #define and use it to check for
protection.

No functional change.

Revision 1.137 / (download) - annotate - [select for diffs], Sun Mar 26 12:19:54 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.136: +16 -13 lines
Diff to previous 1.136 (colored)

Add MICROSOFT_BASIC_DATA_GUID #define to make clear what menu
items result in the same GUID. Easier to spot and more resistant
to simple typos in a 36 character hex string.

No functional change.

Revision 1.136 / (download) - annotate - [select for diffs], Sat Mar 25 22:00:28 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.135: +18 -1 lines
Diff to previous 1.135 (colored)

Add comments documenting possible sources for MBR partition types
and GPT partition GUIDs.

No functional change.

Revision 1.135 / (download) - annotate - [select for diffs], Sat Mar 25 19:37:34 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.134: +10 -9 lines
Diff to previous 1.134 (colored)

Rename ascii_id() find_mbr_type(), make it a bit more like its
sibling find_gpt_type(), tweaking PRT_print_part() as needed.

No functional change.

Revision 1.134 / (download) - annotate - [select for diffs], Sat Mar 25 15:58:44 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.133: +11 -13 lines
Diff to previous 1.133 (colored)

Make *_name fields char * instead of char[]. Specify desired
width of output in printf() rather than "%-*s" and sizeof(name) +
1.  Clearer, may even save some bytes as many names are shorter
than the max.

Rename PRT_print_mbrtypes() to PRT_print_mbrmenu() and
PRT_print_gpttypes() to PRT_print_gptmenu() to remove implied
completeness of list presented in menu.

No functional change.

Revision 1.133 / (download) - annotate - [select for diffs], Sat Mar 25 15:05:45 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.132: +12 -12 lines
Diff to previous 1.132 (colored)

Rename *_sname fields/functions to *_name to remove implied
shortness of the names.

No functional change.

Revision 1.132 / (download) - annotate - [select for diffs], Mon Mar 6 17:42:39 2023 UTC (15 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.131: +4 -2 lines
Diff to previous 1.131 (colored)

Use GPT_UUID_NBSD_UFS, not GPT_UUID_FBSD_DATA, for NetBSD GPT
partition entries.

Add GPT_UUID_LEGACY_MBR entry to list of known partition id's as
it is defined in the UEFI Standard.

Revision 1.131 / (download) - annotate - [select for diffs], Mon Aug 29 07:19:14 2022 UTC (21 months, 1 week ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.130: +8 -1 lines
Diff to previous 1.130 (colored)

Print warning when an MBR partition starts or extends past the
end of the device the MBR is currently inhabiting.

Prompted by some interesting MBR's from France, verbiage
suggestion from deraadt@, ok miod@

Revision 1.130 / (download) - annotate - [select for diffs], Sun May 8 18:01:23 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.129: +29 -29 lines
Diff to previous 1.129 (colored)

Rename gt_protected field of struct gpt_type to gt_attr and
#define GTATTR_PROTECT and GTATTR_PROTECT_EFISYS as bits in it.

Use GTATTR_PROTECT to replace the magic value of '1' indicating
the partition is protected. Use GTATTR_PROTECT_EFISYS to replace
hack of checking for "APFS" string in the names of partitions
that want the EFI System (a.k.a. 0xEF) partition to be preserved.

More flexible and easier to extend protections to new partition
types or add new attributes to partition types.

No intentional functional change.

Revision 1.129 / (download) - annotate - [select for diffs], Sun May 8 13:33:01 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.128: +109 -75 lines
Diff to previous 1.128 (colored)

Shuffle local helper function declarations and definitions into
one easy to find spot. Wrap the long lines of gpt_types[] to
make room for future expansion.

No functional change.

Revision 1.128 / (download) - annotate - [select for diffs], Sat May 7 11:45:36 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.127: +10 -38 lines
Diff to previous 1.127 (colored)

Now that the internal versions of GPT partitions are host-endian,
simplify PRT_protected_guid() by comparing GUID's with
uuid_compare() rather than converting them to strings and using
strncmp().

Further clarify logic by doing the EFI Sys dance only if
the GUID being tested is not marked as protected.

No intentional functional change.

Revision 1.127 / (download) - annotate - [select for diffs], Fri May 6 23:53:43 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.126: +6 -6 lines
Diff to previous 1.126 (colored)

Rename PRT_uuid_to_[protection|typename] to PRT_uuid_to_[protected|sname],
and PRT_type_to_uuid() to PRT_type_to_guid() so the names clearly match
the field names being searched for.

No intentional functional change.

Revision 1.126 / (download) - annotate - [select for diffs], Fri May 6 14:22:49 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.125: +15 -10 lines
Diff to previous 1.125 (colored)

When printing the GPT table, display "Microsoft basic data" instead of
"FAT12" for partition types that are mapped to GPT_UUID_MSDOS.

No intentional functional change.

Revision 1.125 / (download) - annotate - [select for diffs], Tue May 3 11:48:47 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.124: +150 -154 lines
Diff to previous 1.124 (colored)

Rework display of partition types, removing unnecessary trailing
blanks in the arrays of type names, simplifying the code and
making better use of printf().

Along the way discover that "APFS Recovery" fits, so nuke the
annoying "AFPS Recovry" contraction.

No intentional functional change.

Some "APFS Recovery" nits pointed out by jsg@

Revision 1.124 / (download) - annotate - [select for diffs], Thu Apr 28 13:22:19 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.123: +4 -4 lines
Diff to previous 1.123 (colored)

Convert the internal GPT partition entries into host-endian form
on input/initialization and back to little-endian when writing to
disk.

Easier to read the code when letoh*() and uuid_[enc|dec]_*
invocations are minimized.

No intentional functional change.

ok jmatthew@

Revision 1.123 / (download) - annotate - [select for diffs], Mon Apr 18 17:32:16 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.122: +2 -2 lines
Diff to previous 1.122 (colored)

Convert the GPT header read from disk into a host-endian version,
and then back to little-endian when writing to disk.

Reduces the number of invocations of the letoh*() and htole*()
functions by 90 or so. Also makes that code much easier to read.

No intentional functional change.

Revision 1.122 / (download) - annotate - [select for diffs], Wed Mar 16 17:03:13 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.121: +4 -3 lines
Diff to previous 1.121 (colored)

The 'status' parameter to uuid_* functions is uint32_t, not int.

No intentional functional change.

Revision 1.121 / (download) - annotate - [select for diffs], Tue Mar 15 17:59:39 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.120: +2 -2 lines
Diff to previous 1.120 (colored)

Always use letoh32(gh.gh_part_num) instead of NGPTPARTITIONS when
scanning the GPT partition table. gh.gh_part_num reflects the actual
size of the table read from/written to the disk and scanning
possible entries between this value and the maximum allowed size
of a partition table is pointless.

No intentional functional change.

Revision 1.120 / (download) - annotate - [select for diffs], Mon Mar 14 17:11:44 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.119: +56 -41 lines
Diff to previous 1.119 (colored)

Abstract duplicated code scanning gpt_types[] into a helper
function find_gpt_type().

Use find_gpt_type() to simplify the functions obtaining
information from gpt_types[]. Add not yet used
PRT_uuid_to_protection() to allow simplification of GPT partition
protection code..

No intentional functional change.

Revision 1.119 / (download) - annotate - [select for diffs], Mon Mar 14 14:28:58 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.118: +3 -3 lines
Diff to previous 1.118 (colored)

PRT_uuid_to_typename() can return const char *.

Revision 1.118 / (download) - annotate - [select for diffs], Mon Mar 14 14:22:32 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.117: +1 -2 lines
Diff to previous 1.117 (colored)

Nuke extraneous blank line.

Revision 1.117 / (download) - annotate - [select for diffs], Fri Mar 11 22:29:55 2022 UTC (2 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.116: +30 -6 lines
Diff to previous 1.116 (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.116 / (download) - annotate - [select for diffs], Fri Feb 4 23:32:17 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.115: +7 -5 lines
Diff to previous 1.115 (colored)

Wrap some annoyingly long lines.

Revision 1.115 / (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.114: +44 -68 lines
Diff to previous 1.114 (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.114 / (download) - annotate - [select for diffs], Thu Feb 3 13:24:04 2022 UTC (2 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.113: +2 -2 lines
Diff to previous 1.113 (colored)

fdisk(8): Make -A preserve BIOS boot partition

On PolarFire SoC, the HSS firmware loads HSS payload from BIOS boot
partition. Typically the payload carries second-stage low-level boot
code, such as U-Boot. If the payload is missing, the SoC is not able
to boot normally. Hence automatic disk formatting should not delete
the partition.

OK krw@

Revision 1.113 / (download) - annotate - [select for diffs], Thu Jan 27 16:26:32 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.112: +1 -33 lines
Diff to previous 1.112 (colored)

Nuke single use function PRT_fix_BN() and just use the ATA/ATAPI LBA -> CHS
conversion formula

LBA = (C × HPC + H) × SPT + (S − 1)

instead of the equivalent tortuous arithmetic used in PRT_fix_BN().

No intentional functional change.

Revision 1.112 / (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.111: +21 -19 lines
Diff to previous 1.111 (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.111 / (download) - annotate - [select for diffs], Tue Jan 18 19:37:27 2022 UTC (2 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.110: +6 -1 lines
Diff to previous 1.110 (colored)

PRT_make() can just zap the destination dos_partition if the
source prt has prt_ns == 0 or prt_id == DOSPTYP_UNUSED.

No functional change.

Revision 1.110 / (download) - annotate - [select for diffs], Mon Oct 18 20:27:32 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.109: +1 -9 lines
Diff to previous 1.109 (colored)

Don't bother decoding a partition's c/h/s start or end from the MBR read from
disk.

The decoded values were overwritten by an invocation of PRT_fix_CHS() before
they were used.

Revision 1.109 / (download) - annotate - [select for diffs], Mon Oct 18 16:12:02 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.108: +1 -8 lines
Diff to previous 1.108 (colored)

r1.66 (May 2014) introduced a two #if 0/#else/#endif chunks to avoid "over
optimistic alignment expectations" when extracting a uint32_t field from a
packed struct.

r1.70 (March 2015) removed one of the two #if 0 chunks, realizing there was no
real gain to be had even if various compilers were ever able to intuit the
expected alignment.

Belatedly nuke the other #if 0 chunk and always memcpy() the uint32_t values out
of the struct.

Revision 1.108 / (download) - annotate - [select for diffs], Sun Oct 10 15:34:21 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.107: +9 -5 lines
Diff to previous 1.107 (colored)

No need to assign dl.d_nsectors to disk.dk_sectors twice.

Two statements on one line may have seemed clever but now it's
just confusing.

No functional change.

Revision 1.107 / (download) - annotate - [select for diffs], Mon Sep 13 15:07:51 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.106: +5 -12 lines
Diff to previous 1.106 (colored)

disk.dk_size can't be 0 as we errx() if that happens during
DISK_open(). So eliminate pointless check when printing geometry.

Replace unit_lookup() with units_size(), reducing four
conversion dances to one. Return pointer to the unit_type used in
the conversion. unit_types[] is now needed only in misc.c.

Fewer variables make for cleaner logic.

No intentional functional change.

Revision 1.106 / (download) - annotate - [select for diffs], Sun Sep 12 16:36:52 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.105: +5 -3 lines
Diff to previous 1.105 (colored)

Stop taking detour through unit_types[SECTORS] to find
dl.d_secsize.

Leave unit_types[SECTORS].ut_conversion at 0, and test that to
determine if a size needs to be converted from a sectors value.

Use consistent dance to find the desired size value to print.

Logic is clearer, unit_types[] is now const, nobody but misc.c
knows about SECTORS.

No intentional functional change.

Revision 1.105 / (download) - annotate - [select for diffs], Thu Sep 2 18:07:45 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.104: +195 -143 lines
Diff to previous 1.104 (colored)

Split part_type into separate types 'mbr_type' and 'gpt_type',
shrinking static data demands. Split PRT_printall() into
PRT_print_mbrtypes() and PRT_print_gpttypes() to eliminate
pointless 'pseudo' MBR partition types and pointless display of
MBR partition types with no associated GPT GUIDs.

Eases future MBR and GPT partition type editing improvements.

ok kettenis@

Revision 1.104 / (download) - annotate - [select for diffs], Fri Aug 27 11:28:22 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.103: +2 -2 lines
Diff to previous 1.103 (colored)

Replace stray hand-rolled nitems() with nitems().

Revision 1.103 / (download) - annotate - [select for diffs], Thu Aug 12 12:31:16 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.102: +1 -5 lines
Diff to previous 1.102 (colored)

Further reduce cross-file confusion by adding USER_help() and
calling it from Xhelp(). Move declaration of struct cmd to nestle
next to its only instantiation (cmd_table) and use nitems() when
scanning cmd_table.

No functional change.

Revision 1.102 / (download) - annotate - [select for diffs], Thu Jul 22 13:30:40 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.101: +4 -5 lines
Diff to previous 1.101 (colored)

Have PRT_protected_guid() return 0/-1 like everything else
reporting success/failure.

No functional change.

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

Tweak one comment and nuke a bunch of pointless ones.

Revision 1.100 / (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.99: +10 -20 lines
Diff to previous 1.99 (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.99 / (download) - annotate - [select for diffs], Fri Jul 16 22:50:43 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.98: +3 -5 lines
Diff to previous 1.98 (colored)

Change PRT_protected_guid() to take native order uuid's instead of little endian
uuid's. This brings it into line with all the other PRT_ functions taking uuid
parameters.

While adapting gsetid(), introduce separate partition type and partition guid
variables to make the logic clearer.

No intentional functional change.

Revision 1.98 / (download) - annotate - [select for diffs], Fri Jul 16 13:26:04 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.97: +4 -4 lines
Diff to previous 1.97 (colored)

Be consistent and always return -1 to indicate failure.

DISK_printgeometry() return value was always 0 and never
checked so just make it void.

No functional change.

Revision 1.97 / (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.96: +2 -2 lines
Diff to previous 1.96 (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.96 / (download) - annotate - [select for diffs], Tue Jul 13 22:10:20 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.95: +7 -8 lines
Diff to previous 1.95 (colored)

No need to manually reinvent nitems() 5 times to scan part_types.

No functional change.

Revision 1.95 / (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.94: +5 -6 lines
Diff to previous 1.94 (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.94 / (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.93: +14 -14 lines
Diff to previous 1.93 (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.93 / (download) - annotate - [select for diffs], Mon Jul 12 18:31:53 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.92: +25 -25 lines
Diff to previous 1.92 (colored)

Final batch of struct field name tweaks. 'cmd_' for cmd, ut_' for
unit_types, 'pt_' for part_type, 'pg_' for protected_guid.

No functional change.

Revision 1.92 / (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.91: +5 -5 lines
Diff to previous 1.91 (colored)

Add 'dk_' prefix to struct disk field names.

No functional change.

Revision 1.91 / (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.90: +92 -92 lines
Diff to previous 1.90 (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.90 / (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.89: +4 -4 lines
Diff to previous 1.89 (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.89 / (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.88: +32 -32 lines
Diff to previous 1.88 (colored)

Add tabs to make variable declarations easier
to read.

No functional change.

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

'return' is not a function call.

No functional change.

Revision 1.87 / (download) - annotate - [select for diffs], Mon Jun 21 13:17:20 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.86: +4 -2 lines
Diff to previous 1.86 (colored)

Wrap #define nitems in #ifndef nitems/#endif.

While here fix a misplaced '(' to make this nitems the same as
all its friends.

Pointed out by okan@

Revision 1.86 / (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.85: +42 -1 lines
Diff to previous 1.85 (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.85 / (download) - annotate - [select for diffs], Sun Jun 13 23:53:51 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.84: +3 -3 lines
Diff to previous 1.84 (colored)

There is no '!' in HiFive.

Pointed out by kettenis@

Revision 1.84 / (download) - annotate - [select for diffs], Sun Jun 13 14:14:56 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.83: +3 -3 lines
Diff to previous 1.83 (colored)

UUID_STR_LEN+1 is less mysterious than '37'.

Revision 1.83 / (download) - annotate - [select for diffs], Sat Jun 12 18:35:37 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.82: +3 -1 lines
Diff to previous 1.82 (colored)

Recognize "HiFive! FSBL" and "HiFive! BBL" GPT partitions.

Seen on SiFive Unmatched stock image provided by mlarkin@.

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

Local functions don't need to be in .h files, nor do they need the
all caps prefixes.

No functional change.

Revision 1.81 / (download) - annotate - [select for diffs], Thu Jun 3 15:05:55 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.80: +4 -1 lines
Diff to previous 1.80 (colored)

Recognize the Apple APFS GPT partition types seen on Apple M1 boxen.

ok kettenis@

Revision 1.80 / (download) - annotate - [select for diffs], Sat May 15 19:44:15 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.79: +11 -2 lines
Diff to previous 1.79 (colored)

Keep internal representation of DOSPTYP_EFI partition sizes correct.
Translate to/from UINT32_MAX as required when translating between
on-disk MBR format and internal format.

No intentional functional change.

Revision 1.79 / (download) - annotate - [select for diffs], Sat May 8 17:44:22 2021 UTC (3 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.78: +2 -1 lines
Diff to previous 1.78 (colored)

Recognize GPT partitions of type 21686148-6449-6e6f-744e-656564454649 (a.k.a.
"IdontNeedEFI", a.k.a. "BIOS boot"). Often used to contain the second stage boot
loader binary on disk images.

Makes it easier to recognize/overwrite/remove the contents.

Example image provided by mlarkin@

Revision 1.78 / (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.77: +14 -14 lines
Diff to previous 1.77 (colored)

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

Revision 1.77 / (download) - annotate - [select for diffs], Sun Mar 26 00:22:49 2017 UTC (7 years, 2 months ago) by sobrado
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.76: +7 -7 lines
Diff to previous 1.76 (colored)

cleanup fdisk(8) partition names used by FAT file systems so they are more
consistent and easier to identify, as outlined here:

    - FAT12: FAT12 (01h)
    - FAT16: FAT16S (04h), FAT16B (06h), FAT16L (0Eh)
    - FAT32: FAT32 (0Bh), FAT32L (0Ch)

nothing in our tree is looking to the strings being replaced for anything
but printing them out, only to the numerical ids taken from disklabel.h

ok krw@, jmc@

Revision 1.76 / (download) - annotate - [select for diffs], Tue Dec 27 15:01:03 2016 UTC (7 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.75: +1 -4 lines
Diff to previous 1.75 (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.75 / (download) - annotate - [select for diffs], Thu Nov 26 08:15:07 2015 UTC (8 years, 6 months ago) by tim
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.74: +28 -2 lines
Diff to previous 1.74 (colored)

When prompting for a GPT partition type, use the partition's current type as
default; OK krw@

Revision 1.74 / (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.73: +2 -1 lines
Diff to previous 1.73 (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.73 / (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.72: +90 -31 lines
Diff to previous 1.72 (colored)

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

Revision 1.72 / (download) - annotate - [select for diffs], Fri Mar 27 16:06:00 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.71: +11 -6 lines
Diff to previous 1.71 (colored)

Wrap some annoying long lines.

Revision 1.71 / (download) - annotate - [select for diffs], Fri Mar 27 15:56:45 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.70: +2 -2 lines
Diff to previous 1.70 (colored)

Use DOSACTIVE define instead of magic number 0x80.

Revision 1.70 / (download) - annotate - [select for diffs], Thu Mar 26 14:08:12 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.69: +5 -10 lines
Diff to previous 1.69 (colored)

Expand internal representation of partition starting LBA and size
to 64 bits, adjusting printf()'s, etc. as required. Preparing for
GPT partitions. Add 't' size unit. No other intentional 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: +10 -10 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], Sat Mar 14 18:32:29 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.67: +4 -3 lines
Diff to previous 1.67 (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.67 / (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.66: +11 -20 lines
Diff to previous 1.66 (colored)

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

With the permission of Toby.

ok deraadt@

Revision 1.66 / (download) - annotate - [select for diffs], Mon May 5 17:18:08 2014 UTC (10 years, 1 month ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.65: +17 -1 lines
Diff to previous 1.65 (colored)

Ugly workaround for an overoptimistic alignment expectation of dos_partition
fields, found the hard way on landisk, to allow the tree to build until a
proper fix is devised.

ok deraadt@

Revision 1.65 / (download) - annotate - [select for diffs], Mon Mar 31 22:03:29 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.64: +2 -2 lines
Diff to previous 1.64 (colored)

Whitespace rectification.

Revision 1.64 / (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.63: +5 -5 lines
Diff to previous 1.63 (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.63 / (download) - annotate - [select for diffs], Tue Mar 25 12:59:03 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.62: +30 -40 lines
Diff to previous 1.62 (colored)

Use 'struct dos_partition' variable to access 'struct dos_partition'
data. Since all the fields but 2 that are specially handled are
u_int8_t's there should be no danger from alignment issues.

ok dlg@

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

warn() -> warnx() when errno is irrelevant.

Revision 1.61 / (download) - annotate - [select for diffs], Thu Mar 20 13:43:32 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.60: +9 -10 lines
Diff to previous 1.60 (colored)

Simplify a bit of code to make sure even -Wall can see the variables
are not used uninitialized. As a bonus, make variables the same
type as the data they are trying to preserve.

Revision 1.60 / (download) - annotate - [select for diffs], Thu Mar 20 13:18:21 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.59: +2 -1 lines
Diff to previous 1.59 (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.59 / (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.58: +3 -2 lines
Diff to previous 1.58 (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.58 / (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.57: +7 -7 lines
Diff to previous 1.57 (colored)

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

Revision 1.57 / (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.56: +7 -7 lines
Diff to previous 1.56 (colored)

Revert last -- broke building snaps.

Revision 1.56 / (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.55: +7 -7 lines
Diff to previous 1.55 (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.55 / (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.54: +2 -7 lines
Diff to previous 1.54 (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.54 / (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.53: +9 -9 lines
Diff to previous 1.53 (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.53 / (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_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.52: +5 -6 lines
Diff to previous 1.52 (colored)

more substantial include cleanup

Revision 1.52 / (download) - annotate - [select for diffs], Wed Jul 25 19:49:11 2012 UTC (11 years, 10 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.51: +2 -2 lines
Diff to previous 1.51 (colored)

do not check ns here, we're supposed to compute it; ok krw@ deraadt@

Revision 1.51 / (download) - annotate - [select for diffs], Wed Jul 11 10:27:34 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.50: +3 -3 lines
Diff to previous 1.50 (colored)

Simplify guts and calling of getuint(). Eliminate a useless 'help'
capablity by using help text as regular prompt for 'size' and
'offset'. Try to detect and handle more overflow/underflow conditions
in getuint() and ensure returned value is always within requested
bounds. Handle zero-length partitions by treating them as UNUSED.

tested & ok halex@

Revision 1.50 / (download) - annotate - [select for diffs], Wed Apr 29 22:58:24 2009 UTC (15 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: 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
Changes since 1.49: +8 -8 lines
Diff to previous 1.49 (colored)

code that stank and made me upset

Revision 1.49 / (download) - annotate - [select for diffs], Wed Apr 1 15:00:55 2009 UTC (15 years, 2 months ago) by jsg
Branch: MAIN
Changes since 1.48: +1 -2 lines
Diff to previous 1.48 (colored)

Remove duplicate entry for partition id 0x07 so NTFS partitions
will show as NTFS in fdisk output.
ok todd@ otto@ deraadt@

Revision 1.48 / (download) - annotate - [select for diffs], Tue Mar 24 15:10:03 2009 UTC (15 years, 2 months ago) by todd
Branch: MAIN
Changes since 1.47: +3 -1 lines
Diff to previous 1.47 (colored)

two more MBR partition names
ok otto@ beck@

Revision 1.47 / (download) - annotate - [select for diffs], Sat May 31 09:45:01 2008 UTC (16 years ago) by fgsch
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.46: +2 -1 lines
Diff to previous 1.46 (colored)

add hfs+ type. deraadt@ ok

Revision 1.46 / (download) - annotate - [select for diffs], Mon Feb 18 21:33:05 2008 UTC (16 years, 3 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.45: +5 -5 lines
Diff to previous 1.45 (colored)

adjust width of S column to improve printing of the MBR partition table
on modern disk geometries; while here, better alignment of column labels

ok jmc@, jsing@, krw@, and otto@

Revision 1.45 / (download) - annotate - [select for diffs], Wed Jul 4 16:34:15 2007 UTC (16 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.44: +2 -1 lines
Diff to previous 1.44 (colored)

another mbr partition type; fgsch

Revision 1.44 / (download) - annotate - [select for diffs], Sun Jun 10 11:38:27 2007 UTC (17 years ago) by sobrado
Branch: MAIN
Changes since 1.43: +4 -4 lines
Diff to previous 1.43 (colored)

adjust the width of columns to match the geometry of current drives

ok deraadt@

Revision 1.43 / (download) - annotate - [select for diffs], Wed Apr 4 14:36:05 2007 UTC (17 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.42: +2 -2 lines
Diff to previous 1.42 (colored)

Thinkpad -> ThinkPad; from Igor Sobrado
ok millert jasper mbalmer

Revision 1.42 / (download) - annotate - [select for diffs], Fri Jun 9 17:01:47 2006 UTC (18 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.41: +3 -1 lines
Diff to previous 1.41 (colored)

EFI partition types; didickman@yahoo.com

Revision 1.41 / (download) - annotate - [select for diffs], Mon Nov 21 01:59:24 2005 UTC (18 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.40: +2 -2 lines
Diff to previous 1.40 (colored)

Replace default DEV_BSIZE sector conversion factor with disklabel's
sector size when possible. Fixes the "[ XX Sectors ]" size display.
Pointed out by Robert Szasz while playing with his Sony Hi-MD device.

Apply input conversion fixes similar to those recently applied to
disklabel(8). Use correct sector size in the conversions.

It is still *not* possible to use unusual sector sizes for non-ISO9660
filesystems!

ok millert@

Revision 1.40 / (download) - annotate - [select for diffs], Wed Nov 10 17:29:41 2004 UTC (19 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.39: +2 -1 lines
Diff to previous 1.39 (colored)

0xBF is new Solaris ID; lclee@west.sun.com

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_6_BASE, OPENBSD_3_6
Changes since 1.38: +8 -8 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], Tue Jul 13 06:00:33 2004 UTC (19 years, 11 months ago) by tom
Branch: MAIN
Changes since 1.37: +4 -4 lines
Diff to previous 1.37 (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.37 / (download) - annotate - [select for diffs], Sat Jul 10 08:43:36 2004 UTC (19 years, 11 months ago) by tom
Branch: MAIN
Changes since 1.36: +90 -91 lines
Diff to previous 1.36 (colored)

The long descriptions of partition types are not used by the code, so
have them as comments rather than data.  Reduces the size of the
executable by over 2 KB.

Also s/Netware/NetWare/.

ok tedu@ deraadt@

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

spaces

Revision 1.35 / (download) - annotate - [select for diffs], Wed Jul 2 21:44:57 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.34: +2 -1 lines
Diff to previous 1.34 (colored)

missing protos

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

ansification

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

Nuke terms 3 & 4.

Revision 1.32 / (download) - annotate - [select for diffs], Sat Apr 19 18:42:14 2003 UTC (21 years, 1 month ago) by avsm
Branch: MAIN
Changes since 1.31: +2 -2 lines
Diff to previous 1.31 (colored)

change "%12.f" -> "%12.0f" to avoid a -Wformat warning
ok millert@

Revision 1.31 / (download) - annotate - [select for diffs], Thu Mar 13 22:41:03 2003 UTC (21 years, 3 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.30: +1 -3 lines
Diff to previous 1.30 (colored)

Remove duplicate Amoeba entries.

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

rm trailing whitespace

Revision 1.29 / (download) - annotate - [select for diffs], Tue Feb 12 17:56:35 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.28: +3 -1 lines
Diff to previous 1.28 (colored)

Add Dell, Thinkpad maintenance partition types.

Revision 1.28 / (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.27: +14 -7 lines
Diff to previous 1.27 (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.27 / (download) - annotate - [select for diffs], Fri Jan 18 08:29:01 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
Changes since 1.26: +13 -24 lines
Diff to previous 1.26 (colored)

Do not truncate the cylinder value to 1023 until the MBR
is actually written to disk. Cylinder values for disks >8G
are instead "faked" from the LBA values in the partition table.
These faked values are now displayed correctly after a save.

Revision 1.26 / (download) - annotate - [select for diffs], Wed Nov 14 16:42:27 2001 UTC (22 years, 6 months ago) by mickey
Branch: MAIN
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)

fix a typo, from Daniel Lucq <daniel@lucq.org>, tested on:
> (0) a SCSI disk with a working OpenBSD install
> (1) a SCSI disk with cleared first sector (dd if=/dev/zero)
> (2) an IDE disk with a working OpenBSD install
> (3) an IDE disk with cleared first sector

Revision 1.25 / (download) - annotate - [select for diffs], Wed Nov 7 01:27:33 2001 UTC (22 years, 7 months ago) by miod
Branch: MAIN
Changes since 1.24: +3 -1 lines
Diff to previous 1.24 (colored)

Add MacOS X for Intel (or Darwin for Intel, or whatever the correct
name is) partition ID.
ok millert@ mickey@

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

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

Revision 1.23 / (download) - annotate - [select for diffs], Sat Jun 23 04:27:30 2001 UTC (22 years, 11 months ago) by kjell
Branch: MAIN
Changes since 1.22: +48 -16 lines
Diff to previous 1.22 (colored)

Add more partition types - ref. NetBSD

Revision 1.22 / (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.21: +15 -3 lines
Diff to previous 1.21 (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.21 / (download) - annotate - [select for diffs], Fri May 18 20:22:02 2001 UTC (23 years ago) by mickey
Branch: MAIN
Changes since 1.20: +1 -2 lines
Diff to previous 1.20 (colored)

oops

Revision 1.20 / (download) - annotate - [select for diffs], Fri May 18 07:15:18 2001 UTC (23 years ago) by mickey
Branch: MAIN
Changes since 1.19: +9 -8 lines
Diff to previous 1.19 (colored)

a few harmless cleanups

Revision 1.19 / (download) - annotate - [select for diffs], Fri Mar 16 19:02:14 2001 UTC (23 years, 2 months ago) by markus
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.18: +2 -1 lines
Diff to previous 1.18 (colored)

0x9f == BSDI, ok millert@

Revision 1.18 / (download) - annotate - [select for diffs], Sat Jul 1 21:49:12 2000 UTC (23 years, 11 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.17: +11 -8 lines
Diff to previous 1.17 (colored)

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

Revision 1.17 / (download) - annotate - [select for diffs], Sun Jun 11 16:11:55 2000 UTC (24 years ago) by markus
Branch: MAIN
Changes since 1.16: +2 -1 lines
Diff to previous 1.16 (colored)

0x39 == plan9

Revision 1.16 / (download) - annotate - [select for diffs], Sat Jun 10 15:56:42 2000 UTC (24 years ago) by deraadt
Branch: MAIN
Changes since 1.15: +5 -2 lines
Diff to previous 1.15 (colored)

know QNX; jcplace@ibm.ne

Revision 1.15 / (download) - annotate - [select for diffs], Wed Mar 29 01:53:01 2000 UTC (24 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.14: +16 -7 lines
Diff to previous 1.14 (colored)

sort partition type list vertically rather than across. ok weingart@

Revision 1.14 / (download) - annotate - [select for diffs], Sat Jan 8 04:51:16 2000 UTC (24 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.13: +38 -19 lines
Diff to previous 1.13 (colored)

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

Revision 1.13 / (download) - annotate - [select for diffs], Tue Nov 23 01:56:39 1999 UTC (24 years, 6 months ago) by ian
Branch: MAIN
Changes since 1.12: +2 -1 lines
Diff to previous 1.12 (colored)

Add Phoenix BIOS notebook save-to-disk partition type (ok theo).

Revision 1.12 / (download) - annotate - [select for diffs], Thu Jul 22 22:05:55 1999 UTC (24 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (colored)

align collumns

Revision 1.11 / (download) - annotate - [select for diffs], Tue Feb 9 19:06:36 1999 UTC (25 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.10: +2 -1 lines
Diff to previous 1.10 (colored)

BeOS/i386; ura@yamato.ibm.co.jp

Revision 1.10 / (download) - annotate - [select for diffs], Fri Sep 18 02:36:56 1998 UTC (25 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.9: +3 -3 lines
Diff to previous 1.9 (colored)

fix table

Revision 1.9 / (download) - annotate - [select for diffs], Mon Sep 14 03:54:35 1998 UTC (25 years, 9 months ago) by rahnds
Branch: MAIN
Changes since 1.8: +59 -12 lines
Diff to previous 1.8 (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.8 / (download) - annotate - [select for diffs], Thu Feb 19 20:48:08 1998 UTC (26 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.7: +3 -2 lines
Diff to previous 1.7 (colored)

new netbsd partition type

Revision 1.7 / (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_2_BASE, OPENBSD_2_2
Changes since 1.6: +14 -5 lines
Diff to previous 1.6 (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.6 / (download) - annotate - [select for diffs], Sun Oct 19 23:29:38 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.5: +9 -9 lines
Diff to previous 1.5 (colored)

indent

Revision 1.5 / (download) - annotate - [select for diffs], Thu Oct 16 01:53:08 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

better message

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

a bunch of improvements by weingart & I

Revision 1.3 / (download) - annotate - [select for diffs], Thu Oct 2 02:10:07 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

shorten two common names

Revision 1.2 / (download) - annotate - [select for diffs], Mon Sep 29 23:33:39 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:18 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.