diff options
author | mwilck@arcor.de <mwilck@arcor.de> | 2013-07-03 22:27:44 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-07-08 15:28:31 +1000 |
commit | a4057a88a2f0959690a7eb3e5cbfa1a585a0a71a (patch) | |
tree | 70d9ad78777ebb9171ccb5014670d1ede54a98ca /super-ddf.c | |
parent | dbeb699a77e898bb82b90342348dc59743b0c16f (diff) | |
download | mdadm-a4057a88a2f0959690a7eb3e5cbfa1a585a0a71a.tar.gz |
DDF: handle "open flag" according to spec
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@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super-ddf.c')
-rw-r--r-- | super-ddf.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/super-ddf.c b/super-ddf.c index 45522f2e..b8069496 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) |