Commit Graph

82 Commits

Author SHA1 Message Date
Simon L. B. Nielsen
aee85526aa - Fail with an understandable error message if we cannot detect the
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
2006-06-18 22:02:22 +00:00
Craig Rodrigues
d63612b470 Call gctl_free() to free resource allocated with gctl_get_handle().
PR:		bin/84664
Submitted by:	Daan Vreeken <Danovitsch at Vitsch dot net>
MFC after:	3 days
2005-09-17 14:56:10 +00:00
Poul-Henning Kamp
de78c288db Attempt gctl verb "write MBR" when updating.
This should solve the problem of modifying a busy MBR.
2005-07-15 08:02:51 +00:00
Yoshihiro Takahashi
7fa181d423 cosmetic changes. 2005-05-01 09:50:02 +00:00
Yoshihiro Takahashi
61456bbd76 Use NDOSPART macro instead of a magic number. 2005-05-01 05:01:55 +00:00
Poul-Henning Kamp
ca4cc47388 If we resort to opening a slice instead of the base device, do so with
the correct mode for our arguments.
2005-04-29 21:24:27 +00:00
Poul-Henning Kamp
59a514685c Add 0xbf as new partition id for Solaris.
Submitted by:	Lawrence.Lee@sun.com
2004-11-10 07:48:29 +00:00
Ruslan Ermilov
26cd344960 Don't prepend "/dev" if an argument given is an absolute pathname.
Reviewed by:	jhb
2004-10-20 05:43:45 +00:00
Poul-Henning Kamp
a67ed623d0 Make fdisk initialize the first instead of the last slice by default. 2004-06-14 07:21:19 +00:00
Hartmut Brandt
bb00732864 Add the Solaris x86 boot partition type. This is used in Solaris 10
(and perhaps earlier).

Submitted by:	Joerg Schilling <schilling@fokus.fraunhofer.de>
2003-12-18 13:13:02 +00:00
Dag-Erling Smørgrav
7fb7df3159 Warn about partitions that would overlap with the master boot record, and
if the user agrees, move them out one track.

MFC after:	7 days
2003-11-13 21:13:43 +00:00
David E. O'Brien
c69284ca08 Use __FBSDID() to quiet GCC 3.3 warnings. 2003-05-03 18:41:59 +00:00
Poul-Henning Kamp
1a03d6d57a Use symbolic constants from <sys/diskmbr.h> instead of local constants.
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.
2003-04-13 21:57:08 +00:00
Poul-Henning Kamp
c0fdfdba29 Use default geometry in case the device doesn't provide one:
512 for sectorsize.
	63 for sectors.
	255 for heads.
This will mostly show up on MD(4) devices.
2003-03-29 22:06:52 +00:00
Jens Schweikhardt
d64ada501a Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.
2002-12-30 21:18:15 +00:00
Poul-Henning Kamp
f353c761f7 Make fdisk work on active GEOM devices. 2002-12-29 15:17:11 +00:00
Poul-Henning Kamp
a8ad364a7f Fix the regexp evilness so that fdisk can (again?) find the device
root is on from the root mount path.

Spotted by:	imp
2002-10-27 10:52:54 +00:00
Poul-Henning Kamp
8b4d099d5f Don't attempt to find the geometry with disklabel based ioctl, it just
issues a useless warning now.
2002-10-27 10:33:38 +00:00
Poul-Henning Kamp
3bb24c35f2 Split MBR and PC98 on-disk sliceformats out from disklabel.h, step 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.
2002-10-01 07:24:55 +00:00
Poul-Henning Kamp
7963fae61f Straighten out get_params().
Sponsored by:	DARPA & NAI Labs.
2002-09-20 08:12:51 +00:00
Poul-Henning Kamp
3f8ba8b5f8 Try to pick up disk geometry with specific DIOC* ioctls, rather than
expecting a bogo-disklabel to contain them, if possible.

