Skip to content

Commit

Permalink
static-nodes: remove creation of static nodes if HAVE_LIBKMOD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
blueness committed Jul 31, 2013
1 parent ccc3016 commit aa417a4
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
7 changes: 3 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

AC_PREREQ([2.68])
AC_INIT([eudev],[1.2],[https://github.com/gentoo/eudev/issues])
AC_SUBST(UDEV_VERSION, 205)
AC_SUBST(UDEV_VERSION, 206)
AC_CONFIG_SRCDIR([src/udev/udevd.c])

AC_USE_SYSTEM_EXTENSIONS
Expand Down Expand Up @@ -267,10 +267,10 @@ if test "x${enable_modules}" = xyes; then

AS_IF([test "x${enable_libkmod}" = xyes],
[AC_CHECK_LIB([kmod], [main],
[PKG_CHECK_MODULES(KMOD, [libkmod >= 5])
[PKG_CHECK_MODULES(KMOD, [libkmod >= 14])
AC_SUBST([LIBKMOD], ["-lkmod"])
AC_DEFINE([HAVE_LIBKMOD], [1],
[Define if you have libkmod])
[AC_MSG_ERROR([*** kmod version >= 14 not found])])
],
[AC_MSG_FAILURE(
[--enable-libkmod was given, but test for kmod failed])],
Expand All @@ -281,7 +281,6 @@ fi
AM_CONDITIONAL([HAVE_MODULES], [test "x${enable_modules}" = xyes])
AM_CONDITIONAL([HAVE_LIBKMOD], [test "x${enable_libkmod}" = xyes])


# ------------------------------------------------------------------------------

AC_ARG_WITH([modprobe],
Expand Down
37 changes: 37 additions & 0 deletions src/libudev/strv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions src/libudev/strv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
35 changes: 35 additions & 0 deletions src/libudev/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/libudev/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
4 changes: 4 additions & 0 deletions src/udev/udevd.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ static void handle_signal(struct udev *udev, int signo)
}
}

#ifndef HAVE_LIBKMOD
static void static_dev_create_from_modules(struct udev *udev)
{
struct utsname kernel;
Expand Down Expand Up @@ -881,6 +882,7 @@ static void static_dev_create_from_modules(struct udev *udev)

fclose(f);
}
#endif

/*
* read the kernel commandline, in case we need to get into debug mode
Expand Down Expand Up @@ -1033,7 +1035,9 @@ int main(int argc, char *argv[])
mkdir("/run/udev", 0755);

dev_setup(NULL);
#ifndef HAVE_LIBKMOD
static_dev_create_from_modules(udev);
#endif

/* before opening new files, make sure std{in,out,err} fds are in a sane state */
if (daemonize) {
Expand Down

0 comments on commit aa417a4

Please sign in to comment.