Blame SOURCES/parted-3.1-avoid-dasd-as-default-file-image-type.patch

fc4a62
Subject: [PATCH] libparted: Avoid dasd as default disk type while probe
fc4a62
fc4a62
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
fc4a62
fc4a62
This patch avoids setting 'dasd' as a default disk type for
fc4a62
'disk image file' at the time of probe.
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  |    6 +++++-
fc4a62
 2 files changed, 6 insertions(+), 1 deletion(-)
fc4a62
fc4a62
--- a/include/parted/fdasd.h
fc4a62
+++ b/include/parted/fdasd.h
fc4a62
@@ -261,6 +261,7 @@ typedef struct fdasd_anchor {
fc4a62
 	struct fdasd_hd_geometry geo;
fc4a62
 	unsigned int label_block;
fc4a62
 	unsigned int FBA_layout;
fc4a62
+	bool is_file;
fc4a62
 } fdasd_anchor_t;
fc4a62
 
fc4a62
 enum offset {lower, upper};
fc4a62
--- a/libparted/labels/fdasd.c
fc4a62
+++ b/libparted/labels/fdasd.c
fc4a62
@@ -301,6 +301,7 @@ fdasd_initialize_anchor (fdasd_anchor_t
fc4a62
 	}
fc4a62
 	anc->hw_cylinders = 0;
fc4a62
 	anc->formatted_cylinders = 0;
fc4a62
+	anc->is_file = 0;
fc4a62
 }
fc4a62
 
fc4a62
 /*
fc4a62
@@ -892,7 +893,7 @@ fdasd_check_volume (fdasd_anchor_t *anc,
fc4a62
 		/* Some times LDL formatted disks does not
fc4a62
 		   contain any volume label */
fc4a62
 		return 1;
fc4a62
-	} else {
fc4a62
+	} else if (! anc->is_file) {
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
@@ -976,6 +977,7 @@ fdasd_get_geometry (const PedDevice *dev
fc4a62
 	    dasd_info.FBA_layout = 0;
fc4a62
 	    anc->hw_cylinders = ((st.st_size / blksize) / anc->geo.sectors) /
fc4a62
 				anc->geo.heads;
fc4a62
+	    anc->is_file = 1;
fc4a62
 	} else {
fc4a62
 		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fc4a62
 			fdasd_error(anc, unable_to_ioctl,
fc4a62
@@ -997,6 +999,8 @@ fdasd_get_geometry (const PedDevice *dev
fc4a62
 			anc->hw_cylinders = characteristics->long_no_cyl;
fc4a62
 		else
fc4a62
 			anc->hw_cylinders = characteristics->no_cyl;
fc4a62
+
fc4a62
+		anc->is_file = 0;
fc4a62
 	}
fc4a62
 
fc4a62
 	anc->dev_type   = dasd_info.dev_type;