summaryrefslogtreecommitdiff
path: root/sbin/fdisk/part.c
AgeCommit message (Collapse)Author
2023-06-19"%-Ns\n" is more appropriately "%s\n" to avoid adding extraneousKenneth R Westerback
blanks to the end of the line. Unexpected line wrapping noticed by kettenis@, cause spotted by deraadt@ Nuke an unused variable in passing.
2023-05-21If an MBR partition start or end can be represented by CHS, setKenneth R Westerback
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!
2023-05-17Make function and symmetry obvious by renaming PRT_make() toKenneth R Westerback
PRT_prt_to_dp() and PRT_parse() to PRT_dp_to_prt(). No functional change.
2023-05-10Display correct type name for Microsoft basic data GPTKenneth R Westerback
partitions. Inadvertantly lost in transition to new menu logic.
2023-04-12Simplify code by folding uuid_attr() into PRT_protected_uuid().Kenneth R Westerback
No functional change.
2023-04-12Clarify logic in PRT_uuid_to_menudflt() by using find_gpt_menuitem().Kenneth R Westerback
No functional change.
2023-04-11Abstract find_[gpt|mbr]_menuitem() to simplify code andKenneth R Westerback
prepare for future uses. No functional change.
2023-04-11Simplify code by passing pointers to the appropriate type toKenneth R Westerback
find_gpt_desc() and find_mbr_desc(). No functional change.
2023-04-11Shuffle mbr and gpt function prototypes and declarations together.Kenneth R Westerback
No functional change.
2023-04-10Make GPT display of menu hex octet the same as the MBR display.Kenneth R Westerback
i.e. two digits.
2023-04-09Refactor and simplify GPT menu selection logic.Kenneth R Westerback
No intentional functional change.
2023-04-08A bit more guid vs uuid naming consistency.Kenneth R Westerback
No functional change.
2023-04-07Add helper functions find_mbr_desc() and find_gpt_desc() to allowKenneth R Westerback
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.
2023-04-05Add (inside #if 0 blocks) #define's and gpt_types[] entries forKenneth R Westerback
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.
2023-04-04Adopt a more compact idiom when initializing gpt_types[]. GroupKenneth R Westerback
entries with attributes together. No intentional functional change.
2023-04-02Use #define instead of `char * const' for the repeated GUID strings. Ugly,Miod Vallat
but restores compilability with older compilers such as gcc. No intentional functional change.
2023-04-01Use char * const for the rest of the repeated GUID strings. MoreKenneth R Westerback
readable, less prone to typos. No intentional functional change.
2023-03-31Refactor partition type menu code, disentangling mbr and gptKenneth R Westerback
partition types from menu building and display. Some GPT partition names change to match their MBR bretheren. No intentional functional change.
2023-03-31Oops. Missed eliminating unneeded double quotes in previous.Kenneth R Westerback
2023-03-31Be more consistent in function naming. Functions taking orKenneth R Westerback
returning struct uuid's use 'uuid' in their names. Lengthen a pointlessly short line. No functional change.
2023-03-30Use 'char * const' instead of #define for repeatedKenneth R Westerback
GUID strings. Consistently use strcasecmp() when comparing GUID's, allowing use of simple 'char *' for gt_guid. No intentional functional change.
2023-03-30Remove needless memset() call, 'entries' variable andKenneth R Westerback
limit check in PRT_menuid_to_guid(). No functional change.
2023-03-29Change 'type' to 'menuid' in various struct's, functions andKenneth R Westerback
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.
2023-03-29No need to assume a nil GUID can be found at gpt_types[0]. JustKenneth R Westerback
use uuid_create_nil(). No functional change.
2023-03-29Simplify code by having PRT_uuid_to_type() return -1 whenKenneth R Westerback
no type can be found. 0 is a valid type! No functional change.
2023-03-26Pass lbuf/lbuflen to PRT_print_[mbr|gpt]_menu() to allow changesKenneth R Westerback
to the original input. Just zap it for now. No functional change.
2023-03-26Add EFI_SYSTEM_PARTITION_GUID #define and use it to check forKenneth R Westerback
protection. No functional change.
2023-03-26Add MICROSOFT_BASIC_DATA_GUID #define to make clear what menuKenneth R Westerback
items result in the same GUID. Easier to spot and more resistant to simple typos in a 36 character hex string. No functional change.
2023-03-25Add comments documenting possible sources for MBR partition typesKenneth R Westerback
and GPT partition GUIDs. No functional change.
2023-03-25Rename ascii_id() find_mbr_type(), make it a bit more like itsKenneth R Westerback
sibling find_gpt_type(), tweaking PRT_print_part() as needed. No functional change.
2023-03-25Make *_name fields char * instead of char[]. Specify desiredKenneth R Westerback
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.
2023-03-25Rename *_sname fields/functions to *_name to remove impliedKenneth R Westerback
shortness of the names. No functional change.
2023-03-06Use GPT_UUID_NBSD_UFS, not GPT_UUID_FBSD_DATA, for NetBSD GPTKenneth R Westerback
partition entries. Add GPT_UUID_LEGACY_MBR entry to list of known partition id's as it is defined in the UEFI Standard.
2022-08-29Print warning when an MBR partition starts or extends past theKenneth R Westerback
end of the device the MBR is currently inhabiting. Prompted by some interesting MBR's from France, verbiage suggestion from deraadt@, ok miod@
2022-05-08Rename gt_protected field of struct gpt_type to gt_attr andKenneth R Westerback
#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.
2022-05-08Shuffle local helper function declarations and definitions intoKenneth R Westerback
one easy to find spot. Wrap the long lines of gpt_types[] to make room for future expansion. No functional change.
2022-05-07Now that the internal versions of GPT partitions are host-endian,Kenneth R Westerback
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.
2022-05-06Rename PRT_uuid_to_[protection|typename] to PRT_uuid_to_[protected|sname],Kenneth R Westerback
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.
2022-05-06When printing the GPT table, display "Microsoft basic data" instead ofKenneth R Westerback
"FAT12" for partition types that are mapped to GPT_UUID_MSDOS. No intentional functional change.
2022-05-03Rework display of partition types, removing unnecessary trailingKenneth R Westerback
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@
2022-04-28Convert the internal GPT partition entries into host-endian formKenneth R Westerback
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@
2022-04-18Convert the GPT header read from disk into a host-endian version,Kenneth R Westerback
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.
2022-03-16The 'status' parameter to uuid_* functions is uint32_t, not int.Kenneth R Westerback
No intentional functional change.
2022-03-15Always use letoh32(gh.gh_part_num) instead of NGPTPARTITIONS whenKenneth R Westerback
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.
2022-03-14Abstract duplicated code scanning gpt_types[] into a helperKenneth R Westerback
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.
2022-03-14PRT_uuid_to_typename() can return const char *.Kenneth R Westerback
2022-03-14Nuke extraneous blank line.Kenneth R Westerback
2022-03-11Simple hack to preserve the EFI System partition whenKenneth R Westerback
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@
2022-02-04Wrap some annoyingly long lines.Kenneth R Westerback
2022-02-04Remove CHS information from internal representation of MBR partitions. GenerateKenneth R Westerback
CHS information as required when writing MBR to disk, editing a partition in CHS mode or printing MBR. No intentional functional change.