summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/guestfs-py.c25
-rw-r--r--python/guestfs.py13
2 files changed, 38 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 59a891ff..ac1283be 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -4853,6 +4853,30 @@ py_guestfs_df_h (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_du (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int64_t r;
+ const char *path;
+
+ if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_du",
+ &py_g, &path))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_du (g, path);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyLong_FromLongLong (r);
+ return py_r;
+}
+
static PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -5034,6 +5058,7 @@ static PyMethodDef methods[] = {
{ (char *) "tail_n", py_guestfs_tail_n, METH_VARARGS, NULL },
{ (char *) "df", py_guestfs_df, METH_VARARGS, NULL },
{ (char *) "df_h", py_guestfs_df_h, METH_VARARGS, NULL },
+ { (char *) "du", py_guestfs_du, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index d838aaea..e62a5271 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -1827,3 +1827,16 @@ class GuestFS:
"""
return libguestfsmod.df_h (self._o)
+ def du (self, path):
+ u"""This command runs the "du -s" command to estimate file
+ space usage for "path".
+
+ "path" can be a file or a directory. If "path" is a
+ directory then the estimate includes the contents of the
+ directory and all subdirectories (recursively).
+
+ The result is the estimated size in *kilobytes* (ie.
+ units of 1024 bytes).
+ """
+ return libguestfsmod.du (self._o, path)
+