[parted-devel] [PATCH] libparted: Add support for MBR id and GPT GUID of UDF filesystem
Pali Rohár
pali.rohar at gmail.com
Mon Aug 13 21:31:27 BST 2018
This is needed for libparted based applications (like Gparted) to correctly
choose MBR id and GPT GUID for UDF filesystem. MBR id for UDF is 0x07 and
GPT GUID is Microsoft Basic Data, see why: https://serverfault.com/a/829172
Without registering a new libparted fs code it is not possible to assign
MBR id or GPT GUID. So there is a stub for udf filesystem.
---
libparted/fs/Makefile.am | 1 +
libparted/fs/udf/udf.c | 50 +++++++++++++++++++++++++++++++++++
libparted/labels/dos.c | 3 +++
libparted/labels/gpt.c | 1 +
libparted/libparted.c | 4 +++
scripts/data/abi/baseline_symbols.txt | 2 ++
6 files changed, 61 insertions(+)
create mode 100644 libparted/fs/udf/udf.c
diff --git a/libparted/fs/Makefile.am b/libparted/fs/Makefile.am
index d3cc8bc..cab32c7 100644
--- a/libparted/fs/Makefile.am
+++ b/libparted/fs/Makefile.am
@@ -44,6 +44,7 @@ libfs_la_SOURCES = \
ntfs/ntfs.c \
reiserfs/reiserfs.c \
reiserfs/reiserfs.h \
+ udf/udf.c \
ufs/ufs.c \
xfs/platform_defs.h \
xfs/xfs.c \
diff --git a/libparted/fs/udf/udf.c b/libparted/fs/udf/udf.c
new file mode 100644
index 0000000..4373ed6
--- /dev/null
+++ b/libparted/fs/udf/udf.c
@@ -0,0 +1,50 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <config.h>
+
+#include <parted/parted.h>
+
+PedGeometry*
+udf_probe (PedGeometry* geom)
+{
+ /* Detection is not implemented yet */
+ return NULL;
+}
+
+static PedFileSystemOps udf_ops = {
+ probe: udf_probe,
+};
+
+static PedFileSystemType udf_type = {
+ next: NULL,
+ ops: &udf_ops,
+ name: "udf",
+};
+
+void
+ped_file_system_udf_init ()
+{
+ ped_file_system_type_register (&udf_type);
+}
+
+void
+ped_file_system_udf_done ()
+{
+ ped_file_system_type_unregister (&udf_type);
+}
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index fa53020..b2b8de9 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -65,6 +65,7 @@ static const char MBR_BOOT_CODE[] = {
#define PARTITION_FAT16 0x06
#define PARTITION_NTFS 0x07
#define PARTITION_HPFS 0x07
+#define PARTITION_UDF 0x07
#define PARTITION_FAT32 0x0b
#define PARTITION_FAT32_LBA 0x0c
#define PARTITION_FAT16_LBA 0x0e
@@ -1498,6 +1499,8 @@ msdos_partition_set_system (PedPartition* part,
} else if (!strcmp (fs_type->name, "hfs")
|| !strcmp (fs_type->name, "hfs+"))
dos_data->system = PARTITION_HFS;
+ else if (!strcmp (fs_type->name, "udf"))
+ dos_data->system = PARTITION_UDF;
else if (!strcmp (fs_type->name, "sun-ufs"))
dos_data->system = PARTITION_SUN_UFS;
else if (is_linux_swap (fs_type->name))
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 4f922b2..925ff08 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1513,6 +1513,7 @@ gpt_partition_set_system (PedPartition *part,
if (fs_type)
{
if (strncmp (fs_type->name, "fat", 3) == 0
+ || strcmp (fs_type->name, "udf") == 0
|| strcmp (fs_type->name, "ntfs") == 0)
{
gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
diff --git a/libparted/libparted.c b/libparted/libparted.c
index 3bd071d..e517875 100644
--- a/libparted/libparted.c
+++ b/libparted/libparted.c
@@ -112,6 +112,7 @@ extern void ped_file_system_fat_init (void);
extern void ped_file_system_ext2_init (void);
extern void ped_file_system_nilfs2_init (void);
extern void ped_file_system_btrfs_init (void);
+extern void ped_file_system_udf_init (void);
static void
init_file_system_types ()
@@ -128,6 +129,7 @@ init_file_system_types ()
ped_file_system_ext2_init ();
ped_file_system_nilfs2_init ();
ped_file_system_btrfs_init ();
+ ped_file_system_udf_init ();
}
extern void ped_disk_aix_done ();
@@ -193,6 +195,7 @@ extern void ped_file_system_ufs_done (void);
extern void ped_file_system_xfs_done (void);
extern void ped_file_system_amiga_done (void);
extern void ped_file_system_btrfs_done (void);
+extern void ped_file_system_udf_done (void);
static void
done_file_system_types ()
@@ -209,6 +212,7 @@ done_file_system_types ()
ped_file_system_xfs_done ();
ped_file_system_amiga_done ();
ped_file_system_btrfs_done ();
+ ped_file_system_udf_done ();
}
static void _done() __attribute__ ((destructor));
diff --git a/scripts/data/abi/baseline_symbols.txt b/scripts/data/abi/baseline_symbols.txt
index 9162f1a..69abd82 100644
--- a/scripts/data/abi/baseline_symbols.txt
+++ b/scripts/data/abi/baseline_symbols.txt
@@ -340,6 +340,8 @@ FUNC:ped_file_system_type_get
FUNC:ped_file_system_type_get_next
FUNC:ped_file_system_type_register
FUNC:ped_file_system_type_unregister
+FUNC:ped_file_system_udf_init
+FUNC:ped_file_system_udf_done
FUNC:ped_file_system_ufs_done
FUNC:ped_file_system_ufs_init
FUNC:ped_file_system_xfs_done
--
2.11.0
More information about the parted-devel
mailing list