4 #include <asm-generic/unistd.h>
8 chfscontext(PyObject *self, PyObject *args)
13 if (!PyArg_ParseTuple(args, "s", &filepath))
16 int fd = open(filepath, O_RDONLY);
18 //printf("Could not open ns file\n");
29 return Py_BuildValue("i", sts);
33 proc_mount(PyObject *self, PyObject *args)
36 sts = mount("none","/proc","proc",0,NULL);
38 return Py_BuildValue("i", sts);
42 chcontext(PyObject *self, PyObject *args)
47 if (!PyArg_ParseTuple(args, "s", &filepath))
50 int fd = open(filepath, O_RDONLY);
52 // printf("Could not open ns file\n");
63 return Py_BuildValue("i", sts);
66 static PyMethodDef SetnsMethods[] =
68 {"proc_mount", proc_mount, METH_VARARGS, "Mount a volume via the mount system call."},
69 {"chcontext", chcontext, METH_VARARGS, "Switch into an lxc container."},
70 {"chfscontext", chfscontext, METH_VARARGS, "Switch into an lxc container."},
78 (void) Py_InitModule("setns", SetnsMethods);