Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
More FD usage
Baptiste Daroussin committed 9 years ago
commit 497f2e690ca2777424f0a5cdc6b5796bdac281c2
parent cd74830
3 files changed +13 -15
modified configure.ac
@@ -388,18 +388,18 @@ if test "$ac_cv_func_bsd_dirname" = yes ; then
	AC_DEFINE(HAVE_BSD_DIRNAME, 1, [Define 1 if you have 'dirname(const char *)' function.])
fi

-
AC_CACHE_CHECK(for BSD statfs(const char *path, struct statfs *buf),
-
               ac_cv_func_statfs,
+
AC_CACHE_CHECK(for BSD fstatfs(int, struct statfs *buf),
+
               ac_cv_func_fstatfs,
               [ac_save_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS -Werror"
		AC_TRY_COMPILE([#include <sys/param.h>
     					#include <sys/mount.h>],
-
                               [struct statfs stfs; static int (*ac_test_statfs)(const char *path, struct statfs *buf) = statfs; ac_test_statfs("", &stfs);],
-
                               [ac_cv_func_statfs=yes],
-
                               [ac_cv_func_statfs=no])
+
                               [struct statfs stfs; static int (*ac_test_fstatfs)(int fd, struct statfs *buf) = fstatfs; ac_test_fstatfs(0, &stfs);],
+
                               [ac_cv_func_fstatfs=yes],
+
                               [ac_cv_func_fstatfs=no])
		CFLAGS="$ac_save_CFLAGS"])
-
if test "$ac_cv_func_statfs" = yes ; then
-
	AC_DEFINE(HAVE_STATFS, 1, [Define 1 if you have 'statfs(const char *path, struct statfs *buf)' function.])
+
if test "$ac_cv_func_fstatfs" = yes ; then
+
	AC_DEFINE(HAVE_FSTATFS, 1, [Define 1 if you have 'fstatfs(int fd, struct statfs *buf)' function.])
fi

AC_CHECK_FUNCS(chflags chflagsat)
modified libpkg/pkg_jobs.c
@@ -2180,7 +2180,7 @@ pkg_jobs_fetch(struct pkg_jobs *j)
	if (dlsize == 0)
		return (EPKG_OK);

-
#ifdef HAVE_STATFS
+
#ifdef HAVE_FSTATFS
	struct statfs fs;
	while (statfs(cachedir, &fs) == -1) {
		if (errno == ENOENT) {
modified libpkg/pkgdb.c
@@ -58,9 +58,7 @@

#include <sqlite3.h>

-
#ifdef HAVE_SYS_STATFS_H
-
#include <sys/statfs.h>
-
#elif defined(HAVE_SYS_STATVFS_H)
+
#if defined(HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
#endif

@@ -1039,7 +1037,7 @@ pkgdb_syscall_overload(void)
void
pkgdb_setup_lock(void)
{
-
	const char *dbdir = pkg_object_string(pkg_config_get("PKG_DBDIR"));
+
	int dbdirfd = pkg_get_dbdirfd();

	if (pkg_object_bool(pkg_config_get("NFS_WITH_PROPER_LOCKING")))
		return;
@@ -1051,14 +1049,14 @@ pkgdb_setup_lock(void)
#if defined(HAVE_SYS_STATVFS_H) && defined(ST_LOCAL)
	struct statvfs stfs;

-
	if (statvfs(dbdir, &stfs) == 0) {
+
	if (fstatvfs(dbdirfd, &stfs) == 0) {
		if ((stfs.f_flag & ST_LOCAL) != ST_LOCAL)
			sqlite3_vfs_register(sqlite3_vfs_find("unix-dotfile"), 1);
	}
-
#elif defined(HAVE_STATFS) && defined(MNT_LOCAL)
+
#elif defined(HAVE_FSTATFS) && defined(MNT_LOCAL)
	struct statfs stfs;

-
	if (statfs(dbdir, &stfs) == 0) {
+
	if (fstatfs(dbdirfd, &stfs) == 0) {
		if ((stfs.f_flags & MNT_LOCAL) != MNT_LOCAL)
			sqlite3_vfs_register(sqlite3_vfs_find("unix-dotfile"), 1);
	}