From 857533a523d058e9833a553f6ef192ff1ab33b15 Mon Sep 17 00:00:00 2001 From: Lennart Poettering <lennart@poettering.net> Date: Tue, 23 Mar 2021 14:04:59 +0100 Subject: [PATCH] blockdev-util: actually specify an access mode on open() Linux is pretty lenient here, but we should specify the access mode. (cherry picked from commit 86b86107942e84de4eb22944251694c0ae21b3ee) --- src/basic/blockdev-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/blockdev-util.c b/src/basic/blockdev-util.c index 2f3f1aecc8..676ad9351b 100644 --- a/src/basic/blockdev-util.c +++ b/src/basic/blockdev-util.c @@ -68,7 +68,7 @@ int get_block_device(const char *path, dev_t *ret) { /* Gets the block device directly backing a file system. If the block device is encrypted, returns * the device mapper block device. */ - fd = open(path, O_NOFOLLOW|O_CLOEXEC); + fd = open(path, O_RDONLY|O_NOFOLLOW|O_CLOEXEC); if (fd < 0) return -errno;