bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] To add FreeBSD GPT partitions


From: Arun Sharma
Subject: [PATCH] To add FreeBSD GPT partitions
Date: Wed, 16 Jun 2004 13:49:16 -0700
User-agent: Mozilla Thunderbird 0.5 (Windows/20040207)

All,

The attached patch adds GPT GUIDs defined by FreeBSD to GNU parted. This allows 
the use of GNU parted to create Linux as well as FreeBSD partitions on a dual 
boot EFI GPT based platform.

The filesystem probe routines are dummy and should not be used. The main intent 
is to be able to create the GUID partitions but not necessarily create the 
filesystem or probe it correctly.

Please let me know if you have any comments.

        -Arun

--- parted-1.6.11/libparted/fs_ufs/ufs.c.orig   2004-03-09 02:13:06.000000000 
-0800
+++ parted-1.6.11/libparted/fs_ufs/ufs.c        2004-06-09 18:07:43.000000000 
-0700
@@ -290,6 +290,24 @@
        get_copy_constraint:    NULL
 };
 
+static PedFileSystemOps ufs_ops_44bsd = {
+       probe:          ufs_probe_hp,   /* XXX: Fix me */
+#ifndef DISCOVER_ONLY
+       clobber:        ufs_clobber,
+#else
+       clobber:        NULL,
+#endif
+       open:           NULL,
+       create:         NULL,
+       close:          NULL,
+       check:          NULL,
+       copy:           NULL,
+       resize:         NULL,
+       get_create_constraint:  NULL,
+       get_resize_constraint:  NULL,
+       get_copy_constraint:    NULL
+};
+
 static PedFileSystemType ufs_type_sun = {
        next:   NULL,
        ops:    &ufs_ops_sun,
@@ -302,6 +320,18 @@
        name:   "hp-ufs"
 };
 
+static PedFileSystemType ufs_type_freebsd_ufs = {
+       next:   NULL,
+       ops:    &ufs_ops_44bsd,
+       name:   "freebsd-ufs"
+};
+
+static PedFileSystemType ufs_type_freebsd_swap = {
+       next:   NULL,
+       ops:    &ufs_ops_44bsd,
+       name:   "freebsd-swap"
+};
+
 void
 ped_file_system_ufs_init ()
 {
@@ -309,11 +339,15 @@
 
        ped_file_system_type_register (&ufs_type_sun);
        ped_file_system_type_register (&ufs_type_hp);
+       ped_file_system_type_register (&ufs_type_freebsd_ufs);
+       ped_file_system_type_register (&ufs_type_freebsd_swap);
 }
 
 void
 ped_file_system_ufs_done ()
 {
+       ped_file_system_type_unregister (&ufs_type_freebsd_swap);
+       ped_file_system_type_unregister (&ufs_type_freebsd_ufs);
        ped_file_system_type_unregister (&ufs_type_hp);
        ped_file_system_type_unregister (&ufs_type_sun);
 }
--- parted-1.6.11/libparted/disk_gpt.c.orig     2004-03-10 14:11:42.000000000 
-0800
+++ parted-1.6.11/libparted/disk_gpt.c  2004-06-09 18:19:33.000000000 -0700
@@ -111,6 +111,25 @@
     ((efi_guid_t) { PED_CPU_TO_LE32 (0xe2a1e728), PED_CPU_TO_LE16 (0x32e3), \
                    PED_CPU_TO_LE16 (0x11d6), 0xa6, 0x82, \
                    { 0x7b, 0x03, 0xa0, 0x00, 0x00, 0x00 }})
+#define PARTITION_FREEBSD_GUID \
+   ((efi_guid_t) { PED_CPU_TO_LE32 (0x516e7cb4), PED_CPU_TO_LE16 (0x6ecf), \
+                   PED_CPU_TO_LE16 (0x11d6), 0x8f, 0xf8, \
+                   { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b }})
+
+#define PARTITION_FREEBSD_SWAP_GUID \
+   ((efi_guid_t) { PED_CPU_TO_LE32 (0x516e7cb5), PED_CPU_TO_LE16 (0x6ecf), \
+                   PED_CPU_TO_LE16 (0x11d6), 0x8f, 0xf8, \
+                   { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b }})
+
+#define PARTITION_FREEBSD_UFS_GUID \
+   ((efi_guid_t) { PED_CPU_TO_LE32 (0x516e7cb6), PED_CPU_TO_LE16 (0x6ecf), \
+                   PED_CPU_TO_LE16 (0x11d6), 0x8f, 0xf8, \
+                   { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b }})
+
+#define PARTITION_FREEBSD_VINUM_GUID \
+   ((efi_guid_t) { PED_CPU_TO_LE32 (0x516e7cb8), PED_CPU_TO_LE16 (0x6ecf), \
+                   PED_CPU_TO_LE16 (0x11d6), 0x8f, 0xf8, \
+                   { 0x00, 0x02, 0x2d, 0x09, 0x71, 0x2b }})
 
 typedef struct _GuidPartitionTableHeader_t {
        uint64_t Signature;
@@ -951,10 +970,21 @@
                        gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
                        return 1;
                }
-               if (strstr (fs_type->name, "swap")) {
+
+               if (strncmp(fs_type->name, "swap", 4) == 0) {
                        gpt_part_data->type = PARTITION_SWAP_GUID;
                        return 1;
                }
+
+               if (strncmp(fs_type->name, "freebsd-swap", 12) == 0) {
+                       gpt_part_data->type = PARTITION_FREEBSD_SWAP_GUID;
+                       return 1;
+               }
+
+               if (strncmp(fs_type->name, "freebsd-ufs", 11) == 0) {
+                       gpt_part_data->type = PARTITION_FREEBSD_UFS_GUID;
+                       return 1;
+               }
        }
 
        gpt_part_data->type = PARTITION_BASIC_DATA_GUID;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]