const char* pakfire_snapshot_path(struct pakfire_snapshot* snapshot);
-int pakfire_snapshot_mount(struct pakfire_snapshot* snapshot);
+int pakfire_snapshot_mount(struct pakfire_snapshot* snapshot, const char* path);
int pakfire_snapshot_umount(struct pakfire_snapshot* snapshot);
#endif
// Mount the snapshot
if (p->snapshot) {
- r = pakfire_snapshot_mount(p->snapshot);
+ r = pakfire_snapshot_mount(p->snapshot, path);
if (r < 0) {
CTX_ERROR(p->ctx, "Could not mount snapshot: %s\n", strerror(-r));
goto ERROR;
}
-
- // Fetch the path where the snapshot was mounted
- path = pakfire_snapshot_path(p->snapshot);
}
}
return r;
}
-const char* pakfire_snapshot_path(struct pakfire_snapshot* snapshot) {
- return snapshot->overlayfs.path;
-}
-
static int pakfire_snapshot_mount_tmpfs(struct pakfire_snapshot* snapshot) {
char* path = NULL;
int r;
return 0;
}
-int pakfire_snapshot_mount(struct pakfire_snapshot* snapshot) {
- const char* path = NULL;
+int pakfire_snapshot_mount(struct pakfire_snapshot* snapshot, const char* path) {
int mountfd = -EBADF;
int fsfd = -EBADF;
int r;
- CTX_DEBUG(snapshot->ctx, "Mounting snapshot %s\n", snapshot->path);
+ CTX_DEBUG(snapshot->ctx, "Mounting snapshot %s to %s\n", snapshot->path, path);
// Mount the tmpfs
r = pakfire_snapshot_mount_tmpfs(snapshot);
goto ERROR;
}
- // Make path
- r = pakfire_string_set(snapshot->overlayfs.path, PAKFIRE_TMP_DIR "/pakfire-root.XXXXXX");
+ // Store the path
+ r = pakfire_string_set(snapshot->overlayfs.path, path);
if (r < 0)
goto ERROR;
- // Create a temporary directory
- path = pakfire_mkdtemp(snapshot->overlayfs.path);
- if (!path)
- goto ERROR;
-
// Move the snapshot to the right place
r = move_mount(mountfd, "", AT_FDCWD, path, MOVE_MOUNT_F_EMPTY_PATH);
if (r < 0)
r = umount(snapshot->overlayfs.path);
if (r < 0)
return r;
-
- r = pakfire_rmtree(snapshot->overlayfs.path, 0);
- if (r < 0)
- return r;
}
// Umount the tmpfs