int fd,
const char *label,
sd_id128_t partition_uuid,
+ uint64_t sector_size,
sd_id128_t *ret_partition_uuid,
uint64_t *ret_offset,
uint64_t *ret_size) {
assert(label);
assert(ret_offset);
assert(ret_size);
+ assert(sector_size > 0);
r = dlopen_libblkid();
if (r < 0)
if (r != 0)
return errno_or_else(ENOMEM);
+ /* Set probing sector size if explicitly specified */
+ if (sector_size != UINT32_MAX) {
+ r = sym_blkid_probe_set_sectorsize(b, sector_size);
+ if (r != 0)
+ return errno_or_else(EINVAL);
+ }
(void) sym_blkid_probe_enable_superblocks(b, 1);
(void) sym_blkid_probe_set_superblocks_flags(b, BLKID_SUBLKS_TYPE);
(void) sym_blkid_probe_enable_partitions(b, 1);
if ((uint64_t) size > UINT64_MAX / 512U)
return -EINVAL;
+ /* libblkid returns partitions sizes in count of 512-sectors. This does not necessarily need to match the device sector size */
*ret_offset = offset * 512U;
*ret_size = size * 512U;
*ret_partition_uuid = found_partition_uuid;
if (!subdir)
return log_oom();
- r = luks_validate(setup->image_fd, user_record_user_name_and_realm(h), h->partition_uuid, &found_partition_uuid, &offset, &size);
+ r = luks_validate(
+ setup->image_fd,
+ user_record_user_name_and_realm(h),
+ h->partition_uuid,
+ /* if sector size is not specified, select UINT32_MAX, i.e. auto-probe */
+ h->luks_sector_size == UINT64_MAX ? UINT32_MAX : user_record_luks_sector_size(h),
+ &found_partition_uuid,
+ &offset,
+ &size);
if (r < 0)
return log_error_errno(r, "Failed to validate disk label: %m");