diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-30 19:28:54 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-30 19:28:54 +0100 |
commit | 62df226f26bd6ac3c481a7790eb89d760d2f0386 (patch) | |
tree | 617a5a436598902b2239d67535925520c20a6e6e /python | |
parent | 2a42bec2c5ee521f29179a5aab713f5a9ca2c3b8 (diff) | |
download | libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.gz libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.xz libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.zip |
Added 'zero' command to wipe partition tables and superblocks.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 26 | ||||
-rw-r--r-- | python/guestfs.py | 11 |
2 files changed, 37 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 6b93b276..a1cfb09d 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -3027,6 +3027,31 @@ py_guestfs_fsck (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_zero (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *device; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_zero", + &py_g, &device)) + return NULL; + g = get_handle (py_g); + + r = guestfs_zero (g, device); + if (r == -1) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + Py_INCREF (Py_None); + py_r = Py_None; + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -3135,6 +3160,7 @@ static PyMethodDef methods[] = { { (char *) "set_e2uuid", py_guestfs_set_e2uuid, METH_VARARGS, NULL }, { (char *) "get_e2uuid", py_guestfs_get_e2uuid, METH_VARARGS, NULL }, { (char *) "fsck", py_guestfs_fsck, METH_VARARGS, NULL }, + { (char *) "zero", py_guestfs_zero, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 37dce2bf..3cfc86a1 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -1163,3 +1163,14 @@ class GuestFS: """ return libguestfsmod.fsck (self._o, fstype, device) + def zero (self, device): + u"""This command writes zeroes over the first few blocks of + "device". + + How many blocks are zeroed isn't specified (but it's + *not* enough to securely wipe the device). It should be + sufficient to remove any partition tables, filesystem + superblocks and so on. + """ + return libguestfsmod.zero (self._o, device) + |