Blob Blame History Raw
Subject: [PATCH] libparted: Avoid dasd as default disk type while probe

From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>

This patch avoids setting 'dasd' as a default disk type for
'disk image file' at the time of probe.

Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
 include/parted/fdasd.h    |    1 +
 libparted/labels/fdasd.c  |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

--- a/include/parted/fdasd.h
+++ b/include/parted/fdasd.h
@@ -261,6 +261,7 @@ typedef struct fdasd_anchor {
 	struct fdasd_hd_geometry geo;
 	unsigned int label_block;
 	unsigned int FBA_layout;
+	bool is_file;
 } fdasd_anchor_t;
 
 enum offset {lower, upper};
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -301,6 +301,7 @@ fdasd_initialize_anchor (fdasd_anchor_t
 	}
 	anc->hw_cylinders = 0;
 	anc->formatted_cylinders = 0;
+	anc->is_file = 0;
 }
 
 /*
@@ -892,7 +893,7 @@ fdasd_check_volume (fdasd_anchor_t *anc,
 		/* Some times LDL formatted disks does not
 		   contain any volume label */
 		return 1;
-	} else {
+	} else if (! anc->is_file) {
 	/* didn't find VOL1 volume label */
 		anc->formatted_cylinders = anc->hw_cylinders;
 		anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
@@ -976,6 +977,7 @@ fdasd_get_geometry (const PedDevice *dev
 	    dasd_info.FBA_layout = 0;
 	    anc->hw_cylinders = ((st.st_size / blksize) / anc->geo.sectors) /
 				anc->geo.heads;
+	    anc->is_file = 1;
 	} else {
 		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
 			fdasd_error(anc, unable_to_ioctl,
@@ -997,6 +999,8 @@ fdasd_get_geometry (const PedDevice *dev
 			anc->hw_cylinders = characteristics->long_no_cyl;
 		else
 			anc->hw_cylinders = characteristics->no_cyl;
+
+		anc->is_file = 0;
 	}
 
 	anc->dev_type   = dasd_info.dev_type;