Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
reposdirfd: add abstractions to prepare the move of repo metadata
Baptiste Daroussin committed 2 years ago
commit 647e10a3a153e1002557b110a4e4265e50ece644
parent 76fc5eb
2 files changed +19 -0
modified libpkg/pkg_config.c
@@ -1705,6 +1705,23 @@ pkg_get_dbdirfd(void)
}

int
+
pkg_get_reposdirfd(void)
+
{
+
	int dbfd = pkg_get_dbdirfd();
+
	if (dbfd == -1)
+
		return (-1);
+
	if (ctx.pkg_reposdirfd == -1) {
+
		ctx.pkg_reposdirfd = openat(dbfd, "repos", O_DIRECTORY|O_CLOEXEC);
+
		if (ctx.pkg_reposdirfd == -1) {
+
			if (mkdirat(dbfd, "repos", 0755) == -1)
+
				return (-1);
+
			ctx.pkg_reposdirfd = openat(dbfd, "repos", O_DIRECTORY|O_CLOEXEC);
+
		}
+
	}
+
	return (ctx.pkg_reposdirfd);
+
}
+

+
int
pkg_open_devnull(void) {
	pkg_close_devnull();

modified libpkg/private/pkg.h
@@ -162,6 +162,7 @@ struct pkg_ctx {
	int devnullfd;
	int dbdirfd;
	int pkg_dbdirfd;
+
	int pkg_reposdirfd;
	int osversion;
	bool archive_symlink;
	bool backup_libraries;
@@ -853,5 +854,6 @@ void append_touched_file(const char *path);
bool stringlist_contains(stringlist_t *l, const char *name);

int pkg_parse_manifest_ucl(struct pkg *pkg, ucl_object_t *o);
+
int pkg_get_reposdirfd(void);

#endif