]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
open_mddev: open RDONLY if RDWR doesn't work.
authorNeilBrown <neilb@suse.de>
Mon, 31 Jan 2011 03:49:39 +0000 (14:49 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 31 Jan 2011 03:49:39 +0000 (14:49 +1100)
If an array is read-only then "mdadm -S"
cannot open it to stop it without this fix.

Signed-off-by: NeilBrown <neilb@suse.de>
mdopen.c

index 21baf5da8bb5532e2eff3f494598758f2624e7c6..0a174211512d5d16c98f43e80c2eb2a821f086a8 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -390,6 +390,8 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 int open_mddev(char *dev, int report_errors)
 {
        int mdfd = open(dev, O_RDWR);
+       if (mdfd < 0 && errno == EACCES)
+               mdfd = open(dev, O_RDONLY);
        if (mdfd < 0) {
                if (report_errors)
                        fprintf(stderr, Name ": error opening %s: %s\n",