summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-30 19:28:54 +0100
committerRichard Jones <rjones@redhat.com>2009-04-30 19:28:54 +0100
commit62df226f26bd6ac3c481a7790eb89d760d2f0386 (patch)
tree617a5a436598902b2239d67535925520c20a6e6e /java
parent2a42bec2c5ee521f29179a5aab713f5a9ca2c3b8 (diff)
downloadlibguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.gz
libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.xz
libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.zip
Added 'zero' command to wipe partition tables and superblocks.
Diffstat (limited to 'java')
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java23
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c17
2 files changed, 40 insertions, 0 deletions
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index 844c3b33..293ee23e 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -2382,4 +2382,27 @@ public class GuestFS {
private native int _fsck (long g, String fstype, String device)
throws LibGuestFSException;
+ /**
+ * write zeroes to the device
+ *
+ * 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.
+ *
+ * @throws LibGuestFSException
+ */
+ public void zero (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("zero: handle is closed");
+ _zero (g, device);
+ }
+ private native void _zero (long g, String device)
+ throws LibGuestFSException;
+
}
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 1f5579e2..466ced85 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -2420,3 +2420,20 @@ Java_com_redhat_et_libguestfs_GuestFS__1fsck
return (jint) r;
}
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1zero
+ (JNIEnv *env, jobject obj, jlong jg, jstring jdevice)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ const char *device;
+
+ device = (*env)->GetStringUTFChars (env, jdevice, NULL);
+ r = guestfs_zero (g, device);
+ (*env)->ReleaseStringUTFChars (env, jdevice, device);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+