- Read NVMe model names from sysfs (dann.frazier)

- Fix warnings from GCC 7's -Wimplicit-fallthrough (dann.frazier)
- ped_unit_get_name: Resolve conflicting attributes 'const' and 'pure' (dann.frazier)
- Add udf to t1700-probe-fs and to the manpage (bcl)
- libparted: Add support for MBR id, GPT GUID and detection of UDF filesystem (pali.rohar)
- Fix potential command line buffer overflow (xu.simon)
- t6100-mdraid-partitions: Use v0.90 metadata for the test (bcl)
- parted.c: Make sure dev_name is freed (bcl)
- parted.c: Always free peek_word (bcl)
- Fix the length of several strncpy calls (bcl)
This commit is contained in:
Brian C. Lane 2018-10-16 15:38:03 -07:00
parent c0bbbd4bbe
commit 8f615e462d
12 changed files with 895 additions and 3 deletions

View File

@ -0,0 +1,29 @@
From 93684aeb12cf96e5bfefa405940c3010f60161b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm@gentoo.org>
Date: Sat, 14 Jul 2018 09:09:31 +0200
Subject: [PATCH] libparted: Fix ending CHS address in PMBR.
According to the UEFI specification version 2.7, Section 5.2.3,
Table 16, the ending CHS address in the protective MBR should be set
to 0xFFFFFF. This also agrees with the behaviour of fdisk from
util-linux-2.32.
---
libparted/labels/gpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 4f922b2..6f92a34 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1144,7 +1144,7 @@ _write_pmbr (PedDevice *dev, bool pmbr_boot)
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
pmbr->PartitionRecord[0].StartSector = 2;
- pmbr->PartitionRecord[0].EndHead = 0xFE;
+ pmbr->PartitionRecord[0].EndHead = 0xFF;
pmbr->PartitionRecord[0].EndSector = 0xFF;
pmbr->PartitionRecord[0].EndTrack = 0xFF;
pmbr->PartitionRecord[0].StartingLBA = PED_CPU_TO_LE32 (1);
--
2.17.2

View File

