From 3d74c534bfec942777ddbb106e3b2b80036d32ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Tue, 26 Nov 2019 15:30:09 +0100 Subject: [PATCH] libdasd: Fix flag for opening read-only devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: a5c1923d328e ("libdasd: Add common DASD ioctl's to the lib") Reviewed-by: Marc Hartmayer Reviewed-by: Stefan Haberland --- libdasd/dasd_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdasd/dasd_ioctl.c b/libdasd/dasd_ioctl.c index 49d2cea9..f9549612 100644 --- a/libdasd/dasd_ioctl.c +++ b/libdasd/dasd_ioctl.c @@ -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);