From: Steve Muir Date: Wed, 5 Oct 2005 21:36:06 +0000 (+0000) Subject: Save and restore cwd since it gets clobbered by the directory walker X-Git-Tag: after-util-vserver-0_30_208-revert~98 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7e619bcc9b7a8623780102cf4913c783255b8f51;p=util-vserver.git Save and restore cwd since it gets clobbered by the directory walker --- diff --git a/python/vduimpl.c b/python/vduimpl.c index 01fc63c..fb219ff 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,7 +546,9 @@ 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); /* deallocate whatever has been added to tbl */ Dispose(&tbl);