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