diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-07-31 10:46:49 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-07-31 10:46:49 -0400 |
commit | aa417a4d83999f6d7f092161d5c411b8cbce9977 (patch) | |
tree | a3c0da66e997c079d3803c2c72293bbdc73f2ece /src/libudev | |
parent | ccc30166822f4597ceba3e3b62c09b8f091b9cbb (diff) |
static-nodes: remove creation of static nodes if HAVE_LIBKMOD
This address upstream commit edeb68c53f1cdc452016b4c8512586a70b1262e3
and https://bugs.gentoo.org/show_bug.cgi?id=477890. If eudev is
configured with --enable-libkmod then we check for kmod >= 14 and
ifdef out the code removed in the upstream commit. Otherwise we
retain it for modutils.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r-- | src/libudev/strv.c | 37 | ||||
-rw-r--r-- | src/libudev/strv.h | 3 | ||||
-rw-r--r-- | src/libudev/util.c | 35 | ||||
-rw-r--r-- | src/libudev/util.h | 4 |
4 files changed, 79 insertions, 0 deletions
diff --git a/src/libudev/strv.c b/src/libudev/strv.c index 041e20d700..3619701e9d 100644 --- a/src/libudev/strv.c +++ b/src/libudev/strv.c @@ -142,6 +142,43 @@ char **strv_new(const char *x, ...) { return r; } +int strv_push(char ***l, char *value) { + char **c; + unsigned n; + + if (!value) + return 0; + + n = strv_length(*l); + c = realloc(*l, sizeof(char*) * (n + 2)); + if (!c) + return -ENOMEM; + + c[n] = value; + c[n+1] = NULL; + + *l = c; + return 0; +} + +int strv_extend(char ***l, const char *value) { + char *v; + int r; + + if (!value) + return 0; + + v = strdup(value); + if (!v) + return -ENOMEM; + + r = strv_push(l, v); + if (r < 0) + free(v); + + return r; +} + char **strv_uniq(char **l) { char **i; diff --git a/src/libudev/strv.h b/src/libudev/strv.h index d9e0e1c20b..9fba94e566 100644 --- a/src/libudev/strv.h +++ b/src/libudev/strv.h @@ -36,6 +36,9 @@ static inline void strv_freep(char ***l) { char **strv_copy(char * const *l); unsigned strv_length(char * const *l) _pure_; +int strv_extend(char ***l, const char *value); +int strv_push(char ***l, char *value); + char **strv_remove(char **l, const char *s); char **strv_uniq(char **l); diff --git a/src/libudev/util.c b/src/libudev/util.c index f625cfe99b..61d000c350 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -664,6 +664,41 @@ int null_or_empty_path(const char *fn) { return null_or_empty(&st); } +char hexchar(int x) { + static const char table[16] = "0123456789abcdef"; + + return table[x & 15]; +} + +char *xescape(const char *s, const char *bad) { + char *r, *t; + const char *f; + + /* Escapes all chars in bad, in addition to \ and all special + * chars, in \xFF style escaping. May be reversed with + * cunescape. */ + + r = new(char, strlen(s) * 4 + 1); + if (!r) + return NULL; + + for (f = s, t = r; *f; f++) { + + if ((*f < ' ') || (*f >= 127) || + (*f == '\\') || strchr(bad, *f)) { + *(t++) = '\\'; + *(t++) = 'x'; + *(t++) = hexchar(*f >> 4); + *(t++) = hexchar(*f); + } else + *(t++) = *f; + } + + *t = 0; + + return r; +} + bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) { assert(de); diff --git a/src/libudev/util.h b/src/libudev/util.h index 60b300da3c..7b6571ab10 100644 --- a/src/libudev/util.h +++ b/src/libudev/util.h @@ -131,6 +131,10 @@ char *strnappend(const char *s, const char *suffix, size_t length); char *truncate_nl(char *s); +char hexchar(int x) _const_; + +char *xescape(const char *s, const char *bad); + bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_; bool ignore_file(const char *filename) _pure_; |