summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-11 23:23:22 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-18 23:47:20 +0900
commitf906075a1523ec807e4e6614f4bfdea687b558cd (patch)
tree0ee46a6152f0759d0e3c7ac6d45c8182ebbcc4b3
parentc72aed4c204d21ae5de23c7925cf220b398d658b (diff)
downloadsystemd-f906075a1523ec807e4e6614f4bfdea687b558cd.tar.gz
dissect-image: introduce dissected_image_relinquish()
-rw-r--r--src/shared/dissect-image.c17
-rw-r--r--src/shared/dissect-image.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index eb319a9ff9..4949b4c9ee 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -2239,6 +2239,23 @@ int decrypted_image_relinquish(DecryptedImage *d) {
return 0;
}
+int dissected_image_relinquish(DissectedImage *m) {
+ int r;
+
+ assert(m);
+
+ if (m->decrypted_image) {
+ r = decrypted_image_relinquish(m->decrypted_image);
+ if (r < 0)
+ return r;
+ }
+
+ if (m->loop)
+ loop_device_relinquish(m->loop);
+
+ return 0;
+}
+
static char *build_auxiliary_path(const char *image, const char *suffix) {
const char *e;
char *n;
diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h
index c49bff0e5d..c385bb44d9 100644
--- a/src/shared/dissect-image.h
+++ b/src/shared/dissect-image.h
@@ -285,7 +285,9 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
DecryptedImage* decrypted_image_ref(DecryptedImage *p);
DecryptedImage* decrypted_image_unref(DecryptedImage *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(DecryptedImage*, decrypted_image_unref);
+
int decrypted_image_relinquish(DecryptedImage *d);
+int dissected_image_relinquish(DissectedImage *m);
const char* partition_designator_to_string(PartitionDesignator d) _const_;
PartitionDesignator partition_designator_from_string(const char *name) _pure_;