summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-11-22 10:58:06 +0100
committerNeilBrown <neilb@suse.de>2010-11-22 10:58:06 +0100
commit3a3716107b614f679a4ea224e5bb882739d81cf9 (patch)
tree7874c3cc38822e3ca4e3af9909d3c7278d73ae63 /util.c
parentAssemble: turn next_member goto loop into a for loop. (diff)
downloadmdadm-3a3716107b614f679a4ea224e5bb882739d81cf9.tar.xz
mdadm-3a3716107b614f679a4ea224e5bb882739d81cf9.zip
Add must_be_container helper.
This checks a block device to see if it could be a container, and in particular cannot be a member device. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 14 insertions, 0 deletions
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