@@ -52,7 +52,7 @@ int prout_do_scsi_ioctl(char * dev, int rq_servact, int rq_scope,
int fd = -1;
snprintf(devname, FILE_NAME_SIZE, "/dev/%s",dev);
- fd = open(devname, O_WRONLY);
+ fd = open(devname, O_RDONLY);
if(fd < 0){
condlog (1, "%s: unable to open device.", dev);
return MPATH_PR_FILE_ERROR;
@@ -308,7 +308,7 @@ int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp * resp, int
{MPATH_PRIN_CMD, 0, 0, 0, 0, 0, 0, 0, 0, 0};
snprintf(devname, FILE_NAME_SIZE, "/dev/%s",dev);
- fd = open(devname, O_WRONLY);
+ fd = open(devname, O_RDONLY);
if(fd < 0){
condlog(0, "%s: Unable to open device ", dev);
return MPATH_PR_FILE_ERROR;
@@ -380,7 +380,7 @@ int main (int argc, char * argv[])
}
/* open device */
- if ((fd = open (device_name, O_WRONLY)) < 0)
+ if ((fd = open (device_name, O_RDONLY)) < 0)
{
fprintf (stderr, "%s: error opening file (rw) fd=%d\n",
device_name, fd);
udevd catches close-after-write inotify events and generates "change" uvents for such devices, which may cause extra unnecessary and unwanted udev activity. Therefore use O_RDONLY file descriptors for PRIN and PROUT commands. This works just as well as O_WRONLY. sg_persist has supported the --readonly option for years. Signed-off-by: Martin Wilck <mwilck@suse.com> --- libmpathpersist/mpath_pr_ioctl.c | 4 ++-- mpathpersist/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)