summaryrefslogtreecommitdiffstats
path: root/mdopen.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-12-05 07:27:03 +0100
committerJes Sorensen <Jes.Sorensen@redhat.com>2016-12-05 15:26:22 +0100
commitf71d2b8f4bd50888d1e20e9fdf7af9beb0729aae (patch)
treed9be5c2762e7c4ccd14188c0a97121fd8125c4a2 /mdopen.c
parentimsm: 4kn support for bad block log (diff)
downloadmdadm-f71d2b8f4bd50888d1e20e9fdf7af9beb0729aae.tar.xz
mdadm-f71d2b8f4bd50888d1e20e9fdf7af9beb0729aae.zip
mdopen: open md devices O_RDONLY
There is no need to request write access when opening the md device, as we never write to it, and none of the ioctls we use require write access. If we do open with write access, then when we close, udev notices that the device was closed after being open for write access, and it generates a CHANGE event. This is generally unwanted, and particularly problematic when mdadm is trying to --stop the array, as the CHANGE event can cause the array to be re-opened before it completely closed, which results in a new mddev being allocated. So just use O_RDONLY instead of O_RDWR. Reported-by: Marc Smith <marc.smith@mcc.edu> Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Diffstat (limited to 'mdopen.c')
-rw-r--r--mdopen.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/mdopen.c b/mdopen.c
index 0ea38749..685ca328 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -416,9 +416,7 @@ 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);
+ int mdfd = open(dev, O_RDONLY);
if (mdfd < 0) {
if (report_errors)
pr_err("error opening %s: %s\n",