]> git.proxmox.com Git - mirror_lxc.git/commitdiff
change lxc_cgroup_set/get functions to return -1
authorMichel Normand <normand@fr.ibm.com>
Thu, 14 May 2009 14:27:29 +0000 (16:27 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 14 May 2009 14:27:29 +0000 (16:27 +0200)
and report error message as soon as detected error in these two functions

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
src/lxc/cgroup.c
src/lxc/conf.c

index 004470585ef1d6cfc3fbcfa23dddddc79cb50772..7827b70c98d76b59953418e57276a38525ee8947 100644 (file)
@@ -108,17 +108,21 @@ int lxc_unlink_nsgroup(const char *name)
 
 int lxc_cgroup_set(const char *name, const char *subsystem, const char *value)
 {
-       int fd, ret = -LXC_ERROR_INTERNAL;;
+       int fd, ret = -1;
        char path[MAXPATHLEN];
 
         snprintf(path, MAXPATHLEN, LXCPATH "/%s/nsgroup/%s", name, subsystem);
 
        fd = open(path, O_WRONLY);
-       if (fd < 0)
+       if (fd < 0) {
+               ERROR("open %s : %s", path, strerror(errno));
                return -1;
+       }
 
-       if (write(fd, value, strlen(value)) < 0)
+       if (write(fd, value, strlen(value)) < 0) {
+               ERROR("write %s : %s", path, strerror(errno));
                goto out;
+       }
        
        ret = 0;
 out:
@@ -129,17 +133,21 @@ out:
 int lxc_cgroup_get(const char *name, const char *subsystem,  
                   char *value, size_t len)
 {
-       int fd, ret = -LXC_ERROR_INTERNAL;
+       int fd, ret = -1;
        char path[MAXPATHLEN];
 
         snprintf(path, MAXPATHLEN, LXCPATH "/%s/nsgroup/%s", name, subsystem);
 
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
+               ERROR("open %s : %s", path, strerror(errno));
                return -1;
+       }
 
-       if (read(fd, value, len) < 0)
+       if (read(fd, value, len) < 0) {
+               ERROR("read %s : %s", path, strerror(errno));
                goto out;
+       }
        
        ret = 0;
 out:
index 9e88486f6ac8136a3eaed364bf002424a4abbe0d..496d65b4b2af9dda554135b003cb338213e14641 100644 (file)
@@ -982,7 +982,7 @@ static int setup_cgroup_cb(void* buffer, void *data)
 
        ret = lxc_cgroup_set(name, key, value);
        if (ret)
-               SYSERROR("failed to set cgroup '%s' = '%s' for '%s'",
+               ERROR("failed to set cgroup '%s' = '%s' for '%s'",
                                 key, value, name);
        return ret;
 }