diff options
author | NeilBrown <neilb@suse.de> | 2012-07-09 17:14:17 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-07-09 17:14:17 +1000 |
commit | 72d566f68d495261608a900b2d8cb8d037cd9178 (patch) | |
tree | d960093c9a46d85258fda0cd741caa35c94ae061 /Create.c | |
parent | 0ea8f5b167d3e98fa09d392079fc5e269b5a0395 (diff) |
Create: support --readonly flag.
Allow array to be created read-only
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Create.c')
-rw-r--r-- | Create.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -67,7 +67,8 @@ int Create(struct supertype *st, char *mddev, int raiddisks, int sparedisks, char *name, char *homehost, int *uuid, int subdevs, struct mddev_dev *devlist, - int runstop, int verbose, int force, int assume_clean, + int runstop, int readonly, int verbose, + int force, int assume_clean, char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int autof) { @@ -958,7 +959,9 @@ int Create(struct supertype *st, char *mddev, case LEVEL_MULTIPATH: case 0: err = sysfs_set_str(&info, NULL, "array_state", - "active"); + readonly + ? "readonly" + : "active"); need_mdmon = 0; break; default: @@ -973,12 +976,22 @@ int Create(struct supertype *st, char *mddev, ioctl(mdfd, STOP_ARRAY, NULL); goto abort; } + } else if (readonly && + sysfs_attribute_available( + &info, NULL, "array_state")) { + if (sysfs_set_str(&info, NULL, + "array_state", "readonly") < 0) { + pr_err("Failed to start array: %s\n", + strerror(errno)); + ioctl(mdfd, STOP_ARRAY, NULL); + goto abort; + } } else { /* param is not actually used */ mdu_param_t param; if (ioctl(mdfd, RUN_ARRAY, ¶m)) { pr_err("RUN_ARRAY failed: %s\n", - strerror(errno)); + strerror(errno)); if (info.array.chunk_size & (info.array.chunk_size-1)) { cont_err("Problem may be that " "chunk size is not a power of 2\n"); |