[Parted-maintainers] Bug#887016: parted: Cherry-pick DASD updates from upstream git

Julian Andres Klode julian.klode at canonical.com
Fri Jan 12 15:21:30 UTC 2018


Package: parted
Version: 3.2-18
Severity: wishlist
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu bionic ubuntu-patch

In Ubuntu, the attached patch was applied to achieve the following:

  * Merge latest fdasd / vtoc code (LP: #1737144), taken from upstream git:
    - libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
    - libparted-dasd-update-and-improve-fdasd-functions.patch
    - libparted-dasd-add-new-fdasd-functions.patch
    - libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch

This updates the dasd code with newer code from s390-utils which probably
fixes some bugs some people are worried about. openSUSE also ships them.

-- System Information:
Debian Release: buster/sid
  APT prefers bionic
  APT policy: (500, 'bionic'), (100, 'bionic-proposed')
Architecture: amd64 (x86_64)

Kernel: Linux 4.14.0-16-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en
-------------- next part --------------
diff -Nru parted-3.2/debian/patches/libparted-dasd-add-new-fdasd-functions.patch parted-3.2/debian/patches/libparted-dasd-add-new-fdasd-functions.patch
--- parted-3.2/debian/patches/libparted-dasd-add-new-fdasd-functions.patch	1970-01-01 01:00:00.000000000 +0100
+++ parted-3.2/debian/patches/libparted-dasd-add-new-fdasd-functions.patch	2018-01-12 10:33:02.000000000 +0100
@@ -0,0 +1,171 @@
+From b9e12819ecef30087753b967bebc9809120593a6 Mon Sep 17 00:00:00 2001
+From: Wang Dong <dongdwdw at linux.vnet.ibm.com>
+Date: Wed, 26 Oct 2016 04:22:48 +0200
+Subject: [PATCH 3/4] 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 at linux.vnet.ibm.com>
+Signed-off-by: Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
+Signed-off-by: Brian C. Lane <bcl at 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.15.1
+
diff -Nru parted-3.2/debian/patches/libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch parted-3.2/debian/patches/libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch
--- parted-3.2/debian/patches/libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch	1970-01-01 01:00:00.000000000 +0100
+++ parted-3.2/debian/patches/libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch	2018-01-12 10:33:02.000000000 +0100
@@ -0,0 +1,43 @@
+From 571e078406b59e8dcf02db3e8fe28d8eb4d2cef0 Mon Sep 17 00:00:00 2001
+From: Wang Dong <dongdwdw at linux.vnet.ibm.com>
+Date: Wed, 26 Oct 2016 04:22:49 +0200
+Subject: [PATCH 4/4] 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 at linux.vnet.ibm.com>
+Signed-off-by: Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
+Signed-off-by: Brian C. Lane <bcl at 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.15.1
+
diff -Nru parted-3.2/debian/patches/libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch parted-3.2/debian/patches/libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
--- parted-3.2/debian/patches/libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch	1970-01-01 01:00:00.000000000 +0100
+++ parted-3.2/debian/patches/libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch	2018-01-12 10:33:02.000000000 +0100
@@ -0,0 +1,272 @@
+From 4f25d54d4d2bd6ae12d56b5a97ed2b7f60f753e9 Mon Sep 17 00:00:00 2001
+From: Wang Dong <dongdwdw at linux.vnet.ibm.com>
+Date: Wed, 26 Oct 2016 04:22:46 +0200
+Subject: [PATCH 1/4] 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 at linux.vnet.ibm.com>
+Signed-off-by: Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
+Signed-off-by: Brian C. Lane <bcl at 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.15.1
+
diff -Nru parted-3.2/debian/patches/libparted-dasd-update-and-improve-fdasd-functions.patch parted-3.2/debian/patches/libparted-dasd-update-and-improve-fdasd-functions.patch
--- parted-3.2/debian/patches/libparted-dasd-update-and-improve-fdasd-functions.patch	1970-01-01 01:00:00.000000000 +0100
+++ parted-3.2/debian/patches/libparted-dasd-update-and-improve-fdasd-functions.patch	2018-01-12 10:33:02.000000000 +0100
@@ -0,0 +1,208 @@
+From db37c8c017ebef8f241420dda071940957d4bbe5 Mon Sep 17 00:00:00 2001
+From: Wang Dong <dongdwdw at linux.vnet.ibm.com>
+Date: Wed, 26 Oct 2016 04:22:47 +0200
+Subject: [PATCH 2/4] 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 at linux.vnet.ibm.com>
+Hendrik Brueckner <brueckner at linux.vnet.ibm.com>
+
+Signed-off-by: Brian C. Lane <bcl at 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.15.1
+
diff -Nru parted-3.2/debian/patches/series parted-3.2/debian/patches/series
--- parted-3.2/debian/patches/series	2017-10-11 14:02:37.000000000 +0200
+++ parted-3.2/debian/patches/series	2018-01-12 10:36:21.000000000 +0100
@@ -20,3 +20,7 @@
 fdasd-check-geometry.patch
 tests-move-get-sector-size.patch
 atari.patch
+libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
+libparted-dasd-update-and-improve-fdasd-functions.patch
+libparted-dasd-add-new-fdasd-functions.patch
+libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch


More information about the Parted-maintainers mailing list