This makes fdisk work with GEOM.
2002-09-15 16:08:52 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Bruce Evans
689fee8724 Fixed some print format errors. Avoid some warnings about possible
(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.
2002-07-16 23:18:29 +00:00
Peter Wemm
29ea697d8a Add a hack so that fdisk(8) can initialize an ia64 disk. There is
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.
2002-05-01 06:48:29 +00:00
Greg Lehey
1254a3ba7b Add partition type for IBM's JFS.
Submitted by:	Hiten Pandya <hiten@uk.FreeBSD.org>
2002-04-28 01:52:17 +00:00
Tom Rhodes
05a213f1e8 Fix the fdisk(8) manual page.
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
2002-04-18 16:25:18 +00:00
Poul-Henning Kamp
041b8b0058 Get this to WARNS=4 and closer to style(9) at a sacrifice in
linelength.
2002-03-29 19:33:14 +00:00
Josef Karthauser
978d3bfe9c Add some more partition types.
PR:		i386/14793
MFC after:	3 days
2002-02-18 19:32:38 +00:00
Ian Dowse
881c9063c7 Oops, the arguments to a bcopy() were reversed, which broke zeroing
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
2001-12-30 18:51:51 +00:00
Bruce Evans
2175f5f1b9 Fixed spelling error in previous commit. 2001-10-16 10:52:12 +00:00
Peter Wemm
a528d3185a Add 0xEE (EFI GPT) and 0xEF (EFI System Partition) 2001-10-15 07:21:32 +00:00
Ian Dowse
6369218752 Fix a number of bugs and annoyances in fdisk, many of which were
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
2001-08-05 16:24:13 +00:00
Joerg Wunsch
df77f711f3 After some (long-standing ;-) critics from Bruce, throw away the old
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. :)
2001-07-13 16:48:56 +00:00
Joerg Wunsch
8de9ed220e Make open_disk() fail nicely upon encountering an ENOENT so to not
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
2001-07-05 10:04:43 +00:00
David E. O'Brien
6580291ba4 I didn't maintain the "chs" ordering. Rather the bug was in print_part().
Requested by:	bde.
2000-11-29 20:22:47 +00:00
David E. O'Brien
0469c254fb Make the order of values prompted for with the "-i" option match print_part() 2000-11-18 02:55:43 +00:00
John Baldwin
b594e0fea2 - When adjusting the end of a partition to lie on a cylinder boundary, don't
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
2000-08-24 17:54:45 +00:00
Josef Karthauser
197ef30718 0xA0 = Suspend to disk. 2000-08-07 00:26:09 +00:00
John Baldwin
fe81981fdb Fix a really stupid bug where I assumed sizeof(int) == 2. This resulted in
MBR's with a 4th slice failing the signature check and fdisk saying that
they are invalid.

Submitted by:	bde
2000-07-21 18:26:20 +00:00
John Baldwin
a12de06299 - Don't try to free mboot.bootinst before it has been allocated. If, for
some reason, mboot.bootinst is not initialized to NULL at the beginning
  of the program, then the last commit to this would try to free whatever
  bogus address is in it.
- Restore the behavior of free()'ing the mboot.bootinst buffer after we
  abuse it to determine the sector size of the disk (as clearly noted in
  the comments).  Properly fix the double free() bug by setting the pointer
  to NULL after we free it.
2000-07-17 19:51:42 +00:00
Andrey A. Chernov
2b5ce8a961 Fix memory leak/double free found by phkmalloc
Uniform mboot.bootinst allocation code to be independent of functions order
2000-07-15 13:37:47 +00:00
John Baldwin
85c2cf303d - Always respect cylinder boundaries when creating slices unless the user
explicitly sets the geometry.
- Allow for MBR boot loaders that are longer than one sector.  Only accept
  boot loaders if their size is a multiple of the sector size, however.
2000-07-12 16:45:11 +00:00
John Baldwin
ed1235ad70 Catch the usage() function up to the command line changes. Add -I and
remove -e.
2000-06-27 20:36:44 +00:00
Brian Somers
35bfe0c305 0x39 == plan9
Obtained from: OpenBSD
2000-06-12 09:08:40 +00:00
Guy Helmer
691e5f80b5 Add QNX 4 partitions to fdisk's list.
PR:		bin/8809
Submitted by:	"John C. Place" <jcplace@ibm.net>
Prompted by:	<nrahlstr@winternet.com>
2000-06-09 19:10:09 +00:00
Mike Smith
149938cc61 Don't try to open the /dev/rXXX device. 2000-05-31 00:58:55 +00:00
Warner Losh
10b0ee9392 -e -> -I change.
-s for sumary

Approved by:	jkh
2000-03-10 22:03:00 +00:00
David E. O'Brien
dc6bbfb6f8 Don't use the old raw name for disk devices. 2000-03-09 19:35:32 +00:00
Ruslan Ermilov
cb840fc730 Add ata(4) support.
Approved by:	jkh
2000-02-11 11:25:23 +00:00
Bill Fumerola
cefdc4ef10 Stuff a variable declaration inside a #if block that is only used for that
#if.
1999-09-25 02:11:30 +00:00