@ -0,0 +1,76 @@
From 60906f5674ca32ddfaf8c18fe2e4ebe510dbbd6f Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 23 Jul 2018 14:34:30 -0700
Subject: [PATCH 094/103] Fix the length of several strncpy calls
These need to be 1 less than the allocated size of the buffer, strncpy
will fill shorter strings with zeros, but there needs to be room for at
least one 0x00 at the end if the string is the same length as the buffer
and has no terminating 0x00.
Related: rhbz#1602652
---
libparted/arch/linux.c | 12 ++++++++----
libparted/labels/mac.c | 9 ++++++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 7e86b51..4c778ea 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2582,9 +2582,12 @@ _blkpg_add_partition (PedDisk* disk, const PedPartition *part)
linux_part.length = part->geom.length * disk->dev->sector_size;
}
linux_part.pno = part->num;
- strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
- if (vol_name)
- strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH);
+ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH-1);
+ linux_part.devname[BLKPG_DEVNAMELTH-1] = '\0';
+ if (vol_name) {
+ strncpy (linux_part.volname, vol_name, BLKPG_VOLNAMELTH-1);
+ linux_part.volname[BLKPG_VOLNAMELTH-1] = '\0';
+ }
free (dev_name);
@@ -2640,7 +2643,8 @@ static int _blkpg_resize_partition (PedDisk* disk, const PedPartition *part)
else
linux_part.length = part->geom.length * disk->dev->sector_size;
linux_part.pno = part->num;
- strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
+ strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH-1);
+ linux_part.devname[BLKPG_DEVNAMELTH-1] = '\0';
free (dev_name);
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index fa4e43f..4942c82 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -930,8 +930,10 @@ _generate_raw_part (PedDisk* disk, PedPartition* part,
= PED_CPU_TO_BE32 (mac_disk_data->last_part_entry_num);
part_map_entry->start_block = PED_CPU_TO_BE32 (part->geom.start);
part_map_entry->block_count = PED_CPU_TO_BE32 (part->geom.length);
- strncpy (part_map_entry->name, mac_part_data->volume_name, 32);
- strncpy (part_map_entry->type, mac_part_data->system_name, 32);
+ strncpy (part_map_entry->name, mac_part_data->volume_name, 31);
+ part_map_entry->name[31] = '\0';
+ strncpy (part_map_entry->type, mac_part_data->system_name, 31);
+ part_map_entry->type[31] = '\0';
if (mac_part_data->is_driver) {
if (mac_part_data->has_driver)
@@ -954,7 +956,8 @@ _generate_raw_part (PedDisk* disk, PedPartition* part,
part_map_entry->boot_cksum =
PED_CPU_TO_BE32 (mac_part_data->boot_checksum);
- strncpy (part_map_entry->processor, mac_part_data->processor_name, 16);
+ strncpy (part_map_entry->processor, mac_part_data->processor_name, 15);
+ part_map_entry->processor[15] = '\0';
if (!_pad_raw_part (disk, part->num, part_map))
goto error;
--
2.17.2

View File

@ -0,0 +1,35 @@
From b260c3354d5e9318321c2fc482724870fd9b2740 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 23 Jul 2018 15:12:38 -0700
Subject: [PATCH 095/103] parted.c: Always free peek_word
If command_line_get_fs_type failed it would never free it, so put a free
in both branches of the if.
Related: rhbz#1602652
---
parted/parted.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/parted/parted.c b/parted/parted.c
index 267c346..0dc38c3 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -684,12 +684,13 @@ do_mkpart (PedDevice** dev, PedDisk** diskp)
if (part_type == PED_PARTITION_EXTENDED
|| (peek_word && (isdigit (peek_word[0]) || peek_word[0] == '-'))) {
fs_type = NULL;
+ free (peek_word);
} else {
+ free (peek_word);
if (!command_line_get_fs_type (_("File system type?"),
&fs_type))
goto error;
}
- free (peek_word);
if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start, NULL))
goto error;
--
2.17.2

View File

@ -0,0 +1,45 @@
From c624fe22349912ca8bd1a288d5ccc65b6e346420 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 23 Jul 2018 15:18:37 -0700
Subject: [PATCH 096/103] parted.c: Make sure dev_name is freed
If there was a problem with ped_device_get or ped_device_open it would not be freed.
Related: rhbz#1602652
---
parted/parted.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 0dc38c3..35432c6 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1101,6 +1101,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
if (has_devices_arg) {
char* dev_name;
PedDevice* current_dev = NULL;
+ int status = 0;
ped_device_probe_all();
@@ -1116,14 +1117,11 @@ do_print (PedDevice** dev, PedDisk** diskp)
ped_device_free_all ();
*dev = ped_device_get (dev_name);
- if (!*dev)
- return 0;
- if (!ped_device_open (*dev))
- return 0;
-
+ if (*dev && ped_device_open (*dev))
+ status = 1;
free (dev_name);
- return 1;
+ return status;
}
else if (has_list_arg)
--
2.17.2

View File

@ -0,0 +1,29 @@
From f0cfa9581f6bd9a1b0d7f0389d3460bcd4ccfde8 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 23 Jul 2018 16:07:40 -0700
Subject: [PATCH 097/103] t6100-mdraid-partitions: Use v0.90 metadata for the
test
Newer metadata types use more disk space, causing the test to fail.
---
tests/t6100-mdraid-partitions.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index b37cddf..42905fa 100755
--- a/tests/t6100-mdraid-partitions.sh
+++ b/tests/t6100-mdraid-partitions.sh
@@ -45,8 +45,8 @@ cleanup_fn_() {
mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev"
}
-# create mdraid on top of both partitions
-mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
+# create mdraid on top of both partitions with v0.90 metadata
+mdadm -C $md_dev -e0 --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
wait_for_dev_to_appear_ ${md_dev} || { fail=1; cat /proc/partitions; }
# create gpt and two partitions on the raid device
--
2.17.2

View File

@ -0,0 +1,46 @@
From a52926f6d3cd2520419c60d4f81a410d33d6d970 Mon Sep 17 00:00:00 2001
From: Simon Xu <xu.simon@oracle.com>
Date: Mon, 20 Aug 2018 20:31:26 +0800
Subject: [PATCH 098/103] Fix potential command line buffer overflow
parted terminates with 'stack smashing detected' when fed with a long command
line argument, and segfaults when the argument is long enough:
root # /sbin/parted /dev/sda $(perl -e 'print "a"x265')
*** stack smashing detected ***: /sbin/parted terminated
...
Aborted
root # /sbin/parted /dev/sda $(perl -e 'print "a"x328')
*** stack smashing detected ***: /sbin/parted terminated
...
Command History:
Segmentation fault
parted should be able to detect it and exit with error and usage messages.
This also makes command line buffer overflow exploit more possible. Fix it by
adding length check in the condition of the for loop where command line
arguments are copied.
Signed-off-by: Simon Xu <xu.simon@oracle.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
parted/ui.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parted/ui.c b/parted/ui.c
index 4f42b7c..d421768 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -728,7 +728,7 @@ command_line_push_line (const char* line, int multi_word)
line++;
i = 0;
- for (; *line; line++) {
+ for (; *line && i < sizeof (this_word) - 1; line++) {
if (*line == ' ' && !quoted) {
if (multi_word)
break;
--
2.17.2

View File

@ -0,0 +1,379 @@
From 8740cfcff3ea839dd6dc8650dec0a466e9870625 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
Date: Tue, 28 Aug 2018 21:20:01 +0200
Subject: [PATCH 099/103] libparted: Add support for MBR id, GPT GUID and
detection of UDF filesystem
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.
Detection of UDF filesystem is done by checking presence of UDF VSD (NSR02
or NSR03 identifier) and UDF AVDP at expected locations (blocks 256, -257,
-1, 512).
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
NEWS | 2 +
libparted/fs/Makefile.am | 1 +
libparted/fs/udf/udf.c | 175 ++++++++++++++++++++++++++
libparted/labels/dos.c | 3 +
libparted/labels/gpt.c | 1 +
libparted/libparted.c | 4 +
scripts/data/abi/baseline_symbols.txt | 2 +
tests/Makefile.am | 1 +
tests/t2410-dos-udf-partition-type.sh | 38 ++++++
9 files changed, 227 insertions(+)
create mode 100644 libparted/fs/udf/udf.c
create mode 100644 tests/t2410-dos-udf-partition-type.sh
diff --git a/NEWS b/NEWS
index ee6efb6..45ea91c 100644
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,8 @@ GNU parted NEWS -*- outline -*-
** New Features
+ Add support for MBR id, GPT GUID and detection of UDF filesystem.
+
libparted-fs-resize: Work on non 512 byte sectors.
Add resizepart command to resize a partition. This works even on
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..00209e1
--- /dev/null
+++ b/libparted/fs/udf/udf.c
@@ -0,0 +1,175 @@
+/*
+ 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>
+
+/* Read bytes using ped_geometry_read() function */
+static int read_bytes (const PedGeometry* geom, void* buffer, PedSector offset, PedSector count)
+{
+ char* sector_buffer;
+ PedSector sector_offset, sector_count, buffer_offset;
+
+ sector_offset = offset / geom->dev->sector_size;
+ sector_count = (offset + count + geom->dev->sector_size - 1) / geom->dev->sector_size - sector_offset;
+ buffer_offset = offset - sector_offset * geom->dev->sector_size;
+
+ sector_buffer = alloca (sector_count * geom->dev->sector_size);
+
+ if (!ped_geometry_read (geom, sector_buffer, sector_offset, sector_count))
+ return 0;
+
+ memcpy (buffer, sector_buffer + buffer_offset, count);
+ return 1;
+}
+
+/* Scan VSR and check for UDF VSD */
+static int check_vrs (const PedGeometry* geom, unsigned int vsdsize)
+{
+ PedSector block;
+ PedSector offset;
+ unsigned char ident[5];
+
+ /* Check only first 64 blocks, but theoretically standard does not define upper limit */
+ for (block = 0; block < 64; block++) {
+ /* VRS starts at fixed offset 32kB, it is independent of block size or vsd size */
+ offset = 32768 + block * vsdsize;
+
+ /* Read VSD identifier, it is at offset 1 */
+ if (!read_bytes (geom, ident, offset + 1, 5))
+ return 0;
+
+ /* Check for UDF identifier */
+ if (memcmp (ident, "NSR02", 5) == 0 ||
+ memcmp (ident, "NSR03", 5) == 0)
+ return 1;
+
+ /* Unknown VSD identifier means end of VRS */
+ if (memcmp (ident, "BEA01", 5) != 0 &&
+ memcmp (ident, "TEA01", 5) != 0 &&
+ memcmp (ident, "BOOT2", 5) != 0 &&
+ memcmp (ident, "CD001", 5) != 0 &&
+ memcmp (ident, "CDW02", 5) != 0)
+ break;
+ }
+
+ return 0;
+}
+
+/* Check for UDF AVDP */
+static int check_anchor (const PedGeometry* geom, unsigned int blocksize, int rel_block)
+{
+ PedSector block;
+ unsigned char tag[16];
+
+ /* Negative block means relative to the end of device */
+ if (rel_block < 0) {
+ block = geom->length * geom->dev->sector_size / blocksize;
+ if (block <= (PedSector)(-rel_block))
+ return 0;
+ block -= (PedSector)(-rel_block);
+ if (block < 257)
+ return 0;
+ } else {
+ block = rel_block;
+ }
+
+ if (!read_bytes (geom, tag, block * blocksize, 16))
+ return 0;
+
+ /* Check for AVDP type (0x0002) */
+ if (((unsigned short)tag[0] | ((unsigned short)tag[1] << 8)) != 0x0002)
+ return 0;
+
+ /* Check that location stored in AVDP matches */
+ if (((unsigned long)tag[12] | ((unsigned long)tag[13] << 8) | ((unsigned long)tag[14] << 16) | ((unsigned long)tag[15] << 24)) != block)
+ return 0;
+
+ return 1;
+}
+
+/* Detect presence of UDF AVDP */
+static int detect_anchor(const PedGeometry* geom, unsigned int blocksize)
+{
+ /* All possible AVDP locations in preferred order */
+ static int anchors[] = { 256, -257, -1, 512 };
+ size_t i;
+
+ for (i = 0; i < sizeof (anchors)/sizeof (*anchors); i++) {
+ if (check_anchor (geom, blocksize, anchors[i]))
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Detect UDF filesystem, it must have VRS and AVDP */
+static int detect_udf (const PedGeometry* geom)
+{
+ unsigned int blocksize;
+
+ /* VSD size is min(2048, UDF block size), check for block sizes <= 2048 */
+ if (check_vrs (geom, 2048)) {
+ for (blocksize = 512; blocksize <= 2048; blocksize *= 2) {
+ if (detect_anchor (geom, blocksize))
+ return 1;
+ }
+ }
+
+ /* Check for block sizes larger then 2048, maximal theoretical block size is 32kB */
+ for (blocksize = 4096; blocksize <= 32768; blocksize *= 2) {
+ if (!check_vrs (geom, blocksize))
+ continue;
+ if (detect_anchor (geom, blocksize))
+ return 1;
+ }
+
+ return 0;
+}
+
+PedGeometry*
+udf_probe (PedGeometry* geom)
+{
+ if (!detect_udf (geom))
+ return NULL;
+
+ return ped_geometry_duplicate (geom);
+}
+
+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 6f92a34..860f415 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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3851983..3fa75a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -51,6 +51,7 @@ TESTS = \
t2310-dos-extended-2-sector-min-offset.sh \
t2320-dos-extended-noclobber.sh \
t2400-dos-hfs-partition-type.sh \
+ t2410-dos-udf-partition-type.sh \
t2500-probe-corrupt-hfs.sh \
t3000-resize-fs.sh \
t3200-resize-partition.sh \
diff --git a/tests/t2410-dos-udf-partition-type.sh b/tests/t2410-dos-udf-partition-type.sh
new file mode 100644
index 0000000..7cc8a02
--- /dev/null
+++ b/tests/t2410-dos-udf-partition-type.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Ensure that an UDF partition in a dos table gets the right ID
+
+# 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/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+dev=loop-file
+ss=$sector_size_
+n_sectors=8000
+
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || framework_failure
+
+# create a GPT partition table
+parted -s $dev mklabel msdos \
+ mkpart pri udf 2048s 4095s > out 2>&1 || fail=1
+# expect no output
+compare /dev/null out || fail=1
+
+# Extract the "type" byte of the first partition.
+od -An -j450 -tx1 -N1 $dev > out || fail=1
+printf ' 07\n' > exp || fail=1
+compare exp out || fail=1
+
+Exit $fail
--
2.17.2

View File

@ -0,0 +1,41 @@
From 749b42f25534bec8625e74a6c1c61c3ad6cc8b17 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 16 Oct 2018 13:37:09 -0700
Subject: [PATCH 100/103] Add udf to t1700-probe-fs and to the manpage
If mkfs.udf is installed this will test to make sure that the filesystem
is detected.
---
doc/C/parted.8 | 2 +-
tests/t1700-probe-fs.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index eb7cd98..fecdc29 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -78,7 +78,7 @@ Create a new partition. \fIpart-type\fP may be specified only with msdos and
dvh partition tables, it should be one of "primary", "logical", or "extended".
\fIname\fP is required for GPT partition tables and \fIfs-type\fP is optional.
\fIfs-type\fP can be one of "btrfs", "ext2", "ext3", "ext4", "fat16", "fat32",
-"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", or "xfs".
+"hfs", "hfs+", "linux-swap", "ntfs", "reiserfs", "udf", or "xfs".
.TP
.B name \fIpartition\fP \fIname\fP
Set the name of \fIpartition\fP to \fIname\fP. This option works only on Mac,
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index b13cec0..853d6bc 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -23,7 +23,7 @@ dev=loop-file
ss=$sector_size_
n_sectors=$((512*1024))
-for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus; do
+for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus udf; do
( mkfs.$type 2>&1 | grep -i '^usage' ) > /dev/null \
|| { warn_ "$ME: no $type support"; continue; }
--
2.17.2

View File

@ -0,0 +1,34 @@
From 3262e2fe9ec93ad2c24e1b117bf87fb6f4b6ffec Mon Sep 17 00:00:00 2001
From: dann frazier <dann.frazier@canonical.com>
Date: Fri, 31 Aug 2018 09:28:27 -0600
Subject: [PATCH 101/103] ped_unit_get_name: Resolve conflicting attributes
'const' and 'pure'
The const and pure attributes conflict:
error: ignoring attribute 'const' because it conflicts with attribute 'pure' [-Werror=attributes]
pure functions may access global memory, const functions may not.
ped_unit_get_name() accesses non-local variable unit_names, so drop const.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/unit.in.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/parted/unit.in.h b/include/parted/unit.in.h
index 9d6e06a..315660d 100644
--- a/include/parted/unit.in.h
+++ b/include/parted/unit.in.h
@@ -66,7 +66,7 @@ typedef enum {
extern long long ped_unit_get_size (const PedDevice* dev, PedUnit unit);
extern const char *ped_unit_get_name (PedUnit unit)
- _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST;
+ _GL_ATTRIBUTE_PURE;
extern PedUnit ped_unit_get_by_name (const char* unit_name) _GL_ATTRIBUTE_PURE;
extern void ped_unit_set_default (PedUnit unit);
--
2.17.2

View File

@ -0,0 +1,97 @@
From 25a19f80a97b4b04d1ada3fdfe45671121886b6d Mon Sep 17 00:00:00 2001
From: dann frazier <dann.frazier@canonical.com>
Date: Fri, 31 Aug 2018 09:28:28 -0600
Subject: [PATCH 102/103] Fix warnings from GCC 7's -Wimplicit-fallthrough
All of these locations appear to have intentional fallthroughs. Add
comments that GCC will detect to mute warnings w/ -Wimplicit-fallthrough.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/linux.c | 8 ++++++++
libparted/labels/rdb.c | 1 +
2 files changed, 9 insertions(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4c778ea..02d7a52 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -961,6 +961,7 @@ init_ide (PedDevice* dev)
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_IGNORE:
dev->model = strdup(_("Generic IDE"));
break;
@@ -998,6 +999,7 @@ init_ide (PedDevice* dev)
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_IGNORE:
break;
default:
@@ -1347,6 +1349,7 @@ init_generic (PedDevice* dev, const char* model_name)
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_IGNORE:
break;
default:
@@ -1890,6 +1893,7 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_CANCEL:
return 0;
default:
@@ -1933,6 +1937,7 @@ linux_read (const PedDevice* dev, void* buffer, PedSector start,
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_CANCEL:
free(diobuf);
return 0;
@@ -2032,6 +2037,7 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start,
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_CANCEL:
return 0;
default:
@@ -2075,6 +2081,7 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start,
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_CANCEL:
free(diobuf_start);
return 0;
@@ -2146,6 +2153,7 @@ _do_fsync (PedDevice* dev)
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
+ /* FALLTHROUGH */
case PED_EXCEPTION_CANCEL:
return 0;
default:
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index 34b59aa..48e8d7a 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -175,6 +175,7 @@ _amiga_read_block (const PedDevice *dev, struct AmigaBlock *blk,
_amiga_calculate_checksum(AMIGA(blk));
if (!ped_device_write ((PedDevice*)dev, blk, block, 1))
return NULL;
+ /* FALLTHROUGH */
case PED_EXCEPTION_IGNORE :
case PED_EXCEPTION_UNHANDLED :
default :
--
2.17.2

View File

@ -0,0 +1,59 @@
From 279bd5540a59e3bdc4e3702ff062f87fd842c0e9 Mon Sep 17 00:00:00 2001
From: dann frazier <dann.frazier@canonical.com>
Date: Fri, 7 Sep 2018 13:31:15 -0600
Subject: [PATCH 103/103] Read NVMe model names from sysfs
parted currently shows the same generic model name for all NVMe devices:
# parted /dev/nvme0n1 -s print | grep Model
Model: NVMe Device (nvme)
If the model information is available in sysfs, display that instead:
# parted /dev/nvme0n1 -s print | grep Model
Model: THNSN5512GPU7 NVMe TOSHIBA 512GB (nvme)
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/linux.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 02d7a52..7d83dfb 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1405,6 +1405,22 @@ init_sdmmc (PedDevice* dev)
return init_generic(dev, id);
}
+static int
+init_nvme (PedDevice* dev)
+{
+ int ret;
+ char *model = read_device_sysfs_file (dev, "model");
+
+ if (!model)
+ ret = init_generic (dev, _("NVMe Device"));
+ else {
+ ret = init_generic (dev, model);
+ free (model);
+ }
+
+ return ret;
+}
+
static PedDevice*
linux_new (const char* path)
{
@@ -1489,7 +1505,7 @@ linux_new (const char* path)
break;
case PED_DEVICE_NVME:
- if (!init_generic (dev, _("NVMe Device")))
+ if (!init_nvme (dev))
goto error_free_arch_specific;
break;
--
2.17.2

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.2
Release: 36%{?dist}
Release: 37%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -104,13 +104,23 @@ Patch0087: 0087-Fix-resizepart-iec-unit-end-sector.patch
Patch0088: 0088-build-Remove-unused-traces-of-dynamic-loading.patch
Patch0089: 0089-Lift-512-byte-restriction-on-fat-resize.patch
Patch0090: 0090-Fix-atari-label-false-positives.patch
Patch0091: 0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch
# Use python3 in the buildroot
# Sent upstream 2018-06-27
Patch0091: 0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch
Patch0092: 0092-Switch-gpt-header-move-and-msdos-overlap-to-python3.patch
Patch0093: 0093-libparted-Fix-ending-CHS-address-in-PMBR.patch
Patch0094: 0094-Fix-the-length-of-several-strncpy-calls.patch
Patch0095: 0095-parted.c-Always-free-peek_word.patch
Patch0096: 0096-parted.c-Make-sure-dev_name-is-freed.patch
Patch0097: 0097-t6100-mdraid-partitions-Use-v0.90-metadata-for-the-t.patch
Patch0098: 0098-Fix-potential-command-line-buffer-overflow.patch
Patch0099: 0099-libparted-Add-support-for-MBR-id-GPT-GUID-and-detect.patch
Patch0100: 0100-Add-udf-to-t1700-probe-fs-and-to-the-manpage.patch
Patch0101: 0101-ped_unit_get_name-Resolve-conflicting-attributes-con.patch
Patch0102: 0102-Fix-warnings-from-GCC-7-s-Wimplicit-fallthrough.patch
Patch0103: 0103-Read-NVMe-model-names-from-sysfs.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gcc
@ -239,6 +249,18 @@ fi
%changelog
* Tue Oct 16 2018 Brian C. Lane <bcl@redhat.com> - 3.2-37
- Read NVMe model names from sysfs (dann.frazier)
- Fix warnings from GCC 7's -Wimplicit-fallthrough (dann.frazier)
- ped_unit_get_name: Resolve conflicting attributes 'const' and 'pure' (dann.frazier)
- Add udf to t1700-probe-fs and to the manpage (bcl)
- libparted: Add support for MBR id, GPT GUID and detection of UDF filesystem (pali.rohar)
- Fix potential command line buffer overflow (xu.simon)
- t6100-mdraid-partitions: Use v0.90 metadata for the test (bcl)
- parted.c: Make sure dev_name is freed (bcl)
- parted.c: Always free peek_word (bcl)
- Fix the length of several strncpy calls (bcl)
* Thu Jul 19 2018 Brian C. Lane <bcl@redhat.com> - 3.2-36
- drop ldconfig, it no longer needs to be called on un/install (bcl)
- Fix msdos-overlap py3 conversion (bcl)