From: Daan De Meyer Date: Wed, 13 May 2026 19:23:48 +0000 (+0200) Subject: repart: Add debug logging for block_device_partition_add() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd7a152345cf58b034ceefb0fe7ca58b8cf38e13;p=thirdparty%2Fsystemd.git repart: Add debug logging for block_device_partition_add() --- diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 6ed6cf2f8a0..d38800d2607 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -278,6 +278,13 @@ assert_cc(sizeof(long long) == sizeof(intmax_t)); CONST_ISPOWEROF2(_x); \ })) +/* Returns the largest power of two that divides x (i.e. x's natural alignment in bytes), or 0 if x is 0. */ +#define NATURAL_ALIGNMENT(x) \ + ({ \ + const uint64_t _x = (x); \ + _x == 0 ? UINT64_C(0) : UINT64_C(1) << __builtin_ctzll(_x); \ + }) + #define ADD_SAFE(ret, a, b) (!__builtin_add_overflow(a, b, ret)) #define INC_SAFE(a, b) __INC_SAFE(UNIQ, a, b) #define __INC_SAFE(q, a, b) \ diff --git a/src/repart/repart.c b/src/repart/repart.c index 331b31b7899..0cdfef56be3 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -5202,6 +5202,10 @@ static int partition_target_prepare( * keep them alive if we succeed, and the rescan will remove them if possible if * there is an error before writing the partition table. */ + log_debug("Adding partition '%s' (nr=%i, offset=%" PRIu64 " [align=%" PRIu64 "], size=%" PRIu64 " [align=%" PRIu64 "])", + part_node, nr, + p->offset, NATURAL_ALIGNMENT(p->offset), + size, NATURAL_ALIGNMENT(size)); r = block_device_add_partition(whole_fd, part_node, nr, p->offset, size); if (r < 0) return log_error_errno(r, "Failed to create new partition '%s': %m", part_node);