Commit Graph

109 Commits

Author SHA1 Message Date
peter
6059c4954f 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
grog
a8a9a0dc87 Add partition type for IBM's JFS.
Submitted by:	Hiten Pandya <hiten@uk.FreeBSD.org>
2002-04-28 01:52:17 +00:00
trhodes
a4c67b08cb 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
phk
e611c891de Get this to WARNS=4 and closer to style(9) at a sacrifice in
linelength.
2002-03-29 19:33:14 +00:00
joe
7b1c9df62b Add some more partition types.
PR:		i386/14793
MFC after:	3 days
2002-02-18 19:32:38 +00:00
iedowse
56c642c621 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
bde
a06986b04d Fixed spelling error in previous commit. 2001-10-16 10:52:12 +00:00
peter
60debe6543 Add 0xEE (EFI GPT) and 0xEF (EFI System Partition) 2001-10-15 07:21:32 +00:00
iedowse
4c37b1678b 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
43c5cead2a 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
cc4212cf2c 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
obrien
b5bd88f4f5 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
obrien
463fa1112a Make the order of values prompted for with the "-i" option match print_part() 2000-11-18 02:55:43 +00:00
jhb
ef802e57c7 - 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
joe
947183f6d9 0xA0 = Suspend to disk. 2000-08-07 00:26:09 +00:00
jhb
02577b6635 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
jhb
2f0eda9a3b - 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
ache
fce096f2b7 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
jhb
bfeca60861 - 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
jhb
1a17cb6a0c Catch the usage() function up to the command line changes. Add -I and
remove -e.
2000-06-27 20:36:44 +00:00
brian
93da552950 0x39 == plan9
Obtained from: OpenBSD
2000-06-12 09:08:40 +00:00
ghelmer
35515887ce 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
msmith
2d0d9c4581 Don't try to open the /dev/rXXX device. 2000-05-31 00:58:55 +00:00
imp
35eef19e27 -e -> -I change.
-s for sumary

Approved by:	jkh
2000-03-10 22:03:00 +00:00
obrien
dcbc63c349 Don't use the old raw name for disk devices. 2000-03-09 19:35:32 +00:00
ru
fe933b4c21 Add ata(4) support.
Approved by:	jkh
2000-02-11 11:25:23 +00:00
billf
5f4efefebc Stuff a variable declaration inside a #if block that is only used for that
#if.
1999-09-25 02:11:30 +00:00
peter
76f0c923fe $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
dwhite
eb58c0d8ed Add -e option to usage(). 1999-08-25 21:31:08 +00:00
phk
78878d252b Add new option to fdisk: -e
This wipes the MBR and creates slice 1 as a FreeBSD slice covering the
disk starting from the second track to the cylinder aligned end of the disk.

This is the most compatibly layout we have as far as I know.
1999-08-23 11:06:19 +00:00
rnordier
db2d7d3fb6 Drop the embedded boot code in favour of a -B option which reads
the boot code from /boot/mbr, or elsewhere as defined by the revised
"-b bootcode" option; use getopt(3); clarify usage(); partially
revise man page; etc.
1999-06-27 19:29:15 +00:00
rnordier
6f61fb4448 Add a -b option as a simple way to rewrite the mbr code
(eg. replacing a boot manager with a standard mbr)
1999-01-22 11:54:17 +00:00
joerg
d77f34aad8 sd0 -> da0 1998-11-26 12:24:35 +00:00
alex
fe3661b3bc Add an entry for the new NetBSD partition id. 1998-11-06 03:43:21 +00:00
jkoshy
f3b4d13e58 Add an entry for BSD/OS [23].x partition types.
I don't have access to a BSD/OS machine to check the veracity of the
magic number.  However, no harm will be done by the commit and since
someone was motivated enough to file a PR, I'm committing the change.

