From: Mike Yuan Date: Sun, 25 Jan 2026 15:50:34 +0000 (+0100) Subject: storagetm: ensure device lock fd is opened for writing X-Git-Tag: v257.11~89 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5d99d4e1619ebe1ce5c4797a3e4f601144dc1f0;p=thirdparty%2Fsystemd.git storagetm: ensure device lock fd is opened for writing Follow-up for e582484789a6d889d11b97d9c2afa74c3c985130 _cleanup_close_ is dropped, as the fd would be immediately consumed by the nvme_subsystem_add() call below anyways. (cherry picked from commit 28fb7e869c6be086fc7ab8ddbc8a4e00b53714b6) (cherry picked from commit a827513472cda8f65faabc536ef396189d6ecd15) (cherry picked from commit 763a2a400c4509800ada9da1bd1ac3a7438a3624) --- diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index ca8e886d37d..cb960088daa 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -937,7 +937,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); @@ -981,7 +980,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;