Don't stash strings in the handle.
[libguestfs.git] / java / com / redhat / et / libguestfs / GuestFS.java
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 package com.redhat.et.libguestfs;
23
24 import java.util.HashMap;
25 import com.redhat.et.libguestfs.LibGuestFSException;
26 import com.redhat.et.libguestfs.PV;
27 import com.redhat.et.libguestfs.VG;
28 import com.redhat.et.libguestfs.LV;
29 import com.redhat.et.libguestfs.Stat;
30 import com.redhat.et.libguestfs.StatVFS;
31 import com.redhat.et.libguestfs.IntBool;
32
33 /**
34  * The GuestFS object is a libguestfs handle.
35  *
36  * @author rjones
37  */
38 public class GuestFS {
39   // Load the native code.
40   static {
41     System.loadLibrary ("guestfs_jni");
42   }
43
44   /**
45    * The native guestfs_h pointer.
46    */
47   long g;
48
49   /**
50    * Create a libguestfs handle.
51    *
52    * @throws LibGuestFSException
53    */
54   public GuestFS () throws LibGuestFSException
55   {
56     g = _create ();
57   }
58   private native long _create () throws LibGuestFSException;
59
60   /**
61    * Close a libguestfs handle.
62    *
63    * You can also leave handles to be collected by the garbage
64    * collector, but this method ensures that the resources used
65    * by the handle are freed up immediately.  If you call any
66    * other methods after closing the handle, you will get an
67    * exception.
68    *
69    * @throws LibGuestFSException
70    */
71   public void close () throws LibGuestFSException
72   {
73     if (g != 0)
74       _close (g);
75     g = 0;
76   }
77   private native void _close (long g) throws LibGuestFSException;
78
79   public void finalize () throws LibGuestFSException
80   {
81     close ();
82   }
83
84   /**
85    * launch the qemu subprocess
86    *
87    * Internally libguestfs is implemented by running a
88    * virtual machine using qemu(1).
89    * 
90    * You should call this after configuring the handle (eg.
91    * adding drives) but before performing any actions.
92    * 
93    * @throws LibGuestFSException
94    */
95   public void launch ()
96     throws LibGuestFSException
97   {
98     if (g == 0)
99       throw new LibGuestFSException ("launch: handle is closed");
100     _launch (g);
101   }
102   private native void _launch (long g)
103     throws LibGuestFSException;
104
105   /**
106    * wait until the qemu subprocess launches
107    *
108    * Internally libguestfs is implemented by running a
109    * virtual machine using qemu(1).
110    * 
111    * You should call this after "g.launch" to wait for the
112    * launch to complete.
113    * 
114    * @throws LibGuestFSException
115    */
116   public void wait_ready ()
117     throws LibGuestFSException
118   {
119     if (g == 0)
120       throw new LibGuestFSException ("wait_ready: handle is closed");
121     _wait_ready (g);
122   }
123   private native void _wait_ready (long g)
124     throws LibGuestFSException;
125
126   /**
127    * kill the qemu subprocess
128    *
129    * This kills the qemu subprocess. You should never need to
130    * call this.
131    * 
132    * @throws LibGuestFSException
133    */
134   public void kill_subprocess ()
135     throws LibGuestFSException
136   {
137     if (g == 0)
138       throw new LibGuestFSException ("kill_subprocess: handle is closed");
139     _kill_subprocess (g);
140   }
141   private native void _kill_subprocess (long g)
142     throws LibGuestFSException;
143
144   /**
145    * add an image to examine or modify
146    *
147    * This function adds a virtual machine disk image
148    * "filename" to the guest. The first time you call this
149    * function, the disk appears as IDE disk 0 ("/dev/sda") in
150    * the guest, the second time as "/dev/sdb", and so on.
151    * 
152    * You don't necessarily need to be root when using
153    * libguestfs. However you obviously do need sufficient
154    * permissions to access the filename for whatever
155    * operations you want to perform (ie. read access if you
156    * just want to read the image or write access if you want
157    * to modify the image).
158    * 
159    * This is equivalent to the qemu parameter "-drive
160    * file=filename".
161    * 
162    * @throws LibGuestFSException
163    */
164   public void add_drive (String filename)
165     throws LibGuestFSException
166   {
167     if (g == 0)
168       throw new LibGuestFSException ("add_drive: handle is closed");
169     _add_drive (g, filename);
170   }
171   private native void _add_drive (long g, String filename)
172     throws LibGuestFSException;
173
174   /**
175    * add a CD-ROM disk image to examine
176    *
177    * This function adds a virtual CD-ROM disk image to the
178    * guest.
179    * 
180    * This is equivalent to the qemu parameter "-cdrom
181    * filename".
182    * 
183    * @throws LibGuestFSException
184    */
185   public void add_cdrom (String filename)
186     throws LibGuestFSException
187   {
188     if (g == 0)
189       throw new LibGuestFSException ("add_cdrom: handle is closed");
190     _add_cdrom (g, filename);
191   }
192   private native void _add_cdrom (long g, String filename)
193     throws LibGuestFSException;
194
195   /**
196    * add qemu parameters
197    *
198    * This can be used to add arbitrary qemu command line
199    * parameters of the form "-param value". Actually it's not
200    * quite arbitrary - we prevent you from setting some
201    * parameters which would interfere with parameters that we
202    * use.
203    * 
204    * The first character of "param" string must be a "-"
205    * (dash).
206    * 
207    * "value" can be NULL.
208    * 
209    * @throws LibGuestFSException
210    */
211   public void config (String qemuparam, String qemuvalue)
212     throws LibGuestFSException
213   {
214     if (g == 0)
215       throw new LibGuestFSException ("config: handle is closed");
216     _config (g, qemuparam, qemuvalue);
217   }
218   private native void _config (long g, String qemuparam, String qemuvalue)
219     throws LibGuestFSException;
220
221   /**
222    * set the qemu binary
223    *
224    * Set the qemu binary that we will use.
225    * 
226    * The default is chosen when the library was compiled by
227    * the configure script.
228    * 
229    * You can also override this by setting the
230    * "LIBGUESTFS_QEMU" environment variable.
231    * 
232    * Setting "qemu" to "NULL" restores the default qemu
233    * binary.
234    * 
235    * @throws LibGuestFSException
236    */
237   public void set_qemu (String qemu)
238     throws LibGuestFSException
239   {
240     if (g == 0)
241       throw new LibGuestFSException ("set_qemu: handle is closed");
242     _set_qemu (g, qemu);
243   }
244   private native void _set_qemu (long g, String qemu)
245     throws LibGuestFSException;
246
247   /**
248    * get the qemu binary
249    *
250    * Return the current qemu binary.
251    * 
252    * This is always non-NULL. If it wasn't set already, then
253    * this will return the default qemu binary name.
254    * 
255    * @throws LibGuestFSException
256    */
257   public String get_qemu ()
258     throws LibGuestFSException
259   {
260     if (g == 0)
261       throw new LibGuestFSException ("get_qemu: handle is closed");
262     return _get_qemu (g);
263   }
264   private native String _get_qemu (long g)
265     throws LibGuestFSException;
266
267   /**
268    * set the search path
269    *
270    * Set the path that libguestfs searches for kernel and
271    * initrd.img.
272    * 
273    * The default is "$libdir/guestfs" unless overridden by
274    * setting "LIBGUESTFS_PATH" environment variable.
275    * 
276    * Setting "path" to "NULL" restores the default path.
277    * 
278    * @throws LibGuestFSException
279    */
280   public void set_path (String path)
281     throws LibGuestFSException
282   {
283     if (g == 0)
284       throw new LibGuestFSException ("set_path: handle is closed");
285     _set_path (g, path);
286   }
287   private native void _set_path (long g, String path)
288     throws LibGuestFSException;
289
290   /**
291    * get the search path
292    *
293    * Return the current search path.
294    * 
295    * This is always non-NULL. If it wasn't set already, then
296    * this will return the default path.
297    * 
298    * @throws LibGuestFSException
299    */
300   public String get_path ()
301     throws LibGuestFSException
302   {
303     if (g == 0)
304       throw new LibGuestFSException ("get_path: handle is closed");
305     return _get_path (g);
306   }
307   private native String _get_path (long g)
308     throws LibGuestFSException;
309
310   /**
311    * add options to kernel command line
312    *
313    * This function is used to add additional options to the
314    * guest kernel command line.
315    * 
316    * The default is "NULL" unless overridden by setting
317    * "LIBGUESTFS_APPEND" environment variable.
318    * 
319    * Setting "append" to "NULL" means *no* additional options
320    * are passed (libguestfs always adds a few of its own).
321    * 
322    * @throws LibGuestFSException
323    */
324   public void set_append (String append)
325     throws LibGuestFSException
326   {
327     if (g == 0)
328       throw new LibGuestFSException ("set_append: handle is closed");
329     _set_append (g, append);
330   }
331   private native void _set_append (long g, String append)
332     throws LibGuestFSException;
333
334   /**
335    * get the additional kernel options
336    *
337    * Return the additional kernel options which are added to
338    * the guest kernel command line.
339    * 
340    * If "NULL" then no options are added.
341    * 
342    * @throws LibGuestFSException
343    */
344   public String get_append ()
345     throws LibGuestFSException
346   {
347     if (g == 0)
348       throw new LibGuestFSException ("get_append: handle is closed");
349     return _get_append (g);
350   }
351   private native String _get_append (long g)
352     throws LibGuestFSException;
353
354   /**
355    * set autosync mode
356    *
357    * If "autosync" is true, this enables autosync. Libguestfs
358    * will make a best effort attempt to run "g.umount_all"
359    * followed by "g.sync" when the handle is closed (also if
360    * the program exits without closing handles).
361    * 
362    * This is disabled by default (except in guestfish where
363    * it is enabled by default).
364    * 
365    * @throws LibGuestFSException
366    */
367   public void set_autosync (boolean autosync)
368     throws LibGuestFSException
369   {
370     if (g == 0)
371       throw new LibGuestFSException ("set_autosync: handle is closed");
372     _set_autosync (g, autosync);
373   }
374   private native void _set_autosync (long g, boolean autosync)
375     throws LibGuestFSException;
376
377   /**
378    * get autosync mode
379    *
380    * Get the autosync flag.
381    * 
382    * @throws LibGuestFSException
383    */
384   public boolean get_autosync ()
385     throws LibGuestFSException
386   {
387     if (g == 0)
388       throw new LibGuestFSException ("get_autosync: handle is closed");
389     return _get_autosync (g);
390   }
391   private native boolean _get_autosync (long g)
392     throws LibGuestFSException;
393
394   /**
395    * set verbose mode
396    *
397    * If "verbose" is true, this turns on verbose messages (to
398    * "stderr").
399    * 
400    * Verbose messages are disabled unless the environment
401    * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
402    * 
403    * @throws LibGuestFSException
404    */
405   public void set_verbose (boolean verbose)
406     throws LibGuestFSException
407   {
408     if (g == 0)
409       throw new LibGuestFSException ("set_verbose: handle is closed");
410     _set_verbose (g, verbose);
411   }
412   private native void _set_verbose (long g, boolean verbose)
413     throws LibGuestFSException;
414
415   /**
416    * get verbose mode
417    *
418    * This returns the verbose messages flag.
419    * 
420    * @throws LibGuestFSException
421    */
422   public boolean get_verbose ()
423     throws LibGuestFSException
424   {
425     if (g == 0)
426       throw new LibGuestFSException ("get_verbose: handle is closed");
427     return _get_verbose (g);
428   }
429   private native boolean _get_verbose (long g)
430     throws LibGuestFSException;
431
432   /**
433    * is ready to accept commands
434    *
435    * This returns true iff this handle is ready to accept
436    * commands (in the "READY" state).
437    * 
438    * For more information on states, see guestfs(3).
439    * 
440    * @throws LibGuestFSException
441    */
442   public boolean is_ready ()
443     throws LibGuestFSException
444   {
445     if (g == 0)
446       throw new LibGuestFSException ("is_ready: handle is closed");
447     return _is_ready (g);
448   }
449   private native boolean _is_ready (long g)
450     throws LibGuestFSException;
451
452   /**
453    * is in configuration state
454    *
455    * This returns true iff this handle is being configured
456    * (in the "CONFIG" state).
457    * 
458    * For more information on states, see guestfs(3).
459    * 
460    * @throws LibGuestFSException
461    */
462   public boolean is_config ()
463     throws LibGuestFSException
464   {
465     if (g == 0)
466       throw new LibGuestFSException ("is_config: handle is closed");
467     return _is_config (g);
468   }
469   private native boolean _is_config (long g)
470     throws LibGuestFSException;
471
472   /**
473    * is launching subprocess
474    *
475    * This returns true iff this handle is launching the
476    * subprocess (in the "LAUNCHING" state).
477    * 
478    * For more information on states, see guestfs(3).
479    * 
480    * @throws LibGuestFSException
481    */
482   public boolean is_launching ()
483     throws LibGuestFSException
484   {
485     if (g == 0)
486       throw new LibGuestFSException ("is_launching: handle is closed");
487     return _is_launching (g);
488   }
489   private native boolean _is_launching (long g)
490     throws LibGuestFSException;
491
492   /**
493    * is busy processing a command
494    *
495    * This returns true iff this handle is busy processing a
496    * command (in the "BUSY" state).
497    * 
498    * For more information on states, see guestfs(3).
499    * 
500    * @throws LibGuestFSException
501    */
502   public boolean is_busy ()
503     throws LibGuestFSException
504   {
505     if (g == 0)
506       throw new LibGuestFSException ("is_busy: handle is closed");
507     return _is_busy (g);
508   }
509   private native boolean _is_busy (long g)
510     throws LibGuestFSException;
511
512   /**
513    * get the current state
514    *
515    * This returns the current state as an opaque integer.
516    * This is only useful for printing debug and internal
517    * error messages.
518    * 
519    * For more information on states, see guestfs(3).
520    * 
521    * @throws LibGuestFSException
522    */
523   public int get_state ()
524     throws LibGuestFSException
525   {
526     if (g == 0)
527       throw new LibGuestFSException ("get_state: handle is closed");
528     return _get_state (g);
529   }
530   private native int _get_state (long g)
531     throws LibGuestFSException;
532
533   /**
534    * set state to busy
535    *
536    * This sets the state to "BUSY". This is only used when
537    * implementing actions using the low-level API.
538    * 
539    * For more information on states, see guestfs(3).
540    * 
541    * @throws LibGuestFSException
542    */
543   public void set_busy ()
544     throws LibGuestFSException
545   {
546     if (g == 0)
547       throw new LibGuestFSException ("set_busy: handle is closed");
548     _set_busy (g);
549   }
550   private native void _set_busy (long g)
551     throws LibGuestFSException;
552
553   /**
554    * set state to ready
555    *
556    * This sets the state to "READY". This is only used when
557    * implementing actions using the low-level API.
558    * 
559    * For more information on states, see guestfs(3).
560    * 
561    * @throws LibGuestFSException
562    */
563   public void set_ready ()
564     throws LibGuestFSException
565   {
566     if (g == 0)
567       throw new LibGuestFSException ("set_ready: handle is closed");
568     _set_ready (g);
569   }
570   private native void _set_ready (long g)
571     throws LibGuestFSException;
572
573   /**
574    * leave the busy state
575    *
576    * This sets the state to "READY", or if in "CONFIG" then
577    * it leaves the state as is. This is only used when
578    * implementing actions using the low-level API.
579    * 
580    * For more information on states, see guestfs(3).
581    * 
582    * @throws LibGuestFSException
583    */
584   public void end_busy ()
585     throws LibGuestFSException
586   {
587     if (g == 0)
588       throw new LibGuestFSException ("end_busy: handle is closed");
589     _end_busy (g);
590   }
591   private native void _end_busy (long g)
592     throws LibGuestFSException;
593
594   /**
595    * mount a guest disk at a position in the filesystem
596    *
597    * Mount a guest disk at a position in the filesystem.
598    * Block devices are named "/dev/sda", "/dev/sdb" and so
599    * on, as they were added to the guest. If those block
600    * devices contain partitions, they will have the usual
601    * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
602    * names can be used.
603    * 
604    * The rules are the same as for mount(2): A filesystem
605    * must first be mounted on "/" before others can be
606    * mounted. Other filesystems can only be mounted on
607    * directories which already exist.
608    * 
609    * The mounted filesystem is writable, if we have
610    * sufficient permissions on the underlying device.
611    * 
612    * The filesystem options "sync" and "noatime" are set with
613    * this call, in order to improve reliability.
614    * 
615    * @throws LibGuestFSException
616    */
617   public void mount (String device, String mountpoint)
618     throws LibGuestFSException
619   {
620     if (g == 0)
621       throw new LibGuestFSException ("mount: handle is closed");
622     _mount (g, device, mountpoint);
623   }
624   private native void _mount (long g, String device, String mountpoint)
625     throws LibGuestFSException;
626
627   /**
628    * sync disks, writes are flushed through to the disk image
629    *
630    * This syncs the disk, so that any writes are flushed
631    * through to the underlying disk image.
632    * 
633    * You should always call this if you have modified a disk
634    * image, before closing the handle.
635    * 
636    * @throws LibGuestFSException
637    */
638   public void sync ()
639     throws LibGuestFSException
640   {
641     if (g == 0)
642       throw new LibGuestFSException ("sync: handle is closed");
643     _sync (g);
644   }
645   private native void _sync (long g)
646     throws LibGuestFSException;
647
648   /**
649    * update file timestamps or create a new file
650    *
651    * Touch acts like the touch(1) command. It can be used to
652    * update the timestamps on a file, or, if the file does
653    * not exist, to create a new zero-length file.
654    * 
655    * @throws LibGuestFSException
656    */
657   public void touch (String path)
658     throws LibGuestFSException
659   {
660     if (g == 0)
661       throw new LibGuestFSException ("touch: handle is closed");
662     _touch (g, path);
663   }
664   private native void _touch (long g, String path)
665     throws LibGuestFSException;
666
667   /**
668    * list the contents of a file
669    *
670    * Return the contents of the file named "path".
671    * 
672    * Note that this function cannot correctly handle binary
673    * files (specifically, files containing "\0" character
674    * which is treated as end of string). For those you need
675    * to use the "g.download" function which has a more
676    * complex interface.
677    * 
678    * Because of the message protocol, there is a transfer
679    * limit of somewhere between 2MB and 4MB. To transfer
680    * large files you should use FTP.
681    * 
682    * @throws LibGuestFSException
683    */
684   public String cat (String path)
685     throws LibGuestFSException
686   {
687     if (g == 0)
688       throw new LibGuestFSException ("cat: handle is closed");
689     return _cat (g, path);
690   }
691   private native String _cat (long g, String path)
692     throws LibGuestFSException;
693
694   /**
695    * list the files in a directory (long format)
696    *
697    * List the files in "directory" (relative to the root
698    * directory, there is no cwd) in the format of 'ls -la'.
699    * 
700    * This command is mostly useful for interactive sessions.
701    * It is *not* intended that you try to parse the output
702    * string.
703    * 
704    * @throws LibGuestFSException
705    */
706   public String ll (String directory)
707     throws LibGuestFSException
708   {
709     if (g == 0)
710       throw new LibGuestFSException ("ll: handle is closed");
711     return _ll (g, directory);
712   }
713   private native String _ll (long g, String directory)
714     throws LibGuestFSException;
715
716   /**
717    * list the files in a directory
718    *
719    * List the files in "directory" (relative to the root
720    * directory, there is no cwd). The '.' and '..' entries
721    * are not returned, but hidden files are shown.
722    * 
723    * This command is mostly useful for interactive sessions.
724    * Programs should probably use "g.readdir" instead.
725    * 
726    * @throws LibGuestFSException
727    */
728   public String[] ls (String directory)
729     throws LibGuestFSException
730   {
731     if (g == 0)
732       throw new LibGuestFSException ("ls: handle is closed");
733     return _ls (g, directory);
734   }
735   private native String[] _ls (long g, String directory)
736     throws LibGuestFSException;
737
738   /**
739    * list the block devices
740    *
741    * List all the block devices.
742    * 
743    * The full block device names are returned, eg. "/dev/sda"
744    * 
745    * @throws LibGuestFSException
746    */
747   public String[] list_devices ()
748     throws LibGuestFSException
749   {
750     if (g == 0)
751       throw new LibGuestFSException ("list_devices: handle is closed");
752     return _list_devices (g);
753   }
754   private native String[] _list_devices (long g)
755     throws LibGuestFSException;
756
757   /**
758    * list the partitions
759    *
760    * List all the partitions detected on all block devices.
761    * 
762    * The full partition device names are returned, eg.
763    * "/dev/sda1"
764    * 
765    * This does not return logical volumes. For that you will
766    * need to call "g.lvs".
767    * 
768    * @throws LibGuestFSException
769    */
770   public String[] list_partitions ()
771     throws LibGuestFSException
772   {
773     if (g == 0)
774       throw new LibGuestFSException ("list_partitions: handle is closed");
775     return _list_partitions (g);
776   }
777   private native String[] _list_partitions (long g)
778     throws LibGuestFSException;
779
780   /**
781    * list the LVM physical volumes (PVs)
782    *
783    * List all the physical volumes detected. This is the
784    * equivalent of the pvs(8) command.
785    * 
786    * This returns a list of just the device names that
787    * contain PVs (eg. "/dev/sda2").
788    * 
789    * See also "g.pvs_full".
790    * 
791    * @throws LibGuestFSException
792    */
793   public String[] pvs ()
794     throws LibGuestFSException
795   {
796     if (g == 0)
797       throw new LibGuestFSException ("pvs: handle is closed");
798     return _pvs (g);
799   }
800   private native String[] _pvs (long g)
801     throws LibGuestFSException;
802
803   /**
804    * list the LVM volume groups (VGs)
805    *
806    * List all the volumes groups detected. This is the
807    * equivalent of the vgs(8) command.
808    * 
809    * This returns a list of just the volume group names that
810    * were detected (eg. "VolGroup00").
811    * 
812    * See also "g.vgs_full".
813    * 
814    * @throws LibGuestFSException
815    */
816   public String[] vgs ()
817     throws LibGuestFSException
818   {
819     if (g == 0)
820       throw new LibGuestFSException ("vgs: handle is closed");
821     return _vgs (g);
822   }
823   private native String[] _vgs (long g)
824     throws LibGuestFSException;
825
826   /**
827    * list the LVM logical volumes (LVs)
828    *
829    * List all the logical volumes detected. This is the
830    * equivalent of the lvs(8) command.
831    * 
832    * This returns a list of the logical volume device names
833    * (eg. "/dev/VolGroup00/LogVol00").
834    * 
835    * See also "g.lvs_full".
836    * 
837    * @throws LibGuestFSException
838    */
839   public String[] lvs ()
840     throws LibGuestFSException
841   {
842     if (g == 0)
843       throw new LibGuestFSException ("lvs: handle is closed");
844     return _lvs (g);
845   }
846   private native String[] _lvs (long g)
847     throws LibGuestFSException;
848
849   /**
850    * list the LVM physical volumes (PVs)
851    *
852    * List all the physical volumes detected. This is the
853    * equivalent of the pvs(8) command. The "full" version
854    * includes all fields.
855    * 
856    * @throws LibGuestFSException
857    */
858   public PV[] pvs_full ()
859     throws LibGuestFSException
860   {
861     if (g == 0)
862       throw new LibGuestFSException ("pvs_full: handle is closed");
863     return _pvs_full (g);
864   }
865   private native PV[] _pvs_full (long g)
866     throws LibGuestFSException;
867
868   /**
869    * list the LVM volume groups (VGs)
870    *
871    * List all the volumes groups detected. This is the
872    * equivalent of the vgs(8) command. The "full" version
873    * includes all fields.
874    * 
875    * @throws LibGuestFSException
876    */
877   public VG[] vgs_full ()
878     throws LibGuestFSException
879   {
880     if (g == 0)
881       throw new LibGuestFSException ("vgs_full: handle is closed");
882     return _vgs_full (g);
883   }
884   private native VG[] _vgs_full (long g)
885     throws LibGuestFSException;
886
887   /**
888    * list the LVM logical volumes (LVs)
889    *
890    * List all the logical volumes detected. This is the
891    * equivalent of the lvs(8) command. The "full" version
892    * includes all fields.
893    * 
894    * @throws LibGuestFSException
895    */
896   public LV[] lvs_full ()
897     throws LibGuestFSException
898   {
899     if (g == 0)
900       throw new LibGuestFSException ("lvs_full: handle is closed");
901     return _lvs_full (g);
902   }
903   private native LV[] _lvs_full (long g)
904     throws LibGuestFSException;
905
906   /**
907    * read file as lines
908    *
909    * Return the contents of the file named "path".
910    * 
911    * The file contents are returned as a list of lines.
912    * Trailing "LF" and "CRLF" character sequences are *not*
913    * returned.
914    * 
915    * Note that this function cannot correctly handle binary
916    * files (specifically, files containing "\0" character
917    * which is treated as end of line). For those you need to
918    * use the "g.read_file" function which has a more complex
919    * interface.
920    * 
921    * @throws LibGuestFSException
922    */
923   public String[] read_lines (String path)
924     throws LibGuestFSException
925   {
926     if (g == 0)
927       throw new LibGuestFSException ("read_lines: handle is closed");
928     return _read_lines (g, path);
929   }
930   private native String[] _read_lines (long g, String path)
931     throws LibGuestFSException;
932
933   /**
934    * create a new Augeas handle
935    *
936    * Create a new Augeas handle for editing configuration
937    * files. If there was any previous Augeas handle
938    * associated with this guestfs session, then it is closed.
939    * 
940    * You must call this before using any other "g.aug_*"
941    * commands.
942    * 
943    * "root" is the filesystem root. "root" must not be NULL,
944    * use "/" instead.
945    * 
946    * The flags are the same as the flags defined in
947    * <augeas.h>, the logical *or* of the following integers:
948    * 
949    * "AUG_SAVE_BACKUP" = 1
950    * Keep the original file with a ".augsave" extension.
951    * 
952    * "AUG_SAVE_NEWFILE" = 2
953    * Save changes into a file with extension ".augnew",
954    * and do not overwrite original. Overrides
955    * "AUG_SAVE_BACKUP".
956    * 
957    * "AUG_TYPE_CHECK" = 4
958    * Typecheck lenses (can be expensive).
959    * 
960    * "AUG_NO_STDINC" = 8
961    * Do not use standard load path for modules.
962    * 
963    * "AUG_SAVE_NOOP" = 16
964    * Make save a no-op, just record what would have been
965    * changed.
966    * 
967    * "AUG_NO_LOAD" = 32
968    * Do not load the tree in "g.aug_init".
969    * 
970    * To close the handle, you can call "g.aug_close".
971    * 
972    * To find out more about Augeas, see <http://augeas.net/>.
973    * 
974    * @throws LibGuestFSException
975    */
976   public void aug_init (String root, int flags)
977     throws LibGuestFSException
978   {
979     if (g == 0)
980       throw new LibGuestFSException ("aug_init: handle is closed");
981     _aug_init (g, root, flags);
982   }
983   private native void _aug_init (long g, String root, int flags)
984     throws LibGuestFSException;
985
986   /**
987    * close the current Augeas handle
988    *
989    * Close the current Augeas handle and free up any
990    * resources used by it. After calling this, you have to
991    * call "g.aug_init" again before you can use any other
992    * Augeas functions.
993    * 
994    * @throws LibGuestFSException
995    */
996   public void aug_close ()
997     throws LibGuestFSException
998   {
999     if (g == 0)
1000       throw new LibGuestFSException ("aug_close: handle is closed");
1001     _aug_close (g);
1002   }
1003   private native void _aug_close (long g)
1004     throws LibGuestFSException;
1005
1006   /**
1007    * define an Augeas variable
1008    *
1009    * Defines an Augeas variable "name" whose value is the
1010    * result of evaluating "expr". If "expr" is NULL, then
1011    * "name" is undefined.
1012    * 
1013    * On success this returns the number of nodes in "expr",
1014    * or 0 if "expr" evaluates to something which is not a
1015    * nodeset.
1016    * 
1017    * @throws LibGuestFSException
1018    */
1019   public int aug_defvar (String name, String expr)
1020     throws LibGuestFSException
1021   {
1022     if (g == 0)
1023       throw new LibGuestFSException ("aug_defvar: handle is closed");
1024     return _aug_defvar (g, name, expr);
1025   }
1026   private native int _aug_defvar (long g, String name, String expr)
1027     throws LibGuestFSException;
1028
1029   /**
1030    * define an Augeas node
1031    *
1032    * Defines a variable "name" whose value is the result of
1033    * evaluating "expr".
1034    * 
1035    * If "expr" evaluates to an empty nodeset, a node is
1036    * created, equivalent to calling "g.aug_set" "expr",
1037    * "value". "name" will be the nodeset containing that
1038    * single node.
1039    * 
1040    * On success this returns a pair containing the number of
1041    * nodes in the nodeset, and a boolean flag if a node was
1042    * created.
1043    * 
1044    * @throws LibGuestFSException
1045    */
1046   public IntBool aug_defnode (String name, String expr, String val)
1047     throws LibGuestFSException
1048   {
1049     if (g == 0)
1050       throw new LibGuestFSException ("aug_defnode: handle is closed");
1051     return _aug_defnode (g, name, expr, val);
1052   }
1053   private native IntBool _aug_defnode (long g, String name, String expr, String val)
1054     throws LibGuestFSException;
1055
1056   /**
1057    * look up the value of an Augeas path
1058    *
1059    * Look up the value associated with "path". If "path"
1060    * matches exactly one node, the "value" is returned.
1061    * 
1062    * @throws LibGuestFSException
1063    */
1064   public String aug_get (String path)
1065     throws LibGuestFSException
1066   {
1067     if (g == 0)
1068       throw new LibGuestFSException ("aug_get: handle is closed");
1069     return _aug_get (g, path);
1070   }
1071   private native String _aug_get (long g, String path)
1072     throws LibGuestFSException;
1073
1074   /**
1075    * set Augeas path to value
1076    *
1077    * Set the value associated with "path" to "value".
1078    * 
1079    * @throws LibGuestFSException
1080    */
1081   public void aug_set (String path, String val)
1082     throws LibGuestFSException
1083   {
1084     if (g == 0)
1085       throw new LibGuestFSException ("aug_set: handle is closed");
1086     _aug_set (g, path, val);
1087   }
1088   private native void _aug_set (long g, String path, String val)
1089     throws LibGuestFSException;
1090
1091   /**
1092    * insert a sibling Augeas node
1093    *
1094    * Create a new sibling "label" for "path", inserting it
1095    * into the tree before or after "path" (depending on the
1096    * boolean flag "before").
1097    * 
1098    * "path" must match exactly one existing node in the tree,
1099    * and "label" must be a label, ie. not contain "/", "*" or
1100    * end with a bracketed index "[N]".
1101    * 
1102    * @throws LibGuestFSException
1103    */
1104   public void aug_insert (String path, String label, boolean before)
1105     throws LibGuestFSException
1106   {
1107     if (g == 0)
1108       throw new LibGuestFSException ("aug_insert: handle is closed");
1109     _aug_insert (g, path, label, before);
1110   }
1111   private native void _aug_insert (long g, String path, String label, boolean before)
1112     throws LibGuestFSException;
1113
1114   /**
1115    * remove an Augeas path
1116    *
1117    * Remove "path" and all of its children.
1118    * 
1119    * On success this returns the number of entries which were
1120    * removed.
1121    * 
1122    * @throws LibGuestFSException
1123    */
1124   public int aug_rm (String path)
1125     throws LibGuestFSException
1126   {
1127     if (g == 0)
1128       throw new LibGuestFSException ("aug_rm: handle is closed");
1129     return _aug_rm (g, path);
1130   }
1131   private native int _aug_rm (long g, String path)
1132     throws LibGuestFSException;
1133
1134   /**
1135    * move Augeas node
1136    *
1137    * Move the node "src" to "dest". "src" must match exactly
1138    * one node. "dest" is overwritten if it exists.
1139    * 
1140    * @throws LibGuestFSException
1141    */
1142   public void aug_mv (String src, String dest)
1143     throws LibGuestFSException
1144   {
1145     if (g == 0)
1146       throw new LibGuestFSException ("aug_mv: handle is closed");
1147     _aug_mv (g, src, dest);
1148   }
1149   private native void _aug_mv (long g, String src, String dest)
1150     throws LibGuestFSException;
1151
1152   /**
1153    * return Augeas nodes which match path
1154    *
1155    * Returns a list of paths which match the path expression
1156    * "path". The returned paths are sufficiently qualified so
1157    * that they match exactly one node in the current tree.
1158    * 
1159    * @throws LibGuestFSException
1160    */
1161   public String[] aug_match (String path)
1162     throws LibGuestFSException
1163   {
1164     if (g == 0)
1165       throw new LibGuestFSException ("aug_match: handle is closed");
1166     return _aug_match (g, path);
1167   }
1168   private native String[] _aug_match (long g, String path)
1169     throws LibGuestFSException;
1170
1171   /**
1172    * write all pending Augeas changes to disk
1173    *
1174    * This writes all pending changes to disk.
1175    * 
1176    * The flags which were passed to "g.aug_init" affect
1177    * exactly how files are saved.
1178    * 
1179    * @throws LibGuestFSException
1180    */
1181   public void aug_save ()
1182     throws LibGuestFSException
1183   {
1184     if (g == 0)
1185       throw new LibGuestFSException ("aug_save: handle is closed");
1186     _aug_save (g);
1187   }
1188   private native void _aug_save (long g)
1189     throws LibGuestFSException;
1190
1191   /**
1192    * load files into the tree
1193    *
1194    * Load files into the tree.
1195    * 
1196    * See "aug_load" in the Augeas documentation for the full
1197    * gory details.
1198    * 
1199    * @throws LibGuestFSException
1200    */
1201   public void aug_load ()
1202     throws LibGuestFSException
1203   {
1204     if (g == 0)
1205       throw new LibGuestFSException ("aug_load: handle is closed");
1206     _aug_load (g);
1207   }
1208   private native void _aug_load (long g)
1209     throws LibGuestFSException;
1210
1211   /**
1212    * list Augeas nodes under a path
1213    *
1214    * This is just a shortcut for listing "g.aug_match"
1215    * "path/*" and sorting the resulting nodes into
1216    * alphabetical order.
1217    * 
1218    * @throws LibGuestFSException
1219    */
1220   public String[] aug_ls (String path)
1221     throws LibGuestFSException
1222   {
1223     if (g == 0)
1224       throw new LibGuestFSException ("aug_ls: handle is closed");
1225     return _aug_ls (g, path);
1226   }
1227   private native String[] _aug_ls (long g, String path)
1228     throws LibGuestFSException;
1229
1230   /**
1231    * remove a file
1232    *
1233    * Remove the single file "path".
1234    * 
1235    * @throws LibGuestFSException
1236    */
1237   public void rm (String path)
1238     throws LibGuestFSException
1239   {
1240     if (g == 0)
1241       throw new LibGuestFSException ("rm: handle is closed");
1242     _rm (g, path);
1243   }
1244   private native void _rm (long g, String path)
1245     throws LibGuestFSException;
1246
1247   /**
1248    * remove a directory
1249    *
1250    * Remove the single directory "path".
1251    * 
1252    * @throws LibGuestFSException
1253    */
1254   public void rmdir (String path)
1255     throws LibGuestFSException
1256   {
1257     if (g == 0)
1258       throw new LibGuestFSException ("rmdir: handle is closed");
1259     _rmdir (g, path);
1260   }
1261   private native void _rmdir (long g, String path)
1262     throws LibGuestFSException;
1263
1264   /**
1265    * remove a file or directory recursively
1266    *
1267    * Remove the file or directory "path", recursively
1268    * removing the contents if its a directory. This is like
1269    * the "rm -rf" shell command.
1270    * 
1271    * @throws LibGuestFSException
1272    */
1273   public void rm_rf (String path)
1274     throws LibGuestFSException
1275   {
1276     if (g == 0)
1277       throw new LibGuestFSException ("rm_rf: handle is closed");
1278     _rm_rf (g, path);
1279   }
1280   private native void _rm_rf (long g, String path)
1281     throws LibGuestFSException;
1282
1283   /**
1284    * create a directory
1285    *
1286    * Create a directory named "path".
1287    * 
1288    * @throws LibGuestFSException
1289    */
1290   public void mkdir (String path)
1291     throws LibGuestFSException
1292   {
1293     if (g == 0)
1294       throw new LibGuestFSException ("mkdir: handle is closed");
1295     _mkdir (g, path);
1296   }
1297   private native void _mkdir (long g, String path)
1298     throws LibGuestFSException;
1299
1300   /**
1301    * create a directory and parents
1302    *
1303    * Create a directory named "path", creating any parent
1304    * directories as necessary. This is like the "mkdir -p"
1305    * shell command.
1306    * 
1307    * @throws LibGuestFSException
1308    */
1309   public void mkdir_p (String path)
1310     throws LibGuestFSException
1311   {
1312     if (g == 0)
1313       throw new LibGuestFSException ("mkdir_p: handle is closed");
1314     _mkdir_p (g, path);
1315   }
1316   private native void _mkdir_p (long g, String path)
1317     throws LibGuestFSException;
1318
1319   /**
1320    * change file mode
1321    *
1322    * Change the mode (permissions) of "path" to "mode". Only
1323    * numeric modes are supported.
1324    * 
1325    * @throws LibGuestFSException
1326    */
1327   public void chmod (int mode, String path)
1328     throws LibGuestFSException
1329   {
1330     if (g == 0)
1331       throw new LibGuestFSException ("chmod: handle is closed");
1332     _chmod (g, mode, path);
1333   }
1334   private native void _chmod (long g, int mode, String path)
1335     throws LibGuestFSException;
1336
1337   /**
1338    * change file owner and group
1339    *
1340    * Change the file owner to "owner" and group to "group".
1341    * 
1342    * Only numeric uid and gid are supported. If you want to
1343    * use names, you will need to locate and parse the
1344    * password file yourself (Augeas support makes this
1345    * relatively easy).
1346    * 
1347    * @throws LibGuestFSException
1348    */
1349   public void chown (int owner, int group, String path)
1350     throws LibGuestFSException
1351   {
1352     if (g == 0)
1353       throw new LibGuestFSException ("chown: handle is closed");
1354     _chown (g, owner, group, path);
1355   }
1356   private native void _chown (long g, int owner, int group, String path)
1357     throws LibGuestFSException;
1358
1359   /**
1360    * test if file or directory exists
1361    *
1362    * This returns "true" if and only if there is a file,
1363    * directory (or anything) with the given "path" name.
1364    * 
1365    * See also "g.is_file", "g.is_dir", "g.stat".
1366    * 
1367    * @throws LibGuestFSException
1368    */
1369   public boolean exists (String path)
1370     throws LibGuestFSException
1371   {
1372     if (g == 0)
1373       throw new LibGuestFSException ("exists: handle is closed");
1374     return _exists (g, path);
1375   }
1376   private native boolean _exists (long g, String path)
1377     throws LibGuestFSException;
1378
1379   /**
1380    * test if file exists
1381    *
1382    * This returns "true" if and only if there is a file with
1383    * the given "path" name. Note that it returns false for
1384    * other objects like directories.
1385    * 
1386    * See also "g.stat".
1387    * 
1388    * @throws LibGuestFSException
1389    */
1390   public boolean is_file (String path)
1391     throws LibGuestFSException
1392   {
1393     if (g == 0)
1394       throw new LibGuestFSException ("is_file: handle is closed");
1395     return _is_file (g, path);
1396   }
1397   private native boolean _is_file (long g, String path)
1398     throws LibGuestFSException;
1399
1400   /**
1401    * test if file exists
1402    *
1403    * This returns "true" if and only if there is a directory
1404    * with the given "path" name. Note that it returns false
1405    * for other objects like files.
1406    * 
1407    * See also "g.stat".
1408    * 
1409    * @throws LibGuestFSException
1410    */
1411   public boolean is_dir (String path)
1412     throws LibGuestFSException
1413   {
1414     if (g == 0)
1415       throw new LibGuestFSException ("is_dir: handle is closed");
1416     return _is_dir (g, path);
1417   }
1418   private native boolean _is_dir (long g, String path)
1419     throws LibGuestFSException;
1420
1421   /**
1422    * create an LVM physical volume
1423    *
1424    * This creates an LVM physical volume on the named
1425    * "device", where "device" should usually be a partition
1426    * name such as "/dev/sda1".
1427    * 
1428    * @throws LibGuestFSException
1429    */
1430   public void pvcreate (String device)
1431     throws LibGuestFSException
1432   {
1433     if (g == 0)
1434       throw new LibGuestFSException ("pvcreate: handle is closed");
1435     _pvcreate (g, device);
1436   }
1437   private native void _pvcreate (long g, String device)
1438     throws LibGuestFSException;
1439
1440   /**
1441    * create an LVM volume group
1442    *
1443    * This creates an LVM volume group called "volgroup" from
1444    * the non-empty list of physical volumes "physvols".
1445    * 
1446    * @throws LibGuestFSException
1447    */
1448   public void vgcreate (String volgroup, String[] physvols)
1449     throws LibGuestFSException
1450   {
1451     if (g == 0)
1452       throw new LibGuestFSException ("vgcreate: handle is closed");
1453     _vgcreate (g, volgroup, physvols);
1454   }
1455   private native void _vgcreate (long g, String volgroup, String[] physvols)
1456     throws LibGuestFSException;
1457
1458   /**
1459    * create an LVM volume group
1460    *
1461    * This creates an LVM volume group called "logvol" on the
1462    * volume group "volgroup", with "size" megabytes.
1463    * 
1464    * @throws LibGuestFSException
1465    */
1466   public void lvcreate (String logvol, String volgroup, int mbytes)
1467     throws LibGuestFSException
1468   {
1469     if (g == 0)
1470       throw new LibGuestFSException ("lvcreate: handle is closed");
1471     _lvcreate (g, logvol, volgroup, mbytes);
1472   }
1473   private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1474     throws LibGuestFSException;
1475
1476   /**
1477    * make a filesystem
1478    *
1479    * This creates a filesystem on "device" (usually a
1480    * partition or LVM logical volume). The filesystem type is
1481    * "fstype", for example "ext3".
1482    * 
1483    * @throws LibGuestFSException
1484    */
1485   public void mkfs (String fstype, String device)
1486     throws LibGuestFSException
1487   {
1488     if (g == 0)
1489       throw new LibGuestFSException ("mkfs: handle is closed");
1490     _mkfs (g, fstype, device);
1491   }
1492   private native void _mkfs (long g, String fstype, String device)
1493     throws LibGuestFSException;
1494
1495   /**
1496    * create partitions on a block device
1497    *
1498    * This is a direct interface to the sfdisk(8) program for
1499    * creating partitions on block devices.
1500    * 
1501    * "device" should be a block device, for example
1502    * "/dev/sda".
1503    * 
1504    * "cyls", "heads" and "sectors" are the number of
1505    * cylinders, heads and sectors on the device, which are
1506    * passed directly to sfdisk as the *-C*, *-H* and *-S*
1507    * parameters. If you pass 0 for any of these, then the
1508    * corresponding parameter is omitted. Usually for 'large'
1509    * disks, you can just pass 0 for these, but for small
1510    * (floppy-sized) disks, sfdisk (or rather, the kernel)
1511    * cannot work out the right geometry and you will need to
1512    * tell it.
1513    * 
1514    * "lines" is a list of lines that we feed to "sfdisk". For
1515    * more information refer to the sfdisk(8) manpage.
1516    * 
1517    * To create a single partition occupying the whole disk,
1518    * you would pass "lines" as a single element list, when
1519    * the single element being the string "," (comma).
1520    * 
1521    * This command is dangerous. Without careful use you can
1522    * easily destroy all your data.
1523    * 
1524    * @throws LibGuestFSException
1525    */
1526   public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1527     throws LibGuestFSException
1528   {
1529     if (g == 0)
1530       throw new LibGuestFSException ("sfdisk: handle is closed");
1531     _sfdisk (g, device, cyls, heads, sectors, lines);
1532   }
1533   private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1534     throws LibGuestFSException;
1535
1536   /**
1537    * create a file
1538    *
1539    * This call creates a file called "path". The contents of
1540    * the file is the string "content" (which can contain any
1541    * 8 bit data), with length "size".
1542    * 
1543    * As a special case, if "size" is 0 then the length is
1544    * calculated using "strlen" (so in this case the content
1545    * cannot contain embedded ASCII NULs).
1546    * 
1547    * *NB.* Owing to a bug, writing content containing ASCII
1548    * NUL characters does *not* work, even if the length is
1549    * specified. We hope to resolve this bug in a future
1550    * version. In the meantime use "g.upload".
1551    * 
1552    * Because of the message protocol, there is a transfer
1553    * limit of somewhere between 2MB and 4MB. To transfer
1554    * large files you should use FTP.
1555    * 
1556    * @throws LibGuestFSException
1557    */
1558   public void write_file (String path, String content, int size)
1559     throws LibGuestFSException
1560   {
1561     if (g == 0)
1562       throw new LibGuestFSException ("write_file: handle is closed");
1563     _write_file (g, path, content, size);
1564   }
1565   private native void _write_file (long g, String path, String content, int size)
1566     throws LibGuestFSException;
1567
1568   /**
1569    * unmount a filesystem
1570    *
1571    * This unmounts the given filesystem. The filesystem may
1572    * be specified either by its mountpoint (path) or the
1573    * device which contains the filesystem.
1574    * 
1575    * @throws LibGuestFSException
1576    */
1577   public void umount (String pathordevice)
1578     throws LibGuestFSException
1579   {
1580     if (g == 0)
1581       throw new LibGuestFSException ("umount: handle is closed");
1582     _umount (g, pathordevice);
1583   }
1584   private native void _umount (long g, String pathordevice)
1585     throws LibGuestFSException;
1586
1587   /**
1588    * show mounted filesystems
1589    *
1590    * This returns the list of currently mounted filesystems.
1591    * It returns the list of devices (eg. "/dev/sda1",
1592    * "/dev/VG/LV").
1593    * 
1594    * Some internal mounts are not shown.
1595    * 
1596    * @throws LibGuestFSException
1597    */
1598   public String[] mounts ()
1599     throws LibGuestFSException
1600   {
1601     if (g == 0)
1602       throw new LibGuestFSException ("mounts: handle is closed");
1603     return _mounts (g);
1604   }
1605   private native String[] _mounts (long g)
1606     throws LibGuestFSException;
1607
1608   /**
1609    * unmount all filesystems
1610    *
1611    * This unmounts all mounted filesystems.
1612    * 
1613    * Some internal mounts are not unmounted by this call.
1614    * 
1615    * @throws LibGuestFSException
1616    */
1617   public void umount_all ()
1618     throws LibGuestFSException
1619   {
1620     if (g == 0)
1621       throw new LibGuestFSException ("umount_all: handle is closed");
1622     _umount_all (g);
1623   }
1624   private native void _umount_all (long g)
1625     throws LibGuestFSException;
1626
1627   /**
1628    * remove all LVM LVs, VGs and PVs
1629    *
1630    * This command removes all LVM logical volumes, volume
1631    * groups and physical volumes.
1632    * 
1633    * This command is dangerous. Without careful use you can
1634    * easily destroy all your data.
1635    * 
1636    * @throws LibGuestFSException
1637    */
1638   public void lvm_remove_all ()
1639     throws LibGuestFSException
1640   {
1641     if (g == 0)
1642       throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1643     _lvm_remove_all (g);
1644   }
1645   private native void _lvm_remove_all (long g)
1646     throws LibGuestFSException;
1647
1648   /**
1649    * determine file type
1650    *
1651    * This call uses the standard file(1) command to determine
1652    * the type or contents of the file. This also works on
1653    * devices, for example to find out whether a partition
1654    * contains a filesystem.
1655    * 
1656    * The exact command which runs is "file -bsL path". Note
1657    * in particular that the filename is not prepended to the
1658    * output (the "-b" option).
1659    * 
1660    * @throws LibGuestFSException
1661    */
1662   public String file (String path)
1663     throws LibGuestFSException
1664   {
1665     if (g == 0)
1666       throw new LibGuestFSException ("file: handle is closed");
1667     return _file (g, path);
1668   }
1669   private native String _file (long g, String path)
1670     throws LibGuestFSException;
1671
1672   /**
1673    * run a command from the guest filesystem
1674    *
1675    * This call runs a command from the guest filesystem. The
1676    * filesystem must be mounted, and must contain a
1677    * compatible operating system (ie. something Linux, with
1678    * the same or compatible processor architecture).
1679    * 
1680    * The single parameter is an argv-style list of arguments.
1681    * The first element is the name of the program to run.
1682    * Subsequent elements are parameters. The list must be
1683    * non-empty (ie. must contain a program name).
1684    * 
1685    * The return value is anything printed to *stdout* by the
1686    * command.
1687    * 
1688    * If the command returns a non-zero exit status, then this
1689    * function returns an error message. The error message
1690    * string is the content of *stderr* from the command.
1691    * 
1692    * The $PATH environment variable will contain at least
1693    * "/usr/bin" and "/bin". If you require a program from
1694    * another location, you should provide the full path in
1695    * the first parameter.
1696    * 
1697    * Shared libraries and data files required by the program
1698    * must be available on filesystems which are mounted in
1699    * the correct places. It is the caller's responsibility to
1700    * ensure all filesystems that are needed are mounted at
1701    * the right locations.
1702    * 
1703    * Because of the message protocol, there is a transfer
1704    * limit of somewhere between 2MB and 4MB. To transfer
1705    * large files you should use FTP.
1706    * 
1707    * @throws LibGuestFSException
1708    */
1709   public String command (String[] arguments)
1710     throws LibGuestFSException
1711   {
1712     if (g == 0)
1713       throw new LibGuestFSException ("command: handle is closed");
1714     return _command (g, arguments);
1715   }
1716   private native String _command (long g, String[] arguments)
1717     throws LibGuestFSException;
1718
1719   /**
1720    * run a command, returning lines
1721    *
1722    * This is the same as "g.command", but splits the result
1723    * into a list of lines.
1724    * 
1725    * Because of the message protocol, there is a transfer
1726    * limit of somewhere between 2MB and 4MB. To transfer
1727    * large files you should use FTP.
1728    * 
1729    * @throws LibGuestFSException
1730    */
1731   public String[] command_lines (String[] arguments)
1732     throws LibGuestFSException
1733   {
1734     if (g == 0)
1735       throw new LibGuestFSException ("command_lines: handle is closed");
1736     return _command_lines (g, arguments);
1737   }
1738   private native String[] _command_lines (long g, String[] arguments)
1739     throws LibGuestFSException;
1740
1741   /**
1742    * get file information
1743    *
1744    * Returns file information for the given "path".
1745    * 
1746    * This is the same as the stat(2) system call.
1747    * 
1748    * @throws LibGuestFSException
1749    */
1750   public Stat stat (String path)
1751     throws LibGuestFSException
1752   {
1753     if (g == 0)
1754       throw new LibGuestFSException ("stat: handle is closed");
1755     return _stat (g, path);
1756   }
1757   private native Stat _stat (long g, String path)
1758     throws LibGuestFSException;
1759
1760   /**
1761    * get file information for a symbolic link
1762    *
1763    * Returns file information for the given "path".
1764    * 
1765    * This is the same as "g.stat" except that if "path" is a
1766    * symbolic link, then the link is stat-ed, not the file it
1767    * refers to.
1768    * 
1769    * This is the same as the lstat(2) system call.
1770    * 
1771    * @throws LibGuestFSException
1772    */
1773   public Stat lstat (String path)
1774     throws LibGuestFSException
1775   {
1776     if (g == 0)
1777       throw new LibGuestFSException ("lstat: handle is closed");
1778     return _lstat (g, path);
1779   }
1780   private native Stat _lstat (long g, String path)
1781     throws LibGuestFSException;
1782
1783   /**
1784    * get file system statistics
1785    *
1786    * Returns file system statistics for any mounted file
1787    * system. "path" should be a file or directory in the
1788    * mounted file system (typically it is the mount point
1789    * itself, but it doesn't need to be).
1790    * 
1791    * This is the same as the statvfs(2) system call.
1792    * 
1793    * @throws LibGuestFSException
1794    */
1795   public StatVFS statvfs (String path)
1796     throws LibGuestFSException
1797   {
1798     if (g == 0)
1799       throw new LibGuestFSException ("statvfs: handle is closed");
1800     return _statvfs (g, path);
1801   }
1802   private native StatVFS _statvfs (long g, String path)
1803     throws LibGuestFSException;
1804
1805   /**
1806    * get ext2/ext3/ext4 superblock details
1807    *
1808    * This returns the contents of the ext2, ext3 or ext4
1809    * filesystem superblock on "device".
1810    * 
1811    * It is the same as running "tune2fs -l device". See
1812    * tune2fs(8) manpage for more details. The list of fields
1813    * returned isn't clearly defined, and depends on both the
1814    * version of "tune2fs" that libguestfs was built against,
1815    * and the filesystem itself.
1816    * 
1817    * @throws LibGuestFSException
1818    */
1819   public HashMap<String,String> tune2fs_l (String device)
1820     throws LibGuestFSException
1821   {
1822     if (g == 0)
1823       throw new LibGuestFSException ("tune2fs_l: handle is closed");
1824     return _tune2fs_l (g, device);
1825   }
1826   private native HashMap<String,String> _tune2fs_l (long g, String device)
1827     throws LibGuestFSException;
1828
1829   /**
1830    * set block device to read-only
1831    *
1832    * Sets the block device named "device" to read-only.
1833    * 
1834    * This uses the blockdev(8) command.
1835    * 
1836    * @throws LibGuestFSException
1837    */
1838   public void blockdev_setro (String device)
1839     throws LibGuestFSException
1840   {
1841     if (g == 0)
1842       throw new LibGuestFSException ("blockdev_setro: handle is closed");
1843     _blockdev_setro (g, device);
1844   }
1845   private native void _blockdev_setro (long g, String device)
1846     throws LibGuestFSException;
1847
1848   /**
1849    * set block device to read-write
1850    *
1851    * Sets the block device named "device" to read-write.
1852    * 
1853    * This uses the blockdev(8) command.
1854    * 
1855    * @throws LibGuestFSException
1856    */
1857   public void blockdev_setrw (String device)
1858     throws LibGuestFSException
1859   {
1860     if (g == 0)
1861       throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1862     _blockdev_setrw (g, device);
1863   }
1864   private native void _blockdev_setrw (long g, String device)
1865     throws LibGuestFSException;
1866
1867   /**
1868    * is block device set to read-only
1869    *
1870    * Returns a boolean indicating if the block device is
1871    * read-only (true if read-only, false if not).
1872    * 
1873    * This uses the blockdev(8) command.
1874    * 
1875    * @throws LibGuestFSException
1876    */
1877   public boolean blockdev_getro (String device)
1878     throws LibGuestFSException
1879   {
1880     if (g == 0)
1881       throw new LibGuestFSException ("blockdev_getro: handle is closed");
1882     return _blockdev_getro (g, device);
1883   }
1884   private native boolean _blockdev_getro (long g, String device)
1885     throws LibGuestFSException;
1886
1887   /**
1888    * get sectorsize of block device
1889    *
1890    * This returns the size of sectors on a block device.
1891    * Usually 512, but can be larger for modern devices.
1892    * 
1893    * (Note, this is not the size in sectors, use
1894    * "g.blockdev_getsz" for that).
1895    * 
1896    * This uses the blockdev(8) command.
1897    * 
1898    * @throws LibGuestFSException
1899    */
1900   public int blockdev_getss (String device)
1901     throws LibGuestFSException
1902   {
1903     if (g == 0)
1904       throw new LibGuestFSException ("blockdev_getss: handle is closed");
1905     return _blockdev_getss (g, device);
1906   }
1907   private native int _blockdev_getss (long g, String device)
1908     throws LibGuestFSException;
1909
1910   /**
1911    * get blocksize of block device
1912    *
1913    * This returns the block size of a device.
1914    * 
1915    * (Note this is different from both *size in blocks* and
1916    * *filesystem block size*).
1917    * 
1918    * This uses the blockdev(8) command.
1919    * 
1920    * @throws LibGuestFSException
1921    */
1922   public int blockdev_getbsz (String device)
1923     throws LibGuestFSException
1924   {
1925     if (g == 0)
1926       throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1927     return _blockdev_getbsz (g, device);
1928   }
1929   private native int _blockdev_getbsz (long g, String device)
1930     throws LibGuestFSException;
1931
1932   /**
1933    * set blocksize of block device
1934    *
1935    * This sets the block size of a device.
1936    * 
1937    * (Note this is different from both *size in blocks* and
1938    * *filesystem block size*).
1939    * 
1940    * This uses the blockdev(8) command.
1941    * 
1942    * @throws LibGuestFSException
1943    */
1944   public void blockdev_setbsz (String device, int blocksize)
1945     throws LibGuestFSException
1946   {
1947     if (g == 0)
1948       throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1949     _blockdev_setbsz (g, device, blocksize);
1950   }
1951   private native void _blockdev_setbsz (long g, String device, int blocksize)
1952     throws LibGuestFSException;
1953
1954   /**
1955    * get total size of device in 512-byte sectors
1956    *
1957    * This returns the size of the device in units of 512-byte
1958    * sectors (even if the sectorsize isn't 512 bytes ...
1959    * weird).
1960    * 
1961    * See also "g.blockdev_getss" for the real sector size of
1962    * the device, and "g.blockdev_getsize64" for the more
1963    * useful *size in bytes*.
1964    * 
1965    * This uses the blockdev(8) command.
1966    * 
1967    * @throws LibGuestFSException
1968    */
1969   public long blockdev_getsz (String device)
1970     throws LibGuestFSException
1971   {
1972     if (g == 0)
1973       throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1974     return _blockdev_getsz (g, device);
1975   }
1976   private native long _blockdev_getsz (long g, String device)
1977     throws LibGuestFSException;
1978
1979   /**
1980    * get total size of device in bytes
1981    *
1982    * This returns the size of the device in bytes.
1983    * 
1984    * See also "g.blockdev_getsz".
1985    * 
1986    * This uses the blockdev(8) command.
1987    * 
1988    * @throws LibGuestFSException
1989    */
1990   public long blockdev_getsize64 (String device)
1991     throws LibGuestFSException
1992   {
1993     if (g == 0)
1994       throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1995     return _blockdev_getsize64 (g, device);
1996   }
1997   private native long _blockdev_getsize64 (long g, String device)
1998     throws LibGuestFSException;
1999
2000   /**
2001    * flush device buffers
2002    *
2003    * This tells the kernel to flush internal buffers
2004    * associated with "device".
2005    * 
2006    * This uses the blockdev(8) command.
2007    * 
2008    * @throws LibGuestFSException
2009    */
2010   public void blockdev_flushbufs (String device)
2011     throws LibGuestFSException
2012   {
2013     if (g == 0)
2014       throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2015     _blockdev_flushbufs (g, device);
2016   }
2017   private native void _blockdev_flushbufs (long g, String device)
2018     throws LibGuestFSException;
2019
2020   /**
2021    * reread partition table
2022    *
2023    * Reread the partition table on "device".
2024    * 
2025    * This uses the blockdev(8) command.
2026    * 
2027    * @throws LibGuestFSException
2028    */
2029   public void blockdev_rereadpt (String device)
2030     throws LibGuestFSException
2031   {
2032     if (g == 0)
2033       throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2034     _blockdev_rereadpt (g, device);
2035   }
2036   private native void _blockdev_rereadpt (long g, String device)
2037     throws LibGuestFSException;
2038
2039   /**
2040    * upload a file from the local machine
2041    *
2042    * Upload local file "filename" to "remotefilename" on the
2043    * filesystem.
2044    * 
2045    * "filename" can also be a named pipe.
2046    * 
2047    * See also "g.download".
2048    * 
2049    * @throws LibGuestFSException
2050    */
2051   public void upload (String filename, String remotefilename)
2052     throws LibGuestFSException
2053   {
2054     if (g == 0)
2055       throw new LibGuestFSException ("upload: handle is closed");
2056     _upload (g, filename, remotefilename);
2057   }
2058   private native void _upload (long g, String filename, String remotefilename)
2059     throws LibGuestFSException;
2060
2061   /**
2062    * download a file to the local machine
2063    *
2064    * Download file "remotefilename" and save it as "filename"
2065    * on the local machine.
2066    * 
2067    * "filename" can also be a named pipe.
2068    * 
2069    * See also "g.upload", "g.cat".
2070    * 
2071    * @throws LibGuestFSException
2072    */
2073   public void download (String remotefilename, String filename)
2074     throws LibGuestFSException
2075   {
2076     if (g == 0)
2077       throw new LibGuestFSException ("download: handle is closed");
2078     _download (g, remotefilename, filename);
2079   }
2080   private native void _download (long g, String remotefilename, String filename)
2081     throws LibGuestFSException;
2082
2083   /**
2084    * compute MD5, SHAx or CRC checksum of file
2085    *
2086    * This call computes the MD5, SHAx or CRC checksum of the
2087    * file named "path".
2088    * 
2089    * The type of checksum to compute is given by the
2090    * "csumtype" parameter which must have one of the
2091    * following values:
2092    * 
2093    * "crc"
2094    * Compute the cyclic redundancy check (CRC) specified
2095    * by POSIX for the "cksum" command.
2096    * 
2097    * "md5"
2098    * Compute the MD5 hash (using the "md5sum" program).
2099    * 
2100    * "sha1"
2101    * Compute the SHA1 hash (using the "sha1sum" program).
2102    * 
2103    * "sha224"
2104    * Compute the SHA224 hash (using the "sha224sum"
2105    * program).
2106    * 
2107    * "sha256"
2108    * Compute the SHA256 hash (using the "sha256sum"
2109    * program).
2110    * 
2111    * "sha384"
2112    * Compute the SHA384 hash (using the "sha384sum"
2113    * program).
2114    * 
2115    * "sha512"
2116    * Compute the SHA512 hash (using the "sha512sum"
2117    * program).
2118    * 
2119    * The checksum is returned as a printable string.
2120    * 
2121    * @throws LibGuestFSException
2122    */
2123   public String checksum (String csumtype, String path)
2124     throws LibGuestFSException
2125   {
2126     if (g == 0)
2127       throw new LibGuestFSException ("checksum: handle is closed");
2128     return _checksum (g, csumtype, path);
2129   }
2130   private native String _checksum (long g, String csumtype, String path)
2131     throws LibGuestFSException;
2132
2133   /**
2134    * unpack tarfile to directory
2135    *
2136    * This command uploads and unpacks local file "tarfile"
2137    * (an *uncompressed* tar file) into "directory".
2138    * 
2139    * To upload a compressed tarball, use "g.tgz_in".
2140    * 
2141    * @throws LibGuestFSException
2142    */
2143   public void tar_in (String tarfile, String directory)
2144     throws LibGuestFSException
2145   {
2146     if (g == 0)
2147       throw new LibGuestFSException ("tar_in: handle is closed");
2148     _tar_in (g, tarfile, directory);
2149   }
2150   private native void _tar_in (long g, String tarfile, String directory)
2151     throws LibGuestFSException;
2152
2153   /**
2154    * pack directory into tarfile
2155    *
2156    * This command packs the contents of "directory" and
2157    * downloads it to local file "tarfile".
2158    * 
2159    * To download a compressed tarball, use "g.tgz_out".
2160    * 
2161    * @throws LibGuestFSException
2162    */
2163   public void tar_out (String directory, String tarfile)
2164     throws LibGuestFSException
2165   {
2166     if (g == 0)
2167       throw new LibGuestFSException ("tar_out: handle is closed");
2168     _tar_out (g, directory, tarfile);
2169   }
2170   private native void _tar_out (long g, String directory, String tarfile)
2171     throws LibGuestFSException;
2172
2173   /**
2174    * unpack compressed tarball to directory
2175    *
2176    * This command uploads and unpacks local file "tarball" (a
2177    * *gzip compressed* tar file) into "directory".
2178    * 
2179    * To upload an uncompressed tarball, use "g.tar_in".
2180    * 
2181    * @throws LibGuestFSException
2182    */
2183   public void tgz_in (String tarball, String directory)
2184     throws LibGuestFSException
2185   {
2186     if (g == 0)
2187       throw new LibGuestFSException ("tgz_in: handle is closed");
2188     _tgz_in (g, tarball, directory);
2189   }
2190   private native void _tgz_in (long g, String tarball, String directory)
2191     throws LibGuestFSException;
2192
2193   /**
2194    * pack directory into compressed tarball
2195    *
2196    * This command packs the contents of "directory" and
2197    * downloads it to local file "tarball".
2198    * 
2199    * To download an uncompressed tarball, use "g.tar_out".
2200    * 
2201    * @throws LibGuestFSException
2202    */
2203   public void tgz_out (String directory, String tarball)
2204     throws LibGuestFSException
2205   {
2206     if (g == 0)
2207       throw new LibGuestFSException ("tgz_out: handle is closed");
2208     _tgz_out (g, directory, tarball);
2209   }
2210   private native void _tgz_out (long g, String directory, String tarball)
2211     throws LibGuestFSException;
2212
2213   /**
2214    * mount a guest disk, read-only
2215    *
2216    * This is the same as the "g.mount" command, but it mounts
2217    * the filesystem with the read-only (*-o ro*) flag.
2218    * 
2219    * @throws LibGuestFSException
2220    */
2221   public void mount_ro (String device, String mountpoint)
2222     throws LibGuestFSException
2223   {
2224     if (g == 0)
2225       throw new LibGuestFSException ("mount_ro: handle is closed");
2226     _mount_ro (g, device, mountpoint);
2227   }
2228   private native void _mount_ro (long g, String device, String mountpoint)
2229     throws LibGuestFSException;
2230
2231   /**
2232    * mount a guest disk with mount options
2233    *
2234    * This is the same as the "g.mount" command, but it allows
2235    * you to set the mount options as for the mount(8) *-o*
2236    * flag.
2237    * 
2238    * @throws LibGuestFSException
2239    */
2240   public void mount_options (String options, String device, String mountpoint)
2241     throws LibGuestFSException
2242   {
2243     if (g == 0)
2244       throw new LibGuestFSException ("mount_options: handle is closed");
2245     _mount_options (g, options, device, mountpoint);
2246   }
2247   private native void _mount_options (long g, String options, String device, String mountpoint)
2248     throws LibGuestFSException;
2249
2250   /**
2251    * mount a guest disk with mount options and vfstype
2252    *
2253    * This is the same as the "g.mount" command, but it allows
2254    * you to set both the mount options and the vfstype as for
2255    * the mount(8) *-o* and *-t* flags.
2256    * 
2257    * @throws LibGuestFSException
2258    */
2259   public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2260     throws LibGuestFSException
2261   {
2262     if (g == 0)
2263       throw new LibGuestFSException ("mount_vfs: handle is closed");
2264     _mount_vfs (g, options, vfstype, device, mountpoint);
2265   }
2266   private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2267     throws LibGuestFSException;
2268
2269   /**
2270    * debugging and internals
2271    *
2272    * The "g.debug" command exposes some internals of
2273    * "guestfsd" (the guestfs daemon) that runs inside the
2274    * qemu subprocess.
2275    * 
2276    * There is no comprehensive help for this command. You
2277    * have to look at the file "daemon/debug.c" in the
2278    * libguestfs source to find out what you can do.
2279    * 
2280    * @throws LibGuestFSException
2281    */
2282   public String debug (String subcmd, String[] extraargs)
2283     throws LibGuestFSException
2284   {
2285     if (g == 0)
2286       throw new LibGuestFSException ("debug: handle is closed");
2287     return _debug (g, subcmd, extraargs);
2288   }
2289   private native String _debug (long g, String subcmd, String[] extraargs)
2290     throws LibGuestFSException;
2291
2292   /**
2293    * remove an LVM logical volume
2294    *
2295    * Remove an LVM logical volume "device", where "device" is
2296    * the path to the LV, such as "/dev/VG/LV".
2297    * 
2298    * You can also remove all LVs in a volume group by
2299    * specifying the VG name, "/dev/VG".
2300    * 
2301    * @throws LibGuestFSException
2302    */
2303   public void lvremove (String device)
2304     throws LibGuestFSException
2305   {
2306     if (g == 0)
2307       throw new LibGuestFSException ("lvremove: handle is closed");
2308     _lvremove (g, device);
2309   }
2310   private native void _lvremove (long g, String device)
2311     throws LibGuestFSException;
2312
2313   /**
2314    * remove an LVM volume group
2315    *
2316    * Remove an LVM volume group "vgname", (for example "VG").
2317    * 
2318    * This also forcibly removes all logical volumes in the
2319    * volume group (if any).
2320    * 
2321    * @throws LibGuestFSException
2322    */
2323   public void vgremove (String vgname)
2324     throws LibGuestFSException
2325   {
2326     if (g == 0)
2327       throw new LibGuestFSException ("vgremove: handle is closed");
2328     _vgremove (g, vgname);
2329   }
2330   private native void _vgremove (long g, String vgname)
2331     throws LibGuestFSException;
2332
2333   /**
2334    * remove an LVM physical volume
2335    *
2336    * This wipes a physical volume "device" so that LVM will
2337    * no longer recognise it.
2338    * 
2339    * The implementation uses the "pvremove" command which
2340    * refuses to wipe physical volumes that contain any volume
2341    * groups, so you have to remove those first.
2342    * 
2343    * @throws LibGuestFSException
2344    */
2345   public void pvremove (String device)
2346     throws LibGuestFSException
2347   {
2348     if (g == 0)
2349       throw new LibGuestFSException ("pvremove: handle is closed");
2350     _pvremove (g, device);
2351   }
2352   private native void _pvremove (long g, String device)
2353     throws LibGuestFSException;
2354
2355   /**
2356    * set the ext2/3/4 filesystem label
2357    *
2358    * This sets the ext2/3/4 filesystem label of the
2359    * filesystem on "device" to "label". Filesystem labels are
2360    * limited to 16 characters.
2361    * 
2362    * You can use either "g.tune2fs_l" or "g.get_e2label" to
2363    * return the existing label on a filesystem.
2364    * 
2365    * @throws LibGuestFSException
2366    */
2367   public void set_e2label (String device, String label)
2368     throws LibGuestFSException
2369   {
2370     if (g == 0)
2371       throw new LibGuestFSException ("set_e2label: handle is closed");
2372     _set_e2label (g, device, label);
2373   }
2374   private native void _set_e2label (long g, String device, String label)
2375     throws LibGuestFSException;
2376
2377   /**
2378    * get the ext2/3/4 filesystem label
2379    *
2380    * This returns the ext2/3/4 filesystem label of the
2381    * filesystem on "device".
2382    * 
2383    * @throws LibGuestFSException
2384    */
2385   public String get_e2label (String device)
2386     throws LibGuestFSException
2387   {
2388     if (g == 0)
2389       throw new LibGuestFSException ("get_e2label: handle is closed");
2390     return _get_e2label (g, device);
2391   }
2392   private native String _get_e2label (long g, String device)
2393     throws LibGuestFSException;
2394
2395   /**
2396    * set the ext2/3/4 filesystem UUID
2397    *
2398    * This sets the ext2/3/4 filesystem UUID of the filesystem
2399    * on "device" to "uuid". The format of the UUID and
2400    * alternatives such as "clear", "random" and "time" are
2401    * described in the tune2fs(8) manpage.
2402    * 
2403    * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2404    * return the existing UUID of a filesystem.
2405    * 
2406    * @throws LibGuestFSException
2407    */
2408   public void set_e2uuid (String device, String uuid)
2409     throws LibGuestFSException
2410   {
2411     if (g == 0)
2412       throw new LibGuestFSException ("set_e2uuid: handle is closed");
2413     _set_e2uuid (g, device, uuid);
2414   }
2415   private native void _set_e2uuid (long g, String device, String uuid)
2416     throws LibGuestFSException;
2417
2418   /**
2419    * get the ext2/3/4 filesystem UUID
2420    *
2421    * This returns the ext2/3/4 filesystem UUID of the
2422    * filesystem on "device".
2423    * 
2424    * @throws LibGuestFSException
2425    */
2426   public String get_e2uuid (String device)
2427     throws LibGuestFSException
2428   {
2429     if (g == 0)
2430       throw new LibGuestFSException ("get_e2uuid: handle is closed");
2431     return _get_e2uuid (g, device);
2432   }
2433   private native String _get_e2uuid (long g, String device)
2434     throws LibGuestFSException;
2435
2436   /**
2437    * run the filesystem checker
2438    *
2439    * This runs the filesystem checker (fsck) on "device"
2440    * which should have filesystem type "fstype".
2441    * 
2442    * The returned integer is the status. See fsck(8) for the
2443    * list of status codes from "fsck".
2444    * 
2445    * Notes:
2446    * 
2447    * *   Multiple status codes can be summed together.
2448    * 
2449    * *   A non-zero return code can mean "success", for
2450    * example if errors have been corrected on the
2451    * filesystem.
2452    * 
2453    * *   Checking or repairing NTFS volumes is not supported
2454    * (by linux-ntfs).
2455    * 
2456    * This command is entirely equivalent to running "fsck -a
2457    * -t fstype device".
2458    * 
2459    * @throws LibGuestFSException
2460    */
2461   public int fsck (String fstype, String device)
2462     throws LibGuestFSException
2463   {
2464     if (g == 0)
2465       throw new LibGuestFSException ("fsck: handle is closed");
2466     return _fsck (g, fstype, device);
2467   }
2468   private native int _fsck (long g, String fstype, String device)
2469     throws LibGuestFSException;
2470
2471   /**
2472    * write zeroes to the device
2473    *
2474    * This command writes zeroes over the first few blocks of
2475    * "device".
2476    * 
2477    * How many blocks are zeroed isn't specified (but it's
2478    * *not* enough to securely wipe the device). It should be
2479    * sufficient to remove any partition tables, filesystem
2480    * superblocks and so on.
2481    * 
2482    * @throws LibGuestFSException
2483    */
2484   public void zero (String device)
2485     throws LibGuestFSException
2486   {
2487     if (g == 0)
2488       throw new LibGuestFSException ("zero: handle is closed");
2489     _zero (g, device);
2490   }
2491   private native void _zero (long g, String device)
2492     throws LibGuestFSException;
2493
2494   /**
2495    * install GRUB
2496    *
2497    * This command installs GRUB (the Grand Unified
2498    * Bootloader) on "device", with the root directory being
2499    * "root".
2500    * 
2501    * @throws LibGuestFSException
2502    */
2503   public void grub_install (String root, String device)
2504     throws LibGuestFSException
2505   {
2506     if (g == 0)
2507       throw new LibGuestFSException ("grub_install: handle is closed");
2508     _grub_install (g, root, device);
2509   }
2510   private native void _grub_install (long g, String root, String device)
2511     throws LibGuestFSException;
2512
2513   /**
2514    * copy a file
2515    *
2516    * This copies a file from "src" to "dest" where "dest" is
2517    * either a destination filename or destination directory.
2518    * 
2519    * @throws LibGuestFSException
2520    */
2521   public void cp (String src, String dest)
2522     throws LibGuestFSException
2523   {
2524     if (g == 0)
2525       throw new LibGuestFSException ("cp: handle is closed");
2526     _cp (g, src, dest);
2527   }
2528   private native void _cp (long g, String src, String dest)
2529     throws LibGuestFSException;
2530
2531   /**
2532    * copy a file or directory recursively
2533    *
2534    * This copies a file or directory from "src" to "dest"
2535    * recursively using the "cp -a" command.
2536    * 
2537    * @throws LibGuestFSException
2538    */
2539   public void cp_a (String src, String dest)
2540     throws LibGuestFSException
2541   {
2542     if (g == 0)
2543       throw new LibGuestFSException ("cp_a: handle is closed");
2544     _cp_a (g, src, dest);
2545   }
2546   private native void _cp_a (long g, String src, String dest)
2547     throws LibGuestFSException;
2548
2549   /**
2550    * move a file
2551    *
2552    * This moves a file from "src" to "dest" where "dest" is
2553    * either a destination filename or destination directory.
2554    * 
2555    * @throws LibGuestFSException
2556    */
2557   public void mv (String src, String dest)
2558     throws LibGuestFSException
2559   {
2560     if (g == 0)
2561       throw new LibGuestFSException ("mv: handle is closed");
2562     _mv (g, src, dest);
2563   }
2564   private native void _mv (long g, String src, String dest)
2565     throws LibGuestFSException;
2566
2567   /**
2568    * drop kernel page cache, dentries and inodes
2569    *
2570    * This instructs the guest kernel to drop its page cache,
2571    * and/or dentries and inode caches. The parameter
2572    * "whattodrop" tells the kernel what precisely to drop,
2573    * see <http://linux-mm.org/Drop_Caches>
2574    * 
2575    * Setting "whattodrop" to 3 should drop everything.
2576    * 
2577    * This automatically calls sync(2) before the operation,
2578    * so that the maximum guest memory is freed.
2579    * 
2580    * @throws LibGuestFSException
2581    */
2582   public void drop_caches (int whattodrop)
2583     throws LibGuestFSException
2584   {
2585     if (g == 0)
2586       throw new LibGuestFSException ("drop_caches: handle is closed");
2587     _drop_caches (g, whattodrop);
2588   }
2589   private native void _drop_caches (long g, int whattodrop)
2590     throws LibGuestFSException;
2591
2592   /**
2593    * return kernel messages
2594    *
2595    * This returns the kernel messages ("dmesg" output) from
2596    * the guest kernel. This is sometimes useful for extended
2597    * debugging of problems.
2598    * 
2599    * Another way to get the same information is to enable
2600    * verbose messages with "g.set_verbose" or by setting the
2601    * environment variable "LIBGUESTFS_DEBUG=1" before running
2602    * the program.
2603    * 
2604    * @throws LibGuestFSException
2605    */
2606   public String dmesg ()
2607     throws LibGuestFSException
2608   {
2609     if (g == 0)
2610       throw new LibGuestFSException ("dmesg: handle is closed");
2611     return _dmesg (g);
2612   }
2613   private native String _dmesg (long g)
2614     throws LibGuestFSException;
2615
2616   /**
2617    * ping the guest daemon
2618    *
2619    * This is a test probe into the guestfs daemon running
2620    * inside the qemu subprocess. Calling this function checks
2621    * that the daemon responds to the ping message, without
2622    * affecting the daemon or attached block device(s) in any
2623    * other way.
2624    * 
2625    * @throws LibGuestFSException
2626    */
2627   public void ping_daemon ()
2628     throws LibGuestFSException
2629   {
2630     if (g == 0)
2631       throw new LibGuestFSException ("ping_daemon: handle is closed");
2632     _ping_daemon (g);
2633   }
2634   private native void _ping_daemon (long g)
2635     throws LibGuestFSException;
2636
2637   /**
2638    * test if two files have equal contents
2639    *
2640    * This compares the two files "file1" and "file2" and
2641    * returns true if their content is exactly equal, or false
2642    * otherwise.
2643    * 
2644    * The external cmp(1) program is used for the comparison.
2645    * 
2646    * @throws LibGuestFSException
2647    */
2648   public boolean equal (String file1, String file2)
2649     throws LibGuestFSException
2650   {
2651     if (g == 0)
2652       throw new LibGuestFSException ("equal: handle is closed");
2653     return _equal (g, file1, file2);
2654   }
2655   private native boolean _equal (long g, String file1, String file2)
2656     throws LibGuestFSException;
2657
2658   /**
2659    * print the printable strings in a file
2660    *
2661    * This runs the strings(1) command on a file and returns
2662    * the list of printable strings found.
2663    * 
2664    * Because of the message protocol, there is a transfer
2665    * limit of somewhere between 2MB and 4MB. To transfer
2666    * large files you should use FTP.
2667    * 
2668    * @throws LibGuestFSException
2669    */
2670   public String[] strings (String path)
2671     throws LibGuestFSException
2672   {
2673     if (g == 0)
2674       throw new LibGuestFSException ("strings: handle is closed");
2675     return _strings (g, path);
2676   }
2677   private native String[] _strings (long g, String path)
2678     throws LibGuestFSException;
2679
2680   /**
2681    * print the printable strings in a file
2682    *
2683    * This is like the "g.strings" command, but allows you to
2684    * specify the encoding.
2685    * 
2686    * See the strings(1) manpage for the full list of
2687    * encodings.
2688    * 
2689    * Commonly useful encodings are "l" (lower case L) which
2690    * will show strings inside Windows/x86 files.
2691    * 
2692    * The returned strings are transcoded to UTF-8.
2693    * 
2694    * Because of the message protocol, there is a transfer
2695    * limit of somewhere between 2MB and 4MB. To transfer
2696    * large files you should use FTP.
2697    * 
2698    * @throws LibGuestFSException
2699    */
2700   public String[] strings_e (String encoding, String path)
2701     throws LibGuestFSException
2702   {
2703     if (g == 0)
2704       throw new LibGuestFSException ("strings_e: handle is closed");
2705     return _strings_e (g, encoding, path);
2706   }
2707   private native String[] _strings_e (long g, String encoding, String path)
2708     throws LibGuestFSException;
2709
2710   /**
2711    * dump a file in hexadecimal
2712    *
2713    * This runs "hexdump -C" on the given "path". The result
2714    * is the human-readable, canonical hex dump of the file.
2715    * 
2716    * Because of the message protocol, there is a transfer
2717    * limit of somewhere between 2MB and 4MB. To transfer
2718    * large files you should use FTP.
2719    * 
2720    * @throws LibGuestFSException
2721    */
2722   public String hexdump (String path)
2723     throws LibGuestFSException
2724   {
2725     if (g == 0)
2726       throw new LibGuestFSException ("hexdump: handle is closed");
2727     return _hexdump (g, path);
2728   }
2729   private native String _hexdump (long g, String path)
2730     throws LibGuestFSException;
2731
2732 }