]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
storagetm: ensure device lock fd is opened for writing
authorMike Yuan <me@yhndnzj.com>
Sun, 25 Jan 2026 15:50:34 +0000 (16:50 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Jan 2026 01:56:22 +0000 (10:56 +0900)
Follow-up for e582484789a6d889d11b97d9c2afa74c3c985130

_cleanup_close_ is dropped, as the fd would be immediately
consumed by the nvme_subsystem_add() call below anyways.

src/storagetm/storagetm.c

index 54d516ef128b4d6c8f377be81b52f14fef11fc9f..8d1bf0732bc7933b0c55e6e1a6fcd957ca7c8a1e 100644 (file)
@@ -923,7 +923,6 @@ static bool device_is_allowed(sd_device *d) {
 }
 
 static int device_added(Context *c, sd_device *device) {
-        _cleanup_close_ int fd = -EBADF;
         int r;
 
         assert(c);
@@ -967,7 +966,7 @@ static int device_added(Context *c, sd_device *device) {
                 return 0;
         }
 
-        fd = sd_device_open(device, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
+        int fd = sd_device_open(device, O_RDWR|O_CLOEXEC|O_NONBLOCK);
         if (fd < 0) {
                 log_device_warning_errno(device, fd, "Failed to open newly acquired device '%s', ignoring device: %m", devname);
                 return 0;