Hi Faidon,

On 3/17/23 13:21, Faidon Liambotis wrote:
Friendly bump on this! I'd just like to agree on next steps while we
have this in our recent memory :)

Ok, let's summarize.
Because we don't know in advance how libev it built (with or without 64-bit 
offsets), we:
- can't enable future=+lfs, and
- can't enable AC_SYS_LARGEFILE
otherwise it breaks libev.
So, we have to uncouple gdnsd from libev.

My suggestion:
The attached patch switches gdnsd to use 64-bit functions unconditionally.
It works for me, but of course doesn't fix all corner cases unless libev
is built with 64-bit offsets as well.
Anyway, it's a step forward.

What do you think?
Would that patch be acceptable upstream? In either case I think it should
be applied to the debian package.

Helge
diff --git a/libgdnsd/file.c b/libgdnsd/file.c
index 25b64a2..0230688 100644
--- a/libgdnsd/file.c
+++ b/libgdnsd/file.c
@@ -49,8 +49,8 @@ gdnsd_fmap_t* gdnsd_fmap_new(const char* fn, const bool seq, const bool mod)
         return NULL;
     }
 
-    struct stat st;
-    if (fstat(fd, &st) < 0) {
+    struct stat64 st;
+    if (fstat64(fd, &st) < 0) {
         log_err("Cannot fstat '%s': %s", fn, logf_errno());
         close(fd);
         return NULL;
diff --git a/libgdnsd/paths.c b/libgdnsd/paths.c
index f2e1626..c0363c0 100644
--- a/libgdnsd/paths.c
+++ b/libgdnsd/paths.c
@@ -62,8 +62,8 @@ static void gdnsd_ensure_dir(const char* dpath, const char* desc, mode_t dir_mod
             log_fatal("mkdir of %s directory '%s' failed: %s", desc, dpath, logf_errno());
         if (force_mode && chmod(dpath, dir_mode))
             log_fatal("%s directory '%s': chmod(%o) failed: %s", desc, dpath, dir_mode, logf_errno());
-        struct stat st;
-        if (stat(dpath, &st) || !S_ISDIR(st.st_mode))
+        struct stat64 st;
+        if (stat64(dpath, &st) || !S_ISDIR(st.st_mode))
             log_fatal("%s directory '%s' does not exist or is not a directory!", desc, dpath);
     }
 }
@@ -81,8 +81,8 @@ static vscf_data_t* conf_load_vscf(const char* cfg_file)
 {
     vscf_data_t* out = NULL;
 
-    struct stat cfg_stat;
-    if (!stat(cfg_file, &cfg_stat)) {
+    struct stat64 cfg_stat;
+    if (!stat64(cfg_file, &cfg_stat)) {
         log_debug("Loading configuration from '%s'", cfg_file);
         out = vscf_scan_filename(cfg_file);
         if (!out)
diff --git a/libgdnsd/vscf.rl b/libgdnsd/vscf.rl
index 29d25ee..e4abbd3 100644
--- a/libgdnsd/vscf.rl
+++ b/libgdnsd/vscf.rl
@@ -467,8 +467,8 @@ static bool vscf_include_glob(vscf_scnr_t* scnr, const char* inc_glob, const int
 F_NONNULL F_WUNUSED
 static bool vscf_include_glob_or_dir(vscf_scnr_t* scnr, const char* glob_or_dir)
 {
-    struct stat st;
-    if (!stat(glob_or_dir, &st) && S_ISDIR(st.st_mode)) {
+    struct stat64 st;
+    if (!stat64(glob_or_dir, &st) && S_ISDIR(st.st_mode)) {
         // we handle the directory case by transforming it into a
         // glob, but allowing GLOB_NOMATCH
         const size_t inc_dir_len = strlen(glob_or_dir);
diff --git a/src/plugins/mon.c b/src/plugins/mon.c
index 7ed124b..63d0a66 100644
--- a/src/plugins/mon.c
+++ b/src/plugins/mon.c
@@ -392,10 +392,10 @@ static void admin_init(struct ev_loop* mloop)
 // public interface to just check admin_state parsing
 void gdnsd_mon_check_admin_file(void)
 {
-    struct stat st;
+    struct stat64 st;
     char* pathname = gdnsd_resolve_path_state("admin_state", NULL);
 
-    if (!stat(pathname, &st)) {
+    if (!stat64(pathname, &st)) {
         if (!admin_process_file(pathname, true))
             log_fatal("%s has errors!", pathname);
     } else if (errno != ENOENT) {
diff --git a/src/zsrc_rfc1035.c b/src/zsrc_rfc1035.c
index ed58890..acea4f4 100644
--- a/src/zsrc_rfc1035.c
+++ b/src/zsrc_rfc1035.c
@@ -256,16 +256,16 @@ bool zsrc_rfc1035_load_zones(ltree_node_t* new_root_tree, ltarena_t* new_root_ar
     zf_threads_t* zft = zf_threads_new(gcfg->zones_rfc1035_threads);
 
     bool failed = false;
-    const struct dirent* result = NULL;
+    const struct dirent64* result = NULL;
     do {
         errno = 0;
-        result = readdir(zdhandle);
+        result = readdir64(zdhandle);
         if (likely(result)) {
             if (result->d_name[0] != '.') {
-                struct stat st;
+                struct stat64 st;
                 const char* fn;
                 char* full_fn = gdnsd_str_combine(rfc1035_dir, result->d_name, &fn);
-                if (stat(full_fn, &st)) {
+                if (stat64(full_fn, &st)) {
                     log_err("rfc1035: stat(%s) failed: %s", full_fn, logf_errno());
                     free(full_fn);
                     failed = true;
diff --git a/t/libgdmaps/gdmaps_test.c b/t/libgdmaps/gdmaps_test.c
index 32ef58f..df733be 100644
--- a/t/libgdmaps/gdmaps_test.c
+++ b/t/libgdmaps/gdmaps_test.c
@@ -109,8 +109,8 @@ bool gdmaps_test_db_exists(const char* dbfile)
 {
     bool rv = false;
     char* fn = gdnsd_resolve_path_cfg(dbfile, "geoip");
-    struct stat st;
-    if (!stat(fn, &st) && !S_ISDIR(st.st_mode))
+    struct stat64 st;
+    if (!stat64(fn, &st) && !S_ISDIR(st.st_mode))
         rv = true;
     free(fn);
     return rv;

Reply via email to