PR:		7629
Submitted by:	Jos Backus <jbackus@plex.nl>
1998-11-06 03:25:56 +00:00
obrien
339a231363 Linux swap and Solaris x86 use the same BIOS partition id. 1998-09-16 19:25:47 +00:00
charnier
a6ba9a0903 Correct use of .Nm, use .Bx Free for FreeBSD. Add rcsid, remove unused
#includes. Spelling. Use err(3) and add usage().
1998-07-06 06:44:36 +00:00
bde
31e25f7859 Fixed printf format errors. 1998-06-28 20:48:03 +00:00
jraynard
772c68cbf5 Fix typo in prompt. 1998-05-20 22:23:16 +00:00
obrien
ab7e5a8f6b Add NTFS partition type.
Add "." at the end of some sentances.
Also print "flag 80" in English.
Give hint that "sysid" for FreeBSD is 165 decimal.
Ensure active partition specified by user is 1-4.
1998-03-29 23:41:51 +00:00
ache
fb0b69a9d2 Add more DOS/Win95 partition types 1998-03-14 21:22:09 +00:00
ache
03dc84e1ed Oops, merge back 32bit fat description from -stable.
It was added to -stable but not to -current, strange.
1998-03-07 22:00:31 +00:00
ache
1bc27d9539 Add primary fat-32 1998-03-07 08:45:46 +00:00
brian
864e7b2e63 Number partitions 1-4, not 0-3.
Any existing config files (using the -f option) will need
to be changed although using the old files will usually result
in an error (partition 0 is invalid).
1997-06-03 21:24:39 +00:00
gibbs
9ad77f813d Don't overflow when calculating the size in MB of a partition.
No more 241MB 4+ gig partitions for me!
1997-06-02 19:25:48 +00:00
imp
edf3f04212 OpenBSD uses ID 0xa6 for its partitions on i386, arc and others that need
a BIOS-like partition table.  We now detect this correctly and print the
right thing.
Obtained from: Value obtained from OpenBSD sources.
1997-05-02 03:08:04 +00:00
sos
304d831859 This update adds the support for != 512 byte sector SCSI devices to
the sd & od drivers. There is also slight changes to fdisk & newfs
in order to comply with different sectorsizes.
Currently sectors of size 512, 1024 & 2048 are supported, the only
restriction beeing in fdisk, which hunts for the sectorsize of
the device.
This is based on patches to od.c and the other system files by
John Gumb & Barry Scott, minor changes and the sd.c patches by
me.
There also exist some patches for the msdos filesys code, but I
havn't been able to test those (yet).

	John Gumb (john@talisker.demon.co.uk)
	Barry Scott (barry@scottb.demon.co.uk)
1996-12-01 11:25:38 +00:00
jkh
7b9dce080d Allow fdisk to be driven from a configuration file, making a 3rd-party
utility for front-ending its operation more of a possibility.

2.2-RELEASE candiate.  Closes PR#1960
Submitted-By: Darryl Okahata <darrylo@hpnmhjw.sr.hp.com>
1996-11-06 14:08:39 +00:00
bde
f35890901a The dos() function needs a new second argument, containing the size
of the partition. Only if the size is 0 should the
special handling of 0 as first argument be triggered.

[This bug caused offset 0 to give C/H/S = 0/0/0 instead of 0/0/1.]

The init_sector0 function needs to decrease the first argument
to the second call to dos() by one to be consistent with the
calls to dos() in change_part().

[This bug caused fdisk -i to create bogus partition tables with
the ending C/H/S value 1 too high.  This usually gives S = 1
instead of S = maximum, so the geometry guessing in the slice
code and perhaps in SCSI BIOSes was defeated.]

Submitted by:	Tor Egge <tegge@itea.ntnu.no>
1996-10-13 18:18:50 +00:00
alex
cd53830060 Code clean up. Prototypes, parentheses around assignments used in
if statements, #if 0 some unused code, use off_t in calls to read/
write_disk, fix a printf format, remove unused variables, and
#include necessary files.
1996-06-21 02:39:19 +00:00
julian
a7126a6a16 remove the calls to DIOCWLABEL, as it isn't supported any more
and the error message confuses the user.
(just commented out foe now)
1995-10-03 11:12:50 +00:00
joerg
79384fe51b Update to the slices era. Make /dev/rfoo0 the defaults, not
/dev/rfoo0d.

Scan a list of devices instead of insisting on all the world
being wd0.

Allow for disk names to be specified (e.g. `sd0') instead of full
path names only.

Sync the man page with the reality.
1995-09-01 18:00:14 +00:00
rgrimes
f3a2b348da Remove trailing whitespace. 1995-05-30 06:12:45 +00:00
gpalmer
cf76707291 Add NEXTSTEP as claiming partition code 0xA7. 1995-04-17 09:42:54 +00:00
jkh
0a93efad73 Recognise Linux filesystems.
Submitted by:	remy
1995-01-14 02:26:07 +00:00
bde
c4b64391bf Don't write outside of partp[] if the user gives an invalid partition
number for the partition to be made active.  Do nothing instead.  This
allows clearing all the active flags by specifying an invalid partition.
1994-10-25 17:46:53 +00:00
bde
f7b7df385e Don't change the active partition when the user says not to change it.
Convert absolute sector 0 to C/H/S 0/0/0, not 0/0/1.

Open in O_RDWR mode for the undocumented -a option, so that -a can be
used without -u.
1994-10-19 21:25:28 +00:00
bde
19e34663ff Don't exit early if the device is not character special or if the
device driver cannot supply a label (real or faked).  This allows
you to practice using fdisk on disposable media (e.g., "dd count=1
<dev/zero >/tmp/junk; fdisk /tmp/junk", "dd count=1 </etc/passwd
>/tmp/fix-up-the-mess; fdisk /tmp/fix-up-the-mess") and allows me
to test DOSpartitioning and labelling on floppies.
1994-09-15 20:19:51 +00:00
rgrimes
854999a7d1 Initial import, 0.1 + pk 0.2.4-B1 1993-06-12 14:58:17 +00:00