summaryrefslogtreecommitdiff
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-11-30 16:56:01 +1100
committerNeilBrown <neilb@suse.de>2010-11-30 16:56:01 +1100
commit484ae54d16d7e4c271a484cdd691a5ba7c52d6d6 (patch)
treed416e3e4c8b821b2c9d5b674f1785236a215b02f /Assemble.c
parent5a31170d95236fdfd35a62cd3d7345ac43a75104 (diff)
Assemble: call remove_partitions later.
We shouldn't call remove_partitions until we have made a really firm decision to include the device into the array. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Assemble.c b/Assemble.c
index a152d656..5e71a434 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -648,8 +648,6 @@ int Assemble(struct supertype *st, char *mddev,
}
dfd = dev_open(devname, O_RDWR|O_EXCL);
- remove_partitions(dfd);
-
tst = dup_super(st);
if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
@@ -714,8 +712,6 @@ int Assemble(struct supertype *st, char *mddev,
int dfd;
dfd = dev_open(devname, O_RDWR|O_EXCL);
- remove_partitions(dfd);
-
if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
devname);
@@ -1181,6 +1177,12 @@ int Assemble(struct supertype *st, char *mddev,
j = chosen_drive;
if (j >= 0 /* && devices[j].uptodate */) {
+ int dfd = dev_open(devices[j].devname,
+ O_RDWR|O_EXCL);
+ if (dfd >= 0) {
+ remove_partitions(dfd);
+ close(dfd);
+ }
rv = add_disk(mdfd, st, content, &devices[j].i);
if (rv) {