summaryrefslogtreecommitdiffstats
path: root/Incremental.c
diff options
context:
space:
mode:
Diffstat (limited to 'Incremental.c')
-rw-r--r--Incremental.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/Incremental.c b/Incremental.c
index 8bc455d..d3dd0c3 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -941,7 +941,7 @@ static int IncrementalNewDisk(char *devname, int verbose, int export,
struct domain_ent *domain)
{
struct stat stb;
- int dfd;
+ int dfd, rv;
dfd = dev_open_check(devname, O_RDONLY|O_EXCL, &stb);
if (dfd < 0)
@@ -954,8 +954,11 @@ static int IncrementalNewDisk(char *devname, int verbose, int export,
close(dfd);
return 1;
}
- if (domain->handler->check_table(dfd, verbose, export, domain) == 0)
+
+ if (domain->handler->check_table(dfd, verbose, export, domain) == 0) {
+ close(dfd);
return 0;
+ }
/*
* OK, at this point we have a valid block device without a
* superblock, the partition table doesn't match, and we are a
@@ -965,10 +968,11 @@ static int IncrementalNewDisk(char *devname, int verbose, int export,
* last 4k of the device must be one of three patterns: 0x00, 0x5a,
* or 0xff.
*/
- if (force(domain))
- return domain->handler->write_table(dfd, verbose, export,
- domain);
- return 0;
+ if (check_clean(dfd) || force(domain)) {
+ rv = domain->handler->write_table(dfd, verbose, export, domain);
+ }
+ close(dfd);
+ return rv;
}
/*