Subject: admin/16073: fdisk
To: None <gnats-bugs@gnats.netbsd.org>
From: Jachym _Freza_ Holecek <jakym@volny.cz>
List: netbsd-bugs
Date: 03/26/2002 23:12:42
>Number: 16073
>Category: admin
>Synopsis: there is no list of sysids known by fdisk
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: netbsd-admin
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 26 15:17:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: _Freza_
>Release: NetBSD 1.5ZA 08-Mar-2002
>Organization:
bsd.cz
>Environment:
System: NetBSD gloom 1.5ZA NetBSD 1.5ZA (GLOOM) #13: Sun Mar 17 13:44:32 CET 2002 root@gloom:/usr/src/sys/arch/i386/compile/GLOOM i386
Architecture: i386
Machine: i386
>Description:
There is no way to list the sysids recognized by fdisk besides
checking the source, which is impossible when the system crashes (ie only / is
mounted). Thus, one is unable to (for example) create a msdos partition in
case of emergency (if he doesn't remember that sysid, of course).
>How-To-Repeat:
Crash your /usr and try to make a msdos partition.
>Fix:
This patch adds the -l option to fdisk which lists all the sysids
(this is the simplest solution, since fdisk already contains all the
necessary information), and updates the manpage.
diff -r -u fdisk.orig/fdisk.8 fdisk/fdisk.8
--- fdisk.orig/fdisk.8 Tue Mar 12 23:38:15 2002
+++ fdisk/fdisk.8 Thu Mar 7 23:52:38 2002
@@ -1,4 +1,4 @@
-.\" $NetBSD: fdisk.8,v 1.28 2002/02/08 01:30:43 ross Exp $
+.\" $NetBSD: fdisk.8,v 1.29 2002/03/05 15:11:11 wiz Exp $
.\"
.Dd December 19, 2000
.Dt FDISK 8
@@ -86,7 +86,9 @@
is used to label the partition.
.Nx
reserves the magic number 169 decimal (A9 in hex).
-The number 0 is used to mark a partition as unused.
+The number 0 is used to mark a partition as unused. See the
+.Fl l
+flag.
.It Xo
.Em start ,
.Em size
@@ -128,7 +130,6 @@
.Nm
selects defaults for its questions to guarantee that behavior.
.Pp
-.Pp
Getting the
.Em cylinder ,
.Em head ,
@@ -210,6 +211,10 @@
.Tn MSDOS ) ,
even if the magic number in the first sector is ok.
The partition table is left alone by this (but see above).
+.It Fl l
+Lists known
+.Em sysid
+values and exit.
.It Fl s Ar id/start/size
Specify the partition
.Ar id ,
diff -r -u fdisk.orig/fdisk.c fdisk/fdisk.c
--- fdisk.orig/fdisk.c Tue Mar 12 23:38:15 2002
+++ fdisk/fdisk.c Thu Mar 7 23:52:44 2002
@@ -1,4 +1,4 @@
-/* $NetBSD: fdisk.c,v 1.48 2001/11/07 14:50:32 lukem Exp $ */
+/* $NetBSD: fdisk.c,v 1.49 2002/03/04 04:22:22 dbj Exp $ */
/*
* Mach Operating System
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.48 2001/11/07 14:50:32 lukem Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.49 2002/03/04 04:22:22 dbj Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -104,9 +104,9 @@
#define DEFAULT_BOOTCODE "/usr/mdec/mbr"
#define DEFAULT_BOOTSELCODE "/usr/mdec/mbr_bootsel"
-#define OPTIONS "0123BSafius:b:c:"
+#define OPTIONS "0123BSafilus:b:c:"
#else
-#define OPTIONS "0123Safius:b:c:"
+#define OPTIONS "0123Safilus:b:c:"
#endif
#define ACTIVE 0x80
@@ -229,7 +229,9 @@
{0xA5, "FreeBSD or 386BSD or old NetBSD"},
{0xA6, "OpenBSD"},
{0xA7, "NeXTSTEP 486"},
+ {0xa8, "Apple UFS"},
{0xa9, "NetBSD"},
+ {0xab, "Apple Boot"},
{0xb1, reserved},
{0xb3, reserved},
{0xb4, reserved},
@@ -258,6 +260,8 @@
{0xFF, "Xenix Bad Block Table"},
};
+#define KNOWN_SYSIDS (sizeof(part_types)/sizeof(part_types[0]))
+
void usage(void);
void print_s0(int);
void print_part(int);
@@ -346,6 +350,15 @@
case 'i':
i_flag = 1;
break;
+ case 'l':
+ {
+ int i;
+
+ for (i = 0; i < KNOWN_SYSIDS; i++)
+ printf( "%03d %s\n", i,
+ part_types[i].name );
+ exit(0);
+ }
case 'u':
u_flag = 1;
break;
>Release-Note:
>Audit-Trail:
>Unformatted: