Commit Graph

115 Commits

Author SHA1 Message Date
Conrad Meyer
ac8e5d02cf Remove deprecated GEOM classes
Follow-up on r322318 and r322319 and remove the deprecated modules.

Shift some now-unused kernel files into userspace utilities that incorporate
them.  Remove references to removed GEOM classes in userspace utilities.

Reviewed by:	imp (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D21249
2019-08-13 20:06:55 +00:00
Conrad Meyer
276b25f172 Add DragonFly's partition number to fdisk(8) and diskmbr.h
This change doesn't make any attempt to add support for these slices to the
relevent GEOM classes.  Just register the number in fdisk and the canonical
list of kernel macros (diskmbr.h).

Obtained from:	DragonFlyBSD (794d80aa519b394b3174f20776a) (small subset of)
2019-05-18 00:22:28 +00:00
Rodney W. Grimes
554e6a7563 Allow fdisk(8) to deal with sectors larger than 2048
especially for 4Kn drives with PMBR's

Approved by:    bde (mentor)
MFC:            3 days
2018-10-25 12:13:13 +00:00
Pedro F. Giffuni
fbcfcbbc5b fdisk: drop unused macro and make use of roundup()/rounddown(). 2016-04-30 19:58:54 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Juli Mallett
c69a7a718d Fix fdisk(8) to create 2TB partitions on disks larger than 2TB, rather than
only being able to create 1TB partitions:
o) Use an unsigned 32-bit quantity to store the number of disk sectors.
o) Detect overflow of said 32-bit quantity and clamp to 2^32.
o) Rather than returning the disk sector count from get_params, return 0 on
   success, since its return value is only ever compared to -1 to detect
   failure.  This would cause returning 2^32 sectors to be interpreted as an
   error.

Reviewed by:	bde ("good for a quick fix")
2013-11-27 17:59:13 +00:00
Dmitry Morozovsky
f933af5dbf VMware environment is frequent nowadays. Add VMFS id.
MFC after:	2 weeks
2012-04-16 17:30:19 +00:00
Andrey V. Elsukov
39e9a28fdf Fix multi-line comment formatting.
Pointed by:	jh
MFC after:	1 week
2011-11-07 07:50:35 +00:00
Andrey V. Elsukov
fd1ca22afb Improve error reporting when MBR can not be written.
Remove obsolete code which uses DIOCSMBR ioctl.
When writing MBR first check that GEOM_MBR is available, if it is not
available, then try write MBR directly to provider. If both are failed,
then recommend to use gpart(8).

MFC after:	2 week
2011-11-07 06:24:35 +00:00
Andrey V. Elsukov
1b100fd31b Initialize "acc" value inside the loop to reset failed attempts.
PR:		misc/162262
MFC after:	3 days
2011-11-06 21:12:52 +00:00
Ed Schouten
1efe3c6b58 Add missing static keywords for global variables to tools in sbin/.
These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.
2011-11-04 13:36:02 +00:00
John-Mark Gurney
21fa393279 remove trailing whitespace...
MFC after:	1 week
2011-10-29 17:30:57 +00:00
John-Mark Gurney
469a1218c0 error if /boot/mbr is empty... This can happen on a system like arm
that doesn't have a /boot/mbr, and you touch it to get past the previous
error message...

MFC after:	1 week
2011-10-29 17:28:59 +00:00
Andrey V. Elsukov
6bfcd9c37b The decimal() function was changed in r217808 to take the
maximum value instead of number of bits. But for case when
limitation is not needed it erroneously skips conversion to
number and always returns zero. So, don't skip conversion
for case when limitation is not needed.

PR:		bin/159765
Approved by:	re (kib)
2011-08-19 12:48:06 +00:00
Ryan Stone
f9373bbdac The MBR uses a 32-bit unsigned integer to store the size of a slice, but
fdisk(1) internally uses a signed int.  Should a user attempt to specify
a slice containing more than 2^31 - 1 sectors, an error will be reported
on systems with sizeof(long) == 4 and the slice size will be silently
truncated on systems with sizeof(long) > 4.

