From: Michael Tremer Date: Fri, 3 Jan 2025 06:02:34 +0000 (+0000) Subject: pakfire: Keep a fd open to the root X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=155e002d71a6f988ce22aeda3b47addb25d4c8a6;p=people%2Fric9%2Fpakfire.git pakfire: Keep a fd open to the root Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index b6591c736..f9a22c45d 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -70,6 +70,8 @@ struct pakfire { int nrefs; char path[PATH_MAX]; + int fd; + char cache_path[PATH_MAX]; struct pakfire_arches { @@ -394,6 +396,10 @@ static void pakfire_free(struct pakfire* pakfire) { pakfire_repo_unref(repo); } + // Close the path + if (pakfire->fd >= 0) + close(pakfire->fd); + // Umount the snapshot if (pakfire->snapshot) { r = pakfire_snapshot_umount(pakfire->snapshot); @@ -947,6 +953,14 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx* if (r < 0) goto ERROR; + // Open the path + r = p->fd = open(p->path, O_DIRECTORY); + if (r < 0) { + ERROR(p->ctx, "Could not open %s: %m\n", p->path); + r = -errno; + goto ERROR; + } + // Populate pool r = pakfire_populate_pool(p); if (r < 0)