From 91f7d4ab476dc6fb2fa5cfeb9a20c6484cc24700 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 15 Jan 2014 11:35:58 +0100 Subject: [PATCH] more meaningful retcods for ch[fs]context --- setns.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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); -- 2.43.0