]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: canonicalize node in varlink Run method
authorDaan De Meyer <daan@amutable.com>
Wed, 13 May 2026 21:01:41 +0000 (23:01 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 20 May 2026 14:22:00 +0000 (16:22 +0200)
Run acquire_root_devno() on the varlink-provided node so symlinks (e.g.
/dev/disk/by-id/...) resolve to their canonical /dev/ path before being
used. Without this, sym_fdisk_partname() produces a "-partN" symlink
that udev hasn't created yet when repart calls open() on it right after
BLKPG_ADD_PARTITION, failing with ENOENT.

This also brings the varlink path in line with the CLI path's
partition-to-whole-disk and dm-crypt-to-backing resolution.

src/repart/repart.c

index 133a8e02118dceaf551fa4d8b613f49427da04f8..8cfb798339538920439e2249280b7813e5756541 100644 (file)
@@ -10964,7 +10964,7 @@ static int find_root(Context *context) {
         } else if (r < 0)
                 return log_error_errno(r, "Failed to read symlink /run/systemd/volatile-root: %m");
         else {
-                r = acquire_root_devno(device, NULL, open_flags, &context->node, &context->backing_fd);
+                r = acquire_root_devno(device, /* root= */ NULL, open_flags, &context->node, &context->backing_fd);
                 if (r == -EUCLEAN)
                         return btrfs_log_dev_root(LOG_ERR, r, device);
                 if (r < 0)
@@ -11389,7 +11389,9 @@ static int vl_method_run(
                 return r;
 
         if (p.node) {
-                context->node = TAKE_PTR(p.node);
+                r = acquire_root_devno(p.node, NULL, O_CLOEXEC|context_open_mode(context), &context->node, &context->backing_fd);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to open file or determine backing device of %s: %m", p.node);
 
                 r = context_load_partition_table(context);
                 if (r == -EHWPOISON)