dissect-image: Notify btrfs when we're done using a loop device

Let's explicitly let btrfs know when we're done using a loop device.
Otherwise, btrfs will keep the device UUID cached which will result
in mount() failures if we ever generate a device or filesystem with
the same UUID again.
This commit is contained in:
Daan De Meyer
2023-01-12 16:36:09 +01:00
parent da2a4f6a2e
commit 5228c58ebe
4 changed files with 35 additions and 0 deletions
+4
View File
@@ -707,6 +707,10 @@ int block_device_remove_all_partitions(sd_device *dev, int fd) {
if (r < 0)
return r;
r = btrfs_forget_device(devname);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to forget btrfs device %s, ignoring: %m", devname);
r = block_device_remove_partition(fd, devname, nr);
if (r == -ENODEV) {
log_debug("Kernel removed partition %s before us, ignoring", devname);