summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java25
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c16
2 files changed, 41 insertions, 0 deletions
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index 515fc77b..c29789c0 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -2487,4 +2487,29 @@ public class GuestFS {
private native void _mv (long g, String src, String dest)
throws LibGuestFSException;
+ /**
+ * drop kernel page cache, dentries and inodes
+ *
+ * This instructs the guest kernel to drop its page cache,
+ * and/or dentries and inode caches. The parameter
+ * "whattodrop" tells the kernel what precisely to drop,
+ * see <http://linux-mm.org/Drop_Caches>
+ *
+ * Setting "whattodrop" to 3 should drop everything.
+ *
+ * This automatically calls sync(2) before the operation,
+ * so that the maximum guest memory is freed.
+ *
+ * @throws LibGuestFSException
+ */
+ public void drop_caches (int whattodrop)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("drop_caches: handle is closed");
+ _drop_caches (g, whattodrop);
+ }
+ private native void _drop_caches (long g, int whattodrop)
+ throws LibGuestFSException;
+
}
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 0f20d844..ae6ff863 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -2517,3 +2517,19 @@ Java_com_redhat_et_libguestfs_GuestFS__1mv
}
}
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1drop_1caches
+ (JNIEnv *env, jobject obj, jlong jg, jint jwhattodrop)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ int whattodrop;
+
+ whattodrop = jwhattodrop;
+ r = guestfs_drop_caches (g, whattodrop);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+