From 24d59aeed3eb4a91dad2e7aea44237f1e3610477 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 28 Jul 2022 01:49:07 +0200 Subject: [PATCH] loop-util: Add loop_device_unrelinquish() Allows taking ownership of a loop device which makes sure that loop_device_unrefp() will try to destroy it when it runs. --- src/shared/loop-util.c | 5 +++++ src/shared/loop-util.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index 530688fc97..a5ad914577 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -768,6 +768,11 @@ void loop_device_relinquish(LoopDevice *d) { d->relinquished = true; } +void loop_device_unrelinquish(LoopDevice *d) { + assert(d); + d->relinquished = false; +} + int loop_device_open(const char *loop_path, int open_flags, LoopDevice **ret) { _cleanup_close_ int loop_fd = -1; _cleanup_free_ char *p = NULL; diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h index 964ce3ed08..a33d7e3e59 100644 --- a/src/shared/loop-util.h +++ b/src/shared/loop-util.h @@ -27,6 +27,7 @@ LoopDevice* loop_device_unref(LoopDevice *d); DEFINE_TRIVIAL_CLEANUP_FUNC(LoopDevice*, loop_device_unref); void loop_device_relinquish(LoopDevice *d); +void loop_device_unrelinquish(LoopDevice *d); int loop_device_refresh_size(LoopDevice *d, uint64_t offset, uint64_t size); -- 2.25.1