diff options
author | NeilBrown <neilb@suse.de> | 2010-07-06 14:46:47 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-07-06 14:46:47 +1000 |
commit | 1538aca5cbbd99be47657e0ca0b7e2186426a1b1 (patch) | |
tree | f4750261bcd916a5714154d310c6a9e87769c7f0 /Manage.c | |
parent | 7d2e6486e34180215e4859c3b342246dfc6c07a0 (diff) | |
parent | d19e3cfb6627c40e3a28454ebc2098c0e19b9a77 (diff) | |
download | mdadm-1538aca5cbbd99be47657e0ca0b7e2186426a1b1.tar.gz |
Merge branch 'master' of git://github.com/djbw/mdadm
Diffstat (limited to 'Manage.c')
-rw-r--r-- | Manage.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -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 |