Accepting request 763641 from Base:System

OBS-URL: https://build.opensuse.org/request/show/763641
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/parted?expand=0&rev=129
This commit is contained in:
Dominique Leuenberger 2020-01-15 15:08:41 +00:00 committed by Git OBS Bridge
commit bb77e380af
71 changed files with 486 additions and 4179 deletions

View File

@ -1,276 +0,0 @@
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Date: Thu, 17 Sep 2015 15:33:28 +0200
Subject: fdasd: geometry handling updated from upstream s390-tools
References: fate#320525 / bsc#935127
Patch-mainline: v3.3
Git-commit: 4d480d980a9b69b432b8d60df3c4397ba8cdc965
Remove the necessity for DASD-specific ioctls for partition handling.
This allows to correctly handle DASD-backed virtio block devices.
Note that this is necessary because virtio is just the transport.
A DASD, even if provided via virtio, still has it's unique
characteristics, which means that only traditional DASD partition
table formats can be used (no MBR, GPT, or similar).
Use bzero for initialization to make sure all struct members are
properly cleared. Also changed partition list handling code to be
more similar to upstream s390-tools fdasd.
Further, enhanced error handling capabilities by providing a
return code by fdasd_get_geometry.
Code is largely backported from s390-tools project.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Acked-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/fdasd.in.h | 4 +-
libparted/labels/fdasd.c | 166 ++++++++++++++++++++++++++++++++--------------
2 files changed, 119 insertions(+), 51 deletions(-)
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -190,6 +190,8 @@ typedef struct format_data_t {
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
+/* device size in bytes (u64 *arg)*/
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device geometry */
#define HDIO_GETGEO 0x0301
@@ -285,7 +287,7 @@ enum fdasd_failure {
void fdasd_cleanup (fdasd_anchor_t *anchor);
void fdasd_initialize_anchor (fdasd_anchor_t * anc);
-void fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd);
+int fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd);
void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -210,27 +210,7 @@ fdasd_initialize_anchor (fdasd_anchor_t
partition_info_t *p = NULL;
partition_info_t *q = NULL;
- anc->devno = 0;
- anc->dev_type = 0;
- anc->used_partitions = 0;
-
- anc->silent = 0;
- anc->verbose = 0;
- anc->big_disk = 0;
- anc->volid_specified = 0;
- anc->config_specified = 0;
- anc->auto_partition = 0;
- anc->devname_specified = 0;
- anc->print_table = 0;
-
- anc->option_reuse = 0;
- anc->option_recreate = 0;
-
- anc->vlabel_changed = 0;
- anc->vtoc_changed = 0;
- anc->blksize = 0;
- anc->fspace_trk = 0;
- anc->label_pos = 0;
+ bzero(anc, sizeof(fdasd_anchor_t));
for (i=0; i<USABLE_PARTITIONS; i++)
setpos(anc, i, -1);
@@ -272,24 +252,18 @@ fdasd_initialize_anchor (fdasd_anchor_t
if (p == NULL)
fdasd_error(anc, malloc_failed,
_("No room for partition info."));
- p->used = 0x00;
- p->len_trk = 0;
- p->start_trk = 0;
- p->fspace_trk = 0;
- p->type = 0;
+ bzero(p, sizeof(partition_info_t));
/* add p to double pointered list */
if (i == 1) {
- anc->first = p;
- p->prev = NULL;
+ anc->first = p;
} else if (i == USABLE_PARTITIONS) {
- anc->last = p;
- p->next = NULL;
+ anc->last = p;
p->prev = q;
q->next = p;
} else {
- p->prev = q;
- q->next = p;
+ p->prev = q;
+ q->next = p;
}
p->f1 = malloc(sizeof(format1_label_t));
@@ -947,15 +921,77 @@ fdasd_check_api_version (fdasd_anchor_t
}
/*
+ * The following two functions match those in the DASD ECKD device driver.
+ * They are used to compute how many records of a given size can be stored
+ * in one track.
+ */
+static unsigned int ceil_quot(unsigned int d1, unsigned int d2)
+{
+ return (d1 + (d2 - 1)) / d2;
+}
+
+/* kl: key length, dl: data length */
+static unsigned int recs_per_track(unsigned short dev_type, unsigned int kl,
+ unsigned int dl)
+{
+ unsigned int dn, kn;
+
+ switch (dev_type) {
+ case DASD_3380_TYPE:
+ if (kl)
+ return 1499 / (15 + 7 + ceil_quot(kl + 12, 32) +
+ ceil_quot(dl + 12, 32));
+ else
+ return 1499 / (15 + ceil_quot(dl + 12, 32));
+ case DASD_3390_TYPE:
+ dn = ceil_quot(dl + 6, 232) + 1;
+ if (kl) {
+ kn = ceil_quot(kl + 6, 232) + 1;
+ return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
+ 9 + ceil_quot(dl + 6 * dn, 34));
+ } else
+ return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
+ case DASD_9345_TYPE:
+ dn = ceil_quot(dl + 6, 232) + 1;
+ if (kl) {
+ kn = ceil_quot(kl + 6, 232) + 1;
+ return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
+ ceil_quot(dl + 6 * dn, 34));
+ } else
+ return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
+ }
+ return 0;
+}
+
+/*
+ * Verify that number of tracks (heads) per cylinder and number of
+ * sectors per track match the expected values for a given device type
+ * and block size.
+ * Returns 1 for a valid match and 0 otherwise.
+ */
+static int fdasd_verify_geometry(unsigned short dev_type, int blksize,
+ struct fdasd_hd_geometry *geometry)
+{
+ unsigned int expected_sectors;
+ if (geometry->heads != 15)
+ return 0;
+ expected_sectors = recs_per_track(dev_type, 0, blksize);
+ if (geometry->sectors == expected_sectors)
+ return 1;
+ return 0;
+}
+
+/*
* reads dasd geometry data
*/
-void
+int
fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
{
PDEBUG
int blksize = 0;
dasd_information_t dasd_info;
struct dasd_eckd_characteristics *characteristics;
+ unsigned long long size_in_bytes;
/* We can't get geometry from a regular file,
so simulate something usable, for the sake of testing. */
@@ -979,6 +1015,12 @@ fdasd_get_geometry (const PedDevice *dev
anc->geo.heads;
anc->is_file = 1;
} else {
+ if (ioctl(f, BLKGETSIZE64, &size_in_bytes) != 0) {
+ fdasd_error(anc, unable_to_ioctl,
+ _("Could not retrieve disk size."));
+ goto error;
+ }
+
if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fdasd_error(anc, unable_to_ioctl,
_("Could not retrieve disk geometry information."));
@@ -988,27 +1030,51 @@ fdasd_get_geometry (const PedDevice *dev
_("Could not retrieve blocksize information."));
/* get disk type */
- if (ioctl(f, BIODASDINFO, &dasd_info) != 0)
- fdasd_error(anc, unable_to_ioctl,
- _("Could not retrieve disk information."));
-
- characteristics = (struct dasd_eckd_characteristics *)
- &dasd_info.characteristics;
- if (characteristics->no_cyl == LV_COMPAT_CYL &&
- characteristics->long_no_cyl)
- anc->hw_cylinders = characteristics->long_no_cyl;
- else
- anc->hw_cylinders = characteristics->no_cyl;
+ if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {
+ /* verify that the geometry matches a 3390 DASD */
+ if (!fdasd_verify_geometry(DASD_3390_TYPE, blksize,
+ &anc->geo)) {
+ fdasd_error(anc, wrong_disk_type,
+ _("Disk geometry does not match a " \
+ "DASD device of type 3390."));
+ goto error;
+ }
+ anc->dev_type = DASD_3390_TYPE;
+ anc->hw_cylinders =
+ size_in_bytes / (blksize * anc->geo.heads * anc->geo.sectors);
+ /* The VOL1 label on a CDL formatted ECKD DASD is in block 2
+ * It will be verified later, if this position actually holds a
+ * valid label record.
+ */
+ anc->label_pos = 2 * blksize;
+ /* A devno 0 is actually a valid devno, which could exist
+ * in the system. Since we use this number only to create
+ * a default volume serial, there is no serious conflict.
+ */
+ anc->devno = 0;
+ } else {
+ characteristics = (struct dasd_eckd_characteristics *)
+ &dasd_info.characteristics;
+ if (characteristics->no_cyl == LV_COMPAT_CYL &&
+ characteristics->long_no_cyl)
+ anc->hw_cylinders = characteristics->long_no_cyl;
+ else
+ anc->hw_cylinders = characteristics->no_cyl;
+ anc->dev_type = dasd_info.dev_type;
+ anc->label_pos = dasd_info.label_block * blksize;
+ anc->devno = dasd_info.devno;
+ anc->label_block = dasd_info.label_block;
+ anc->FBA_layout = dasd_info.FBA_layout;
+ }
anc->is_file = 0;
}
- anc->dev_type = dasd_info.dev_type;
- anc->blksize = blksize;
- anc->label_pos = dasd_info.label_block * blksize;
- anc->devno = dasd_info.devno;
- anc->label_block = dasd_info.label_block;
- anc->FBA_layout = dasd_info.FBA_layout;
+ anc->blksize = blksize;
+ return 1;
+
+ error:
+ return 0;
}
/*

View File

@ -1,213 +0,0 @@
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Date: Thu, 17 Sep 2015 15:33:29 +0200
Subject: dasd: enhance device probing
References: fate#320525 / bsc#935127
Patch-mainline: v3.3
Git-commit: 834713b5aee1edc004f863231dd489ee3a79f536
Probe for all device/transport types as every block device
could be a DASD on s390.
Since the calculation of the minimum and optimum alignment
is different between DASDs and common fixed block disks
we need a means other than dev->type == PED_DEVICE_DASD.
For that purpose a static function _ped_device_like_dasd()
offering a DASD detection heuristic has been added to
arch/linux.c.
By always providing arch-specific alignment functions the
need for DASD-specific code could be removed from device.c.
Observe fdasd_get_geometry return code for proper error
handling.
Remove the obsolete API check as we no longer require the
DASD-specific IOCTLs.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Acked-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 72 ++++++++++++++++++++++++++++++++++++++++++------
libparted/device.c | 14 ++-------
libparted/labels/dasd.c | 18 +++++-------
3 files changed, 76 insertions(+), 28 deletions(-)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -814,9 +814,13 @@ _device_set_sector_size (PedDevice* dev)
#endif
#if defined __s390__ || defined __s390x__
+ /* The real_sector_size is currently needed for DASD layouts,
+ * so we set it unconditionally. In the long run it should
+ * be considered to use the dev->phys_sector_size in label/dasd.c.
+ */
+ arch_specific->real_sector_size = dev->sector_size;
/* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */
if (dev->type == PED_DEVICE_DASD) {
- arch_specific->real_sector_size = dev->sector_size;
dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
}
#endif
@@ -3259,6 +3263,60 @@ linux_disk_commit (PedDisk* disk)
return 1;
}
+#if defined __s390__ || defined __s390x__
+/**
+ * Check whether this device could be a DASD
+ *
+ * The device probing yields PED_DEVICE_DASD for native DASD transport
+ * If the block device uses a different transport (e.g. virtio)
+ * a simplified heuristic (assuming a model 3390 with 4K sectors)
+ * is applied (only) on s390x systems for this check.
+ *
+ * \return 1 if the geometry indicates this could be a DASD
+ * and 0 otherwise
+ */
+static int
+_ped_device_like_dasd(const PedDevice *dev)
+{
+ return (dev->type == PED_DEVICE_DASD)
+ || (dev->hw_geom.heads == 15
+ && dev->hw_geom.sectors == 12
+ && (dev->hw_geom.cylinders
+ * dev->hw_geom.heads
+ * dev->hw_geom.sectors
+ * dev->phys_sector_size
+ == dev->length * dev->sector_size));
+}
+
+
+
+static PedAlignment*
+s390_get_minimum_alignment(const PedDevice *dev)
+{
+#if USE_BLKID
+ return linux_get_minimum_alignment(dev);
+#else
+ return ped_alignment_new(0,
+ dev->phys_sector_size
+ / dev->sector_size);
+#endif
+}
+
+static PedAlignment*
+s390_get_optimum_alignment(const PedDevice *dev)
+{
+ /* DASD needs to use minimum alignment */
+ if (_ped_device_like_dasd(dev))
+ return s390_get_minimum_alignment(dev);
+#if USE_BLKID
+ return linux_get_optimum_alignment(dev);
+#else
+ return NULL;
+#endif
+}
+#endif
+
+
#if USE_BLKID
static PedAlignment*
linux_get_minimum_alignment(const PedDevice *dev)
@@ -3299,15 +3357,10 @@ linux_get_optimum_alignment(const PedDev
&& PED_DEFAULT_ALIGNMENT % optimal_io == 0)
|| (!optimal_io && minimum_io
&& PED_DEFAULT_ALIGNMENT % minimum_io == 0)
- ) {
- /* DASD needs to use minimum alignment */
- if (dev->type == PED_DEVICE_DASD)
- return linux_get_minimum_alignment(dev);
-
+ )
return ped_alignment_new(
blkid_topology_get_alignment_offset(tp) / dev->sector_size,
PED_DEFAULT_ALIGNMENT / dev->sector_size);
- }
/* If optimal_io_size is 0 and we don't meet the other criteria
for using the device.c default, return the minimum alignment. */
@@ -3372,7 +3425,10 @@ static PedDeviceArchOps linux_dev_ops =
sync: linux_sync,
sync_fast: linux_sync_fast,
probe_all: linux_probe_all,
-#if USE_BLKID
+#if defined __s390__ || defined __s390x__
+ get_minimum_alignment: s390_get_minimum_alignment,
+ get_optimum_alignment: s390_get_optimum_alignment,
+#elif USE_BLKID
get_minimum_alignment: linux_get_minimum_alignment,
get_optimum_alignment: linux_get_optimum_alignment,
#endif
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -550,16 +550,10 @@ ped_device_get_optimum_alignment(const P
/* If the arch specific code could not give as an alignment
return a default value based on the type of device. */
if (align == NULL) {
- switch (dev->type) {
- case PED_DEVICE_DASD:
- align = ped_device_get_minimum_alignment(dev);
- break;
- default:
- /* Align to a grain of 1MiB (like vista / win7) */
- align = ped_alignment_new(0,
- (PED_DEFAULT_ALIGNMENT
- / dev->sector_size));
- }
+ /* Align to a grain of 1MiB (like vista / win7) */
+ align = ped_alignment_new(0,
+ (PED_DEFAULT_ALIGNMENT
+ / dev->sector_size));
}
return align;
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -224,19 +224,13 @@ dasd_probe (const PedDevice *dev)
PED_ASSERT(dev != NULL);
- if (!(dev->type == PED_DEVICE_DASD
- || dev->type == PED_DEVICE_VIODASD
- || dev->type == PED_DEVICE_FILE))
- return 0;
-
arch_specific = LINUX_SPECIFIC(dev);
/* add partition test here */
fdasd_initialize_anchor(&anchor);
- fdasd_get_geometry(dev, &anchor, arch_specific->fd);
-
- fdasd_check_api_version(&anchor, arch_specific->fd);
+ if (fdasd_get_geometry(dev, &anchor, arch_specific->fd) == 0)
+ goto error_cleanup;
/* Labels are required on CDL formatted DASDs. */
if (fdasd_check_volume(&anchor, arch_specific->fd) &&
@@ -286,7 +280,9 @@ dasd_read (PedDisk* disk)
fdasd_initialize_anchor(&anchor);
- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
+ if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)
+ goto error_close_dev;
+
disk_specific->label_block = anchor.label_block;
if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
@@ -645,7 +641,9 @@ dasd_write (const PedDisk* disk)
/* initialize the anchor */
fdasd_initialize_anchor(&anchor);
- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
+ if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)
+ goto error;
+
fdasd_check_volume(&anchor, arch_specific->fd);
memcpy(anchor.vlabel, &disk_specific->vlabel, sizeof(volume_label_t));
anchor.vlabel_changed++;

View File

