libdasd: Fix flag for opening read-only devices

dasd_is_ro() uses the O_RDWR flag when opening the file descriptor.
However, an attempt to open the file descriptor of a device that is in
read-only state will fail and the BLKROGET ioctl that is used to
actually determine the read-only state can't be issued.
Change the flag to O_RDONLY to fix this.

Fixes: a5c1923d32 ("libdasd: Add common DASD ioctl's to the lib")
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2019-11-26 15:30:09 +01:00
parent ca2ffe9e18
commit 3d74c534bf

View File

@@ -146,7 +146,7 @@ int dasd_is_ro(const char *device, bool *ro)
{
int fd, val;
fd = dasd_open_device(device, O_RDWR);
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKROGET, &val);
*ro = (val != 0) ? true : false;
dasd_close_device(fd);