]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
blockdev-util: actually specify an access mode on open()
authorLennart Poettering <lennart@poettering.net>
Tue, 23 Mar 2021 13:04:59 +0000 (14:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Mar 2021 15:37:05 +0000 (16:37 +0100)
Linux is pretty lenient here, but we should specify the access mode.

src/basic/blockdev-util.c

index 2f3f1aecc8a99c277422940abebabc47d46db13f..676ad9351b25e7c2c7daa3d86a9eca4534bda379 100644 (file)
@@ -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;