>Number:         166308
>Category:       bin
>Synopsis:       [patch] fdisk(8) add an option to list all partitions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 21 22:50:14 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     David Demelier
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD Melon.malikania.fr 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Mon Mar 19 
18:27:22 CET 2012     r...@melon.malikania.fr:/usr/obj/usr/src/sys/Melon  amd64
>Description:
When you use fdisk in interactive mode, you never know which id refers to the 
partition type, e.g :

11 refers to MS-Dos
165 regers to BSD.
etc...

This patch add a -l flag to fdisk(8) to show all partitions types, the 
following output will be printed like that :

markand@Melon ~ $ fdisk -l
0       unused
1       Primary DOS with 12 bit FAT
2       XENIX / file system
3       XENIX /usr file system
4       Primary DOS with 16 bit FAT (< 32MB)
5       Extended DOS
6       Primary DOS, 16 bit FAT (>= 32MB)
7       NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX
8       AIX file system or SplitDrive
9       AIX boot partition or Coherent
10      OS/2 Boot Manager, OPUS or Coherent swap
11      DOS or Windows 95 with 32 bit FAT
12      DOS or Windows 95 with 32 bit FAT (LBA)
14      Primary 'big' DOS (>= 32MB, LBA)
15      Extended DOS (LBA)
16      OPUS
17      OS/2 BM: hidden DOS with 12-bit FAT
18      Compaq diagnostics
20      OS/2 BM: hidden DOS with 16-bit FAT (< 32MB)
22      OS/2 BM: hidden DOS with 16-bit FAT (>= 32MB)
23      OS/2 BM: hidden IFS (e.g. HPFS)
24      AST Windows swapfile
27      ASUS Recovery partition (NTFS)
36      NEC DOS
57      plan9
60      PartitionMagic recovery
64      VENIX 286
65      Linux/MINIX (sharing disk with DRDOS)
66      SFS or Linux swap (sharing disk with DRDOS)
67      Linux native (sharing disk with DRDOS)
77      QNX 4.2 Primary
78      QNX 4.2 Secondary
79      QNX 4.2 Tertiary
80      DM (disk manager)
81      DM6 Aux1 (or Novell)
82      CP/M or Microport SysV/AT
83      DM6 Aux3
84      DM6
85      EZ-Drive (disk manager)
86      Golden Bow (disk manager)
92      Priam Edisk (disk manager)
97      SpeedStor
99      System V/386 (such as ISC UNIX), GNU HURD or Mach
100     Novell Netware/286 2.xx
101     Novell Netware/386 3.xx
112     DiskSecure Multi-Boot
117     PCIX
119     QNX4.x
120     QNX4.x 2nd part
121     QNX4.x 3rd part
128     Minix until 1.4a
129     Minix since 1.4b, early Linux partition or Mitac disk manager
130     Linux swap or Solaris x86
131     Linux native
132     OS/2 hidden C: drive
133     Linux extended
134     NTFS volume set??
135     NTFS volume set??
147     Amoeba file system
148     Amoeba bad block table
159     BSD/OS
160     Suspend to Disk
165     FreeBSD/NetBSD/386BSD
166     OpenBSD
167     NeXTSTEP
169     NetBSD
172     IBM JFS
175     HFS+
183     BSDI BSD/386 file system
184     BSDI BSD/386 swap
190     Solaris x86 boot
191     Solaris x86 (new)
193     DRDOS/sec with 12-bit FAT
196     DRDOS/sec with 16-bit FAT (< 32MB)
198     DRDOS/sec with 16-bit FAT (>= 32MB)
199     Syrinx
219     CP/M, Concurrent CP/M, Concurrent DOS or CTOS
222     DELL Utilities - FAT filesystem
225     DOS access or SpeedStor with 12-bit FAT extended partition
227     DOS R/O or SpeedStor
228     SpeedStor with 16-bit FAT extended partition < 1024 cyl.
235     BeOS file system
238     EFI GPT
239     EFI System Partition
241     SpeedStor
242     DOS 3.3+ Secondary
244     SpeedStor large partition
254     SpeedStor >1024 cyl. or LANstep
255     Xenix bad blocks table

>How-To-Repeat:

>Fix:
--- fdisk.diff begins here ---
--- fdisk.c.orig        2012-03-21 23:24:44.000000000 +0100
+++ fdisk.c     2012-03-21 23:37:23.000000000 +0100
@@ -119,6 +119,7 @@
 static int a_flag  = 0;                /* set active partition */
 static char *b_flag = NULL;    /* path to boot code */
 static int i_flag  = 0;                /* replace partition data */
+static int l_flag  = 0;                /* print partitions types */
 static int q_flag  = 0;                /* Be quiet */
 static int u_flag  = 0;                /* update partition data */
 static int s_flag  = 0;                /* Print a summary and exit */
@@ -233,6 +234,7 @@
 
 
 static int geom_class_available(const char *);
+static void print_partition_types(void);
 static void print_s0(void);
 static void print_part(const struct dos_partition *);
 static void init_sector0(unsigned long start);
@@ -264,7 +266,7 @@
        int     partition = -1;
        struct  dos_partition *partp;
 
-       while ((c = getopt(argc, argv, "BIab:f:ipqstuv1234")) != -1)
+       while ((c = getopt(argc, argv, "BIab:f:ilpqstuv1234")) != -1)
                switch (c) {
                case 'B':
                        B_flag = 1;
@@ -284,6 +286,9 @@
                case 'i':
                        i_flag = 1;
                        break;
+               case 'l':
+                       l_flag = 1;
+                       break;
                case 'p':
                        print_config_flag = 1;
                        break;
@@ -313,7 +318,10 @@
                }
        if (f_flag || i_flag)
                u_flag = 1;
-       if (t_flag)
+       if (l_flag) {
+               print_partition_types();
+               exit(0);
+       } if (t_flag)
                v_flag = 1;
        argc -= optind;
        argv += optind;
@@ -455,6 +463,17 @@
 }
 
 static void
+print_partition_types(void)
+{
+       int i;
+
+       for (i = 0; i < 256; ++i)
+               if (part_types[i] != NULL)
+                       printf("%d\t%s\n", i, part_types[i]);
+
+}
+
+static void
 print_s0(void)
 {
        int     i;
--- fdisk.8.orig        2012-03-21 23:37:44.000000000 +0100
+++ fdisk.8     2012-03-21 23:41:39.000000000 +0100
@@ -8,7 +8,7 @@
 .Nd PC slice table maintenance utility
 .Sh SYNOPSIS
 .Nm
-.Op Fl BIaipqstu
+.Op Fl BIailpqstu
 .Op Fl b Ar bootcode
 .Op Fl 1234
 .Op Ar disk
@@ -104,6 +104,8 @@
 (marked as unused) before editing.
 (Compare with
 .Fl u . )
+.It Fl l
+List all partition types.
 .It Fl I
 Initialize sector 0 slice table
 for one
--- fdisk.diff ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to