From e1f39e694f3671330c15988cfe5f196d2fe9fa46 Mon Sep 17 00:00:00 2001 From: Elie Kheirallah Date: Fri, 4 Sep 2026 00:38:12 +0000 Subject: [PATCH] Update composite disk mtime when disk spec matches existing When CreateOrUpdateCompositeDisk determines that an existing composite disk already matches the target partition layout, it skips regenerating the disk file. However, if a component partition (such as persistent_vbmeta.img) was regenerated or touched during instance setup, the composite disk's modification time would remain older than that component. This causes subsequent assemble_cvd checks to falsely detect that a component was updated and fail with an mtime mismatch error. Update the modification time of output_composite_path using utimensat when the existing disk spec is retained, ensuring the composite disk mtime remains up to date. Bug: 554545294 --- .../cuttlefish/host/libs/image_aggregator/BUILD.bazel | 1 + .../host/libs/image_aggregator/image_aggregator.cc | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/base/cvd/cuttlefish/host/libs/image_aggregator/BUILD.bazel b/base/cvd/cuttlefish/host/libs/image_aggregator/BUILD.bazel index d746af5c910..c2ea6c1440f 100644 --- a/base/cvd/cuttlefish/host/libs/image_aggregator/BUILD.bazel +++ b/base/cvd/cuttlefish/host/libs/image_aggregator/BUILD.bazel @@ -99,6 +99,7 @@ cf_cc_library( "//cuttlefish/io", "//cuttlefish/io:write_exact", "//cuttlefish/result", + "@abseil-cpp//absl/log", "@protobuf", "@protobuf//:differencer", "@zlib", diff --git a/base/cvd/cuttlefish/host/libs/image_aggregator/image_aggregator.cc b/base/cvd/cuttlefish/host/libs/image_aggregator/image_aggregator.cc index f6a33a633f5..fc7a3f99aeb 100644 --- a/base/cvd/cuttlefish/host/libs/image_aggregator/image_aggregator.cc +++ b/base/cvd/cuttlefish/host/libs/image_aggregator/image_aggregator.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,8 @@ #include #include +#include "absl/log/log.h" + #include "google/protobuf/util/message_differencer.h" #include @@ -361,7 +364,12 @@ Result CreateOrUpdateCompositeDisk( google::protobuf::util::MessageDifferencer::Equals( composite_proto, composite_image_res->GetCompositeDisk())) { // The existing composite disk matches the given partitions, no need to - // regenerate + // regenerate, but update its modification time so it is not older than + // any recently updated component images. + if (utimensat(AT_FDCWD, output_composite_path.c_str(), nullptr, 0) != 0) { + LOG(WARNING) << "Failed to update modification time for \"" + << output_composite_path << "\": " << strerror(errno); + } return {}; }