From: Roy Marples Date: Sun, 12 Jul 2009 15:10:16 +0000 (+0000) Subject: Add some logging for errors reading/writing the leasefile. X-Git-Tag: v5.0.7~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e11fce587c1463e84899f2649ff40a83c9dbbe1;p=thirdparty%2Fdhcpcd.git Add some logging for errors reading/writing the leasefile. --- diff --git a/dhcp.c b/dhcp.c index f347acaa..be08c004 100644 --- a/dhcp.c +++ b/dhcp.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "config.h" @@ -1041,9 +1042,14 @@ write_lease(const struct interface *iface, const struct dhcp_message *dhcp) return 0; } + syslog(LOG_DEBUG, "%s: writing lease `%s'", + iface->name, iface->leasefile); + fd = open(iface->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0400); - if (fd == -1) + if (fd == -1) { + syslog(LOG_ERR, "%s: open: %m", iface->name); return -1; + } /* Only write as much as we need */ while (p < e) { @@ -1071,8 +1077,14 @@ read_lease(const struct interface *iface) ssize_t bytes; fd = open(iface->leasefile, O_RDONLY); - if (fd == -1) + if (fd == -1) { + if (errno != ENOENT) + syslog(LOG_ERR, "%s: open `%s': %m", + iface->name, iface->leasefile); return NULL; + } + syslog(LOG_DEBUG, "%s: reading lease `%s'", + iface->name, iface->leasefile); dhcp = xmalloc(sizeof(*dhcp)); memset(dhcp, 0, sizeof(*dhcp)); bytes = read(fd, dhcp, sizeof(*dhcp));