[systemd-commits] 3 commits - src/shared src/udev
Tom Gundersen
tomegun at kemper.freedesktop.org
Sat Oct 26 05:55:02 PDT 2013
src/shared/path-util.c | 31 +++++++++++++++++++++++++++++++
src/shared/path-util.h | 3 +++
src/shared/strv.h | 3 ++-
src/udev/udev-builtin-path_id.c | 16 ++++++++++++++++
src/udev/udev-rules.c | 27 +--------------------------
5 files changed, 53 insertions(+), 27 deletions(-)
New commits:
commit 89f17d4f807f2fbd9918b513296e25ee2be108c3
Author: Tom Gundersen <teg at jklm.no>
Date: Sat Oct 26 12:22:04 2013 +0200
udev-builtin: path_id - add support for bcma bus
This matches the bcma support in the network device naming.
Eventually wa want to make sure ID_PATH is equivalent to ID_NET_NAME_PATH,
so we never need to match on the latter.
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
index 0659967..763f3c3 100644
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -452,6 +452,19 @@ static struct udev_device *handle_usb(struct udev_device *parent, char **path)
return parent;
}
+static struct udev_device *handle_bcma(struct udev_device *parent, char **path)
+{
+ const char *sysname;
+ unsigned int core;
+
+ sysname = udev_device_get_sysname(parent);
+ if (sscanf(sysname, "bcma%*u:%u", &core) != 1)
+ return NULL;
+
+ path_prepend(path, "bcma-%u", core);
+ return parent;
+}
+
static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path)
{
struct udev_device *scsi_dev;
@@ -509,6 +522,9 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
} else if (streq(subsys, "usb")) {
parent = handle_usb(parent, &path);
some_transport = true;
+ } else if (streq(subsys, "bcma")) {
+ parent = handle_bcma(parent, &path);
+ some_transport = true;
} else if (streq(subsys, "serio")) {
path_prepend(&path, "serio-%s", udev_device_get_sysnum(parent));
parent = skip_subsystem(parent, "serio");
commit 8e18485284a8718d4a9111b7c1ed91cb2f9634b0
Author: Tom Gundersen <teg at jklm.no>
Date: Sat Oct 26 00:36:49 2013 +0200
udev: move udev_rules_check_timestamp to shared
I want to use this from a bulitin in a subsequent patch.
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 45099ee..def7a74 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;
+}
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
index 0a42de7..42b4189 100644
--- a/src/shared/path-util.h
+++ b/src/shared/path-util.h
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include "macro.h"
+#include "time-util.h"
#ifdef HAVE_SPLIT_USR
# define DEFAULT_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@@ -52,6 +53,8 @@ int path_is_os_tree(const char *path);
int find_binary(const char *name, char **filename);
+bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update);
+
/* Iterates through the path prefixes of the specified path, going up
* the tree, to root. Also returns "" (and not "/"!) for the root
* directory. Excludes the specified directory itself */
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 9d9529a..58da79b 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1718,32 +1718,7 @@ struct udev_rules *udev_rules_unref(struct udev_rules *rules)
bool udev_rules_check_timestamp(struct udev_rules *rules)
{
- unsigned int i;
- bool changed = false;
-
- if (rules == NULL)
- goto out;
-
- for (i = 0; rules->dirs[i]; i++) {
- struct stat stats;
-
- if (stat(rules->dirs[i], &stats) < 0)
- continue;
-
- if (rules->dirs_ts_usec[i] == timespec_load(&stats.st_mtim))
- continue;
-
- /* first check */
- if (rules->dirs_ts_usec[i] != 0) {
- log_debug("reload - timestamp of '%s' changed\n", rules->dirs[i]);
- changed = true;
- }
-
- /* update timestamp */
- rules->dirs_ts_usec[i] = timespec_load(&stats.st_mtim);
- }
-out:
- return changed;
+ return paths_check_timestamp(rules->dirs, rules->dirs_ts_usec, true);
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val)
commit 5ecb28f69ef670c7e194b656b57fda6f8850f0ba
Author: Tom Gundersen <teg at jklm.no>
Date: Sat Oct 26 13:41:31 2013 +0200
STRV_FOREACH_BACWARDS: start at the tail of the list
Otherwise, the user would have to manually initialize the pointer. Nobody currently uses this code,
so the change in behaviour sohuld be fine.
diff --git a/src/shared/strv.h b/src/shared/strv.h
index f6fb033..571ea38 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -75,7 +75,8 @@ bool strv_overlap(char **a, char **b) _pure_;
for ((s) = (l); (s) && *(s); (s)++)
#define STRV_FOREACH_BACKWARDS(s, l) \
- for (; (l) && ((s) >= (l)); (s)--)
+ STRV_FOREACH(s, l) ; \
+ for ((s)--; (l) && ((s) >= (l)); (s)--)
#define STRV_FOREACH_PAIR(x, y, l) \
for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
More information about the systemd-commits
mailing list