Instead use an unsigned long to store the slice size in fdisk(1).  This
allows the user to specify a slice size up to the maximum permitted by
the MBR on-disk format and does not have any problems with silent
truncation should the use specify an slice size larger than 2^32 on systems
with sizeof(long) > 4.

Submitted by:	Mark Johnston (markjdb AT gmail DOT com)
MFC after:	2 weeks
2011-07-17 21:08:16 +00:00
Maxim Sobolev
4be78ce327 Supply maximum value as an argument to the decimal() function
instead of supplying number of bits.

Submitted by:	bde
2011-01-25 04:35:07 +00:00
Maxim Sobolev
f70a8a9cf5 o Cylinder numbers are 10 bits in the MBR;
o Sector numbers are only 6 bits in the MBR;

o bde'cize name of the local variable.

Submitted by:	bde
2011-01-24 07:16:20 +00:00
Maxim Sobolev
68df7abe8a Warn user when value entered is greated than the amount supported
by the MBR for the given parameter and set that parameter to the
maximum value instead of just truncating the most significant part
silently.

Could happen for example if the capacity of the device is more
than 2TB, so that the number of sectors is greater than 2Mib.

MFC after:	1 month
2011-01-22 05:21:20 +00:00
Brian Somers
6a5ffa0630 Add support for identifying a journaled root filesystem.
Fix support for identifying the given /dev/vinum/root example.

MFC after:	3 weeks
2010-09-16 08:16:53 +00:00
Brian Somers
1dc7e010ec Handle geli-encrypted root disk devices.
MFC after:	2 weeks
2010-09-06 04:15:49 +00:00
Ulf Lilleengen
ea32a6995b - Back out the previous change in order to maintain compatibility. 2009-06-17 06:41:10 +00:00
Ulf Lilleengen
1d695e8ed4 - The maximum number of heads is 255, not 256.
Pointed out by:		marcel
2009-06-15 16:51:07 +00:00
Brian Somers
d1c77156d8 Enhance the 'p' command so that it understands size qualifiers (K/M/G) and
so that it understands '*' as 'DTRT'.

PR:		68312
Submitted by:	Rene de Vries - rene at tunix dot nl (mostly)
MFC after:	3 weeks
2009-05-25 09:23:26 +00:00
Luigi Rizzo
31fade0527 Reword some entries for NTFS and DOS.
Add entries for DELL and ASUS recovery partitions.

MFC after:	3 days
2009-01-14 22:05:51 +00:00
Luigi Rizzo
22fccf5ce9 Another change from Christoph:
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
2009-01-14 21:31:09 +00:00
Luigi Rizzo
40905b6e22 more changes from Christoph:
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
2009-01-14 21:08:19 +00:00
Luigi Rizzo
fbcb16efdf remove unused argument to print_s0()
Submitted by:	Christoph Mallon
MFC after:	3 days
2009-01-14 20:53:46 +00:00
Luigi Rizzo
c4898ccb7c Some small fixes submitted by Christoph Mallon, specifically:
+ 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
2009-01-13 23:36:38 +00:00
Ulf Lilleengen
bd5add5884 - Improve error message given on g_providername call failure.
- While there, make error messages consistent with the rest.

Approved by:	kib (mentor)
2008-09-30 07:18:49 +00:00
Ulf Lilleengen
b31e5ae243 - Make use of the new and g_device_path utility function in libgeom to avoid
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)
2008-09-07 13:58:35 +00:00
David E. O'Brien
a61d918656 Add a -q[uiet] flag for scripts. 2008-07-31 00:55:29 +00:00
Andre Oppermann
5b93d33118 Add Apple HFS+ (0xAF) MBR partition type identificator.
Submitted by:	rpaulo (SoC2007 student)
2007-05-06 18:48:30 +00:00
Maxim Konovalov
7914c60f5a o Add -p flag: print a slice table in fdisk configuration file format.
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
2007-04-30 18:29:36 +00:00
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