From 6bc201343fea0d01b96eac37c46dd12b2a3dfab4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 4 Dec 2023 18:02:45 +0100 Subject: [PATCH] loop-util: remember if we created the LoopDevice 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 | 2 ++ src/shared/loop-util.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index c337e881fe2..8434587286c 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -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; diff --git a/src/shared/loop-util.h b/src/shared/loop-util.h index 194e7f78d4e..94357bba717 100644 --- a/src/shared/loop-util.h +++ b/src/shared/loop-util.h @@ -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 */ -- 2.47.3