summaryrefslogtreecommitdiff
path: root/sbin/fdisk
AgeCommit message (Collapse)Author
2012-08-14remove unused variableCharles Longeau
ok krw@
2012-07-25do not check ns here, we're supposed to compute it; ok krw@ deraadt@Otto Moerbeek
2012-07-11MBR can't handle the truth.Kenneth R Westerback
When reading disk size/geometry from disklabel, clamp disk size to the maximum number of cylinders that fit into UINT32_MAX sectors. Don't just use the bottom 32 bits of the DL_GETDSIZE(). Warn that truncation has been done.
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
2012-04-04Don't 'reserve' a head/track if there is only only 1 head and 1Kenneth R Westerback
cylinder. If there is only one head but multiple cylinders reserve one cylinder. Prevents nonsense MBR being created on scsi attached floppies, which have a 'geometry' of 1/1/2888. No change to less pathological cases.
2011-12-25printf("msg")/return 1 -> err(1, "msg"), which will also show relevantKenneth R Westerback
errno string. Since we are err()'ing out, don't worry about closing MBR fd first.
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.
2011-07-05Add DIOCGPDINFO to rxioctl(), as a synonym for DIOCGDINFO, the lastKenneth R Westerback
place it was missing. Delete now redundant calls to DIOCGDINFO when getting physical disk info in disklabel(8) and fdisk(8). Reminded by a fdisk discussion with Andres Perera on tech@. ok deraadt@
2011-06-23switch to installing source manuals (base part)Ingo Schwarze
discussed with lots of people, tested by naddy@, "move fast" deraadt@
2011-06-20MBR_read() can be reading from a file as well as a raw partition.Kenneth R Westerback
And files can be smaller (e.g. 512 bytes like /usr/mdec/mbr) than a disk sector (e.g. 4096 bytes on pirofti's external disk drive). So relax the length test on the read() result to < DEV_BSIZE (the amount of data we actually want) instead of < secsize (the minimum size that read() will accept). 'fdisk -e' and 'fdisk -i' now work on devices with sector sizes greater than DEV_BSIZE.
2011-02-21Honour MBR_read() results and don't pretend we can parse blocks weKenneth R Westerback
did not successfully read. Tweak some casts. Fixes infinite loop problem noted by jeremy@ while installing on boxen with 'random' garbage in MBR. General loop detection may follow post-4.9. Tested by jeremy@ and ok miod@
2010-12-03disklabel now uses "duid", not "uid";Jason McIntyre
2010-11-22Update example disk partition info to more current reality. NoticedKenneth R Westerback
by and diff from Roberth via tech@. ok jmc@
2010-07-05improve description for -i; as a consequence of recent changes,Igor Sobrado
OpenBSD MBR partition does not span from sector 1 after MBR partition data is re-initialized. written with lot of good advice from deraadt@ and jmc@ ok deraadt@
2010-07-04make ^D handling consistant in fdisk by just bailing out instead ofAlexander Hall
returning a magic value that is not even handled as such by the caller ok krw@
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@
2010-06-30Make 'fdisk -i' start the OpenBSD partition on a power of 2 512-byteKenneth R Westerback
block boundary. In most modern (i.e. 'faked' geometry) situations this will start it at (0-based) block[64] rather than block[63] as now. This should help performance on disks which really have 4K sectors but report 512-byte sectors. Power of 2 idea from deraadt@. ok toby@ deraadt@
2010-05-25match usage to the manual page, and borrow the description of 'disk'Theo de Raadt
from disklabel(8), since it describes the effect of using opendev()
2010-05-20document the optional arg to "flag", as requested by Thomas Pfaff;Jason McIntyre
this version after some feedback from krw and otto; ok otto krw
2010-05-18dont let sys/ioctl.h imply that you get the ioctls in dkio.h. thisDavid Gwynne
gets rid of #include <sys/dkio.h> in sys/ioctl.h and adds #include <sys/dkio.h> to the places that actually want and use the disk ioctls. this became an issue when krw@'s X build failed when he was testing a change to dkio.h. tested by krw@ help from and ok miod@
2010-03-27remainer->remainder; from miodJason McIntyre
2010-03-27various improvements from Anders Langworthy, with some tweaksJason McIntyre
from krw and myself; ok deraadt krw
2010-03-22introduce HAS_MBR and let make define it for the right machines;Otto Moerbeek
requested by miod@; ok miod@ krw@
2010-02-17loongson has mbr as well; ok miod@ (but he made me promise to makeOtto Moerbeek
a -DHAVE_MBR diff after release)
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-07-24properly sanitize the default value in ask_num(...)Alexander Hall
2009-04-29code that stank and made me upsetTheo de Raadt
2009-04-07Fix the default value to be between low/high range. Thanks forTobias Weingartner
frantisek holop pointing out the issue. ok deraadt@
2009-04-01Remove duplicate entry for partition id 0x07 so NTFS partitionsJonathan Gray
will show as NTFS in fdisk output. ok todd@ otto@ deraadt@
2009-03-30some improvements inspired by a mail on misc@ from frantisek holop:Jason McIntyre
- clarify the terms geometry sectors field and start field - change the fdisk prompt from 0 to 1, and explain its meaning - temper CAVEATS: the note is "common practice", not mandatory from nick and myself
2009-03-24two more MBR partition namesTodd T. Fries
ok otto@ beck@
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@
2008-12-01Back out previous; it broke specifying paritions sizes with decimals,Ray Lai
e.g. "0.5g".
2008-12-01Check for invalid integers passed getuint(); instead of getuint()Ray Lai
returning an error, just reprompt. If there is an error reading from stdin, use the old (default) value. Shrinks fdisk a few bytes! OK deraadt.
2008-05-31add hfs+ type. deraadt@ okFederico G. Schwindt
2008-05-13fix an error in the example partition table; from Adam PattersonJason McIntyre
ok nick
2008-02-18adjust width of S column to improve printing of the MBR partition tableIgor Sobrado
on modern disk geometries; while here, better alignment of column labels ok jmc@, jsing@, krw@, and otto@
2007-12-30sort flags in both synopsis and usage, file not commited in last diffIgor Sobrado
ok jmc@
2007-12-30sort flags in both synopsis and usageIgor Sobrado
ok jmc@