mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user