summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/device-nodes.c1
-rw-r--r--src/libudev/path-util.c31
-rw-r--r--src/libudev/path-util.h12
3 files changed, 39 insertions, 5 deletions
diff --git a/src/libudev/device-nodes.c b/src/libudev/device-nodes.c
index c548f1ffff..9efafaf548 100644
--- a/src/libudev/device-nodes.c
+++ b/src/libudev/device-nodes.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <stdint.h>
#include <sys/types.h>
diff --git a/src/libudev/path-util.c b/src/libudev/path-util.c
index 417450f283..616577088c 100644
--- a/src/libudev/path-util.c
+++ b/src/libudev/path-util.c
@@ -331,3 +331,34 @@ fallback:
return a.st_dev != b.st_dev;
}
+
+bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update)
+{
+ unsigned int i;
+ bool changed = false;
+
+ if (paths == NULL)
+ goto out;
+
+ for (i = 0; paths[i]; i++) {
+ struct stat stats;
+
+ if (stat(paths[i], &stats) < 0)
+ continue;
+
+ if (paths_ts_usec[i] == timespec_load(&stats.st_mtim))
+ continue;
+
+ /* first check */
+ if (paths_ts_usec[i] != 0) {
+ log_debug("reload - timestamp of '%s' changed\n", paths[i]);
+ changed = true;
+ }
+
+ /* update timestamp */
+ if (update)
+ paths_ts_usec[i] = timespec_load(&stats.st_mtim);
+ }
+out:
+ return changed;
+}
diff --git a/src/libudev/path-util.h b/src/libudev/path-util.h
index 653ae8d7c8..0b7577ff4f 100644
--- a/src/libudev/path-util.h
+++ b/src/libudev/path-util.h
@@ -1,9 +1,5 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#pragma once
-
/***
- This file is part of systemd.
+ This file is part of eudev, forked from systemd.
Copyright 2010-2012 Lennart Poettering
@@ -22,6 +18,10 @@
***/
#include <stdbool.h>
+#include <inttypes.h>
+
+typedef uint64_t usec_t;
+typedef uint64_t nsec_t;
char* path_get_file_name(const char *p) _pure_;
int path_get_parent(const char *path, char **parent);
@@ -35,3 +35,5 @@ char** path_strv_canonicalize(char **l);
char** path_strv_canonicalize_uniq(char **l);
int path_is_mount_point(const char *path, bool allow_symlink);
+
+bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update);