const char *fname, const char *subfname)
{
struct file_lists *f = *list;
+ struct stat sb = {0};
+ int rc;
while (f) {
if (f->name && !strcmp(f->name, fname))
}
if (!f) {
- f = talloc(mem_ctx, struct file_lists);
+ f = talloc_zero(mem_ctx, struct file_lists);
if (!f)
goto fail;
f->next = *list;
goto fail;
}
*list = f;
- f->modtime = file_modtime(subfname);
- } else {
- time_t t = file_modtime(subfname);
- if (t)
- f->modtime = t;
}
+
+ rc = stat(subfname, &sb);
+ if (rc != 0) {
+ return;
+ }
+ f->modtime = get_mtimespec(&sb);
+
return;
fail:
#include "auth/credentials/credentials.h"
#include "source3/lib/substitute.h"
#include "source3/librpc/gen_ndr/ads.h"
+#include "lib/util/time_basic.h"
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
return true;
}
} else {
- time_t mod_time;
+ struct timespec mod_time = {
+ .tv_sec = 0,
+ };
+ struct timeval_buf tbuf = {
+ .buf = {0},
+ };
char *n2 = NULL;
+ struct stat sb = {0};
+ int rc;
n2 = talloc_sub_basic(talloc_tos(),
get_current_username(),
return false;
}
DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
- f->name, n2, ctime(&f->modtime)));
-
- mod_time = file_modtime(n2);
+ f->name, n2,
+ timespec_string_buf(&f->modtime,
+ true,
+ &tbuf)));
+
+ rc = stat(n2, &sb);
+ if (rc == 0) {
+ mod_time = get_mtimespec(&sb);
+ }
- if (mod_time &&
- ((f->modtime != mod_time) ||
+ if (mod_time.tv_sec > 0 &&
+ ((timespec_compare(&mod_time, &f->modtime) != 0) ||
(f->subfname == NULL) ||
(strcmp(n2, f->subfname) != 0)))
{
+ f->modtime = mod_time;
+
DEBUGADD(6,
("file %s modified: %s\n", n2,
- ctime(&mod_time)));
- f->modtime = mod_time;
+ timespec_string_buf(&f->modtime,
+ true,
+ &tbuf)));
+
TALLOC_FREE(f->subfname);
f->subfname = talloc_strdup(f, n2);
if (f->subfname == NULL) {