aboutsummaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
Commit message (Collapse)AuthorAgeFilesLines
* Enhance the 'p' command so that it understands size qualifiers (K/M/G) andBrian Somers2009-05-251-6/+82
| | | | | | | | | | | so that it understands '*' as 'DTRT'. PR: 68312 Submitted by: Rene de Vries - rene at tunix dot nl (mostly) MFC after: 3 weeks Notes: svn path=/head/; revision=192745
* Reword some entries for NTFS and DOS.Luigi Rizzo2009-01-141-2/+4
| | | | | | | | | Add entries for DELL and ASUS recovery partitions. MFC after: 3 days Notes: svn path=/head/; revision=187248
* Another change from Christoph:Luigi Rizzo2009-01-141-110/+101
| | | | | | | | | | | | | replace the table of partition with a simpler and faster array of strings. The change in the array is done mechanically, using vi commands. Most entries in the table are probably 15+ years old and largely outdated, so the next step is to remove stale entries with more current values. Submitted by: Christoph Mallon, with small changes from me MFC after: 3 days Notes: svn path=/head/; revision=187246
* more changes from Christoph:Luigi Rizzo2009-01-141-15/+14
| | | | | | | | | | | pass a pointer instead of an index to print_part() so it does not depend on a static variable. Submitted by: Christoph Mallon MFC after: 3 days Notes: svn path=/head/; revision=187241
* remove unused argument to print_s0()Luigi Rizzo2009-01-141-11/+8
| | | | | | | | Submitted by: Christoph Mallon MFC after: 3 days Notes: svn path=/head/; revision=187239
* Some small fixes submitted by Christoph Mallon, specifically:Luigi Rizzo2009-01-131-17/+16
| | | | | | | | | | | | | | | | + Remove a dead field of a struct. It serves no purpose anymore. + Remove a \n at the end of the format string of err(); the err() function already adds a \n ; + remove many unnecessary casts which obfuscate the code. This file has a huge number of indentation bugs, but I'd rather fix them when/if we happen to modify the relevant parts of the code. Submitted by: Christoph Mallon MFC after: 3 days Notes: svn path=/head/; revision=187203
* - Improve error message given on g_providername call failure.Ulf Lilleengen2008-09-301-1/+1
| | | | | | | | | - While there, make error messages consistent with the rest. Approved by: kib (mentor) Notes: svn path=/head/; revision=183487
* - Make use of the new and g_device_path utility function in libgeom to avoidUlf Lilleengen2008-09-071-49/+30
| | | | | | | | | | | | duplication of code in fdisk and boot0cfg. Also make use of g_providername to fix an issue with fdisk and boot0cfg not using the correct provider when writing the MBR. Reviewed by: phk Approved by: pjd (mentor) Notes: svn path=/head/; revision=182844
* Add a -q[uiet] flag for scripts.David E. O'Brien2008-07-311-3/+8
| | | | Notes: svn path=/head/; revision=181036
* Add Apple HFS+ (0xAF) MBR partition type identificator.Andre Oppermann2007-05-061-0/+1
| | | | | | | Submitted by: rpaulo (SoC2007 student) Notes: svn path=/head/; revision=169324
* o Add -p flag: print a slice table in fdisk configuration file format.Maxim Konovalov2007-04-301-2/+28
| | | | | | | | | | | Now it is possible to do something like fdisk -p ad0 | fdisk -f - ad1. PR: bin/110182 Submitted by: Jukka A. Ukkonen MFC after: 1 month Notes: svn path=/head/; revision=169143
* - Fail with an understandable error message if we cannot detect theSimon L. B. Nielsen2006-06-181-2/+5
| | | | | | | | | | | | | | | | | | | sector size, instead of later failing with an error about /boot/mbr not being a multiple of the sector size (since we end up with an assumed sector size of MAX_SEC_SIZE * 2). - We query the sector size via an IOCTL anyway, so if that succeeds use that instead of probing for it via read(2) calls. This fixes the problem with fdisk failing to operate on at least graid3 and md(4) devices on kernels with src/sys/geom/geom_dev.c before rev. 1.90, due to fdisk failing to detect the sector size. - When detecting the root device allow "/" characters in it, which happens with e.g. gmirror devices. Reviewed by: cperciva MFC after: 1 week Notes: svn path=/head/; revision=159757
* Call gctl_free() to free resource allocated with gctl_get_handle().Craig Rodrigues2005-09-171-1/+4
| | | | | | | | | PR: bin/84664 Submitted by: Daan Vreeken <Danovitsch at Vitsch dot net> MFC after: 3 days Notes: svn path=/head/; revision=150249
* Attempt gctl verb "write MBR" when updating.Poul-Henning Kamp2005-07-151-27/+42
| | | | | | | This should solve the problem of modifying a busy MBR. Notes: svn path=/head/; revision=148035
* cosmetic changes.Yoshihiro Takahashi2005-05-011-17/+15
| | | | Notes: svn path=/head/; revision=145763
* Use NDOSPART macro instead of a magic number.Yoshihiro Takahashi2005-05-011-2/+2
| | | | Notes: svn path=/head/; revision=145747
* If we resort to opening a slice instead of the base device, do so withPoul-Henning Kamp2005-04-291-1/+1
| | | | | | | the correct mode for our arguments. Notes: svn path=/head/; revision=145690
* Add 0xbf as new partition id for Solaris.Poul-Henning Kamp2004-11-101-0/+1
| | | | | | | Submitted by: Lawrence.Lee@sun.com Notes: svn path=/head/; revision=137511
* Don't prepend "/dev" if an argument given is an absolute pathname.Ruslan Ermilov2004-10-201-1/+1
| | | | | | | Reviewed by: jhb Notes: svn path=/head/; revision=136720
* Make fdisk initialize the first instead of the last slice by default.Poul-Henning Kamp2004-06-141-3/+3
| | | | Notes: svn path=/head/; revision=130452
* Add the Solaris x86 boot partition type. This is used in Solaris 10Hartmut Brandt2003-12-181-0/+1
| | | | | | | | | (and perhaps earlier). Submitted by: Joerg Schilling <schilling@fokus.fraunhofer.de> Notes: svn path=/head/; revision=123637
* Warn about partitions that would overlap with the master boot record, andDag-Erling Smørgrav2003-11-131-0/+5
| | | | | | | | | if the user agrees, move them out one track. MFC after: 7 days Notes: svn path=/head/; revision=122627
* Use __FBSDID() to quiet GCC 3.3 warnings.David E. O'Brien2003-05-031-4/+2
| | | | Notes: svn path=/head/; revision=114589
* Use symbolic constants from <sys/diskmbr.h> instead of local constants.Poul-Henning Kamp2003-04-131-13/+15
| | | | | | | | | | | | | | | | | | | | | Always set the magic sequence when we write, rather than trusting the previously read boot code to do so. Use explicit encoding/decoding of little endian disk image. Remove a comment which was OBE. Change the test vector for "fdisk -I" to reflect that there is a magic sequence in the result now. Add test case for "fdisk" which reads the image back. At least for the two test-cases this program now gives the same result on sparc64 as on i386. The lack of an installed /boot/mbr on sparc64 raises an (un)interesting question. Notes: svn path=/head/; revision=113454
* Use default geometry in case the device doesn't provide one:Poul-Henning Kamp2003-03-291-1/+6
| | | | | | | | | | 512 for sectorsize. 63 for sectors. 255 for heads. This will mostly show up on MD(4) devices. Notes: svn path=/head/; revision=112826
* Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/Jens Schweikhardt2002-12-301-2/+2
| | | | | | | Add FreeBSD Id tag where missing. Notes: svn path=/head/; revision=108470
* Make fdisk work on active GEOM devices.Poul-Henning Kamp2002-12-291-8/+33
| | | | Notes: svn path=/head/; revision=108395
* Fix the regexp evilness so that fdisk can (again?) find the devicePoul-Henning Kamp2002-10-271-1/+1
| | | | | | | | | root is on from the root mount path. Spotted by: imp Notes: svn path=/head/; revision=106033
* Don't attempt to find the geometry with disklabel based ioctl, it justPoul-Henning Kamp2002-10-271-15/+0
| | | | | | | issues a useless warning now. Notes: svn path=/head/; revision=106031
* Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 1:Poul-Henning Kamp2002-10-011-0/+1
| | | | | | | | | | | | | | | | | | | Peter had repocopied sys/disklabel.h to sys/diskpc98.h and sys/diskmbr.h. These two new copies are still intact copies of disklabel.h and therefore protected by #ifndef _SYS_DISKLABEL_H_ so #including them in programs which already include <sys.disklabel.h> is currently a no-op. This commit adds a number of such #includes. Once I have verified that I have fixed all the places which need fixing, I will commit the updated versions of the three #include files. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=104272
* Straighten out get_params().Poul-Henning Kamp2002-09-201-32/+33
| | | | | | | Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=103665
* Try to pick up disk geometry with specific DIOC* ioctls, rather thanPoul-Henning Kamp2002-09-151-1/+21
| | | | | | | | | expecting a bogo-disklabel to contain them, if possible. This makes fdisk work with GEOM. Notes: svn path=/head/; revision=103348
* s/filesystem/file system/g as discussed on -developersTom Rhodes2002-08-211-6/+6
| | | | Notes: svn path=/head/; revision=102231
* Fixed some print format errors. Avoid some warnings about possibleBruce Evans2002-07-161-4/+5
| | | | | | | | | (but not actual) alignment problems. Both of these bugs were detected on ia64's and were fatal on ia64's due to premature setting of WARNS to 4. Notes: svn path=/head/; revision=100202
* Add a hack so that fdisk(8) can initialize an ia64 disk. There isPeter Wemm2002-05-011-0/+10
| | | | | | | | no /boot/mbr to read the boot code from (ia64 does not *have* bootblocks!). fdisk depended on magic in the /boot/mbr file to initialize some fields. Notes: svn path=/head/; revision=95860
* Add partition type for IBM's JFS.Greg Lehey2002-04-281-0/+1
| | | | | | | Submitted by: Hiten Pandya <hiten@uk.FreeBSD.org> Notes: svn path=/head/; revision=95602
* Fix the fdisk(8) manual page.Tom Rhodes2002-04-181-5/+5
| | | | | | | | | | | | s/partition/slice/ in fdisk.8 fix a bug in fdisk(8) where it did not honer -t when using -I PR: 36563 and 35688 Submitted by: bde Reviewed by: bde Notes: svn path=/head/; revision=95002
* Get this to WARNS=4 and closer to style(9) at a sacrifice inPoul-Henning Kamp2002-03-291-299/+101
| | | | | | | linelength. Notes: svn path=/head/; revision=93394
* Add some more partition types.Josef Karthauser2002-02-181-26/+56
| | | | | | | | PR: i386/14793 MFC after: 3 days Notes: svn path=/head/; revision=90866
* Oops, the arguments to a bcopy() were reversed, which broke zeroingIan Dowse2001-12-301-3/+2
| | | | | | | | | | | | of unused partition entries and later detection of unused entries. Use memcpy to be consistent with the rest of the code, and fix a minor style nit. Submitted by: bde Notes: svn path=/head/; revision=88714
* Fixed spelling error in previous commit.Bruce Evans2001-10-161-1/+1
| | | | Notes: svn path=/head/; revision=85027
* Add 0xEE (EFI GPT) and 0xEF (EFI System Partition)Peter Wemm2001-10-151-0/+2
| | | | Notes: svn path=/head/; revision=84964
* Fix a number of bugs and annoyances in fdisk, many of which wereIan Dowse2001-08-051-71/+93
| | | | | | | | | | | | | | | | | | | | | | | pointed out by bde: - Ask for user confirmation before adjusting to a head/cylinder boundary (only when running interactively), and separate this adjustment from the automatic calculation of c/h/s parameters. - In sanitize_partition, don't change any values in the slice until we know that the automatic adjustment will succeed. - When auto-adjusting, ignore unused slices and give an appropriate error for other zero-size slices depending on the cause. - Change dos() to do all of the c/h/s calculations for a whole slice; this fixes a bug where the ending c/h/s of an unused slice was set incorrectly. - When changing the active slice, detect the currently active slice number instead of always defaulting to slice 4. - Call fflush(stdout) before calling fgets(). - Test for fgets() returning NULL so we don't loop on EOF. Reviewed by: bde Notes: svn path=/head/; revision=81164
* After some (long-standing ;-) critics from Bruce, throw away the oldJoerg Wunsch2001-07-131-30/+60
| | | | | | | | | | | | | | | | | device search code i introduce nearly six years ago in rev 1.8. Bruce suggested to rather use the device name of the root filesystem instead which is certainly the most sensible default. Since there are many possible cases for a root filesystem name (device with and without slices, consider /dev/vinum/root even though it currently could not work as such), there's some heuristic using a RE in order to find out the canonical device name from the mounted name. This probably won't quite fit for a NFS root (can't test that right now), but then, there's hard to find a good default for those machines anyway. ;-) This unbreaks the functionality of rev 1.2 i once broke in 1.8. :) Notes: svn path=/head/; revision=79681
* Make open_disk() fail nicely upon encountering an ENOENT so to notJoerg Wunsch2001-07-051-2/+4
| | | | | | | | | | | | | prematurely terminate the search for a usable disk. ENOENT is quite normal in particulare now with the advent of devfs. While being here, also remove /dev/wd0 and /dev/od0 from the list of disks to search since we don't have them anymore. MFC after: 1 week Notes: svn path=/head/; revision=79306
* I didn't maintain the "chs" ordering. Rather the bug was in print_part().David E. O'Brien2000-11-291-6/+6
| | | | | | | Requested by: bde. Notes: svn path=/head/; revision=69371
* Make the order of values prompted for with the "-i" option match print_part()David E. O'Brien2000-11-181-2/+2
| | | | Notes: svn path=/head/; revision=68871
* - When adjusting the end of a partition to lie on a cylinder boundary, don'tJohn Baldwin2000-08-241-46/+94
| | | | | | | | | | | | | | adjust the size, but the actual end. - Break out some of the sanity checks on partitions into a sanitize_partition function. - When adjusting partitions, always adjust the start "up", and the end "down" so that we stay within the boundaries of the original request. - Various small nits found by bde. Reported by: bde, imp, rgrimes Notes: svn path=/head/; revision=65054
* 0xA0 = Suspend to disk.Josef Karthauser2000-08-071-0/+1
| | | | Notes: svn path=/head/; revision=64316
* Fix a really stupid bug where I assumed sizeof(int) == 2. This resulted inJohn Baldwin2000-07-211-1/+1
| | | | | | | | | | MBR's with a 4th slice failing the signature check and fdisk saying that they are invalid. Submitted by: bde Notes: svn path=/head/; revision=63729