]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
bindings: better logging for write_string()
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 30 Jul 2018 08:53:19 +0000 (10:53 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 30 Jul 2018 20:14:08 +0000 (22:14 +0200)
Closes #249.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
bindings.c

index 4b6f51b07377eeb243b8233ffbea498e713153ae..08267f77cde63e9d9d4dec599d5a66115c52c3da 100644 (file)
@@ -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,24 @@ 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, fnam);
                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);
                return false;
        }
+
        return true;
 }
 
@@ -4629,7 +4634,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: