Commit Graph

246 Commits

Author SHA1 Message Date
christos
124bff0089 PR/33522: Peter Bex: Sanity checks to avoid zerodivide. 2006-05-21 16:00:17 +00:00
mrg
16efbf8575 don't do the -Wno-pointer-sign dance for host programs. 2006-05-12 01:18:25 +00:00
mrg
aadd7d4847 sprinkle some -fno-strict-aliasing and -Wno-pointer-sign with GCC4. 2006-05-11 23:16:28 +00:00
dsl
df7e187ccb Appease Coverty CID 7449. Avoid close(-1) in error path. 2006-03-18 08:36:50 +00:00
rumble
e948e1b17f Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.
2006-03-17 15:53:46 +00:00
dyoung
6c1041b8b7 So that we can build a full-featured fdisk cross-tool with -DBOOTSEL,
condition the definition of DEFAULT_BOOTxxx variables and SCAN_xxx
on defined(BOOTSEL), instead of defined(__i386__) || defined(__x86_64__).

While I'm here, only build get_diskname in the same conditions as
get_geometry is built, since only the latter calls the former.
2006-02-14 04:48:15 +00:00
dsl
c28e0ae4af Byteswap the constant MBR_{BS_}MAGIC throughout, should genetate better code.
Except that non all architectures have that optimisation :-(
2006-01-29 12:55:16 +00:00
uwe
39ab40b2aa PRI* macros should not contain percent sign.
While here, conditionalise use of "lld" for PRId64 on HAVE_LONG_LONG.
2005-10-07 23:57:10 +00:00
dogcow
7babc7145c Fix cross-compilation on FreeBSD 4.x (and other OSes) where PRId64 isn't
defined.
2005-10-07 01:04:08 +00:00
uwe
25503c6713 When building as host tool don't include "../../include/util.h".
opendisk() declared in that file is not used in this case anyway, and
<util.h> pulls in unwatned includes (e.g. <utmpx.h> doesn't exist on
FreeBSD 4.*).
2005-08-27 22:43:40 +00:00
christos
2c6eadc9ce Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
2005-06-27 01:00:04 +00:00
fvdl
a33a5a18b5 If HOSTPROG is empty, do not pull in libutil, since we do not need it in that
case, and several host platforms do not have libutil. Fixes the build of
these programs as host tools on platforms without libutil.
2005-06-23 00:54:47 +00:00
dyoung
4580f13f42 Turn fdisk(8) into a host tool. Still todo: commit the host-tool
build infrastructure to src/tools/fdisk/.
2005-06-12 19:14:10 +00:00
dyoung
023801f122 For portability, use standard types: s/uint/unsigned int/,
s/ulong/unsigned long/, s/u_int8_t/uint8_t/.
2005-06-12 19:06:43 +00:00
lukem
dfee67134f Make fdisk(8) available on all platforms, since MS-DOS partitioning
is the de-facto standard for many removable media types.
2005-05-22 03:45:30 +00:00
dsl
4118385742 Allow partition sizes to be input in GB 2005-04-07 20:23:13 +00:00
xtraeme
76500fc2f9 WARNS=2 is the default defined in sbin/Makefile.inc. (thanks wiz) 2005-01-20 16:39:22 +00:00
xtraeme
784c275927 Remove main() prototype; WARNS=2 2005-01-20 16:01:02 +00:00
wiz
7913b43af5 Fix typo in error message, reported by Nicolas Joly in PR 28347. 2004-11-18 12:00:18 +00:00
christos
fdad6cabc9 Use the 1st element's size as the argument to bsearch. 2004-11-15 21:59:23 +00:00
christos
88825a8a55 Use ptype table from <sys/bootblock.h> 2004-11-12 16:57:46 +00:00
christos
88ddc79ebd Add 0xBF for Solaris. From Larry Lee <lclee at west.sun.com> 2004-11-10 02:39:48 +00:00
dsl
25b17683bd Add (unsigned char) to isdigit() calls 2004-10-28 19:48:41 +00:00
gavan
0560d8b947 Initial import of iyonix port.
The Iyonix is a desktop machine from Castle Technology, based on a 600MHz
XScale[tm] 80321 processor.

* Uses the bootloader from NetBSD/acorn32, which is now 32-bit compatible.
* Currently boots multiuser with a serial console.
* Device support is not yet complete.

With help from abs.
2004-10-13 23:28:34 +00:00
dsl
9721e88965 Fix intuit_translated_geometry() calculation.
From Izumi Tsutsui in PR bin/26917
2004-09-12 07:46:24 +00:00
dbj
3aca86e05b check sysctl error return on both calls.
this prevents sysctl from coredumping if the second call fails while the
first succeeds.  This isn't supposed to happen, but there is another bug
in the i386 kernel implementation of sysctl machdep.diskinfo that excites this
2004-07-30 23:42:29 +00:00
uwe
3eac78fb64 s/Nm/Nx/, as it's NetBSD that has ports, not fdisk. 2004-07-13 19:24:03 +00:00
wiz
af679c56e7 Bump date for previous; new sentence, new line;
sort list of ports where fdisk is available.
2004-07-13 13:38:39 +00:00
darcy
e3937fb4c5 Add note top man page explaining that fdisk is not used on all platforms
and list the ones that is is.

Partial fix to PR#25943
2004-07-13 10:45:49 +00:00
dyoung
87598533f6 Insert missing space so fdisk prints "primary partition table
invalid, no magic in sector 0", not "primarypartition ...".
2004-05-19 07:36:14 +00:00
dsl
b31522861f Use the disk size from the device driver, not the bios when checking
whether partitions are valid.
Stops problems with broken BIOS, fixes PR bin/25491
2004-05-10 20:32:07 +00:00
dsl
503ee58711 Don't output the 'Installed bootfile doesn't support required options'
message when we are updating the mbr code because the user did fdisk -i ...
2004-05-08 20:52:59 +00:00
lukem
a5a429b354 Only examine mbr_bootsel* #ifdef BOOTSEL.
Noted on current-users@ by Markus Hennecke.
2004-03-24 02:49:37 +00:00
lukem
455da8e60b Move mbr_bootsel from offset 404 to offset 400 in struct mbr_sector to
leave 4 bytes for the Windows NT Drive Serial Number (DSN) at 440-443
(as mbr_sector.mbr_dsn).

Ensure that all the MBR & PBR code reserves space for mbr_sector.mbr_dsn.

Leave the bootsel magic number at 444-445 as mbr_sector.mbr_bootsel_magic
(instead of mbr_sector.mbr_bootsel.mbrbs_magic), but use 0xb5e1 (MBR_BS_MAGIC)
instead of 0xaa55 (MBR_MAGIC) to indicate that this change has occurred.

Rework MBR_BS_NEWMBR to mean "mbr_bootsel has moved to 400".

Modify fdisk(8) to automatically relocate the mbr_bootsel from 404 to 400
if mbr_bootsel_magic is the old value (0xaa55), and unset MBR_BS_NEWMBR
to flag that new mbr_bootsel code must be used if updating the MBR.


These changes fixes a problem where Windows 2000 or Windows XP would corrupt
the last 3 bytes + NUL of MBR partition 3's bootsel name if the bootsel name
was 5 characters long, replacing bytes 6-9 with the DSN.
Also, by explicitly reserving the space for the DSN we prevent problems in the
future if non bootsel MBR or PBR code had other information at bytes 440-443.
2004-03-22 07:11:00 +00:00
lukem
fcfc427464 Use .Pp instead of .br as appropriate.
(This needs more work)
2004-03-22 05:07:56 +00:00
wiz
24be734e2d Nm needs no argument; also, correct wrong Nm usage. 2004-03-20 18:49:33 +00:00
snj
17ed0d0099 Bump date for last. Use Sq for single quotes. Drop trailing space.
New sentence, new line.  Sort xrefs.  Fix a spelling error.
2004-03-19 22:21:36 +00:00
dyoung
6c02382b7e Add flag -F, options -t disktab and -T disktype to fdisk. Flag -F
indicates that the target of the fdisk operation is a file, not a
disk. With -t and -T, the user tells fdisk the geometry for the
file If the default geometry that fdisk will "fake up" for a file
are not satisfactory, the user may tell the geometry to fdisk using
-t disktab -T disktype.
2004-03-19 18:19:17 +00:00
jmmv
b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
lukem
2a42af8c7a Add "DISK" to -S output. 2003-11-21 21:47:42 +00:00
lukem
7a699e2bed unconditionally #define DEFAULT_BOOTDIR. should fix non-x86 builds 2003-10-11 04:50:49 +00:00
lukem
1c33b4e6a4 Overhaul MBR handling (part 1):
<sys/bootblock.h>:
    *	Added definitions for the Master Boot Record (MBR) used by
	a variety of systems (primarily i386), including the format
	of the BIOS Parameter Block (BPB).
	This information was cribbed from a variety of sources
	including <sys/disklabel_mbr.h> which this is a superset of.

	As part of this, some data structure elements and #defines
	were renamed to be more "namespace friendly" and consistent
	with other bootblocks and MBR documentation.
	Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
    *	Deprecated in favor of <sys/bootblock.h> (the latter is more
	"host tool" friendly).

amd64 & i386:
    *	Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
	be consistent with the naming convention of the msdosfs tools.

    *	Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
	and it's confusing to have two functionally equivalent bootblocks,
	especially given that "ufs" has multiple meanings (it could be
	a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

    *	Rework pbr.S (the first sector of bootxx_*):
	    +	Ensure that BPB (bytes 11..89) and the partition table
		(bytes 446..509) do not contain code.
	    +	Add support for booting from FAT partitions if BOOT_FROM_FAT
		is defined.  (Only set for bootxx_msdos).
	    +	Remove "dummy" partition 3; if people want to installboot(8)
		these to the start of the disk they can use fdisk(8) to
		create a real MBR partition table...
	    +	Compile with TERSE_ERROR so it fits because of the above.
		Whilst this is less user friendly, I feel it's important
		to have a valid partition table and BPB in the MBR/PBR.

    *	Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
	with other platforms.

    *	Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
    	we can boot off FAT partitions.

    *	Crank version of /usr/mdec/boot to 3.1, and fix some of the other
	entries in the version file.

installboot(8) (i386):
    *	Read the existing MBR of the filesystem and retain the BIOS
    	Parameter Block (BPB) in bytes 11..89 and the MBR partition
	table in bytes 446..509.  (Previously installboot(8) would
	trash those two sections of the MBR.)

mbrlabel(8):
    *	Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
	to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
2003-10-08 04:25:43 +00:00
lukem
f41de51799 be consistent about "MS-DOS" 2003-10-06 12:02:52 +00:00
itojun
731ae88ecd realloc pedant 2003-09-19 08:35:15 +00:00
dsl
1ce757782d Define and use PRIdaddr for printing disk block numbers.
Should fix bin/22638 for compilation on amd64.
2003-08-29 16:31:30 +00:00
dsl
26461e4412 Put cylinder number 1023 into the mbr for sectors beyond the CHS limit
(rather than encoding the highest CHS addressable sector).
2003-08-10 10:20:08 +00:00
dsl
ae60f83e33 Remove old i386 mbr stuff (move to arch/i386/stand/mbr a while ago)
mbr.8 moved to src/share/man/man8/man8.i386
2003-07-16 11:11:49 +00:00
dsl
02af72a142 Fix code that detects bios geometry from mbr table. 2003-07-14 09:32:12 +00:00
dsl
93e88fd2eb Only look at each pair of CHS values once when trying to guess geometry. 2003-07-07 11:45:00 +00:00
joda
e5986b088f add missing . before Fl 2003-06-03 12:35:54 +00:00
itojun
00868410fd asprintf is easier 2003-05-17 23:14:42 +00:00
dsl
b081987b73 delete a diagnostic printf that was accidentally left in 2003-05-14 11:24:05 +00:00
wiz
c94730c38a MBR, not mbr. 2003-05-06 07:56:03 +00:00
dsl
5e53f766f8 Change a couple of .Em to .Ar 2003-05-01 13:36:25 +00:00
wiz
0682f1a427 Replace some raw roff with mdoc. 2003-05-01 13:01:17 +00:00
wiz
0d14e41651 Improve formatting for [/bootmenu], requested by dsl; add some commas. 2003-05-01 12:55:52 +00:00
dsl
315515ebe4 a mbr -> an mbr 2003-05-01 10:43:58 +00:00
wiz
c662d486a9 mdoc fix, use \*[Lt]/\*[Gt], sort SEE ALSO, some other nits. 2003-05-01 10:43:14 +00:00
wiz
b3d7fe267b Drop trailing space. 2003-05-01 09:50:12 +00:00
bjh21
b2fbd85bee Remove some unused variabled from get_params_to_use() in the !i386 && !amd64
case.
2003-05-01 09:23:30 +00:00
dsl
93174a8c33 Update to match new mbr code 2003-05-01 08:40:17 +00:00
dsl
c5bd7c9dfd i386/amd64 mbr is now built in sys/arch/i386/stand/mbr 2003-04-30 19:50:42 +00:00
dsl
8defedc8ba Don't descend into mbr_bootsel.
i386/and64 mbr code is built in arch i386/stand/mbr
2003-04-30 19:49:01 +00:00
dsl
fa01152676 Rototilled fdisk that supports:
- editing of the extended partition list
- user friendly default start/size for new partitions
- partition start/size input in sectors, cylinders or MB
- bootsel menu names configured with paritition bounds
- partition update loop asks used which partition to change
  (instead of asking about each partition in turn).
- detection (and erroring) of overlapped partitions.
- automatic installation of correct mbr_xxx code (after prompting user)
2003-04-30 19:47:10 +00:00
dsl
6ac09f276d Move some definitions from fdisk.c to disklabel_mbr.h so they don't have
to be duplicated elsewhere (eg in mbr.S).
Modify fdisk.c so that it builds with the new disklabel.h
2003-04-30 10:29:51 +00:00
fvdl
043f21d9ea x86_64 -> amd64 2003-04-26 19:14:17 +00:00
fvdl
0945a6df17 x86_64 -> amd64 2003-04-26 19:02:50 +00:00
fvdl
96757427c6 Fix range check for the default boot option case. 2003-04-01 19:39:13 +00:00
wiz
990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
wiz
82ece76c41 Drop trailing space (in last). 2003-02-09 21:56:19 +00:00
perry
d259c39de5 Slightly clarify/improve the documentation for the -B (boot selector)
option
2003-02-09 20:46:29 +00:00
jmmv
dd4a382f46 Print missing newline in two bootselector-related messages. Approved by wiz. 2003-01-10 23:37:34 +00:00
fvdl
f77d71f782 Enable bootselector code for x86_64.
XXX the ifdef-ed parts should be split off into a seperate file.
2002-11-30 13:47:19 +00:00
fvdl
2ee89df87b Avoid format warning for off_t printf. 2002-11-24 21:49:15 +00:00
fvdl
304258c96f Compile mbr and mbr_bootsel on x86_64 2002-11-23 23:45:51 +00:00
jdarrow
7e912cff61 Make the -l flage more useful, by actually printing the systype number
alongside the sysid string (instead of just the array index of the
struct part_type they are found in).

Now fdisk -l shows the familiar 169 for NetBSD, 165 for FreeBSD or
386BSD or old NetBSD, and other possibly-familiar (131 for Linux native,
015 for Ext. Partition - LBA) values in with their correct numbers.
2002-10-08 07:38:47 +00:00
wiz
2fb4b1db52 New sentence, new line. By Robert Elz with minimal fixes. 2002-10-01 13:40:23 +00:00
dbj
bfd495ea39 add partition type 0xaf for Apple HFS. 2002-09-27 23:19:56 +00:00
lukem
0d1ba7e8a0 minor makefile delint 2002-09-18 06:38:50 +00:00
enami
eb0197ee71 Fix unbalanced paren. 2002-09-09 03:01:26 +00:00
soren
26bc587db9 Clean up printf->err conversions. 2002-08-08 13:19:18 +00:00
ross
08c3bcd192 shut up assembler warnings 2002-08-04 20:29:44 +00:00
ross
626a25bc13 deal with assembler warnings 2002-08-04 20:27:22 +00:00
manu
3f13baf349 Added fdisk on hpcarm 2002-07-26 17:22:51 +00:00
wiz
1322c69689 Nit. 2002-07-09 22:51:13 +00:00
jdolecek
0fb4a207d2 This isn't i386 specific (also macppc) 2002-07-09 22:11:50 +00:00
itojun
245453be61 mbr for FDISK-formatted macppc disk 2002-06-17 15:25:45 +00:00
itojun
b11bd24490 fdisk is now useful for macppc, build it 2002-06-17 15:11:46 +00:00
yamt
15da77e3d3 exit on EOF from stdin. 2002-06-05 12:19:23 +00:00
uch
f7b9e074ee add hpcsh 2002-05-09 18:16:16 +00:00
thorpej
34525f12a8 Build fdisk(8) on netwinder. 2002-04-03 03:17:36 +00:00
christos
56a72506f9 nicer printing. 2002-03-26 23:56:45 +00:00
christos
d9d77caa18 PR/16073: Jachym _Freza_ Holecek: Add the ability to list known partition types.
While I am here, KNF a bit.
2002-03-26 23:56:05 +00:00
wiz
10d6eb080d Drop duplicate .Pp. 2002-03-05 15:09:26 +00:00
dbj
5aa1b71afb add "Apple UFS" and "Apple Boot" partition ids used by Darwin 2002-03-04 04:22:22 +00:00
scw
aea350ead2 fdisk(8) is needed on mvmeppc since PPCBUG uses PeeCee-style MBR
partition info when booting from disk.
2002-02-27 22:31:18 +00:00
ross
dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
fair
fe1cad9aa9 Cross-link fdisk(8), mbr(8), and mbrlabel(8) in the SEE ALSO sections,
as suggested in PR 14288.  Also add a little white space to mbr(8) to
make it a little more readable.
2002-01-13 08:02:14 +00:00
tv
8e6f7afb5b MKfoo=no -> NOfoo 2001-12-12 01:48:43 +00:00
wiz
217af7b8a1 Use .Nx for NetBSD, drop some unnecessary empty lines, use standard headers. 2001-11-16 11:36:09 +00:00