Blame SOURCES/parted-3.1-libparted-mklabel-eav.patch

fc4a62
Subject: [PATCH] libparted: mklabel to support EAV DASD
fc4a62
fc4a62
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
fc4a62
fc4a62
Extended Address Volume (EAV) DASDs are ECKD DASDs with more than
fc4a62
65520 cylinders. This patch adds support for mklabel to properly
fc4a62
handle unformatted EAV DASDs.
fc4a62
fc4a62
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
fc4a62
---
fc4a62
 include/parted/fdasd.h |    1 
fc4a62
 libparted/labels/fdasd.c  |   92 +++++++++++++++++++++++++++++++++++++++++++++-
fc4a62
 2 files changed, 90 insertions(+), 3 deletions(-)
fc4a62
fc4a62
--- a/include/parted/fdasd.h
fc4a62
+++ b/include/parted/fdasd.h
fc4a62
@@ -288,7 +288,6 @@ void fdasd_get_geometry (const PedDevice
fc4a62
 void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
fc4a62
 int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
fc4a62
 int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
fc4a62
-int fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc);
fc4a62
 void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
fc4a62
 partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
fc4a62
                                         unsigned int start, unsigned int stop);
fc4a62
--- a/libparted/labels/fdasd.c
fc4a62
+++ b/libparted/labels/fdasd.c
fc4a62
@@ -581,6 +581,22 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc
fc4a62
 	anc->vtoc_changed++;
fc4a62
 }
fc4a62
 
fc4a62
+ /*
fc4a62
+ * initialize the VOL1 volume label
fc4a62
+ */
fc4a62
+static void
fc4a62
+fdasd_init_volume_label(fdasd_anchor_t *anc, int fd)
fc4a62
+{
fc4a62
+	volume_label_t *vlabel = anc->vlabel;
fc4a62
+
fc4a62
+	vtoc_volume_label_init(vlabel);
fc4a62
+	vtoc_volume_label_set_key(vlabel, "VOL1");
fc4a62
+	vtoc_volume_label_set_label(vlabel, "VOL1");
fc4a62
+
fc4a62
+	vtoc_set_cchhb(&vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
fc4a62
+}
fc4a62
+
fc4a62
+
fc4a62
 /*
fc4a62
  * sets some important partition data
fc4a62
  * (like used, start_trk, end_trk, len_trk)
fc4a62
@@ -769,6 +785,52 @@ fdasd_process_valid_vtoc (fdasd_anchor_t
fc4a62
 	fdasd_update_partition_info (anc);
fc4a62
 }
fc4a62
 
fc4a62
+static void
fc4a62
+fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
fc4a62
+{
fc4a62
+	PDEBUG
fc4a62
+	anc->formatted_cylinders = anc->hw_cylinders;
fc4a62
+	anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
fc4a62
+			- FIRST_USABLE_TRK;
fc4a62
+	vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
fc4a62
+			anc->geo.cylinders, anc->formatted_cylinders,
fc4a62
+			anc->geo.heads, anc->geo.sectors,
fc4a62
+			anc->blksize, anc->dev_type);
fc4a62
+
fc4a62
+	vtoc_init_format5_label(anc->f5);
fc4a62
+	vtoc_init_format7_label(anc->f7);
fc4a62
+
fc4a62
+	vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
fc4a62
+			FIRST_USABLE_TRK,
fc4a62
+			anc->formatted_cylinders * anc->geo.heads - 1,
fc4a62
+			anc->formatted_cylinders, anc->geo.heads);
fc4a62
+
fc4a62
+	vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
fc4a62
+}
fc4a62
+
fc4a62
+/*
fc4a62
+ * we have a invalid FMT4 DSCB and therefore we will re-create the VTOC
fc4a62
+ */
fc4a62
+static void
fc4a62
+fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
fc4a62
+{
fc4a62
+	anc->formatted_cylinders = anc->hw_cylinders;
fc4a62
+	anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
fc4a62
+			- FIRST_USABLE_TRK;
fc4a62
+	vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
fc4a62
+			anc->geo.cylinders, anc->formatted_cylinders,
fc4a62
+			anc->geo.heads, anc->geo.sectors,
fc4a62
+			anc->blksize, anc->dev_type);
fc4a62
+
fc4a62
+	vtoc_init_format5_label(anc->f5);
fc4a62
+	vtoc_init_format7_label(anc->f7);
fc4a62
+	vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
fc4a62
+			FIRST_USABLE_TRK,
fc4a62
+			anc->formatted_cylinders * anc->geo.heads - 1,
fc4a62
+			anc->formatted_cylinders, anc->geo.heads);
fc4a62
+}
fc4a62
+
fc4a62
+
fc4a62
 static int
fc4a62
 fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
fc4a62
 {
fc4a62
@@ -781,6 +843,8 @@ fdasd_valid_vtoc_pointer(fdasd_anchor_t
fc4a62
 	if (anc->f4->DS4IDFMT == 0xf4) {
fc4a62
 		fdasd_process_valid_vtoc (anc, b, fd);
fc4a62
 		return 0;
fc4a62
+	} else {
fc4a62
+		fdasd_process_invalid_vtoc(anc);
fc4a62
 	}
fc4a62
 	if (strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("LNX1",str,4),4) == 0 ||
fc4a62
 	    strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("CMS1",str,4),4) == 0)
fc4a62
@@ -817,13 +881,37 @@ fdasd_check_volume (fdasd_anchor_t *anc,
fc4a62
 			else
fc4a62
 				return 0;
fc4a62
 		} else {
fc4a62
-			return 1;
fc4a62
+			fdasd_invalid_vtoc_pointer(anc);
fc4a62
 		}
fc4a62
 	} else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0 ||
fc4a62
 	           strncmp (v->volkey, vtoc_ebcdic_enc ("CMS1", str, 4), 4) == 0) {
fc4a62
 		return 0;
fc4a62
+	} else if (anc->FBA_layout == 1) {
fc4a62
+		/* Some times LDL formatted disks does not
fc4a62
+		   contain any volume label */
fc4a62
+		return 1;
fc4a62
+	} else {
fc4a62
+	/* didn't find VOL1 volume label */
fc4a62
+		anc->formatted_cylinders = anc->hw_cylinders;
fc4a62
+		anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
fc4a62
+					- FIRST_USABLE_TRK;
fc4a62
+
fc4a62
+		fdasd_init_volume_label(anc, fd);
fc4a62
+
fc4a62
+		vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
fc4a62
+				anc->geo.cylinders, anc->formatted_cylinders,
fc4a62
+				anc->geo.heads, anc->geo.sectors,
fc4a62
+				anc->blksize, anc->dev_type);
fc4a62
+
fc4a62
+		vtoc_init_format5_label(anc->f5);
fc4a62
+		vtoc_init_format7_label(anc->f7);
fc4a62
+
fc4a62
+		vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+',
fc4a62
+			anc->verbose, FIRST_USABLE_TRK,
fc4a62
+			anc->formatted_cylinders * anc->geo.heads - 1,
fc4a62
+			anc->formatted_cylinders, anc->geo.heads);
fc4a62
+		return 0;
fc4a62
 	}
fc4a62
-
fc4a62
 	return 1;
fc4a62
 }
fc4a62