]> git.ipfire.org Git - thirdparty/util-linux.git/commit
losetup: cleanup device node modes
authorKarel Zak <kzak@redhat.com>
Tue, 15 Aug 2023 10:32:49 +0000 (12:32 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 Aug 2023 14:03:05 +0000 (16:03 +0200)
commitced1142d6f25a19ebaac7afbc1376a786059924c
tree6729976ce788c6254ccc70f39364ecca3744442a
parent3119a8060102ed7dd04d4a782932494c386f72a6
losetup: cleanup device node modes

The current code follows ro/rw mode not only set mode of the new
device, but also to open the device node for ioctls.

Linux kernel does not care and it seems O_RDONLY is good enough
for all cases (ioctls).

Unfortunately, udevd is sensitive as it monitors devices by inotify
and IN_CLOSE_WRITE event is expected to apply udev rules for the
device.

Changes:

* remove LOOPDEV_FL_{RDONLY,RDWR} private flags, it's too complex and
  unnecessary

* use mode_t for open() modes (rater than int)

* re-open only if O_RDWR requested otherwise default to O_RDONLY

* make sure O_RDWR is used on device setup

Fixes: https://github.com/util-linux/util-linux/issues/2434
Signed-off-by: Karel Zak <kzak@redhat.com>
include/loopdev.h
lib/loopdev.c