summaryrefslogtreecommitdiff
path: root/sbin/fdisk
AgeCommit message (Collapse)Author
2022-02-04Wrap some annoyingly long lines.Kenneth R Westerback
2022-02-04%llu should be enough for anybody, no need to use %lld/(long long) forKenneth R Westerback
uint64_t values.
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.
2022-02-03fdisk(8): Make -A preserve BIOS boot partitionVisa Hankala
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@
2022-01-27Nuke single use function PRT_fix_BN() and just use the ATA/ATAPI LBA -> CHSKenneth R Westerback
conversion formula LBA = (C × HPC + H) × SPT + (S − 1) instead of the equivalent tortuous arithmetic used in PRT_fix_BN(). No intentional functional change.
2022-01-22Wrap some long lines.Kenneth R Westerback
2022-01-21Split PRT_print() into PRT_print_parthdr() and PRT_print_part()Kenneth R Westerback
to align with GPT functions. Simplifies logic and eliminates the magic invocations to print the header. No functional change.
2022-01-18PRT_make() can just zap the destination dos_partition if theKenneth R Westerback
source prt has prt_ns == 0 or prt_id == DOSPTYP_UNUSED. No functional change.
2022-01-02Stop writing big-endian checksums into the little-endian GPTKenneth R Westerback
header fields gh_csum and gh_part_csum. Constrain kernel to accepting only correct little-endian checksums. Temporarily allow fdisk(8) to read either endian GPTs so that big-endian GPTs can be made correct by a simple 'fdisk -e' && 'w'. Fixes inter-architecture, inter-OS GPT portability and GPT fdisk(8) on big-endian architectures. Broken since initial GPT implementation. Suggestions and ok kettenis@
2021-12-29Tweak some DEBUG output.Kenneth R Westerback
Always put '0x' prefix in front of displayed hex values, i.e. the checksums. Add missing letoh32() so bad endian checksum is clear. Be consistent when displaying 'expected' and 'got' checksums, i.e. 'expected' == calculated checksum and 'got' == checksum found in GPT.
2021-12-28Tweak some DEBUG output.Kenneth R Westerback
'EFI PART' reads better than "TRAP IFE" and checksums are easier to read/compare when shown in hex rather than decimal. Prompted by recent GPT vs disklabel misc@ thread concerning Rob Whitlock's problematic GPT.
2021-12-11Start the default OpenBSD partition either immediately followingKenneth R Westerback
any boot partition specified via '-b' or /usr/mdec/mbr; at the power of 2 block after the first track; or immediately following the MBR if there is only one track. Mark any non-EFISYS boot partition created by -b as DOSACTIVE. Suggested by kettenis@, better than a separate new option. Brings -b behaviour into line with many uses of -e to create boot partitions, allowing for the eventual elimination of said -e uses in the creation of the various boot media and in the install scripts.
2021-12-07Don't truncate the default OpenBSD partition at the end of theKenneth R Westerback
last full cylinder. Let it extend to the end of the disk.
2021-12-01Remove the MBR_init() "#ifdef defined(__macppc__) ||Kenneth R Westerback
defined(__mips__)" chunk that rounded the start of the default OpenBSD partition to a cylinder boundary. The value has been immediately re-rounded to a power of 2 block since r1.25 in 2009. Eliminates wasted space when no /usr/mdec/mbr partition 0 information is available. '-b' becomes available to architectures other than amd64 and i386, taking precedence over /usr/mdec/mbr partition 0 information. The latter being present only in macppc and loongson /usr/mdec/mbr files.
2021-11-26remaing -> remainingJonathan Gray
2021-11-25Honour /usr/mdec/mbr or -f partition 0 information even outsideKenneth R Westerback
of _powerpc__ and __mips__, preventing the possible creation of MBRs with overlapping partitions 0 and 3. Don't set bootprt DOSACTIVE flag if no partition 0 information was provided via /usr/mdec/mbr or -f. Lets octeon fdisk(8) set DOSACTIVE on the OpenBSD partition in the default MBR like every other fdisk(8) does.
2021-11-20Gather the setup of the initial OpenBSD MBR partition into oneKenneth R Westerback
location within MBR_init(), ensuring that MBR_init() creates an OpenBSD MBR partition only when there is space for it. No functional change.
2021-11-20No need for intermediate 'adj' variable. Add 'disksz'Kenneth R Westerback
intermediate variable to make MBR_init() code clearer and lay more groundwork for upcoming functional enhancements. No functional change.
2021-11-20Sectors-per-cylinder (spc) is a constant value, so make it constKenneth R Westerback
and use it instead of calculating it twice in MBR_init(). No functional change.
2021-11-14Calculate initial OpenBSD partition start/size using LBA valuesKenneth R Westerback
instead of CHS values. Shorter, easier to follow. No intentional functional change.
2021-11-10Set correct prt_flag to 0.Kenneth R Westerback
2021-11-09Try this again, with (__powerpc__ || __mips__) chunk actuallyKenneth R Westerback
compiling. Use a couple of local 'struct prt' variables to make MBR_init() easier to read. No functional change.
2021-11-09no, that breaks architecturesTheo de Raadt
2021-11-08Use a couple of local 'struct prt' variables to make MBR_init()Kenneth R Westerback
easier to read. No functional change.
2021-11-07Nuke unused file.Kenneth R Westerback
2021-10-29Tweak code to make it clear that MBR_init() uses just the boot code andKenneth R Westerback
partition 0 information from the default MBR. loongson and macppc provide partition 0 information but no boot code. amd64, i386, landisk provide boot code but no partition 0 information. Other arch's get by w/o a default MBR (a.k.a. /usr/mdec/mbr). No functional change.
2021-10-25Nuke a bunch of pointless #ifndef _<.h file>/#endif guards.Kenneth R Westerback
2021-10-21Remove 'disk' editing command. Determining the disk geometry on startup (fromKenneth R Westerback
-l, -c/-h/-s or DIOCGPDINFO) should be enough for anyone.
2021-10-19Move get_default_mbr() invocation before DISK_open() invocation and removeKenneth R Westerback
"rpath wpath" from the pledge() invocation. Makes default_dmbr information available to DISK_open(). No intentional functional change.
2021-10-18Don't bother decoding a partition's c/h/s start or end from the MBR read fromKenneth R Westerback
disk. The decoded values were overwritten by an invocation of PRT_fix_CHS() before they were used.
2021-10-18r1.66 (May 2014) introduced a two #if 0/#else/#endif chunks to avoid "overKenneth R Westerback
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.
2021-10-13Nuke builtin_mbr.Kenneth R Westerback
Those architectures needing either MBR boot code (amd64, i386, landisk) or special boot partitions (macppc, loongson) have long used /usr/mdec/mbr to provide that information. Other architectures should not blindly write i386/amd64 boot code into the MBR. Fail quickly if the desired default MBR file is missing. Prompted by deraadt@, tweak from kettenis@.
2021-10-10No need to assign dl.d_nsectors to disk.dk_sectors twice.Kenneth R Westerback
Two statements on one line may have seemed clever but now it's just confusing. No functional change.
2021-09-29Don't constrain -b specified block count or block size to be greater than 63.Kenneth R Westerback
Allow any value from 1 to UINT32_MAX. MBR boot partition sizes/offsets are completely machine dependent. Pointed out by loongson.
2021-09-26Revert '-b' change. Forgot required bsd.rd tweak.Kenneth R Westerback
2021-09-26MBR partitions created with '-b' should be marked DOSACTIVE.Kenneth R Westerback
That's what 'bootable' means in the MBR world. GPT partitions created by '-b' are unaffected. Pointed out by kettenis@, obviating need for new option.
2021-09-13disk.dk_size can't be 0 as we errx() if that happens duringKenneth R Westerback
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.
2021-09-13Document that the editing command 'disk' takes an optional units argument.Kenneth R Westerback
2021-09-12Stop taking detour through unit_types[SECTORS] to findKenneth R Westerback
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.
2021-09-10Stop using NULL as a synonym for "s" (SECTORS). Just use "s".Kenneth R Westerback
Remove now pointless NULL check in unit_lookup(). No intentional functional change.
2021-09-09Simplify logic in USER_edit() loop to eliminate unnecessaryKenneth R Westerback
goto's. Rename CMD_SAVE to CMD_QUIT to reflect actual command (Xquit) and help and man page verbiage. No intentional functional change.
2021-09-09Scan unit_types[] array using nitems() and eliminate the NULLKenneth R Westerback
sentinal entry. No functional change.
2021-09-02Split part_type into separate types 'mbr_type' and 'gpt_type',Kenneth R Westerback
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@
2021-09-01Improve editing GPT partition type GUID's by rejecting partitionKenneth R Westerback
id's that have no associated GUID, rather than disabling the partition. If the current partition type is a GUID with no corresponding partition id, display and use that GUID as the default value. Less surprising behaviour all round.
2021-08-29Nuke unused variable and unnecessary initialization.Kenneth R Westerback
2021-08-28Add hex_octet() so the strtol(..,16) dance is done in just oneKenneth R Westerback
place. Allows single-digit partition id's in '-b' as a side benefit.
2021-08-27Replace stray hand-rolled nitems() with nitems().Kenneth R Westerback
2021-08-25Two more Capt. Obvious comments go away.Kenneth R Westerback
2021-08-25Consolidate '-e' edit command parsing into ask_cmd(), simplifyingKenneth R Westerback
the main '-e' loop. No functional change.
2021-08-24Add an #ifdef DEBUG/#endif chunk that dumps the entire GPT header whenKenneth R Westerback
printing a GPT. No functional change outside of DEBUG.