X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2Fvduimpl.c;h=21918260c88193a03341337f861de71ba7cd291a;hb=95e2774070e989fe9cf9f48dae5fa054e55e2a3e;hp=00ff5db2d77b02c9764c74b87a1b20894c56ceff;hpb=f3bf699064b2ecfbd8b5c1c310ea6c3081893310;p=util-vserver.git diff --git a/python/vduimpl.c b/python/vduimpl.c index 00ff5db..2191826 100644 --- a/python/vduimpl.c +++ b/python/vduimpl.c @@ -537,6 +537,7 @@ do_vdu(PyObject *self, PyObject *args) int res; struct stats s; HashTable tbl; + int cwd_fd; if (!PyArg_ParseTuple(args, "s", &path)) return Py_None; @@ -545,13 +546,22 @@ do_vdu(PyObject *self, PyObject *args) s.inodes = s.blocks = s.size = 0; (void) Init(&tbl,0,0); + cwd_fd = open(".", O_RDONLY); res = vdu_onedir(&tbl, &s, path); + fchdir(cwd_fd); + close(cwd_fd); /* deallocate whatever has been added to tbl */ Dispose(&tbl); /* create a python (inode, block, size) tuple */ - tuple = Py_BuildValue("(L,L,L)",s.inodes,s.blocks,s.size); + tuple = Py_BuildValue("(L,L,L)", + s.inodes, + s.blocks>>1, /* NOTE: div by 2 to adjust + * 512b block count to 1K + * block count + */ + s.size); return (res == -1) ? PyErr_SetFromErrno(PyExc_OSError) : tuple; }