summaryrefslogtreecommitdiff
path: root/Create.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-07-09 17:14:17 +1000
committerNeilBrown <neilb@suse.de>2012-07-09 17:14:17 +1000
commit72d566f68d495261608a900b2d8cb8d037cd9178 (patch)
treed960093c9a46d85258fda0cd741caa35c94ae061 /Create.c
parent0ea8f5b167d3e98fa09d392079fc5e269b5a0395 (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.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Create.c b/Create.c
index af094952..ed6d2ae3 100644
--- a/Create.c
+++ b/Create.c
@@ -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, &param)) {
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");