summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-09-18 15:13:32 +1000
committerNeilBrown <neilb@suse.de>2008-09-18 15:13:32 +1000
commit7801ac209240ca5d5159d2ab990dd8d5573e2195 (patch)
tree9eef66102669532a41150d2750c234b6cf658bfe /util.c
parent9b2a22d319a85c1571c776e7059d9ca4bf1a0f0a (diff)
Factor out add-disk code
The variety of approaches to 'add_disk' are factored out into a separate function, and Incremental mode benefits by being closer to supporting the assembly of containers. Also remove the adding-to-array-data-structure out of sysfs_add_disk and into add_disk. And add some tests for --incremental mode to make sure we don't break it. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.c b/util.c
index 181a0a3c..7469fca4 100644
--- a/util.c
+++ b/util.c
@@ -999,6 +999,27 @@ int open_container(int fd)
return -1;
}
+int add_disk(int mdfd, struct supertype *st,
+ struct mdinfo *sra, struct mdinfo *info)
+{
+ /* Add a device to an array, in one of 2 ways. */
+ int rv;
+#ifndef MDASSEMBLE
+ if (st->ss->external) {
+ rv = sysfs_add_disk(sra, info);
+ if (! rv) {
+ struct mdinfo *sd2;
+ sd2 = malloc(sizeof(*sd2));
+ *sd2 = *info;
+ sd2->next = sra->devs;
+ sra->devs = sd2;
+ }
+ } else
+#endif
+ rv = ioctl(mdfd, ADD_NEW_DISK, &info->disk);
+ return rv;
+}
+
char *devnum2devname(int num)
{
char name[100];