[PATCH 04/27] DDF: handle "open flag" according to spec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The DDF spec mandates that the "open flag" be set to non-0 before
writing a configuration, and reset to 0 when finished to indicate
success.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 super-ddf.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/super-ddf.c b/super-ddf.c
index 45522f2..b806949 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -2518,6 +2518,7 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type,
 	unsigned long long sector;
 	struct ddf_header *header;
 	int fd, i, n_config, conf_size;
+	int ret = 0;
 
 	fd = d->fd;
 
@@ -2535,23 +2536,23 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type,
 	}
 
 	header->type = type;
-	header->openflag = 0;
+	header->openflag = 1;
 	header->crc = calc_crc(header, 512);
 
 	lseek64(fd, sector<<9, 0);
 	if (write(fd, header, 512) < 0)
-		return 0;
+		goto out;
 
 	ddf->controller.crc = calc_crc(&ddf->controller, 512);
 	if (write(fd, &ddf->controller, 512) < 0)
-		return 0;
+		goto out;
 
 	ddf->phys->crc = calc_crc(ddf->phys, ddf->pdsize);
 	if (write(fd, ddf->phys, ddf->pdsize) < 0)
-		return 0;
+		goto out;
 	ddf->virt->crc = calc_crc(ddf->virt, ddf->vdsize);
 	if (write(fd, ddf->virt, ddf->vdsize) < 0)
-		return 0;
+		goto out;
 
 	/* Now write lots of config records. */
 	n_config = ddf->max_part;
@@ -2590,13 +2591,22 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type,
 		}
 	}
 	if (i <= n_config)
-		return 0;
+		goto out;
 
 	d->disk.crc = calc_crc(&d->disk, 512);
 	if (write(fd, &d->disk, 512) < 0)
-		return 0;
+		goto out;
 
-	return 1;
+	ret = 1;
+out:
+	header->openflag = 0;
+	header->crc = calc_crc(header, 512);
+
+	lseek64(fd, sector<<9, 0);
+	if (write(fd, header, 512) < 0)
+		ret = 0;
+
+	return ret;
 }
 
 static int __write_init_super_ddf(struct supertype *st)
-- 
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux