Mercurial > hg > dhcpcd
changeset 4245:e2fd7f648419 draft
udev: Use our logerr framework instead of syslog(3)
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Tue, 27 Mar 2018 07:52:25 +0000 |
| parents | 9fcf992bb7cc |
| children | 687273d5849d |
| files | configure src/dev/udev.c |
| diffstat | 2 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Tue Mar 27 07:23:31 2018 +0100 +++ b/configure Tue Mar 27 07:52:25 2018 +0000 @@ -1285,7 +1285,7 @@ fi if [ "$HMAC" = no ]; then echo "#include \"compat/crypt/hmac.h\"" >>$CONFIG_H - echo "HMAC_SRC= compat/crypt/hmac.c" >>$CONFIG_MK + echo "HMAC_SRC= compat/crypt/hmac.c" >>$CONFIG_MK else # echo "#define HAVE_HMAC_H" >>$CONFIG_H echo "HMAC_SRC=" >>$CONFIG_MK @@ -1351,6 +1351,9 @@ echo "CPPFLAGS+= -DPLUGIN_DEV" >>$CONFIG_MK echo "MKDIRS+= dev" >>$CONFIG_MK + # So the plugins have access to logerr + echo "LDFLAGS+= -Wl,-export-dynamic" >>$CONFIG_MK + printf "Testing for dlopen ... " cat <<EOF >_dlopen.c #include <dlfcn.h>
--- a/src/dev/udev.c Tue Mar 27 07:23:31 2018 +0100 +++ b/src/dev/udev.c Tue Mar 27 07:52:25 2018 +0000 @@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> + * Copyright (c) 2006-2018 Roy Marples <roy@marples.name> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,10 +35,10 @@ #include <libudev.h> #include <string.h> -#include <syslog.h> #include "../common.h" #include "../dev.h" +#include "../logerr.h" static const char udev_name[] = "udev"; static struct udev *udev; @@ -80,7 +80,7 @@ device = udev_monitor_receive_device(monitor); if (device == NULL) { - syslog(LOG_ERR, "libudev: received NULL device"); + logerrx("libudev: received NULL device"); return -1; } @@ -90,7 +90,7 @@ /* udev filter documentation says "usually" so double check */ if (strcmp(subsystem, "net") == 0) { - syslog(LOG_DEBUG, "%s: libudev: %s", ifname, action); + logdebugx("%s: libudev: %s", ifname, action); if (strcmp(action, "add") == 0 || strcmp(action, "move") == 0) dhcpcd.handle_interface(ctx, 1, ifname); else if (strcmp(action, "remove") == 0) @@ -122,37 +122,36 @@ int fd; if (udev) { - syslog(LOG_ERR, "udev: already started"); + logerrx("udev: already started"); return -1; } - syslog(LOG_DEBUG, "udev: starting"); + logdebugx("udev: starting"); udev = udev_new(); if (udev == NULL) { - syslog(LOG_ERR, "udev_new: %m"); + logerr("udev_new"); return -1; } monitor = udev_monitor_new_from_netlink(udev, "udev"); if (monitor == NULL) { - syslog(LOG_ERR, "udev_monitor_new_from_netlink: %m"); + logerr("udev_monitor_new_from_netlink"); goto bad; } #ifndef LIBUDEV_NOFILTER if (udev_monitor_filter_add_match_subsystem_devtype(monitor, "net", NULL) != 0) { - syslog(LOG_ERR, - "udev_monitor_filter_add_match_subsystem_devtype: %m"); + logerr("udev_monitor_filter_add_match_subsystem_devtype"); goto bad; } #endif if (udev_monitor_enable_receiving(monitor) != 0) { - syslog(LOG_ERR, "udev_monitor_enable_receiving: %m"); + logerr("udev_monitor_enable_receiving"); goto bad; } fd = udev_monitor_get_fd(monitor); if (fd == -1) { - syslog(LOG_ERR, "udev_monitor_get_fd: %m"); + logerr("udev_monitor_get_fd"); goto bad; } return fd;
