]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
loop-util: tweak codepath when a loopback file is "created" from an existing block...
authorLennart Poettering <lennart@poettering.net>
Mon, 31 Dec 2018 16:00:10 +0000 (17:00 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 7 Jan 2019 16:50:39 +0000 (17:50 +0100)
Be more careful with initialized of the 'relinquished' boolean field,
and let's return the fd, like we do for the regular codepath, too.

src/shared/loop-util.c

index e77eee6d3ae28c0c632ccf2f1bd65f6f56cf3791..bf426eb8bca4d2d3a65e13f8d3186ec4b5685182 100644 (file)
@@ -45,11 +45,11 @@ int loop_device_make(int fd, int open_flags, LoopDevice **ret) {
                 *d = (LoopDevice) {
                         .fd = copy,
                         .nr = -1,
+                        .relinquished = true, /* It's not allocated by us, don't destroy it when this object is freed */
                 };
 
                 *ret = d;
-
-                return 0;
+                return d->fd;
         }
 
         r = stat_verify_regular(&st);