119a2df1d6dc232f68b88c396142405dba411ce7
[libguestfs.git] / java / com / redhat / et / libguestfs / GuestFS.java
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 package com.redhat.et.libguestfs;
23
24 import java.util.HashMap;
25 import com.redhat.et.libguestfs.LibGuestFSException;
26 import com.redhat.et.libguestfs.PV;
27 import com.redhat.et.libguestfs.VG;
28 import com.redhat.et.libguestfs.LV;
29 import com.redhat.et.libguestfs.Stat;
30 import com.redhat.et.libguestfs.StatVFS;
31 import com.redhat.et.libguestfs.IntBool;
32
33 /**
34  * The GuestFS object is a libguestfs handle.
35  *
36  * @author rjones
37  */
38 public class GuestFS {
39   // Load the native code.
40   static {
41     System.loadLibrary ("guestfs_jni");
42   }
43
44   /**
45    * The native guestfs_h pointer.
46    */
47   long g;
48
49   /**
50    * Create a libguestfs handle.
51    *
52    * @throws LibGuestFSException
53    */
54   public GuestFS () throws LibGuestFSException
55   {
56     g = _create ();
57   }
58   private native long _create () throws LibGuestFSException;
59
60   /**
61    * Close a libguestfs handle.
62    *
63    * You can also leave handles to be collected by the garbage
64    * collector, but this method ensures that the resources used
65    * by the handle are freed up immediately.  If you call any
66    * other methods after closing the handle, you will get an
67    * exception.
68    *
69    * @throws LibGuestFSException
70    */
71   public void close () throws LibGuestFSException
72   {
73     if (g != 0)
74       _close (g);
75     g = 0;
76   }
77   private native void _close (long g) throws LibGuestFSException;
78
79   public void finalize () throws LibGuestFSException
80   {
81     close ();
82   }
83
84   /**
85    * launch the qemu subprocess
86    *
87    * Internally libguestfs is implemented by running a
88    * virtual machine using qemu(1).
89    * 
90    * You should call this after configuring the handle (eg.
91    * adding drives) but before performing any actions.
92    * 
93    * @throws LibGuestFSException
94    */
95   public void launch ()
96     throws LibGuestFSException
97   {
98     if (g == 0)
99       throw new LibGuestFSException ("launch: handle is closed");
100     _launch (g);
101   }
102   private native void _launch (long g)
103     throws LibGuestFSException;
104
105   /**
106    * wait until the qemu subprocess launches
107    *
108    * Internally libguestfs is implemented by running a
109    * virtual machine using qemu(1).
110    * 
111    * You should call this after "g.launch" to wait for the
112    * launch to complete.
113    * 
114    * @throws LibGuestFSException
115    */
116   public void wait_ready ()
117     throws LibGuestFSException
118   {
119     if (g == 0)
120       throw new LibGuestFSException ("wait_ready: handle is closed");
121     _wait_ready (g);
122   }
123   private native void _wait_ready (long g)
124     throws LibGuestFSException;
125
126   /**
127    * kill the qemu subprocess
128    *
129    * This kills the qemu subprocess. You should never need to
130    * call this.
131    * 
132    * @throws LibGuestFSException
133    */
134   public void kill_subprocess ()
135     throws LibGuestFSException
136   {
137     if (g == 0)
138       throw new LibGuestFSException ("kill_subprocess: handle is closed");
139     _kill_subprocess (g);
140   }
141   private native void _kill_subprocess (long g)
142     throws LibGuestFSException;
143
144   /**
145    * add an image to examine or modify
146    *
147    * This function adds a virtual machine disk image
148    * "filename" to the guest. The first time you call this
149    * function, the disk appears as IDE disk 0 ("/dev/sda") in
150    * the guest, the second time as "/dev/sdb", and so on.
151    * 
152    * You don't necessarily need to be root when using
153    * libguestfs. However you obviously do need sufficient
154    * permissions to access the filename for whatever
155    * operations you want to perform (ie. read access if you
156    * just want to read the image or write access if you want
157    * to modify the image).
158    * 
159    * This is equivalent to the qemu parameter "-drive
160    * file=filename".
161    * 
162    * @throws LibGuestFSException
163    */
164   public void add_drive (String filename)
165     throws LibGuestFSException
166   {
167     if (g == 0)
168       throw new LibGuestFSException ("add_drive: handle is closed");
169     _add_drive (g, filename);
170   }
171   private native void _add_drive (long g, String filename)
172     throws LibGuestFSException;
173
174   /**
175    * add a CD-ROM disk image to examine
176    *
177    * This function adds a virtual CD-ROM disk image to the
178    * guest.
179    * 
180    * This is equivalent to the qemu parameter "-cdrom
181    * filename".
182    * 
183    * @throws LibGuestFSException
184    */
185   public void add_cdrom (String filename)
186     throws LibGuestFSException
187   {
188     if (g == 0)
189       throw new LibGuestFSException ("add_cdrom: handle is closed");
190     _add_cdrom (g, filename);
191   }
192   private native void _add_cdrom (long g, String filename)
193     throws LibGuestFSException;
194
195   /**
196    * add qemu parameters
197    *
198    * This can be used to add arbitrary qemu command line
199    * parameters of the form "-param value". Actually it's not
200    * quite arbitrary - we prevent you from setting some
201    * parameters which would interfere with parameters that we
202    * use.
203    * 
204    * The first character of "param" string must be a "-"
205    * (dash).
206    * 
207    * "value" can be NULL.
208    * 
209    * @throws LibGuestFSException
210    */
211   public void config (String qemuparam, String qemuvalue)
212     throws LibGuestFSException
213   {
214     if (g == 0)
215       throw new LibGuestFSException ("config: handle is closed");
216     _config (g, qemuparam, qemuvalue);
217   }
218   private native void _config (long g, String qemuparam, String qemuvalue)
219     throws LibGuestFSException;
220
221   /**
222    * set the qemu binary
223    *
224    * Set the qemu binary that we will use.
225    * 
226    * The default is chosen when the library was compiled by
227    * the configure script.
228    * 
229    * You can also override this by setting the
230    * "LIBGUESTFS_QEMU" environment variable.
231    * 
232    * The string "qemu" is stashed in the libguestfs handle,
233    * so the caller must make sure it remains valid for the
234    * lifetime of the handle.
235    * 
236    * Setting "qemu" to "NULL" restores the default qemu
237    * binary.
238    * 
239    * @throws LibGuestFSException
240    */
241   public void set_qemu (String qemu)
242     throws LibGuestFSException
243   {
244     if (g == 0)
245       throw new LibGuestFSException ("set_qemu: handle is closed");
246     _set_qemu (g, qemu);
247   }
248   private native void _set_qemu (long g, String qemu)
249     throws LibGuestFSException;
250
251   /**
252    * get the qemu binary
253    *
254    * Return the current qemu binary.
255    * 
256    * This is always non-NULL. If it wasn't set already, then
257    * this will return the default qemu binary name.
258    * 
259    * @throws LibGuestFSException
260    */
261   public String get_qemu ()
262     throws LibGuestFSException
263   {
264     if (g == 0)
265       throw new LibGuestFSException ("get_qemu: handle is closed");
266     return _get_qemu (g);
267   }
268   private native String _get_qemu (long g)
269     throws LibGuestFSException;
270
271   /**
272    * set the search path
273    *
274    * Set the path that libguestfs searches for kernel and
275    * initrd.img.
276    * 
277    * The default is "$libdir/guestfs" unless overridden by
278    * setting "LIBGUESTFS_PATH" environment variable.
279    * 
280    * The string "path" is stashed in the libguestfs handle,
281    * so the caller must make sure it remains valid for the
282    * lifetime of the handle.
283    * 
284    * Setting "path" to "NULL" restores the default path.
285    * 
286    * @throws LibGuestFSException
287    */
288   public void set_path (String path)
289     throws LibGuestFSException
290   {
291     if (g == 0)
292       throw new LibGuestFSException ("set_path: handle is closed");
293     _set_path (g, path);
294   }
295   private native void _set_path (long g, String path)
296     throws LibGuestFSException;
297
298   /**
299    * get the search path
300    *
301    * Return the current search path.
302    * 
303    * This is always non-NULL. If it wasn't set already, then
304    * this will return the default path.
305    * 
306    * @throws LibGuestFSException
307    */
308   public String get_path ()
309     throws LibGuestFSException
310   {
311     if (g == 0)
312       throw new LibGuestFSException ("get_path: handle is closed");
313     return _get_path (g);
314   }
315   private native String _get_path (long g)
316     throws LibGuestFSException;
317
318   /**
319    * set autosync mode
320    *
321    * If "autosync" is true, this enables autosync. Libguestfs
322    * will make a best effort attempt to run "g.sync" when the
323    * handle is closed (also if the program exits without
324    * closing handles).
325    * 
326    * @throws LibGuestFSException
327    */
328   public void set_autosync (boolean autosync)
329     throws LibGuestFSException
330   {
331     if (g == 0)
332       throw new LibGuestFSException ("set_autosync: handle is closed");
333     _set_autosync (g, autosync);
334   }
335   private native void _set_autosync (long g, boolean autosync)
336     throws LibGuestFSException;
337
338   /**
339    * get autosync mode
340    *
341    * Get the autosync flag.
342    * 
343    * @throws LibGuestFSException
344    */
345   public boolean get_autosync ()
346     throws LibGuestFSException
347   {
348     if (g == 0)
349       throw new LibGuestFSException ("get_autosync: handle is closed");
350     return _get_autosync (g);
351   }
352   private native boolean _get_autosync (long g)
353     throws LibGuestFSException;
354
355   /**
356    * set verbose mode
357    *
358    * If "verbose" is true, this turns on verbose messages (to
359    * "stderr").
360    * 
361    * Verbose messages are disabled unless the environment
362    * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
363    * 
364    * @throws LibGuestFSException
365    */
366   public void set_verbose (boolean verbose)
367     throws LibGuestFSException
368   {
369     if (g == 0)
370       throw new LibGuestFSException ("set_verbose: handle is closed");
371     _set_verbose (g, verbose);
372   }
373   private native void _set_verbose (long g, boolean verbose)
374     throws LibGuestFSException;
375
376   /**
377    * get verbose mode
378    *
379    * This returns the verbose messages flag.
380    * 
381    * @throws LibGuestFSException
382    */
383   public boolean get_verbose ()
384     throws LibGuestFSException
385   {
386     if (g == 0)
387       throw new LibGuestFSException ("get_verbose: handle is closed");
388     return _get_verbose (g);
389   }
390   private native boolean _get_verbose (long g)
391     throws LibGuestFSException;
392
393   /**
394    * is ready to accept commands
395    *
396    * This returns true iff this handle is ready to accept
397    * commands (in the "READY" state).
398    * 
399    * For more information on states, see guestfs(3).
400    * 
401    * @throws LibGuestFSException
402    */
403   public boolean is_ready ()
404     throws LibGuestFSException
405   {
406     if (g == 0)
407       throw new LibGuestFSException ("is_ready: handle is closed");
408     return _is_ready (g);
409   }
410   private native boolean _is_ready (long g)
411     throws LibGuestFSException;
412
413   /**
414    * is in configuration state
415    *
416    * This returns true iff this handle is being configured
417    * (in the "CONFIG" state).
418    * 
419    * For more information on states, see guestfs(3).
420    * 
421    * @throws LibGuestFSException
422    */
423   public boolean is_config ()
424     throws LibGuestFSException
425   {
426     if (g == 0)
427       throw new LibGuestFSException ("is_config: handle is closed");
428     return _is_config (g);
429   }
430   private native boolean _is_config (long g)
431     throws LibGuestFSException;
432
433   /**
434    * is launching subprocess
435    *
436    * This returns true iff this handle is launching the
437    * subprocess (in the "LAUNCHING" state).
438    * 
439    * For more information on states, see guestfs(3).
440    * 
441    * @throws LibGuestFSException
442    */
443   public boolean is_launching ()
444     throws LibGuestFSException
445   {
446     if (g == 0)
447       throw new LibGuestFSException ("is_launching: handle is closed");
448     return _is_launching (g);
449   }
450   private native boolean _is_launching (long g)
451     throws LibGuestFSException;
452
453   /**
454    * is busy processing a command
455    *
456    * This returns true iff this handle is busy processing a
457    * command (in the "BUSY" state).
458    * 
459    * For more information on states, see guestfs(3).
460    * 
461    * @throws LibGuestFSException
462    */
463   public boolean is_busy ()
464     throws LibGuestFSException
465   {
466     if (g == 0)
467       throw new LibGuestFSException ("is_busy: handle is closed");
468     return _is_busy (g);
469   }
470   private native boolean _is_busy (long g)
471     throws LibGuestFSException;
472
473   /**
474    * get the current state
475    *
476    * This returns the current state as an opaque integer.
477    * This is only useful for printing debug and internal
478    * error messages.
479    * 
480    * For more information on states, see guestfs(3).
481    * 
482    * @throws LibGuestFSException
483    */
484   public int get_state ()
485     throws LibGuestFSException
486   {
487     if (g == 0)
488       throw new LibGuestFSException ("get_state: handle is closed");
489     return _get_state (g);
490   }
491   private native int _get_state (long g)
492     throws LibGuestFSException;
493
494   /**
495    * set state to busy
496    *
497    * This sets the state to "BUSY". This is only used when
498    * implementing actions using the low-level API.
499    * 
500    * For more information on states, see guestfs(3).
501    * 
502    * @throws LibGuestFSException
503    */
504   public void set_busy ()
505     throws LibGuestFSException
506   {
507     if (g == 0)
508       throw new LibGuestFSException ("set_busy: handle is closed");
509     _set_busy (g);
510   }
511   private native void _set_busy (long g)
512     throws LibGuestFSException;
513
514   /**
515    * set state to ready
516    *
517    * This sets the state to "READY". This is only used when
518    * implementing actions using the low-level API.
519    * 
520    * For more information on states, see guestfs(3).
521    * 
522    * @throws LibGuestFSException
523    */
524   public void set_ready ()
525     throws LibGuestFSException
526   {
527     if (g == 0)
528       throw new LibGuestFSException ("set_ready: handle is closed");
529     _set_ready (g);
530   }
531   private native void _set_ready (long g)
532     throws LibGuestFSException;
533
534   /**
535    * mount a guest disk at a position in the filesystem
536    *
537    * Mount a guest disk at a position in the filesystem.
538    * Block devices are named "/dev/sda", "/dev/sdb" and so
539    * on, as they were added to the guest. If those block
540    * devices contain partitions, they will have the usual
541    * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
542    * names can be used.
543    * 
544    * The rules are the same as for mount(2): A filesystem
545    * must first be mounted on "/" before others can be
546    * mounted. Other filesystems can only be mounted on
547    * directories which already exist.
548    * 
549    * The mounted filesystem is writable, if we have
550    * sufficient permissions on the underlying device.
551    * 
552    * The filesystem options "sync" and "noatime" are set with
553    * this call, in order to improve reliability.
554    * 
555    * @throws LibGuestFSException
556    */
557   public void mount (String device, String mountpoint)
558     throws LibGuestFSException
559   {
560     if (g == 0)
561       throw new LibGuestFSException ("mount: handle is closed");
562     _mount (g, device, mountpoint);
563   }
564   private native void _mount (long g, String device, String mountpoint)
565     throws LibGuestFSException;
566
567   /**
568    * sync disks, writes are flushed through to the disk image
569    *
570    * This syncs the disk, so that any writes are flushed
571    * through to the underlying disk image.
572    * 
573    * You should always call this if you have modified a disk
574    * image, before closing the handle.
575    * 
576    * @throws LibGuestFSException
577    */
578   public void sync ()
579     throws LibGuestFSException
580   {
581     if (g == 0)
582       throw new LibGuestFSException ("sync: handle is closed");
583     _sync (g);
584   }
585   private native void _sync (long g)
586     throws LibGuestFSException;
587
588   /**
589    * update file timestamps or create a new file
590    *
591    * Touch acts like the touch(1) command. It can be used to
592    * update the timestamps on a file, or, if the file does
593    * not exist, to create a new zero-length file.
594    * 
595    * @throws LibGuestFSException
596    */
597   public void touch (String path)
598     throws LibGuestFSException
599   {
600     if (g == 0)
601       throw new LibGuestFSException ("touch: handle is closed");
602     _touch (g, path);
603   }
604   private native void _touch (long g, String path)
605     throws LibGuestFSException;
606
607   /**
608    * list the contents of a file
609    *
610    * Return the contents of the file named "path".
611    * 
612    * Note that this function cannot correctly handle binary
613    * files (specifically, files containing "\0" character
614    * which is treated as end of string). For those you need
615    * to use the "g.download" function which has a more
616    * complex interface.
617    * 
618    * Because of the message protocol, there is a transfer
619    * limit of somewhere between 2MB and 4MB. To transfer
620    * large files you should use FTP.
621    * 
622    * @throws LibGuestFSException
623    */
624   public String cat (String path)
625     throws LibGuestFSException
626   {
627     if (g == 0)
628       throw new LibGuestFSException ("cat: handle is closed");
629     return _cat (g, path);
630   }
631   private native String _cat (long g, String path)
632     throws LibGuestFSException;
633
634   /**
635    * list the files in a directory (long format)
636    *
637    * List the files in "directory" (relative to the root
638    * directory, there is no cwd) in the format of 'ls -la'.
639    * 
640    * This command is mostly useful for interactive sessions.
641    * It is *not* intended that you try to parse the output
642    * string.
643    * 
644    * @throws LibGuestFSException
645    */
646   public String ll (String directory)
647     throws LibGuestFSException
648   {
649     if (g == 0)
650       throw new LibGuestFSException ("ll: handle is closed");
651     return _ll (g, directory);
652   }
653   private native String _ll (long g, String directory)
654     throws LibGuestFSException;
655
656   /**
657    * list the files in a directory
658    *
659    * List the files in "directory" (relative to the root
660    * directory, there is no cwd). The '.' and '..' entries
661    * are not returned, but hidden files are shown.
662    * 
663    * This command is mostly useful for interactive sessions.
664    * Programs should probably use "g.readdir" instead.
665    * 
666    * @throws LibGuestFSException
667    */
668   public String[] ls (String directory)
669     throws LibGuestFSException
670   {
671     if (g == 0)
672       throw new LibGuestFSException ("ls: handle is closed");
673     return _ls (g, directory);
674   }
675   private native String[] _ls (long g, String directory)
676     throws LibGuestFSException;
677
678   /**
679    * list the block devices
680    *
681    * List all the block devices.
682    * 
683    * The full block device names are returned, eg. "/dev/sda"
684    * 
685    * @throws LibGuestFSException
686    */
687   public String[] list_devices ()
688     throws LibGuestFSException
689   {
690     if (g == 0)
691       throw new LibGuestFSException ("list_devices: handle is closed");
692     return _list_devices (g);
693   }
694   private native String[] _list_devices (long g)
695     throws LibGuestFSException;
696
697   /**
698    * list the partitions
699    *
700    * List all the partitions detected on all block devices.
701    * 
702    * The full partition device names are returned, eg.
703    * "/dev/sda1"
704    * 
705    * This does not return logical volumes. For that you will
706    * need to call "g.lvs".
707    * 
708    * @throws LibGuestFSException
709    */
710   public String[] list_partitions ()
711     throws LibGuestFSException
712   {
713     if (g == 0)
714       throw new LibGuestFSException ("list_partitions: handle is closed");
715     return _list_partitions (g);
716   }
717   private native String[] _list_partitions (long g)
718     throws LibGuestFSException;
719
720   /**
721    * list the LVM physical volumes (PVs)
722    *
723    * List all the physical volumes detected. This is the
724    * equivalent of the pvs(8) command.
725    * 
726    * This returns a list of just the device names that
727    * contain PVs (eg. "/dev/sda2").
728    * 
729    * See also "g.pvs_full".
730    * 
731    * @throws LibGuestFSException
732    */
733   public String[] pvs ()
734     throws LibGuestFSException
735   {
736     if (g == 0)
737       throw new LibGuestFSException ("pvs: handle is closed");
738     return _pvs (g);
739   }
740   private native String[] _pvs (long g)
741     throws LibGuestFSException;
742
743   /**
744    * list the LVM volume groups (VGs)
745    *
746    * List all the volumes groups detected. This is the
747    * equivalent of the vgs(8) command.
748    * 
749    * This returns a list of just the volume group names that
750    * were detected (eg. "VolGroup00").
751    * 
752    * See also "g.vgs_full".
753    * 
754    * @throws LibGuestFSException
755    */
756   public String[] vgs ()
757     throws LibGuestFSException
758   {
759     if (g == 0)
760       throw new LibGuestFSException ("vgs: handle is closed");
761     return _vgs (g);
762   }
763   private native String[] _vgs (long g)
764     throws LibGuestFSException;
765
766   /**
767    * list the LVM logical volumes (LVs)
768    *
769    * List all the logical volumes detected. This is the
770    * equivalent of the lvs(8) command.
771    * 
772    * This returns a list of the logical volume device names
773    * (eg. "/dev/VolGroup00/LogVol00").
774    * 
775    * See also "g.lvs_full".
776    * 
777    * @throws LibGuestFSException
778    */
779   public String[] lvs ()
780     throws LibGuestFSException
781   {
782     if (g == 0)
783       throw new LibGuestFSException ("lvs: handle is closed");
784     return _lvs (g);
785   }
786   private native String[] _lvs (long g)
787     throws LibGuestFSException;
788
789   /**
790    * list the LVM physical volumes (PVs)
791    *
792    * List all the physical volumes detected. This is the
793    * equivalent of the pvs(8) command. The "full" version
794    * includes all fields.
795    * 
796    * @throws LibGuestFSException
797    */
798   public PV[] pvs_full ()
799     throws LibGuestFSException
800   {
801     if (g == 0)
802       throw new LibGuestFSException ("pvs_full: handle is closed");
803     return _pvs_full (g);
804   }
805   private native PV[] _pvs_full (long g)
806     throws LibGuestFSException;
807
808   /**
809    * list the LVM volume groups (VGs)
810    *
811    * List all the volumes groups detected. This is the
812    * equivalent of the vgs(8) command. The "full" version
813    * includes all fields.
814    * 
815    * @throws LibGuestFSException
816    */
817   public VG[] vgs_full ()
818     throws LibGuestFSException
819   {
820     if (g == 0)
821       throw new LibGuestFSException ("vgs_full: handle is closed");
822     return _vgs_full (g);
823   }
824   private native VG[] _vgs_full (long g)
825     throws LibGuestFSException;
826
827   /**
828    * list the LVM logical volumes (LVs)
829    *
830    * List all the logical volumes detected. This is the
831    * equivalent of the lvs(8) command. The "full" version
832    * includes all fields.
833    * 
834    * @throws LibGuestFSException
835    */
836   public LV[] lvs_full ()
837     throws LibGuestFSException
838   {
839     if (g == 0)
840       throw new LibGuestFSException ("lvs_full: handle is closed");
841     return _lvs_full (g);
842   }
843   private native LV[] _lvs_full (long g)
844     throws LibGuestFSException;
845
846   /**
847    * read file as lines
848    *
849    * Return the contents of the file named "path".
850    * 
851    * The file contents are returned as a list of lines.
852    * Trailing "LF" and "CRLF" character sequences are *not*
853    * returned.
854    * 
855    * Note that this function cannot correctly handle binary
856    * files (specifically, files containing "\0" character
857    * which is treated as end of line). For those you need to
858    * use the "g.read_file" function which has a more complex
859    * interface.
860    * 
861    * @throws LibGuestFSException
862    */
863   public String[] read_lines (String path)
864     throws LibGuestFSException
865   {
866     if (g == 0)
867       throw new LibGuestFSException ("read_lines: handle is closed");
868     return _read_lines (g, path);
869   }
870   private native String[] _read_lines (long g, String path)
871     throws LibGuestFSException;
872
873   /**
874    * create a new Augeas handle
875    *
876    * Create a new Augeas handle for editing configuration
877    * files. If there was any previous Augeas handle
878    * associated with this guestfs session, then it is closed.
879    * 
880    * You must call this before using any other "g.aug_*"
881    * commands.
882    * 
883    * "root" is the filesystem root. "root" must not be NULL,
884    * use "/" instead.
885    * 
886    * The flags are the same as the flags defined in
887    * <augeas.h>, the logical *or* of the following integers:
888    * 
889    * "AUG_SAVE_BACKUP" = 1
890    * Keep the original file with a ".augsave" extension.
891    * 
892    * "AUG_SAVE_NEWFILE" = 2
893    * Save changes into a file with extension ".augnew",
894    * and do not overwrite original. Overrides
895    * "AUG_SAVE_BACKUP".
896    * 
897    * "AUG_TYPE_CHECK" = 4
898    * Typecheck lenses (can be expensive).
899    * 
900    * "AUG_NO_STDINC" = 8
901    * Do not use standard load path for modules.
902    * 
903    * "AUG_SAVE_NOOP" = 16
904    * Make save a no-op, just record what would have been
905    * changed.
906    * 
907    * "AUG_NO_LOAD" = 32
908    * Do not load the tree in "g.aug_init".
909    * 
910    * To close the handle, you can call "g.aug_close".
911    * 
912    * To find out more about Augeas, see <http://augeas.net/>.
913    * 
914    * @throws LibGuestFSException
915    */
916   public void aug_init (String root, int flags)
917     throws LibGuestFSException
918   {
919     if (g == 0)
920       throw new LibGuestFSException ("aug_init: handle is closed");
921     _aug_init (g, root, flags);
922   }
923   private native void _aug_init (long g, String root, int flags)
924     throws LibGuestFSException;
925
926   /**
927    * close the current Augeas handle
928    *
929    * Close the current Augeas handle and free up any
930    * resources used by it. After calling this, you have to
931    * call "g.aug_init" again before you can use any other
932    * Augeas functions.
933    * 
934    * @throws LibGuestFSException
935    */
936   public void aug_close ()
937     throws LibGuestFSException
938   {
939     if (g == 0)
940       throw new LibGuestFSException ("aug_close: handle is closed");
941     _aug_close (g);
942   }
943   private native void _aug_close (long g)
944     throws LibGuestFSException;
945
946   /**
947    * define an Augeas variable
948    *
949    * Defines an Augeas variable "name" whose value is the
950    * result of evaluating "expr". If "expr" is NULL, then
951    * "name" is undefined.
952    * 
953    * On success this returns the number of nodes in "expr",
954    * or 0 if "expr" evaluates to something which is not a
955    * nodeset.
956    * 
957    * @throws LibGuestFSException
958    */
959   public int aug_defvar (String name, String expr)
960     throws LibGuestFSException
961   {
962     if (g == 0)
963       throw new LibGuestFSException ("aug_defvar: handle is closed");
964     return _aug_defvar (g, name, expr);
965   }
966   private native int _aug_defvar (long g, String name, String expr)
967     throws LibGuestFSException;
968
969   /**
970    * define an Augeas node
971    *
972    * Defines a variable "name" whose value is the result of
973    * evaluating "expr".
974    * 
975    * If "expr" evaluates to an empty nodeset, a node is
976    * created, equivalent to calling "g.aug_set" "expr",
977    * "value". "name" will be the nodeset containing that
978    * single node.
979    * 
980    * On success this returns a pair containing the number of
981    * nodes in the nodeset, and a boolean flag if a node was
982    * created.
983    * 
984    * @throws LibGuestFSException
985    */
986   public IntBool aug_defnode (String name, String expr, String val)
987     throws LibGuestFSException
988   {
989     if (g == 0)
990       throw new LibGuestFSException ("aug_defnode: handle is closed");
991     return _aug_defnode (g, name, expr, val);
992   }
993   private native IntBool _aug_defnode (long g, String name, String expr, String val)
994     throws LibGuestFSException;
995
996   /**
997    * look up the value of an Augeas path
998    *
999    * Look up the value associated with "path". If "path"
1000    * matches exactly one node, the "value" is returned.
1001    * 
1002    * @throws LibGuestFSException
1003    */
1004   public String aug_get (String path)
1005     throws LibGuestFSException
1006   {
1007     if (g == 0)
1008       throw new LibGuestFSException ("aug_get: handle is closed");
1009     return _aug_get (g, path);
1010   }
1011   private native String _aug_get (long g, String path)
1012     throws LibGuestFSException;
1013
1014   /**
1015    * set Augeas path to value
1016    *
1017    * Set the value associated with "path" to "value".
1018    * 
1019    * @throws LibGuestFSException
1020    */
1021   public void aug_set (String path, String val)
1022     throws LibGuestFSException
1023   {
1024     if (g == 0)
1025       throw new LibGuestFSException ("aug_set: handle is closed");
1026     _aug_set (g, path, val);
1027   }
1028   private native void _aug_set (long g, String path, String val)
1029     throws LibGuestFSException;
1030
1031   /**
1032    * insert a sibling Augeas node
1033    *
1034    * Create a new sibling "label" for "path", inserting it
1035    * into the tree before or after "path" (depending on the
1036    * boolean flag "before").
1037    * 
1038    * "path" must match exactly one existing node in the tree,
1039    * and "label" must be a label, ie. not contain "/", "*" or
1040    * end with a bracketed index "[N]".
1041    * 
1042    * @throws LibGuestFSException
1043    */
1044   public void aug_insert (String path, String label, boolean before)
1045     throws LibGuestFSException
1046   {
1047     if (g == 0)
1048       throw new LibGuestFSException ("aug_insert: handle is closed");
1049     _aug_insert (g, path, label, before);
1050   }
1051   private native void _aug_insert (long g, String path, String label, boolean before)
1052     throws LibGuestFSException;
1053
1054   /**
1055    * remove an Augeas path
1056    *
1057    * Remove "path" and all of its children.
1058    * 
1059    * On success this returns the number of entries which were
1060    * removed.
1061    * 
1062    * @throws LibGuestFSException
1063    */
1064   public int aug_rm (String path)
1065     throws LibGuestFSException
1066   {
1067     if (g == 0)
1068       throw new LibGuestFSException ("aug_rm: handle is closed");
1069     return _aug_rm (g, path);
1070   }
1071   private native int _aug_rm (long g, String path)
1072     throws LibGuestFSException;
1073
1074   /**
1075    * move Augeas node
1076    *
1077    * Move the node "src" to "dest". "src" must match exactly
1078    * one node. "dest" is overwritten if it exists.
1079    * 
1080    * @throws LibGuestFSException
1081    */
1082   public void aug_mv (String src, String dest)
1083     throws LibGuestFSException
1084   {
1085     if (g == 0)
1086       throw new LibGuestFSException ("aug_mv: handle is closed");
1087     _aug_mv (g, src, dest);
1088   }
1089   private native void _aug_mv (long g, String src, String dest)
1090     throws LibGuestFSException;
1091
1092   /**
1093    * return Augeas nodes which match path
1094    *
1095    * Returns a list of paths which match the path expression
1096    * "path". The returned paths are sufficiently qualified so
1097    * that they match exactly one node in the current tree.
1098    * 
1099    * @throws LibGuestFSException
1100    */
1101   public String[] aug_match (String path)
1102     throws LibGuestFSException
1103   {
1104     if (g == 0)
1105       throw new LibGuestFSException ("aug_match: handle is closed");
1106     return _aug_match (g, path);
1107   }
1108   private native String[] _aug_match (long g, String path)
1109     throws LibGuestFSException;
1110
1111   /**
1112    * write all pending Augeas changes to disk
1113    *
1114    * This writes all pending changes to disk.
1115    * 
1116    * The flags which were passed to "g.aug_init" affect
1117    * exactly how files are saved.
1118    * 
1119    * @throws LibGuestFSException
1120    */
1121   public void aug_save ()
1122     throws LibGuestFSException
1123   {
1124     if (g == 0)
1125       throw new LibGuestFSException ("aug_save: handle is closed");
1126     _aug_save (g);
1127   }
1128   private native void _aug_save (long g)
1129     throws LibGuestFSException;
1130
1131   /**
1132    * load files into the tree
1133    *
1134    * Load files into the tree.
1135    * 
1136    * See "aug_load" in the Augeas documentation for the full
1137    * gory details.
1138    * 
1139    * @throws LibGuestFSException
1140    */
1141   public void aug_load ()
1142     throws LibGuestFSException
1143   {
1144     if (g == 0)
1145       throw new LibGuestFSException ("aug_load: handle is closed");
1146     _aug_load (g);
1147   }
1148   private native void _aug_load (long g)
1149     throws LibGuestFSException;
1150
1151   /**
1152    * list Augeas nodes under a path
1153    *
1154    * This is just a shortcut for listing "g.aug_match"
1155    * "path/*" and sorting the resulting nodes into
1156    * alphabetical order.
1157    * 
1158    * @throws LibGuestFSException
1159    */
1160   public String[] aug_ls (String path)
1161     throws LibGuestFSException
1162   {
1163     if (g == 0)
1164       throw new LibGuestFSException ("aug_ls: handle is closed");
1165     return _aug_ls (g, path);
1166   }
1167   private native String[] _aug_ls (long g, String path)
1168     throws LibGuestFSException;
1169
1170   /**
1171    * remove a file
1172    *
1173    * Remove the single file "path".
1174    * 
1175    * @throws LibGuestFSException
1176    */
1177   public void rm (String path)
1178     throws LibGuestFSException
1179   {
1180     if (g == 0)
1181       throw new LibGuestFSException ("rm: handle is closed");
1182     _rm (g, path);
1183   }
1184   private native void _rm (long g, String path)
1185     throws LibGuestFSException;
1186
1187   /**
1188    * remove a directory
1189    *
1190    * Remove the single directory "path".
1191    * 
1192    * @throws LibGuestFSException
1193    */
1194   public void rmdir (String path)
1195     throws LibGuestFSException
1196   {
1197     if (g == 0)
1198       throw new LibGuestFSException ("rmdir: handle is closed");
1199     _rmdir (g, path);
1200   }
1201   private native void _rmdir (long g, String path)
1202     throws LibGuestFSException;
1203
1204   /**
1205    * remove a file or directory recursively
1206    *
1207    * Remove the file or directory "path", recursively
1208    * removing the contents if its a directory. This is like
1209    * the "rm -rf" shell command.
1210    * 
1211    * @throws LibGuestFSException
1212    */
1213   public void rm_rf (String path)
1214     throws LibGuestFSException
1215   {
1216     if (g == 0)
1217       throw new LibGuestFSException ("rm_rf: handle is closed");
1218     _rm_rf (g, path);
1219   }
1220   private native void _rm_rf (long g, String path)
1221     throws LibGuestFSException;
1222
1223   /**
1224    * create a directory
1225    *
1226    * Create a directory named "path".
1227    * 
1228    * @throws LibGuestFSException
1229    */
1230   public void mkdir (String path)
1231     throws LibGuestFSException
1232   {
1233     if (g == 0)
1234       throw new LibGuestFSException ("mkdir: handle is closed");
1235     _mkdir (g, path);
1236   }
1237   private native void _mkdir (long g, String path)
1238     throws LibGuestFSException;
1239
1240   /**
1241    * create a directory and parents
1242    *
1243    * Create a directory named "path", creating any parent
1244    * directories as necessary. This is like the "mkdir -p"
1245    * shell command.
1246    * 
1247    * @throws LibGuestFSException
1248    */
1249   public void mkdir_p (String path)
1250     throws LibGuestFSException
1251   {
1252     if (g == 0)
1253       throw new LibGuestFSException ("mkdir_p: handle is closed");
1254     _mkdir_p (g, path);
1255   }
1256   private native void _mkdir_p (long g, String path)
1257     throws LibGuestFSException;
1258
1259   /**
1260    * change file mode
1261    *
1262    * Change the mode (permissions) of "path" to "mode". Only
1263    * numeric modes are supported.
1264    * 
1265    * @throws LibGuestFSException
1266    */
1267   public void chmod (int mode, String path)
1268     throws LibGuestFSException
1269   {
1270     if (g == 0)
1271       throw new LibGuestFSException ("chmod: handle is closed");
1272     _chmod (g, mode, path);
1273   }
1274   private native void _chmod (long g, int mode, String path)
1275     throws LibGuestFSException;
1276
1277   /**
1278    * change file owner and group
1279    *
1280    * Change the file owner to "owner" and group to "group".
1281    * 
1282    * Only numeric uid and gid are supported. If you want to
1283    * use names, you will need to locate and parse the
1284    * password file yourself (Augeas support makes this
1285    * relatively easy).
1286    * 
1287    * @throws LibGuestFSException
1288    */
1289   public void chown (int owner, int group, String path)
1290     throws LibGuestFSException
1291   {
1292     if (g == 0)
1293       throw new LibGuestFSException ("chown: handle is closed");
1294     _chown (g, owner, group, path);
1295   }
1296   private native void _chown (long g, int owner, int group, String path)
1297     throws LibGuestFSException;
1298
1299   /**
1300    * test if file or directory exists
1301    *
1302    * This returns "true" if and only if there is a file,
1303    * directory (or anything) with the given "path" name.
1304    * 
1305    * See also "g.is_file", "g.is_dir", "g.stat".
1306    * 
1307    * @throws LibGuestFSException
1308    */
1309   public boolean exists (String path)
1310     throws LibGuestFSException
1311   {
1312     if (g == 0)
1313       throw new LibGuestFSException ("exists: handle is closed");
1314     return _exists (g, path);
1315   }
1316   private native boolean _exists (long g, String path)
1317     throws LibGuestFSException;
1318
1319   /**
1320    * test if file exists
1321    *
1322    * This returns "true" if and only if there is a file with
1323    * the given "path" name. Note that it returns false for
1324    * other objects like directories.
1325    * 
1326    * See also "g.stat".
1327    * 
1328    * @throws LibGuestFSException
1329    */
1330   public boolean is_file (String path)
1331     throws LibGuestFSException
1332   {
1333     if (g == 0)
1334       throw new LibGuestFSException ("is_file: handle is closed");
1335     return _is_file (g, path);
1336   }
1337   private native boolean _is_file (long g, String path)
1338     throws LibGuestFSException;
1339
1340   /**
1341    * test if file exists
1342    *
1343    * This returns "true" if and only if there is a directory
1344    * with the given "path" name. Note that it returns false
1345    * for other objects like files.
1346    * 
1347    * See also "g.stat".
1348    * 
1349    * @throws LibGuestFSException
1350    */
1351   public boolean is_dir (String path)
1352     throws LibGuestFSException
1353   {
1354     if (g == 0)
1355       throw new LibGuestFSException ("is_dir: handle is closed");
1356     return _is_dir (g, path);
1357   }
1358   private native boolean _is_dir (long g, String path)
1359     throws LibGuestFSException;
1360
1361   /**
1362    * create an LVM physical volume
1363    *
1364    * This creates an LVM physical volume on the named
1365    * "device", where "device" should usually be a partition
1366    * name such as "/dev/sda1".
1367    * 
1368    * @throws LibGuestFSException
1369    */
1370   public void pvcreate (String device)
1371     throws LibGuestFSException
1372   {
1373     if (g == 0)
1374       throw new LibGuestFSException ("pvcreate: handle is closed");
1375     _pvcreate (g, device);
1376   }
1377   private native void _pvcreate (long g, String device)
1378     throws LibGuestFSException;
1379
1380   /**
1381    * create an LVM volume group
1382    *
1383    * This creates an LVM volume group called "volgroup" from
1384    * the non-empty list of physical volumes "physvols".
1385    * 
1386    * @throws LibGuestFSException
1387    */
1388   public void vgcreate (String volgroup, String[] physvols)
1389     throws LibGuestFSException
1390   {
1391     if (g == 0)
1392       throw new LibGuestFSException ("vgcreate: handle is closed");
1393     _vgcreate (g, volgroup, physvols);
1394   }
1395   private native void _vgcreate (long g, String volgroup, String[] physvols)
1396     throws LibGuestFSException;
1397
1398   /**
1399    * create an LVM volume group
1400    *
1401    * This creates an LVM volume group called "logvol" on the
1402    * volume group "volgroup", with "size" megabytes.
1403    * 
1404    * @throws LibGuestFSException
1405    */
1406   public void lvcreate (String logvol, String volgroup, int mbytes)
1407     throws LibGuestFSException
1408   {
1409     if (g == 0)
1410       throw new LibGuestFSException ("lvcreate: handle is closed");
1411     _lvcreate (g, logvol, volgroup, mbytes);
1412   }
1413   private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1414     throws LibGuestFSException;
1415
1416   /**
1417    * make a filesystem
1418    *
1419    * This creates a filesystem on "device" (usually a
1420    * partition of LVM logical volume). The filesystem type is
1421    * "fstype", for example "ext3".
1422    * 
1423    * @throws LibGuestFSException
1424    */
1425   public void mkfs (String fstype, String device)
1426     throws LibGuestFSException
1427   {
1428     if (g == 0)
1429       throw new LibGuestFSException ("mkfs: handle is closed");
1430     _mkfs (g, fstype, device);
1431   }
1432   private native void _mkfs (long g, String fstype, String device)
1433     throws LibGuestFSException;
1434
1435   /**
1436    * create partitions on a block device
1437    *
1438    * This is a direct interface to the sfdisk(8) program for
1439    * creating partitions on block devices.
1440    * 
1441    * "device" should be a block device, for example
1442    * "/dev/sda".
1443    * 
1444    * "cyls", "heads" and "sectors" are the number of
1445    * cylinders, heads and sectors on the device, which are
1446    * passed directly to sfdisk as the *-C*, *-H* and *-S*
1447    * parameters. If you pass 0 for any of these, then the
1448    * corresponding parameter is omitted. Usually for 'large'
1449    * disks, you can just pass 0 for these, but for small
1450    * (floppy-sized) disks, sfdisk (or rather, the kernel)
1451    * cannot work out the right geometry and you will need to
1452    * tell it.
1453    * 
1454    * "lines" is a list of lines that we feed to "sfdisk". For
1455    * more information refer to the sfdisk(8) manpage.
1456    * 
1457    * To create a single partition occupying the whole disk,
1458    * you would pass "lines" as a single element list, when
1459    * the single element being the string "," (comma).
1460    * 
1461    * This command is dangerous. Without careful use you can
1462    * easily destroy all your data.
1463    * 
1464    * @throws LibGuestFSException
1465    */
1466   public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1467     throws LibGuestFSException
1468   {
1469     if (g == 0)
1470       throw new LibGuestFSException ("sfdisk: handle is closed");
1471     _sfdisk (g, device, cyls, heads, sectors, lines);
1472   }
1473   private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1474     throws LibGuestFSException;
1475
1476   /**
1477    * create a file
1478    *
1479    * This call creates a file called "path". The contents of
1480    * the file is the string "content" (which can contain any
1481    * 8 bit data), with length "size".
1482    * 
1483    * As a special case, if "size" is 0 then the length is
1484    * calculated using "strlen" (so in this case the content
1485    * cannot contain embedded ASCII NULs).
1486    * 
1487    * Because of the message protocol, there is a transfer
1488    * limit of somewhere between 2MB and 4MB. To transfer
1489    * large files you should use FTP.
1490    * 
1491    * @throws LibGuestFSException
1492    */
1493   public void write_file (String path, String content, int size)
1494     throws LibGuestFSException
1495   {
1496     if (g == 0)
1497       throw new LibGuestFSException ("write_file: handle is closed");
1498     _write_file (g, path, content, size);
1499   }
1500   private native void _write_file (long g, String path, String content, int size)
1501     throws LibGuestFSException;
1502
1503   /**
1504    * unmount a filesystem
1505    *
1506    * This unmounts the given filesystem. The filesystem may
1507    * be specified either by its mountpoint (path) or the
1508    * device which contains the filesystem.
1509    * 
1510    * @throws LibGuestFSException
1511    */
1512   public void umount (String pathordevice)
1513     throws LibGuestFSException
1514   {
1515     if (g == 0)
1516       throw new LibGuestFSException ("umount: handle is closed");
1517     _umount (g, pathordevice);
1518   }
1519   private native void _umount (long g, String pathordevice)
1520     throws LibGuestFSException;
1521
1522   /**
1523    * show mounted filesystems
1524    *
1525    * This returns the list of currently mounted filesystems.
1526    * It returns the list of devices (eg. "/dev/sda1",
1527    * "/dev/VG/LV").
1528    * 
1529    * Some internal mounts are not shown.
1530    * 
1531    * @throws LibGuestFSException
1532    */
1533   public String[] mounts ()
1534     throws LibGuestFSException
1535   {
1536     if (g == 0)
1537       throw new LibGuestFSException ("mounts: handle is closed");
1538     return _mounts (g);
1539   }
1540   private native String[] _mounts (long g)
1541     throws LibGuestFSException;
1542
1543   /**
1544    * unmount all filesystems
1545    *
1546    * This unmounts all mounted filesystems.
1547    * 
1548    * Some internal mounts are not unmounted by this call.
1549    * 
1550    * @throws LibGuestFSException
1551    */
1552   public void umount_all ()
1553     throws LibGuestFSException
1554   {
1555     if (g == 0)
1556       throw new LibGuestFSException ("umount_all: handle is closed");
1557     _umount_all (g);
1558   }
1559   private native void _umount_all (long g)
1560     throws LibGuestFSException;
1561
1562   /**
1563    * remove all LVM LVs, VGs and PVs
1564    *
1565    * This command removes all LVM logical volumes, volume
1566    * groups and physical volumes.
1567    * 
1568    * This command is dangerous. Without careful use you can
1569    * easily destroy all your data.
1570    * 
1571    * @throws LibGuestFSException
1572    */
1573   public void lvm_remove_all ()
1574     throws LibGuestFSException
1575   {
1576     if (g == 0)
1577       throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1578     _lvm_remove_all (g);
1579   }
1580   private native void _lvm_remove_all (long g)
1581     throws LibGuestFSException;
1582
1583   /**
1584    * determine file type
1585    *
1586    * This call uses the standard file(1) command to determine
1587    * the type or contents of the file. This also works on
1588    * devices, for example to find out whether a partition
1589    * contains a filesystem.
1590    * 
1591    * The exact command which runs is "file -bsL path". Note
1592    * in particular that the filename is not prepended to the
1593    * output (the "-b" option).
1594    * 
1595    * @throws LibGuestFSException
1596    */
1597   public String file (String path)
1598     throws LibGuestFSException
1599   {
1600     if (g == 0)
1601       throw new LibGuestFSException ("file: handle is closed");
1602     return _file (g, path);
1603   }
1604   private native String _file (long g, String path)
1605     throws LibGuestFSException;
1606
1607   /**
1608    * run a command from the guest filesystem
1609    *
1610    * This call runs a command from the guest filesystem. The
1611    * filesystem must be mounted, and must contain a
1612    * compatible operating system (ie. something Linux, with
1613    * the same or compatible processor architecture).
1614    * 
1615    * The single parameter is an argv-style list of arguments.
1616    * The first element is the name of the program to run.
1617    * Subsequent elements are parameters. The list must be
1618    * non-empty (ie. must contain a program name).
1619    * 
1620    * The $PATH environment variable will contain at least
1621    * "/usr/bin" and "/bin". If you require a program from
1622    * another location, you should provide the full path in
1623    * the first parameter.
1624    * 
1625    * Shared libraries and data files required by the program
1626    * must be available on filesystems which are mounted in
1627    * the correct places. It is the caller's responsibility to
1628    * ensure all filesystems that are needed are mounted at
1629    * the right locations.
1630    * 
1631    * @throws LibGuestFSException
1632    */
1633   public String command (String[] arguments)
1634     throws LibGuestFSException
1635   {
1636     if (g == 0)
1637       throw new LibGuestFSException ("command: handle is closed");
1638     return _command (g, arguments);
1639   }
1640   private native String _command (long g, String[] arguments)
1641     throws LibGuestFSException;
1642
1643   /**
1644    * run a command, returning lines
1645    *
1646    * This is the same as "g.command", but splits the result
1647    * into a list of lines.
1648    * 
1649    * @throws LibGuestFSException
1650    */
1651   public String[] command_lines (String[] arguments)
1652     throws LibGuestFSException
1653   {
1654     if (g == 0)
1655       throw new LibGuestFSException ("command_lines: handle is closed");
1656     return _command_lines (g, arguments);
1657   }
1658   private native String[] _command_lines (long g, String[] arguments)
1659     throws LibGuestFSException;
1660
1661   /**
1662    * get file information
1663    *
1664    * Returns file information for the given "path".
1665    * 
1666    * This is the same as the stat(2) system call.
1667    * 
1668    * @throws LibGuestFSException
1669    */
1670   public Stat stat (String path)
1671     throws LibGuestFSException
1672   {
1673     if (g == 0)
1674       throw new LibGuestFSException ("stat: handle is closed");
1675     return _stat (g, path);
1676   }
1677   private native Stat _stat (long g, String path)
1678     throws LibGuestFSException;
1679
1680   /**
1681    * get file information for a symbolic link
1682    *
1683    * Returns file information for the given "path".
1684    * 
1685    * This is the same as "g.stat" except that if "path" is a
1686    * symbolic link, then the link is stat-ed, not the file it
1687    * refers to.
1688    * 
1689    * This is the same as the lstat(2) system call.
1690    * 
1691    * @throws LibGuestFSException
1692    */
1693   public Stat lstat (String path)
1694     throws LibGuestFSException
1695   {
1696     if (g == 0)
1697       throw new LibGuestFSException ("lstat: handle is closed");
1698     return _lstat (g, path);
1699   }
1700   private native Stat _lstat (long g, String path)
1701     throws LibGuestFSException;
1702
1703   /**
1704    * get file system statistics
1705    *
1706    * Returns file system statistics for any mounted file
1707    * system. "path" should be a file or directory in the
1708    * mounted file system (typically it is the mount point
1709    * itself, but it doesn't need to be).
1710    * 
1711    * This is the same as the statvfs(2) system call.
1712    * 
1713    * @throws LibGuestFSException
1714    */
1715   public StatVFS statvfs (String path)
1716     throws LibGuestFSException
1717   {
1718     if (g == 0)
1719       throw new LibGuestFSException ("statvfs: handle is closed");
1720     return _statvfs (g, path);
1721   }
1722   private native StatVFS _statvfs (long g, String path)
1723     throws LibGuestFSException;
1724
1725   /**
1726    * get ext2/ext3 superblock details
1727    *
1728    * This returns the contents of the ext2 or ext3 filesystem
1729    * superblock on "device".
1730    * 
1731    * It is the same as running "tune2fs -l device". See
1732    * tune2fs(8) manpage for more details. The list of fields
1733    * returned isn't clearly defined, and depends on both the
1734    * version of "tune2fs" that libguestfs was built against,
1735    * and the filesystem itself.
1736    * 
1737    * @throws LibGuestFSException
1738    */
1739   public HashMap<String,String> tune2fs_l (String device)
1740     throws LibGuestFSException
1741   {
1742     if (g == 0)
1743       throw new LibGuestFSException ("tune2fs_l: handle is closed");
1744     return _tune2fs_l (g, device);
1745   }
1746   private native HashMap<String,String> _tune2fs_l (long g, String device)
1747     throws LibGuestFSException;
1748
1749   /**
1750    * set block device to read-only
1751    *
1752    * Sets the block device named "device" to read-only.
1753    * 
1754    * This uses the blockdev(8) command.
1755    * 
1756    * @throws LibGuestFSException
1757    */
1758   public void blockdev_setro (String device)
1759     throws LibGuestFSException
1760   {
1761     if (g == 0)
1762       throw new LibGuestFSException ("blockdev_setro: handle is closed");
1763     _blockdev_setro (g, device);
1764   }
1765   private native void _blockdev_setro (long g, String device)
1766     throws LibGuestFSException;
1767
1768   /**
1769    * set block device to read-write
1770    *
1771    * Sets the block device named "device" to read-write.
1772    * 
1773    * This uses the blockdev(8) command.
1774    * 
1775    * @throws LibGuestFSException
1776    */
1777   public void blockdev_setrw (String device)
1778     throws LibGuestFSException
1779   {
1780     if (g == 0)
1781       throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1782     _blockdev_setrw (g, device);
1783   }
1784   private native void _blockdev_setrw (long g, String device)
1785     throws LibGuestFSException;
1786
1787   /**
1788    * is block device set to read-only
1789    *
1790    * Returns a boolean indicating if the block device is
1791    * read-only (true if read-only, false if not).
1792    * 
1793    * This uses the blockdev(8) command.
1794    * 
1795    * @throws LibGuestFSException
1796    */
1797   public boolean blockdev_getro (String device)
1798     throws LibGuestFSException
1799   {
1800     if (g == 0)
1801       throw new LibGuestFSException ("blockdev_getro: handle is closed");
1802     return _blockdev_getro (g, device);
1803   }
1804   private native boolean _blockdev_getro (long g, String device)
1805     throws LibGuestFSException;
1806
1807   /**
1808    * get sectorsize of block device
1809    *
1810    * This returns the size of sectors on a block device.
1811    * Usually 512, but can be larger for modern devices.
1812    * 
1813    * (Note, this is not the size in sectors, use
1814    * "g.blockdev_getsz" for that).
1815    * 
1816    * This uses the blockdev(8) command.
1817    * 
1818    * @throws LibGuestFSException
1819    */
1820   public int blockdev_getss (String device)
1821     throws LibGuestFSException
1822   {
1823     if (g == 0)
1824       throw new LibGuestFSException ("blockdev_getss: handle is closed");
1825     return _blockdev_getss (g, device);
1826   }
1827   private native int _blockdev_getss (long g, String device)
1828     throws LibGuestFSException;
1829
1830   /**
1831    * get blocksize of block device
1832    *
1833    * This returns the block size of a device.
1834    * 
1835    * (Note this is different from both *size in blocks* and
1836    * *filesystem block size*).
1837    * 
1838    * This uses the blockdev(8) command.
1839    * 
1840    * @throws LibGuestFSException
1841    */
1842   public int blockdev_getbsz (String device)
1843     throws LibGuestFSException
1844   {
1845     if (g == 0)
1846       throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1847     return _blockdev_getbsz (g, device);
1848   }
1849   private native int _blockdev_getbsz (long g, String device)
1850     throws LibGuestFSException;
1851
1852   /**
1853    * set blocksize of block device
1854    *
1855    * This sets the block size of a device.
1856    * 
1857    * (Note this is different from both *size in blocks* and
1858    * *filesystem block size*).
1859    * 
1860    * This uses the blockdev(8) command.
1861    * 
1862    * @throws LibGuestFSException
1863    */
1864   public void blockdev_setbsz (String device, int blocksize)
1865     throws LibGuestFSException
1866   {
1867     if (g == 0)
1868       throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1869     _blockdev_setbsz (g, device, blocksize);
1870   }
1871   private native void _blockdev_setbsz (long g, String device, int blocksize)
1872     throws LibGuestFSException;
1873
1874   /**
1875    * get total size of device in 512-byte sectors
1876    *
1877    * This returns the size of the device in units of 512-byte
1878    * sectors (even if the sectorsize isn't 512 bytes ...
1879    * weird).
1880    * 
1881    * See also "g.blockdev_getss" for the real sector size of
1882    * the device, and "g.blockdev_getsize64" for the more
1883    * useful *size in bytes*.
1884    * 
1885    * This uses the blockdev(8) command.
1886    * 
1887    * @throws LibGuestFSException
1888    */
1889   public long blockdev_getsz (String device)
1890     throws LibGuestFSException
1891   {
1892     if (g == 0)
1893       throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1894     return _blockdev_getsz (g, device);
1895   }
1896   private native long _blockdev_getsz (long g, String device)
1897     throws LibGuestFSException;
1898
1899   /**
1900    * get total size of device in bytes
1901    *
1902    * This returns the size of the device in bytes.
1903    * 
1904    * See also "g.blockdev_getsz".
1905    * 
1906    * This uses the blockdev(8) command.
1907    * 
1908    * @throws LibGuestFSException
1909    */
1910   public long blockdev_getsize64 (String device)
1911     throws LibGuestFSException
1912   {
1913     if (g == 0)
1914       throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1915     return _blockdev_getsize64 (g, device);
1916   }
1917   private native long _blockdev_getsize64 (long g, String device)
1918     throws LibGuestFSException;
1919
1920   /**
1921    * flush device buffers
1922    *
1923    * This tells the kernel to flush internal buffers
1924    * associated with "device".
1925    * 
1926    * This uses the blockdev(8) command.
1927    * 
1928    * @throws LibGuestFSException
1929    */
1930   public void blockdev_flushbufs (String device)
1931     throws LibGuestFSException
1932   {
1933     if (g == 0)
1934       throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
1935     _blockdev_flushbufs (g, device);
1936   }
1937   private native void _blockdev_flushbufs (long g, String device)
1938     throws LibGuestFSException;
1939
1940   /**
1941    * reread partition table
1942    *
1943    * Reread the partition table on "device".
1944    * 
1945    * This uses the blockdev(8) command.
1946    * 
1947    * @throws LibGuestFSException
1948    */
1949   public void blockdev_rereadpt (String device)
1950     throws LibGuestFSException
1951   {
1952     if (g == 0)
1953       throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
1954     _blockdev_rereadpt (g, device);
1955   }
1956   private native void _blockdev_rereadpt (long g, String device)
1957     throws LibGuestFSException;
1958
1959   /**
1960    * upload a file from the local machine
1961    *
1962    * Upload local file "filename" to "remotefilename" on the
1963    * filesystem.
1964    * 
1965    * "filename" can also be a named pipe.
1966    * 
1967    * See also "g.download".
1968    * 
1969    * @throws LibGuestFSException
1970    */
1971   public void upload (String filename, String remotefilename)
1972     throws LibGuestFSException
1973   {
1974     if (g == 0)
1975       throw new LibGuestFSException ("upload: handle is closed");
1976     _upload (g, filename, remotefilename);
1977   }
1978   private native void _upload (long g, String filename, String remotefilename)
1979     throws LibGuestFSException;
1980
1981   /**
1982    * download a file to the local machine
1983    *
1984    * Download file "remotefilename" and save it as "filename"
1985    * on the local machine.
1986    * 
1987    * "filename" can also be a named pipe.
1988    * 
1989    * See also "g.upload", "g.cat".
1990    * 
1991    * @throws LibGuestFSException
1992    */
1993   public void download (String remotefilename, String filename)
1994     throws LibGuestFSException
1995   {
1996     if (g == 0)
1997       throw new LibGuestFSException ("download: handle is closed");
1998     _download (g, remotefilename, filename);
1999   }
2000   private native void _download (long g, String remotefilename, String filename)
2001     throws LibGuestFSException;
2002
2003   /**
2004    * compute MD5, SHAx or CRC checksum of file
2005    *
2006    * This call computes the MD5, SHAx or CRC checksum of the
2007    * file named "path".
2008    * 
2009    * The type of checksum to compute is given by the
2010    * "csumtype" parameter which must have one of the
2011    * following values:
2012    * 
2013    * "crc"
2014    * Compute the cyclic redundancy check (CRC) specified
2015    * by POSIX for the "cksum" command.
2016    * 
2017    * "md5"
2018    * Compute the MD5 hash (using the "md5sum" program).
2019    * 
2020    * "sha1"
2021    * Compute the SHA1 hash (using the "sha1sum" program).
2022    * 
2023    * "sha224"
2024    * Compute the SHA224 hash (using the "sha224sum"
2025    * program).
2026    * 
2027    * "sha256"
2028    * Compute the SHA256 hash (using the "sha256sum"
2029    * program).
2030    * 
2031    * "sha384"
2032    * Compute the SHA384 hash (using the "sha384sum"
2033    * program).
2034    * 
2035    * "sha512"
2036    * Compute the SHA512 hash (using the "sha512sum"
2037    * program).
2038    * 
2039    * The checksum is returned as a printable string.
2040    * 
2041    * @throws LibGuestFSException
2042    */
2043   public String checksum (String csumtype, String path)
2044     throws LibGuestFSException
2045   {
2046     if (g == 0)
2047       throw new LibGuestFSException ("checksum: handle is closed");
2048     return _checksum (g, csumtype, path);
2049   }
2050   private native String _checksum (long g, String csumtype, String path)
2051     throws LibGuestFSException;
2052
2053   /**
2054    * unpack tarfile to directory
2055    *
2056    * This command uploads and unpacks local file "tarfile"
2057    * (an *uncompressed* tar file) into "directory".
2058    * 
2059    * To upload a compressed tarball, use "g.tgz_in".
2060    * 
2061    * @throws LibGuestFSException
2062    */
2063   public void tar_in (String tarfile, String directory)
2064     throws LibGuestFSException
2065   {
2066     if (g == 0)
2067       throw new LibGuestFSException ("tar_in: handle is closed");
2068     _tar_in (g, tarfile, directory);
2069   }
2070   private native void _tar_in (long g, String tarfile, String directory)
2071     throws LibGuestFSException;
2072
2073   /**
2074    * pack directory into tarfile
2075    *
2076    * This command packs the contents of "directory" and
2077    * downloads it to local file "tarfile".
2078    * 
2079    * To download a compressed tarball, use "g.tgz_out".
2080    * 
2081    * @throws LibGuestFSException
2082    */
2083   public void tar_out (String directory, String tarfile)
2084     throws LibGuestFSException
2085   {
2086     if (g == 0)
2087       throw new LibGuestFSException ("tar_out: handle is closed");
2088     _tar_out (g, directory, tarfile);
2089   }
2090   private native void _tar_out (long g, String directory, String tarfile)
2091     throws LibGuestFSException;
2092
2093   /**
2094    * unpack compressed tarball to directory
2095    *
2096    * This command uploads and unpacks local file "tarball" (a
2097    * *gzip compressed* tar file) into "directory".
2098    * 
2099    * To upload an uncompressed tarball, use "g.tar_in".
2100    * 
2101    * @throws LibGuestFSException
2102    */
2103   public void tgz_in (String tarball, String directory)
2104     throws LibGuestFSException
2105   {
2106     if (g == 0)
2107       throw new LibGuestFSException ("tgz_in: handle is closed");
2108     _tgz_in (g, tarball, directory);
2109   }
2110   private native void _tgz_in (long g, String tarball, String directory)
2111     throws LibGuestFSException;
2112
2113   /**
2114    * pack directory into compressed tarball
2115    *
2116    * This command packs the contents of "directory" and
2117    * downloads it to local file "tarball".
2118    * 
2119    * To download an uncompressed tarball, use "g.tar_out".
2120    * 
2121    * @throws LibGuestFSException
2122    */
2123   public void tgz_out (String directory, String tarball)
2124     throws LibGuestFSException
2125   {
2126     if (g == 0)
2127       throw new LibGuestFSException ("tgz_out: handle is closed");
2128     _tgz_out (g, directory, tarball);
2129   }
2130   private native void _tgz_out (long g, String directory, String tarball)
2131     throws LibGuestFSException;
2132
2133 }