summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-04-29 16:09:59 +1000
committerNeilBrown <neilb@suse.de>2010-04-29 16:09:59 +1000
commit691c6ee1b6bb77bc44a5474d856771b0aec9882d (patch)
tree64b9b56a0662289302e13307ad6dc1d1289941b2 /util.c
parent4eb269706f403d2424166683688f0a41d893c1c3 (diff)
IMSM/DDF: don't recognised these metadata on partitions.
These metadata are not expected on partitions, and they have no way of differentiation whether which is correct if they are found both on the device and on the last partition. So if the device is a partition, refuse to read the metadata. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/util.c b/util.c
index 79d2b0fe..25f1e56a 100644
--- a/util.c
+++ b/util.c
@@ -302,6 +302,31 @@ void remove_partitions(int fd)
#endif
}
+int test_partition(int fd)
+{
+ /* Check if fd is a whole-disk or a partition.
+ * BLKPG will return EINVAL on a partition, and BLKPG_DEL_PARTITION
+ * will return ENXIO on an invalid partition number.
+ */
+ struct blkpg_ioctl_arg a;
+ struct blkpg_partition p;
+ a.op = BLKPG_DEL_PARTITION;
+ a.data = (void*)&p;
+ a.datalen = sizeof(p);
+ a.flags = 0;
+ memset(a.data, 0, a.datalen);
+ p.pno = 1<<30;
+ if (ioctl(fd, BLKPG, &a) == 0)
+ /* Very unlikely, but not a partition */
+ return 0;
+ if (errno == ENXIO)
+ /* not a partition */
+ return 0;
+
+ return 1;
+}
+
+
int enough(int level, int raid_disks, int layout, int clean,
char *avail, int avail_disks)
{