summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-07-12 15:10:16 +0000
committerRoy Marples <roy@marples.name>2009-07-12 15:10:16 +0000
commit1e11fce587c1463e84899f2649ff40a83c9dbbe1 (patch)
tree51aee8f7da301428978b3eb6572bd4e19e2bce4f
parentec407a088597976bae2bfe6700167bcdde6c4633 (diff)
downloaddhcpcd-1e11fce587c1463e84899f2649ff40a83c9dbbe1.tar.xz
Add some logging for errors reading/writing the leasefile.
-rw-r--r--dhcp.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/dhcp.c b/dhcp.c
index f347acaa..be08c004 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include <unistd.h>
#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));