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 proc_umount(PyObject *self, PyObject *args)
45 sts = umount("/proc");
47 return Py_BuildValue("i", sts);
52 chcontext(PyObject *self, PyObject *args)
57 if (!PyArg_ParseTuple(args, "s", &filepath))
60 int fd = open(filepath, O_RDONLY);
62 // printf("Could not open ns file\n");
73 return Py_BuildValue("i", sts);
76 static PyMethodDef SetnsMethods[] =
78 {"proc_mount", proc_mount, METH_VARARGS, "Mount a volume via the mount system call."},
79 {"proc_umount", proc_umount, METH_VARARGS, "Umount a volume via the umount system call."},
80 {"chcontext", chcontext, METH_VARARGS, "Switch into an lxc container."},
81 {"chfscontext", chfscontext, METH_VARARGS, "Switch into an lxc container."},
89 (void) Py_InitModule("setns", SetnsMethods);