From: Thierry Parmentelat Date: Wed, 15 Jan 2014 10:35:58 +0000 (+0100) Subject: more meaningful retcods for ch[fs]context X-Git-Tag: lxc-userspace-1.0-9~14 X-Git-Url: http://git.onelab.eu/?p=lxc-userspace.git;a=commitdiff_plain;h=91f7d4ab476dc6fb2fa5cfeb9a20c6484cc24700 more meaningful retcods for ch[fs]context --- diff --git a/setns.c b/setns.c index e562cd6..36aa360 100644 --- a/setns.c +++ b/setns.c @@ -3,6 +3,7 @@ #include #include #include +#include static PyObject * proc_mount(PyObject *self, PyObject *args) @@ -20,7 +21,6 @@ proc_umount(PyObject *self, PyObject *args) sts = umount("/proc"); return Py_BuildValue("i", sts); - } static PyObject * @@ -34,14 +34,15 @@ chfscontext(PyObject *self, PyObject *args) int fd = open(filepath, O_RDONLY); if (fd < 0) { - sts = -1; + sts = -errno; goto out; } if (setns(fd, 0)) { - sts = -1; + sts = -errno; } close(fd); + sts = 0; out: return Py_BuildValue("i", sts); @@ -58,14 +59,15 @@ chcontext(PyObject *self, PyObject *args) int fd = open(filepath, O_RDONLY); if (fd < 0) { - sts = -1; + sts = -errno; goto out; } if (setns(fd, 0)) { - sts = -1; + sts = -errno; } close(fd); + sts = 0; out: return Py_BuildValue("i", sts);