enum pakfire_internal_flags {
PAKFIRE_HAS_PATH = (1 << 0),
PAKFIRE_DESTROY_ON_FREE = (1 << 1),
+ PAKFIRE_UMOUNT_PATH = (1 << 2),
} internal_flags;
// Lock
}
// Umount the snapshot
- if (pakfire->snapshot)
- pakfire_snapshot_unref(pakfire->snapshot);
+ if (pakfire->snapshot) {
+ r = pakfire_snapshot_umount(pakfire->snapshot);
+ if (r)
+ CTX_ERROR(pakfire->ctx, "Could not umount the snapshot: %s\n", strerror(-r));
- if (pakfire->internal_flags & PAKFIRE_DESTROY_ON_FREE) {
- CTX_DEBUG(pakfire->ctx, "Destroying %s\n", pakfire->path);
+ pakfire_snapshot_unref(pakfire->snapshot);
+ }
- // Umount the ramdisk
- r = umount2(pakfire->path, MNT_DETACH);
+ // Umount path
+ if (pakfire->internal_flags & PAKFIRE_UMOUNT_PATH) {
+ r = umount2(pakfire->path, 0);
if (r)
CTX_ERROR(pakfire->ctx, "Could not umount ramdisk at %s: %m\n", pakfire->path);
+ }
+
+ // Destroy path
+ if (pakfire->internal_flags & PAKFIRE_DESTROY_ON_FREE) {
+ CTX_DEBUG(pakfire->ctx, "Destroying %s\n", pakfire->path);
// Destroy the temporary directory
- pakfire_rmtree(pakfire->path, 0);
+ r = pakfire_rmtree(pakfire->path, 0);
+ if (r)
+ CTX_ERROR(pakfire->ctx, "Could not destroy %s: %s\n", pakfire->path, strerror(-r));
}
pakfire_repo_free_all(pakfire);
r = -errno;
goto ERROR;
}
+
+ // Umount path later
+ p->internal_flags |= PAKFIRE_UMOUNT_PATH;
}
}