git://git.onelab.eu
/
util-vserver.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
36499d4
)
Fix vserver_isrunning() by doing a simple stat of /proc/virtual/
author
Marc Fiuczynski
<mef@cs.princeton.edu>
Thu, 10 May 2007 22:35:32 +0000
(22:35 +0000)
committer
Marc Fiuczynski
<mef@cs.princeton.edu>
Thu, 10 May 2007 22:35:32 +0000
(22:35 +0000)
python/vserverimpl.c
patch
|
blob
|
history
diff --git
a/python/vserverimpl.c
b/python/vserverimpl.c
index
1d5a62e
..
85563cc
100644
(file)
--- a/
python/vserverimpl.c
+++ b/
python/vserverimpl.c
@@
-35,8
+35,10
@@
POSSIBILITY OF SUCH DAMAGE.
#include <errno.h>
#include <stdint.h>
#include <errno.h>
#include <stdint.h>
-#include <unistd.h>
#include <sys/resource.h>
#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "config.h"
#include "pathconfig.h"
#include "config.h"
#include "pathconfig.h"
@@
-89,27
+91,21
@@
vserver_setup_done(PyObject *self, PyObject *args)
static PyObject *
vserver_isrunning(PyObject *self, PyObject *args)
{
static PyObject *
vserver_isrunning(PyObject *self, PyObject *args)
{
- struct vc_vx_info vx_info;
xid_t ctx;
PyObject *ret;
xid_t ctx;
PyObject *ret;
+ struct stat statbuf;
+ char fname[64];
if (!PyArg_ParseTuple(args, "I", &ctx))
return NULL;
if (!PyArg_ParseTuple(args, "I", &ctx))
return NULL;
- switch (vc_get_vx_info(ctx, &vx_info)) {
- case EPERM:
- case ENOSYS:
- case EFAULT:
- return PyErr_SetFromErrno(PyExc_OSError);
- case ESRCH:
- /* XXX should be boolean */
- ret = Py_BuildValue("L",0);
- break;
- default:
- /* XXX should be boolean */
- ret = Py_BuildValue("L",1);
- break;
- }
+ sprintf(fname,"/proc/virtual/%d", ctx);
+
+ if(stat(&fname[0],&statbuf)==0)
+ ret = Py_BuildValue("i",1);
+ else
+ ret = Py_BuildValue("i",0);
+
return ret;
}
return ret;
}