summaryrefslogtreecommitdiff
path: root/sbin/fdisk
AgeCommit message (Collapse)Author
2022-08-29Print warning when a GPT partition start or end is outside theKenneth R Westerback
usable LBA area of the device the GPT is currently inhabiting. Makes GPT display as informative as MBR display. In passing, eliminate possible underflow in partition size calculation. ok deraadt@
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-07-26Allow editing of an MBR of all zeros.Kenneth R Westerback
Fallout from regress failure spotted by anton@.
2022-07-25Only MBR and GPT structures can be edited by fdisk.Kenneth R Westerback
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@.
2022-07-18Synch 'help' command descriptions with man page descriptions.Kenneth R Westerback
Put 'setpid' description in correct place in COMMAND MODE command list. i.e. in same order as ask_cmd() will parse it. Simplify ask_cmd() by displaying prompt in edit loop rather than passing editlevel to ask_cmd(). No intentional functional change.
2022-07-18'quit' and 'exit' descriptions were reversed.Kenneth R Westerback
Tweak 'abort' description to emphasize discarding of changes.
2022-07-17Modernize and cleanse fdisk.8, making it more concise andKenneth R Westerback
aligned with the code. Tweak usage() to stay in step. Usual cogent feedback, tweaks and ok jmc@
2022-07-10Add some anti-feline input protection by refusing to processKenneth R Westerback
input of excessive length. Make 'args' parameter to Xfuncs const char * and do the multiple argument parsing in Xswap() and Xflag() on a local copy.
2022-07-10Use nice #define's for input buf size and output help buf size.Kenneth R Westerback
No functional change.
2022-06-28Move debug-only variable 'i' to be with the other debug-onlyKenneth R Westerback
variables inside the #ifdef DEBUG block using them.
2022-05-23Neither macppc nor the retired loongson have any remaining usefulKenneth R Westerback
information in /usr/mdec/mbr. Stop telling fdisk(8) that macppc and loongson HAS_MBR, and don't bother including the file in the base set. macppc build/install tests and ok gkoehler@ loongson is gone deraadt@
2022-05-12And the man page change too.Kenneth R Westerback
2022-05-12Prevent '-u' when operating on GPT formatted disks, as theKenneth R Westerback
equivalent 'update' editing command already is. Avoids the destruction of the GPT when the preventative MBR is overwritten with the default MBR. ok deraadt@
2022-05-10Align fdisk with the logic used in the kernel and allow theKenneth R Westerback
protective EFI GPT partition to be in MBR partitions 0-3, not just the default partition 0.
2022-05-09Replace a stray 0xA6 with DOSPTYP_OPENBSD. Tweak a ">= 2" to moreKenneth R Westerback
obvious "> 1". Use easier to spot 'ask_yn() == 0' instead of '!ask_yn()'. No functional change.
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-25Push DISK_[read|write]sectors() down to disk.c local functionsKenneth R Westerback
and expose new DISK_[read|write]bytes() functions. Eliminates many bytes <-> sector i/o dances and makes the code much easier to understand. Be a bit more careful to consistently write only bytes that checksums are calculated over. No intentional functional change.
2022-04-25gh_csum an gh_part_csum are not used between initializingKenneth R Westerback
the GPT and calculating them when writing the GPT to disk. No need to update them in add_partition(). Pointed out by jmatthew@
2022-04-24Use warnx() if errno is not relevant. close() after errno ofKenneth R Westerback
interest is checked, not before. Less confusing error messages.
2022-04-23Add missing uuid_dec_le() to init_gp() so -A works onKenneth R Westerback
big-endian architectures too.
2022-04-20Refine the GPT partition entry table validity check to ensureKenneth R Westerback
that the partition entry table associated with the primary GPT header at sector 1 doesn't overwrite the header or intrude into the sectors available for partitions. Similarly ensure that the partition entry table associated with the alternate header does not overwrite that header or intrude into the sectors available for partitions.
2022-04-20Wrap a long line.Kenneth R Westerback
2022-04-20Sigh. Another forgotten header file.Kenneth R Westerback
2022-04-20Simpify code manipulating GPT partition names by coalescingKenneth R Westerback
logic into GPT_get_name(), string_to_name() and name_to_string() functions. Remove unnecessarily abstract functions ask_string(), utf16le_to_string() and string_to_utf16le(). No intentional functional change.
2022-04-20Eliminate some local pointers to gp[pn] and just use gp[pn].Kenneth R Westerback
Fix some whitespace and memset() parameters in passing. No intentional functional change.
2022-04-19Forgot a file for previous commit.Kenneth R Westerback
No functional change.
2022-04-19Bring GPT_print_partition() into line with other functions being passedKenneth R Westerback
an index to the gp[] array by calling said parameter 'pn' and making it const unsigned int. No functional change.
2022-04-19Move declaration of DEBUG-only variable inside #ifdef DEBUG.Kenneth R Westerback
No functional change.
2022-04-19Eliminate superfluous intermediate variables 'pncnt' now thatKenneth R Westerback
gh.gh_part_num does not need a letoh32(). No functional change.
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-04-14Move ((gh_part_size % d_secsize) == 0) validity checkKenneth R Westerback
to get_header() with the rest of the header validity checks. No functional change.
2022-04-13Correct a gh_part_csum calculation used in debug output.Kenneth R Westerback
Always calculate the GPT partition entries checksum over gh_part_num * gh_part_size bytes, not the maximal size of the internal partition entries array. No functional change.
2022-04-13Correct a gh_csum calculation used in debug output.Kenneth R Westerback
Always calculate the GPT header checksum over gh_size bytes (a.k.a. 92), not sizeof(struct gpt_header). Compilers in their wisdom may pad the struct to a nice round size, e.g. 96 bytes. No functional change.
2022-04-13Eliminate a couple of 'XXX' assumptions by calculating the actualKenneth R Westerback
number of sectors a given number of GPT partition entries require. No intentional functional change.
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
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-14And the prototype too.Kenneth R Westerback
2022-03-14PRT_uuid_to_typename() can return const char *.Kenneth R Westerback
2022-03-14Nuke extraneous blank line.Kenneth R Westerback
2022-03-13Missing 'or'.Kenneth R Westerback
Pointed out by jmc@
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