Accepting request 492573 from Base:System

1

OBS-URL: https://build.opensuse.org/request/show/492573
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/parted?expand=0&rev=113
This commit is contained in:
Dominique Leuenberger 2017-05-04 06:55:04 +00:00 committed by Git OBS Bridge
commit fba86e243a
7 changed files with 709 additions and 10 deletions

View File

@ -0,0 +1,167 @@
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:48 +0200
Subject: libparted/dasd: add new fdasd functions
References: fate#321531
Patch-mainline: v3.3
Git-commit: b9e12819ecef30087753b967bebc9809120593a6
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>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/fdasd.in.h | 4 ++
libparted/labels/fdasd.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+)
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -291,5 +291,9 @@ void fdasd_recreate_vtoc(fdasd_anchor_t
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 */
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -1247,4 +1247,127 @@ fdasd_add_partition (fdasd_anchor_t *anc
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: */

View File

@ -0,0 +1,266 @@
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:46 +0200
Subject: libparted/dasd: unify vtoc handling for cdl/ldl
References: fate#321531
Patch-mainline: v3.3
Git-commit: 4f25d54d4d2bd6ae12d56b5a97ed2b7f60f753e9
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>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/vtoc.in.h | 34 +++++++++++++++++++---------------
libparted/labels/dasd.c | 8 +++-----
libparted/labels/vtoc.c | 38 +++++++++++++++++---------------------
3 files changed, 39 insertions(+), 41 deletions(-)
--- 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)) labeldat
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_l
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
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_
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 (form
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);
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -345,13 +345,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;
@@ -375,8 +374,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;
--- 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
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
}
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
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 p
* 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
* 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,
}
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_la
* 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_l
* 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_l
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,
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");

View File

@ -0,0 +1,204 @@
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Date: Wed, 26 Oct 2016 04:22:47 +0200
Subject: libparted/dasd: update and improve fdasd functions
References: fate#321531
Patch-mainline: v3.3
Git-commit: db37c8c017ebef8f241420dda071940957d4bbe5
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>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/fdasd.in.h | 14 +++++-------
libparted/labels/fdasd.c | 56 ++++++++++++++++++++++++-----------------------
2 files changed, 35 insertions(+), 35 deletions(-)
--- 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 */
@@ -196,15 +197,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"
@@ -231,9 +231,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;
@@ -280,7 +277,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);
--- 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 f
_("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);
}
@@ -313,7 +314,7 @@ fdasd_write_vtoc_labels (fdasd_anchor_t
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;
@@ -545,7 +546,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,
@@ -793,7 +793,7 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_
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);
@@ -807,6 +807,8 @@ fdasd_invalid_vtoc_pointer(fdasd_anchor_
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++;
}
/*
@@ -818,7 +820,7 @@ fdasd_process_invalid_vtoc(fdasd_anchor_
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);
@@ -829,6 +831,8 @@ fdasd_process_invalid_vtoc(fdasd_anchor_
FIRST_USABLE_TRK,
anc->formatted_cylinders * anc->geo.heads - 1,
anc->formatted_cylinders, anc->geo.heads);
+
+ anc->vtoc_changed++;
}
@@ -901,7 +905,7 @@ fdasd_check_volume (fdasd_anchor_t *anc,
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);
@@ -1213,12 +1217,10 @@ fdasd_add_partition (fdasd_anchor_t *anc
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;

View File

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

@ -1,19 +1,18 @@
From b9420b8e618c8ad988c410e4289273ac962ec918 Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 26 May 2016 09:28:21 +0200
Subject: [PATCH] libparted: open the device RO and lazily switch to RW only if
Subject: libparted: open the device RO and lazily switch to RW only if
necessary
[sparschauer: Use _flush_cache() also for reads, don't switch to RW
in _flush_cache() to avoid a possible recursion (bnc#989751), open
partitions in _flush_cache() O_RDONLY instead of O_WRONLY]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
References: bsc#979275
Patch-mainline: not yet
Avoid useless udev events triggered by opening the device RW
for purely read-only operations.
References: https://bugzilla.novell.com/show_bug.cgi?id=979275
Author: Michael Matz <matz@suse.de>
[sparschauer: Use _flush_cache() also for reads, don't switch to RW
in _flush_cache() to avoid a possible recursion (bnc#989751), open
partitions in _flush_cache() O_RDONLY instead of O_WRONLY]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 33 ++++++++++++++++++++++++++++++---
libparted/arch/linux.h | 1 +

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Tue May 2 10:45:37 CEST 2017 - sparschauer@suse.de
- Use latest fdasd/vtoc code base from s390-tools (fate#321531)
- add: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
- add: libparted-dasd-update-and-improve-fdasd-functions.patch
- add: libparted-dasd-add-new-fdasd-functions.patch
-------------------------------------------------------------------
Thu Apr 27 17:37:19 CEST 2017 - sparschauer@suse.de
- libparted: Don't warn if the HDIO_GET_IDENTITY ioctl isn't
supported (bsc#964012, bsc#1001967)
- add: libparted-dont-warn-if-no-HDIO_GET_IDENTITY.patch
- Amend patch description:
- libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
-------------------------------------------------------------------
Tue Aug 9 14:36:20 CEST 2016 - sparschauer@suse.de

View File

@ -1,7 +1,7 @@
#
# spec file for package parted
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 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
@ -59,10 +59,14 @@ Patch31: parted-do-not-warn-when-shrinking-in-script-mode.patch
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
# 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#321531
Patch38: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
Patch39: libparted-dasd-update-and-improve-fdasd-functions.patch
Patch40: libparted-dasd-add-new-fdasd-functions.patch
Patch100: parted-fatresize-autoconf.patch
BuildRequires: check-devel
BuildRequires: device-mapper-devel >= 1.02.33
@ -142,6 +146,10 @@ to develop applications that require these.
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch100 -p1
%build