]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
dev_open should always open read-only.
authorNeilBrown <neilb@suse.de>
Thu, 10 Mar 2011 00:41:21 +0000 (11:41 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 10 Mar 2011 05:54:32 +0000 (16:54 +1100)
When opening an array to manipulate it we never need to write to the
array and  sometimes it might be read-only so the open for write will
fail.
So always open read-only.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
util.c

diff --git a/util.c b/util.c
index 75a5e6df33ade38db8ad54773159ef6a2973ce07..52171cc230c1b4f418014fa88dd36daf382614ad 100644 (file)
--- a/util.c
+++ b/util.c
@@ -994,7 +994,7 @@ int open_dev(int devnum)
        char buf[20];
 
        sprintf(buf, "%d:%d", dev2major(devnum), dev2minor(devnum));
-       return dev_open(buf, O_RDWR);
+       return dev_open(buf, O_RDONLY);
 }
 
 int open_dev_excl(int devnum)