]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
loop-util: Add loop_device_unrelinquish()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 27 Jul 2022 23:49:07 +0000 (01:49 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Aug 2022 18:55:32 +0000 (20:55 +0200)
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
src/shared/loop-util.h

index 530688fc97f0255eddc942b77e8793f4a4190142..a5ad914577071d7acb182779eafce2a648ddeed6 100644 (file)
@@ -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;
index 964ce3ed083c1affe098d345acbaba8dc0b954e6..a33d7e3e59d42002286b68f02afe3d131713a64e 100644 (file)
@@ -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);