summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Examine.c3
-rw-r--r--Incremental.c5
-rw-r--r--mdadm.h1
-rw-r--r--util.c14
4 files changed, 17 insertions, 6 deletions
diff --git a/Examine.c b/Examine.c
index 3c1e73f9..ffca9ca5 100644
--- a/Examine.c
+++ b/Examine.c
@@ -76,11 +76,10 @@ int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
err = 1;
}
else {
- unsigned long long size;
int container = 0;
if (forcest)
st = dup_super(forcest);
- else if (get_dev_size(fd, NULL, &size) == 0 || size == 0) {
+ else if (must_be_container(fd)) {
/* might be a container */
st = super_by_fd(fd, NULL);
container = 1;
diff --git a/Incremental.c b/Incremental.c
index 0df69b7d..b7bf0b4f 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -103,7 +103,6 @@ int Incremental(char *devname, int verbose, int runstop,
char *name_to_use;
mdu_array_info_t ainf;
struct dev_policy *policy = NULL;
- unsigned long long size;
struct createinfo *ci = conf_get_create_info();
@@ -127,9 +126,7 @@ int Incremental(char *devname, int verbose, int runstop,
return rv;
}
/* If the device is a container, we do something very different */
- if (get_dev_size(dfd, devname, &size) == 0)
- goto out;
- if (size == 0) {
+ if (must_be_container(dfd)) {
if (!st)
st = super_by_fd(dfd, NULL);
if (st)
diff --git a/mdadm.h b/mdadm.h
index 6d1169b1..13e1df94 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -739,6 +739,7 @@ static inline struct supertype *guess_super(int fd) {
}
extern struct supertype *dup_super(struct supertype *st);
extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
+extern int must_be_container(int fd);
extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
mdu_disk_info_t *disk);
void wait_for(char *dev, int fd);
diff --git a/util.c b/util.c
index f744cdbe..ac5d8b13 100644
--- a/util.c
+++ b/util.c
@@ -1189,6 +1189,20 @@ int get_dev_size(int fd, char *dname, unsigned long long *sizep)
return 1;
}
+/* Return true if this can only be a container, not a member device.
+ * i.e. is and md device and size is zero
+ */
+int must_be_container(int fd)
+{
+ unsigned long long size;
+ if (md_get_version(fd) < 0)
+ return 0;
+ if (get_dev_size(fd, NULL, &size) == 0)
+ return 1;
+ if (size == 0)
+ return 1;
+ return 0;
+}
/* Sets endofpart parameter to the last block used by the last GPT partition on the device.
* Returns: 1 if successful