]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mountfsd: Communicate whether the image is a single filesystem
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 20 Jan 2026 21:43:08 +0000 (22:43 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 Jan 2026 11:03:08 +0000 (12:03 +0100)
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.

src/mountfsd/mountwork.c
src/shared/dissect-image.c
src/shared/varlink-io.systemd.MountFileSystem.c

index d196c081b46e476d48cb95d80feb41b08e47cd01..242516619f956c4981984ec6e48e1922a4b950cb 100644 (file)
@@ -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),
index 422f2b42bb76c6521693b72931624f3f7f2624b1..5bc764cefb8f596af927d025cfb65cd03fcf41f4 100644 (file)
@@ -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;
index 619a09e333bc77e901657c439cd635cd6e08c18d..78c922e2cb1fded69a28fcc330e8e9d39816df2a 100644 (file)
@@ -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."),