forked from pool/parted
Accepting request 541562 from Base:System
OBS-URL: https://build.opensuse.org/request/show/541562 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/parted?expand=0&rev=119
This commit is contained in:
commit
2e499b2bb2
74
libparted-Add-support-for-NVDIMM-devices.patch
Normal file
74
libparted-Add-support-for-NVDIMM-devices.patch
Normal file
@ -0,0 +1,74 @@
|
||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
||||
Date: Mon, 23 Oct 2017 17:47:47 +0200
|
||||
Subject: Add support for NVDIMM devices
|
||||
References: bsc#1064446
|
||||
Patch-mainline: submitted, 2017-10-24 10:22 +0200
|
||||
|
||||
Recognize NVDIMM devices, so that "parted -s /dev/pmem7 p" now
|
||||
prints "Model: NVDIMM Device (pmem)" instead of
|
||||
"Model: Unknown (unknown)".
|
||||
|
||||
In order for a device to be recognized as NVDIMM, it has to
|
||||
have a 'blkext' major number. But since this major can be
|
||||
used also by other device types, we also check that the device
|
||||
path contains 'pmem' as a substring.
|
||||
|
||||
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_PMEM
|
||||
* libparted/arch/linux.c(_device_probe_type): Recognize NVDIMM devices.
|
||||
* libparted/arch/linux.c(linux_new): Handle NVDIMM devices.
|
||||
* parted/parted.c(do_print): Add "pmem" to list of transports.
|
||||
|
||||
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
---
|
||||
include/parted/device.in.h | 3 ++-
|
||||
libparted/arch/linux.c | 7 +++++++
|
||||
parted/parted.c | 3 ++-
|
||||
3 files changed, 11 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/include/parted/device.in.h
|
||||
+++ b/include/parted/device.in.h
|
||||
@@ -51,7 +51,8 @@ typedef enum {
|
||||
PED_DEVICE_MD = 17,
|
||||
PED_DEVICE_LOOP = 18,
|
||||
PED_DEVICE_NVME = 19,
|
||||
- PED_DEVICE_RAM = 20
|
||||
+ PED_DEVICE_RAM = 20,
|
||||
+ PED_DEVICE_PMEM = 21
|
||||
} PedDeviceType;
|
||||
|
||||
typedef struct _PedDevice PedDevice;
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -724,6 +724,8 @@ _device_probe_type (PedDevice* dev)
|
||||
dev->type = PED_DEVICE_NVME;
|
||||
} else if (dev_major == RAM_MAJOR) {
|
||||
dev->type = PED_DEVICE_RAM;
|
||||
+ } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "pmem")) {
|
||||
+ dev->type = PED_DEVICE_PMEM;
|
||||
} else {
|
||||
dev->type = PED_DEVICE_UNKNOWN;
|
||||
}
|
||||
@@ -1497,6 +1499,11 @@ linux_new (const char* path)
|
||||
goto error_free_arch_specific;
|
||||
break;
|
||||
|
||||
+ case PED_DEVICE_PMEM:
|
||||
+ if (!init_generic (dev, _("NVDIMM Device")))
|
||||
+ goto error_free_arch_specific;
|
||||
+ break;
|
||||
+
|
||||
case PED_DEVICE_ATARAID:
|
||||
if (!init_generic (dev, _("ATARAID Controller")))
|
||||
goto error_free_arch_specific;
|
||||
--- a/parted/parted.c
|
||||
+++ b/parted/parted.c
|
||||
@@ -1045,7 +1045,8 @@ _print_disk_info (const PedDevice *dev,
|
||||
"cpqarray", "file", "ataraid", "i2o",
|
||||
"ubd", "dasd", "viodasd", "sx8", "dm",
|
||||
"xvd", "sd/mmc", "virtblk", "aoe",
|
||||
- "md", "loopback", "nvme", "brd"};
|
||||
+ "md", "loopback", "nvme", "brd",
|
||||
+ "pmem"};
|
||||
|
||||
char* start = ped_unit_format (dev, 0);
|
||||
PedUnit default_unit = ped_unit_get_default ();
|
30
libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
Normal file
30
libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Fri, 5 Jun 2015 14:40:00 -0700
|
||||
Subject: libparted: BLKPG_RESIZE_PARTITION uses bytes, not sectors
|
||||
References: bsc#1058667
|
||||
Patch-mainline: v3.3
|
||||
Git-commit: c6dc6e5d0f49a26242d2b28622514814a53d92e1
|
||||
|
||||
This results in the extended partition vanishing after adding another
|
||||
partition.
|
||||
|
||||
Resolves: rhbz#1135493
|
||||
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
---
|
||||
libparted/arch/linux.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -2640,7 +2640,10 @@ static int _blkpg_resize_partition (PedD
|
||||
if (walk->geom.start == part->geom.start+1)
|
||||
linux_part.length = 1;
|
||||
}
|
||||
- } else linux_part.length = 1;
|
||||
+ } else {
|
||||
+ linux_part.length = 1;
|
||||
+ }
|
||||
+ linux_part.length *= disk->dev->sector_size;
|
||||
}
|
||||
else
|
||||
linux_part.length = part->geom.length * disk->dev->sector_size;
|
17
libparted-fix-NVDIMM-partition-naming.patch
Normal file
17
libparted-fix-NVDIMM-partition-naming.patch
Normal file
@ -0,0 +1,17 @@
|
||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
||||
Date: Mon, 23 Oct 2017 17:47:47 +0200
|
||||
Subject: libparted: Fix NVDIMM partition naming
|
||||
References: bsc#1064446
|
||||
Patch-mainline: no, required to fix custom SUSE device naming
|
||||
|
||||
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -2437,6 +2437,7 @@ _device_get_part_path (PedDevice const *
|
||||
const char *p;
|
||||
if (dev->type == PED_DEVICE_CPQARRAY ||
|
||||
dev->type == PED_DEVICE_NVME ||
|
||||
+ dev->type == PED_DEVICE_PMEM ||
|
||||
dev->type == PED_DEVICE_SDMMC)
|
||||
p = "p";
|
||||
else if (dev->type == PED_DEVICE_DM)
|
67
libparted-fix-udev-cookie-leak.patch
Normal file
67
libparted-fix-udev-cookie-leak.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Thu, 25 May 2017 09:42:23 -0700
|
||||
Subject: libparted: Fix udev cookie leak in _dm_resize_partition
|
||||
References: bsc#1058667
|
||||
Patch-mainline: v3.3
|
||||
Git-commit: e7870afe3c13dcc77845d48409daa35e3e42b5fb
|
||||
|
||||
The function is setting udev cookies, but not using them when waiting
|
||||
for the task. This results in leaked cookies, which can eventually
|
||||
exhaust the available number of semaphores.
|
||||
|
||||
'dmsetup udevcookies' will show a cookie remaining afterwards, and 'ipcs -s'
|
||||
will show the semaphores in use.
|
||||
|
||||
Also simplified the exit so that the task is always destroyed and memory
|
||||
is all freed in the same path.
|
||||
|
||||
Resolves: rhbz#1455564
|
||||
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
---
|
||||
libparted/arch/linux.c | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/libparted/arch/linux.c
|
||||
+++ b/libparted/arch/linux.c
|
||||
@@ -2964,6 +2964,7 @@ _dm_resize_partition (PedDisk* disk, con
|
||||
char* vol_name = NULL;
|
||||
const char* dev_name = NULL;
|
||||
uint32_t cookie = 0;
|
||||
+ int rc = 0;
|
||||
|
||||
/* Get map name from devicemapper */
|
||||
struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
|
||||
@@ -3004,8 +3005,9 @@ _dm_resize_partition (PedDisk* disk, con
|
||||
/* device-mapper uses 512b units, not the device's sector size */
|
||||
dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT),
|
||||
"linear", params);
|
||||
- if (!dm_task_set_cookie (task, &cookie, 0))
|
||||
- goto err;
|
||||
+ /* NOTE: DM_DEVICE_RELOAD doesn't generate udev events, so no cookie is needed (it will freeze).
|
||||
+ * DM_DEVICE_RESUME does, so get a cookie and synchronize with udev.
|
||||
+ */
|
||||
if (dm_task_run (task)) {
|
||||
dm_task_destroy (task);
|
||||
task = dm_task_create (DM_DEVICE_RESUME);
|
||||
@@ -3014,10 +3016,8 @@ _dm_resize_partition (PedDisk* disk, con
|
||||
dm_task_set_name (task, vol_name);
|
||||
if (!dm_task_set_cookie (task, &cookie, 0))
|
||||
goto err;
|
||||
- if (dm_task_run (task)) {
|
||||
- free (params);
|
||||
- free (vol_name);
|
||||
- return 1;
|
||||
+ if (_dm_task_run_wait (task, cookie)) {
|
||||
+ rc = 1;
|
||||
}
|
||||
}
|
||||
err:
|
||||
@@ -3026,7 +3026,7 @@ err:
|
||||
dm_task_destroy (task);
|
||||
free (params);
|
||||
free (vol_name);
|
||||
- return 0;
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
#endif
|
77
parted-escape-printed-device-path.patch
Normal file
77
parted-escape-printed-device-path.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
||||
Date: Tue, 7 Nov 2017 20:14:06 +0100
|
||||
Subject: parted: Escape printed device path in machine mode
|
||||
References: bsc#1066467
|
||||
Patch-mainline: submitted, 2017-11-07
|
||||
|
||||
The function _print_disk_info() uses the colon ':' as the separator
|
||||
but the device path it prints can contain that character as well.
|
||||
In that case parsing fails.
|
||||
So introduce the function _escape_machine_string() to allocate an
|
||||
output string twice as big as the input string and escape ':' and
|
||||
'\' with a '\'. Print the escaped path and free it again. Ignore
|
||||
the NULL pointer dereference in out-of-memory situation like it
|
||||
is done for the other allocations in _print_disk_info() as well.
|
||||
|
||||
Resolves: bsc#1066467
|
||||
|
||||
Reported-by: Arvin Schnell <aschnell@suse.com>
|
||||
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
---
|
||||
parted/parted.c | 29 ++++++++++++++++++++++++++++-
|
||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/parted/parted.c
|
||||
+++ b/parted/parted.c
|
||||
@@ -1038,6 +1038,30 @@ _print_disk_geometry (const PedDevice *d
|
||||
free (cyl_size);
|
||||
}
|
||||
|
||||
+static char *
|
||||
+_escape_machine_string (const char *str)
|
||||
+{
|
||||
+ size_t i, j;
|
||||
+ char *dest;
|
||||
+
|
||||
+ dest = ped_malloc ((strlen(str) + 1) * 2);
|
||||
+ if (!dest)
|
||||
+ return NULL;
|
||||
+
|
||||
+ for (i = 0, j = 0; str[i] != '\0'; i++, j++) {
|
||||
+ switch (str[i]) {
|
||||
+ case ':':
|
||||
+ case '\\':
|
||||
+ dest[j++] = '\\';
|
||||
+ default:
|
||||
+ dest[j] = str[i];
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ dest[j] = '\0';
|
||||
+ return dest;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
_print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|
||||
{
|
||||
@@ -1058,6 +1082,8 @@ _print_disk_info (const PedDevice *dev,
|
||||
char *disk_flags = disk_print_flags (diskp);
|
||||
|
||||
if (opt_machine_mode) {
|
||||
+ char *path = _escape_machine_string (dev->path);
|
||||
+
|
||||
switch (default_unit) {
|
||||
case PED_UNIT_CHS: puts ("CHS;");
|
||||
break;
|
||||
@@ -1068,9 +1094,10 @@ _print_disk_info (const PedDevice *dev,
|
||||
|
||||
}
|
||||
printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
|
||||
- dev->path, end, transport[dev->type],
|
||||
+ path, end, transport[dev->type],
|
||||
dev->sector_size, dev->phys_sector_size,
|
||||
pt_name, dev->model, disk_flags);
|
||||
+ free(path);
|
||||
} else {
|
||||
printf (_("Model: %s (%s)\n"),
|
||||
dev->model, transport[dev->type]);
|
@ -1,3 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 13 17:17:40 CET 2017 - sparschauer@suse.de
|
||||
|
||||
- Escape printed device path in machine mode (bsc#1066467)
|
||||
- add: parted-escape-printed-device-path.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 23 18:18:36 CEST 2017 - sparschauer@suse.de
|
||||
|
||||
- Add support for NVDIMM devices (bsc#1064446)
|
||||
- add: libparted-Add-support-for-NVDIMM-devices.patch
|
||||
- add: libparted-fix-NVDIMM-partition-naming.patch)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 20 10:00:07 UTC 2017 - sparschauer@suse.de
|
||||
|
||||
- Prepare to fix the resizepart command (bsc#1058667)
|
||||
- add: libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
|
||||
- add: libparted-fix-udev-cookie-leak.patch
|
||||
- add: tests-check-extended-partition-length.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 13 13:54:45 UTC 2017 - sparschauer@suse.de
|
||||
|
||||
|
13
parted.spec
13
parted.spec
@ -78,6 +78,12 @@ Patch49: libparted-set-swap-flag-on-GPT-partitions.patch
|
||||
Patch50: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
|
||||
Patch51: parted-mkpart-allow-empty-gpt-part-name.patch
|
||||
Patch52: libparted-fix-starting-CHS-in-protective-MBR.patch
|
||||
Patch53: libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
|
||||
Patch54: libparted-fix-udev-cookie-leak.patch
|
||||
Patch55: libparted-Add-support-for-NVDIMM-devices.patch
|
||||
Patch56: libparted-fix-NVDIMM-partition-naming.patch
|
||||
Patch57: parted-escape-printed-device-path.patch
|
||||
# Fatresize
|
||||
Patch100: parted-fatresize-autoconf.patch
|
||||
# Upstream tests patches
|
||||
Patch150: tests-set-optimal-blocks-for-scsi_debug.patch
|
||||
@ -85,6 +91,7 @@ Patch151: tests-increase-scsi_debug-tmo.patch
|
||||
Patch152: tests-use-wait_for_dev_to_-functions.patch
|
||||
Patch153: tests-wait_for_-loop.patch
|
||||
Patch154: tests-update-t0220-t0280-for-swap-flag.patch
|
||||
Patch155: tests-check-extended-partition-length.patch
|
||||
# SUSE tests patches
|
||||
Patch200: tests-adapt-to-SUSE.patch
|
||||
BuildRequires: check-devel
|
||||
@ -178,12 +185,18 @@ to develop applications that require these.
|
||||
%patch50 -p1
|
||||
%patch51 -p1
|
||||
%patch52 -p1
|
||||
%patch53 -p1
|
||||
%patch54 -p1
|
||||
%patch55 -p1
|
||||
%patch56 -p1
|
||||
%patch57 -p1
|
||||
%patch100 -p1
|
||||
%patch150 -p1
|
||||
%patch151 -p1
|
||||
%patch152 -p1
|
||||
%patch153 -p1
|
||||
%patch154 -p1
|
||||
%patch155 -p1
|
||||
%patch200 -p1
|
||||
|
||||
%build
|
||||
|
84
tests-check-extended-partition-length.patch
Normal file
84
tests-check-extended-partition-length.patch
Normal file
@ -0,0 +1,84 @@
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Fri, 5 Jun 2015 13:46:29 -0700
|
||||
Subject: tests: Make sure the extended partition length is correct
|
||||
For: libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
|
||||
References: bsc#1058667
|
||||
Patch-mainline: v3.3
|
||||
Git-commit: 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9
|
||||
|
||||
parted tells the kernel the wrong length when reporting a resize of an
|
||||
extended partition. Make sure the length is 2 for 512b sectors and 1
|
||||
sector for larger.
|
||||
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||
---
|
||||
tests/Makefile.am | 1 +
|
||||
tests/t2320-dos-extended-noclobber.sh | 48 +++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 49 insertions(+)
|
||||
create mode 100644 tests/t2320-dos-extended-noclobber.sh
|
||||
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index ce8391d..001b9de 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -47,6 +47,7 @@ TESTS = \
|
||||
t2201-pc98-label-recog.sh \
|
||||
t2300-dos-label-extended-bootcode.sh \
|
||||
t2310-dos-extended-2-sector-min-offset.sh \
|
||||
+ t2320-dos-extended-noclobber.sh \
|
||||
t2400-dos-hfs-partition-type.sh \
|
||||
t2500-probe-corrupt-hfs.sh \
|
||||
t3000-resize-fs.sh \
|
||||
diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh
|
||||
new file mode 100644
|
||||
index 0000000..6f3dfff
|
||||
--- /dev/null
|
||||
+++ b/tests/t2320-dos-extended-noclobber.sh
|
||||
@@ -0,0 +1,48 @@
|
||||
+#!/bin/sh
|
||||
+# Ensure that the extended partition reports the correct length
|
||||
+# after adding another partition.
|
||||
+
|
||||
+# Copyright (C) 2015 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
|
||||
+
|
||||
+require_root_
|
||||
+require_scsi_debug_module_
|
||||
+
|
||||
+# create memory-backed device
|
||||
+ss=$sector_size_
|
||||
+scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
|
||||
+ skip_ 'failed to create scsi_debug device'
|
||||
+scsi_dev=$(cat dev-name)
|
||||
+
|
||||
+# Create a DOS label with an extended partition and a primary partition
|
||||
+parted -s $scsi_dev mklabel msdos || fail=1
|
||||
+parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1
|
||||
+parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1
|
||||
+
|
||||
+# Make sure the size of the extended partition is correct.
|
||||
+# 2 sectors for 512b and 1 sector for larger. /sys/.../size is in
|
||||
+# 512b blocks so convert accordingly.
|
||||
+dev=${scsi_dev#/dev/}
|
||||
+ext_len=$(cat /sys/block/$dev/${dev}1/size)
|
||||
+if [ $ss -eq 512 ]; then
|
||||
+ expected_len=2
|
||||
+else
|
||||
+ expected_len=$((ss / 512))
|
||||
+fi
|
||||
+[ $ext_len -eq $expected_len ] || fail=1
|
||||
+
|
||||
+Exit $fail
|
Loading…
x
Reference in New Issue
Block a user