Generated code for 'find' command.
[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    * See also: "g.sfdisk_l", "g.sfdisk_N"
1522    * 
1523    * This command is dangerous. Without careful use you can
1524    * easily destroy all your data.
1525    * 
1526    * @throws LibGuestFSException
1527    */
1528   public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1529     throws LibGuestFSException
1530   {
1531     if (g == 0)
1532       throw new LibGuestFSException ("sfdisk: handle is closed");
1533     _sfdisk (g, device, cyls, heads, sectors, lines);
1534   }
1535   private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1536     throws LibGuestFSException;
1537
1538   /**
1539    * create a file
1540    *
1541    * This call creates a file called "path". The contents of
1542    * the file is the string "content" (which can contain any
1543    * 8 bit data), with length "size".
1544    * 
1545    * As a special case, if "size" is 0 then the length is
1546    * calculated using "strlen" (so in this case the content
1547    * cannot contain embedded ASCII NULs).
1548    * 
1549    * *NB.* Owing to a bug, writing content containing ASCII
1550    * NUL characters does *not* work, even if the length is
1551    * specified. We hope to resolve this bug in a future
1552    * version. In the meantime use "g.upload".
1553    * 
1554    * Because of the message protocol, there is a transfer
1555    * limit of somewhere between 2MB and 4MB. To transfer
1556    * large files you should use FTP.
1557    * 
1558    * @throws LibGuestFSException
1559    */
1560   public void write_file (String path, String content, int size)
1561     throws LibGuestFSException
1562   {
1563     if (g == 0)
1564       throw new LibGuestFSException ("write_file: handle is closed");
1565     _write_file (g, path, content, size);
1566   }
1567   private native void _write_file (long g, String path, String content, int size)
1568     throws LibGuestFSException;
1569
1570   /**
1571    * unmount a filesystem
1572    *
1573    * This unmounts the given filesystem. The filesystem may
1574    * be specified either by its mountpoint (path) or the
1575    * device which contains the filesystem.
1576    * 
1577    * @throws LibGuestFSException
1578    */
1579   public void umount (String pathordevice)
1580     throws LibGuestFSException
1581   {
1582     if (g == 0)
1583       throw new LibGuestFSException ("umount: handle is closed");
1584     _umount (g, pathordevice);
1585   }
1586   private native void _umount (long g, String pathordevice)
1587     throws LibGuestFSException;
1588
1589   /**
1590    * show mounted filesystems
1591    *
1592    * This returns the list of currently mounted filesystems.
1593    * It returns the list of devices (eg. "/dev/sda1",
1594    * "/dev/VG/LV").
1595    * 
1596    * Some internal mounts are not shown.
1597    * 
1598    * @throws LibGuestFSException
1599    */
1600   public String[] mounts ()
1601     throws LibGuestFSException
1602   {
1603     if (g == 0)
1604       throw new LibGuestFSException ("mounts: handle is closed");
1605     return _mounts (g);
1606   }
1607   private native String[] _mounts (long g)
1608     throws LibGuestFSException;
1609
1610   /**
1611    * unmount all filesystems
1612    *
1613    * This unmounts all mounted filesystems.
1614    * 
1615    * Some internal mounts are not unmounted by this call.
1616    * 
1617    * @throws LibGuestFSException
1618    */
1619   public void umount_all ()
1620     throws LibGuestFSException
1621   {
1622     if (g == 0)
1623       throw new LibGuestFSException ("umount_all: handle is closed");
1624     _umount_all (g);
1625   }
1626   private native void _umount_all (long g)
1627     throws LibGuestFSException;
1628
1629   /**
1630    * remove all LVM LVs, VGs and PVs
1631    *
1632    * This command removes all LVM logical volumes, volume
1633    * groups and physical volumes.
1634    * 
1635    * This command is dangerous. Without careful use you can
1636    * easily destroy all your data.
1637    * 
1638    * @throws LibGuestFSException
1639    */
1640   public void lvm_remove_all ()
1641     throws LibGuestFSException
1642   {
1643     if (g == 0)
1644       throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1645     _lvm_remove_all (g);
1646   }
1647   private native void _lvm_remove_all (long g)
1648     throws LibGuestFSException;
1649
1650   /**
1651    * determine file type
1652    *
1653    * This call uses the standard file(1) command to determine
1654    * the type or contents of the file. This also works on
1655    * devices, for example to find out whether a partition
1656    * contains a filesystem.
1657    * 
1658    * The exact command which runs is "file -bsL path". Note
1659    * in particular that the filename is not prepended to the
1660    * output (the "-b" option).
1661    * 
1662    * @throws LibGuestFSException
1663    */
1664   public String file (String path)
1665     throws LibGuestFSException
1666   {
1667     if (g == 0)
1668       throw new LibGuestFSException ("file: handle is closed");
1669     return _file (g, path);
1670   }
1671   private native String _file (long g, String path)
1672     throws LibGuestFSException;
1673
1674   /**
1675    * run a command from the guest filesystem
1676    *
1677    * This call runs a command from the guest filesystem. The
1678    * filesystem must be mounted, and must contain a
1679    * compatible operating system (ie. something Linux, with
1680    * the same or compatible processor architecture).
1681    * 
1682    * The single parameter is an argv-style list of arguments.
1683    * The first element is the name of the program to run.
1684    * Subsequent elements are parameters. The list must be
1685    * non-empty (ie. must contain a program name).
1686    * 
1687    * The return value is anything printed to *stdout* by the
1688    * command.
1689    * 
1690    * If the command returns a non-zero exit status, then this
1691    * function returns an error message. The error message
1692    * string is the content of *stderr* from the command.
1693    * 
1694    * The $PATH environment variable will contain at least
1695    * "/usr/bin" and "/bin". If you require a program from
1696    * another location, you should provide the full path in
1697    * the first parameter.
1698    * 
1699    * Shared libraries and data files required by the program
1700    * must be available on filesystems which are mounted in
1701    * the correct places. It is the caller's responsibility to
1702    * ensure all filesystems that are needed are mounted at
1703    * the right locations.
1704    * 
1705    * Because of the message protocol, there is a transfer
1706    * limit of somewhere between 2MB and 4MB. To transfer
1707    * large files you should use FTP.
1708    * 
1709    * @throws LibGuestFSException
1710    */
1711   public String command (String[] arguments)
1712     throws LibGuestFSException
1713   {
1714     if (g == 0)
1715       throw new LibGuestFSException ("command: handle is closed");
1716     return _command (g, arguments);
1717   }
1718   private native String _command (long g, String[] arguments)
1719     throws LibGuestFSException;
1720
1721   /**
1722    * run a command, returning lines
1723    *
1724    * This is the same as "g.command", but splits the result
1725    * into a list of lines.
1726    * 
1727    * Because of the message protocol, there is a transfer
1728    * limit of somewhere between 2MB and 4MB. To transfer
1729    * large files you should use FTP.
1730    * 
1731    * @throws LibGuestFSException
1732    */
1733   public String[] command_lines (String[] arguments)
1734     throws LibGuestFSException
1735   {
1736     if (g == 0)
1737       throw new LibGuestFSException ("command_lines: handle is closed");
1738     return _command_lines (g, arguments);
1739   }
1740   private native String[] _command_lines (long g, String[] arguments)
1741     throws LibGuestFSException;
1742
1743   /**
1744    * get file information
1745    *
1746    * Returns file information for the given "path".
1747    * 
1748    * This is the same as the stat(2) system call.
1749    * 
1750    * @throws LibGuestFSException
1751    */
1752   public Stat stat (String path)
1753     throws LibGuestFSException
1754   {
1755     if (g == 0)
1756       throw new LibGuestFSException ("stat: handle is closed");
1757     return _stat (g, path);
1758   }
1759   private native Stat _stat (long g, String path)
1760     throws LibGuestFSException;
1761
1762   /**
1763    * get file information for a symbolic link
1764    *
1765    * Returns file information for the given "path".
1766    * 
1767    * This is the same as "g.stat" except that if "path" is a
1768    * symbolic link, then the link is stat-ed, not the file it
1769    * refers to.
1770    * 
1771    * This is the same as the lstat(2) system call.
1772    * 
1773    * @throws LibGuestFSException
1774    */
1775   public Stat lstat (String path)
1776     throws LibGuestFSException
1777   {
1778     if (g == 0)
1779       throw new LibGuestFSException ("lstat: handle is closed");
1780     return _lstat (g, path);
1781   }
1782   private native Stat _lstat (long g, String path)
1783     throws LibGuestFSException;
1784
1785   /**
1786    * get file system statistics
1787    *
1788    * Returns file system statistics for any mounted file
1789    * system. "path" should be a file or directory in the
1790    * mounted file system (typically it is the mount point
1791    * itself, but it doesn't need to be).
1792    * 
1793    * This is the same as the statvfs(2) system call.
1794    * 
1795    * @throws LibGuestFSException
1796    */
1797   public StatVFS statvfs (String path)
1798     throws LibGuestFSException
1799   {
1800     if (g == 0)
1801       throw new LibGuestFSException ("statvfs: handle is closed");
1802     return _statvfs (g, path);
1803   }
1804   private native StatVFS _statvfs (long g, String path)
1805     throws LibGuestFSException;
1806
1807   /**
1808    * get ext2/ext3/ext4 superblock details
1809    *
1810    * This returns the contents of the ext2, ext3 or ext4
1811    * filesystem superblock on "device".
1812    * 
1813    * It is the same as running "tune2fs -l device". See
1814    * tune2fs(8) manpage for more details. The list of fields
1815    * returned isn't clearly defined, and depends on both the
1816    * version of "tune2fs" that libguestfs was built against,
1817    * and the filesystem itself.
1818    * 
1819    * @throws LibGuestFSException
1820    */
1821   public HashMap<String,String> tune2fs_l (String device)
1822     throws LibGuestFSException
1823   {
1824     if (g == 0)
1825       throw new LibGuestFSException ("tune2fs_l: handle is closed");
1826     return _tune2fs_l (g, device);
1827   }
1828   private native HashMap<String,String> _tune2fs_l (long g, String device)
1829     throws LibGuestFSException;
1830
1831   /**
1832    * set block device to read-only
1833    *
1834    * Sets the block device named "device" to read-only.
1835    * 
1836    * This uses the blockdev(8) command.
1837    * 
1838    * @throws LibGuestFSException
1839    */
1840   public void blockdev_setro (String device)
1841     throws LibGuestFSException
1842   {
1843     if (g == 0)
1844       throw new LibGuestFSException ("blockdev_setro: handle is closed");
1845     _blockdev_setro (g, device);
1846   }
1847   private native void _blockdev_setro (long g, String device)
1848     throws LibGuestFSException;
1849
1850   /**
1851    * set block device to read-write
1852    *
1853    * Sets the block device named "device" to read-write.
1854    * 
1855    * This uses the blockdev(8) command.
1856    * 
1857    * @throws LibGuestFSException
1858    */
1859   public void blockdev_setrw (String device)
1860     throws LibGuestFSException
1861   {
1862     if (g == 0)
1863       throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1864     _blockdev_setrw (g, device);
1865   }
1866   private native void _blockdev_setrw (long g, String device)
1867     throws LibGuestFSException;
1868
1869   /**
1870    * is block device set to read-only
1871    *
1872    * Returns a boolean indicating if the block device is
1873    * read-only (true if read-only, false if not).
1874    * 
1875    * This uses the blockdev(8) command.
1876    * 
1877    * @throws LibGuestFSException
1878    */
1879   public boolean blockdev_getro (String device)
1880     throws LibGuestFSException
1881   {
1882     if (g == 0)
1883       throw new LibGuestFSException ("blockdev_getro: handle is closed");
1884     return _blockdev_getro (g, device);
1885   }
1886   private native boolean _blockdev_getro (long g, String device)
1887     throws LibGuestFSException;
1888
1889   /**
1890    * get sectorsize of block device
1891    *
1892    * This returns the size of sectors on a block device.
1893    * Usually 512, but can be larger for modern devices.
1894    * 
1895    * (Note, this is not the size in sectors, use
1896    * "g.blockdev_getsz" for that).
1897    * 
1898    * This uses the blockdev(8) command.
1899    * 
1900    * @throws LibGuestFSException
1901    */
1902   public int blockdev_getss (String device)
1903     throws LibGuestFSException
1904   {
1905     if (g == 0)
1906       throw new LibGuestFSException ("blockdev_getss: handle is closed");
1907     return _blockdev_getss (g, device);
1908   }
1909   private native int _blockdev_getss (long g, String device)
1910     throws LibGuestFSException;
1911
1912   /**
1913    * get blocksize of block device
1914    *
1915    * This returns the block size of a device.
1916    * 
1917    * (Note this is different from both *size in blocks* and
1918    * *filesystem block size*).
1919    * 
1920    * This uses the blockdev(8) command.
1921    * 
1922    * @throws LibGuestFSException
1923    */
1924   public int blockdev_getbsz (String device)
1925     throws LibGuestFSException
1926   {
1927     if (g == 0)
1928       throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1929     return _blockdev_getbsz (g, device);
1930   }
1931   private native int _blockdev_getbsz (long g, String device)
1932     throws LibGuestFSException;
1933
1934   /**
1935    * set blocksize of block device
1936    *
1937    * This sets the block size of a device.
1938    * 
1939    * (Note this is different from both *size in blocks* and
1940    * *filesystem block size*).
1941    * 
1942    * This uses the blockdev(8) command.
1943    * 
1944    * @throws LibGuestFSException
1945    */
1946   public void blockdev_setbsz (String device, int blocksize)
1947     throws LibGuestFSException
1948   {
1949     if (g == 0)
1950       throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1951     _blockdev_setbsz (g, device, blocksize);
1952   }
1953   private native void _blockdev_setbsz (long g, String device, int blocksize)
1954     throws LibGuestFSException;
1955
1956   /**
1957    * get total size of device in 512-byte sectors
1958    *
1959    * This returns the size of the device in units of 512-byte
1960    * sectors (even if the sectorsize isn't 512 bytes ...
1961    * weird).
1962    * 
1963    * See also "g.blockdev_getss" for the real sector size of
1964    * the device, and "g.blockdev_getsize64" for the more
1965    * useful *size in bytes*.
1966    * 
1967    * This uses the blockdev(8) command.
1968    * 
1969    * @throws LibGuestFSException
1970    */
1971   public long blockdev_getsz (String device)
1972     throws LibGuestFSException
1973   {
1974     if (g == 0)
1975       throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1976     return _blockdev_getsz (g, device);
1977   }
1978   private native long _blockdev_getsz (long g, String device)
1979     throws LibGuestFSException;
1980
1981   /**
1982    * get total size of device in bytes
1983    *
1984    * This returns the size of the device in bytes.
1985    * 
1986    * See also "g.blockdev_getsz".
1987    * 
1988    * This uses the blockdev(8) command.
1989    * 
1990    * @throws LibGuestFSException
1991    */
1992   public long blockdev_getsize64 (String device)
1993     throws LibGuestFSException
1994   {
1995     if (g == 0)
1996       throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1997     return _blockdev_getsize64 (g, device);
1998   }
1999   private native long _blockdev_getsize64 (long g, String device)
2000     throws LibGuestFSException;
2001
2002   /**
2003    * flush device buffers
2004    *
2005    * This tells the kernel to flush internal buffers
2006    * associated with "device".
2007    * 
2008    * This uses the blockdev(8) command.
2009    * 
2010    * @throws LibGuestFSException
2011    */
2012   public void blockdev_flushbufs (String device)
2013     throws LibGuestFSException
2014   {
2015     if (g == 0)
2016       throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2017     _blockdev_flushbufs (g, device);
2018   }
2019   private native void _blockdev_flushbufs (long g, String device)
2020     throws LibGuestFSException;
2021
2022   /**
2023    * reread partition table
2024    *
2025    * Reread the partition table on "device".
2026    * 
2027    * This uses the blockdev(8) command.
2028    * 
2029    * @throws LibGuestFSException
2030    */
2031   public void blockdev_rereadpt (String device)
2032     throws LibGuestFSException
2033   {
2034     if (g == 0)
2035       throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2036     _blockdev_rereadpt (g, device);
2037   }
2038   private native void _blockdev_rereadpt (long g, String device)
2039     throws LibGuestFSException;
2040
2041   /**
2042    * upload a file from the local machine
2043    *
2044    * Upload local file "filename" to "remotefilename" on the
2045    * filesystem.
2046    * 
2047    * "filename" can also be a named pipe.
2048    * 
2049    * See also "g.download".
2050    * 
2051    * @throws LibGuestFSException
2052    */
2053   public void upload (String filename, String remotefilename)
2054     throws LibGuestFSException
2055   {
2056     if (g == 0)
2057       throw new LibGuestFSException ("upload: handle is closed");
2058     _upload (g, filename, remotefilename);
2059   }
2060   private native void _upload (long g, String filename, String remotefilename)
2061     throws LibGuestFSException;
2062
2063   /**
2064    * download a file to the local machine
2065    *
2066    * Download file "remotefilename" and save it as "filename"
2067    * on the local machine.
2068    * 
2069    * "filename" can also be a named pipe.
2070    * 
2071    * See also "g.upload", "g.cat".
2072    * 
2073    * @throws LibGuestFSException
2074    */
2075   public void download (String remotefilename, String filename)
2076     throws LibGuestFSException
2077   {
2078     if (g == 0)
2079       throw new LibGuestFSException ("download: handle is closed");
2080     _download (g, remotefilename, filename);
2081   }
2082   private native void _download (long g, String remotefilename, String filename)
2083     throws LibGuestFSException;
2084
2085   /**
2086    * compute MD5, SHAx or CRC checksum of file
2087    *
2088    * This call computes the MD5, SHAx or CRC checksum of the
2089    * file named "path".
2090    * 
2091    * The type of checksum to compute is given by the
2092    * "csumtype" parameter which must have one of the
2093    * following values:
2094    * 
2095    * "crc"
2096    * Compute the cyclic redundancy check (CRC) specified
2097    * by POSIX for the "cksum" command.
2098    * 
2099    * "md5"
2100    * Compute the MD5 hash (using the "md5sum" program).
2101    * 
2102    * "sha1"
2103    * Compute the SHA1 hash (using the "sha1sum" program).
2104    * 
2105    * "sha224"
2106    * Compute the SHA224 hash (using the "sha224sum"
2107    * program).
2108    * 
2109    * "sha256"
2110    * Compute the SHA256 hash (using the "sha256sum"
2111    * program).
2112    * 
2113    * "sha384"
2114    * Compute the SHA384 hash (using the "sha384sum"
2115    * program).
2116    * 
2117    * "sha512"
2118    * Compute the SHA512 hash (using the "sha512sum"
2119    * program).
2120    * 
2121    * The checksum is returned as a printable string.
2122    * 
2123    * @throws LibGuestFSException
2124    */
2125   public String checksum (String csumtype, String path)
2126     throws LibGuestFSException
2127   {
2128     if (g == 0)
2129       throw new LibGuestFSException ("checksum: handle is closed");
2130     return _checksum (g, csumtype, path);
2131   }
2132   private native String _checksum (long g, String csumtype, String path)
2133     throws LibGuestFSException;
2134
2135   /**
2136    * unpack tarfile to directory
2137    *
2138    * This command uploads and unpacks local file "tarfile"
2139    * (an *uncompressed* tar file) into "directory".
2140    * 
2141    * To upload a compressed tarball, use "g.tgz_in".
2142    * 
2143    * @throws LibGuestFSException
2144    */
2145   public void tar_in (String tarfile, String directory)
2146     throws LibGuestFSException
2147   {
2148     if (g == 0)
2149       throw new LibGuestFSException ("tar_in: handle is closed");
2150     _tar_in (g, tarfile, directory);
2151   }
2152   private native void _tar_in (long g, String tarfile, String directory)
2153     throws LibGuestFSException;
2154
2155   /**
2156    * pack directory into tarfile
2157    *
2158    * This command packs the contents of "directory" and
2159    * downloads it to local file "tarfile".
2160    * 
2161    * To download a compressed tarball, use "g.tgz_out".
2162    * 
2163    * @throws LibGuestFSException
2164    */
2165   public void tar_out (String directory, String tarfile)
2166     throws LibGuestFSException
2167   {
2168     if (g == 0)
2169       throw new LibGuestFSException ("tar_out: handle is closed");
2170     _tar_out (g, directory, tarfile);
2171   }
2172   private native void _tar_out (long g, String directory, String tarfile)
2173     throws LibGuestFSException;
2174
2175   /**
2176    * unpack compressed tarball to directory
2177    *
2178    * This command uploads and unpacks local file "tarball" (a
2179    * *gzip compressed* tar file) into "directory".
2180    * 
2181    * To upload an uncompressed tarball, use "g.tar_in".
2182    * 
2183    * @throws LibGuestFSException
2184    */
2185   public void tgz_in (String tarball, String directory)
2186     throws LibGuestFSException
2187   {
2188     if (g == 0)
2189       throw new LibGuestFSException ("tgz_in: handle is closed");
2190     _tgz_in (g, tarball, directory);
2191   }
2192   private native void _tgz_in (long g, String tarball, String directory)
2193     throws LibGuestFSException;
2194
2195   /**
2196    * pack directory into compressed tarball
2197    *
2198    * This command packs the contents of "directory" and
2199    * downloads it to local file "tarball".
2200    * 
2201    * To download an uncompressed tarball, use "g.tar_out".
2202    * 
2203    * @throws LibGuestFSException
2204    */
2205   public void tgz_out (String directory, String tarball)
2206     throws LibGuestFSException
2207   {
2208     if (g == 0)
2209       throw new LibGuestFSException ("tgz_out: handle is closed");
2210     _tgz_out (g, directory, tarball);
2211   }
2212   private native void _tgz_out (long g, String directory, String tarball)
2213     throws LibGuestFSException;
2214
2215   /**
2216    * mount a guest disk, read-only
2217    *
2218    * This is the same as the "g.mount" command, but it mounts
2219    * the filesystem with the read-only (*-o ro*) flag.
2220    * 
2221    * @throws LibGuestFSException
2222    */
2223   public void mount_ro (String device, String mountpoint)
2224     throws LibGuestFSException
2225   {
2226     if (g == 0)
2227       throw new LibGuestFSException ("mount_ro: handle is closed");
2228     _mount_ro (g, device, mountpoint);
2229   }
2230   private native void _mount_ro (long g, String device, String mountpoint)
2231     throws LibGuestFSException;
2232
2233   /**
2234    * mount a guest disk with mount options
2235    *
2236    * This is the same as the "g.mount" command, but it allows
2237    * you to set the mount options as for the mount(8) *-o*
2238    * flag.
2239    * 
2240    * @throws LibGuestFSException
2241    */
2242   public void mount_options (String options, String device, String mountpoint)
2243     throws LibGuestFSException
2244   {
2245     if (g == 0)
2246       throw new LibGuestFSException ("mount_options: handle is closed");
2247     _mount_options (g, options, device, mountpoint);
2248   }
2249   private native void _mount_options (long g, String options, String device, String mountpoint)
2250     throws LibGuestFSException;
2251
2252   /**
2253    * mount a guest disk with mount options and vfstype
2254    *
2255    * This is the same as the "g.mount" command, but it allows
2256    * you to set both the mount options and the vfstype as for
2257    * the mount(8) *-o* and *-t* flags.
2258    * 
2259    * @throws LibGuestFSException
2260    */
2261   public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2262     throws LibGuestFSException
2263   {
2264     if (g == 0)
2265       throw new LibGuestFSException ("mount_vfs: handle is closed");
2266     _mount_vfs (g, options, vfstype, device, mountpoint);
2267   }
2268   private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2269     throws LibGuestFSException;
2270
2271   /**
2272    * debugging and internals
2273    *
2274    * The "g.debug" command exposes some internals of
2275    * "guestfsd" (the guestfs daemon) that runs inside the
2276    * qemu subprocess.
2277    * 
2278    * There is no comprehensive help for this command. You
2279    * have to look at the file "daemon/debug.c" in the
2280    * libguestfs source to find out what you can do.
2281    * 
2282    * @throws LibGuestFSException
2283    */
2284   public String debug (String subcmd, String[] extraargs)
2285     throws LibGuestFSException
2286   {
2287     if (g == 0)
2288       throw new LibGuestFSException ("debug: handle is closed");
2289     return _debug (g, subcmd, extraargs);
2290   }
2291   private native String _debug (long g, String subcmd, String[] extraargs)
2292     throws LibGuestFSException;
2293
2294   /**
2295    * remove an LVM logical volume
2296    *
2297    * Remove an LVM logical volume "device", where "device" is
2298    * the path to the LV, such as "/dev/VG/LV".
2299    * 
2300    * You can also remove all LVs in a volume group by
2301    * specifying the VG name, "/dev/VG".
2302    * 
2303    * @throws LibGuestFSException
2304    */
2305   public void lvremove (String device)
2306     throws LibGuestFSException
2307   {
2308     if (g == 0)
2309       throw new LibGuestFSException ("lvremove: handle is closed");
2310     _lvremove (g, device);
2311   }
2312   private native void _lvremove (long g, String device)
2313     throws LibGuestFSException;
2314
2315   /**
2316    * remove an LVM volume group
2317    *
2318    * Remove an LVM volume group "vgname", (for example "VG").
2319    * 
2320    * This also forcibly removes all logical volumes in the
2321    * volume group (if any).
2322    * 
2323    * @throws LibGuestFSException
2324    */
2325   public void vgremove (String vgname)
2326     throws LibGuestFSException
2327   {
2328     if (g == 0)
2329       throw new LibGuestFSException ("vgremove: handle is closed");
2330     _vgremove (g, vgname);
2331   }
2332   private native void _vgremove (long g, String vgname)
2333     throws LibGuestFSException;
2334
2335   /**
2336    * remove an LVM physical volume
2337    *
2338    * This wipes a physical volume "device" so that LVM will
2339    * no longer recognise it.
2340    * 
2341    * The implementation uses the "pvremove" command which
2342    * refuses to wipe physical volumes that contain any volume
2343    * groups, so you have to remove those first.
2344    * 
2345    * @throws LibGuestFSException
2346    */
2347   public void pvremove (String device)
2348     throws LibGuestFSException
2349   {
2350     if (g == 0)
2351       throw new LibGuestFSException ("pvremove: handle is closed");
2352     _pvremove (g, device);
2353   }
2354   private native void _pvremove (long g, String device)
2355     throws LibGuestFSException;
2356
2357   /**
2358    * set the ext2/3/4 filesystem label
2359    *
2360    * This sets the ext2/3/4 filesystem label of the
2361    * filesystem on "device" to "label". Filesystem labels are
2362    * limited to 16 characters.
2363    * 
2364    * You can use either "g.tune2fs_l" or "g.get_e2label" to
2365    * return the existing label on a filesystem.
2366    * 
2367    * @throws LibGuestFSException
2368    */
2369   public void set_e2label (String device, String label)
2370     throws LibGuestFSException
2371   {
2372     if (g == 0)
2373       throw new LibGuestFSException ("set_e2label: handle is closed");
2374     _set_e2label (g, device, label);
2375   }
2376   private native void _set_e2label (long g, String device, String label)
2377     throws LibGuestFSException;
2378
2379   /**
2380    * get the ext2/3/4 filesystem label
2381    *
2382    * This returns the ext2/3/4 filesystem label of the
2383    * filesystem on "device".
2384    * 
2385    * @throws LibGuestFSException
2386    */
2387   public String get_e2label (String device)
2388     throws LibGuestFSException
2389   {
2390     if (g == 0)
2391       throw new LibGuestFSException ("get_e2label: handle is closed");
2392     return _get_e2label (g, device);
2393   }
2394   private native String _get_e2label (long g, String device)
2395     throws LibGuestFSException;
2396
2397   /**
2398    * set the ext2/3/4 filesystem UUID
2399    *
2400    * This sets the ext2/3/4 filesystem UUID of the filesystem
2401    * on "device" to "uuid". The format of the UUID and
2402    * alternatives such as "clear", "random" and "time" are
2403    * described in the tune2fs(8) manpage.
2404    * 
2405    * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2406    * return the existing UUID of a filesystem.
2407    * 
2408    * @throws LibGuestFSException
2409    */
2410   public void set_e2uuid (String device, String uuid)
2411     throws LibGuestFSException
2412   {
2413     if (g == 0)
2414       throw new LibGuestFSException ("set_e2uuid: handle is closed");
2415     _set_e2uuid (g, device, uuid);
2416   }
2417   private native void _set_e2uuid (long g, String device, String uuid)
2418     throws LibGuestFSException;
2419
2420   /**
2421    * get the ext2/3/4 filesystem UUID
2422    *
2423    * This returns the ext2/3/4 filesystem UUID of the
2424    * filesystem on "device".
2425    * 
2426    * @throws LibGuestFSException
2427    */
2428   public String get_e2uuid (String device)
2429     throws LibGuestFSException
2430   {
2431     if (g == 0)
2432       throw new LibGuestFSException ("get_e2uuid: handle is closed");
2433     return _get_e2uuid (g, device);
2434   }
2435   private native String _get_e2uuid (long g, String device)
2436     throws LibGuestFSException;
2437
2438   /**
2439    * run the filesystem checker
2440    *
2441    * This runs the filesystem checker (fsck) on "device"
2442    * which should have filesystem type "fstype".
2443    * 
2444    * The returned integer is the status. See fsck(8) for the
2445    * list of status codes from "fsck".
2446    * 
2447    * Notes:
2448    * 
2449    * *   Multiple status codes can be summed together.
2450    * 
2451    * *   A non-zero return code can mean "success", for
2452    * example if errors have been corrected on the
2453    * filesystem.
2454    * 
2455    * *   Checking or repairing NTFS volumes is not supported
2456    * (by linux-ntfs).
2457    * 
2458    * This command is entirely equivalent to running "fsck -a
2459    * -t fstype device".
2460    * 
2461    * @throws LibGuestFSException
2462    */
2463   public int fsck (String fstype, String device)
2464     throws LibGuestFSException
2465   {
2466     if (g == 0)
2467       throw new LibGuestFSException ("fsck: handle is closed");
2468     return _fsck (g, fstype, device);
2469   }
2470   private native int _fsck (long g, String fstype, String device)
2471     throws LibGuestFSException;
2472
2473   /**
2474    * write zeroes to the device
2475    *
2476    * This command writes zeroes over the first few blocks of
2477    * "device".
2478    * 
2479    * How many blocks are zeroed isn't specified (but it's
2480    * *not* enough to securely wipe the device). It should be
2481    * sufficient to remove any partition tables, filesystem
2482    * superblocks and so on.
2483    * 
2484    * @throws LibGuestFSException
2485    */
2486   public void zero (String device)
2487     throws LibGuestFSException
2488   {
2489     if (g == 0)
2490       throw new LibGuestFSException ("zero: handle is closed");
2491     _zero (g, device);
2492   }
2493   private native void _zero (long g, String device)
2494     throws LibGuestFSException;
2495
2496   /**
2497    * install GRUB
2498    *
2499    * This command installs GRUB (the Grand Unified
2500    * Bootloader) on "device", with the root directory being
2501    * "root".
2502    * 
2503    * @throws LibGuestFSException
2504    */
2505   public void grub_install (String root, String device)
2506     throws LibGuestFSException
2507   {
2508     if (g == 0)
2509       throw new LibGuestFSException ("grub_install: handle is closed");
2510     _grub_install (g, root, device);
2511   }
2512   private native void _grub_install (long g, String root, String device)
2513     throws LibGuestFSException;
2514
2515   /**
2516    * copy a file
2517    *
2518    * This copies a file from "src" to "dest" where "dest" is
2519    * either a destination filename or destination directory.
2520    * 
2521    * @throws LibGuestFSException
2522    */
2523   public void cp (String src, String dest)
2524     throws LibGuestFSException
2525   {
2526     if (g == 0)
2527       throw new LibGuestFSException ("cp: handle is closed");
2528     _cp (g, src, dest);
2529   }
2530   private native void _cp (long g, String src, String dest)
2531     throws LibGuestFSException;
2532
2533   /**
2534    * copy a file or directory recursively
2535    *
2536    * This copies a file or directory from "src" to "dest"
2537    * recursively using the "cp -a" command.
2538    * 
2539    * @throws LibGuestFSException
2540    */
2541   public void cp_a (String src, String dest)
2542     throws LibGuestFSException
2543   {
2544     if (g == 0)
2545       throw new LibGuestFSException ("cp_a: handle is closed");
2546     _cp_a (g, src, dest);
2547   }
2548   private native void _cp_a (long g, String src, String dest)
2549     throws LibGuestFSException;
2550
2551   /**
2552    * move a file
2553    *
2554    * This moves a file from "src" to "dest" where "dest" is
2555    * either a destination filename or destination directory.
2556    * 
2557    * @throws LibGuestFSException
2558    */
2559   public void mv (String src, String dest)
2560     throws LibGuestFSException
2561   {
2562     if (g == 0)
2563       throw new LibGuestFSException ("mv: handle is closed");
2564     _mv (g, src, dest);
2565   }
2566   private native void _mv (long g, String src, String dest)
2567     throws LibGuestFSException;
2568
2569   /**
2570    * drop kernel page cache, dentries and inodes
2571    *
2572    * This instructs the guest kernel to drop its page cache,
2573    * and/or dentries and inode caches. The parameter
2574    * "whattodrop" tells the kernel what precisely to drop,
2575    * see <http://linux-mm.org/Drop_Caches>
2576    * 
2577    * Setting "whattodrop" to 3 should drop everything.
2578    * 
2579    * This automatically calls sync(2) before the operation,
2580    * so that the maximum guest memory is freed.
2581    * 
2582    * @throws LibGuestFSException
2583    */
2584   public void drop_caches (int whattodrop)
2585     throws LibGuestFSException
2586   {
2587     if (g == 0)
2588       throw new LibGuestFSException ("drop_caches: handle is closed");
2589     _drop_caches (g, whattodrop);
2590   }
2591   private native void _drop_caches (long g, int whattodrop)
2592     throws LibGuestFSException;
2593
2594   /**
2595    * return kernel messages
2596    *
2597    * This returns the kernel messages ("dmesg" output) from
2598    * the guest kernel. This is sometimes useful for extended
2599    * debugging of problems.
2600    * 
2601    * Another way to get the same information is to enable
2602    * verbose messages with "g.set_verbose" or by setting the
2603    * environment variable "LIBGUESTFS_DEBUG=1" before running
2604    * the program.
2605    * 
2606    * @throws LibGuestFSException
2607    */
2608   public String dmesg ()
2609     throws LibGuestFSException
2610   {
2611     if (g == 0)
2612       throw new LibGuestFSException ("dmesg: handle is closed");
2613     return _dmesg (g);
2614   }
2615   private native String _dmesg (long g)
2616     throws LibGuestFSException;
2617
2618   /**
2619    * ping the guest daemon
2620    *
2621    * This is a test probe into the guestfs daemon running
2622    * inside the qemu subprocess. Calling this function checks
2623    * that the daemon responds to the ping message, without
2624    * affecting the daemon or attached block device(s) in any
2625    * other way.
2626    * 
2627    * @throws LibGuestFSException
2628    */
2629   public void ping_daemon ()
2630     throws LibGuestFSException
2631   {
2632     if (g == 0)
2633       throw new LibGuestFSException ("ping_daemon: handle is closed");
2634     _ping_daemon (g);
2635   }
2636   private native void _ping_daemon (long g)
2637     throws LibGuestFSException;
2638
2639   /**
2640    * test if two files have equal contents
2641    *
2642    * This compares the two files "file1" and "file2" and
2643    * returns true if their content is exactly equal, or false
2644    * otherwise.
2645    * 
2646    * The external cmp(1) program is used for the comparison.
2647    * 
2648    * @throws LibGuestFSException
2649    */
2650   public boolean equal (String file1, String file2)
2651     throws LibGuestFSException
2652   {
2653     if (g == 0)
2654       throw new LibGuestFSException ("equal: handle is closed");
2655     return _equal (g, file1, file2);
2656   }
2657   private native boolean _equal (long g, String file1, String file2)
2658     throws LibGuestFSException;
2659
2660   /**
2661    * print the printable strings in a file
2662    *
2663    * This runs the strings(1) command on a file and returns
2664    * the list of printable strings found.
2665    * 
2666    * Because of the message protocol, there is a transfer
2667    * limit of somewhere between 2MB and 4MB. To transfer
2668    * large files you should use FTP.
2669    * 
2670    * @throws LibGuestFSException
2671    */
2672   public String[] strings (String path)
2673     throws LibGuestFSException
2674   {
2675     if (g == 0)
2676       throw new LibGuestFSException ("strings: handle is closed");
2677     return _strings (g, path);
2678   }
2679   private native String[] _strings (long g, String path)
2680     throws LibGuestFSException;
2681
2682   /**
2683    * print the printable strings in a file
2684    *
2685    * This is like the "g.strings" command, but allows you to
2686    * specify the encoding.
2687    * 
2688    * See the strings(1) manpage for the full list of
2689    * encodings.
2690    * 
2691    * Commonly useful encodings are "l" (lower case L) which
2692    * will show strings inside Windows/x86 files.
2693    * 
2694    * The returned strings are transcoded to UTF-8.
2695    * 
2696    * Because of the message protocol, there is a transfer
2697    * limit of somewhere between 2MB and 4MB. To transfer
2698    * large files you should use FTP.
2699    * 
2700    * @throws LibGuestFSException
2701    */
2702   public String[] strings_e (String encoding, String path)
2703     throws LibGuestFSException
2704   {
2705     if (g == 0)
2706       throw new LibGuestFSException ("strings_e: handle is closed");
2707     return _strings_e (g, encoding, path);
2708   }
2709   private native String[] _strings_e (long g, String encoding, String path)
2710     throws LibGuestFSException;
2711
2712   /**
2713    * dump a file in hexadecimal
2714    *
2715    * This runs "hexdump -C" on the given "path". The result
2716    * is the human-readable, canonical hex dump of the file.
2717    * 
2718    * Because of the message protocol, there is a transfer
2719    * limit of somewhere between 2MB and 4MB. To transfer
2720    * large files you should use FTP.
2721    * 
2722    * @throws LibGuestFSException
2723    */
2724   public String hexdump (String path)
2725     throws LibGuestFSException
2726   {
2727     if (g == 0)
2728       throw new LibGuestFSException ("hexdump: handle is closed");
2729     return _hexdump (g, path);
2730   }
2731   private native String _hexdump (long g, String path)
2732     throws LibGuestFSException;
2733
2734   /**
2735    * zero unused inodes and disk blocks on ext2/3 filesystem
2736    *
2737    * This runs the *zerofree* program on "device". This
2738    * program claims to zero unused inodes and disk blocks on
2739    * an ext2/3 filesystem, thus making it possible to
2740    * compress the filesystem more effectively.
2741    * 
2742    * You should not run this program if the filesystem is
2743    * mounted.
2744    * 
2745    * It is possible that using this program can damage the
2746    * filesystem or data on the filesystem.
2747    * 
2748    * @throws LibGuestFSException
2749    */
2750   public void zerofree (String device)
2751     throws LibGuestFSException
2752   {
2753     if (g == 0)
2754       throw new LibGuestFSException ("zerofree: handle is closed");
2755     _zerofree (g, device);
2756   }
2757   private native void _zerofree (long g, String device)
2758     throws LibGuestFSException;
2759
2760   /**
2761    * resize an LVM physical volume
2762    *
2763    * This resizes (expands or shrinks) an existing LVM
2764    * physical volume to match the new size of the underlying
2765    * device.
2766    * 
2767    * @throws LibGuestFSException
2768    */
2769   public void pvresize (String device)
2770     throws LibGuestFSException
2771   {
2772     if (g == 0)
2773       throw new LibGuestFSException ("pvresize: handle is closed");
2774     _pvresize (g, device);
2775   }
2776   private native void _pvresize (long g, String device)
2777     throws LibGuestFSException;
2778
2779   /**
2780    * modify a single partition on a block device
2781    *
2782    * This runs sfdisk(8) option to modify just the single
2783    * partition "n" (note: "n" counts from 1).
2784    * 
2785    * For other parameters, see "g.sfdisk". You should usually
2786    * pass 0 for the cyls/heads/sectors parameters.
2787    * 
2788    * This command is dangerous. Without careful use you can
2789    * easily destroy all your data.
2790    * 
2791    * @throws LibGuestFSException
2792    */
2793   public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
2794     throws LibGuestFSException
2795   {
2796     if (g == 0)
2797       throw new LibGuestFSException ("sfdisk_N: handle is closed");
2798     _sfdisk_N (g, device, n, cyls, heads, sectors, line);
2799   }
2800   private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
2801     throws LibGuestFSException;
2802
2803   /**
2804    * display the partition table
2805    *
2806    * This displays the partition table on "device", in the
2807    * human-readable output of the sfdisk(8) command. It is
2808    * not intended to be parsed.
2809    * 
2810    * @throws LibGuestFSException
2811    */
2812   public String sfdisk_l (String device)
2813     throws LibGuestFSException
2814   {
2815     if (g == 0)
2816       throw new LibGuestFSException ("sfdisk_l: handle is closed");
2817     return _sfdisk_l (g, device);
2818   }
2819   private native String _sfdisk_l (long g, String device)
2820     throws LibGuestFSException;
2821
2822   /**
2823    * display the kernel geometry
2824    *
2825    * This displays the kernel's idea of the geometry of
2826    * "device".
2827    * 
2828    * The result is in human-readable format, and not designed
2829    * to be parsed.
2830    * 
2831    * @throws LibGuestFSException
2832    */
2833   public String sfdisk_kernel_geometry (String device)
2834     throws LibGuestFSException
2835   {
2836     if (g == 0)
2837       throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
2838     return _sfdisk_kernel_geometry (g, device);
2839   }
2840   private native String _sfdisk_kernel_geometry (long g, String device)
2841     throws LibGuestFSException;
2842
2843   /**
2844    * display the disk geometry from the partition table
2845    *
2846    * This displays the disk geometry of "device" read from
2847    * the partition table. Especially in the case where the
2848    * underlying block device has been resized, this can be
2849    * different from the kernel's idea of the geometry (see
2850    * "g.sfdisk_kernel_geometry").
2851    * 
2852    * The result is in human-readable format, and not designed
2853    * to be parsed.
2854    * 
2855    * @throws LibGuestFSException
2856    */
2857   public String sfdisk_disk_geometry (String device)
2858     throws LibGuestFSException
2859   {
2860     if (g == 0)
2861       throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
2862     return _sfdisk_disk_geometry (g, device);
2863   }
2864   private native String _sfdisk_disk_geometry (long g, String device)
2865     throws LibGuestFSException;
2866
2867   /**
2868    * activate or deactivate all volume groups
2869    *
2870    * This command activates or (if "activate" is false)
2871    * deactivates all logical volumes in all volume groups. If
2872    * activated, then they are made known to the kernel, ie.
2873    * they appear as "/dev/mapper" devices. If deactivated,
2874    * then those devices disappear.
2875    * 
2876    * This command is the same as running "vgchange -a y|n"
2877    * 
2878    * @throws LibGuestFSException
2879    */
2880   public void vg_activate_all (boolean activate)
2881     throws LibGuestFSException
2882   {
2883     if (g == 0)
2884       throw new LibGuestFSException ("vg_activate_all: handle is closed");
2885     _vg_activate_all (g, activate);
2886   }
2887   private native void _vg_activate_all (long g, boolean activate)
2888     throws LibGuestFSException;
2889
2890   /**
2891    * activate or deactivate some volume groups
2892    *
2893    * This command activates or (if "activate" is false)
2894    * deactivates all logical volumes in the listed volume
2895    * groups "volgroups". If activated, then they are made
2896    * known to the kernel, ie. they appear as "/dev/mapper"
2897    * devices. If deactivated, then those devices disappear.
2898    * 
2899    * This command is the same as running "vgchange -a y|n
2900    * volgroups..."
2901    * 
2902    * Note that if "volgroups" is an empty list then all
2903    * volume groups are activated or deactivated.
2904    * 
2905    * @throws LibGuestFSException
2906    */
2907   public void vg_activate (boolean activate, String[] volgroups)
2908     throws LibGuestFSException
2909   {
2910     if (g == 0)
2911       throw new LibGuestFSException ("vg_activate: handle is closed");
2912     _vg_activate (g, activate, volgroups);
2913   }
2914   private native void _vg_activate (long g, boolean activate, String[] volgroups)
2915     throws LibGuestFSException;
2916
2917   /**
2918    * resize an LVM logical volume
2919    *
2920    * This resizes (expands or shrinks) an existing LVM
2921    * logical volume to "mbytes". When reducing, data in the
2922    * reduced part is lost.
2923    * 
2924    * @throws LibGuestFSException
2925    */
2926   public void lvresize (String device, int mbytes)
2927     throws LibGuestFSException
2928   {
2929     if (g == 0)
2930       throw new LibGuestFSException ("lvresize: handle is closed");
2931     _lvresize (g, device, mbytes);
2932   }
2933   private native void _lvresize (long g, String device, int mbytes)
2934     throws LibGuestFSException;
2935
2936   /**
2937    * resize an ext2/ext3 filesystem
2938    *
2939    * This resizes an ext2 or ext3 filesystem to match the
2940    * size of the underlying device.
2941    * 
2942    * @throws LibGuestFSException
2943    */
2944   public void resize2fs (String device)
2945     throws LibGuestFSException
2946   {
2947     if (g == 0)
2948       throw new LibGuestFSException ("resize2fs: handle is closed");
2949     _resize2fs (g, device);
2950   }
2951   private native void _resize2fs (long g, String device)
2952     throws LibGuestFSException;
2953
2954   /**
2955    * find all files and directories
2956    *
2957    * This command lists out all files and directories,
2958    * recursively, starting at "directory". It is essentially
2959    * equivalent to running the shell command "find directory
2960    * -print" but some post-processing happens on the output,
2961    * described below.
2962    * 
2963    * This returns a list of strings *without any prefix*.
2964    * Thus if the directory structure was:
2965    * 
2966    * /tmp/a
2967    * /tmp/b
2968    * /tmp/c/d
2969    * 
2970    * then the returned list from "g.find" "/tmp" would be 4
2971    * elements:
2972    * 
2973    * a
2974    * b
2975    * c
2976    * c/d
2977    * 
2978    * If "directory" is not a directory, then this command
2979    * returns an error.
2980    * 
2981    * The returned list is sorted.
2982    * 
2983    * @throws LibGuestFSException
2984    */
2985   public String[] find (String directory)
2986     throws LibGuestFSException
2987   {
2988     if (g == 0)
2989       throw new LibGuestFSException ("find: handle is closed");
2990     return _find (g, directory);
2991   }
2992   private native String[] _find (long g, String directory)
2993     throws LibGuestFSException;
2994
2995 }