@ -1,142 +0,0 @@
From: Colin Watson <cjwatson@ubuntu.com>
Date: Thu, 29 Oct 2015 21:12:01 +0100
Subject: parted: fix build error on s390
References: fate#320525 / bsc#935127
Patch-mainline: v3.3
Git-commit: 388bab890a4e09b09d2428c0e773ed083295f91b
The preceding dasd probing patches have introduced a compile error
when building with blkid support. Fixed by reordering function
definitions.
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 107 ++++++++++++++++++++++++-------------------------
1 file changed, 54 insertions(+), 53 deletions(-)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -3263,59 +3263,6 @@ linux_disk_commit (PedDisk* disk)
return 1;
}
-#if defined __s390__ || defined __s390x__
-/**
- * Check whether this device could be a DASD
- *
- * The device probing yields PED_DEVICE_DASD for native DASD transport
- * If the block device uses a different transport (e.g. virtio)
- * a simplified heuristic (assuming a model 3390 with 4K sectors)
- * is applied (only) on s390x systems for this check.
- *
- * \return 1 if the geometry indicates this could be a DASD
- * and 0 otherwise
- */
-static int
-_ped_device_like_dasd(const PedDevice *dev)
-{
- return (dev->type == PED_DEVICE_DASD)
- || (dev->hw_geom.heads == 15
- && dev->hw_geom.sectors == 12
- && (dev->hw_geom.cylinders
- * dev->hw_geom.heads
- * dev->hw_geom.sectors
- * dev->phys_sector_size
- == dev->length * dev->sector_size));
-}
-
-
-
-static PedAlignment*
-s390_get_minimum_alignment(const PedDevice *dev)
-{
-#if USE_BLKID
- return linux_get_minimum_alignment(dev);
-#else
- return ped_alignment_new(0,
- dev->phys_sector_size
- / dev->sector_size);
-#endif
-}
-
-static PedAlignment*
-s390_get_optimum_alignment(const PedDevice *dev)
-{
- /* DASD needs to use minimum alignment */
- if (_ped_device_like_dasd(dev))
- return s390_get_minimum_alignment(dev);
-#if USE_BLKID
- return linux_get_optimum_alignment(dev);
-#else
- return NULL;
-#endif
-}
-#endif
-
#if USE_BLKID
static PedAlignment*
@@ -3411,6 +3358,60 @@ error:
}
#endif
+#if defined __s390__ || defined __s390x__
+/**
+ * Check whether this device could be a DASD
+ *
+ * The device probing yields PED_DEVICE_DASD for native DASD transport
+ * If the block device uses a different transport (e.g. virtio)
+ * a simplified heuristic (assuming a model 3390 with 4K sectors)
+ * is applied (only) on s390x systems for this check.
+ *
+ * \return 1 if the geometry indicates this could be a DASD
+ * and 0 otherwise
+ */
+static int
+_ped_device_like_dasd(const PedDevice *dev)
+{
+ return (dev->type == PED_DEVICE_DASD)
+ || (dev->hw_geom.heads == 15
+ && dev->hw_geom.sectors == 12
+ && (dev->hw_geom.cylinders
+ * dev->hw_geom.heads
+ * dev->hw_geom.sectors
+ * dev->phys_sector_size
+ == dev->length * dev->sector_size));
+}
+
+
+
+static PedAlignment*
+s390_get_minimum_alignment(const PedDevice *dev)
+{
+#if USE_BLKID
+ return linux_get_minimum_alignment(dev);
+#else
+ return ped_alignment_new(0,
+ dev->phys_sector_size
+ / dev->sector_size);
+#endif
+}
+
+static PedAlignment*
+s390_get_optimum_alignment(const PedDevice *dev)
+{
+ /* DASD needs to use minimum alignment */
+ if (_ped_device_like_dasd(dev))
+ return s390_get_minimum_alignment(dev);
+#if USE_BLKID
+ return linux_get_optimum_alignment(dev);
+#else
+ return NULL;
+#endif
+}
+#endif
+
+
static PedDeviceArchOps linux_dev_ops = {
_new: linux_new,
destroy: linux_destroy,

View File

@ -1,46 +0,0 @@
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Date: Fri, 5 Feb 2016 14:47:11 +0100
Subject: fdasd.c: Safeguard against geometry misprobing
References: fate#320525 / bsc#935127
Patch-mainline: v3.3
Git-commit: 8c6de55e4375bd63ae0d0dc7dd7104a7c2290cac
Fixes an issue with parted print being run against a logical
volume realised by extents on a physical volume residing on
a DASD.
We must make sure that geometry, device blocksize and DASD
attributes are present before we start format verifications
If any of it is missing this is not a DASD.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/fdasd.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -1021,13 +1021,20 @@ fdasd_get_geometry (const PedDevice *dev
goto error;
}
- if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
+ if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0 ||
+ anc->geo.heads == 0 ||
+ anc->geo.sectors == 0 ||
+ anc->geo.cylinders == 0 ) {
fdasd_error(anc, unable_to_ioctl,
_("Could not retrieve disk geometry information."));
+ goto error;
+ }
- if (ioctl(f, BLKSSZGET, &blksize) != 0)
+ if (ioctl(f, BLKSSZGET, &blksize) != 0) {
fdasd_error(anc, unable_to_ioctl,
_("Could not retrieve blocksize information."));
+ goto error;
+ }
/* get disk type */
if (ioctl(f, BIODASDINFO, &dasd_info) != 0) {

View File

@ -1,46 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 11 Apr 2016 15:10:51 -0700
Subject: libparted: Remove fdasd geometry code from alloc_metadata
(#1244833)
References: fate#320525 / bsc#935127
Patch-mainline: v3.3
Git-commit: c58f816ffbc0bc4eacfb57d492cbe3b7497ede9f
commit db20944f changed how the trailing_metadata_end is calculated in
dasd_alloc_metadata, removing the need for setting up the anchor struct.
But dasd_alloc_metadata can be called in various contexts, and the
arch_specific->fd may or may not be valid during these calls. This can
result in unpredictable crashes when it uses a stale fd and tries to run
the file image code in fdasd_get_geometry instead of the device code.
The solution is to just drop the unneeded code, and to remember that
arch_specific->fd should only be used when ped_device_open has first
been called.
Resolves: rhbz#1244833
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/dasd.c | 4 ----
1 file changed, 4 deletions(-)
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -998,7 +998,6 @@ dasd_alloc_metadata (PedDisk* disk)
PedPartition* part = NULL; /* initialize solely to placate gcc */
PedPartition* new_part2;
PedSector trailing_meta_start, trailing_meta_end;
- struct fdasd_anchor anchor;
PED_ASSERT (disk != NULL);
PED_ASSERT (disk->dev != NULL);
@@ -1048,10 +1047,7 @@ dasd_alloc_metadata (PedDisk* disk)
backed up, then restored to a larger size disk, etc.
*/
trailing_meta_start = part->geom.end + 1;
- fdasd_initialize_anchor(&anchor);
- fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
trailing_meta_end = (long long) disk->dev->length - 1;
- fdasd_cleanup(&anchor);
if (trailing_meta_end >= trailing_meta_start) {
new_part2 = ped_partition_new (disk,PED_PARTITION_METADATA,
NULL, trailing_meta_start, trailing_meta_end);

View File

@ -1,83 +0,0 @@
From 5a61f15b7003cba73e6517ac22204bafd9a3cb8e Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 23 Dec 2016 06:53:38 +0100
Subject: [PATCH] clean the disk information when commands fail in interactive
mode.
parted always reads disk information to memory before any
operations. The disk that user operates is actually
a copy of real one in memory. When the information in memory
is changed, it will commit the memory to device to update the
disk information.
Once the disk information is read, parted will never re-read it
again unless another device is loaded or the device is re-read.
Above work has been done in commit 7eac058 (parted: don't reload
partition table on every command)
Each command of parted always commits the memory when it succeeds.
Then the disk information on device and in memory are the same.
But when it fails, they might be different. User will be confused
by this, and sometimes get undesired result with the contaminated
memory. This memory should be cleaned if some command fails.
Then the command followed will re-read the disk.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/parted.c | 14 ++++++++++----
parted/ui.c | 8 +++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -1501,8 +1501,12 @@ _rescue_add_partition (PedPartition* par
default: break;
}
- ped_partition_set_system (part, fs_type);
- ped_disk_commit (part->disk);
+ if (!ped_partition_set_system (part, fs_type))
+ return 0;
+
+ if (!ped_disk_commit (part->disk))
+ return 0;
+
return 1;
}
@@ -1727,8 +1731,10 @@ do_rm (PedDevice** dev, PedDisk** diskp)
if (!_partition_warn_busy (part, danger_if_busy))
goto error;
- ped_disk_delete_partition (*diskp, part);
- ped_disk_commit (*diskp);
+ if (!ped_disk_delete_partition (*diskp, part))
+ goto error;
+ if (!ped_disk_commit (*diskp))
+ goto error;
if ((*dev)->type != PED_DEVICE_FILE)
disk_is_modified = 1;
Index: parted-3.2/parted/ui.c
===================================================================
--- parted-3.2.orig/parted/ui.c
+++ parted-3.2/parted/ui.c
@@ -1614,8 +1614,14 @@ interactive_mode (PedDevice** dev, PedDi
cmd = command_get (commands, word);
free (word);
if (cmd) {
- if (!command_run (cmd, dev, disk))
+ if (!command_run (cmd, dev, disk)) {
command_line_flush ();
+
+ if (*disk) {
+ ped_disk_destroy (*disk);
+ *disk = 0;
+ }
+ }
} else
print_commands_help ();
}

View File

@ -5,11 +5,11 @@ Patch-mainline: no, custom SUSE patch
libparted/labels/dos.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: parted-3.2/libparted/labels/dos.c
Index: parted-3.3/libparted/labels/dos.c
===================================================================
--- parted-3.2.orig/libparted/labels/dos.c
+++ parted-3.2/libparted/labels/dos.c
@@ -1285,6 +1285,12 @@ msdos_write (const PedDisk* disk)
--- parted-3.3.orig/libparted/labels/dos.c
+++ parted-3.3/libparted/labels/dos.c
@@ -1287,6 +1287,12 @@ msdos_write (const PedDisk* disk)
return 0;
DosRawTable *table = (DosRawTable *) s0;
@ -22,7 +22,7 @@ Index: parted-3.2/libparted/labels/dos.c
/* either no bootrecord at all, or AIX IPL signature ... */
if ( (!table->boot_code[0]) ||
( table->boot_code[0] == (char) 0xc9 &&
@@ -1295,6 +1301,7 @@ msdos_write (const PedDisk* disk)
@@ -1297,6 +1303,7 @@ msdos_write (const PedDisk* disk)
memset (table->boot_code, 0, 512);
memcpy (table->boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
}

View File

@ -2,11 +2,11 @@
libparted/labels/mac.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: parted-3.2/libparted/labels/mac.c
Index: parted-3.3/libparted/labels/mac.c
===================================================================
--- parted-3.2.orig/libparted/labels/mac.c
+++ parted-3.2/libparted/labels/mac.c
@@ -467,7 +467,7 @@ _rawpart_is_void (MacRawPartition* raw_p
--- parted-3.3.orig/libparted/labels/mac.c
+++ parted-3.3/libparted/labels/mac.c
@@ -468,7 +468,7 @@ _rawpart_is_void (MacRawPartition* raw_p
return _rawpart_cmp_type (raw_part, "Apple_Void");
}
@ -15,7 +15,7 @@ Index: parted-3.2/libparted/labels/mac.c
* doesn't represent a partition at all. NOTE: some people make Apple_Free
* partitions with MacOS, because they can't select another type. So, if the
* name is anything other than "Extra" or "", it is treated as a "real"
@@ -530,6 +530,13 @@ _rawpart_analyse (MacRawPartition* raw_p
@@ -531,6 +531,13 @@ _rawpart_analyse (MacRawPartition* raw_p
if (!part)
goto error;

View File

@ -1,67 +0,0 @@
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
Date: Sun, 28 Sep 2014 16:15:48 +0100
Subject: lib-fs-resize: Prevent crash resizing FAT16 file systems
Patch-mainline: v3.3
Git-commit: 1e9e770f4bc7f3d80e09ecd1df58575fad064163
Resizing FAT16 file system crashes in libparted/fs/r/fat/resize.c
create_resize_context() because it was dereferencing NULL pointer
fs_info->info_sector to copy the info_sector.
Only FAT32 file systems have info_sector populated by fat_open() ->
fat_info_sector_read(). FAT12 and FAT16 file systems don't have an
info_sector so pointer fs_info->info_sector remains assigned NULL from
fat_alloc(). When resizing a FAT file system create_resize_context()
was always dereferencing fs_info->info_sector to memory copy the
info_sector, hence it crashed for FAT12 and FAT16.
Make create_resize_context() only copy the info_sector for FAT32 file
systems.
Reported by Christian Hesse in
https://bugzilla.gnome.org/show_bug.cgi?id=735669
---
NEWS | 4 ++++
libparted/fs/r/fat/resize.c | 12 +++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
Index: parted-3.2/NEWS
===================================================================
--- parted-3.2.orig/NEWS
+++ parted-3.2/NEWS
@@ -160,6 +160,10 @@ GNU parted NEWS
System partitions) or "msftres" (which sets the "Microsoft Reserved" type
code).
+** Bug Fixes
+
+ libparted-fs-resize: Prevent crash resizing FAT16 file systems.
+
* Noteworthy changes in release 3.1 (2012-03-02) [stable]
Index: parted-3.2/libparted/fs/r/fat/resize.c
===================================================================
--- parted-3.2.orig/libparted/fs/r/fat/resize.c
+++ parted-3.2/libparted/fs/r/fat/resize.c
@@ -668,11 +668,17 @@ create_resize_context (PedFileSystem* fs
/* preserve boot code, etc. */
new_fs_info->boot_sector = ped_malloc (new_geom->dev->sector_size);
- new_fs_info->info_sector = ped_malloc (new_geom->dev->sector_size);
memcpy (new_fs_info->boot_sector, fs_info->boot_sector,
new_geom->dev->sector_size);
- memcpy (new_fs_info->info_sector, fs_info->info_sector,
- new_geom->dev->sector_size);
+ new_fs_info->info_sector = NULL;
+ if (fs_info->fat_type == FAT_TYPE_FAT32)
+ {
+ PED_ASSERT (fs_info->info_sector != NULL);
+ new_fs_info->info_sector =
+ ped_malloc (new_geom->dev->sector_size);
+ memcpy (new_fs_info->info_sector, fs_info->info_sector,
+ new_geom->dev->sector_size);
+ }
new_fs_info->logical_sector_size = fs_info->logical_sector_size;
new_fs_info->sector_count = new_geom->length;

View File

@ -1,44 +0,0 @@
From 1545d6d4db29fa20f0c611786a094521e8974d4a Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:12 +0100
Subject: [PATCH] libpartd/dasd: improve flag processing for DASD-LDL
DASD-LDL does not support flag now, so all the flags are
unavailable to it.
Signed-off-by: Andre Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/labels/dasd.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: parted-3.2/libparted/labels/dasd.c
===================================================================
--- parted-3.2.orig/libparted/labels/dasd.c
+++ parted-3.2/libparted/labels/dasd.c
@@ -788,10 +788,24 @@ dasd_partition_get_flag (const PedPartit
}
}
+/*
+ * The DASD-LDL does not support flags now.
+ * So just return 0.
+*/
static int
dasd_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag)
{
+ DasdDiskSpecific* disk_specific;
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk != NULL);
+ PED_ASSERT (part->disk->disk_specific != NULL);
+
+ disk_specific = part->disk->disk_specific;
+
+ if (disk_specific->format_type == 1)
+ return 0;
+
switch (flag) {
case PED_PARTITION_SWAP:
return 1;

View File

@ -1,75 +0,0 @@
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: v3.3
Git-commit: 71885c5f493f3a5d950adbb3e8d17eff7e023053
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 ();

View File

@ -1,101 +0,0 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Tue, 14 Jun 2016 10:41:18 +0200
Subject: Add support for NVMe devices
References: bsc#982169
Patch-mainline: v3.3
Git-commit: e4ae4330f3e33201aeeed3b7ca88e15d98d03e13
Recognize NVMe Devices, so "parted -s /dev/nvme0n1" now prints
"NVMe Device (nvme)" instead of "Model: Unknown (unknown)".
In order for a device to be recognized as NVMe, it has to
have a 'blkext' major number. But since this major can be
used also by other device types, we also check the device
path contains 'nvme' as a substring.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_NVME
* libparted/arch/linux.c(BLKEXT_MAJOR): New define.
* libparted/arch/linux.c(_is_blkext_major): New function.
* libparted/arch/linux.c(_device_probe_type): Recognize NVMe devices.
* libparted/arch/linux.c(linux_new): Handle NVMe devices.
* parted/parted.c(do_print): Add "nvme" to list of transports.
---
include/parted/device.in.h | 3 ++-
libparted/arch/linux.c | 14 ++++++++++++++
parted/parted.c | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
Index: parted-3.2/include/parted/device.in.h
===================================================================
--- parted-3.2.orig/include/parted/device.in.h
+++ parted-3.2/include/parted/device.in.h
@@ -49,7 +49,8 @@ typedef enum {
PED_DEVICE_VIRTBLK = 15,
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
- PED_DEVICE_LOOP = 18
+ PED_DEVICE_LOOP = 18,
+ PED_DEVICE_NVME = 19
} PedDeviceType;
typedef struct _PedDevice PedDevice;
Index: parted-3.2/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -279,6 +279,7 @@ struct blkdev_ioctl_param {
#define SDMMC_MAJOR 179
#define LOOP_MAJOR 7
#define MD_MAJOR 9
+#define BLKEXT_MAJOR 259
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -461,6 +462,12 @@ _ensure_read_write (PedDevice *dev)
return;
}
+static int
+_is_blkext_major (int major)
+{
+ return _major_type_in_devices (major, "blkext");
+}
+
#ifdef ENABLE_DEVICE_MAPPER
static int
_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
@@ -712,6 +719,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_LOOP;
} else if (dev_major == MD_MAJOR) {
dev->type = PED_DEVICE_MD;
+ } else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
+ dev->type = PED_DEVICE_NVME;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1471,6 +1480,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_NVME:
+ if (!init_generic (dev, _("NVMe Device")))
+ goto error_free_arch_specific;
+ break;
+
case PED_DEVICE_ATARAID:
if (!init_generic (dev, _("ATARAID Controller")))
goto error_free_arch_specific;
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -1035,7 +1035,7 @@ _print_disk_info (const PedDevice *dev,
"cpqarray", "file", "ataraid", "i2o",
"ubd", "dasd", "viodasd", "sx8", "dm",
"xvd", "sd/mmc", "virtblk", "aoe",
- "md", "loopback"};
+ "md", "loopback", "nvme"};
char* start = ped_unit_format (dev, 0);
PedUnit default_unit = ped_unit_get_default ();

View File

@ -1,95 +0,0 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 14 Mar 2017 16:40:00 +0100
Subject: Add support for RAM drives
References: bsc#1006834
Patch-mainline: v3.3
Git-commit: 21131f62c6f508a5d0c080e025cf7db5df43fc7d
Recognize RAM drives, so "parted -s /dev/ram0 p" now prints
"RAM Drive (brd)" instead of "Model: Unknown (unknown)".
In order for a device to be recognized as RAM drive, it has to
have major number 1. Also the BLKFLSBUF ioctl shouldn't be used
on RAM drives as it is used to zero the device.
* NEWS: Mention the change
* include/parted/device.h.in(PedDeviceType): Add PED_DEVICE_RAM.
* libparted/arch/linux.c(RAM_MAJOR): New define.
* libparted/arch/linux.c(_device_probe_type): Recognize RAM drives.
* libparted/arch/linux.c(linux_new): Handle RAM drives.
* libparted/arch/linux.c(_flush_cache): Skip RAM drives.
* parted/parted.c(do_print): Add "brd" to list of transports.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/device.in.h | 3 ++-
libparted/arch/linux.c | 12 ++++++++++--
parted/parted.c | 2 +-
3 files changed, 13 insertions(+), 4 deletions(-)
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -50,7 +50,8 @@ typedef enum {
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
PED_DEVICE_LOOP = 18,
- PED_DEVICE_NVME = 19
+ PED_DEVICE_NVME = 19,
+ PED_DEVICE_RAM = 20
} PedDeviceType;
typedef struct _PedDevice PedDevice;
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -280,6 +280,7 @@ struct blkdev_ioctl_param {
#define LOOP_MAJOR 7
#define MD_MAJOR 9
#define BLKEXT_MAJOR 259
+#define RAM_MAJOR 1
#define SCSI_BLK_MAJOR(M) ( \
(M) == SCSI_DISK0_MAJOR \
@@ -721,6 +722,8 @@ _device_probe_type (PedDevice* dev)
dev->type = PED_DEVICE_MD;
} else if (_is_blkext_major(dev_major) && dev->path && strstr(dev->path, "nvme")) {
dev->type = PED_DEVICE_NVME;
+ } else if (dev_major == RAM_MAJOR) {
+ dev->type = PED_DEVICE_RAM;
} else {
dev->type = PED_DEVICE_UNKNOWN;
}
@@ -1553,6 +1556,11 @@ linux_new (const char* path)
goto error_free_arch_specific;
break;
+ case PED_DEVICE_RAM:
+ if (!init_generic (dev, _("RAM Drive")))
+ goto error_free_arch_specific;
+ break;
+
default:
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
@@ -1625,9 +1633,9 @@ _flush_cache (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
int i;
- int lpn = _device_get_partition_range(dev);
+ int lpn = _device_get_partition_range(dev);
- if (dev->read_only)
+ if (dev->read_only || dev->type == PED_DEVICE_RAM)
return;
dev->dirty = 0;
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1035,7 +1035,7 @@ _print_disk_info (const PedDevice *dev,
"cpqarray", "file", "ataraid", "i2o",
"ubd", "dasd", "viodasd", "sx8", "dm",
"xvd", "sd/mmc", "virtblk", "aoe",
- "md", "loopback", "nvme"};
+ "md", "loopback", "nvme", "brd"};
char* start = ped_unit_format (dev, 0);
PedUnit default_unit = ped_unit_get_default ();

View File

@ -1,30 +0,0 @@
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;

View File

@ -1,216 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 6 Aug 2015 07:17:14 -0700
Subject: libparted: Use read only when probing devices on linux
Patch-mainline: v3.3
Git-commit: 44d5ae0115c4ecfe3158748309e9912c5aede92d
When a device is opened for RW closing it can trigger other actions,
like udev scanning it for partition changes. Use read only for the
init_* methods and RW for actual changes to the device.
This adds _device_open which takes mode flags as an argument and turns
linux_open into a wrapper for it with RW_MODE.
_device_open_ro is added to open the device with RD_MODE and increment
the open_counter. This is used in the init_* functions.
_device_close is a wrapper around linux_close that decrements the
open_counter and is used in the init_* functions.
All of these changes are self-contained with no external API changes.
The only visible change in behavior is that when a new PedDevice is
created the device is opened in RO_MODE instead of RW_MODE.
Resolves: rhbz#1245144
---
libparted/arch/linux.c | 62 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 18 deletions(-)
Index: parted-3.2/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -292,7 +292,9 @@ struct blkdev_ioctl_param {
static char* _device_get_part_path (PedDevice const *dev, int num);
static int _partition_is_mounted_by_path (const char* path);
static unsigned int _device_get_partition_range(PedDevice const* dev);
-
+static int _device_open (PedDevice* dev, int flags);
+static int _device_open_ro (PedDevice* dev);
+static int _device_close (PedDevice* dev);
static int
_read_fd (int fd, char **buf)
@@ -911,7 +913,7 @@ init_ide (PedDevice* dev)
if (!_device_stat (dev, &dev_stat))
goto error;
- if (!ped_device_open (dev))
+ if (!_device_open_ro (dev))
goto error;
if (ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi)) {
@@ -980,11 +982,11 @@ init_ide (PedDevice* dev)
if (!_device_probe_geometry (dev))
goto error_close_dev;
- ped_device_close (dev);
+ _device_close (dev);
return 1;
error_close_dev:
- ped_device_close (dev);
+ _device_close (dev);
error:
return 0;
}
@@ -1117,7 +1119,7 @@ init_scsi (PedDevice* dev)
char* vendor;
char* product;
- if (!ped_device_open (dev))
+ if (!_device_open_ro (dev))
goto error;
if (ioctl (arch_specific->fd, SCSI_IOCTL_GET_IDLUN, &idlun) < 0) {
@@ -1131,7 +1133,7 @@ init_scsi (PedDevice* dev)
goto error_close_dev;
if (!_device_probe_geometry (dev))
goto error_close_dev;
- ped_device_close (dev);
+ _device_close (dev);
return 1;
}
@@ -1153,11 +1155,11 @@ init_scsi (PedDevice* dev)
if (!_device_probe_geometry (dev))
goto error_close_dev;
- ped_device_close (dev);
+ _device_close (dev);
return 1;
error_close_dev:
- ped_device_close (dev);
+ _device_close (dev);
error:
return 0;
}
@@ -1169,7 +1171,7 @@ init_file (PedDevice* dev)
if (!_device_stat (dev, &dev_stat))
goto error;
- if (!ped_device_open (dev))
+ if (!_device_open_ro (dev))
goto error;
dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
@@ -1196,7 +1198,7 @@ init_file (PedDevice* dev)
goto error_close_dev;
}
- ped_device_close (dev);
+ _device_close (dev);
dev->bios_geom.cylinders = dev->length / 4 / 32;
dev->bios_geom.heads = 4;
@@ -1207,7 +1209,7 @@ init_file (PedDevice* dev)
return 1;
error_close_dev:
- ped_device_close (dev);
+ _device_close (dev);
error:
return 0;
}
@@ -1223,7 +1225,7 @@ init_dasd (PedDevice* dev, const char* m
if (!_device_stat (dev, &dev_stat))
goto error;
- if (!ped_device_open (dev))
+ if (!_device_open_ro (dev))
goto error;
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
@@ -1263,11 +1265,11 @@ init_dasd (PedDevice* dev, const char* m
dev->model = strdup (model_name);
- ped_device_close (dev);
+ _device_close (dev);
return 1;
error_close_dev:
- ped_device_close (dev);
+ _device_close (dev);
error:
return 0;
}
@@ -1282,7 +1284,7 @@ init_generic (PedDevice* dev, const char
if (!_device_stat (dev, &dev_stat))
goto error;
- if (!ped_device_open (dev))
+ if (!_device_open_ro (dev))
goto error;
ped_exception_fetch_all ();
@@ -1330,11 +1332,11 @@ init_generic (PedDevice* dev, const char
dev->model = strdup (model_name);
- ped_device_close (dev);
+ _device_close (dev);
return 1;
error_close_dev:
- ped_device_close (dev);
+ _device_close (dev);
error:
return 0;
}
@@ -1621,12 +1623,27 @@ retry:
}
static int
+_device_open_ro (PedDevice* dev)
+{
+ int rc = _device_open (dev, RD_MODE);
+ if (rc)
+ dev->open_count++;
+ return rc;
+}
+
+static int
linux_open (PedDevice* dev)
{
+ return _device_open (dev, RW_MODE);
+}
+
+static int
+_device_open (PedDevice* dev, int flags)
+{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
retry:
- arch_specific->fd = open (dev->path, RW_MODE);
+ arch_specific->fd = open (dev->path, flags);
if (arch_specific->fd == -1) {
char* rw_error_msg = strerror (errno);
@@ -1695,6 +1712,15 @@ linux_refresh_close (PedDevice* dev)
return 1;
}
+static int
+_device_close (PedDevice* dev)
+{
+ int rc = linux_close (dev);
+ if (dev->open_count > 0)
+ dev->open_count--;
+ return rc;
+}
+
#if SIZEOF_OFF_T < 8
static _syscall5(int,_llseek,

View File

@ -1,42 +0,0 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 29 May 2014 14:50:31 +0200
Subject: libparted: allow bigger snap radius if cylinders are used
References: bnc#879387
Patch-mainline: no, custom change for flexibility
This is partial revert of commit
commit 18e727d492933ae1ebb16961e1df553f9299af8b
Author: Brian C. Lane <bcl@redhat.com>
Date: Tue Jun 21 10:44:15 2011 -0700
libparted: fix snap radius so that it is using half (#665496)
The snap radius didn't match the documentation, it has been
using +/- unit size instead +/- 0.5 * unit (eg. 500KB for a MB
unit). This caused problems when specifying 1MB, 1GB, etc. as a
partition start or end resulting in partitions being created
that were nowhere near the specified size.
Only revert to the old behavior if cylinders are used in order to
give parted more flexibility when snapping the partition start/end.
---
libparted/unit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: parted-3.1/libparted/unit.c
===================================================================
--- parted-3.1.orig/libparted/unit.c
+++ parted-3.1/libparted/unit.c
@@ -540,7 +540,10 @@ ped_unit_parse_custom (const char* str,
}
unit_size = ped_unit_get_size (dev, unit);
- radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
+ if (unit == PED_UNIT_CYLINDER)
+ radius = ped_div_round_up (unit_size, dev->sector_size) - 1;
+ else
+ radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
if (radius < 0)
radius = 0;
/* If the user specifies units in a power of 2, e.g., 4MiB, as in

View File

@ -5,11 +5,11 @@ Patch-mainline: no, custom SUSE patch
libparted/arch/linux.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: parted-3.2/libparted/arch/linux.c
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -2728,6 +2728,12 @@ _dm_remove_partition(PedDisk* disk, int
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2852,6 +2852,12 @@ _dm_remove_partition(PedDisk* disk, int
goto err;
}
close (fd);

View File

@ -1,35 +0,0 @@
From ee2c0c20fb215af43b12195e8cd645cc1a0bd96e Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 11:20:09 +0100
Subject: [PATCH] libparted/dasd: add an exception for changing DASD-LDL
partition table
The partition table of DASD-LDL device with the dasd disk label
should not be changed according to its character in Linux.
When the user tries to modify the partition table, an exception
will be raised to inform user of this character.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/labels/dasd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Index: parted-3.2/libparted/labels/dasd.c
===================================================================
--- parted-3.2.orig/libparted/labels/dasd.c
+++ parted-3.2/libparted/labels/dasd.c
@@ -617,8 +617,12 @@ dasd_write (const PedDisk* disk)
PDEBUG;
/* If not formated in CDL, don't write anything. */
- if (disk_specific->format_type == 1)
+ if (disk_specific->format_type == 1) {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_CANCEL,
+ _("The partition table of DASD-LDL device cannot be changed.\n"));
return 1;
+ }
/* Ensure the device is open RW */
char dummy[10]; /* to avoid assertion in ped_device_write */

View File

@ -1,171 +0,0 @@
From b9e12819ecef30087753b967bebc9809120593a6 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:48 +0200
Subject: [PATCH] libparted/dasd: add new fdasd functions
Introduce a set of new functions from the fdasd utility of the s390-tools
to keep the code base in parted and s390-tools in sync.
These new functions are:
fdasd_check_volser(): validate the volser input
fdasd_get_volser(): get volume serial (volser)
fdasd_change_volser(): change volser with string
fdasd_reuse_vtoc(): re-create vtoc labels based on the existing vtoc
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/fdasd.in.h | 4 ++
libparted/labels/fdasd.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 09a35a0..9e5d7d1 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -293,5 +293,9 @@ void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
unsigned int start, unsigned int stop);
int fdasd_prepare_labels (fdasd_anchor_t *anc, int fd) ;
+void fdasd_check_volser(char *volser, int devno);
+int fdasd_get_volser(fdasd_anchor_t *anc, char *volser, int fd);
+void fdasd_change_volser(fdasd_anchor_t *anc, char *str);
+void fdasd_reuse_vtoc(fdasd_anchor_t *anc);
#endif /* FDASD_H */
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index e5df5cf..713ed6b 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -1320,4 +1320,127 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start,
return p;
}
+/*
+ * Check for valid volume serial characters (max. 6) - remove invalid.
+ * If volser is empty, fill with default volser.
+ */
+void fdasd_check_volser (char *volser, int devno)
+{
+ int from, to;
+
+ for (from = 0, to = 0; volser[from] && from < VOLSER_LENGTH; from++) {
+
+ if ((volser[from] >= 0x23 &&
+ volser[from] <= 0x25) ||
+ (volser[from] >= 0x30 &&
+ volser[from] <= 0x39) ||
+ (volser[from] >= 0x40 &&
+ volser[from] <= 0x5a) ||
+ (volser[from] >= 0x61 &&
+ volser[from] <= 0x7a))
+ volser[to++] = toupper(volser[from]);
+ }
+
+ volser[to] = 0x00;
+
+ if (volser[0] == 0x00)
+ sprintf(volser, "0X%04x", devno);
+}
+
+/*
+ * get volser from vtoc
+ */
+int fdasd_get_volser (fdasd_anchor_t *anc, char *volser, int fd)
+{
+ volume_label_t vlabel;
+
+ vtoc_read_volume_label(fd, anc->label_pos, &vlabel);
+ vtoc_volume_label_get_volser(&vlabel, volser);
+ return 0;
+}
+
+/* Changes the volume serial (menu option)
+ *
+ */
+void fdasd_change_volser (fdasd_anchor_t *anc, char *str)
+{
+ fdasd_check_volser(str, anc->devno);
+ vtoc_volume_label_set_volser(anc->vlabel, str);
+
+ vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+ anc->vlabel_changed++;
+ anc->vtoc_changed++;
+}
+
+/*
+ * re-create all VTOC labels, but use the partition information
+ * from existing VTOC
+ */
+void fdasd_reuse_vtoc (fdasd_anchor_t *anc)
+{
+ partition_info_t *part_info = anc->first;
+ struct fdasd_hd_geometry geo = anc->geo;
+ format1_label_t f1;
+ format4_label_t f4;
+ format5_label_t f5;
+ format7_label_t f7;
+
+ vtoc_init_format4_label(&f4, geo.cylinders, anc->formatted_cylinders,
+ geo.heads, geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ /* reuse some FMT4 values */
+ f4.DS4HPCHR = anc->f4->DS4HPCHR;
+ f4.DS4DSREC = anc->f4->DS4DSREC;
+
+ /* re-initialize both free-space labels */
+ vtoc_init_format5_label(&f5);
+ vtoc_init_format7_label(&f7);
+
+ if (anc->fspace_trk > 0)
+ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ FIRST_USABLE_TRK + anc->fspace_trk - 1,
+ anc->formatted_cylinders, geo.heads);
+
+ while (part_info != NULL) {
+ if (part_info->used != 0x01) {
+ part_info = part_info->next;
+ continue;
+ }
+
+ if (anc->formatted_cylinders > LV_COMPAT_CYL)
+ vtoc_init_format8_label(anc->blksize,
+ &part_info->f1->DS1EXT1, &f1);
+ else
+ vtoc_init_format1_label(anc->blksize,
+ &part_info->f1->DS1EXT1, &f1);
+
+
+ strncpy(f1.DS1DSNAM, part_info->f1->DS1DSNAM, 44);
+ strncpy((char *)f1.DS1DSSN, (char *)part_info->f1->DS1DSSN, 6);
+ f1.DS1CREDT = part_info->f1->DS1CREDT;
+
+ memcpy(part_info->f1, &f1, sizeof(format1_label_t));
+
+ if (part_info->fspace_trk > 0)
+ vtoc_set_freespace(&f4, &f5, &f7, '+', anc->verbose,
+ part_info->end_trk + 1,
+ part_info->end_trk +
+ part_info->fspace_trk,
+ anc->formatted_cylinders, geo.heads);
+
+ part_info = part_info->next;
+ }
+
+ /* over-write old labels with new ones */
+ memcpy(anc->f4, &f4, sizeof(format4_label_t));
+ memcpy(anc->f5, &f5, sizeof(format5_label_t));
+ memcpy(anc->f7, &f7, sizeof(format7_label_t));
+
+ anc->vtoc_changed++;
+
+ return;
+}
+
/* vim:set tabstop=4 shiftwidth=4 softtabstop=4: */
--
2.16.4

View File

@ -18,8 +18,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
libparted/labels/dasd.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -65,6 +65,7 @@ extern void ped_disk_dasd_done ();
typedef struct {
int type;
@ -64,7 +66,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
dasd_data->type = 0;
@@ -745,14 +741,25 @@ dasd_partition_set_flag (PedPartition* p
@@ -749,14 +745,25 @@ dasd_partition_set_flag (PedPartition* p
dasd_data = part->disk_specific;
switch (flag) {
@ -92,7 +94,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
dasd_data->lvm = state;
return ped_partition_set_system(part, part->fs_type);
default:
@@ -770,6 +777,8 @@ dasd_partition_get_flag (const PedPartit
@@ -774,6 +781,8 @@ dasd_partition_get_flag (const PedPartit
dasd_data = part->disk_specific;
switch (flag) {
@ -101,16 +103,16 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
case PED_PARTITION_RAID:
return dasd_data->raid;
case PED_PARTITION_LVM:
@@ -784,6 +793,8 @@ dasd_partition_is_flag_available (const
PedPartitionFlag flag)
{
@@ -802,6 +811,8 @@ dasd_partition_is_flag_available (const
return 0;
switch (flag) {
+ case PED_PARTITION_SWAP:
+ return 1;
case PED_PARTITION_RAID:
return 1;
case PED_PARTITION_LVM:
@@ -962,17 +973,14 @@ dasd_partition_set_system (PedPartition*
@@ -985,17 +996,14 @@ dasd_partition_set_system (PedPartition*
return 1;
}

View File

@ -1,282 +0,0 @@
From c11f5c005270d24bc3905ab3b743e96fc1a9a507 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Thu, 20 Apr 2017 10:20:07 +0200
Subject: [PATCH] libparted/dasd: add test cases for the new fdasd functions
The test case uses a temporary file in libparted/tests under
Check framwork.It can be issued by "make check" in the test dir.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
libparted/tests/t4000-volser.sh | 20 +++++
libparted/tests/volser.c | 188 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 208 insertions(+)
create mode 100755 libparted/tests/t4000-volser.sh
create mode 100644 libparted/tests/volser.c
diff --git a/libparted/tests/t4000-volser.sh b/libparted/tests/t4000-volser.sh
new file mode 100755
index 0000000..89688ba
--- /dev/null
+++ b/libparted/tests/t4000-volser.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# 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/>.
+
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
+
+volser || fail=1
+
+Exit $fail
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
new file mode 100644
index 0000000..9063821
--- /dev/null
+++ b/libparted/tests/volser.c
@@ -0,0 +1,188 @@
+/*
+ * Author: Wang Dong <dongdwdw@cn.ibm.com>
+ */
+
+#include <config.h>
+#include <unistd.h>
+#include <check.h>
+
+#include <parted/vtoc.h>
+#include <parted/device.h>
+#include <parted/fdasd.h>
+#include <parted/vtoc.h>
+#include "../arch/linux.h"
+#include "common.h"
+#include "progname.h"
+
+/* set dasd first */
+static char vol_devno[7] = {0};
+static char *tmp_disk;
+static int fd;
+
+static PedDisk *disk;
+static struct fdasd_anchor anc;
+static fdasd_anchor_t *anchor = &anc;
+static LinuxSpecific *arch_specific;
+
+/* set the enviroment */
+static void set_test (void)
+{
+ PedDevice *dev;
+ PedDiskType *type;
+ type = ped_disk_type_get ("dasd");
+
+ tmp_disk = _create_disk (20*1024*1024);
+ fail_if (tmp_disk == NULL, "Failed to create temporary disk");
+ dev = ped_device_get (tmp_disk);
+ if (dev == NULL)
+ return;
+
+ disk = _create_disk_label (dev, type);
+ if (!ped_device_open (disk->dev))
+ return;
+
+ fdasd_initialize_anchor (anchor);
+ arch_specific = LINUX_SPECIFIC (disk->dev);
+ fd = arch_specific->fd;
+ if (!fdasd_get_geometry (dev, anchor, fd))
+ return;
+
+ fdasd_check_volume (anchor, fd);
+ sprintf (vol_devno, "0X%04x", anchor->devno);
+ ck_assert (strlen (vol_devno) == VOLSER_LENGTH);
+}
+
+static void free_test (void)
+{
+ ped_device_close (disk->dev);
+ ped_device_destroy (disk->dev);
+ unlink (tmp_disk);
+ free (tmp_disk);
+ fdasd_cleanup (anchor);
+}
+
+/* Test with default volser */
+START_TEST (test_get_volser)
+{
+ char volser[7] = {0};
+ fdasd_change_volser (anchor, vol_devno);
+ fdasd_write_labels (anchor, fd);
+
+ fdasd_get_volser (anchor, volser, fd);
+ ck_assert (!strcmp (volser, vol_devno));
+}
+END_TEST
+
+START_TEST (test_check_volser)
+{
+ char vol[7] = {0};
+ char vol_long[] = "abcdefg";
+ char vol_short[] = "ab_c ";
+ char vol_null[] = " ";
+ char *vol_input = NULL;
+
+ vol_input = vol_long;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert(!strcmp (vol_input, "ABCDEF"));
+
+ vol_input = vol_short;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert (!strcmp (vol_input, "ABC"));
+
+ vol_input = vol_null;
+ fdasd_check_volser (vol_input, anchor->devno);
+ ck_assert (!strcmp (vol_input, vol_devno));
+}
+END_TEST
+
+START_TEST (test_change_volser)
+{
+
+ char vol[] = "000000";
+ char volser[7] = {0};
+
+ fdasd_change_volser (anchor, vol);
+ fdasd_write_labels (anchor, fd);
+
+ fdasd_get_volser (anchor, volser, fd);
+ ck_assert (!strcmp (volser, vol));
+}
+END_TEST
+
+/*
+ * fdsad_recreate_vtoc recreate the VTOC with existing one.
+ * So the partition information should be not changed after recreating
+ * VTOC.
+*/
+START_TEST (test_reuse_vtoc)
+{
+ ds5ext_t before;
+ ds5ext_t after;
+
+ memcpy (&before, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+
+ if (anchor->fspace_trk) {
+ fdasd_reuse_vtoc (anchor);
+ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft))
+ ck_abort ();
+ } else {
+ fdasd_reuse_vtoc (anchor);
+ memcpy (&after, &anchor->f5->DS5AVEXT, sizeof(ds5ext_t));
+ if ((before.t != after.t) && (before.fc != after.fc) && (before.ft != after.ft))
+ ck_abort ();
+ }
+}
+END_TEST
+
+int main (int argc, char **argv)
+{
+
+ set_program_name (argv[0]);
+
+#if defined __s390__ || defined __s390x__
+
+ int number_failed = 0;
+
+ Suite *suite = suite_create ("Volser");
+
+ TCase *tcase_get = tcase_create ("Get");
+ TCase *tcase_check = tcase_create ("Check");
+ TCase *tcase_change = tcase_create ("Change");
+ TCase *tcase_vtoc = tcase_create ("Vtoc");
+
+ ped_exception_set_handler (_test_exception_handler);
+
+ tcase_add_checked_fixture (tcase_check, set_test, free_test);
+ tcase_add_test (tcase_check, test_check_volser);
+ tcase_set_timeout (tcase_check, 0);
+ suite_add_tcase (suite, tcase_check);
+
+ tcase_add_checked_fixture (tcase_change, set_test, free_test);
+ tcase_add_test (tcase_change, test_change_volser);
+ tcase_set_timeout (tcase_change, 0);
+ suite_add_tcase (suite, tcase_change);
+
+ tcase_add_checked_fixture (tcase_get, set_test, free_test);
+ tcase_add_test (tcase_get, test_get_volser);
+ tcase_set_timeout (tcase_get, 0);
+ suite_add_tcase (suite, tcase_get);
+
+ tcase_add_checked_fixture (tcase_vtoc, set_test, free_test);
+ tcase_add_test (tcase_vtoc, test_reuse_vtoc);
+ tcase_set_timeout (tcase_vtoc, 0);
+ suite_add_tcase (suite, tcase_vtoc);
+
+ SRunner *srunner = srunner_create (suite);
+ /* When to debug, uncomment this line */
+ /* srunner_set_fork_status (srunner, CK_NOFORK); */
+
+ srunner_run_all (srunner, CK_VERBOSE);
+
+ number_failed = srunner_ntests_failed (srunner);
+ srunner_free (srunner);
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+
+#endif
+ return 0;
+}
--
2.16.4
From 571e078406b59e8dcf02db3e8fe28d8eb4d2cef0 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:49 +0200
Subject: [PATCH] libparted/dasd: add test cases for the new fdasd functions
The test case uses a temporary file in libparted/tests under
Check framwork. It can be issued by "make check" in the test dir.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/tests/Makefile.am | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c7c10a9..9689fb3 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,9 +3,9 @@
#
# This file may be modified and/or distributed without restriction.
-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
+TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh t4000-volser.sh
EXTRA_DIST = $(TESTS)
-check_PROGRAMS = label disk zerolen symlink
+check_PROGRAMS = label disk zerolen symlink volser
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
LDADD = \
@@ -23,6 +23,7 @@ label_SOURCES = common.h common.c label.c
disk_SOURCES = common.h common.c disk.c
zerolen_SOURCES = common.h common.c zerolen.c
symlink_SOURCES = common.h common.c symlink.c
+volser_SOURCES = common.h common.c volser.c
# Arrange to symlink to tests/init.sh.
CLEANFILES = init.sh
--
2.16.4

View File

@ -1,53 +0,0 @@
From 4126d0292c75cf7d50a2f4e9d485a52b5beafccc Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Tue, 14 Jun 2016 12:19:40 +0200
Subject: [PATCH] libparted/dasd: correct the offset where the first partition
begins
The start point of first partition must start at least from the third
track of DASD, due to the existence of metadata in the first two track.
The previous constraint just sets all the device to be partitioned.
So when the start point of the first partition start before the third
track, (For example if it starts from.0) parted will exit abruptly.
And this kind of job must be done with constraint explicitly.
Then the constraint is modified to exclude the first two tracks and
to make the first partition start from the third track by default.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/dasd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index f79a867..4e68512 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -829,6 +829,7 @@ _primary_constraint (PedDisk* disk)
PedSector sector_size;
LinuxSpecific* arch_specific;
DasdDiskSpecific* disk_specific;
+ PedSector start;
PDEBUG;
@@ -842,7 +843,12 @@ _primary_constraint (PedDisk* disk)
if (!ped_alignment_init (&end_align, -1,
disk->dev->hw_geom.sectors * sector_size))
return NULL;
- if (!ped_geometry_init (&max_geom, disk->dev, 0, disk->dev->length))
+
+ start = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
+ * (long long) arch_specific->real_sector_size
+ / (long long) disk->dev->sector_size);
+
+ if (!ped_geometry_init (&max_geom, disk->dev, start, disk->dev->length))
return NULL;
return ped_constraint_new(&start_align, &end_align, &max_geom,
--
2.16.4

View File

@ -7,10 +7,10 @@ Patch-mainline: no, custom SUSE patch
libparted/labels/dasd.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
Index: parted-3.1/include/parted/disk.in.h
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.1.orig/include/parted/disk.in.h
+++ parted-3.1/include/parted/disk.in.h
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -38,9 +38,11 @@ enum _PedDiskFlag {
PED_DISK_CYLINDER_ALIGNMENT=1,
/* This flag controls whether the boot flag of a GPT PMBR is set */
@ -24,11 +24,11 @@ Index: parted-3.1/include/parted/disk.in.h
/**
* Partition types
Index: parted-3.1/libparted/disk.c
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.1.orig/libparted/disk.c
+++ parted-3.1/libparted/disk.c
@@ -838,6 +838,8 @@ ped_disk_flag_get_name(PedDiskFlag flag)
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -841,6 +841,8 @@ ped_disk_flag_get_name(PedDiskFlag flag)
return N_("cylinder_alignment");
case PED_DISK_GPT_PMBR_BOOT:
return N_("pmbr_boot");
@ -37,10 +37,10 @@ Index: parted-3.1/libparted/disk.c
default:
ped_exception_throw (
PED_EXCEPTION_BUG,
Index: parted-3.1/libparted/labels/dasd.c
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.1.orig/libparted/labels/dasd.c
+++ parted-3.1/libparted/labels/dasd.c
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -73,6 +73,7 @@ typedef struct {
unsigned int format_type;
unsigned int label_block;
@ -79,7 +79,7 @@ Index: parted-3.1/libparted/labels/dasd.c
/* CDL format, newer */
disk_specific->format_type = 2;
disk_specific->label_block = 2;
@@ -293,6 +303,7 @@ dasd_read (PedDisk* disk)
@@ -289,6 +299,7 @@ dasd_read (PedDisk* disk)
goto error_close_dev;
disk_specific->format_type = 1;
@ -87,7 +87,7 @@ Index: parted-3.1/libparted/labels/dasd.c
/* Register implicit partition */
ped_disk_delete_all (disk);
@@ -905,6 +916,40 @@ dasd_partition_enumerate (PedPartition*
@@ -922,6 +933,40 @@ dasd_partition_enumerate (PedPartition*
}
static int

View File

@ -1,272 +0,0 @@
From 4f25d54d4d2bd6ae12d56b5a97ed2b7f60f753e9 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:46 +0200
Subject: [PATCH] libparted/dasd: unify vtoc handling for cdl/ldl
Merge volume label cdl and ldl. It is convenient to manipulate
the same structure. Also remove unused arguments in the functions.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/vtoc.in.h | 34 +++++++++++++++++++---------------
libparted/labels/dasd.c | 8 +++-----
libparted/labels/vtoc.c | 38 +++++++++++++++++---------------------
3 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/include/parted/vtoc.in.h b/include/parted/vtoc.in.h
index 499c2d3..b9da23a 100644
--- a/include/parted/vtoc.in.h
+++ b/include/parted/vtoc.in.h
@@ -62,7 +62,6 @@ typedef struct cchh cchh_t;
typedef struct labeldate labeldate_t;
typedef struct volume_label volume_label_t;
typedef struct cms_volume_label cms_volume_label_t;
-typedef struct ldl_volume_label ldl_volume_label_t;
typedef struct extent extent_t;
typedef struct dev_const dev_const_t;
typedef struct format1_label format1_label_t;
@@ -94,6 +93,19 @@ struct __attribute__ ((packed)) labeldate {
u_int16_t day;
};
+/*
+ * The following structure is a merger of the cdl and ldl volume label.
+ * On an ldl disk there is no key information, so when reading an
+ * ldl label from disk, the data should be copied at the address of vollbl.
+ * On the other side, the field ldl_version is reserved in a cdl record
+ * and the field formatted_blocks exists only for ldl labels. So when
+ * reading a cdl label from disk, the formatted_blocks field will contain
+ * arbitrary data.
+ * This layout may be a bit awkward, but the advantage of having the
+ * same label type for both disk layout types is bigger than the effort
+ * for taking a bit of extra care at the fringes.
+ */
+
struct __attribute__ ((packed)) volume_label {
char volkey[4]; /* volume key = volume label */
char vollbl[4]; /* volume label ("VOL1" in EBCDIC) */
@@ -107,15 +119,8 @@ struct __attribute__ ((packed)) volume_label {
char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */
char res2[4]; /* reserved */
char lvtoc[14]; /* owner code for LVTOC */
- char res3[29]; /* reserved */
- char fudge[4]; /* filler to match length of ldl label */
-};
-
-struct __attribute__ ((packed)) ldl_volume_label {
- char vollbl[4]; /* Label identifier ("LNX1" in EBCDIC) */
- char volid[6]; /* Volume identifier */
- char res3[69]; /* Reserved field */
- char ldl_version[1]; /* Version number, valid for ldl format */
+ char res3[28]; /* reserved */
+ char ldl_version; /* version number, valid for ldl format */
u_int64_t formatted_blocks; /* valid when ldl_version >= "2" (in
EBCDIC) */
};
@@ -335,11 +340,10 @@ void vtoc_write_label (int fd, unsigned long position,
format7_label_t const *f7,
format9_label_t const *f9);
-void vtoc_init_format1_label (char *volid, unsigned int blksize,
+void vtoc_init_format1_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_init_format4_label (format4_label_t *f4lbl,
- unsigned int usable_partitions,
unsigned int compat_cylinders,
unsigned int real_cylinders,
unsigned int tracks,
@@ -352,11 +356,11 @@ void vtoc_update_format4_label (format4_label_t *f4, cchhb_t *highest_f1,
void vtoc_init_format5_label (format5_label_t *f5);
-void vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
+void vtoc_update_format5_label_add (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
-void vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
+void vtoc_update_format5_label_del (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b,
u_int8_t c);
@@ -368,7 +372,7 @@ void vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
void vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
u_int32_t a, u_int32_t b);
-void vtoc_init_format8_label (char *volid, unsigned int blksize,
+void vtoc_init_format8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1);
void vtoc_update_format8_label (cchhb_t *associated_f9, format1_label_t *f8);
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 4e68512..7594e96 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -330,13 +330,12 @@ dasd_read (PedDisk* disk)
DasdPartitionData* dasd_data;
union vollabel {
- volume_label_t unused;
- ldl_volume_label_t ldl;
+ volume_label_t ldl;
cms_volume_label_t cms;
};
union vollabel *cms_ptr1 = (union vollabel *) anchor.vlabel;
cms_volume_label_t *cms_ptr = &cms_ptr1->cms;
- ldl_volume_label_t *ldl_ptr = &cms_ptr1->ldl;
+ volume_label_t *ldl_ptr = &cms_ptr1->ldl;
int partition_start_block;
disk_specific->format_type = 1;
@@ -360,8 +359,7 @@ dasd_read (PedDisk* disk)
* (long long) cms_ptr->disk_offset;
if (is_ldl)
- if (strncmp(ldl_ptr->ldl_version,
- vtoc_ebcdic_enc("2", str, 1), 1) >= 0)
+ if (ldl_ptr->ldl_version >= 0xf2)
end = (long long) arch_specific->real_sector_size
/ (long long) disk->dev->sector_size
* (long long) ldl_ptr->formatted_blocks - 1;
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index fdfa94f..d47b791 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -150,7 +150,7 @@ enum failure {
unable_to_read
};
-static char buffer[89];
+static char buffer[93];
static void
vtoc_error (enum failure why, char const *s1, char const *s2)
@@ -329,7 +329,7 @@ void
vtoc_volume_label_init (volume_label_t *vlabel)
{
PDEBUG
- sprintf(buffer, "%88s", " ");
+ sprintf(buffer, "%92s", " ");
vtoc_ebcdic_enc(buffer, buffer, sizeof *vlabel);
memcpy(vlabel, buffer, sizeof *vlabel);
}
@@ -348,8 +348,8 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start,
typedef union vollabel vollabel_t;
union __attribute__((packed)) vollabel {
+ /* cdl and ldl have the same data struct */
volume_label_t cdl;
- ldl_volume_label_t ldl;
cms_volume_label_t cms;
};
@@ -373,9 +373,7 @@ vtoc_read_volume_label (int f, unsigned long vlabel_start,
}
rc = read(f, vlabel, sizeof(volume_label_t));
- if (rc != sizeof(volume_label_t) &&
- /* For CDL we ask to read 88 bytes, but only get 84 */
- rc != sizeof(volume_label_t) - 4) {
+ if (rc != sizeof(volume_label_t)) {
vtoc_error(unable_to_read, "vtoc_read_volume_label",
_("Could not read volume label."));
return 1;
@@ -427,10 +425,8 @@ vtoc_write_volume_label (int f, unsigned long vlabel_start,
vtoc_error(unable_to_seek, "vtoc_write_volume_label",
_("Could not write volume label."));
- rc = write(f, vlabel, sizeof(volume_label_t) - 4);
- /* Subtract 4 to leave off the "fudge" variable when writing.
- We only write CDL volume labels, never LDL or CMS. */
- if (rc != sizeof(volume_label_t) - 4)
+ rc = write(f, vlabel, sizeof(volume_label_t));
+ if (rc != sizeof(volume_label_t))
vtoc_error(unable_to_write, "vtoc_write_volume_label",
_("Could not write volume label."));
@@ -632,7 +628,7 @@ vtoc_write_label (int f, unsigned long position,
* initializes a format4 label
*/
void
-vtoc_init_format4_label (format4_label_t *f4, unsigned int usable_partitions,
+vtoc_init_format4_label (format4_label_t *f4,
unsigned int compat_cylinders,
unsigned int real_cylinders, unsigned int tracks,
unsigned int blocks, unsigned int blksize,
@@ -740,7 +736,7 @@ vtoc_init_format7_label (format7_label_t *f7)
* format1 or format 8 label, all but the field DS1FMTID
*/
void
-vtoc_init_format_1_8_label (char *volid, unsigned int blksize,
+vtoc_init_format_1_8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1)
{
PDEBUG
@@ -794,18 +790,18 @@ vtoc_init_format_1_8_label (char *volid, unsigned int blksize,
}
void
-vtoc_init_format1_label (char *volid, unsigned int blksize,
+vtoc_init_format1_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f1)
{
- vtoc_init_format_1_8_label(volid, blksize, part_extent, f1);
+ vtoc_init_format_1_8_label(blksize, part_extent, f1);
f1->DS1FMTID = 0xf1;
}
void
-vtoc_init_format8_label (char *volid, unsigned int blksize,
+vtoc_init_format8_label (unsigned int blksize,
extent_t *part_extent, format1_label_t *f8)
{
- vtoc_init_format_1_8_label(volid, blksize, part_extent, f8);
+ vtoc_init_format_1_8_label(blksize, part_extent, f8);
f8->DS1FMTID = 0xf8;
}
@@ -886,7 +882,7 @@ vtoc_reorganize_FMT5_extents (format5_label_t *f5)
* add a free space extent description to the VTOC FMT5 DSCB
*/
void
-vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
+vtoc_update_format5_label_add (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b, u_int8_t c)
{
PDEBUG
@@ -974,7 +970,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
* remove a free space extent description from the VTOC FMT5 DSCB
*/
void
-vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
+vtoc_update_format5_label_del (format5_label_t *f5, int verbose,
int trk, u_int16_t a, u_int16_t b, u_int8_t c)
{
PDEBUG
@@ -1054,7 +1050,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
ext->ft = (a - ext->t) % trk;
vtoc_update_format5_label_add(f5, verbose,
- cyl, trk, x, y, z);
+ trk, x, y, z);
if (verbose)
puts ("FMT5 del extent: 2 pieces");
@@ -1322,9 +1318,9 @@ vtoc_set_freespace(format4_label_t *f4, format5_label_t *f5,
z = (u_int8_t) ((stop - start + 1) % trk);
if (ch == '+')
- vtoc_update_format5_label_add(f5, verbose, cyl, trk, x, y, z);
+ vtoc_update_format5_label_add(f5, verbose, trk, x, y, z);
else if (ch == '-')
- vtoc_update_format5_label_del(f5, verbose, cyl, trk, x, y, z);
+ vtoc_update_format5_label_del(f5, verbose, trk, x, y, z);
else
puts ("BUG: syntax error in vtoc_set_freespace call");
--
2.16.4

View File

@ -1,208 +0,0 @@
From db37c8c017ebef8f241420dda071940957d4bbe5 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:47 +0200
Subject: [PATCH] libparted/dasd: update and improve fdasd functions
Update the fdasd_anchor_t data structure and the fdasd_cleanup()
function. Also correct vtoc_changed and vlabel_changed accounting
because they are important to rewrite vtoc to save the changes.
Wang Dong <dongdwdw@linux.vnet.ibm.com>
Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/fdasd.in.h | 14 +++++-------
libparted/labels/fdasd.c | 56 ++++++++++++++++++++++++-----------------------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 4e351c4..09a35a0 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -186,6 +186,7 @@ typedef struct format_data_t {
/*****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h) *
*****************************************************************************/
+#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
/* re-read partition table */
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
@@ -198,15 +199,14 @@ typedef struct format_data_t {
/*****************************************************************************
* SECTION: FDASD internal types *
*****************************************************************************/
+#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
+#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
#define DASD_MIN_API_VERSION 0
#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
-#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
-#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
-
-#define FDASD_VERSION "1.05"
+#define FDASD_VERSION "1.32.0"
#define DEVICE "device"
#define DISC "disc"
#define PART "part"
@@ -233,9 +233,6 @@ typedef struct config_data {
typedef struct fdasd_anchor {
int vlabel_changed;
int vtoc_changed;
- int devname_specified;
- int volid_specified;
- int config_specified;
int auto_partition;
int print_table;
int big_disk;
@@ -282,7 +279,8 @@ enum fdasd_failure {
vlabel_corrupted,
dsname_corrupted,
malloc_failed,
- device_verification_failed
+ device_verification_failed,
+ volser_not_found
};
void fdasd_cleanup (fdasd_anchor_t *anchor);
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 968b332..e5df5cf 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -106,28 +106,26 @@ fdasd_cleanup (fdasd_anchor_t *anchor)
{
PDEBUG
int i;
- partition_info_t *p, *q;
+ partition_info_t *part_info, *next;
if (anchor == NULL)
return;
- free(anchor->f4);
- free(anchor->f5);
- free(anchor->f7);
- free(anchor->f9);
- free(anchor->vlabel);
-
- p = anchor->first;
- if (p == NULL)
- return;
-
- for (i=1; i <= USABLE_PARTITIONS; i++) {
- if (p == NULL)
- return;
- q = p->next;
- free(p->f1);
- free(p);
- p = q;
+ if (anchor->f4 != NULL)
+ free(anchor->f4);
+ if (anchor->f5 != NULL)
+ free(anchor->f5);
+ if (anchor->f7 != NULL)
+ free(anchor->f7);
+ if (anchor->vlabel != NULL)
+ free(anchor->vlabel);
+
+ part_info = anchor->first;
+ for (i = 1; i <= USABLE_PARTITIONS && part_info != NULL; i++) {
+ next = part_info->next;
+ free(part_info->f1);
+ free(part_info);
+ part_info = next;
}
}
@@ -190,6 +188,9 @@ fdasd_error (fdasd_anchor_t *anc, enum fdasd_failure why, char const *str)
_("Device verification failed"),
_("The specified device is not a valid DASD device"));
break;
+ case volser_not_found:
+ sprintf(error, "fdasd: %s -- %s\n", _("VOLSER not found on device"), str);
+ break;
default:
sprintf(error, "fdasd: %s: %s\n", _("Fatal error"), str);
}
@@ -287,7 +288,7 @@ fdasd_write_vtoc_labels (fdasd_anchor_t * anc, int fd)
PDEBUG
partition_info_t *p;
unsigned long b, maxblk;
- char dsno[6], s1[7], s2[45], *c1, *c2, *ch;
+ char dsno[6], s1[VOLSER_LENGTH + 1], s2[45], *c1, *c2, *ch;
int i = 0, k = 0;
cchhb_t f9addr;
format1_label_t emptyf1;
@@ -519,7 +520,6 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc)
int i;
vtoc_init_format4_label(anc->f4,
- USABLE_PARTITIONS,
anc->geo.cylinders,
anc->formatted_cylinders,
anc->geo.heads,
@@ -767,7 +767,7 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
- FIRST_USABLE_TRK;
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -781,6 +781,8 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
anc->formatted_cylinders, anc->geo.heads);
vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+ anc->vtoc_changed++;
+ anc->vlabel_changed++;
}
/*
@@ -792,7 +794,7 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
- FIRST_USABLE_TRK;
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -803,6 +805,8 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
FIRST_USABLE_TRK,
anc->formatted_cylinders * anc->geo.heads - 1,
anc->formatted_cylinders, anc->geo.heads);
+
+ anc->vtoc_changed++;
}
@@ -875,7 +879,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
fdasd_init_volume_label(anc, fd);
- vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ vtoc_init_format4_label(anc->f4,
anc->geo.cylinders, anc->formatted_cylinders,
anc->geo.heads, anc->geo.sectors,
anc->blksize, anc->dev_type);
@@ -1286,12 +1290,10 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start,
return 0;
if (anc->formatted_cylinders > LV_COMPAT_CYL) {
- vtoc_init_format8_label(anc->vlabel->volid, anc->blksize, &ext,
- p->f1);
+ vtoc_init_format8_label(anc->blksize, &ext, p->f1);
} else {
PDEBUG;
- vtoc_init_format1_label(anc->vlabel->volid, anc->blksize, &ext,
- p->f1);
+ vtoc_init_format1_label(anc->blksize, &ext, p->f1);
}
PDEBUG;
--
2.16.4

View File

@ -1,90 +0,0 @@
From f98f791e19669b900345dad7d96ea4df974e4596 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 4 Feb 2015 16:46:07 -0800
Subject: [PATCH] libparted: device mapper uses 512b sectors
device mapper doesn't use the device's sector size when creating a
table. It always uses 512b units. This causes partitions to be created
8x smaller than expected on devices with 4906b sectors.
---
NEWS | 4 ++++
libparted/arch/linux.c | 21 +++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
Index: parted-3.2/NEWS
===================================================================
--- parted-3.2.orig/NEWS
+++ parted-3.2/NEWS
@@ -162,6 +162,10 @@ GNU parted NEWS
** Bug Fixes
+ Use 512b sector size when communicating with device-mapper. Fixes
+ problems with partitions being created too small on dm devices
+ with sector sizes > 5121b
+
Don't crash in the disk_set command when a disk label is not found
libparted-fs-resize: Prevent crash resizing FAT16 file systems.
Index: parted-3.2/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -2768,6 +2768,12 @@ _dm_get_partition_start_and_length(PedPa
if (sscanf (params, "%d:%d %Ld", &major, &minor, start) != 3)
goto err;
rc = 1;
+
+ /* device-mapper uses 512b units, make sure we return length and start in terms of the device's
+ * sector size.
+ */
+ *start /= (part->disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
+ *length /= (part->disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
err:
free (path);
dm_task_destroy(task);
@@ -2815,8 +2821,10 @@ _dm_add_partition (PedDisk* disk, const
/* Caution: dm_task_destroy frees dev_name. */
dm_task_destroy (task);
task = NULL;
+ /* device-mapper uses 512b units, not the device's sector size */
if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
- arch_specific->minor, part->geom.start)))
+ arch_specific->minor,
+ part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT))))
goto err;
task = dm_task_create (DM_DEVICE_CREATE);
@@ -2826,7 +2834,8 @@ _dm_add_partition (PedDisk* disk, const
dm_task_set_name (task, vol_name);
if (vol_uuid)
dm_task_set_uuid (task, vol_uuid);
- dm_task_add_target (task, 0, part->geom.length,
+ /* 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;
@@ -2883,8 +2892,11 @@ _dm_resize_partition (PedDisk* disk, con
/* Caution: dm_task_destroy frees dev_name. */
dm_task_destroy (task);
task = NULL;
+
+ /* device-mapper uses 512b units, not the device's sector size */
if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
- arch_specific->minor, part->geom.start)))
+ arch_specific->minor,
+ part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT))))
goto err;
task = dm_task_create (DM_DEVICE_RELOAD);
@@ -2892,7 +2904,8 @@ _dm_resize_partition (PedDisk* disk, con
goto err;
dm_task_set_name (task, vol_name);
- dm_task_add_target (task, 0, part->geom.length,
+ /* 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;

View File

@ -1,38 +0,0 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 4 Oct 2016 10:30:37 +0200
Subject: libparted: Don't warn if no HDIO_GET_IDENTITY ioctl
References: bsc#964012, bsc#1001967
Patch-mainline: v3.3
Git-commit: 3df498541058e933881190677b4cf10193f6aa68
Fully virtualized Xen VMs (HVM) use Linux IDE devices which don't
support the HDIO_GET_IDENTITY ioctl. EINVAL is returned, a warning
is printed and the device model is set to "Generic IDE" in that
case. The problem is seeing the warning all the time. So drop it
for this case.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -937,6 +937,7 @@ init_ide (PedDevice* dev)
PedExceptionOption ex_status;
char hdi_buf[41];
int sector_multiplier = 0;
+ int r;
if (!_device_stat (dev, &dev_stat))
goto error;
@@ -944,7 +945,11 @@ init_ide (PedDevice* dev)
if (!_device_open_ro (dev))
goto error;
- if (ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi)) {
+ r = ioctl (arch_specific->fd, HDIO_GET_IDENTITY, &hdi);
+ if (r && errno == EINVAL) {
+ /* silently ignore unsupported ioctl */
+ dev->model = strdup(_("Generic IDE"));
+ } else if (r) {
ex_status = ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_IGNORE_CANCEL,

View File

@ -9,11 +9,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 1aef651..cf6c754 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2439,6 +2439,7 @@ _device_get_part_path (PedDevice const *dev, int num)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2489,6 +2489,7 @@ _device_get_part_path (PedDevice const *
dev->type == PED_DEVICE_CPQARRAY ||
dev->type == PED_DEVICE_DAC960 ||
dev->type == PED_DEVICE_NVME ||

View File

@ -6,11 +6,11 @@ Patch-mainline: no, required to fix custom SUSE device naming
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e9a694e..69176c6 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2414,6 +2414,7 @@ _device_get_part_path (PedDevice const *dev, int num)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2488,6 +2488,7 @@ _device_get_part_path (PedDevice const *
if (dev->type == PED_DEVICE_ATARAID ||
dev->type == PED_DEVICE_CPQARRAY ||
dev->type == PED_DEVICE_DAC960 ||

View File

@ -1,30 +0,0 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 10 Mar 2016 14:18:52 +0100
Subject: libparted: Fix starting CHS in protective MBR
References: bsc#969165
Patch-mainline: v3.3
Git-commit: df6770d213b60320426a3ee0bed118d063b40fc5
The CHS address for protective partition start in protective MBR
should be 0/0/2, according to UEFI spec (v2.6, section 5.2.1).
* libparted/labels/gpt.c (_write_pmbr): Fix starting CHS address
Reported by Steffen Winterfeldt in https://bugzilla.suse.com/969165
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libparted/labels/gpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1143,7 +1143,7 @@ _write_pmbr (PedDevice *dev, bool pmbr_b
pmbr->Signature = PED_CPU_TO_LE16 (MSDOS_MBR_SIGNATURE);
pmbr->PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
- pmbr->PartitionRecord[0].StartSector = 1;
+ pmbr->PartitionRecord[0].StartSector = 2;
pmbr->PartitionRecord[0].EndHead = 0xFE;
pmbr->PartitionRecord[0].EndSector = 0xFF;
pmbr->PartitionRecord[0].EndTrack = 0xFF;

View File

@ -1,67 +0,0 @@
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

View File

@ -5,8 +5,10 @@ Patch-mainline: no, upstream does not use BLKRRPART and leaves DASDs broken
libparted/arch/linux.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -39,6 +39,7 @@
#include <sys/stat.h>
#include <sys/types.h>
@ -14,8 +16,8 @@ Patch-mainline: no, upstream does not use BLKRRPART and leaves DASDs broken
+#include <sys/file.h>
#include <scsi/scsi.h>
#include <assert.h>
#ifdef ENABLE_DEVICE_MAPPER
@@ -3102,14 +3103,15 @@ static int
#include <sys/sysmacros.h>
@@ -3242,14 +3243,15 @@ static int
_kernel_reread_part_table (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
@ -34,7 +36,7 @@ Patch-mainline: no, upstream does not use BLKRRPART and leaves DASDs broken
if (!retry_count) {
ped_exception_throw (
@@ -3119,10 +3121,12 @@ _kernel_reread_part_table (PedDevice* de
@@ -3259,10 +3261,12 @@ _kernel_reread_part_table (PedDevice* de
"table on %s (%s). As a result, it may not "
"reflect all of your changes until after reboot."),
dev->path, strerror (errno));

View File

@ -1,31 +0,0 @@
From: Phillip Susi <psusi@ubuntu.com>
Date: Mon, 4 Nov 2013 13:10:09 -0500
Subject: libparted: make sure not to treat percentages as exact
Patch-mainline: v3.2, custom part from puzel still required
Git-commit: 01900e056ec250836d15b5f5c3f59a8e1454b781
If 1% of the drive size worked out ot be an even power of
two, it would trigger the exact placement. Add an exception
for the percent units.
Petr Uzel <puzel@suse.cz>:
Also avoid this logic when the unit is specified as cylinders.
---
libparted/unit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: parted-3.2/libparted/unit.c
===================================================================
--- parted-3.2.orig/libparted/unit.c
+++ parted-3.2/libparted/unit.c
@@ -551,7 +551,9 @@ ped_unit_parse_custom (const char* str,
do not use 4MiB as the range. Rather, presume that they
are specifying precisely the starting or ending number,
and treat "4MiB" just as we would treat "4194304B". */
- if (is_power_of_2 (unit_size) && unit != PED_UNIT_PERCENT)
+ if (is_power_of_2 (unit_size) &&
+ unit != PED_UNIT_PERCENT &&
+ unit != PED_UNIT_CYLINDER)
radius = 0;
*sector = num * unit_size / dev->sector_size;

View File

@ -18,11 +18,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
libparted/arch/linux.h | 1 +
2 files changed, 31 insertions(+), 3 deletions(-)
Index: parted-3.2/libparted/arch/linux.c
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -295,6 +295,9 @@ static unsigned int _device_get_partitio
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -298,6 +298,9 @@ static unsigned int _device_get_partitio
static int _device_open (PedDevice* dev, int flags);
static int _device_open_ro (PedDevice* dev);
static int _device_close (PedDevice* dev);
@ -32,8 +32,8 @@ Index: parted-3.2/libparted/arch/linux.c
static int
_read_fd (int fd, char **buf)
@@ -442,6 +445,22 @@ _is_virtblk_major (int major)
return _major_type_in_devices (major, "virtblk");
@@ -451,6 +454,22 @@ _is_blkext_major (int major)
return _major_type_in_devices (major, "blkext");
}
+static void
@ -55,7 +55,7 @@ Index: parted-3.2/libparted/arch/linux.c
#ifdef ENABLE_DEVICE_MAPPER
static int
_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
@@ -1603,7 +1622,7 @@ _flush_cache (PedDevice* dev)
@@ -1678,7 +1697,7 @@ _flush_cache (PedDevice* dev)
if (!name)
break;
if (!_partition_is_mounted_by_path (name)) {
@ -64,7 +64,7 @@ Index: parted-3.2/libparted/arch/linux.c
if (fd > 0) {
ioctl (fd, BLKFLSBUF);
retry:
@@ -1634,7 +1653,7 @@ _device_open_ro (PedDevice* dev)
@@ -1709,7 +1728,7 @@ _device_open_ro (PedDevice* dev)
static int
linux_open (PedDevice* dev)
{
@ -73,7 +73,7 @@ Index: parted-3.2/libparted/arch/linux.c
}
static int
@@ -1672,6 +1691,10 @@ retry:
@@ -1747,6 +1766,10 @@ retry:
}
} else {
dev->read_only = 0;
@ -84,7 +84,7 @@ Index: parted-3.2/libparted/arch/linux.c
}
_flush_cache (dev);
@@ -1907,6 +1930,7 @@ _write_lastoddsector (PedDevice* dev, co
@@ -1984,6 +2007,7 @@ _write_lastoddsector (PedDevice* dev, co
PED_ASSERT(dev != NULL);
PED_ASSERT(buffer != NULL);
@ -92,7 +92,7 @@ Index: parted-3.2/libparted/arch/linux.c
arch_specific = LINUX_SPECIFIC (dev);
@@ -1955,6 +1979,9 @@ linux_write (PedDevice* dev, const void*
@@ -2032,6 +2056,9 @@ linux_write (PedDevice* dev, const void*
return 1;
}
@ -102,7 +102,7 @@ Index: parted-3.2/libparted/arch/linux.c
if (_get_linux_version() < KERNEL_VERSION (2,6,0)) {
/* Kludge. This is necessary to read/write the last
block of an odd-sized disk, until Linux 2.5.x kernel fixes.
@@ -2480,6 +2507,7 @@ _blkpg_part_command (PedDevice* dev, str
@@ -2570,6 +2597,7 @@ _blkpg_part_command (PedDevice* dev, str
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
struct blkpg_ioctl_arg ioctl_arg;
@ -110,10 +110,10 @@ Index: parted-3.2/libparted/arch/linux.c
ioctl_arg.op = op;
ioctl_arg.flags = 0;
ioctl_arg.datalen = sizeof (struct blkpg_partition);
Index: parted-3.2/libparted/arch/linux.h
Index: parted-3.3/libparted/arch/linux.h
===================================================================
--- parted-3.2.orig/libparted/arch/linux.h
+++ parted-3.2/libparted/arch/linux.h
--- parted-3.3.orig/libparted/arch/linux.h
+++ parted-3.3/libparted/arch/linux.h
@@ -30,6 +30,7 @@ struct _LinuxSpecific {
int fd;
int major;
@ -122,13 +122,13 @@ Index: parted-3.2/libparted/arch/linux.h
char* dmtype; /**< device map target type */
#if defined __s390__ || defined __s390x__
unsigned int real_sector_size;
Index: parted-3.2/libparted/labels/dasd.c
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.2.orig/libparted/labels/dasd.c
+++ parted-3.2/libparted/labels/dasd.c
@@ -639,6 +639,10 @@ dasd_write (const PedDisk* disk)
if (disk_specific->format_type == 1)
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -637,6 +637,10 @@ dasd_write (const PedDisk* disk)
return 1;
}
+ /* Ensure the device is open RW */
+ char dummy[10]; /* to avoid assertion in ped_device_write */
@ -136,4 +136,4 @@ Index: parted-3.2/libparted/labels/dasd.c
+
/* initialize the anchor */
fdasd_initialize_anchor(&anchor);
fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)

View File

@ -18,11 +18,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
libparted/arch/linux.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 0f18904..cad5159 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2342,11 +2342,17 @@ _device_get_part_path (PedDevice const *dev, int num)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2456,11 +2456,17 @@ _device_get_part_path (PedDevice const *
result = zasprintf ("%.*s/part%d",
(int) (path_len - 5), devpath, num);
} else {
@ -44,8 +44,8 @@ index 0f18904..cad5159 100644
+ ? "p" : "");
result = zasprintf ("%s%s%d", devpath, p, num);
}
if (dev->type == PED_DEVICE_DM)
@@ -2797,7 +2803,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part)
#ifdef ENABLE_DEVICE_MAPPER
@@ -2927,7 +2933,7 @@ _dm_add_partition (PedDisk* disk, const
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,
@ -54,7 +54,7 @@ index 0f18904..cad5159 100644
part->num);
if (vol_name == NULL)
goto err;
@@ -2870,7 +2876,7 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part)
@@ -3004,7 +3010,7 @@ _dm_resize_partition (PedDisk* disk, con
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,

View File

@ -1,213 +0,0 @@
From: Arvin Schnell <aschnell@suse.com>
Date: Thu, 22 Dec 2016 14:36:43 -0800
Subject: libparted: set swap flag on GPT partitions
References: fate#314888, bsc#1044536
Patch-mainline: v3.3
Git-commit: c7ce5d48f6facccf617467d79c68ccce0bc27dcd
The filesystem type is still detected as befor, but now setting the
'swap' flag will set the partition GUID to PARTITION_SWAP_GUID.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
[sparschauer: Drop setting PARTITION_SWAP_GUID when the FS is swap]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/gpt.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -290,6 +290,7 @@ typedef struct _GPTPartitionData
efi_char16_t name[37];
char *translated_name;
int lvm;
+ int swap;
int raid;
int boot;
int bios_grub;
@@ -818,7 +819,8 @@ _parse_part_entry (PedDisk *disk, GuidPa
gpt_part_data->name[i] = 0;
gpt_part_data->translated_name = 0;
- gpt_part_data->lvm = gpt_part_data->raid
+ gpt_part_data->lvm = gpt_part_data->swap
+ = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
= gpt_part_data->hidden = gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -841,6 +843,8 @@ _parse_part_entry (PedDisk *disk, GuidPa
gpt_part_data->raid = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
gpt_part_data->lvm = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID))
+ gpt_part_data->swap = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
gpt_part_data->hp_service = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
@@ -1361,6 +1365,7 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
gpt_part_data->lvm = 0;
+ gpt_part_data->swap = 0;
gpt_part_data->raid = 0;
gpt_part_data->boot = 0;
gpt_part_data->bios_grub = 0;
@@ -1449,6 +1454,11 @@ gpt_partition_set_system (PedPartition *
gpt_part_data->type = PARTITION_LVM_GUID;
return 1;
}
+ if (gpt_part_data->swap)
+ {
+ gpt_part_data->type = PARTITION_SWAP_GUID;
+ return 1;
+ }
if (gpt_part_data->raid)
{
gpt_part_data->type = PARTITION_RAID_GUID;
@@ -1513,11 +1523,6 @@ gpt_partition_set_system (PedPartition *
gpt_part_data->type = PARTITION_APPLE_HFS_GUID;
return 1;
}
- if (strstr (fs_type->name, "swap"))
- {
- gpt_part_data->type = PARTITION_SWAP_GUID;
- return 1;
- }
}
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
@@ -1636,6 +1641,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1650,6 +1656,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->boot
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1664,6 +1671,7 @@ gpt_partition_set_flag (PedPartition *pa
if (state)
gpt_part_data->boot
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1677,6 +1685,22 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->lvm = state;
if (state)
gpt_part_data->boot
+ = gpt_part_data->swap
+ = gpt_part_data->raid
+ = gpt_part_data->bios_grub
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres
+ = gpt_part_data->msftdata
+ = gpt_part_data->msftrecv
+ = gpt_part_data->prep
+ = gpt_part_data->irst
+ = gpt_part_data->atvrecv = 0;
+ return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_SWAP:
+ gpt_part_data->swap = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->lvm
= gpt_part_data->raid
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
@@ -1693,6 +1717,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->msftres
= gpt_part_data->msftdata
@@ -1707,6 +1732,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1721,6 +1747,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1739,6 +1766,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftdata
@@ -1753,6 +1781,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1766,6 +1795,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1779,6 +1809,7 @@ gpt_partition_set_flag (PedPartition *pa
gpt_part_data->boot
= gpt_part_data->raid
= gpt_part_data->lvm
+ = gpt_part_data->swap
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
= gpt_part_data->msftres
@@ -1793,7 +1824,6 @@ gpt_partition_set_flag (PedPartition *pa
case PED_PARTITION_LEGACY_BOOT:
gpt_part_data->legacy_boot = state;
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:
@@ -1839,6 +1869,7 @@ gpt_partition_get_flag (const PedPartiti
case PED_PARTITION_IRST:
return gpt_part_data->irst;
case PED_PARTITION_SWAP:
+ return gpt_part_data->swap;
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
default:
@@ -1855,6 +1886,7 @@ gpt_partition_is_flag_available (const P
{
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
+ case PED_PARTITION_SWAP:
case PED_PARTITION_BOOT:
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
@@ -1868,7 +1900,6 @@ gpt_partition_is_flag_available (const P
case PED_PARTITION_IRST:
case PED_PARTITION_ESP:
return 1;
- case PED_PARTITION_SWAP:
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
default:

View File

@ -1,23 +0,0 @@
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 24 Mar 2018 17:37:02 +0000
Subject: linux: Include <sys/sysmacros.h> for major() macro.
Patch-mainline: v3.3
Git-commit: ba5e0451b51c983e40afd123b6e0d3eddb55e610
Since glibc 2.27 this header is required.
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -42,6 +42,7 @@
#include <sys/file.h>
#include <scsi/scsi.h>
#include <assert.h>
+#include <sys/sysmacros.h>
#ifdef ENABLE_DEVICE_MAPPER
#include <libdevmapper.h>
#endif

View File

@ -11,11 +11,11 @@ and some fixups on top
libparted/arch/linux.c | 50 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
Index: parted-3.2/libparted/arch/linux.c
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -3097,6 +3097,34 @@ _disk_sync_part_table (PedDisk* disk)
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3239,6 +3239,34 @@ _disk_sync_part_table (PedDisk* disk)
}
static int
@ -50,19 +50,18 @@ Index: parted-3.2/libparted/arch/linux.c
_have_blkpg ()
{
static int have_blkpg = -1;
@@ -3114,15 +3142,19 @@ static int
linux_disk_commit (PedDisk* disk)
@@ -3257,14 +3285,19 @@ linux_disk_commit (PedDisk* disk)
{
if (disk->dev->type != PED_DEVICE_FILE) {
- /* We now require BLKPG support. If this assertion fails,
- please write to the mailing list describing your system.
- Assuming it's never triggered, ...
- FIXME: remove this assertion in 2012. */
- assert (_have_blkpg ());
-
- /* We now require BLKPG support. If this assertion fails,
- please write to the mailing list describing your system.
- Assuming it's never triggered, ...
- FIXME: remove this assertion in 2012. */
- assert (_have_blkpg ());
-
- if (!_disk_sync_part_table (disk))
- return 0;
- if (!_disk_sync_part_table (disk))
- return 0;
+ /* The ioctl() command BLKPG_ADD_PARTITION does not notify
+ * the devfs system; consequently, /proc/partitions will not
+ * be up to date, and the proper links in /dev are not
@ -70,12 +69,12 @@ Index: parted-3.2/libparted/arch/linux.c
+ * to re-read and grok the partition table.
+ */
+ /* Work around kernel dasd problem so we really do BLKRRPART */
+ if (disk->dev->type == PED_DEVICE_DASD)
+ return _kernel_reread_part_table(disk->dev);
+ if (disk->dev->type == PED_DEVICE_DASD)
+ return _kernel_reread_part_table(disk->dev);
+
+ assert(_have_blkpg());
+ if (!_disk_sync_part_table(disk))
+ return 0;
+ assert(_have_blkpg());
+ if (!_disk_sync_part_table(disk))
+ return 0;
}
return 1;

View File

@ -19,10 +19,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
libparted/disk.c | 15 +++++++++++++--
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index b42e7cf..ac57d68 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -195,6 +195,7 @@ struct _PedDisk {
int update_mode; /**< mode without free/metadata
partitions, for easier
@ -31,14 +31,15 @@ index b42e7cf..ac57d68 100644
};
struct _PedDiskOps {
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 461c095..d7d37e7 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -3264,14 +3264,15 @@ static int
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3324,15 +3324,15 @@ static int
linux_disk_commit (PedDisk* disk)
{
if (disk->dev->type != PED_DEVICE_FILE) {
-
- /* The ioctl() command BLKPG_ADD_PARTITION does not notify
- * the devfs system; consequently, /proc/partitions will not
- * be up to date, and the proper links in /dev are not
@ -52,16 +53,16 @@ index 461c095..d7d37e7 100644
+ * and grok the partition table.
*/
/* Work around kernel dasd problem so we really do BLKRRPART */
- if (disk->dev->type == PED_DEVICE_DASD)
+ if (disk->dev->type == PED_DEVICE_DASD && disk->needs_blkrrpart)
return _kernel_reread_part_table(disk->dev);
- if (disk->dev->type == PED_DEVICE_DASD)
+ if (disk->dev->type == PED_DEVICE_DASD && disk->needs_blkrrpart)
return _kernel_reread_part_table(disk->dev);
assert(_have_blkpg());
diff --git a/libparted/disk.c b/libparted/disk.c
index 18cee12..03f8548 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -406,6 +406,7 @@ _ped_disk_alloc (const PedDevice* dev, const PedDiskType* disk_type)
assert(_have_blkpg());
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -407,6 +407,7 @@ _ped_disk_alloc (const PedDevice* dev, c
disk->update_mode = 1;
disk->part_list = NULL;
disk->needs_clobber = 0;
@ -69,7 +70,7 @@ index 18cee12..03f8548 100644
return disk;
error:
@@ -1733,8 +1734,12 @@ _disk_raw_remove (PedDisk* disk, PedPartition* part)
@@ -1734,8 +1735,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
if (part->prev) {
part->prev->next = part->next;
@ -83,7 +84,7 @@ index 18cee12..03f8548 100644
} else {
if (part->type & PED_PARTITION_LOGICAL) {
ped_disk_extended_partition (disk)->part_list
@@ -1742,8 +1747,12 @@ _disk_raw_remove (PedDisk* disk, PedPartition* part)
@@ -1743,8 +1748,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
} else {
disk->part_list = part->next;
}
@ -97,7 +98,7 @@ index 18cee12..03f8548 100644
}
return 1;
@@ -1773,6 +1782,8 @@ _disk_raw_add (PedDisk* disk, PedPartition* part)
@@ -1774,6 +1783,8 @@ _disk_raw_add (PedDisk* disk, PedPartiti
}
if (walk) {

View File

@ -15,11 +15,11 @@ It consists of 2 quite unrelated parts:
parted/parted.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
Index: parted-3.2/libparted/arch/linux.c
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.2.orig/libparted/arch/linux.c
+++ parted-3.2/libparted/arch/linux.c
@@ -3011,7 +3011,7 @@ _disk_sync_part_table (PedDisk* disk)
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3153,7 +3153,7 @@ _disk_sync_part_table (PedDisk* disk)
/* Attempt to remove the partition, retrying for
up to max_sleep_seconds upon any failure due to EBUSY. */
unsigned int sleep_microseconds = 10000;
@ -28,11 +28,11 @@ Index: parted-3.2/libparted/arch/linux.c
unsigned int n_sleep = (max_sleep_seconds
* 1000000 / sleep_microseconds);
do {
Index: parted-3.2/parted/parted.c
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -266,6 +266,32 @@ _disk_warn_loss (PedDisk* disk)
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -267,6 +267,32 @@ _disk_warn_loss (PedDisk* disk)
disk->dev->path) == PED_EXCEPTION_YES;
}
@ -65,7 +65,7 @@ Index: parted-3.2/parted/parted.c
/* This function changes "sector" to "new_sector" if the new value lies
* within the required range.
*/
@@ -1735,7 +1761,7 @@ do_set (PedDevice** dev, PedDisk **diskp
@@ -1791,7 +1817,7 @@ do_set (PedDevice** dev, PedDisk **diskp
if (!ped_partition_set_flag (part, flag, state))
goto error;

View File

@ -5,11 +5,11 @@ Patch-mainline: no, custom SUSE patch
configure.ac | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: parted-3.2/configure.ac
Index: parted-3.3/configure.ac
===================================================================
--- parted-3.2.orig/configure.ac
+++ parted-3.2/configure.ac
@@ -165,7 +165,8 @@ AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
--- parted-3.3.orig/configure.ac
+++ parted-3.3/configure.ac
@@ -151,7 +151,8 @@ AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
dnl Check for programs.
AC_ISC_POSIX
@ -19,7 +19,7 @@ Index: parted-3.2/configure.ac
AC_PROG_GCC_TRADITIONAL
AM_PROG_CC_C_O
@@ -377,7 +378,7 @@ dnl Check for termcap
@@ -331,7 +332,7 @@ dnl Check for termcap
if test "$with_readline" = yes; then
OLD_LIBS="$LIBS"
LIBS=""

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:858b589c22297cacdf437f3baff6f04b333087521ab274f7ab677cb8c6bb78e4
size 1655244

View File

@ -1,11 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQEcBAABCgAGBQJT1xMSAAoJEI5FoCIzSKrwifgH/3RPcmdiLuBG1CFhSwvFMDE4
0+cOupMjmPvLXjjj1wVD1svj5MF5R/Hejd2GzOfZZ1OOZD/1asgBCteh3RLXvj00
gE8vTv9MsYeO6C3IiNNy8KwAi1XMDD/75WyOxgStTZuDaspczyRxtYgHUk/vHRdf
btpkf2fuzSX4EskU5U4QetJgjmVUee0bGafC1CGLdxKTwxY2At4uf9TX+Y4us8Ym
EEqdQyeF8OV/wcGJq8aRkbZbHPVtI1id4IS8X7RxTmJtRHp13/WcYo/vkQUm1BUt
RFFeCCE65PxY33jYSYIJCSrfr1LLvzM2LCfEXNduLXUiKwz54/72j5HBkjeKYps=
=vEMW
-----END PGP SIGNATURE-----

3
parted-3.3.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:57e2b4bd87018625c515421d4524f6e3b55175b472302056391c5f7eccb83d44
size 1757432

11
parted-3.3.tar.xz.sig Normal file
View File

@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----
iQFDBAABCgAtFiEEtMa0UeT6i0IyyhkeEX6MFo7+On8FAl2fxMwPHGJjbEByZWRo
YXQuY29tAAoJEBF+jBaO/jp/bygH/ReO2REK9e3YvbNmJmI4jRsiS6KHJ7ufVHAW
DwFHE6TvD8c0EG5RcZNwJUNB2rLUs+RlZCVxU/qzN+nPlZJNXVqjpIZOwNn9H9op
vqLk/Ja6FzvIDPeyes3HTZFojdLZSLvJ5WUnFf/ZKiiJCM2Qgxy3bp/mmBL9niQb
jEr3UUHzVxfMHBFIqnY81+HriBZGCD+vmcKPZ5iMtb4LhHl+WeiFXByS3j4ZrVcg
NvnyjDQgPJj7oKFGgTfbaZs/d9LCE9XAudYUUTszlEajN2JsNEud4jse19EHeLzd
Gd7gR4NFK0k1qhOvi9GaBReMiW7YzX6xey3oxBKdNRHmu8wGhSA=
=i81F
-----END PGP SIGNATURE-----

View File

@ -19,10 +19,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
parted/parted.c | 16 ++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index e2a24dc..ff01162 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
Index: parted-3.3/doc/C/parted.8
===================================================================
--- parted-3.3.orig/doc/C/parted.8
+++ parted-3.3/doc/C/parted.8
@@ -30,6 +30,9 @@ never prompts for user intervention
.B -v, --version
displays the version
@ -33,11 +33,11 @@ index e2a24dc..ff01162 100644
.B --wipesignatures
mkpart wipes the superblock signatures from the disk region where it is
about to create the partition
diff --git a/parted/parted.c b/parted/parted.c
index 3d7ec4b..3cc8f77 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -76,7 +76,8 @@ static int MEGABYTE_SECTORS (PedDevice* dev)
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -76,7 +76,8 @@ static int MEGABYTE_SECTORS (PedDevice*
enum
{
PRETEND_INPUT_TTY = CHAR_MAX + 1,
@ -55,7 +55,7 @@ index 3d7ec4b..3cc8f77 100644
{"wipesignatures", 0, NULL, WIPESIGNATURES},
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
{NULL, 0, NULL, 0}
@@ -130,10 +132,13 @@ static const char *const options_help [][2] = {
@@ -130,10 +132,13 @@ static const char *const options_help []
{"script", N_("never prompts for user intervention")},
{"version", N_("displays the version")},
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
@ -77,7 +77,7 @@ index 3d7ec4b..3cc8f77 100644
static const char* number_msg = N_(
"NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
@@ -513,12 +519,17 @@ print_options_help ()
@@ -514,12 +520,17 @@ print_options_help ()
{
int i;
@ -96,7 +96,7 @@ index 3d7ec4b..3cc8f77 100644
}
int
@@ -2244,6 +2255,7 @@ while (1)
@@ -2299,6 +2310,7 @@ while (1)
alignment = XARGMATCH ("--align", optarg,
align_args, align_types);
break;

View File

@ -1,40 +0,0 @@
From d7a2ff17b15842bf9a3de65ca1ba577bdf568e79 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:08 +0100
Subject: [PATCH] parted: check the name of partition first when to name a
partition
The previous function works well for the labels supporting naming
partition, but not for these which don't. If the disk label does not
support partition naming, two exceptions will be raised. Even after the first
error indicates it does not support name, parted yet asks user for
name in iteractive mode.
First check if the disk label supports partition naming and if it
does, it will continue; otherwise, it will stop and raise an
exception.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/parted.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -930,6 +930,13 @@ do_name (PedDevice** dev, PedDisk** disk
if (!diskp)
goto error;
+ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_NAME)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("%s disk labels do not support partition name."),
+ (*diskp)->type->name);
+ goto error;
+ }
+
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
goto error;

View File

@ -1,39 +0,0 @@
From 624a8b14af7d358782ecc12627c84da72c28aeff Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Tue, 13 Jan 2015 11:05:48 -0500
Subject: [PATCH] parted: don't crash in disk_set when disk label not found
Due to a typeo in commit 7eac058 "parted: don't reload partition
table on every command", the disk_set command would crash if
a disk label was not found.
---
NEWS | 2 ++
parted/parted.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
Index: parted-3.2/NEWS
===================================================================
--- parted-3.2.orig/NEWS
+++ parted-3.2/NEWS
@@ -162,6 +162,8 @@ GNU parted NEWS
** Bug Fixes
+ Don't crash in the disk_set command when a disk label is not found
+
libparted-fs-resize: Prevent crash resizing FAT16 file systems.
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -1708,7 +1708,7 @@ do_disk_set (PedDevice** dev, PedDisk**
if (!*diskp)
*diskp = ped_disk_new (*dev);
- if (!diskp)
+ if (!*diskp)
goto error;
if (!command_line_get_disk_flag (_("Flag to Invert?"), *diskp, &flag))

View File

@ -21,9 +21,11 @@ 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
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -1053,6 +1053,30 @@ _print_disk_geometry (const PedDevice *d
free (cyl_size);
}
@ -54,7 +56,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
static void
_print_disk_info (const PedDevice *dev, const PedDisk *diskp)
{
@@ -1058,6 +1082,8 @@ _print_disk_info (const PedDevice *dev,
@@ -1073,6 +1097,8 @@ _print_disk_info (const PedDevice *dev,
char *disk_flags = disk_print_flags (diskp);
if (opt_machine_mode) {
@ -63,7 +65,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
switch (default_unit) {
case PED_UNIT_CHS: puts ("CHS;");
break;
@@ -1068,9 +1094,10 @@ _print_disk_info (const PedDevice *dev,
@@ -1083,9 +1109,10 @@ _print_disk_info (const PedDevice *dev,
}
printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",

View File

@ -17,10 +17,10 @@ Upstream: https://github.com/ya-mouse/fatresize
configure.ac | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
Index: parted-3.1/Makefile.am
Index: parted-3.3/Makefile.am
===================================================================
--- parted-3.1.orig/Makefile.am
+++ parted-3.1/Makefile.am
--- parted-3.3.orig/Makefile.am
+++ parted-3.3/Makefile.am
@@ -1,5 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = po lib include libparted parted partprobe doc debug tests
@ -28,12 +28,12 @@ Index: parted-3.1/Makefile.am
EXTRA_DIST = \
.version \
Index: parted-3.1/configure.ac
Index: parted-3.3/configure.ac
===================================================================
--- parted-3.1.orig/configure.ac
+++ parted-3.1/configure.ac
@@ -610,6 +610,7 @@ libparted/tests/Makefile
libparted.pc
--- parted-3.3.orig/configure.ac
+++ parted-3.3/configure.ac
@@ -571,6 +571,7 @@ libparted.pc
libparted-fs-resize.pc
parted/Makefile
partprobe/Makefile
+fatresize/Makefile

View File

@ -1,94 +0,0 @@
From 149f009c3b4ab6bac8059b48142a1c3f698c8e53 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 23 Dec 2016 06:53:36 +0100
Subject: [PATCH] parted: fix crash due to improper partition number input
When the user makes a new partition, if parted fails to add the
partition to disk, it jumps to wrong error label. In this
situation, this new partition actually is not a node in disk
data structure. But in the wrong error label, it pretends this
is a node and removes it as a list node, leading to other
partition in this disk deleted. This might lead to a memory leak.
Because if there are other partitions, it just removes them from
list without releasing the resource. And this also leads to different
disk information between memory and device. This is confusing.
But when the new partition is added to disk successfully and if
any operations followed fail, this partition should be removed from
disk and destroyed.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/ui.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
Index: parted-3.2/parted/ui.c
===================================================================
--- parted-3.2.orig/parted/ui.c
+++ parted-3.2/parted/ui.c
@@ -29,6 +29,8 @@
#include <unistd.h>
#include <setjmp.h>
#include <assert.h>
+#include <limits.h>
+#include <errno.h>
#include "command.h"
#include "strlist.h"
@@ -912,16 +914,34 @@ command_line_get_integer (const char* pr
{
char def_str [10];
char* input;
- int valid;
+ long ret;
snprintf (def_str, 10, "%d", *value);
input = command_line_get_word (prompt, *value ? def_str : NULL,
NULL, 1);
if (!input)
return 0;
- valid = sscanf (input, "%d", value);
+
+ errno = 0;
+
+ if (strstr(input, "0x") == input)
+ ret = strtol (input, (char**) NULL, 16);
+ else
+ ret = strtol (input, (char**) NULL, 10);
+ if (errno)
+ goto error;
+
+ if ((ret > INT_MAX) || (ret < INT_MIN))
+ goto error;
+ else
+ *value = (int) ret;
+
free (input);
- return valid;
+ return 1;
+
+error:
+ free (input);
+ return 0;
}
int
@@ -1031,6 +1051,7 @@ command_line_get_partition (const char*
PedPartition** value)
{
PedPartition* part;
+ int ret;
/* Flawed logic, doesn't seem to work?!
check = ped_disk_next_partition (disk, part);
@@ -1047,7 +1068,8 @@ command_line_get_partition (const char*
*/
int num = (*value) ? (*value)->num : 0;
- if (!command_line_get_integer (prompt, &num)) {
+ ret = command_line_get_integer (prompt, &num);
+ if ((!ret) || (num < 0)) {
ped_exception_throw (PED_EXCEPTION_ERROR,
PED_EXCEPTION_CANCEL,
_("Expecting a partition number."));

View File

@ -0,0 +1,31 @@
From: Brian C. Lane <bcl@redhat.com>
Date: Tue Apr 23 13:52:25 2019 -0700
Subject: Fix end_input usage in do_resizepart
Patch-mainline: v4.4
Git-commit: ca845aeeddb17343c9289816833ca352f7c0d87b
Fix end_input usage in do_resizepart
It needs to be set to NULL, since it may not get set by the call to
command_line_get_sector
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -1667,6 +1667,7 @@ do_resizepart (PedDevice** dev, PedDisk*
const int end_idx = 2;
const bool danger_if_busy = false;
int rc = 0;
+ char* end_input = NULL;
if (!disk) {
disk = ped_disk_new (*dev);
@@ -1688,7 +1689,6 @@ do_resizepart (PedDevice** dev, PedDisk*
start = part->geom.start;
end = oldend = part->geom.end;
- char *end_input;
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);

View File

@ -29,11 +29,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
parted/parted.c | 39 ++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 3cc8f77..2e31659 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -228,13 +228,19 @@ _timer_handler (PedTimer* timer, void* context)
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -229,13 +229,19 @@ _timer_handler (PedTimer* timer, void* c
}
static int
@ -55,7 +55,7 @@ index 3cc8f77..2e31659 100644
PED_EXCEPTION_WARNING,
PED_EXCEPTION_YES_NO,
_("Partition %s is being used. Are you sure you " \
@@ -1634,6 +1640,11 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
@@ -1655,6 +1661,11 @@ do_resizepart (PedDevice** dev, PedDisk*
PedSector start, end, oldend;
PedGeometry *range_end = NULL;
PedConstraint* constraint;
@ -67,19 +67,20 @@ index 3cc8f77..2e31659 100644
int rc = 0;
if (!disk) {
@@ -1650,26 +1661,39 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
@@ -1671,7 +1682,8 @@ do_resizepart (PedDevice** dev, PedDisk*
if (!command_line_get_partition (_("Partition number?"), disk, &part))
goto error;
- if (!_partition_warn_busy (part))
+ /* warn early if the partition end is not provided on cmdline */
+ /* warn early if the partition end is not provided on cmdline */
+ if (cmdline_words <= part_idx && !_partition_warn_busy (part, danger_if_busy))
goto error;
-
start = part->geom.start;
end = oldend = part->geom.end;
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
@@ -1681,19 +1693,32 @@ do_resizepart (PedDevice** dev, PedDisk*
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);
free(end_input);
+ if (cmdline_words >= end_idx && !_partition_warn_busy (part, danger_if_busy))
+ goto error;
+
@ -92,26 +93,27 @@ index 3cc8f77..2e31659 100644
- if (part->geom.end < oldend)
- if (ped_exception_throw (
+ if (part->geom.end < oldend) {
+ if (opt_script_mode && (!ped_partition_is_busy (part) || ignore_busy)) {
+ char *path = ped_partition_get_path (part);
+ if (opt_script_mode && (!ped_partition_is_busy (part) || ignore_busy)) {
+ char *path = ped_partition_get_path (part);
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_UNHANDLED,
+ _("Shrinking partition %s, data loss possible."), path);
+ free(path);
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_UNHANDLED,
+ _("Shrinking partition %s, data loss possible."), path);
+ free(path);
+ } else if (ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_YES_NO,
_("Shrinking a partition can cause data loss, " \
"are you sure you want to continue?")) != PED_EXCEPTION_YES)
+ {
goto error_destroy_constraint;
+ }
- goto error_destroy_constraint;
+ {
+ goto error_destroy_constraint;
+ }
+ }
ped_disk_commit (disk);
if ((*dev)->type != PED_DEVICE_FILE)
@@ -1690,6 +1714,7 @@ static int
@@ -1714,6 +1739,7 @@ static int
do_rm (PedDevice** dev, PedDisk** diskp)
{
PedPartition* part = NULL;
@ -119,7 +121,7 @@ index 3cc8f77..2e31659 100644
if (!*diskp)
*diskp = ped_disk_new (*dev);
@@ -1698,7 +1723,7 @@ do_rm (PedDevice** dev, PedDisk** diskp)
@@ -1722,7 +1748,7 @@ do_rm (PedDevice** dev, PedDisk** diskp)
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
goto error;
@ -127,4 +129,4 @@ index 3cc8f77..2e31659 100644
+ if (!_partition_warn_busy (part, danger_if_busy))
goto error;
ped_disk_delete_partition (*diskp, part);
if (!ped_disk_delete_partition (*diskp, part))

View File

@ -1,66 +0,0 @@
From af150f6764a08eae4b4cf448c392259c067a1523 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 23 Dec 2016 06:53:37 +0100
Subject: [PATCH] parted: fix wrong error label jump in mkpart
When the user makes a new partition, if parted fails to add the
partition to disk, it jumps to wrong error label. In this
situation, this new partition actually is not a node in disk
data structure. But in the wrong error label, it pretends this
is a node and removes it as a list node, leading to other
partition in this disk deleted. This might lead to a memory leak.
Because if there are other partitions, it just removes them from
list without releasing the resource. And this also leads to different
disk information between memory and device. This is confusing.
But when the new partition is added to disk successfully and if
any operations followed fail, this partition should be removed from
disk and destroyed.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/parted.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -796,7 +796,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
ped_constraint_destroy (constraint_any);
if (!added_ok)
- goto error_remove_part;
+ goto error_destroy_simple_constraints;
if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
!ped_geometry_test_sector_inside(range_end, part->geom.end)) {
@@ -865,7 +865,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
free (part_name); /* avoid double-free upon failure */
part_name = NULL;
if (!ped_partition_set_system (part, fs_type))
- goto error;
+ goto error_remove_part;
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
if (ped_partition_is_flag_available (part, PED_PARTITION_SWAP) &&
@@ -881,7 +881,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
}
if (!ped_disk_commit (disk))
- goto error;
+ goto error_remove_part;
/* clean up */
if (range_start != NULL)
@@ -904,7 +904,8 @@ error_remove_part:
error_destroy_simple_constraints:
ped_partition_destroy (part);
error:
- free (part_name);
+ if (part_name)
+ free (part_name);
if (range_start != NULL)
ped_geometry_destroy (range_start);
if (range_end != NULL)

View File

@ -17,8 +17,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
parted/parted.c | 16 ++++++++++++++++
5 files changed, 78 insertions(+)
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
Index: parted-3.3/doc/C/parted.8
===================================================================
--- parted-3.3.orig/doc/C/parted.8
+++ parted-3.3/doc/C/parted.8
@@ -30,6 +30,10 @@ never prompts for user intervention
.B -v, --version
displays the version
@ -30,9 +32,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
.B -a \fIalignment-type\fP, --align \fIalignment-type\fP
Set alignment for newly created partitions, valid alignment types are:
.RS
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -119,6 +119,7 @@ struct _PedDeviceArchOps {
Index: parted-3.3/include/parted/device.in.h
===================================================================
--- parted-3.3.orig/include/parted/device.in.h
+++ parted-3.3/include/parted/device.in.h
@@ -122,6 +122,7 @@ struct _PedDeviceArchOps {
/* These functions are optional */
PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
@ -40,7 +44,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
};
#include <parted/constraint.h>
@@ -155,6 +156,7 @@ extern PedConstraint *ped_device_get_opt
@@ -158,6 +159,7 @@ extern PedConstraint *ped_device_get_opt
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
@ -48,9 +52,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
/* private stuff ;-) */
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -3298,6 +3298,44 @@ linux_get_optimum_alignment(const PedDev
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3395,6 +3395,44 @@ linux_get_optimum_alignment(const PedDev
blkid_topology_get_alignment_offset(tp) / dev->sector_size,
blkid_topology_get_optimal_io_size(tp) / dev->sector_size);
}
@ -94,8 +100,8 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
+}
#endif
static PedDeviceArchOps linux_dev_ops = {
@@ -3318,6 +3356,9 @@ static PedDeviceArchOps linux_dev_ops =
#if defined __s390__ || defined __s390x__
@@ -3471,6 +3509,9 @@ static PedDeviceArchOps linux_dev_ops =
get_minimum_alignment: linux_get_minimum_alignment,
get_optimum_alignment: linux_get_optimum_alignment,
#endif
@ -105,9 +111,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
};
PedDiskArchOps linux_disk_ops = {
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -565,4 +565,21 @@ ped_device_get_optimum_alignment(const P
Index: parted-3.3/libparted/device.c
===================================================================
--- parted-3.3.orig/libparted/device.c
+++ parted-3.3/libparted/device.c
@@ -559,4 +559,21 @@ ped_device_get_optimum_alignment(const P
return align;
}
@ -129,8 +137,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
+}
+
/** @} */
--- a/parted/parted.c
+++ b/parted/parted.c
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -76,6 +76,7 @@ static int MEGABYTE_SECTORS (PedDevice*
enum
{
@ -161,7 +171,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
int opt_machine_mode = 0;
int disk_is_modified = 0;
int is_toggle_mode = 0;
@@ -650,6 +654,7 @@ _adjust_end_if_iec (PedSector* start, Pe
@@ -651,6 +655,7 @@ _adjust_end_if_iec (PedSector* start, Pe
}
}
@ -169,7 +179,7 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
static int
do_mkpart (PedDevice** dev, PedDisk** diskp)
{
@@ -840,6 +845,14 @@ do_mkpart (PedDevice** dev, PedDisk** di
@@ -848,6 +853,14 @@ do_mkpart (PedDevice** dev, PedDisk** di
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
@ -182,9 +192,9 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
+ }
+
if (!ped_disk_commit (disk))
goto error;
goto error_remove_part;
@@ -2196,6 +2209,9 @@ while (1)
@@ -2252,6 +2265,9 @@ while (1)
case PRETEND_INPUT_TTY:
pretend_input_tty = 1;
break;

View File

@ -8,10 +8,10 @@ Patch-mainline: no, custom SUSE patch
parted/parted.c | 12 ++++++++++++
4 files changed, 85 insertions(+), 3 deletions(-)
Index: parted-3.2/include/parted/disk.in.h
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.2.orig/include/parted/disk.in.h
+++ parted-3.2/include/parted/disk.in.h
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -83,10 +83,11 @@ enum _PedPartitionFlag {
enum _PedDiskTypeFeature {
@ -45,11 +45,11 @@ Index: parted-3.2/include/parted/disk.in.h
extern int ped_partition_is_busy (const PedPartition* part);
extern char* ped_partition_get_path (const PedPartition* part);
Index: parted-3.2/libparted/disk.c
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.2.orig/libparted/disk.c
+++ parted-3.2/libparted/disk.c
@@ -1184,6 +1184,39 @@ _disk_pop_update_mode (PedDisk* disk)
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -1185,6 +1185,39 @@ _disk_pop_update_mode (PedDisk* disk)
* @{
*/
@ -89,11 +89,11 @@ Index: parted-3.2/libparted/disk.c
PedPartition*
_ped_partition_alloc (const PedDisk* disk, PedPartitionType type,
const PedFileSystemType* fs_type,
Index: parted-3.2/libparted/labels/mac.c
Index: parted-3.3/libparted/labels/mac.c
===================================================================
--- parted-3.2.orig/libparted/labels/mac.c
+++ parted-3.2/libparted/labels/mac.c
@@ -1393,6 +1393,36 @@ mac_get_partition_alignment(const PedDis
--- parted-3.3.orig/libparted/labels/mac.c
+++ parted-3.3/libparted/labels/mac.c
@@ -1396,6 +1396,36 @@ mac_get_partition_alignment(const PedDis
return ped_alignment_new(0, 1);
}
@ -130,7 +130,7 @@ Index: parted-3.2/libparted/labels/mac.c
static PedConstraint*
_primary_constraint (PedDisk* disk)
{
@@ -1593,6 +1623,8 @@ static PedDiskOps mac_disk_ops = {
@@ -1596,6 +1626,8 @@ static PedDiskOps mac_disk_ops = {
partition_set_name: mac_partition_set_name,
partition_get_name: mac_partition_get_name,
@ -139,7 +139,7 @@ Index: parted-3.2/libparted/labels/mac.c
get_partition_alignment: mac_get_partition_alignment,
@@ -1603,7 +1635,7 @@ static PedDiskType mac_disk_type = {
@@ -1606,7 +1638,7 @@ static PedDiskType mac_disk_type = {
next: NULL,
name: "mac",
ops: &mac_disk_ops,
@ -148,11 +148,11 @@ Index: parted-3.2/libparted/labels/mac.c
};
void
Index: parted-3.2/parted/parted.c
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -888,6 +888,7 @@ static char*
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -929,6 +929,7 @@ static char*
partition_print_flags (PedPartition const *part)
{
int xtype;
@ -160,7 +160,7 @@ Index: parted-3.2/parted/parted.c
char *res = xstrdup ("");
if (!part)
return res;
@@ -920,6 +921,17 @@ partition_print_flags (PedPartition cons
@@ -961,6 +962,17 @@ partition_print_flags (PedPartition cons
}
}

View File

@ -16,9 +16,11 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
parted/parted.c | 10 ++++++++++
1 file changed, 10 insertions(+)
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -655,6 +655,13 @@ _adjust_end_if_iec (PedSector* start, Pe
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -656,6 +656,13 @@ _adjust_end_if_iec (PedSector* start, Pe
}
@ -32,8 +34,8 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
static int
do_mkpart (PedDevice** dev, PedDisk** diskp)
{
@@ -844,6 +851,9 @@ do_mkpart (PedDevice** dev, PedDisk** di
goto error;
@@ -852,6 +859,9 @@ do_mkpart (PedDevice** dev, PedDisk** di
goto error_remove_part;
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ if (ped_partition_is_flag_available (part, PED_PARTITION_SWAP) &&

View File

@ -5,11 +5,11 @@ Patch-mainline: no, compatibility for parted < 3.0 syntax
parted/parted.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Index: parted-3.2/parted/parted.c
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -2055,9 +2055,11 @@ NULL),
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -2111,9 +2111,11 @@ NULL),
command_register (commands, command_create (
str_list_create_unique ("resize", _("resize"), NULL),

View File

@ -12,10 +12,10 @@ type for msdos partition tables.
parted/ui.c | 3 ++
5 files changed, 56 insertions(+), 23 deletions(-)
Index: parted-3.2/include/parted/disk.in.h
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.2.orig/include/parted/disk.in.h
+++ parted-3.2/include/parted/disk.in.h
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -75,10 +75,11 @@ enum _PedPartitionFlag {
PED_PARTITION_LEGACY_BOOT=15,
PED_PARTITION_MSFT_DATA=16,
@ -30,11 +30,11 @@ Index: parted-3.2/include/parted/disk.in.h
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
Index: parted-3.2/libparted/disk.c
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.2.orig/libparted/disk.c
+++ parted-3.2/libparted/disk.c
@@ -2388,6 +2388,8 @@ ped_partition_flag_get_name (PedPartitio
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -2389,6 +2389,8 @@ ped_partition_flag_get_name (PedPartitio
return N_("lba");
case PED_PARTITION_HPSERVICE:
return N_("hp-service");
@ -43,11 +43,11 @@ Index: parted-3.2/libparted/disk.c
case PED_PARTITION_PALO:
return N_("palo");
case PED_PARTITION_PREP:
Index: parted-3.2/libparted/labels/dos.c
Index: parted-3.3/libparted/labels/dos.c
===================================================================
--- parted-3.2.orig/libparted/labels/dos.c
+++ parted-3.2/libparted/labels/dos.c
@@ -1550,6 +1550,10 @@ msdos_partition_set_flag (PedPartition*
--- parted-3.3.orig/libparted/labels/dos.c
+++ parted-3.3/libparted/labels/dos.c
@@ -1565,6 +1565,10 @@ msdos_partition_set_flag (PedPartition*
disk = part->disk;
switch (flag) {
@ -58,7 +58,7 @@ Index: parted-3.2/libparted/labels/dos.c
case PED_PARTITION_HIDDEN:
if (part->type == PED_PARTITION_EXTENDED) {
ped_exception_throw (
@@ -1657,6 +1661,9 @@ msdos_partition_get_flag (const PedParti
@@ -1690,6 +1694,9 @@ msdos_partition_get_flag (const PedParti
case PED_PARTITION_LBA:
return dos_data->lba;
@ -68,7 +68,7 @@ Index: parted-3.2/libparted/labels/dos.c
case PED_PARTITION_PALO:
return dos_data->palo;
@@ -1689,6 +1696,7 @@ msdos_partition_is_flag_available (const
@@ -1728,6 +1735,7 @@ msdos_partition_is_flag_available (const
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_LBA:
@ -76,11 +76,11 @@ Index: parted-3.2/libparted/labels/dos.c
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
Index: parted-3.2/parted/parted.c
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -887,28 +887,40 @@ error:
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -928,28 +928,40 @@ error:
static char*
partition_print_flags (PedPartition const *part)
{
@ -140,7 +140,7 @@ Index: parted-3.2/parted/parted.c
}
static int
@@ -1726,12 +1738,19 @@ do_set (PedDevice** dev, PedDisk **diskp
@@ -1808,12 +1820,19 @@ do_set (PedDevice** dev, PedDisk **diskp
goto error;
if (!command_line_get_part_flag (_("Flag to Invert?"), part, &flag))
goto error;

View File

@ -1,41 +0,0 @@
From 0b7946a095f307e427b81795cbc96028ee179b91 Mon Sep 17 00:00:00 2001
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:10 +0100
Subject: [PATCH] parted/ui: remove unneccesary information of command line
When some command fails, the information still exists in
command_line buffer. When in command mode or interactive mode,
if an interactive exception prompts, the remained information
will be processed as option from user. This will raise some other
information or even unexpected results. So before getting option
input from user, clean the command line buffer.
Example: When the disk label is invalid and user tries to make
new partition on the device with command like,
mkpart 0 50%. Then parted will raise an exception
telling an invalid disk label found and whether to correct it.
But at this time 0 as the input of mkpart will be
considered as the option input for the exception(yes/no).
So one more exception will raised with error information.
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
parted/ui.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/parted/ui.c b/parted/ui.c
index af0539c..752860b 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1288,6 +1288,7 @@ command_line_get_ex_opt (const char* prompt, PedExceptionOption options)
PedExceptionOption opt;
char* opt_name;
+ command_line_flush ();
for (opt = option_get_next (options, 0); opt;
opt = option_get_next (options, opt)) {
options_strlist = str_list_append_unique (options_strlist,
--
2.16.4

View File

@ -5,11 +5,11 @@ Patch-mainline: no, custom SUSE patch
libparted/labels/dos.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Index: parted-3.2/libparted/labels/dos.c
Index: parted-3.3/libparted/labels/dos.c
===================================================================
--- parted-3.2.orig/libparted/labels/dos.c
+++ parted-3.2/libparted/labels/dos.c
@@ -1285,7 +1285,13 @@ msdos_write (const PedDisk* disk)
--- parted-3.3.orig/libparted/labels/dos.c
+++ parted-3.3/libparted/labels/dos.c
@@ -1287,7 +1287,13 @@ msdos_write (const PedDisk* disk)
return 0;
DosRawTable *table = (DosRawTable *) s0;

View File

@ -1,3 +1,84 @@
-------------------------------------------------------------------
Fri Jan 3 14:46:27 UTC 2020 - Anna Maresova <anicka@suse.com>
- fix crash in do_resizepart
+ parted-fix-end_input-usage.patch: Fix end_input usage in
do_resizepart
-------------------------------------------------------------------
Fri Nov 22 14:25:28 UTC 2019 - Anna Maresova <anicka@suse.com>
- update to version 3.3, noteworthy changes:
- s390: Re-enabled virtio-attached DASD heuristics by using
HDIO_GETGEO when probing device geometry. Fixes a bug with
KVM virtio-blk backed by a DASD.
Parted now recognizes NVMe devices, NVDIMM, and RAM drives.
- Fix atari disklabel false positives by probing other labels first.
- Fix resizepart to adjust the end to be -1 sector when using iec
power of 2 units so that the next partition can start immediately
following the new end, just like mkpart does.
- Fix set and disk_set to not crash when there are no flags to set.
- Fix a udev cookie leak when using resizepart on device-mapper devices.
- Fix a gettext crash/error sometimes when using localized languages.
- Fix fat resize to preverve boot code, and thus not render the
filesystem unreconized by Windows.
- Fix rescue command: the rescue command often failed to find
filesystems due to leaving on cylinder alignment.
- libparted-fs-resize: Prevent crash resizing FAT file systems with very
deep directories with path names over 512 bytes long.
- Use 512b sector size when communicating with device-mapper. Fixes
problems with partitions being created too small on dm devices
with sector sizes > 5121b
- Don't crash in the disk_set command when a disk label is not found
- libparted-fs-resize: Prevent crash resizing FAT16 file systems.
- libparted-fs-resize: Prevent crash resizing FAT16 file systems.
- If the user specifies start/end of the partition as cylinders
and a cylinder has a size which is power of 2, then such address
does not trigger exact placement.
- mkpart: Allow negative start value when FS-TYPE is not given
- remove following patches (now in upstream):
- 0001-fdasd-geometry-handling-updated-from-upstream-s390-t.patch
- 0002-dasd-enhance-device-probing.patch
- 0003-parted-fix-build-error-on-s390.patch
- 0004-fdasd.c-Safeguard-against-geometry-misprobing.patch
- 0005-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch
- clean-the-disk-information-when-commands-fail-in-int.patch
- lib-fs-resize-prevent-crash-resizing-FAT16.patch
- libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
- libparted-Add-support-for-NVDIMM-devices.patch
- libparted-Add-support-for-NVMe-devices.patch
- libparted-Add-support-for-RAM-drives.patch
- libparted-BLKPG_RESIZE_PARTITION-uses-bytes.patch
- libparted-Use-read-only-when-probing-devices-on-linu.patch
- libparted-allow-bigger-snap-radius-if-cylinders-are-used.patch
- libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
- libparted-dasd-add-new-fdasd-functions.patch
- libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch
- libparted-dasd-correct-the-offset-where-the-first-pa.patch
- libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
- libparted-dasd-update-and-improve-fdasd-functions.patch
- libparted-device-mapper-uses-512b-sectors.patch
- libparted-dont-warn-if-no-HDIO_GET_IDENTITY.patch
- libparted-fix-starting-CHS-in-protective-MBR.patch
- libparted-fix-udev-cookie-leak.patch
- libparted-make-sure-not-to-treat-percentages-and-cyls-as-exact.patch
- libparted-set-swap-flag-on-GPT-partitions.patch
- libparted-sysmacros.patch
- parted-3.2.tar.xz
- parted-3.2.tar.xz.sig
- parted-check-the-name-of-partition-first-when-to-nam.patch
- parted-dont-crash-in-disk_set-when-disk-label-not-found.patch
- parted-fix-crash-due-to-improper-partition-number-in.patch
- parted-fix-wrong-error-label-jump-in-mkpart.patch
- parted-ui-remove-unneccesary-information-of-command.patch
- tests-check-extended-partition-length.patch
- tests-increase-scsi_debug-tmo.patch
- tests-set-optimal-blocks-for-scsi_debug.patch
- tests-update-t0220-t0280-for-swap-flag.patch
- tests-use-wait_for_dev_to_-functions.patch
- tests-wait_for_-loop.patch
- backported or refreshed remaining patches
-------------------------------------------------------------------
Wed Jul 10 10:16:16 UTC 2019 - Anna Maresova <anicka@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package parted
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,7 +17,7 @@
Name: parted
Version: 3.2
Version: 3.3
Release: 0
Summary: GNU partitioner
License: GPL-3.0-or-later
@ -37,78 +37,36 @@ Patch11: parted-wipeaix.patch
Patch12: libparted-partition-naming.patch
#PATCH-FEATURE-SUSE more-reliable-informing-the-kernel.patch bnc#657360 petr.uzel@suse.cz
Patch13: more-reliable-informing-the-kernel.patch
Patch17: dummy-bootcode-only-for-x86.patch
Patch18: parted-type.patch
Patch19: parted-mac.patch
Patch21: libparted-use-BLKRRPART-for-DASD.patch.patch
Patch22: libparted-allow-bigger-snap-radius-if-cylinders-are-used.patch
Patch23: libparted-make-BLKRRPART-more-robust.patch
Patch24: libparted-make-sure-not-to-treat-percentages-and-cyls-as-exact.patch
Patch25: libparted-dasd-implicit-partition-disk-flag.patch
Patch26: lib-fs-resize-prevent-crash-resizing-FAT16.patch
Patch27: parted-dont-crash-in-disk_set-when-disk-label-not-found.patch
Patch28: libparted-device-mapper-uses-512b-sectors.patch
Patch14: dummy-bootcode-only-for-x86.patch
Patch15: parted-type.patch
Patch16: parted-mac.patch
Patch17: libparted-use-BLKRRPART-for-DASD.patch.patch
Patch18: libparted-make-BLKRRPART-more-robust.patch
Patch19: libparted-dasd-implicit-partition-disk-flag.patch
# Remove following compatibility patch once bnc#931765 is resolved
Patch29: parted-resize-alias-to-resizepart.patch
Patch30: libparted-avoid-libdevice-mapper-warnings.patch
Patch20: parted-resize-alias-to-resizepart.patch
Patch21: libparted-avoid-libdevice-mapper-warnings.patch
# Patch31 dropped for bsc#1058667
Patch32: libparted-Use-read-only-when-probing-devices-on-linu.patch
Patch33: libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
Patch34: parted-implement-wipesignatures-option.patch
Patch22: libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
Patch23: parted-implement-wipesignatures-option.patch
# bsc#982169
Patch35: libparted-Add-support-for-NVMe-devices.patch
Patch36: libparted-fix-nvme-partition-naming.patch
Patch37: libparted-dont-warn-if-no-HDIO_GET_IDENTITY.patch
# fate#320525 / bsc#935127
Patch38: 0001-fdasd-geometry-handling-updated-from-upstream-s390-t.patch
Patch39: 0002-dasd-enhance-device-probing.patch
Patch40: 0003-parted-fix-build-error-on-s390.patch
Patch41: 0004-fdasd.c-Safeguard-against-geometry-misprobing.patch
Patch42: 0005-libparted-Remove-fdasd-geometry-code-from-alloc_meta.patch
# fate#321531
Patch43: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
Patch44: libparted-dasd-update-and-improve-fdasd-functions.patch
Patch45: libparted-dasd-add-new-fdasd-functions.patch
Patch46: libparted-Add-support-for-RAM-drives.patch
Patch24: libparted-fix-nvme-partition-naming.patch
# fate#314888
Patch47: libparted-dasd-improve-lvm-raid-flag-handling.patch
Patch48: parted-mkpart-set-a-swap-flag-if-available.patch
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
Patch58: parted-add-ignore-busy-option.patch
Patch59: parted-fix-resizepart-and-rm-command.patch
Patch60: libparted-use-BLKRRPART-only-when-needed.patch
Patch61: libparted-canonicalize-dev-md-paths.patch
Patch62: libparted-sysmacros.patch
# bsc#1136245
Patch63: libparted-dasd-correct-the-offset-where-the-first-pa.patch
Patch64: parted-fix-crash-due-to-improper-partition-number-in.patch
Patch65: parted-fix-wrong-error-label-jump-in-mkpart.patch
Patch66: clean-the-disk-information-when-commands-fail-in-int.patch
Patch67: parted-check-the-name-of-partition-first-when-to-nam.patch
Patch68: parted-ui-remove-unneccesary-information-of-command.patch
Patch69: libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
Patch70: libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
Patch71: libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch
Patch25: libparted-dasd-improve-lvm-raid-flag-handling.patch
Patch26: parted-mkpart-set-a-swap-flag-if-available.patch
Patch27: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
Patch28: parted-mkpart-allow-empty-gpt-part-name.patch
Patch29: libparted-fix-NVDIMM-partition-naming.patch
Patch30: parted-escape-printed-device-path.patch
Patch31: parted-add-ignore-busy-option.patch
Patch32: parted-fix-resizepart-and-rm-command.patch
Patch33: libparted-use-BLKRRPART-only-when-needed.patch
Patch34: libparted-canonicalize-dev-md-paths.patch
Patch35: parted-fix-end_input-usage.patch
# Fatresize
Patch100: parted-fatresize-autoconf.patch
Patch101: fatresize-fix-getting-dev-name.patch
# Upstream tests patches
Patch150: tests-set-optimal-blocks-for-scsi_debug.patch
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
# Tests patches
Patch156: tests-add-helper-require_swap_.patch
Patch157: tests-add-dev-md-check-to-t6100.patch
@ -169,9 +127,13 @@ to develop applications that require these.
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
@ -182,54 +144,13 @@ to develop applications that require these.
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch100 -p1
%patch101 -p1
%patch150 -p1
%patch151 -p1
%patch152 -p1
%patch153 -p1
%patch154 -p1
%patch155 -p1
%patch156 -p1
%patch157 -p1
%patch200 -p1
@ -271,7 +192,7 @@ rm %{buildroot}%{_libdir}/*.la
%defattr(-,root,root)
%doc doc/API doc/FAT
%{_includedir}/*
%{_libdir}/pkgconfig/libparted.pc
%{_libdir}/pkgconfig/libparted*.pc
%{_libdir}/*.so
%files -n libparted0

View File

@ -11,8 +11,10 @@ Change dm partition name from 'pN' to '-partN'
Tests: t6001, t6002, t6004, t6005
For: libparted-partition-naming.patch
---
--- a/tests/t2200-dos-label-recog.sh
+++ b/tests/t2200-dos-label-recog.sh
Index: parted-3.3/tests/t2200-dos-label-recog.sh
===================================================================
--- parted-3.3.orig/tests/t2200-dos-label-recog.sh
+++ parted-3.3/tests/t2200-dos-label-recog.sh
@@ -45,7 +45,7 @@ printf FAT | dd bs=1c seek=82 count=3 of
# print the partition table
parted -m -s $dev unit s p > out || fail=1
@ -22,8 +24,10 @@ For: libparted-partition-naming.patch
compare exp out || fail=1
--- a/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ b/tests/t2310-dos-extended-2-sector-min-offset.sh
Index: parted-3.3/tests/t2310-dos-extended-2-sector-min-offset.sh
===================================================================
--- parted-3.3.orig/tests/t2310-dos-extended-2-sector-min-offset.sh
+++ parted-3.3/tests/t2310-dos-extended-2-sector-min-offset.sh
@@ -33,8 +33,8 @@ p5=${scsi_dev}5
cat <<EOF > exp || framework_failure
BYT;
@ -35,8 +39,10 @@ For: libparted-partition-naming.patch
EOF
# Create a DOS label with an extended partition starting at sector 64.
--- a/tests/t3200-resize-partition.sh
+++ b/tests/t3200-resize-partition.sh
Index: parted-3.3/tests/t3200-resize-partition.sh
===================================================================
--- parted-3.3.orig/tests/t3200-resize-partition.sh
+++ parted-3.3/tests/t3200-resize-partition.sh
@@ -75,7 +75,7 @@ compare /dev/null err || fail=1
parted -m -s $dev u s p > out 2>&1 || fail=1
@ -46,8 +52,10 @@ For: libparted-partition-naming.patch
compare exp out || fail=1
# Remove the partition explicitly, so that mklabel doesn't evoke a warning.
--- a/tests/t3300-palo-prep.sh
+++ b/tests/t3300-palo-prep.sh
Index: parted-3.3/tests/t3300-palo-prep.sh
===================================================================
--- parted-3.3.orig/tests/t3300-palo-prep.sh
+++ parted-3.3/tests/t3300-palo-prep.sh
@@ -20,9 +20,9 @@
ss=$sector_size_
@ -70,8 +78,10 @@ For: libparted-partition-naming.patch
compare exp out || fail=1
--- a/tests/t4100-msdos-starting-sector.sh
+++ b/tests/t4100-msdos-starting-sector.sh
Index: parted-3.3/tests/t4100-msdos-starting-sector.sh
===================================================================
--- parted-3.3.orig/tests/t4100-msdos-starting-sector.sh
+++ parted-3.3/tests/t4100-msdos-starting-sector.sh
@@ -56,7 +56,7 @@ cat <<EOF > exp || fail=1
BYT;
path:${N}s:file:$ss:$ss:msdos::;
@ -81,8 +91,10 @@ For: libparted-partition-naming.patch
EOF
# create a partition at the end of the label
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
Index: parted-3.3/tests/t6001-psep.sh
===================================================================
--- parted-3.3.orig/tests/t6001-psep.sh
+++ parted-3.3/tests/t6001-psep.sh
@@ -31,9 +31,9 @@ linear2_=plinear-$$foo
d1= d2=
f1= f2=
@ -113,8 +125,10 @@ For: libparted-partition-naming.patch
if [ -n "$fail" ]; then
ls /dev/mapper
--- a/tests/t6004-dm-many-partitions.sh
+++ b/tests/t6004-dm-many-partitions.sh
Index: parted-3.3/tests/t6004-dm-many-partitions.sh
===================================================================
--- parted-3.3.orig/tests/t6004-dm-many-partitions.sh
+++ parted-3.3/tests/t6004-dm-many-partitions.sh
@@ -50,10 +50,10 @@ parted -m -a min -s /dev/mapper/$dm_name
# Make sure all the partitions appeared under /dev/mapper/
@ -128,8 +142,10 @@ For: libparted-partition-naming.patch
done
Exit $fail
--- a/tests/t6005-dm-uuid.sh
+++ b/tests/t6005-dm-uuid.sh
Index: parted-3.3/tests/t6005-dm-uuid.sh
===================================================================
--- parted-3.3.orig/tests/t6005-dm-uuid.sh
+++ parted-3.3/tests/t6005-dm-uuid.sh
@@ -47,14 +47,14 @@ for ((i=1; i<=$n_partitions; i+=1)); do
cmd="$cmd mkpart p$i ${s}s ${s}s"
done
@ -148,8 +164,10 @@ For: libparted-partition-naming.patch
done
Exit $fail
--- a/tests/t0283-overlap-partitions.sh
+++ b/tests/t0283-overlap-partitions.sh
Index: parted-3.3/tests/t0283-overlap-partitions.sh
===================================================================
--- parted-3.3.orig/tests/t0283-overlap-partitions.sh
+++ parted-3.3/tests/t0283-overlap-partitions.sh
@@ -54,8 +54,8 @@ Partition Table: msdos
Disk Flags:
@ -170,8 +188,10 @@ For: libparted-partition-naming.patch
(parted) rm
Partition number? 1
--- a/tests/t6002-dm-busy.sh
+++ b/tests/t6002-dm-busy.sh
Index: parted-3.3/tests/t6002-dm-busy.sh
===================================================================
--- parted-3.3.orig/tests/t6002-dm-busy.sh
+++ parted-3.3/tests/t6002-dm-busy.sh
@@ -35,9 +35,9 @@ d1=
f1=
dev=
@ -212,8 +232,10 @@ For: libparted-partition-naming.patch
EOF
compare exp out || fail=1
--- a/tests/t9042-dos-partition-limit.sh
+++ b/tests/t9042-dos-partition-limit.sh
Index: parted-3.3/tests/t9042-dos-partition-limit.sh
===================================================================
--- parted-3.3.orig/tests/t9042-dos-partition-limit.sh
+++ parted-3.3/tests/t9042-dos-partition-limit.sh
@@ -41,7 +41,7 @@ scsi_dev=$(cat dev-name)
n=$((n_MiB * sectors_per_MiB))
printf '%s\n' "BYT;" \
@ -222,7 +244,7 @@ For: libparted-partition-naming.patch
+ "1:$((start-2))s:$((n-1))s:$((n-start+2))s:::lba, type=0f;" \
> exp || fail=1
parted -s $scsi_dev mklabel msdos || fail=1
parted -s -a min $scsi_dev mklabel msdos mkpart extended $((start-2))s 100% || fail=1
@@ -51,7 +51,7 @@ i=1
while :; do
end=$((start + partition_sectors - 2))
@ -232,8 +254,10 @@ For: libparted-partition-naming.patch
test $i = $((n_partitions - 1)) && break
start=$((start + partition_sectors))
i=$((i+1))
--- a/tests/t4100-msdos-partition-limits.sh
+++ b/tests/t4100-msdos-partition-limits.sh
Index: parted-3.3/tests/t4100-msdos-partition-limits.sh
===================================================================
--- parted-3.3.orig/tests/t4100-msdos-partition-limits.sh
+++ parted-3.3/tests/t4100-msdos-partition-limits.sh
@@ -81,7 +81,7 @@ do_mkpart $n $end || fail=1
# print the result
parted -s $dev unit s p > out 2>&1 || fail=1

View File

@ -21,10 +21,10 @@ Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
tests/t6100-mdraid-partitions.sh | 62 +++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 7 deletions(-)
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index dbb1686..b471f56 100755
--- a/tests/t6100-mdraid-partitions.sh
+++ b/tests/t6100-mdraid-partitions.sh
Index: parted-3.3/tests/t6100-mdraid-partitions.sh
===================================================================
--- parted-3.3.orig/tests/t6100-mdraid-partitions.sh
+++ parted-3.3/tests/t6100-mdraid-partitions.sh
@@ -21,6 +21,7 @@
require_root_
require_scsi_debug_module_
@ -33,13 +33,14 @@ index dbb1686..b471f56 100755
# create memory-backed device
scsi_debug_setup_ dev_size_mb=10 > dev-name ||
@@ -40,13 +41,27 @@ parted -s "$scsi_dev" mklabel gpt \
@@ -40,14 +41,28 @@ parted -s "$scsi_dev" mklabel gpt \
compare /dev/null out || fail=1
wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; }
+create_mddev() {
+ # create mdraid on top of both partitions
+ mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
+ 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; }
+}
+
cleanup_fn_() {
@ -47,8 +48,9 @@ index dbb1686..b471f56 100755
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; }
+remove_mdparts() {
+ # Remove partitions from the raid device.
+ parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
@ -63,7 +65,7 @@ index dbb1686..b471f56 100755
# create gpt and two partitions on the raid device
parted -s $md_dev mklabel gpt \
@@ -57,12 +72,45 @@ compare /dev/null out || fail=1
@@ -58,12 +73,45 @@ compare /dev/null out || fail=1
# Verify that kernel has been informed about the second device.
wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; }

View File

@ -1,84 +0,0 @@
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

View File

@ -1,40 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 24 Feb 2017 11:06:20 -0800
Subject: Increase timeout for rmmod scsi_debug and make it a
framework failure
For: upstream code
Patch-mainline: v3.3
Git-commit: 40e55a0819862d5dbe2098803735f8c48fb30b6d
On some hardware scsi_debug can take longer to remove. If this fails it
inevitably results in the next test failing since it cannot load
scsi_debug.
Increse the timeout to 40 loops (8 seconds), and if it hits the limit
without succeeding call framework_failure_
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t-local.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/t-local.sh b/tests/t-local.sh
index 5655e0f..fb6a7e3 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -27,13 +27,14 @@ scsi_debug_cleanup_()
# "Module scsi_debug is in use".
i=0
udevadm settle
- while [ $i -lt 10 ] ; do
+ while [ $i -lt 40 ] ; do
rmmod scsi_debug \
&& { test "$VERBOSE" = yes && warn_ $ME_ rmmod scsi_debug...; break; }
sleep .2 || sleep 1
i=$((i + 1))
done
udevadm settle
+ test $i = 40 && framework_failure_ rmmod scsi_debug failed.
fi
rm -fr $scsi_debug_lock_dir_
}

View File

@ -1,30 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 23 Aug 2016 08:55:18 -0700
Subject: tests: Set optimal blocks to 64 for scsi_debug devices
For: upstream code
Patch-mainline: v3.3
Git-commit: da36186cb4c2c0470a6490aed424a8d51a2b1085
The Linux kernel 4.5 changed the optimal blocks count from 64 to 1024
This causes tests using scsi_debug devices to fail because of alignment
issues. Set the opt_blks to 64 so that we have consistent behavior
across kernels.
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t-local.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t-local.sh b/tests/t-local.sh
index b40a5a0..5655e0f 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -97,7 +97,7 @@ scsi_debug_setup_()
# It is not trivial to determine the name of the device we're creating.
# Record the names of all /sys/block/sd* devices *before* probing:
touch stamp
- modprobe scsi_debug "$@" || { rm -f stamp; return 1; }
+ modprobe scsi_debug opt_blks=64 "$@" || { rm -f stamp; return 1; }
scsi_debug_modprobe_succeeded_=1
test "$VERBOSE" = yes \
&& echo $ME_ modprobe scsi_debug succeeded 1>&2

View File

@ -1,45 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 22 Dec 2016 16:59:27 -0800
Subject: tests: Update t0220 and t0280 for the swap flag.
For: libparted-set-swap-flag-on-GPT-partitions.patch
For: parted-mkpart-set-a-swap-flag-if-available.patch
For: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
Patch-mainline: v3.3
Git-commit: 5a9a49776ee98ca86cfe123b79bbee2279f93961
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t0220-gpt-msftres.sh | 6 +++++-
tests/t0280-gpt-corrupt.sh | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh
index 79518ae6b342..6721a470b111 100755
--- a/tests/t0220-gpt-msftres.sh
+++ b/tests/t0220-gpt-msftres.sh
@@ -56,7 +56,11 @@ printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:gpt::;\n" > exp
i=1
for type in $fs_types; do
end=$(expr $start + $part_size - 1)
- case $type in fat*|NTFS) flag=msftdata;; *) flag=;; esac
+ case $type in
+ fat*|NTFS) flag=msftdata;;
+ linux-swap) flag=swap;;
+ *) flag=;;
+ esac
echo "$i:${start}s:${end}s:${part_size}s::$type:$flag;" >> exp || fail=1
parted -s $dev mkpart p-name $type ${start}s ${end}s > err 2>&1 || fail=1
compare /dev/null err || fail=1
diff --git a/tests/t0280-gpt-corrupt.sh b/tests/t0280-gpt-corrupt.sh
index a7c8d82291e5..1b4d86b094ea 100755
--- a/tests/t0280-gpt-corrupt.sh
+++ b/tests/t0280-gpt-corrupt.sh
@@ -89,7 +89,7 @@ compare exp err || fail=1
parted -m -s $dev u s print > out 2>&1 || fail=1
# check for expected output
-printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:;\n" > exp || fail=1
+printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:swap;\n" > exp || fail=1
sed "s/.*gpt::;/file/" out > k && mv k out || fail=1
compare exp out || fail=1

View File

@ -1,185 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 7 Aug 2015 11:43:17 -0700
Subject: tests: Use wait_for_dev_to_ functions
For: upstream code
Patch-mainline: v3.3
Git-commit: db1728e6402a27fe64e8e132f810c22160ab8bcc
Recent changes to udev have made some long-standing problems appear more
frequently. udev executes various actions when changes are made to
devices. Sometimes this can result in device nodes not appearing
immediately. Other times it can result in EBUSY being returned. This
patch only addresses devices that are slow to appear/disappear.
It is best to use the wait_for_dev_to_appear_ and
wait_for_dev_to_disappear_ functions than to test for existance. These
will loop and wait for up to 2 seconds for it to appear.
This also changes t9041 to fail if mkfs doesn't work since using skip
here may hide cases when the device node doesn't appear.
[sparschauer: remove hunks for non-existing tests]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t1100-busy-label.sh | 10 ++--------
tests/t1102-loop-label.sh | 25 +++++--------------------
tests/t2320-dos-extended-noclobber.sh | 1 +
tests/t6001-psep.sh | 4 ++--
tests/t6004-dm-many-partitions.sh | 6 ++----
tests/t6006-dm-512b-sectors.sh | 1 +
tests/t6100-mdraid-partitions.sh | 5 +++--
tests/t9041-undetected-in-use-16th-partition.sh | 2 +-
8 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh
index 4e256d32a010..70e8edec8a60 100755
--- a/tests/t1100-busy-label.sh
+++ b/tests/t1100-busy-label.sh
@@ -27,22 +27,16 @@ dev=$(cat dev-name)
parted -s "$dev" mklabel msdos mkpart primary fat32 1 40 > out 2>&1 || fail=1
compare /dev/null out || fail=1
-mkfs.vfat ${dev}1 || skip_ "mkfs.vfat failed"
+wait_for_dev_to_appear_ ${dev}1 || fail=1
+mkfs.vfat ${dev}1 || fail=1
mount_point="`pwd`/mnt"
# Be sure to unmount upon interrupt, failure, etc.
cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
-# There's a race condition here: on udev-based systems, the partition#1
-# device, ${dev}1 (i.e., /dev/sdd1) is not created immediately, and
-# without some delay, this mount command would fail. Using a flash card
-# as $dev, the loop below typically iterates 7-20 times.
-
# create mount point dir. and mount the just-created partition on it
mkdir $mount_point || fail=1
-i=0; while :; do test -e "${dev}1" && break; test $i = 90 && break;
- i=$(expr $i + 1); done;
mount "${dev}1" $mount_point || fail=1
# now that a partition is mounted, mklabel attempt must fail
diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh
index 97520021004d..68b9af45b428 100644
--- a/tests/t1102-loop-label.sh
+++ b/tests/t1102-loop-label.sh
@@ -44,15 +44,9 @@ mv out o2 && sed -e "s,$dev,DEVICE,;s/ *$//" o2 > out
compare exp out || fail=1
parted -s $dev rm 1 || fail=1
-if [ -e ${dev}1 ]; then
- echo "Partition should not exist on loop device"
- fail=1
-fi
+wait_for_dev_to_disappear_ ${dev}1 2 || fail=1
partprobe $dev || fail=1
-if [ -e ${dev}1 ]; then
- echo "Partition should not exist on loop device"
- fail=1
-fi
+wait_for_dev_to_disappear_ ${dev}1 2 || fail=1
mount_point="`pwd`/mnt"
@@ -80,24 +74,15 @@ umount "$mount_point"
# make sure partprobe cleans up stale partition devices
parted -s $dev mklabel msdos mkpart primary ext2 0% 100% || fail=1
-if [ ! -e ${dev}1 ]; then
- echo "Partition doesn't exist on loop device"
- fail=1
-fi
+wait_for_dev_to_appear_ ${dev}1 || fail=1
mke2fs -F $dev
partprobe $dev || fail=1
-if [ -e ${dev}1 ]; then
- echo "Partition should not exist on loop device"
- fail=1
-fi
+wait_for_dev_to_disappear_ ${dev}1 2 || fail=1
# make sure new loop label removes old partitions > 1
parted -s $dev mklabel msdos mkpart primary ext2 0% 50% mkpart primary ext2 50% 100% || fail=1
parted -s $dev mklabel loop || fail=1
-if [ -e ${dev}2 ]; then
- echo "Partition 2 not removed"
- fail=1
-fi
+wait_for_dev_to_disappear_ ${dev}2 2 || fail=1
Exit $fail
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index f15090abb3e7..4c758e8fbc73 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -54,7 +54,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
compare /dev/null out || fail=1
#make sure device name is correct
-test -e ${dev}p1 || fail=1
+wait_for_dev_to_appear_ ${dev}p1 || fail=1
#repeat on name not ending in a digit
# setup: create a mapping
@@ -66,7 +66,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1
compare /dev/null out || fail=1
#make sure device name is correct
-test -e ${dev}1 || fail=1
+wait_for_dev_to_appear_ ${dev}1 || fail=1
if [ -n "$fail" ]; then
ls /dev/mapper
diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh
index 8d291ef55664..7ebc48a18db8 100755
--- a/tests/t6004-dm-many-partitions.sh
+++ b/tests/t6004-dm-many-partitions.sh
@@ -49,10 +49,8 @@ parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fa
# Make sure all the partitions appeared under /dev/mapper/
for ((i=1; i<=$n_partitions; i+=1)); do
- if [ ! -e "/dev/mapper/${dm_name}p$i" ]; then
- fail=1
- break
- fi
+ wait_for_dev_to_appear_ "/dev/mapper/${dm_name}p$i" || { fail=1; break; }
+
# remove the partitions as we go, otherwise cleanup won't work.
dmsetup remove /dev/mapper/${dm_name}p$i
done
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index 6f08442dd66d..dbc5986b9019 100755
--- a/tests/t6100-mdraid-partitions.sh
+++ b/tests/t6100-mdraid-partitions.sh
@@ -54,13 +54,14 @@ parted -s $md_dev mklabel gpt \
compare /dev/null out || fail=1
# Verify that kernel has been informed about the second device.
-grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; }
+wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; }
# Remove partitions from the raid device.
parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
compare /dev/null out || fail=1
# Verify that kernel has been informed about those removals.
-grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; }
+wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; }
+wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; }
Exit $fail
diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh
index edaae1bf8116..673e508319a3 100644
--- a/tests/t9041-undetected-in-use-16th-partition.sh
+++ b/tests/t9041-undetected-in-use-16th-partition.sh
@@ -72,7 +72,7 @@ wait_for_dev_to_appear_ ${scsi_dev}16 || fail_ ${scsi_dev}16 did not appear
partitions="${scsi_dev}14 ${scsi_dev}15 ${scsi_dev}16"
for i in $partitions; do
- mkfs.ext3 $i || skip_ mkfs.ext3 $i failed
+ mkfs.ext3 $i || fail=1
done
# be sure to unmount upon interrupt, failure, etc.

View File

@ -1,119 +0,0 @@
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 1 Mar 2016 10:38:26 -0800
Subject: tests: Add udevadm settle to wait_for_ loop (#1260664)
For: upstream code
Patch-mainline: v3.3
Git-commit: f5cc84cdb5a607449c339cad50fe8be5dd77eb6c
Sometimes the device will vanish after the wait_for_dev_to_appear exits.
Add udevadm settle in an attempt to make sure the udev system is done
flapping around and the device will stay in place.
Related: rhbz#1260664
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t-lib-helpers.sh | 2 ++
tests/t-local.sh | 2 ++
tests/t6001-psep.sh | 2 ++
tests/t6004-dm-many-partitions.sh | 1 +
tests/t6005-dm-uuid.sh | 2 ++
tests/t6100-mdraid-partitions.sh | 1 +
6 files changed, 10 insertions(+)
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index c8684bbd264e..93123432922b 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -377,6 +377,7 @@ wait_for_dev_to_appear_()
local i=0
local incr=1
while :; do
+ udevadm settle
ls "$file" > /dev/null 2>&1 && return 0
sleep .1 2>/dev/null || { sleep 1; incr=10; }
i=$(expr $i + $incr); test $i = 20 && break
@@ -392,6 +393,7 @@ wait_for_dev_to_disappear_()
local i=0
local incr=1
while :; do
+ udevadm settle
ls "$file" > /dev/null 2>&1 || return 0
sleep .1 2>/dev/null || { sleep 1; incr=10; }
i=$(expr $i + $incr); test $i -ge $(expr $n_sec \* 10) && break
diff --git a/tests/t-local.sh b/tests/t-local.sh
index b40a5a0ebbf5..a7d5226a3956 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -47,6 +47,7 @@ wait_for_dev_to_appear_()
local i=0
local incr=1
while :; do
+ udevadm settle
ls "$file" > /dev/null 2>&1 && return 0
sleep .1 2>/dev/null || { sleep 1; incr=10; }
i=$(expr $i + $incr); test $i = 20 && break
@@ -110,6 +111,7 @@ scsi_debug_setup_()
local i=0
local new_dev
while :; do
+ udevadm settle
new_dev=$(new_sdX_) && break
sleep .1 2>/dev/null || { sleep 1; incr=10; }
i=$(expr $i + $incr); test $i = 20 && break
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index 4c758e8fbc73..2985cf5e7d0e 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -19,6 +19,8 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
+require_udevadm_settle_
+
(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
# Device maps names - should be random to not conflict with existing ones on
diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh
index 7ebc48a18db8..01d7fc0da8f3 100755
--- a/tests/t6004-dm-many-partitions.sh
+++ b/tests/t6004-dm-many-partitions.sh
@@ -20,6 +20,7 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
+require_udevadm_settle_
(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
ss=$sector_size_
diff --git a/tests/t6005-dm-uuid.sh b/tests/t6005-dm-uuid.sh
index ce1251a9f16a..a48ae727f940 100755
--- a/tests/t6005-dm-uuid.sh
+++ b/tests/t6005-dm-uuid.sh
@@ -20,6 +20,7 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
+require_udevadm_settle_
(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
ss=$sector_size_
@@ -46,6 +47,7 @@ for ((i=1; i<=$n_partitions; i+=1)); do
cmd="$cmd mkpart p$i ${s}s ${s}s"
done
parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
+wait_for_dev_to_appear_ /dev/mapper/${dm_name}p${n_partitions} || fail=1
# Make sure all the partitions have UUIDs
for ((i=1; i<=$n_partitions; i+=1)); do
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index dbc5986b9019..dbb16861f9f3 100755
--- a/tests/t6100-mdraid-partitions.sh
+++ b/tests/t6100-mdraid-partitions.sh
@@ -38,6 +38,7 @@ parted -s "$scsi_dev" mklabel gpt \
mkpart p1 ext2 1M 4M \
mkpart p2 ext2 5M 8M > out 2>&1 || fail=1
compare /dev/null out || fail=1
+wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; }
cleanup_fn_() {
# stop mdraid array