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;
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();
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)
}
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);
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