summaryrefslogtreecommitdiff
path: root/Manage.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-07-06 14:46:47 +1000
committerNeilBrown <neilb@suse.de>2010-07-06 14:46:47 +1000
commit1538aca5cbbd99be47657e0ca0b7e2186426a1b1 (patch)
treef4750261bcd916a5714154d310c6a9e87769c7f0 /Manage.c
parent7d2e6486e34180215e4859c3b342246dfc6c07a0 (diff)
parentd19e3cfb6627c40e3a28454ebc2098c0e19b9a77 (diff)
downloadmdadm-1538aca5cbbd99be47657e0ca0b7e2186426a1b1.tar.gz
Merge branch 'master' of git://github.com/djbw/mdadm
Diffstat (limited to 'Manage.c')
-rw-r--r--Manage.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/Manage.c b/Manage.c
index c9a3705..3680d68 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1005,4 +1005,57 @@ int autodetect(void)
}
return rv;
}
+
+int Update_subarray(char *dev, char *subarray, char *update, mddev_ident_t ident, int quiet)
+{
+ struct supertype supertype, *st = &supertype;
+ int fd, rv = 2;
+
+ memset(st, 0, sizeof(*st));
+ if (snprintf(st->subarray, sizeof(st->subarray), "%s", subarray) >=
+ sizeof(st->subarray)) {
+ if (!quiet)
+ fprintf(stderr,
+ Name ": Input overflow for subarray '%s' > %zu bytes\n",
+ subarray, sizeof(st->subarray) - 1);
+ return 2;
+ }
+
+ fd = open_subarray(dev, st, quiet);
+ if (fd < 0)
+ return 2;
+
+ if (!st->ss->update_subarray) {
+ if (!quiet)
+ fprintf(stderr,
+ Name ": Operation not supported for %s metadata\n",
+ st->ss->name);
+ goto free_super;
+ }
+
+ if (mdmon_running(st->devnum))
+ st->update_tail = &st->updates;
+
+ rv = st->ss->update_subarray(st, update, ident);
+
+ if (rv) {
+ if (!quiet)
+ fprintf(stderr, Name ": Failed to update %s of subarray-%s in %s\n",
+ update, subarray, dev);
+ } else if (st->update_tail)
+ flush_metadata_updates(st);
+ else
+ st->ss->sync_metadata(st);
+
+ if (rv == 0 && strcmp(update, "name") == 0 && !quiet)
+ fprintf(stderr,
+ Name ": Updated subarray-%s name from %s, UUIDs may have changed\n",
+ subarray, dev);
+
+ free_super:
+ st->ss->free_super(st);
+ close(fd);
+
+ return rv;
+}
#endif