]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
loop-util: remember if we created the LoopDevice
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Dec 2023 17:02:45 +0000 (18:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Dec 2023 16:35:22 +0000 (17:35 +0100)
Let's store in a bool whether a LoopDevice object was created via
loop_device_open() or loop_device_make().

src/shared/loop-util.c
src/shared/loop-util.h

index c337e881fe20da17b4f24686026a0ebce8a55c32..8434587286cff9701ff21ba13e6e1cc3777bacc7 100644 (file)
@@ -427,6 +427,7 @@ static int loop_configure(
                 .timestamp_not_before = timestamp,
                 .sector_size = c->block_size,
                 .device_size = device_size,
+                .created = true,
         };
 
         *ret = TAKE_PTR(d);
@@ -989,6 +990,7 @@ int loop_device_open(
                 .timestamp_not_before = USEC_INFINITY,
                 .sector_size = sector_size,
                 .device_size = device_size,
+                .created = false,
         };
 
         *ret = d;
index 194e7f78d4e50228c3d071cdc6747caf2ef16ae9..94357bba71788e2b63e9dd54460fa9b124bcb09a 100644 (file)
@@ -22,6 +22,7 @@ struct LoopDevice {
         sd_device *dev;
         char *backing_file;
         bool relinquished;
+        bool created;        /* If we created the device */
         dev_t backing_devno; /* The backing file's dev_t */
         ino_t backing_inode; /* The backing file's ino_t */
         uint64_t diskseq; /* Block device sequence number, monothonically incremented by the kernel on create/attach, or 0 if we don't know */