int res;
struct stats s;
HashTable tbl;
+ int cwd_fd;
if (!PyArg_ParseTuple(args, "s", &path))
return Py_None;
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;
}