Skip to contentSkip to conversation

fdisk: add guid

PATCH Applied Davidlohr Bueso 3 participants 11 messages Aug 21, 2012 – Sep 24, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 fdisk: add guid

From: Davidlohr Bueso <[email protected]>

Add a GUID structure to the partition types (struct systypes). This is particularly important to accommodate GPT. For those labels that do not use it, like DOS, SUN and SGI, just ignore it.

---
 fdisks/cfdisk.c         |    2 +-
 fdisks/common.h         |   16 ++++-
 fdisks/fdiskbsdlabel.h  |   38 +++++-----
 fdisks/fdisksgilabel.c  |   38 +++++-----
 fdisks/fdisksunlabel.c  |   34 ++++----
 fdisks/i386_sys_types.c |  198 +++++++++++++++++++++++-----------------------
 6 files changed, 169 insertions(+), 157 deletions(-)
fdisks/cfdisk.c +1 -1
index 0ceed33..3efa42c 100644
@@ -373,7 +373,7 @@ my_basename(char *devname) {
     return s ? s+1 : devname;
 }
 
-static char *
+static const char *
 partition_type_name(unsigned char type) {
     struct systypes *s = i386_sys_types;
 
fdisks/common.h +14 -2
index 352b9a5..0e22d8e 100644
@@ -2,10 +2,22 @@
 #define FDISK_COMMON_H
 
 /* common stuff for fdisk, cfdisk, sfdisk */
+#include <inttypes.h>
+
+/* Globally unique identifier */
+struct fdisk_guid {
+	uint32_t   time_low;
+	uint16_t   time_mid;
+	uint16_t   time_hi_and_version;
+	uint8_t    clock_seq_hi;
+	uint8_t    clock_seq_low;
+	uint8_t    node[6];
+};
 
 struct systypes {
-	unsigned char type;
-	char *name;
+	uint16_t          type;
+	struct fdisk_guid guid;
+	const char        *name;
 };
 
 extern struct systypes i386_sys_types[];
fdisks/fdiskbsdlabel.h +19 -19
index ab6877e..8cdc6eb 100644
@@ -201,28 +201,28 @@ static char *xbsd_dktypenames[] = {
 
 #ifdef	DKTYPENAMES
 static struct systypes xbsd_fstypes[] = {
-        {BSD_FS_UNUSED, "unused"},
-	{BSD_FS_SWAP,   "swap"},
-	{BSD_FS_V6,     "Version 6"},
-	{BSD_FS_V7,     "Version 7"},
-	{BSD_FS_SYSV,   "System V"},
-	{BSD_FS_V71K,   "4.1BSD"},
-	{BSD_FS_V8,     "Eighth Edition"},
-	{BSD_FS_BSDFFS, "4.2BSD"},
+        {BSD_FS_UNUSED, {0}, N_("unused")},
+	{BSD_FS_SWAP,   {0}, N_("swap")},
+	{BSD_FS_V6,     {0}, N_("Version 6")},
+	{BSD_FS_V7,     {0}, N_("Version 7")},
+	{BSD_FS_SYSV,   {0}, N_("System V")},
+	{BSD_FS_V71K,   {0}, N_("4.1BSD")},
+	{BSD_FS_V8,     {0}, N_("Eighth Edition")},
+	{BSD_FS_BSDFFS, {0}, N_("4.2BSD")},
 #ifdef __alpha__
-	{BSD_FS_EXT2,   "ext2"},
+	{BSD_FS_EXT2,   {0}, N_("ext2")},
 #else
-	{BSD_FS_MSDOS,  "MS-DOS"},
+	{BSD_FS_MSDOS,  {0}, N_("MS-DOS")},
 #endif
-	{BSD_FS_BSDLFS, "4.4LFS"},
-	{BSD_FS_OTHER,  "unknown"},
-	{BSD_FS_HPFS,   "HPFS"},
-	{BSD_FS_ISO9660,"ISO-9660"},
-	{BSD_FS_BOOT,   "boot"},
-	{BSD_FS_ADOS,   "ADOS"},
-	{BSD_FS_HFS,    "HFS"},
-	{BSD_FS_ADVFS,	"AdvFS"},
-	{ 0, NULL }
+	{BSD_FS_BSDLFS, {0}, N_("4.4LFS")},
+	{BSD_FS_OTHER,  {0}, N_("unknown")},
+	{BSD_FS_HPFS,   {0}, N_("HPFS")},
+	{BSD_FS_ISO9660,{0}, N_("ISO-9660")},
+	{BSD_FS_BOOT,   {0}, N_("boot")},
+	{BSD_FS_ADOS,   {0}, N_("ADOS")},
+	{BSD_FS_HFS,    {0}, N_("HFS")},
+	{BSD_FS_ADVFS,	{0}, N_("AdvFS")},
+	{ 0, {0}, NULL }
 };
 #define BSD_FSMAXTYPES (ARRAY_SIZE(xbsd_fstypes)-1)
 
fdisks/fdisksgilabel.c +19 -19
index 7253d21..3e466be 100644
@@ -88,25 +88,25 @@ isinfreelist(unsigned int b) {
  * end of free blocks section
  */
 struct systypes sgi_sys_types[] = {
-	{SGI_VOLHDR,	N_("SGI volhdr")},
-	{0x01,		N_("SGI trkrepl")},
-	{0x02,		N_("SGI secrepl")},
-	{SGI_SWAP,	N_("SGI raw")},
-	{0x04,		N_("SGI bsd")},
-	{0x05,		N_("SGI sysv")},
-	{ENTIRE_DISK,	N_("SGI volume")},
-	{SGI_EFS,	N_("SGI efs")},
-	{0x08,		N_("SGI lvol")},
-	{0x09,		N_("SGI rlvol")},
-	{SGI_XFS,	N_("SGI xfs")},
-	{SGI_XFSLOG,	N_("SGI xfslog")},
-	{SGI_XLV,	N_("SGI xlv")},
-	{SGI_XVM,	N_("SGI xvm")},
-	{LINUX_SWAP,	N_("Linux swap")},
-	{LINUX_NATIVE,	N_("Linux native")},
-	{LINUX_LVM,	N_("Linux LVM")},
-	{LINUX_RAID,	N_("Linux RAID")},
-	{0, NULL }
+	{SGI_VOLHDR,	{0}, N_("SGI volhdr")},
+	{0x01,		{0}, N_("SGI trkrepl")},
+	{0x02,		{0}, N_("SGI secrepl")},
+	{SGI_SWAP,	{0}, N_("SGI raw")},
+	{0x04,		{0}, N_("SGI bsd")},
+	{0x05,		{0}, N_("SGI sysv")},
+	{ENTIRE_DISK,	{0}, N_("SGI volume")},
+	{SGI_EFS,	{0}, N_("SGI efs")},
+	{0x08,		{0}, N_("SGI lvol")},
+	{0x09,		{0}, N_("SGI rlvol")},
+	{SGI_XFS,	{0}, N_("SGI xfs")},
+	{SGI_XFSLOG,	{0}, N_("SGI xfslog")},
+	{SGI_XLV,	{0}, N_("SGI xlv")},
+	{SGI_XVM,	{0}, N_("SGI xvm")},
+	{LINUX_SWAP,	{0}, N_("Linux swap")},
+	{LINUX_NATIVE,	{0}, N_("Linux native")},
+	{LINUX_LVM,	{0}, N_("Linux LVM")},
+	{LINUX_RAID,	{0}, N_("Linux RAID")},
+	{0, {0}, NULL }
 };
 
 static int
fdisks/fdisksunlabel.c +17 -17
index 9d17ed2..8246c57 100644
@@ -28,23 +28,23 @@
 static int     other_endian = 0;
 
 struct systypes sun_sys_types[] = {
-	{SUN_TAG_UNASSIGNED, N_("Unassigned")},
-	{SUN_TAG_BOOT, N_("Boot")},
-	{SUN_TAG_ROOT, N_("SunOS root")},
-	{SUN_TAG_SWAP, N_("SunOS swap")},
-	{SUN_TAG_USR, N_("SunOS usr")},
-	{SUN_TAG_BACKUP, N_("Whole disk")},
-	{SUN_TAG_STAND, N_("SunOS stand")},
-	{SUN_TAG_VAR, N_("SunOS var")},
-	{SUN_TAG_HOME, N_("SunOS home")},
-	{SUN_TAG_ALTSCTR, N_("SunOS alt sectors")},
-	{SUN_TAG_CACHE, N_("SunOS cachefs")},
-	{SUN_TAG_RESERVED, N_("SunOS reserved")},
-	{SUN_TAG_LINUX_SWAP, N_("Linux swap")},
-	{SUN_TAG_LINUX_NATIVE, N_("Linux native")},
-	{SUN_TAG_LINUX_LVM, N_("Linux LVM")},
-	{SUN_TAG_LINUX_RAID, N_("Linux raid autodetect")},
-	{ 0, NULL }
+	{SUN_TAG_UNASSIGNED,     {0}, N_("Unassigned")},
+	{SUN_TAG_BOOT,           {0}, N_("Boot")},
+	{SUN_TAG_ROOT,           {0}, N_("SunOS root")},
+	{SUN_TAG_SWAP,           {0}, N_("SunOS swap")},
+	{SUN_TAG_USR,            {0}, N_("SunOS usr")},
+	{SUN_TAG_BACKUP,         {0}, N_("Whole disk")},
+	{SUN_TAG_STAND,          {0}, N_("SunOS stand")},
+	{SUN_TAG_VAR,            {0}, N_("SunOS var")},
+	{SUN_TAG_HOME,           {0}, N_("SunOS home")},
+	{SUN_TAG_ALTSCTR,        {0}, N_("SunOS alt sectors")},
+	{SUN_TAG_CACHE,          {0}, N_("SunOS cachefs")},
+	{SUN_TAG_RESERVED,       {0}, N_("SunOS reserved")},
+	{SUN_TAG_LINUX_SWAP,     {0}, N_("Linux swap")},
+	{SUN_TAG_LINUX_NATIVE,   {0}, N_("Linux native")},
+	{SUN_TAG_LINUX_LVM,      {0}, N_("Linux LVM")},
+	{SUN_TAG_LINUX_RAID,     {0}, N_("Linux raid autodetect")},
+	{ 0, {0}, NULL }
 };
 
 static inline unsigned short __swap16(unsigned short x) {
fdisks/i386_sys_types.c +99 -99

207 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer
#1 lore raw
Quoted 7 lines · Davidlohr Bueso
 fdisks/cfdisk.c         |    2 +-
 fdisks/common.h         |   16 ++++-
 fdisks/fdiskbsdlabel.h  |   38 +++++-----
 fdisks/fdisksgilabel.c  |   38 +++++-----
 fdisks/fdisksunlabel.c  |   34 ++++----
 fdisks/i386_sys_types.c |  198 +++++++++++++++++++++++-----------------------
 6 files changed, 169 insertions(+), 157 deletions(-)

[....]

Quoted 8 lines
fdisks/common.h +8 -0
+
+/* Globally unique identifier */
+struct fdisk_guid {
+	uint32_t   time_low;
+	uint16_t   time_mid;
+	uint16_t   time_hi_and_version;
+	uint8_t    clock_seq_hi;
+	uint8_t    clock_seq_low;

fdisks/common.h line 21

Quoted 10 lines
fdisks/common.h +5 -2
+	uint8_t    node[6];
+};
 
 struct systypes {
-	unsigned char type;
-	char *name;
+	uint16_t          type;
+	struct fdisk_guid guid;
+	const char        *name;
 };

I don't like this hack. On all places in fdisk where we need systypes is available fdisk_context struct where is ideal place to store label specific stuff (ideally by any label specific function in fdisk_label).

fdisks/fdiskbsdlabel.h static char *xbsd_dktypenames[] = { · line 211

Quoted 10 lines

#ifdef DKTYPENAMES
static struct systypes xbsd_fstypes[] = {

fdisks/fdiskbsdlabel.h +0 -8
-        {BSD_FS_UNUSED, "unused"},
-	{BSD_FS_SWAP,   "swap"},
-	{BSD_FS_V6,     "Version 6"},
-	{BSD_FS_V7,     "Version 7"},
-	{BSD_FS_SYSV,   "System V"},
-	{BSD_FS_V71K,   "4.1BSD"},
-	{BSD_FS_V8,     "Eighth Edition"},
-	{BSD_FS_BSDFFS, "4.2BSD"},

it's really strange to modify BSD or DOS stuff when we need to add GPT. All what we need is to move this stuff to label specific files and make generic API for the structs. It's better to to this work now than modify all the entries and later fix the API.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#2 lore raw
Quoted 20 lines · Karel Zak
Quoted 7 lines · Davidlohr Bueso
 fdisks/cfdisk.c         |    2 +-
 fdisks/common.h         |   16 ++++-
 fdisks/fdiskbsdlabel.h  |   38 +++++-----
 fdisks/fdisksgilabel.c  |   38 +++++-----
 fdisks/fdisksunlabel.c  |   34 ++++----
 fdisks/i386_sys_types.c |  198 +++++++++++++++++++++++-----------------------
 6 files changed, 169 insertions(+), 157 deletions(-)

[....]

Quoted 11 lines
fdisks/common.h +10 -0
+
+/* Globally unique identifier */
+struct fdisk_guid {
+	uint32_t   time_low;
+	uint16_t   time_mid;
+	uint16_t   time_hi_and_version;
+	uint8_t    clock_seq_hi;
+	uint8_t    clock_seq_low;
+	uint8_t    node[6];
+};
Quoted 11 lines

fdisks/common.h line 21

Quoted 7 lines

struct systypes {

fdisks/common.h +3 -2
-	unsigned char type;
-	char *name;
+	uint16_t          type;
+	struct fdisk_guid guid;
+	const char        *name;
 };

I don't like this hack. On all places in fdisk where we need systypes is available fdisk_context struct where is ideal place to store label specific stuff (ideally by any label specific function in fdisk_label).

I'd say that creating label specific info in fdisk_context and moving such stuff there would be the next step. Doing it the other way round (which I agree would be nicer) would mean quite a lot of work given what we have now. Would it help if we extended this patchset with requested label specific stuff (and related cleanup) ?

Petr

Signature · 2 lines
Petr Uzel
IRC: ptr_uzl @ freenode
#3 lore raw
In reply to Karel Zak
Quoted 20 lines · Karel Zak
Quoted 7 lines · Davidlohr Bueso
 fdisks/cfdisk.c         |    2 +-
 fdisks/common.h         |   16 ++++-
 fdisks/fdiskbsdlabel.h  |   38 +++++-----
 fdisks/fdisksgilabel.c  |   38 +++++-----
 fdisks/fdisksunlabel.c  |   34 ++++----
 fdisks/i386_sys_types.c |  198 +++++++++++++++++++++++-----------------------
 6 files changed, 169 insertions(+), 157 deletions(-)

[....]

Quoted 11 lines
fdisks/common.h +10 -0
+
+/* Globally unique identifier */
+struct fdisk_guid {
+	uint32_t   time_low;
+	uint16_t   time_mid;
+	uint16_t   time_hi_and_version;
+	uint8_t    clock_seq_hi;
+	uint8_t    clock_seq_low;
+	uint8_t    node[6];
+};
Quoted 12 lines

fdisks/common.h line 21

Quoted 7 lines

struct systypes {

fdisks/common.h +3 -2
-	unsigned char type;
-	char *name;
+	uint16_t          type;
+	struct fdisk_guid guid;
+	const char        *name;
 };

I don't like this hack. On all places in fdisk where we need systypes is available fdisk_context struct where is ideal place to store label specific stuff (ideally by any label specific function in fdisk_label).

While this patchset was still being developed this was one of the things Petr and I discussed. Since systypes is usable throughout all of fdisk I did plan to add it to the fdisk_context structure (with basically the same members this patch uses - type, guid and name).

Quoted 7 lines
Quoted 7 lines

#ifdef DKTYPENAMES
static struct systypes xbsd_fstypes[] = {

fdisks/fdiskbsdlabel.h +0 -5
-        {BSD_FS_UNUSED, "unused"},
-	{BSD_FS_SWAP,   "swap"},
-	{BSD_FS_V6,     "Version 6"},
-	{BSD_FS_V7,     "Version 7"},
-	{BSD_FS_SYSV,   "System V"},
Quoted 9 lines

fdisks/fdiskbsdlabel.h static char *xbsd_dktypenames[] = { · line 211

Quoted 3 lines
fdisks/fdiskbsdlabel.h +0 -3
-	{BSD_FS_V71K,   "4.1BSD"},
-	{BSD_FS_V8,     "Eighth Edition"},
-	{BSD_FS_BSDFFS, "4.2BSD"},

it's really strange to modify BSD or DOS stuff when we need to add GPT. All what we need is to move this stuff to label specific files and make generic API for the structs. It's better to to this work now than modify all the entries and later fix the API.

Well ideally we could have a unique systypes than can be used by all labels, instead of defining it per-label, like what we currently have in DOS, BSD, GPT, SUN. If needed, we can also limit the scope of each label to use only the systypes it needs from that structure. Any thoughts?

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

Thanks.

maintainer
#4 lore raw
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

Anyway, I have no problem to write the patch to split part types to separate per-label tables :-)

It also seems that you're introduce a new hex codes for GPT partition types. It means that you want to use int16_t to address types defined by UUIDs. Is it good idea? Would be better to address the types by numbers <1-N> as printed in the menu or directly by UUIDs?

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#5 lore raw
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Quoted 3 lines

Anyway, I have no problem to write the patch to split part types to separate per-label tables :-)

Me neither, I can easly do it and rebase the GPT patch afterwards. I just really want us all to agree on how we're going to go about this.

Quoted 5 lines

It also seems that you're introduce a new hex codes for GPT partition types. It means that you want to use int16_t to address types defined by UUIDs. Is it good idea? Would be better to address the types by numbers <1-N> as printed in the menu or directly by UUIDs?

True, 1 through N is probably better - I'll look into it. In any case I don't see why we're showing the user (ie: 'l' menu option) hex values, we could easily just show decimal and any number for any partition type. Perhaps I'm missing something about standards, but I clearly remember certain values types, like 'Linux swap' to always be specified by value 82 (hex), which we can see defined in fdisk.h.

So would it be ok to be able to change these values if needed?

Thanks.

maintainer
#6 lore raw
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

Quoted 5 lines

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Maybe we can use strings.

struct fdisk_parttype {
const char *type; /* UUID, 0xNN, ... */
const char *description; /* help string */
};

The fdisk dialogs and menus are always based on strings and the final conversion to label specific type (int or GUID) may be done in label specific functions (like add_partition or so).

Quoted 5 lines
Quoted 4 lines

It also seems that you're introduce a new hex codes for GPT partition types. It means that you want to use int16_t to address types defined by UUIDs. Is it good idea? Would be better to address the types by numbers <1-N> as printed in the menu or directly by UUIDs?

Quoted 7 lines

True, 1 through N is probably better - I'll look into it. In any case I don't see why we're showing the user (ie: 'l' menu option) hex values, we could easily just show decimal and any number for any partition type. Perhaps I'm missing something about standards, but I clearly remember certain values types, like 'Linux swap' to always be specified by value 82 (hex), which we can see defined in fdisk.h.

So would it be ok to be able to change these values if needed?

We have to support the real values for backward compatibility and for extendability -- it should be possible to specify arbitrary UUID. I think the best is to support the both ways

- index value <1-N>
- real values (hex for DOS, strings for Mac, UUID for GPT, ...)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#7 lore raw
Quoted 10 lines · Karel Zak
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

Quoted 7 lines
Quoted 5 lines

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Maybe we can use strings.

I mean strings for UUIDs, for DOS we can keep integers there.

Quoted 1 line

struct fdisk_parttype {

      unsigned int code;
Quoted 7 lines

const char *type; /* UUID, 0xNN, ... */
const char *description; /* help string */
};

The fdisk dialogs and menus are always based on strings and the final conversion to label specific type (int or GUID) may be done in label specific functions (like add_partition or so).

I'll try to prepare a patch... it's the best way how to explain any idea :-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#8 lore raw
Quoted 17 lines · Karel Zak
Quoted 16 lines · Karel Zak
Quoted 14 lines · Davidlohr Bueso
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Quoted 12 lines
Quoted 1 line

Maybe we can use strings.

I mean strings for UUIDs, for DOS we can keep integers there.

Quoted 1 line

struct fdisk_parttype {

      unsigned int code;
Quoted 3 lines

const char *type; /* UUID, 0xNN, ... */
const char *description; /* help string */
};

Ok, so you mean having something like this, right?:

{0x8200, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", N_("Linux Swap")}

I see no problem decomposing the UUID string into the guid struct where it's actually needed, in label specific functions.

Quoted 10 lines
Quoted 4 lines

The fdisk dialogs and menus are always based on strings and the final conversion to label specific type (int or GUID) may be done in label specific functions (like add_partition or so).

I'll try to prepare a patch... it's the best way how to explain any idea :-)

Karel

#9 lore raw
In reply to Karel Zak
Quoted 17 lines · Karel Zak
Quoted 16 lines · Karel Zak
Quoted 14 lines · Davidlohr Bueso
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Quoted 11 lines
Quoted 1 line

Maybe we can use strings.

I mean strings for UUIDs, for DOS we can keep integers there.

Quoted 1 line

struct fdisk_parttype {

      unsigned int code;
Quoted 2 lines

const char *type; /* UUID, 0xNN, ... */
const char *description; /* help string */

+ int visibility;

Quoted 1 line
Quoted 1 line

};

One more thing. We also need a way of hiding parttypes from labels that don't use them. I was thinking on using a similar approach we have with the expert and common menus, just bitmasking the label types.

{0x8200, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", N_("Linux Swap"), ANY_LABEL }

Quoted 10 lines
Quoted 4 lines

The fdisk dialogs and menus are always based on strings and the final conversion to label specific type (int or GUID) may be done in label specific functions (like add_partition or so).

I'll try to prepare a patch... it's the best way how to explain any idea :-)

Karel

#10 lore raw
In reply to Karel Zak
Quoted 38 lines · Karel Zak
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Karel Zak
Quoted 2 lines · Davidlohr Bueso

I honestly don't see much difference between doing it before or after GPT, since all the other labels need to be adapted anyway.

I see a difference. Why we need struct fdisk_guid in struct where we define DOS partition types? Why there is {0} everywhere? Do you want to remove all these changes later?

Quoted 5 lines

My idea of having a unique systypes structure for all labels is for simplicity. I agree, using {0} isn't the best approach, so it would obviously go out, in favor of the same one the other labels would use. So if DOS doesn't need the GUID it just won't use it (and just call ->type or ->name), but it would still be there for those that do require it, like GPT.

Maybe we can use strings.

struct fdisk_parttype {
const char *type; /* UUID, 0xNN, ... */
const char *description; /* help string */
};

The fdisk dialogs and menus are always based on strings and the final conversion to label specific type (int or GUID) may be done in label specific functions (like add_partition or so).

Quoted 11 lines
Quoted 4 lines

It also seems that you're introduce a new hex codes for GPT partition types. It means that you want to use int16_t to address types defined by UUIDs. Is it good idea? Would be better to address the types by numbers <1-N> as printed in the menu or directly by UUIDs?

True, 1 through N is probably better - I'll look into it. In any case I don't see why we're showing the user (ie: 'l' menu option) hex values, we could easily just show decimal and any number for any partition type. Perhaps I'm missing something about standards, but I clearly remember certain values types, like 'Linux swap' to always be specified by value 82 (hex), which we can see defined in fdisk.h.

Quoted 9 lines
Quoted 1 line

So would it be ok to be able to change these values if needed?

We have to support the real values for backward compatibility and for extendability -- it should be possible to specify arbitrary UUID. I think the best is to support the both ways

- index value <1-N>
- real values (hex for DOS, strings for Mac, UUID for GPT, ...)

Ok, I'm a little lost here. What I'm referring to is what we present to the user for choosing a partition type. Currently we only use hex values. I don't think we should bother the user with UUIDs here. Maybe I'm just misreading this.

Thanks.