From: Daan De Meyer Date: Tue, 20 Jan 2026 21:43:08 +0000 (+0100) Subject: mountfsd: Communicate whether the image is a single filesystem X-Git-Tag: v260-rc1~340^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6cfd8ac1f0378f76e2835f3e76cef13ff0c07b8;p=thirdparty%2Fsystemd.git mountfsd: Communicate whether the image is a single filesystem Various parts of the image dissection logic make use of whether the thing is a single file system or not, so communicate this info back from mountfsd. --- diff --git a/src/mountfsd/mountwork.c b/src/mountfsd/mountwork.c index d196c081b46..242516619f9 100644 --- a/src/mountfsd/mountwork.c +++ b/src/mountfsd/mountwork.c @@ -713,6 +713,7 @@ static int vl_method_mount_image( return sd_varlink_replybo( link, SD_JSON_BUILD_PAIR_VARIANT("partitions", aj), + SD_JSON_BUILD_PAIR_BOOLEAN("singleFileSystem", di->single_file_system), SD_JSON_BUILD_PAIR_STRING("imagePolicy", ps), SD_JSON_BUILD_PAIR_UNSIGNED("imageSize", di->image_size), SD_JSON_BUILD_PAIR_UNSIGNED("sectorSize", di->sector_size), diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 422f2b42bb7..5bc764cefb8 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -5094,6 +5094,7 @@ static void partition_fields_done(PartitionFields *f) { typedef struct MountImageReplyParameters { sd_json_variant *partitions; + bool single_file_system; char *image_policy; uint64_t image_size; uint32_t sector_size; @@ -5122,11 +5123,12 @@ int mountfsd_mount_image_fd( _cleanup_(mount_image_reply_parameters_done) MountImageReplyParameters p = {}; static const sd_json_dispatch_field dispatch_table[] = { - { "partitions", SD_JSON_VARIANT_ARRAY, sd_json_dispatch_variant, offsetof(struct MountImageReplyParameters, partitions), SD_JSON_MANDATORY }, - { "imagePolicy", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(struct MountImageReplyParameters, image_policy), 0 }, - { "imageSize", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint64, offsetof(struct MountImageReplyParameters, image_size), SD_JSON_MANDATORY }, - { "sectorSize", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint32, offsetof(struct MountImageReplyParameters, sector_size), SD_JSON_MANDATORY }, - { "imageUuid", SD_JSON_VARIANT_STRING, sd_json_dispatch_id128, offsetof(struct MountImageReplyParameters, image_uuid), 0 }, + { "partitions", SD_JSON_VARIANT_ARRAY, sd_json_dispatch_variant, offsetof(struct MountImageReplyParameters, partitions), SD_JSON_MANDATORY }, + { "singleFileSystem", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, offsetof(struct MountImageReplyParameters, single_file_system), 0 }, + { "imagePolicy", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(struct MountImageReplyParameters, image_policy), 0 }, + { "imageSize", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint64, offsetof(struct MountImageReplyParameters, image_size), SD_JSON_MANDATORY }, + { "sectorSize", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint32, offsetof(struct MountImageReplyParameters, sector_size), SD_JSON_MANDATORY }, + { "imageUuid", SD_JSON_VARIANT_STRING, sd_json_dispatch_id128, offsetof(struct MountImageReplyParameters, image_uuid), 0 }, {} }; @@ -5307,6 +5309,7 @@ int mountfsd_mount_image_fd( }; } + di->single_file_system = p.single_file_system; di->image_size = p.image_size; di->sector_size = p.sector_size; di->image_uuid = p.image_uuid; diff --git a/src/shared/varlink-io.systemd.MountFileSystem.c b/src/shared/varlink-io.systemd.MountFileSystem.c index 619a09e333b..78c922e2cb1 100644 --- a/src/shared/varlink-io.systemd.MountFileSystem.c +++ b/src/shared/varlink-io.systemd.MountFileSystem.c @@ -75,6 +75,8 @@ static SD_VARLINK_DEFINE_METHOD( VARLINK_DEFINE_POLKIT_INPUT, SD_VARLINK_FIELD_COMMENT("An array with information about contained partitions that have been prepared for mounting, as well as their mount file descriptors."), SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(partitions, PartitionInfo, SD_VARLINK_ARRAY), + SD_VARLINK_FIELD_COMMENT("Indicates whether the image contains only a single file system, i.e. no partition table."), + SD_VARLINK_DEFINE_OUTPUT(singleFileSystem, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE), SD_VARLINK_FIELD_COMMENT("The used image policy."), SD_VARLINK_DEFINE_OUTPUT(imagePolicy, SD_VARLINK_STRING, 0), SD_VARLINK_FIELD_COMMENT("The size of the image in bytes."),