From c8f73ce205aea218d4deb8e89e06ec6dc1abcc6b Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Tue, 19 Nov 2013 16:17:48 +0000 Subject: [PATCH] lxc_user_nic: report failing filename in open_and_lock error cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- src/lxc/lxc_user_nic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c index 0b82a5033..4154e8341 100644 --- a/src/lxc/lxc_user_nic.c +++ b/src/lxc/lxc_user_nic.c @@ -105,7 +105,8 @@ int open_and_lock(char *path) fd = open(path, O_RDWR|O_CREAT, S_IWUSR | S_IRUSR); if (fd < 0) { - perror("open"); + fprintf(stderr, "Failed to open %s: %s\n", + path, strerror(errno)); return(fd); } @@ -114,7 +115,8 @@ int open_and_lock(char *path) lk.l_start = 0; lk.l_len = 0; if (fcntl(fd, F_SETLKW, &lk) < 0) { - perror("fcntl lock"); + fprintf(stderr, "Failed to lock %s: %s\n", + path, strerror(errno)); return -1; }