summaryrefslogtreecommitdiffstats
path: root/sbin/fdisk
AgeCommit message (Collapse)AuthorFilesLines
2021-01-31replace fgetln(3) with getline(3) in fdisknaddy1-11/+9
ok millert@
2021-01-30Make editing GPT easier/safer by defaulting offet to beginning of largestkrw3-19/+149
free space and preventing the creation of overlapping partitions. Prompted & tested by landry@
2021-01-30document that sizes in fdisk can be input and printed in terabytesnaddy1-6/+10
2020-07-21extra garbage line found during archeologyderaadt1-2/+1
2019-07-03snprintf/vsnprintf return < 0 on error, rather than -1.deraadt1-2/+2
2019-05-11socppc makes an extended visit to the bigbucket.deraadt1-2/+2
ok kettenis
2019-04-29Add '*' to disklabel(8) editor prompt when in-memory copy of disklabelkrw2-8/+11
has been modified. Use name of disk being edited in fdisk(8) editor prompt. Idea from tb@. ok tb@ deraadt@
2018-04-26Prefer <fcntl.h> over <sys/fcntl.h> in userlandguenther3-7/+7
While here, delete some extra #includes and apply style(9) sort rules. ok deraadt@ krw@ mpi@
2017-11-16Range check default values so that a range likekrw1-3/+5
'[1 - 0] [1]' can no longer return '1'. Issue reported by Alexi Malinin via bugs@. Thanks!
2017-11-13Constrain MBR partition offsets to 0 .. disk.size - 1.krw1-2/+2
Issue reported by Alexi Malinin via bugs@. Thanks!
2017-03-26cleanup fdisk(8) partition names used by FAT file systems so they are moresobrado2-18/+18
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@
2016-12-27The "disk too large" and "only LBA values saved" messages are morekrw2-11/+2
often confusing than useful these days. Stop emitting them. Prompted by bugs@ report of the 8TB disk travails of Jiri. ok deraadt@ tom@
2016-09-03'reinit' should check the MBR on disk, as the man page says.krw1-2/+2
Makes 'reinit' respect current state of disk when deciding between MBR and GPT initialization. Problem noted by halex@
2016-09-03no more boot_zaurus.8;jmc1-3/+2
2016-09-01Nuke now unused 'sz' variable.krw1-5/+1
2016-09-01EFI firmware has been encountered that is (from our point of view) confusedkrw1-6/+9
about the disk size. Making the protective MBR created by fdisk invalid as fdisk used the 'correct' disk size. So just do what MS does and put UINT32_MAX into the EE partition size field, no matter what the disk size is. Lets tom@'s Dell boot. ok kettenis@ tom@
2016-08-02capitalize a question like all the othersjcs1-2/+2
ok krw
2016-06-25Move pledge after opendev and DIOCGPDINFO. Fixes e.g. fdisk /dev/tty.tb1-5/+5
This diff by deraadt was overlooked far too many times, mostly by me. It's the original fix of the pledge disklabel breakage found by espie. diff by deraadt; ok semarie, tb.
2016-03-30Dump strdup()/free() dance and just use a local buffer to translate helpkrw1-9/+7
messages to GPT. Unchecked strdup() result noted by mestre@. ok mestre@ tim@
2016-03-28The GPT versions of help strings that don't contain'MBR' werekrw1-9/+7
leaking. Refactor logic a bit to avoid leak and make logic clearer. Noticed by (and initial diff from) mestre@ and his friend clang.
2016-03-28Remove unused variablesmestre2-6/+4
OK krw@
2016-03-09Accept only character special devices rather than generating a corekrw1-4/+3
dump on the attempt to get a disklabel from a regular file. Regular files have not been acceptable as the 'disk' for some time, and pledging changed the consequences from a somewhat obscure error message to an abort(). Issue discovered by espie@. ok natano@
2016-02-23A disk name of /dev/wd0c doesn't work. Correct verbiage and example.krw1-7/+7
Discovered by rpe@. Tweaked by schwarze@. ok rpe@ schwarze@ jmc@ deraadt@
2016-01-09Revamp the display of GPT information, hiding less importantkrw5-78/+76
information under the '-v' flag. This brings the GPT display more into line with the MBR display and simplifies and hardens the parsing of the partition info in the install scripts. Original problem with install scripts parsing hand edited GPT information reported by Valere Monseur via bugs@. Man page fixes and tweaks from jmc@. Install script changes tested & ok rpe@.
2015-12-30Revert r1.59's over-enthusiatic MBR zero'ing in MBR_init(). It waskrw1-2/+10
killing the macppc MSDOS partition created by '-i'. Should fix the macppc install problems reported by Brian Conway on bugs@. Date of breakage found by rpe@.
2015-12-27Use 'standard' gpt_chk_mbr() to check for protective MBR.krw1-19/+47
2015-12-12In olden times (i + u + e) was considered a clever way to 'or'krw1-3/+3
together three boolean values. In today's englightened world we know about '||'. Pointed out by naddy@
2015-12-12Open disk READONLY if none of i, e or u are specified.krw3-7/+8
Suggestion, original diff and ok naddy@
2015-12-11there are no boot_ pages for armish or landisk that i can see,jmc1-4/+2
so remove their references; while here undo a predefined string (as mandoc_char(7) calls them);
2015-12-11Add '-v' flag that forces the display of both GPT's and the MBR.krw6-25/+58
Useful for seeing exactly what is currently on the disk. Suggested by a request from kettenis@. Man page & usage ok jmc@
2015-12-01Fix inexplicable use of 'disk' instead of 'disk.name' when trying tokrw1-2/+2
print the disk's name in an error message.
2015-12-01Make '-i' set 'reinited' flag so that the initial Xwrite() will zapkrw2-2/+5
any undesirable GPT hanging around. i.e. same as 'reinit' from the fdisk(8) command line. Noticed now that install media relies on '-i' rather than issuing 'reinit' in a script.
2015-11-26When prompting for a GPT partition type, use the partition's current type astim5-10/+38
default; OK krw@
2015-11-26When prompting for an LBA, show the min and max values in the prompt; OK krw@tim1-2/+3
2015-11-25Try harder to prevent 0-length partitions from being defined.krw1-9/+10
Suggested by & ok tim@
2015-11-24pledge "stdio rpath wpath disklabel proc exec" throughout, afterderaadt1-1/+5
krw's refactorings which hoisted disk-opening to the top. tested by krw
2015-11-21Bring GPT partition editing into line with MBR partition editingkrw3-13/+14
by presenting the existing offset and size as the defaults. Enhance getuint64() to take a minimum value as ask_num() does. Use this to ensure that GPT partitions are constrained to the valid area of the disk. Leave MBR partition constraints alone for the moment. Original problem(s) noted by tim@
2015-11-21Nuke long standing annoyance of EDIT() macros and switch both Xedit()krw1-50/+57
and Xgedit() to a new mechanism. Keep a copy of the old partition and compare final edited version to that to decide if it is dirty. Fixes a number of (but not all!) nits in editing partitions. Original problem(s) noted by, suggestions from, much testing and ok tim@
2015-11-19When an existing partition is modified in LBA mode, ensure that the partitiontim1-7/+12
table is marked dirty so that it gets written when "quit" is issued. This commit contains the MBR part of the fix only. The GPT code needs a few adjustments before the GPT part can be fixed properly. OK krw@
2015-11-19Oops. Missed a file.krw1-4/+5
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
2015-11-19Reduce overburden of unnecessary #include's. Note that param.h iskrw7-29/+24
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
2015-11-18Change #include <memory.h> to #include <string.h>krw2-4/+4
2015-11-18Parse the original on-disk MBR into a local variable. Use thekrw3-29/+7
partition table in this variable when doing an 'u'pdate of the MBR. Remove now superfluous MBR_pcopy() and its re-read of the on-disk MBR.
2015-11-18g_flag does not need to be a global. Move it inside main().krw1-4/+2
2015-11-18Rejig the MBR file reading logic sokrw1-21/+16
1) If mbr_file is NULL use built-in mbr for -i, -u and 'reinit'. 2) If mbr_file cannot be opened issue a warning and use built-in mbr for -i, -u, and 'reinit'. 3) If mbr_file can't be read, bail out of fdisk. 4) Use the mbr read from mbr_file for -i, -u, and 'reinit'. Remove inappropriate GPT dancing. This restores pre-GPT-editing mbr_file handling and makes the logic clearer at the expense of a tiny bit of duplication.
2015-11-18USER_edit() (a.k.a. -e) edits the on-disk information. So zap GPTkrw1-1/+8
and re-read it from disk if appropriate. i.e. when the re-read MBR is a protective MBR.
2015-11-18Read MBR immediately, and only read the GPT if the MBR is akrw1-9/+8
protective MBR.
2015-11-17note that -chs and -l are mutually exclusive;jmc1-2/+14
from jan stary
2015-11-15Move zapping of invalid GPT data into GPT_get_gpt() rather thankrw3-12/+15
returning a value to tell callers to zap it. Use consistant idiom to check for the presence of a GPT (check gh.gh_sig). When zapping GPT, always zap both the header and partition table just for paranoia's sake.
2015-11-14Since -l is ignored if -c/-h/-s are specified, make that combinationkrw2-34/+35
invalid and mention the constraint in usage(). Modify the appropriate field(s) of the global 'disk' as -l/-c/-h/-s are encountered. As a result use the disklabel information to populate the global 'disk' only when it has not already been populated. Move test for 'disk' validity into DISK_open().