From: Lennart Poettering Date: Tue, 23 Mar 2021 13:04:59 +0000 (+0100) Subject: blockdev-util: actually specify an access mode on open() X-Git-Tag: v248-2~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86b86107942e84de4eb22944251694c0ae21b3ee;p=thirdparty%2Fsystemd.git blockdev-util: actually specify an access mode on open() Linux is pretty lenient here, but we should specify the access mode. --- diff --git a/src/basic/blockdev-util.c b/src/basic/blockdev-util.c index 2f3f1aecc8a..676ad9351b2 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;