summaryrefslogtreecommitdiff
path: root/src/shared/path-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-26 00:36:49 +0200
committerTom Gundersen <teg@jklm.no>2013-10-26 14:34:31 +0200
commit8e18485284a8718d4a9111b7c1ed91cb2f9634b0 (patch)
tree4d12da40f925b3ba15c1d34d11e97f9871b08da5 /src/shared/path-util.c
parent5ecb28f69ef670c7e194b656b57fda6f8850f0ba (diff)
udev: move udev_rules_check_timestamp to shared
I want to use this from a bulitin in a subsequent patch.
Diffstat (limited to 'src/shared/path-util.c')
-rw-r--r--src/shared/path-util.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 45099eeda8..def7a7409a 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -473,3 +473,34 @@ int find_binary(const char *name, char **filename) {
return -ENOENT;
}
}
+
+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;
+}