#include <pakfire/string.h>
#include <pakfire/util.h>
-struct pakfire_snapshot_fs {
- char path[PATH_MAX];
- int fd;
-};
-
struct pakfire_snapshot {
struct pakfire_ctx* ctx;
int nrefs;
int fd;
// File Systems
- struct pakfire_snapshot_fs overlayfs;
- struct pakfire_snapshot_fs tmpfs;
+ char overlayfs[PATH_MAX];
+ char tmpfs[PATH_MAX];
+ // Overlayfs Directories
char upperdir[PATH_MAX];
char workdir[PATH_MAX];
// Ensure this is umounted
pakfire_snapshot_umount(snapshot);
- if (snapshot->overlayfs.fd >= 0)
- close(snapshot->overlayfs.fd);
- if (snapshot->tmpfs.fd >= 0)
- close(snapshot->tmpfs.fd);
if (snapshot->fd >= 0)
close(snapshot->fd);
goto ERROR;
}
- // Initialize the file descriptors
- s->overlayfs.fd = s->tmpfs.fd = -EBADF;
-
// XXX Check and lock the snapshot
// Return the snapshot
int r;
// Make path
- r = pakfire_string_set(snapshot->tmpfs.path, PAKFIRE_TMP_DIR "/pakfire-tmpfs.XXXXXX");
+ r = pakfire_string_set(snapshot->tmpfs, PAKFIRE_TMP_DIR "/pakfire-tmpfs.XXXXXX");
if (r < 0)
return r;
// Create a temporary directory
- path = pakfire_mkdtemp(snapshot->tmpfs.path);
+ path = pakfire_mkdtemp(snapshot->tmpfs);
if (!path)
return -errno;
// Perform mount
- r = mount("pakfire_tmpfs", snapshot->tmpfs.path, "tmpfs", 0, NULL);
+ r = mount("pakfire_tmpfs", snapshot->tmpfs, "tmpfs", 0, NULL);
if (r < 0)
return -errno;
// Make the upper directory
- r = pakfire_path_append(snapshot->upperdir, snapshot->tmpfs.path, "upper");
+ r = pakfire_path_append(snapshot->upperdir, snapshot->tmpfs, "upper");
if (r < 0)
return r;
return r;
// Make the work directory
- r = pakfire_path_append(snapshot->workdir, snapshot->tmpfs.path, "work");
+ r = pakfire_path_append(snapshot->workdir, snapshot->tmpfs, "work");
if (r < 0)
return r;
}
// Store the path
- r = pakfire_string_set(snapshot->overlayfs.path, path);
+ r = pakfire_string_set(snapshot->overlayfs, path);
if (r < 0)
goto ERROR;
switch (snapshot->state) {
case PAKFIRE_SNAPSHOT_MOUNTED:
// Umount the overlayfs
- if (*snapshot->overlayfs.path) {
- r = umount(snapshot->overlayfs.path);
+ if (*snapshot->overlayfs) {
+ r = umount(snapshot->overlayfs);
if (r < 0)
return r;
}
// Umount the tmpfs
- if (*snapshot->tmpfs.path) {
- r = umount(snapshot->tmpfs.path);
+ if (*snapshot->tmpfs) {
+ r = umount(snapshot->tmpfs);
if (r < 0)
return r;
- r = pakfire_rmtree(snapshot->tmpfs.path, 0);
+ r = pakfire_rmtree(snapshot->tmpfs, 0);
if (r < 0)
return r;
}