From: Michel Normand Date: Thu, 14 May 2009 14:27:29 +0000 (+0200) Subject: change lxc_cgroup_set/get functions to return -1 X-Git-Tag: lxc_0_6_3~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b92dc3ab676044871f920841447cceb707cff7e;p=thirdparty%2Flxc.git change lxc_cgroup_set/get functions to return -1 and report error message as soon as detected error in these two functions Signed-off-by: Daniel Lezcano Signed-off-by: Michel Normand --- diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index 004470585..7827b70c9 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -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: diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 9e88486f6..496d65b4b 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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; }