The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/250

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Closes #249.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 83e224f3ece34b5608218d20b2c10961211e3a6d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Mon, 30 Jul 2018 10:53:19 +0200
Subject: [PATCH] bindings: better logging for write_string()

Closes #249.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 bindings.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/bindings.c b/bindings.c
index 4b6f51b..8a48f0c 100644
--- a/bindings.c
+++ b/bindings.c
@@ -97,7 +97,7 @@ struct cpuacct_usage {
 #define EXP_15         2037            /* 1/exp(5sec/15min) */
 #define LOAD_INT(x) ((x) >> FSHIFT)
 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
-/* 
+/*
  * This parameter is used for proc_loadavg_read().
  * 1 means use loadavg, 0 means not use.
  */
@@ -584,19 +584,26 @@ static bool write_string(const char *fnam, const char 
*string, int fd)
        FILE *f;
        size_t len, ret;
 
-       if (!(f = fdopen(fd, "w")))
+       f = fdopen(fd, "w");
+       if (!f)
                return false;
+
        len = strlen(string);
        ret = fwrite(string, 1, len, f);
        if (ret != len) {
-               lxcfs_error("Error writing to file: %s\n", strerror(errno));
+               lxcfs_error("%s - Error writing \"%s\" to \"%s\"\n",
+                           strerror(errno), string ? string : "(null)",
+                           fnam ? fname : "(null)");
                fclose(f);
                return false;
        }
+
        if (fclose(f) < 0) {
-               lxcfs_error("Error writing to file: %s\n", strerror(errno));
+               lxcfs_error("%s - Failed to close \"%s\"\n", strerror(errno),
+                           fnam ? fname : "(null)");
                return false;
        }
+
        return true;
 }
 
@@ -4629,7 +4636,7 @@ static int refresh_load(struct load_node *p, char *path)
        p->last_pid = last_pid;
 
        free(line);
-err_out:       
+err_out:
        for (; i > 0; i--)
                free(idbuf[i-1]);
 out:
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to