summaryrefslogtreecommitdiff
path: root/sbin/fdisk/cmd.c
AgeCommit message (Collapse)Author
2013-03-21more substantial include cleanupTheo de Raadt
2013-03-21I don't feel great about adding an include for <sys/param.h>, but I feelTheo de Raadt
great for removing an include of <machine/param.h> This needs further cleanup if someone has time.
2012-07-11Simplify guts and calling of getuint(). Eliminate a useless 'help'Kenneth R Westerback
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@
2012-07-09We always want to do unit conversions. So flags parameter of getuint()Kenneth R Westerback
is now superflous. With rounding gone the offset parameter is similarly superfluous. Simply getuint() accordingly.
2012-07-09I want some of what kjell was smoking 10 years ago when he addedKenneth R Westerback
units handling by copying getuint() from disklabel. MBR partition id and disklabel partition type are different beasts. So deciding to round off a MBR partition with id FS_BSDFFS meant rounding off NTFS partitions. And FS_SWAP partitions meant DOS FAT 12. So just nuke rounding off for now to simplify getuint(). ok beck@
2012-07-09Make 'swap' command work like fdisk(8) says -- you must supply two validKenneth R Westerback
partition numbers.
2012-07-09Use strtonum() instead of strtol() inside ask_num(). Many overflowsKenneth R Westerback
are thus avoided. Since bounds are now reliable don't check the returned value for being in-bounds. Since default value is forced inside bounds, don't bother being tricky and passing a default that is outside the bounds being specified. ok beck@
2012-07-08set_pid() does not need prompt string, low or high parameters. TheseKenneth R Westerback
are all constants. Independantly suggested by guenther@.
2012-07-08Split out an ask_pid() function rather than over-parameterizing theKenneth R Westerback
ask_num() function. Remove now unneeded 'flags' and 'help' parameters from both. Display out of range values in hex in ask_pid(), since we are seeking hex input. ok guenther@
2012-07-08Call Xsetpid() to edit the partition type from Xedit() rather thanKenneth R Westerback
duplicating the code. Allows simplification of the EDIT() #define in Xedit() since we always ASK_DEC and use a NULL help parameter when invoking ask_num().
2012-07-08Nuke useless EDIT() #define in Xsetpid.Kenneth R Westerback
A #define to simplify a function calling snippet does not simply or help when it is used only once.
2012-07-08Replace tricker atoi() and hand rolled parsing with strsep() andKenneth R Westerback
strtonum(). Make related error messages consistant. ok haesbaert@
2012-07-07Replace atoi() with strtonum() where it's easy. Make related errorKenneth R Westerback
messages consistant. Check for valid partition when 'select'ing a partition. ok haesbaert@
2012-04-25Before writing it to disk, warn the user if their new MBR containsMatthew Dempsky
more than one OpenBSD partition. ok deraadt
2011-11-11A zero-length partition is a non-partition, so reject a partitionKenneth R Westerback
length of 0. And anyway PRT_fix_CHS() writes garbage when length is zero. Refresh the in-memory copy to reflect any data that was written out, so you can see that your changes have taken effect. Surprise behaviours noted by matthew@ at c2k11.
2010-07-02on error, getuint() will return UINT_MAX. Instead of actually usingAlexander Hall
that value, print an error message and repost the question ok krw@ deraadt@
2009-12-24spelling fixes, from Brad Tilley; we will not fix src/sbin/dump/dump.hIgor Sobrado
as neither arrayified not arrayfied exist -- sanctioned dictionaries like Merriam-Webster ones suggest a few alternatives (e.g., arrayed), however these made up words are easy to understand and we are not certain that current ones are not ok. ok jmc@
2009-02-08Eliminate excessive verbiage for 'fdisk -i' and 'fdisk -u'. EspeciallyKenneth R Westerback
the multi-line banner announcing that the MBR is being changed. Also the listing of the partition table in 'fdisk -u'. Display a consistant message when the MBR is written. While here cleanup and shrink code without changing any semantics. Started with a diff posted on tech@ by Tobias Ulmer. "I like it" marco@ ok jsing@
2006-07-27Add checks to each write(2) attempt and try to keep fdisk in aRay Lai
consistent state upon write failure. OK krw@ and deraadt@.
2006-07-18Fix a typo, paritition -> partition.Marc Balmer
From Alexey Dobriyan <adobriyan@gmail.com>, thanks.
2006-04-26man page is gzip'd, should store as unsigned char array.Theo de Raadt
2005-03-29Allow setting of partition flag with an optional explicit value. PR 4143.Otto Moerbeek
ok weingart@ deraadr@
2005-01-19add a swap primitive; ok various, will be polished after by tomTheo de Raadt
2004-11-06gzip embedded man pages, and pipe through gunzip when viewing.Otto Moerbeek
ok deraadt@
2004-09-18some delinting; ok ottoTheo de Raadt
2004-07-13Remove unused argument 'int pn' to PRT_fix_CHS(). The 'int pn'Tom Cosgrove
argument to PRT_parse() then becomes unused, so remove that too. ok henning@, otto@
2004-06-22Make the interactive "update" command match the command-line "-u"Tom Cosgrove
option by updatng/setting the 0xAA55 signature at the end of the sector. ok nick@ weingart@
2003-06-11ansificationTheo de Raadt
2003-06-03Nuke terms 3 & 4.Tobias Weingartner
2002-01-24allow reinitializing mbr in the ext parts; from Matt Watson <mwatson@apple.com>Michael Shalayeff
2002-01-18Allow size values to be displayed in the user's choice of units.Kjell Wooding
Idea borrowed from disklabel. i.e. Users can now type "print M" and be rewarded with partition sizes in Megs
2002-01-18Add disklabel-style editing for size/offset values inKjell Wooding
the partition tables. These values may now contain units, such as "300k" "500M" or "2G". (sectors, bytes, and cylinders are also supported.) This should largely eliminate the need for a calculator when using fdisk on large disks.
2001-01-28More -Wall cleanup. Ansi style nit.Tobias Weingartner
2001-01-01New command "setpid", just changes the ID of a partition (no otherAngelos D. Keromytis
parameters editing) -- vassilip@dsl.cis.upenn.edu
2000-07-01be more verbose when warning for partition errors,Michael Shalayeff
print partition number in the message.
2000-04-18Favor BIOS geometry over physical. This should fix MANY problems withKjell Wooding
hard drives >8G sharing partitions with other operating systems. Also, support extended partition type 0x0F, which is quite common now.
2000-02-04Max Sectors is 63. ok weingart@Kjell Wooding
2000-01-08support LBA-mapped extended partitions too; ↵Theo de Raadt
sigh@kuzirabekon.econ.nagasaki-u.ac.jp
1999-08-21MIPS boxes that use fdisk need an MS-DOS partitionNiklas Hallqvist
1999-06-10Handle PAGER in a manner consistent with the Single Unix Specification:Paul Janzen
that is, use PAGER rather than "more" if it is defined and non-null, not just if it is defined.
1998-09-14Since on the powerpc, the system does not supply the user withDale S. Rahn
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.
1998-09-08For powerpc's we want to keep the preinstalled msdos partition in the initPer Fogelstrom
MBR when doing a 'fdisk -i'. That is because the msdos partition is used for booting. The OpenBSD part (part 3) is set up to be the rest of the disk. Also the msdos partition is set as the 'active' partition.
1998-08-08Include signal.h so that it compiles.Jason Downs
1998-08-07protect against SIGPIPETodd C. Miller
1998-01-04fix maximal cyl/heads; vons@usa.netTheo de Raadt
1997-12-23swap exit and quitTheo de Raadt
1997-10-21make fdisk grok extended partitions again. we have to keep track of theNiels Provos
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.
1997-10-19when we reinit, show what we didTheo de Raadt
1997-10-19spellingTheo de Raadt
1997-10-19clarifyTheo de Raadt