cdc0f0947ce2c3721ead7de127ebd8643413831b
[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 public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
85     throws LibGuestFSException
86   {
87     if (g == 0)
88       throw new LibGuestFSException ("test0: handle is closed");
89     _test0 (g, str, optstr, strlist, b, integer, filein, fileout);
90   }
91   private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
92     throws LibGuestFSException;
93
94 public int test0rint (String val)
95     throws LibGuestFSException
96   {
97     if (g == 0)
98       throw new LibGuestFSException ("test0rint: handle is closed");
99     return _test0rint (g, val);
100   }
101   private native int _test0rint (long g, String val)
102     throws LibGuestFSException;
103
104 public int test0rinterr ()
105     throws LibGuestFSException
106   {
107     if (g == 0)
108       throw new LibGuestFSException ("test0rinterr: handle is closed");
109     return _test0rinterr (g);
110   }
111   private native int _test0rinterr (long g)
112     throws LibGuestFSException;
113
114 public long test0rint64 (String val)
115     throws LibGuestFSException
116   {
117     if (g == 0)
118       throw new LibGuestFSException ("test0rint64: handle is closed");
119     return _test0rint64 (g, val);
120   }
121   private native long _test0rint64 (long g, String val)
122     throws LibGuestFSException;
123
124 public long test0rint64err ()
125     throws LibGuestFSException
126   {
127     if (g == 0)
128       throw new LibGuestFSException ("test0rint64err: handle is closed");
129     return _test0rint64err (g);
130   }
131   private native long _test0rint64err (long g)
132     throws LibGuestFSException;
133
134 public boolean test0rbool (String val)
135     throws LibGuestFSException
136   {
137     if (g == 0)
138       throw new LibGuestFSException ("test0rbool: handle is closed");
139     return _test0rbool (g, val);
140   }
141   private native boolean _test0rbool (long g, String val)
142     throws LibGuestFSException;
143
144 public boolean test0rboolerr ()
145     throws LibGuestFSException
146   {
147     if (g == 0)
148       throw new LibGuestFSException ("test0rboolerr: handle is closed");
149     return _test0rboolerr (g);
150   }
151   private native boolean _test0rboolerr (long g)
152     throws LibGuestFSException;
153
154 public String test0rconststring (String val)
155     throws LibGuestFSException
156   {
157     if (g == 0)
158       throw new LibGuestFSException ("test0rconststring: handle is closed");
159     return _test0rconststring (g, val);
160   }
161   private native String _test0rconststring (long g, String val)
162     throws LibGuestFSException;
163
164 public String test0rconststringerr ()
165     throws LibGuestFSException
166   {
167     if (g == 0)
168       throw new LibGuestFSException ("test0rconststringerr: handle is closed");
169     return _test0rconststringerr (g);
170   }
171   private native String _test0rconststringerr (long g)
172     throws LibGuestFSException;
173
174 public String test0rstring (String val)
175     throws LibGuestFSException
176   {
177     if (g == 0)
178       throw new LibGuestFSException ("test0rstring: handle is closed");
179     return _test0rstring (g, val);
180   }
181   private native String _test0rstring (long g, String val)
182     throws LibGuestFSException;
183
184 public String test0rstringerr ()
185     throws LibGuestFSException
186   {
187     if (g == 0)
188       throw new LibGuestFSException ("test0rstringerr: handle is closed");
189     return _test0rstringerr (g);
190   }
191   private native String _test0rstringerr (long g)
192     throws LibGuestFSException;
193
194 public String[] test0rstringlist (String val)
195     throws LibGuestFSException
196   {
197     if (g == 0)
198       throw new LibGuestFSException ("test0rstringlist: handle is closed");
199     return _test0rstringlist (g, val);
200   }
201   private native String[] _test0rstringlist (long g, String val)
202     throws LibGuestFSException;
203
204 public String[] test0rstringlisterr ()
205     throws LibGuestFSException
206   {
207     if (g == 0)
208       throw new LibGuestFSException ("test0rstringlisterr: handle is closed");
209     return _test0rstringlisterr (g);
210   }
211   private native String[] _test0rstringlisterr (long g)
212     throws LibGuestFSException;
213
214 public IntBool test0rintbool (String val)
215     throws LibGuestFSException
216   {
217     if (g == 0)
218       throw new LibGuestFSException ("test0rintbool: handle is closed");
219     return _test0rintbool (g, val);
220   }
221   private native IntBool _test0rintbool (long g, String val)
222     throws LibGuestFSException;
223
224 public IntBool test0rintboolerr ()
225     throws LibGuestFSException
226   {
227     if (g == 0)
228       throw new LibGuestFSException ("test0rintboolerr: handle is closed");
229     return _test0rintboolerr (g);
230   }
231   private native IntBool _test0rintboolerr (long g)
232     throws LibGuestFSException;
233
234 public PV[] test0rpvlist (String val)
235     throws LibGuestFSException
236   {
237     if (g == 0)
238       throw new LibGuestFSException ("test0rpvlist: handle is closed");
239     return _test0rpvlist (g, val);
240   }
241   private native PV[] _test0rpvlist (long g, String val)
242     throws LibGuestFSException;
243
244 public PV[] test0rpvlisterr ()
245     throws LibGuestFSException
246   {
247     if (g == 0)
248       throw new LibGuestFSException ("test0rpvlisterr: handle is closed");
249     return _test0rpvlisterr (g);
250   }
251   private native PV[] _test0rpvlisterr (long g)
252     throws LibGuestFSException;
253
254 public VG[] test0rvglist (String val)
255     throws LibGuestFSException
256   {
257     if (g == 0)
258       throw new LibGuestFSException ("test0rvglist: handle is closed");
259     return _test0rvglist (g, val);
260   }
261   private native VG[] _test0rvglist (long g, String val)
262     throws LibGuestFSException;
263
264 public VG[] test0rvglisterr ()
265     throws LibGuestFSException
266   {
267     if (g == 0)
268       throw new LibGuestFSException ("test0rvglisterr: handle is closed");
269     return _test0rvglisterr (g);
270   }
271   private native VG[] _test0rvglisterr (long g)
272     throws LibGuestFSException;
273
274 public LV[] test0rlvlist (String val)
275     throws LibGuestFSException
276   {
277     if (g == 0)
278       throw new LibGuestFSException ("test0rlvlist: handle is closed");
279     return _test0rlvlist (g, val);
280   }
281   private native LV[] _test0rlvlist (long g, String val)
282     throws LibGuestFSException;
283
284 public LV[] test0rlvlisterr ()
285     throws LibGuestFSException
286   {
287     if (g == 0)
288       throw new LibGuestFSException ("test0rlvlisterr: handle is closed");
289     return _test0rlvlisterr (g);
290   }
291   private native LV[] _test0rlvlisterr (long g)
292     throws LibGuestFSException;
293
294 public Stat test0rstat (String val)
295     throws LibGuestFSException
296   {
297     if (g == 0)
298       throw new LibGuestFSException ("test0rstat: handle is closed");
299     return _test0rstat (g, val);
300   }
301   private native Stat _test0rstat (long g, String val)
302     throws LibGuestFSException;
303
304 public Stat test0rstaterr ()
305     throws LibGuestFSException
306   {
307     if (g == 0)
308       throw new LibGuestFSException ("test0rstaterr: handle is closed");
309     return _test0rstaterr (g);
310   }
311   private native Stat _test0rstaterr (long g)
312     throws LibGuestFSException;
313
314 public StatVFS test0rstatvfs (String val)
315     throws LibGuestFSException
316   {
317     if (g == 0)
318       throw new LibGuestFSException ("test0rstatvfs: handle is closed");
319     return _test0rstatvfs (g, val);
320   }
321   private native StatVFS _test0rstatvfs (long g, String val)
322     throws LibGuestFSException;
323
324 public StatVFS test0rstatvfserr ()
325     throws LibGuestFSException
326   {
327     if (g == 0)
328       throw new LibGuestFSException ("test0rstatvfserr: handle is closed");
329     return _test0rstatvfserr (g);
330   }
331   private native StatVFS _test0rstatvfserr (long g)
332     throws LibGuestFSException;
333
334 public HashMap<String,String> test0rhashtable (String val)
335     throws LibGuestFSException
336   {
337     if (g == 0)
338       throw new LibGuestFSException ("test0rhashtable: handle is closed");
339     return _test0rhashtable (g, val);
340   }
341   private native HashMap<String,String> _test0rhashtable (long g, String val)
342     throws LibGuestFSException;
343
344 public HashMap<String,String> test0rhashtableerr ()
345     throws LibGuestFSException
346   {
347     if (g == 0)
348       throw new LibGuestFSException ("test0rhashtableerr: handle is closed");
349     return _test0rhashtableerr (g);
350   }
351   private native HashMap<String,String> _test0rhashtableerr (long g)
352     throws LibGuestFSException;
353
354   /**
355    * launch the qemu subprocess
356    * <p>
357    * Internally libguestfs is implemented by running a
358    * virtual machine using qemu(1).
359    * <p>
360    * You should call this after configuring the handle (eg.
361    * adding drives) but before performing any actions.
362    * <p>
363    * @throws LibGuestFSException
364    */
365   public void launch ()
366     throws LibGuestFSException
367   {
368     if (g == 0)
369       throw new LibGuestFSException ("launch: handle is closed");
370     _launch (g);
371   }
372   private native void _launch (long g)
373     throws LibGuestFSException;
374
375   /**
376    * wait until the qemu subprocess launches
377    * <p>
378    * Internally libguestfs is implemented by running a
379    * virtual machine using qemu(1).
380    * <p>
381    * You should call this after "g.launch" to wait for the
382    * launch to complete.
383    * <p>
384    * @throws LibGuestFSException
385    */
386   public void wait_ready ()
387     throws LibGuestFSException
388   {
389     if (g == 0)
390       throw new LibGuestFSException ("wait_ready: handle is closed");
391     _wait_ready (g);
392   }
393   private native void _wait_ready (long g)
394     throws LibGuestFSException;
395
396   /**
397    * kill the qemu subprocess
398    * <p>
399    * This kills the qemu subprocess. You should never need to
400    * call this.
401    * <p>
402    * @throws LibGuestFSException
403    */
404   public void kill_subprocess ()
405     throws LibGuestFSException
406   {
407     if (g == 0)
408       throw new LibGuestFSException ("kill_subprocess: handle is closed");
409     _kill_subprocess (g);
410   }
411   private native void _kill_subprocess (long g)
412     throws LibGuestFSException;
413
414   /**
415    * add an image to examine or modify
416    * <p>
417    * This function adds a virtual machine disk image
418    * "filename" to the guest. The first time you call this
419    * function, the disk appears as IDE disk 0 ("/dev/sda") in
420    * the guest, the second time as "/dev/sdb", and so on.
421    * <p>
422    * You don't necessarily need to be root when using
423    * libguestfs. However you obviously do need sufficient
424    * permissions to access the filename for whatever
425    * operations you want to perform (ie. read access if you
426    * just want to read the image or write access if you want
427    * to modify the image).
428    * <p>
429    * This is equivalent to the qemu parameter "-drive
430    * file=filename".
431    * <p>
432    * Note that this call checks for the existence of
433    * "filename". This stops you from specifying other types
434    * of drive which are supported by qemu such as "nbd:" and
435    * "http:" URLs. To specify those, use the general
436    * "g.config" call instead.
437    * <p>
438    * @throws LibGuestFSException
439    */
440   public void add_drive (String filename)
441     throws LibGuestFSException
442   {
443     if (g == 0)
444       throw new LibGuestFSException ("add_drive: handle is closed");
445     _add_drive (g, filename);
446   }
447   private native void _add_drive (long g, String filename)
448     throws LibGuestFSException;
449
450   /**
451    * add a CD-ROM disk image to examine
452    * <p>
453    * This function adds a virtual CD-ROM disk image to the
454    * guest.
455    * <p>
456    * This is equivalent to the qemu parameter "-cdrom
457    * filename".
458    * <p>
459    * Note that this call checks for the existence of
460    * "filename". This stops you from specifying other types
461    * of drive which are supported by qemu such as "nbd:" and
462    * "http:" URLs. To specify those, use the general
463    * "g.config" call instead.
464    * <p>
465    * @throws LibGuestFSException
466    */
467   public void add_cdrom (String filename)
468     throws LibGuestFSException
469   {
470     if (g == 0)
471       throw new LibGuestFSException ("add_cdrom: handle is closed");
472     _add_cdrom (g, filename);
473   }
474   private native void _add_cdrom (long g, String filename)
475     throws LibGuestFSException;
476
477   /**
478    * add a drive in snapshot mode (read-only)
479    * <p>
480    * This adds a drive in snapshot mode, making it
481    * effectively read-only.
482    * <p>
483    * Note that writes to the device are allowed, and will be
484    * seen for the duration of the guestfs handle, but they
485    * are written to a temporary file which is discarded as
486    * soon as the guestfs handle is closed. We don't currently
487    * have any method to enable changes to be committed,
488    * although qemu can support this.
489    * <p>
490    * This is equivalent to the qemu parameter "-drive
491    * file=filename,snapshot=on".
492    * <p>
493    * Note that this call checks for the existence of
494    * "filename". This stops you from specifying other types
495    * of drive which are supported by qemu such as "nbd:" and
496    * "http:" URLs. To specify those, use the general
497    * "g.config" call instead.
498    * <p>
499    * @throws LibGuestFSException
500    */
501   public void add_drive_ro (String filename)
502     throws LibGuestFSException
503   {
504     if (g == 0)
505       throw new LibGuestFSException ("add_drive_ro: handle is closed");
506     _add_drive_ro (g, filename);
507   }
508   private native void _add_drive_ro (long g, String filename)
509     throws LibGuestFSException;
510
511   /**
512    * add qemu parameters
513    * <p>
514    * This can be used to add arbitrary qemu command line
515    * parameters of the form "-param value". Actually it's not
516    * quite arbitrary - we prevent you from setting some
517    * parameters which would interfere with parameters that we
518    * use.
519    * <p>
520    * The first character of "param" string must be a "-"
521    * (dash).
522    * <p>
523    * "value" can be NULL.
524    * <p>
525    * @throws LibGuestFSException
526    */
527   public void config (String qemuparam, String qemuvalue)
528     throws LibGuestFSException
529   {
530     if (g == 0)
531       throw new LibGuestFSException ("config: handle is closed");
532     _config (g, qemuparam, qemuvalue);
533   }
534   private native void _config (long g, String qemuparam, String qemuvalue)
535     throws LibGuestFSException;
536
537   /**
538    * set the qemu binary
539    * <p>
540    * Set the qemu binary that we will use.
541    * <p>
542    * The default is chosen when the library was compiled by
543    * the configure script.
544    * <p>
545    * You can also override this by setting the
546    * "LIBGUESTFS_QEMU" environment variable.
547    * <p>
548    * Setting "qemu" to "NULL" restores the default qemu
549    * binary.
550    * <p>
551    * @throws LibGuestFSException
552    */
553   public void set_qemu (String qemu)
554     throws LibGuestFSException
555   {
556     if (g == 0)
557       throw new LibGuestFSException ("set_qemu: handle is closed");
558     _set_qemu (g, qemu);
559   }
560   private native void _set_qemu (long g, String qemu)
561     throws LibGuestFSException;
562
563   /**
564    * get the qemu binary
565    * <p>
566    * Return the current qemu binary.
567    * <p>
568    * This is always non-NULL. If it wasn't set already, then
569    * this will return the default qemu binary name.
570    * <p>
571    * @throws LibGuestFSException
572    */
573   public String get_qemu ()
574     throws LibGuestFSException
575   {
576     if (g == 0)
577       throw new LibGuestFSException ("get_qemu: handle is closed");
578     return _get_qemu (g);
579   }
580   private native String _get_qemu (long g)
581     throws LibGuestFSException;
582
583   /**
584    * set the search path
585    * <p>
586    * Set the path that libguestfs searches for kernel and
587    * initrd.img.
588    * <p>
589    * The default is "$libdir/guestfs" unless overridden by
590    * setting "LIBGUESTFS_PATH" environment variable.
591    * <p>
592    * Setting "path" to "NULL" restores the default path.
593    * <p>
594    * @throws LibGuestFSException
595    */
596   public void set_path (String path)
597     throws LibGuestFSException
598   {
599     if (g == 0)
600       throw new LibGuestFSException ("set_path: handle is closed");
601     _set_path (g, path);
602   }
603   private native void _set_path (long g, String path)
604     throws LibGuestFSException;
605
606   /**
607    * get the search path
608    * <p>
609    * Return the current search path.
610    * <p>
611    * This is always non-NULL. If it wasn't set already, then
612    * this will return the default path.
613    * <p>
614    * @throws LibGuestFSException
615    */
616   public String get_path ()
617     throws LibGuestFSException
618   {
619     if (g == 0)
620       throw new LibGuestFSException ("get_path: handle is closed");
621     return _get_path (g);
622   }
623   private native String _get_path (long g)
624     throws LibGuestFSException;
625
626   /**
627    * add options to kernel command line
628    * <p>
629    * This function is used to add additional options to the
630    * guest kernel command line.
631    * <p>
632    * The default is "NULL" unless overridden by setting
633    * "LIBGUESTFS_APPEND" environment variable.
634    * <p>
635    * Setting "append" to "NULL" means *no* additional options
636    * are passed (libguestfs always adds a few of its own).
637    * <p>
638    * @throws LibGuestFSException
639    */
640   public void set_append (String append)
641     throws LibGuestFSException
642   {
643     if (g == 0)
644       throw new LibGuestFSException ("set_append: handle is closed");
645     _set_append (g, append);
646   }
647   private native void _set_append (long g, String append)
648     throws LibGuestFSException;
649
650   /**
651    * get the additional kernel options
652    * <p>
653    * Return the additional kernel options which are added to
654    * the guest kernel command line.
655    * <p>
656    * If "NULL" then no options are added.
657    * <p>
658    * @throws LibGuestFSException
659    */
660   public String get_append ()
661     throws LibGuestFSException
662   {
663     if (g == 0)
664       throw new LibGuestFSException ("get_append: handle is closed");
665     return _get_append (g);
666   }
667   private native String _get_append (long g)
668     throws LibGuestFSException;
669
670   /**
671    * set autosync mode
672    * <p>
673    * If "autosync" is true, this enables autosync. Libguestfs
674    * will make a best effort attempt to run "g.umount_all"
675    * followed by "g.sync" when the handle is closed (also if
676    * the program exits without closing handles).
677    * <p>
678    * This is disabled by default (except in guestfish where
679    * it is enabled by default).
680    * <p>
681    * @throws LibGuestFSException
682    */
683   public void set_autosync (boolean autosync)
684     throws LibGuestFSException
685   {
686     if (g == 0)
687       throw new LibGuestFSException ("set_autosync: handle is closed");
688     _set_autosync (g, autosync);
689   }
690   private native void _set_autosync (long g, boolean autosync)
691     throws LibGuestFSException;
692
693   /**
694    * get autosync mode
695    * <p>
696    * Get the autosync flag.
697    * <p>
698    * @throws LibGuestFSException
699    */
700   public boolean get_autosync ()
701     throws LibGuestFSException
702   {
703     if (g == 0)
704       throw new LibGuestFSException ("get_autosync: handle is closed");
705     return _get_autosync (g);
706   }
707   private native boolean _get_autosync (long g)
708     throws LibGuestFSException;
709
710   /**
711    * set verbose mode
712    * <p>
713    * If "verbose" is true, this turns on verbose messages (to
714    * "stderr").
715    * <p>
716    * Verbose messages are disabled unless the environment
717    * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
718    * <p>
719    * @throws LibGuestFSException
720    */
721   public void set_verbose (boolean verbose)
722     throws LibGuestFSException
723   {
724     if (g == 0)
725       throw new LibGuestFSException ("set_verbose: handle is closed");
726     _set_verbose (g, verbose);
727   }
728   private native void _set_verbose (long g, boolean verbose)
729     throws LibGuestFSException;
730
731   /**
732    * get verbose mode
733    * <p>
734    * This returns the verbose messages flag.
735    * <p>
736    * @throws LibGuestFSException
737    */
738   public boolean get_verbose ()
739     throws LibGuestFSException
740   {
741     if (g == 0)
742       throw new LibGuestFSException ("get_verbose: handle is closed");
743     return _get_verbose (g);
744   }
745   private native boolean _get_verbose (long g)
746     throws LibGuestFSException;
747
748   /**
749    * is ready to accept commands
750    * <p>
751    * This returns true iff this handle is ready to accept
752    * commands (in the "READY" state).
753    * <p>
754    * For more information on states, see guestfs(3).
755    * <p>
756    * @throws LibGuestFSException
757    */
758   public boolean is_ready ()
759     throws LibGuestFSException
760   {
761     if (g == 0)
762       throw new LibGuestFSException ("is_ready: handle is closed");
763     return _is_ready (g);
764   }
765   private native boolean _is_ready (long g)
766     throws LibGuestFSException;
767
768   /**
769    * is in configuration state
770    * <p>
771    * This returns true iff this handle is being configured
772    * (in the "CONFIG" state).
773    * <p>
774    * For more information on states, see guestfs(3).
775    * <p>
776    * @throws LibGuestFSException
777    */
778   public boolean is_config ()
779     throws LibGuestFSException
780   {
781     if (g == 0)
782       throw new LibGuestFSException ("is_config: handle is closed");
783     return _is_config (g);
784   }
785   private native boolean _is_config (long g)
786     throws LibGuestFSException;
787
788   /**
789    * is launching subprocess
790    * <p>
791    * This returns true iff this handle is launching the
792    * subprocess (in the "LAUNCHING" state).
793    * <p>
794    * For more information on states, see guestfs(3).
795    * <p>
796    * @throws LibGuestFSException
797    */
798   public boolean is_launching ()
799     throws LibGuestFSException
800   {
801     if (g == 0)
802       throw new LibGuestFSException ("is_launching: handle is closed");
803     return _is_launching (g);
804   }
805   private native boolean _is_launching (long g)
806     throws LibGuestFSException;
807
808   /**
809    * is busy processing a command
810    * <p>
811    * This returns true iff this handle is busy processing a
812    * command (in the "BUSY" state).
813    * <p>
814    * For more information on states, see guestfs(3).
815    * <p>
816    * @throws LibGuestFSException
817    */
818   public boolean is_busy ()
819     throws LibGuestFSException
820   {
821     if (g == 0)
822       throw new LibGuestFSException ("is_busy: handle is closed");
823     return _is_busy (g);
824   }
825   private native boolean _is_busy (long g)
826     throws LibGuestFSException;
827
828   /**
829    * get the current state
830    * <p>
831    * This returns the current state as an opaque integer.
832    * This is only useful for printing debug and internal
833    * error messages.
834    * <p>
835    * For more information on states, see guestfs(3).
836    * <p>
837    * @throws LibGuestFSException
838    */
839   public int get_state ()
840     throws LibGuestFSException
841   {
842     if (g == 0)
843       throw new LibGuestFSException ("get_state: handle is closed");
844     return _get_state (g);
845   }
846   private native int _get_state (long g)
847     throws LibGuestFSException;
848
849   /**
850    * set state to busy
851    * <p>
852    * This sets the state to "BUSY". This is only used when
853    * implementing actions using the low-level API.
854    * <p>
855    * For more information on states, see guestfs(3).
856    * <p>
857    * @throws LibGuestFSException
858    */
859   public void set_busy ()
860     throws LibGuestFSException
861   {
862     if (g == 0)
863       throw new LibGuestFSException ("set_busy: handle is closed");
864     _set_busy (g);
865   }
866   private native void _set_busy (long g)
867     throws LibGuestFSException;
868
869   /**
870    * set state to ready
871    * <p>
872    * This sets the state to "READY". This is only used when
873    * implementing actions using the low-level API.
874    * <p>
875    * For more information on states, see guestfs(3).
876    * <p>
877    * @throws LibGuestFSException
878    */
879   public void set_ready ()
880     throws LibGuestFSException
881   {
882     if (g == 0)
883       throw new LibGuestFSException ("set_ready: handle is closed");
884     _set_ready (g);
885   }
886   private native void _set_ready (long g)
887     throws LibGuestFSException;
888
889   /**
890    * leave the busy state
891    * <p>
892    * This sets the state to "READY", or if in "CONFIG" then
893    * it leaves the state as is. This is only used when
894    * implementing actions using the low-level API.
895    * <p>
896    * For more information on states, see guestfs(3).
897    * <p>
898    * @throws LibGuestFSException
899    */
900   public void end_busy ()
901     throws LibGuestFSException
902   {
903     if (g == 0)
904       throw new LibGuestFSException ("end_busy: handle is closed");
905     _end_busy (g);
906   }
907   private native void _end_busy (long g)
908     throws LibGuestFSException;
909
910   /**
911    * mount a guest disk at a position in the filesystem
912    * <p>
913    * Mount a guest disk at a position in the filesystem.
914    * Block devices are named "/dev/sda", "/dev/sdb" and so
915    * on, as they were added to the guest. If those block
916    * devices contain partitions, they will have the usual
917    * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
918    * names can be used.
919    * <p>
920    * The rules are the same as for mount(2): A filesystem
921    * must first be mounted on "/" before others can be
922    * mounted. Other filesystems can only be mounted on
923    * directories which already exist.
924    * <p>
925    * The mounted filesystem is writable, if we have
926    * sufficient permissions on the underlying device.
927    * <p>
928    * The filesystem options "sync" and "noatime" are set with
929    * this call, in order to improve reliability.
930    * <p>
931    * @throws LibGuestFSException
932    */
933   public void mount (String device, String mountpoint)
934     throws LibGuestFSException
935   {
936     if (g == 0)
937       throw new LibGuestFSException ("mount: handle is closed");
938     _mount (g, device, mountpoint);
939   }
940   private native void _mount (long g, String device, String mountpoint)
941     throws LibGuestFSException;
942
943   /**
944    * sync disks, writes are flushed through to the disk image
945    * <p>
946    * This syncs the disk, so that any writes are flushed
947    * through to the underlying disk image.
948    * <p>
949    * You should always call this if you have modified a disk
950    * image, before closing the handle.
951    * <p>
952    * @throws LibGuestFSException
953    */
954   public void sync ()
955     throws LibGuestFSException
956   {
957     if (g == 0)
958       throw new LibGuestFSException ("sync: handle is closed");
959     _sync (g);
960   }
961   private native void _sync (long g)
962     throws LibGuestFSException;
963
964   /**
965    * update file timestamps or create a new file
966    * <p>
967    * Touch acts like the touch(1) command. It can be used to
968    * update the timestamps on a file, or, if the file does
969    * not exist, to create a new zero-length file.
970    * <p>
971    * @throws LibGuestFSException
972    */
973   public void touch (String path)
974     throws LibGuestFSException
975   {
976     if (g == 0)
977       throw new LibGuestFSException ("touch: handle is closed");
978     _touch (g, path);
979   }
980   private native void _touch (long g, String path)
981     throws LibGuestFSException;
982
983   /**
984    * list the contents of a file
985    * <p>
986    * Return the contents of the file named "path".
987    * <p>
988    * Note that this function cannot correctly handle binary
989    * files (specifically, files containing "\0" character
990    * which is treated as end of string). For those you need
991    * to use the "g.download" function which has a more
992    * complex interface.
993    * <p>
994    * Because of the message protocol, there is a transfer
995    * limit of somewhere between 2MB and 4MB. To transfer
996    * large files you should use FTP.
997    * <p>
998    * @throws LibGuestFSException
999    */
1000   public String cat (String path)
1001     throws LibGuestFSException
1002   {
1003     if (g == 0)
1004       throw new LibGuestFSException ("cat: handle is closed");
1005     return _cat (g, path);
1006   }
1007   private native String _cat (long g, String path)
1008     throws LibGuestFSException;
1009
1010   /**
1011    * list the files in a directory (long format)
1012    * <p>
1013    * List the files in "directory" (relative to the root
1014    * directory, there is no cwd) in the format of 'ls -la'.
1015    * <p>
1016    * This command is mostly useful for interactive sessions.
1017    * It is *not* intended that you try to parse the output
1018    * string.
1019    * <p>
1020    * @throws LibGuestFSException
1021    */
1022   public String ll (String directory)
1023     throws LibGuestFSException
1024   {
1025     if (g == 0)
1026       throw new LibGuestFSException ("ll: handle is closed");
1027     return _ll (g, directory);
1028   }
1029   private native String _ll (long g, String directory)
1030     throws LibGuestFSException;
1031
1032   /**
1033    * list the files in a directory
1034    * <p>
1035    * List the files in "directory" (relative to the root
1036    * directory, there is no cwd). The '.' and '..' entries
1037    * are not returned, but hidden files are shown.
1038    * <p>
1039    * This command is mostly useful for interactive sessions.
1040    * Programs should probably use "g.readdir" instead.
1041    * <p>
1042    * @throws LibGuestFSException
1043    */
1044   public String[] ls (String directory)
1045     throws LibGuestFSException
1046   {
1047     if (g == 0)
1048       throw new LibGuestFSException ("ls: handle is closed");
1049     return _ls (g, directory);
1050   }
1051   private native String[] _ls (long g, String directory)
1052     throws LibGuestFSException;
1053
1054   /**
1055    * list the block devices
1056    * <p>
1057    * List all the block devices.
1058    * <p>
1059    * The full block device names are returned, eg. "/dev/sda"
1060    * <p>
1061    * @throws LibGuestFSException
1062    */
1063   public String[] list_devices ()
1064     throws LibGuestFSException
1065   {
1066     if (g == 0)
1067       throw new LibGuestFSException ("list_devices: handle is closed");
1068     return _list_devices (g);
1069   }
1070   private native String[] _list_devices (long g)
1071     throws LibGuestFSException;
1072
1073   /**
1074    * list the partitions
1075    * <p>
1076    * List all the partitions detected on all block devices.
1077    * <p>
1078    * The full partition device names are returned, eg.
1079    * "/dev/sda1"
1080    * <p>
1081    * This does not return logical volumes. For that you will
1082    * need to call "g.lvs".
1083    * <p>
1084    * @throws LibGuestFSException
1085    */
1086   public String[] list_partitions ()
1087     throws LibGuestFSException
1088   {
1089     if (g == 0)
1090       throw new LibGuestFSException ("list_partitions: handle is closed");
1091     return _list_partitions (g);
1092   }
1093   private native String[] _list_partitions (long g)
1094     throws LibGuestFSException;
1095
1096   /**
1097    * list the LVM physical volumes (PVs)
1098    * <p>
1099    * List all the physical volumes detected. This is the
1100    * equivalent of the pvs(8) command.
1101    * <p>
1102    * This returns a list of just the device names that
1103    * contain PVs (eg. "/dev/sda2").
1104    * <p>
1105    * See also "g.pvs_full".
1106    * <p>
1107    * @throws LibGuestFSException
1108    */
1109   public String[] pvs ()
1110     throws LibGuestFSException
1111   {
1112     if (g == 0)
1113       throw new LibGuestFSException ("pvs: handle is closed");
1114     return _pvs (g);
1115   }
1116   private native String[] _pvs (long g)
1117     throws LibGuestFSException;
1118
1119   /**
1120    * list the LVM volume groups (VGs)
1121    * <p>
1122    * List all the volumes groups detected. This is the
1123    * equivalent of the vgs(8) command.
1124    * <p>
1125    * This returns a list of just the volume group names that
1126    * were detected (eg. "VolGroup00").
1127    * <p>
1128    * See also "g.vgs_full".
1129    * <p>
1130    * @throws LibGuestFSException
1131    */
1132   public String[] vgs ()
1133     throws LibGuestFSException
1134   {
1135     if (g == 0)
1136       throw new LibGuestFSException ("vgs: handle is closed");
1137     return _vgs (g);
1138   }
1139   private native String[] _vgs (long g)
1140     throws LibGuestFSException;
1141
1142   /**
1143    * list the LVM logical volumes (LVs)
1144    * <p>
1145    * List all the logical volumes detected. This is the
1146    * equivalent of the lvs(8) command.
1147    * <p>
1148    * This returns a list of the logical volume device names
1149    * (eg. "/dev/VolGroup00/LogVol00").
1150    * <p>
1151    * See also "g.lvs_full".
1152    * <p>
1153    * @throws LibGuestFSException
1154    */
1155   public String[] lvs ()
1156     throws LibGuestFSException
1157   {
1158     if (g == 0)
1159       throw new LibGuestFSException ("lvs: handle is closed");
1160     return _lvs (g);
1161   }
1162   private native String[] _lvs (long g)
1163     throws LibGuestFSException;
1164
1165   /**
1166    * list the LVM physical volumes (PVs)
1167    * <p>
1168    * List all the physical volumes detected. This is the
1169    * equivalent of the pvs(8) command. The "full" version
1170    * includes all fields.
1171    * <p>
1172    * @throws LibGuestFSException
1173    */
1174   public PV[] pvs_full ()
1175     throws LibGuestFSException
1176   {
1177     if (g == 0)
1178       throw new LibGuestFSException ("pvs_full: handle is closed");
1179     return _pvs_full (g);
1180   }
1181   private native PV[] _pvs_full (long g)
1182     throws LibGuestFSException;
1183
1184   /**
1185    * list the LVM volume groups (VGs)
1186    * <p>
1187    * List all the volumes groups detected. This is the
1188    * equivalent of the vgs(8) command. The "full" version
1189    * includes all fields.
1190    * <p>
1191    * @throws LibGuestFSException
1192    */
1193   public VG[] vgs_full ()
1194     throws LibGuestFSException
1195   {
1196     if (g == 0)
1197       throw new LibGuestFSException ("vgs_full: handle is closed");
1198     return _vgs_full (g);
1199   }
1200   private native VG[] _vgs_full (long g)
1201     throws LibGuestFSException;
1202
1203   /**
1204    * list the LVM logical volumes (LVs)
1205    * <p>
1206    * List all the logical volumes detected. This is the
1207    * equivalent of the lvs(8) command. The "full" version
1208    * includes all fields.
1209    * <p>
1210    * @throws LibGuestFSException
1211    */
1212   public LV[] lvs_full ()
1213     throws LibGuestFSException
1214   {
1215     if (g == 0)
1216       throw new LibGuestFSException ("lvs_full: handle is closed");
1217     return _lvs_full (g);
1218   }
1219   private native LV[] _lvs_full (long g)
1220     throws LibGuestFSException;
1221
1222   /**
1223    * read file as lines
1224    * <p>
1225    * Return the contents of the file named "path".
1226    * <p>
1227    * The file contents are returned as a list of lines.
1228    * Trailing "LF" and "CRLF" character sequences are *not*
1229    * returned.
1230    * <p>
1231    * Note that this function cannot correctly handle binary
1232    * files (specifically, files containing "\0" character
1233    * which is treated as end of line). For those you need to
1234    * use the "g.read_file" function which has a more complex
1235    * interface.
1236    * <p>
1237    * @throws LibGuestFSException
1238    */
1239   public String[] read_lines (String path)
1240     throws LibGuestFSException
1241   {
1242     if (g == 0)
1243       throw new LibGuestFSException ("read_lines: handle is closed");
1244     return _read_lines (g, path);
1245   }
1246   private native String[] _read_lines (long g, String path)
1247     throws LibGuestFSException;
1248
1249   /**
1250    * create a new Augeas handle
1251    * <p>
1252    * Create a new Augeas handle for editing configuration
1253    * files. If there was any previous Augeas handle
1254    * associated with this guestfs session, then it is closed.
1255    * <p>
1256    * You must call this before using any other "g.aug_*"
1257    * commands.
1258    * <p>
1259    * "root" is the filesystem root. "root" must not be NULL,
1260    * use "/" instead.
1261    * <p>
1262    * The flags are the same as the flags defined in
1263    * <augeas.h>, the logical *or* of the following integers:
1264    * <p>
1265    * "AUG_SAVE_BACKUP" = 1
1266    * Keep the original file with a ".augsave" extension.
1267    * <p>
1268    * "AUG_SAVE_NEWFILE" = 2
1269    * Save changes into a file with extension ".augnew",
1270    * and do not overwrite original. Overrides
1271    * "AUG_SAVE_BACKUP".
1272    * <p>
1273    * "AUG_TYPE_CHECK" = 4
1274    * Typecheck lenses (can be expensive).
1275    * <p>
1276    * "AUG_NO_STDINC" = 8
1277    * Do not use standard load path for modules.
1278    * <p>
1279    * "AUG_SAVE_NOOP" = 16
1280    * Make save a no-op, just record what would have been
1281    * changed.
1282    * <p>
1283    * "AUG_NO_LOAD" = 32
1284    * Do not load the tree in "g.aug_init".
1285    * <p>
1286    * To close the handle, you can call "g.aug_close".
1287    * <p>
1288    * To find out more about Augeas, see <http://augeas.net/>.
1289    * <p>
1290    * @throws LibGuestFSException
1291    */
1292   public void aug_init (String root, int flags)
1293     throws LibGuestFSException
1294   {
1295     if (g == 0)
1296       throw new LibGuestFSException ("aug_init: handle is closed");
1297     _aug_init (g, root, flags);
1298   }
1299   private native void _aug_init (long g, String root, int flags)
1300     throws LibGuestFSException;
1301
1302   /**
1303    * close the current Augeas handle
1304    * <p>
1305    * Close the current Augeas handle and free up any
1306    * resources used by it. After calling this, you have to
1307    * call "g.aug_init" again before you can use any other
1308    * Augeas functions.
1309    * <p>
1310    * @throws LibGuestFSException
1311    */
1312   public void aug_close ()
1313     throws LibGuestFSException
1314   {
1315     if (g == 0)
1316       throw new LibGuestFSException ("aug_close: handle is closed");
1317     _aug_close (g);
1318   }
1319   private native void _aug_close (long g)
1320     throws LibGuestFSException;
1321
1322   /**
1323    * define an Augeas variable
1324    * <p>
1325    * Defines an Augeas variable "name" whose value is the
1326    * result of evaluating "expr". If "expr" is NULL, then
1327    * "name" is undefined.
1328    * <p>
1329    * On success this returns the number of nodes in "expr",
1330    * or 0 if "expr" evaluates to something which is not a
1331    * nodeset.
1332    * <p>
1333    * @throws LibGuestFSException
1334    */
1335   public int aug_defvar (String name, String expr)
1336     throws LibGuestFSException
1337   {
1338     if (g == 0)
1339       throw new LibGuestFSException ("aug_defvar: handle is closed");
1340     return _aug_defvar (g, name, expr);
1341   }
1342   private native int _aug_defvar (long g, String name, String expr)
1343     throws LibGuestFSException;
1344
1345   /**
1346    * define an Augeas node
1347    * <p>
1348    * Defines a variable "name" whose value is the result of
1349    * evaluating "expr".
1350    * <p>
1351    * If "expr" evaluates to an empty nodeset, a node is
1352    * created, equivalent to calling "g.aug_set" "expr",
1353    * "value". "name" will be the nodeset containing that
1354    * single node.
1355    * <p>
1356    * On success this returns a pair containing the number of
1357    * nodes in the nodeset, and a boolean flag if a node was
1358    * created.
1359    * <p>
1360    * @throws LibGuestFSException
1361    */
1362   public IntBool aug_defnode (String name, String expr, String val)
1363     throws LibGuestFSException
1364   {
1365     if (g == 0)
1366       throw new LibGuestFSException ("aug_defnode: handle is closed");
1367     return _aug_defnode (g, name, expr, val);
1368   }
1369   private native IntBool _aug_defnode (long g, String name, String expr, String val)
1370     throws LibGuestFSException;
1371
1372   /**
1373    * look up the value of an Augeas path
1374    * <p>
1375    * Look up the value associated with "path". If "path"
1376    * matches exactly one node, the "value" is returned.
1377    * <p>
1378    * @throws LibGuestFSException
1379    */
1380   public String aug_get (String path)
1381     throws LibGuestFSException
1382   {
1383     if (g == 0)
1384       throw new LibGuestFSException ("aug_get: handle is closed");
1385     return _aug_get (g, path);
1386   }
1387   private native String _aug_get (long g, String path)
1388     throws LibGuestFSException;
1389
1390   /**
1391    * set Augeas path to value
1392    * <p>
1393    * Set the value associated with "path" to "value".
1394    * <p>
1395    * @throws LibGuestFSException
1396    */
1397   public void aug_set (String path, String val)
1398     throws LibGuestFSException
1399   {
1400     if (g == 0)
1401       throw new LibGuestFSException ("aug_set: handle is closed");
1402     _aug_set (g, path, val);
1403   }
1404   private native void _aug_set (long g, String path, String val)
1405     throws LibGuestFSException;
1406
1407   /**
1408    * insert a sibling Augeas node
1409    * <p>
1410    * Create a new sibling "label" for "path", inserting it
1411    * into the tree before or after "path" (depending on the
1412    * boolean flag "before").
1413    * <p>
1414    * "path" must match exactly one existing node in the tree,
1415    * and "label" must be a label, ie. not contain "/", "*" or
1416    * end with a bracketed index "[N]".
1417    * <p>
1418    * @throws LibGuestFSException
1419    */
1420   public void aug_insert (String path, String label, boolean before)
1421     throws LibGuestFSException
1422   {
1423     if (g == 0)
1424       throw new LibGuestFSException ("aug_insert: handle is closed");
1425     _aug_insert (g, path, label, before);
1426   }
1427   private native void _aug_insert (long g, String path, String label, boolean before)
1428     throws LibGuestFSException;
1429
1430   /**
1431    * remove an Augeas path
1432    * <p>
1433    * Remove "path" and all of its children.
1434    * <p>
1435    * On success this returns the number of entries which were
1436    * removed.
1437    * <p>
1438    * @throws LibGuestFSException
1439    */
1440   public int aug_rm (String path)
1441     throws LibGuestFSException
1442   {
1443     if (g == 0)
1444       throw new LibGuestFSException ("aug_rm: handle is closed");
1445     return _aug_rm (g, path);
1446   }
1447   private native int _aug_rm (long g, String path)
1448     throws LibGuestFSException;
1449
1450   /**
1451    * move Augeas node
1452    * <p>
1453    * Move the node "src" to "dest". "src" must match exactly
1454    * one node. "dest" is overwritten if it exists.
1455    * <p>
1456    * @throws LibGuestFSException
1457    */
1458   public void aug_mv (String src, String dest)
1459     throws LibGuestFSException
1460   {
1461     if (g == 0)
1462       throw new LibGuestFSException ("aug_mv: handle is closed");
1463     _aug_mv (g, src, dest);
1464   }
1465   private native void _aug_mv (long g, String src, String dest)
1466     throws LibGuestFSException;
1467
1468   /**
1469    * return Augeas nodes which match path
1470    * <p>
1471    * Returns a list of paths which match the path expression
1472    * "path". The returned paths are sufficiently qualified so
1473    * that they match exactly one node in the current tree.
1474    * <p>
1475    * @throws LibGuestFSException
1476    */
1477   public String[] aug_match (String path)
1478     throws LibGuestFSException
1479   {
1480     if (g == 0)
1481       throw new LibGuestFSException ("aug_match: handle is closed");
1482     return _aug_match (g, path);
1483   }
1484   private native String[] _aug_match (long g, String path)
1485     throws LibGuestFSException;
1486
1487   /**
1488    * write all pending Augeas changes to disk
1489    * <p>
1490    * This writes all pending changes to disk.
1491    * <p>
1492    * The flags which were passed to "g.aug_init" affect
1493    * exactly how files are saved.
1494    * <p>
1495    * @throws LibGuestFSException
1496    */
1497   public void aug_save ()
1498     throws LibGuestFSException
1499   {
1500     if (g == 0)
1501       throw new LibGuestFSException ("aug_save: handle is closed");
1502     _aug_save (g);
1503   }
1504   private native void _aug_save (long g)
1505     throws LibGuestFSException;
1506
1507   /**
1508    * load files into the tree
1509    * <p>
1510    * Load files into the tree.
1511    * <p>
1512    * See "aug_load" in the Augeas documentation for the full
1513    * gory details.
1514    * <p>
1515    * @throws LibGuestFSException
1516    */
1517   public void aug_load ()
1518     throws LibGuestFSException
1519   {
1520     if (g == 0)
1521       throw new LibGuestFSException ("aug_load: handle is closed");
1522     _aug_load (g);
1523   }
1524   private native void _aug_load (long g)
1525     throws LibGuestFSException;
1526
1527   /**
1528    * list Augeas nodes under a path
1529    * <p>
1530    * This is just a shortcut for listing "g.aug_match"
1531    * "path/*" and sorting the resulting nodes into
1532    * alphabetical order.
1533    * <p>
1534    * @throws LibGuestFSException
1535    */
1536   public String[] aug_ls (String path)
1537     throws LibGuestFSException
1538   {
1539     if (g == 0)
1540       throw new LibGuestFSException ("aug_ls: handle is closed");
1541     return _aug_ls (g, path);
1542   }
1543   private native String[] _aug_ls (long g, String path)
1544     throws LibGuestFSException;
1545
1546   /**
1547    * remove a file
1548    * <p>
1549    * Remove the single file "path".
1550    * <p>
1551    * @throws LibGuestFSException
1552    */
1553   public void rm (String path)
1554     throws LibGuestFSException
1555   {
1556     if (g == 0)
1557       throw new LibGuestFSException ("rm: handle is closed");
1558     _rm (g, path);
1559   }
1560   private native void _rm (long g, String path)
1561     throws LibGuestFSException;
1562
1563   /**
1564    * remove a directory
1565    * <p>
1566    * Remove the single directory "path".
1567    * <p>
1568    * @throws LibGuestFSException
1569    */
1570   public void rmdir (String path)
1571     throws LibGuestFSException
1572   {
1573     if (g == 0)
1574       throw new LibGuestFSException ("rmdir: handle is closed");
1575     _rmdir (g, path);
1576   }
1577   private native void _rmdir (long g, String path)
1578     throws LibGuestFSException;
1579
1580   /**
1581    * remove a file or directory recursively
1582    * <p>
1583    * Remove the file or directory "path", recursively
1584    * removing the contents if its a directory. This is like
1585    * the "rm -rf" shell command.
1586    * <p>
1587    * @throws LibGuestFSException
1588    */
1589   public void rm_rf (String path)
1590     throws LibGuestFSException
1591   {
1592     if (g == 0)
1593       throw new LibGuestFSException ("rm_rf: handle is closed");
1594     _rm_rf (g, path);
1595   }
1596   private native void _rm_rf (long g, String path)
1597     throws LibGuestFSException;
1598
1599   /**
1600    * create a directory
1601    * <p>
1602    * Create a directory named "path".
1603    * <p>
1604    * @throws LibGuestFSException
1605    */
1606   public void mkdir (String path)
1607     throws LibGuestFSException
1608   {
1609     if (g == 0)
1610       throw new LibGuestFSException ("mkdir: handle is closed");
1611     _mkdir (g, path);
1612   }
1613   private native void _mkdir (long g, String path)
1614     throws LibGuestFSException;
1615
1616   /**
1617    * create a directory and parents
1618    * <p>
1619    * Create a directory named "path", creating any parent
1620    * directories as necessary. This is like the "mkdir -p"
1621    * shell command.
1622    * <p>
1623    * @throws LibGuestFSException
1624    */
1625   public void mkdir_p (String path)
1626     throws LibGuestFSException
1627   {
1628     if (g == 0)
1629       throw new LibGuestFSException ("mkdir_p: handle is closed");
1630     _mkdir_p (g, path);
1631   }
1632   private native void _mkdir_p (long g, String path)
1633     throws LibGuestFSException;
1634
1635   /**
1636    * change file mode
1637    * <p>
1638    * Change the mode (permissions) of "path" to "mode". Only
1639    * numeric modes are supported.
1640    * <p>
1641    * @throws LibGuestFSException
1642    */
1643   public void chmod (int mode, String path)
1644     throws LibGuestFSException
1645   {
1646     if (g == 0)
1647       throw new LibGuestFSException ("chmod: handle is closed");
1648     _chmod (g, mode, path);
1649   }
1650   private native void _chmod (long g, int mode, String path)
1651     throws LibGuestFSException;
1652
1653   /**
1654    * change file owner and group
1655    * <p>
1656    * Change the file owner to "owner" and group to "group".
1657    * <p>
1658    * Only numeric uid and gid are supported. If you want to
1659    * use names, you will need to locate and parse the
1660    * password file yourself (Augeas support makes this
1661    * relatively easy).
1662    * <p>
1663    * @throws LibGuestFSException
1664    */
1665   public void chown (int owner, int group, String path)
1666     throws LibGuestFSException
1667   {
1668     if (g == 0)
1669       throw new LibGuestFSException ("chown: handle is closed");
1670     _chown (g, owner, group, path);
1671   }
1672   private native void _chown (long g, int owner, int group, String path)
1673     throws LibGuestFSException;
1674
1675   /**
1676    * test if file or directory exists
1677    * <p>
1678    * This returns "true" if and only if there is a file,
1679    * directory (or anything) with the given "path" name.
1680    * <p>
1681    * See also "g.is_file", "g.is_dir", "g.stat".
1682    * <p>
1683    * @throws LibGuestFSException
1684    */
1685   public boolean exists (String path)
1686     throws LibGuestFSException
1687   {
1688     if (g == 0)
1689       throw new LibGuestFSException ("exists: handle is closed");
1690     return _exists (g, path);
1691   }
1692   private native boolean _exists (long g, String path)
1693     throws LibGuestFSException;
1694
1695   /**
1696    * test if file exists
1697    * <p>
1698    * This returns "true" if and only if there is a file with
1699    * the given "path" name. Note that it returns false for
1700    * other objects like directories.
1701    * <p>
1702    * See also "g.stat".
1703    * <p>
1704    * @throws LibGuestFSException
1705    */
1706   public boolean is_file (String path)
1707     throws LibGuestFSException
1708   {
1709     if (g == 0)
1710       throw new LibGuestFSException ("is_file: handle is closed");
1711     return _is_file (g, path);
1712   }
1713   private native boolean _is_file (long g, String path)
1714     throws LibGuestFSException;
1715
1716   /**
1717    * test if file exists
1718    * <p>
1719    * This returns "true" if and only if there is a directory
1720    * with the given "path" name. Note that it returns false
1721    * for other objects like files.
1722    * <p>
1723    * See also "g.stat".
1724    * <p>
1725    * @throws LibGuestFSException
1726    */
1727   public boolean is_dir (String path)
1728     throws LibGuestFSException
1729   {
1730     if (g == 0)
1731       throw new LibGuestFSException ("is_dir: handle is closed");
1732     return _is_dir (g, path);
1733   }
1734   private native boolean _is_dir (long g, String path)
1735     throws LibGuestFSException;
1736
1737   /**
1738    * create an LVM physical volume
1739    * <p>
1740    * This creates an LVM physical volume on the named
1741    * "device", where "device" should usually be a partition
1742    * name such as "/dev/sda1".
1743    * <p>
1744    * @throws LibGuestFSException
1745    */
1746   public void pvcreate (String device)
1747     throws LibGuestFSException
1748   {
1749     if (g == 0)
1750       throw new LibGuestFSException ("pvcreate: handle is closed");
1751     _pvcreate (g, device);
1752   }
1753   private native void _pvcreate (long g, String device)
1754     throws LibGuestFSException;
1755
1756   /**
1757    * create an LVM volume group
1758    * <p>
1759    * This creates an LVM volume group called "volgroup" from
1760    * the non-empty list of physical volumes "physvols".
1761    * <p>
1762    * @throws LibGuestFSException
1763    */
1764   public void vgcreate (String volgroup, String[] physvols)
1765     throws LibGuestFSException
1766   {
1767     if (g == 0)
1768       throw new LibGuestFSException ("vgcreate: handle is closed");
1769     _vgcreate (g, volgroup, physvols);
1770   }
1771   private native void _vgcreate (long g, String volgroup, String[] physvols)
1772     throws LibGuestFSException;
1773
1774   /**
1775    * create an LVM volume group
1776    * <p>
1777    * This creates an LVM volume group called "logvol" on the
1778    * volume group "volgroup", with "size" megabytes.
1779    * <p>
1780    * @throws LibGuestFSException
1781    */
1782   public void lvcreate (String logvol, String volgroup, int mbytes)
1783     throws LibGuestFSException
1784   {
1785     if (g == 0)
1786       throw new LibGuestFSException ("lvcreate: handle is closed");
1787     _lvcreate (g, logvol, volgroup, mbytes);
1788   }
1789   private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1790     throws LibGuestFSException;
1791
1792   /**
1793    * make a filesystem
1794    * <p>
1795    * This creates a filesystem on "device" (usually a
1796    * partition or LVM logical volume). The filesystem type is
1797    * "fstype", for example "ext3".
1798    * <p>
1799    * @throws LibGuestFSException
1800    */
1801   public void mkfs (String fstype, String device)
1802     throws LibGuestFSException
1803   {
1804     if (g == 0)
1805       throw new LibGuestFSException ("mkfs: handle is closed");
1806     _mkfs (g, fstype, device);
1807   }
1808   private native void _mkfs (long g, String fstype, String device)
1809     throws LibGuestFSException;
1810
1811   /**
1812    * create partitions on a block device
1813    * <p>
1814    * This is a direct interface to the sfdisk(8) program for
1815    * creating partitions on block devices.
1816    * <p>
1817    * "device" should be a block device, for example
1818    * "/dev/sda".
1819    * <p>
1820    * "cyls", "heads" and "sectors" are the number of
1821    * cylinders, heads and sectors on the device, which are
1822    * passed directly to sfdisk as the *-C*, *-H* and *-S*
1823    * parameters. If you pass 0 for any of these, then the
1824    * corresponding parameter is omitted. Usually for 'large'
1825    * disks, you can just pass 0 for these, but for small
1826    * (floppy-sized) disks, sfdisk (or rather, the kernel)
1827    * cannot work out the right geometry and you will need to
1828    * tell it.
1829    * <p>
1830    * "lines" is a list of lines that we feed to "sfdisk". For
1831    * more information refer to the sfdisk(8) manpage.
1832    * <p>
1833    * To create a single partition occupying the whole disk,
1834    * you would pass "lines" as a single element list, when
1835    * the single element being the string "," (comma).
1836    * <p>
1837    * See also: "g.sfdisk_l", "g.sfdisk_N"
1838    * <p>
1839    * This command is dangerous. Without careful use you can
1840    * easily destroy all your data.
1841    * <p>
1842    * @throws LibGuestFSException
1843    */
1844   public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1845     throws LibGuestFSException
1846   {
1847     if (g == 0)
1848       throw new LibGuestFSException ("sfdisk: handle is closed");
1849     _sfdisk (g, device, cyls, heads, sectors, lines);
1850   }
1851   private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1852     throws LibGuestFSException;
1853
1854   /**
1855    * create a file
1856    * <p>
1857    * This call creates a file called "path". The contents of
1858    * the file is the string "content" (which can contain any
1859    * 8 bit data), with length "size".
1860    * <p>
1861    * As a special case, if "size" is 0 then the length is
1862    * calculated using "strlen" (so in this case the content
1863    * cannot contain embedded ASCII NULs).
1864    * <p>
1865    * *NB.* Owing to a bug, writing content containing ASCII
1866    * NUL characters does *not* work, even if the length is
1867    * specified. We hope to resolve this bug in a future
1868    * version. In the meantime use "g.upload".
1869    * <p>
1870    * Because of the message protocol, there is a transfer
1871    * limit of somewhere between 2MB and 4MB. To transfer
1872    * large files you should use FTP.
1873    * <p>
1874    * @throws LibGuestFSException
1875    */
1876   public void write_file (String path, String content, int size)
1877     throws LibGuestFSException
1878   {
1879     if (g == 0)
1880       throw new LibGuestFSException ("write_file: handle is closed");
1881     _write_file (g, path, content, size);
1882   }
1883   private native void _write_file (long g, String path, String content, int size)
1884     throws LibGuestFSException;
1885
1886   /**
1887    * unmount a filesystem
1888    * <p>
1889    * This unmounts the given filesystem. The filesystem may
1890    * be specified either by its mountpoint (path) or the
1891    * device which contains the filesystem.
1892    * <p>
1893    * @throws LibGuestFSException
1894    */
1895   public void umount (String pathordevice)
1896     throws LibGuestFSException
1897   {
1898     if (g == 0)
1899       throw new LibGuestFSException ("umount: handle is closed");
1900     _umount (g, pathordevice);
1901   }
1902   private native void _umount (long g, String pathordevice)
1903     throws LibGuestFSException;
1904
1905   /**
1906    * show mounted filesystems
1907    * <p>
1908    * This returns the list of currently mounted filesystems.
1909    * It returns the list of devices (eg. "/dev/sda1",
1910    * "/dev/VG/LV").
1911    * <p>
1912    * Some internal mounts are not shown.
1913    * <p>
1914    * @throws LibGuestFSException
1915    */
1916   public String[] mounts ()
1917     throws LibGuestFSException
1918   {
1919     if (g == 0)
1920       throw new LibGuestFSException ("mounts: handle is closed");
1921     return _mounts (g);
1922   }
1923   private native String[] _mounts (long g)
1924     throws LibGuestFSException;
1925
1926   /**
1927    * unmount all filesystems
1928    * <p>
1929    * This unmounts all mounted filesystems.
1930    * <p>
1931    * Some internal mounts are not unmounted by this call.
1932    * <p>
1933    * @throws LibGuestFSException
1934    */
1935   public void umount_all ()
1936     throws LibGuestFSException
1937   {
1938     if (g == 0)
1939       throw new LibGuestFSException ("umount_all: handle is closed");
1940     _umount_all (g);
1941   }
1942   private native void _umount_all (long g)
1943     throws LibGuestFSException;
1944
1945   /**
1946    * remove all LVM LVs, VGs and PVs
1947    * <p>
1948    * This command removes all LVM logical volumes, volume
1949    * groups and physical volumes.
1950    * <p>
1951    * This command is dangerous. Without careful use you can
1952    * easily destroy all your data.
1953    * <p>
1954    * @throws LibGuestFSException
1955    */
1956   public void lvm_remove_all ()
1957     throws LibGuestFSException
1958   {
1959     if (g == 0)
1960       throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1961     _lvm_remove_all (g);
1962   }
1963   private native void _lvm_remove_all (long g)
1964     throws LibGuestFSException;
1965
1966   /**
1967    * determine file type
1968    * <p>
1969    * This call uses the standard file(1) command to determine
1970    * the type or contents of the file. This also works on
1971    * devices, for example to find out whether a partition
1972    * contains a filesystem.
1973    * <p>
1974    * The exact command which runs is "file -bsL path". Note
1975    * in particular that the filename is not prepended to the
1976    * output (the "-b" option).
1977    * <p>
1978    * @throws LibGuestFSException
1979    */
1980   public String file (String path)
1981     throws LibGuestFSException
1982   {
1983     if (g == 0)
1984       throw new LibGuestFSException ("file: handle is closed");
1985     return _file (g, path);
1986   }
1987   private native String _file (long g, String path)
1988     throws LibGuestFSException;
1989
1990   /**
1991    * run a command from the guest filesystem
1992    * <p>
1993    * This call runs a command from the guest filesystem. The
1994    * filesystem must be mounted, and must contain a
1995    * compatible operating system (ie. something Linux, with
1996    * the same or compatible processor architecture).
1997    * <p>
1998    * The single parameter is an argv-style list of arguments.
1999    * The first element is the name of the program to run.
2000    * Subsequent elements are parameters. The list must be
2001    * non-empty (ie. must contain a program name). Note that
2002    * the command runs directly, and is *not* invoked via the
2003    * shell (see "g.sh").
2004    * <p>
2005    * The return value is anything printed to *stdout* by the
2006    * command.
2007    * <p>
2008    * If the command returns a non-zero exit status, then this
2009    * function returns an error message. The error message
2010    * string is the content of *stderr* from the command.
2011    * <p>
2012    * The $PATH environment variable will contain at least
2013    * "/usr/bin" and "/bin". If you require a program from
2014    * another location, you should provide the full path in
2015    * the first parameter.
2016    * <p>
2017    * Shared libraries and data files required by the program
2018    * must be available on filesystems which are mounted in
2019    * the correct places. It is the caller's responsibility to
2020    * ensure all filesystems that are needed are mounted at
2021    * the right locations.
2022    * <p>
2023    * Because of the message protocol, there is a transfer
2024    * limit of somewhere between 2MB and 4MB. To transfer
2025    * large files you should use FTP.
2026    * <p>
2027    * @throws LibGuestFSException
2028    */
2029   public String command (String[] arguments)
2030     throws LibGuestFSException
2031   {
2032     if (g == 0)
2033       throw new LibGuestFSException ("command: handle is closed");
2034     return _command (g, arguments);
2035   }
2036   private native String _command (long g, String[] arguments)
2037     throws LibGuestFSException;
2038
2039   /**
2040    * run a command, returning lines
2041    * <p>
2042    * This is the same as "g.command", but splits the result
2043    * into a list of lines.
2044    * <p>
2045    * See also: "g.sh_lines"
2046    * <p>
2047    * Because of the message protocol, there is a transfer
2048    * limit of somewhere between 2MB and 4MB. To transfer
2049    * large files you should use FTP.
2050    * <p>
2051    * @throws LibGuestFSException
2052    */
2053   public String[] command_lines (String[] arguments)
2054     throws LibGuestFSException
2055   {
2056     if (g == 0)
2057       throw new LibGuestFSException ("command_lines: handle is closed");
2058     return _command_lines (g, arguments);
2059   }
2060   private native String[] _command_lines (long g, String[] arguments)
2061     throws LibGuestFSException;
2062
2063   /**
2064    * get file information
2065    * <p>
2066    * Returns file information for the given "path".
2067    * <p>
2068    * This is the same as the stat(2) system call.
2069    * <p>
2070    * @throws LibGuestFSException
2071    */
2072   public Stat stat (String path)
2073     throws LibGuestFSException
2074   {
2075     if (g == 0)
2076       throw new LibGuestFSException ("stat: handle is closed");
2077     return _stat (g, path);
2078   }
2079   private native Stat _stat (long g, String path)
2080     throws LibGuestFSException;
2081
2082   /**
2083    * get file information for a symbolic link
2084    * <p>
2085    * Returns file information for the given "path".
2086    * <p>
2087    * This is the same as "g.stat" except that if "path" is a
2088    * symbolic link, then the link is stat-ed, not the file it
2089    * refers to.
2090    * <p>
2091    * This is the same as the lstat(2) system call.
2092    * <p>
2093    * @throws LibGuestFSException
2094    */
2095   public Stat lstat (String path)
2096     throws LibGuestFSException
2097   {
2098     if (g == 0)
2099       throw new LibGuestFSException ("lstat: handle is closed");
2100     return _lstat (g, path);
2101   }
2102   private native Stat _lstat (long g, String path)
2103     throws LibGuestFSException;
2104
2105   /**
2106    * get file system statistics
2107    * <p>
2108    * Returns file system statistics for any mounted file
2109    * system. "path" should be a file or directory in the
2110    * mounted file system (typically it is the mount point
2111    * itself, but it doesn't need to be).
2112    * <p>
2113    * This is the same as the statvfs(2) system call.
2114    * <p>
2115    * @throws LibGuestFSException
2116    */
2117   public StatVFS statvfs (String path)
2118     throws LibGuestFSException
2119   {
2120     if (g == 0)
2121       throw new LibGuestFSException ("statvfs: handle is closed");
2122     return _statvfs (g, path);
2123   }
2124   private native StatVFS _statvfs (long g, String path)
2125     throws LibGuestFSException;
2126
2127   /**
2128    * get ext2/ext3/ext4 superblock details
2129    * <p>
2130    * This returns the contents of the ext2, ext3 or ext4
2131    * filesystem superblock on "device".
2132    * <p>
2133    * It is the same as running "tune2fs -l device". See
2134    * tune2fs(8) manpage for more details. The list of fields
2135    * returned isn't clearly defined, and depends on both the
2136    * version of "tune2fs" that libguestfs was built against,
2137    * and the filesystem itself.
2138    * <p>
2139    * @throws LibGuestFSException
2140    */
2141   public HashMap<String,String> tune2fs_l (String device)
2142     throws LibGuestFSException
2143   {
2144     if (g == 0)
2145       throw new LibGuestFSException ("tune2fs_l: handle is closed");
2146     return _tune2fs_l (g, device);
2147   }
2148   private native HashMap<String,String> _tune2fs_l (long g, String device)
2149     throws LibGuestFSException;
2150
2151   /**
2152    * set block device to read-only
2153    * <p>
2154    * Sets the block device named "device" to read-only.
2155    * <p>
2156    * This uses the blockdev(8) command.
2157    * <p>
2158    * @throws LibGuestFSException
2159    */
2160   public void blockdev_setro (String device)
2161     throws LibGuestFSException
2162   {
2163     if (g == 0)
2164       throw new LibGuestFSException ("blockdev_setro: handle is closed");
2165     _blockdev_setro (g, device);
2166   }
2167   private native void _blockdev_setro (long g, String device)
2168     throws LibGuestFSException;
2169
2170   /**
2171    * set block device to read-write
2172    * <p>
2173    * Sets the block device named "device" to read-write.
2174    * <p>
2175    * This uses the blockdev(8) command.
2176    * <p>
2177    * @throws LibGuestFSException
2178    */
2179   public void blockdev_setrw (String device)
2180     throws LibGuestFSException
2181   {
2182     if (g == 0)
2183       throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2184     _blockdev_setrw (g, device);
2185   }
2186   private native void _blockdev_setrw (long g, String device)
2187     throws LibGuestFSException;
2188
2189   /**
2190    * is block device set to read-only
2191    * <p>
2192    * Returns a boolean indicating if the block device is
2193    * read-only (true if read-only, false if not).
2194    * <p>
2195    * This uses the blockdev(8) command.
2196    * <p>
2197    * @throws LibGuestFSException
2198    */
2199   public boolean blockdev_getro (String device)
2200     throws LibGuestFSException
2201   {
2202     if (g == 0)
2203       throw new LibGuestFSException ("blockdev_getro: handle is closed");
2204     return _blockdev_getro (g, device);
2205   }
2206   private native boolean _blockdev_getro (long g, String device)
2207     throws LibGuestFSException;
2208
2209   /**
2210    * get sectorsize of block device
2211    * <p>
2212    * This returns the size of sectors on a block device.
2213    * Usually 512, but can be larger for modern devices.
2214    * <p>
2215    * (Note, this is not the size in sectors, use
2216    * "g.blockdev_getsz" for that).
2217    * <p>
2218    * This uses the blockdev(8) command.
2219    * <p>
2220    * @throws LibGuestFSException
2221    */
2222   public int blockdev_getss (String device)
2223     throws LibGuestFSException
2224   {
2225     if (g == 0)
2226       throw new LibGuestFSException ("blockdev_getss: handle is closed");
2227     return _blockdev_getss (g, device);
2228   }
2229   private native int _blockdev_getss (long g, String device)
2230     throws LibGuestFSException;
2231
2232   /**
2233    * get blocksize of block device
2234    * <p>
2235    * This returns the block size of a device.
2236    * <p>
2237    * (Note this is different from both *size in blocks* and
2238    * *filesystem block size*).
2239    * <p>
2240    * This uses the blockdev(8) command.
2241    * <p>
2242    * @throws LibGuestFSException
2243    */
2244   public int blockdev_getbsz (String device)
2245     throws LibGuestFSException
2246   {
2247     if (g == 0)
2248       throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2249     return _blockdev_getbsz (g, device);
2250   }
2251   private native int _blockdev_getbsz (long g, String device)
2252     throws LibGuestFSException;
2253
2254   /**
2255    * set blocksize of block device
2256    * <p>
2257    * This sets the block size of a device.
2258    * <p>
2259    * (Note this is different from both *size in blocks* and
2260    * *filesystem block size*).
2261    * <p>
2262    * This uses the blockdev(8) command.
2263    * <p>
2264    * @throws LibGuestFSException
2265    */
2266   public void blockdev_setbsz (String device, int blocksize)
2267     throws LibGuestFSException
2268   {
2269     if (g == 0)
2270       throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2271     _blockdev_setbsz (g, device, blocksize);
2272   }
2273   private native void _blockdev_setbsz (long g, String device, int blocksize)
2274     throws LibGuestFSException;
2275
2276   /**
2277    * get total size of device in 512-byte sectors
2278    * <p>
2279    * This returns the size of the device in units of 512-byte
2280    * sectors (even if the sectorsize isn't 512 bytes ...
2281    * weird).
2282    * <p>
2283    * See also "g.blockdev_getss" for the real sector size of
2284    * the device, and "g.blockdev_getsize64" for the more
2285    * useful *size in bytes*.
2286    * <p>
2287    * This uses the blockdev(8) command.
2288    * <p>
2289    * @throws LibGuestFSException
2290    */
2291   public long blockdev_getsz (String device)
2292     throws LibGuestFSException
2293   {
2294     if (g == 0)
2295       throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2296     return _blockdev_getsz (g, device);
2297   }
2298   private native long _blockdev_getsz (long g, String device)
2299     throws LibGuestFSException;
2300
2301   /**
2302    * get total size of device in bytes
2303    * <p>
2304    * This returns the size of the device in bytes.
2305    * <p>
2306    * See also "g.blockdev_getsz".
2307    * <p>
2308    * This uses the blockdev(8) command.
2309    * <p>
2310    * @throws LibGuestFSException
2311    */
2312   public long blockdev_getsize64 (String device)
2313     throws LibGuestFSException
2314   {
2315     if (g == 0)
2316       throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2317     return _blockdev_getsize64 (g, device);
2318   }
2319   private native long _blockdev_getsize64 (long g, String device)
2320     throws LibGuestFSException;
2321
2322   /**
2323    * flush device buffers
2324    * <p>
2325    * This tells the kernel to flush internal buffers
2326    * associated with "device".
2327    * <p>
2328    * This uses the blockdev(8) command.
2329    * <p>
2330    * @throws LibGuestFSException
2331    */
2332   public void blockdev_flushbufs (String device)
2333     throws LibGuestFSException
2334   {
2335     if (g == 0)
2336       throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2337     _blockdev_flushbufs (g, device);
2338   }
2339   private native void _blockdev_flushbufs (long g, String device)
2340     throws LibGuestFSException;
2341
2342   /**
2343    * reread partition table
2344    * <p>
2345    * Reread the partition table on "device".
2346    * <p>
2347    * This uses the blockdev(8) command.
2348    * <p>
2349    * @throws LibGuestFSException
2350    */
2351   public void blockdev_rereadpt (String device)
2352     throws LibGuestFSException
2353   {
2354     if (g == 0)
2355       throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2356     _blockdev_rereadpt (g, device);
2357   }
2358   private native void _blockdev_rereadpt (long g, String device)
2359     throws LibGuestFSException;
2360
2361   /**
2362    * upload a file from the local machine
2363    * <p>
2364    * Upload local file "filename" to "remotefilename" on the
2365    * filesystem.
2366    * <p>
2367    * "filename" can also be a named pipe.
2368    * <p>
2369    * See also "g.download".
2370    * <p>
2371    * @throws LibGuestFSException
2372    */
2373   public void upload (String filename, String remotefilename)
2374     throws LibGuestFSException
2375   {
2376     if (g == 0)
2377       throw new LibGuestFSException ("upload: handle is closed");
2378     _upload (g, filename, remotefilename);
2379   }
2380   private native void _upload (long g, String filename, String remotefilename)
2381     throws LibGuestFSException;
2382
2383   /**
2384    * download a file to the local machine
2385    * <p>
2386    * Download file "remotefilename" and save it as "filename"
2387    * on the local machine.
2388    * <p>
2389    * "filename" can also be a named pipe.
2390    * <p>
2391    * See also "g.upload", "g.cat".
2392    * <p>
2393    * @throws LibGuestFSException
2394    */
2395   public void download (String remotefilename, String filename)
2396     throws LibGuestFSException
2397   {
2398     if (g == 0)
2399       throw new LibGuestFSException ("download: handle is closed");
2400     _download (g, remotefilename, filename);
2401   }
2402   private native void _download (long g, String remotefilename, String filename)
2403     throws LibGuestFSException;
2404
2405   /**
2406    * compute MD5, SHAx or CRC checksum of file
2407    * <p>
2408    * This call computes the MD5, SHAx or CRC checksum of the
2409    * file named "path".
2410    * <p>
2411    * The type of checksum to compute is given by the
2412    * "csumtype" parameter which must have one of the
2413    * following values:
2414    * <p>
2415    * "crc"
2416    * Compute the cyclic redundancy check (CRC) specified
2417    * by POSIX for the "cksum" command.
2418    * <p>
2419    * "md5"
2420    * Compute the MD5 hash (using the "md5sum" program).
2421    * <p>
2422    * "sha1"
2423    * Compute the SHA1 hash (using the "sha1sum" program).
2424    * <p>
2425    * "sha224"
2426    * Compute the SHA224 hash (using the "sha224sum"
2427    * program).
2428    * <p>
2429    * "sha256"
2430    * Compute the SHA256 hash (using the "sha256sum"
2431    * program).
2432    * <p>
2433    * "sha384"
2434    * Compute the SHA384 hash (using the "sha384sum"
2435    * program).
2436    * <p>
2437    * "sha512"
2438    * Compute the SHA512 hash (using the "sha512sum"
2439    * program).
2440    * <p>
2441    * The checksum is returned as a printable string.
2442    * <p>
2443    * @throws LibGuestFSException
2444    */
2445   public String checksum (String csumtype, String path)
2446     throws LibGuestFSException
2447   {
2448     if (g == 0)
2449       throw new LibGuestFSException ("checksum: handle is closed");
2450     return _checksum (g, csumtype, path);
2451   }
2452   private native String _checksum (long g, String csumtype, String path)
2453     throws LibGuestFSException;
2454
2455   /**
2456    * unpack tarfile to directory
2457    * <p>
2458    * This command uploads and unpacks local file "tarfile"
2459    * (an *uncompressed* tar file) into "directory".
2460    * <p>
2461    * To upload a compressed tarball, use "g.tgz_in".
2462    * <p>
2463    * @throws LibGuestFSException
2464    */
2465   public void tar_in (String tarfile, String directory)
2466     throws LibGuestFSException
2467   {
2468     if (g == 0)
2469       throw new LibGuestFSException ("tar_in: handle is closed");
2470     _tar_in (g, tarfile, directory);
2471   }
2472   private native void _tar_in (long g, String tarfile, String directory)
2473     throws LibGuestFSException;
2474
2475   /**
2476    * pack directory into tarfile
2477    * <p>
2478    * This command packs the contents of "directory" and
2479    * downloads it to local file "tarfile".
2480    * <p>
2481    * To download a compressed tarball, use "g.tgz_out".
2482    * <p>
2483    * @throws LibGuestFSException
2484    */
2485   public void tar_out (String directory, String tarfile)
2486     throws LibGuestFSException
2487   {
2488     if (g == 0)
2489       throw new LibGuestFSException ("tar_out: handle is closed");
2490     _tar_out (g, directory, tarfile);
2491   }
2492   private native void _tar_out (long g, String directory, String tarfile)
2493     throws LibGuestFSException;
2494
2495   /**
2496    * unpack compressed tarball to directory
2497    * <p>
2498    * This command uploads and unpacks local file "tarball" (a
2499    * *gzip compressed* tar file) into "directory".
2500    * <p>
2501    * To upload an uncompressed tarball, use "g.tar_in".
2502    * <p>
2503    * @throws LibGuestFSException
2504    */
2505   public void tgz_in (String tarball, String directory)
2506     throws LibGuestFSException
2507   {
2508     if (g == 0)
2509       throw new LibGuestFSException ("tgz_in: handle is closed");
2510     _tgz_in (g, tarball, directory);
2511   }
2512   private native void _tgz_in (long g, String tarball, String directory)
2513     throws LibGuestFSException;
2514
2515   /**
2516    * pack directory into compressed tarball
2517    * <p>
2518    * This command packs the contents of "directory" and
2519    * downloads it to local file "tarball".
2520    * <p>
2521    * To download an uncompressed tarball, use "g.tar_out".
2522    * <p>
2523    * @throws LibGuestFSException
2524    */
2525   public void tgz_out (String directory, String tarball)
2526     throws LibGuestFSException
2527   {
2528     if (g == 0)
2529       throw new LibGuestFSException ("tgz_out: handle is closed");
2530     _tgz_out (g, directory, tarball);
2531   }
2532   private native void _tgz_out (long g, String directory, String tarball)
2533     throws LibGuestFSException;
2534
2535   /**
2536    * mount a guest disk, read-only
2537    * <p>
2538    * This is the same as the "g.mount" command, but it mounts
2539    * the filesystem with the read-only (*-o ro*) flag.
2540    * <p>
2541    * @throws LibGuestFSException
2542    */
2543   public void mount_ro (String device, String mountpoint)
2544     throws LibGuestFSException
2545   {
2546     if (g == 0)
2547       throw new LibGuestFSException ("mount_ro: handle is closed");
2548     _mount_ro (g, device, mountpoint);
2549   }
2550   private native void _mount_ro (long g, String device, String mountpoint)
2551     throws LibGuestFSException;
2552
2553   /**
2554    * mount a guest disk with mount options
2555    * <p>
2556    * This is the same as the "g.mount" command, but it allows
2557    * you to set the mount options as for the mount(8) *-o*
2558    * flag.
2559    * <p>
2560    * @throws LibGuestFSException
2561    */
2562   public void mount_options (String options, String device, String mountpoint)
2563     throws LibGuestFSException
2564   {
2565     if (g == 0)
2566       throw new LibGuestFSException ("mount_options: handle is closed");
2567     _mount_options (g, options, device, mountpoint);
2568   }
2569   private native void _mount_options (long g, String options, String device, String mountpoint)
2570     throws LibGuestFSException;
2571
2572   /**
2573    * mount a guest disk with mount options and vfstype
2574    * <p>
2575    * This is the same as the "g.mount" command, but it allows
2576    * you to set both the mount options and the vfstype as for
2577    * the mount(8) *-o* and *-t* flags.
2578    * <p>
2579    * @throws LibGuestFSException
2580    */
2581   public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2582     throws LibGuestFSException
2583   {
2584     if (g == 0)
2585       throw new LibGuestFSException ("mount_vfs: handle is closed");
2586     _mount_vfs (g, options, vfstype, device, mountpoint);
2587   }
2588   private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2589     throws LibGuestFSException;
2590
2591   /**
2592    * debugging and internals
2593    * <p>
2594    * The "g.debug" command exposes some internals of
2595    * "guestfsd" (the guestfs daemon) that runs inside the
2596    * qemu subprocess.
2597    * <p>
2598    * There is no comprehensive help for this command. You
2599    * have to look at the file "daemon/debug.c" in the
2600    * libguestfs source to find out what you can do.
2601    * <p>
2602    * @throws LibGuestFSException
2603    */
2604   public String debug (String subcmd, String[] extraargs)
2605     throws LibGuestFSException
2606   {
2607     if (g == 0)
2608       throw new LibGuestFSException ("debug: handle is closed");
2609     return _debug (g, subcmd, extraargs);
2610   }
2611   private native String _debug (long g, String subcmd, String[] extraargs)
2612     throws LibGuestFSException;
2613
2614   /**
2615    * remove an LVM logical volume
2616    * <p>
2617    * Remove an LVM logical volume "device", where "device" is
2618    * the path to the LV, such as "/dev/VG/LV".
2619    * <p>
2620    * You can also remove all LVs in a volume group by
2621    * specifying the VG name, "/dev/VG".
2622    * <p>
2623    * @throws LibGuestFSException
2624    */
2625   public void lvremove (String device)
2626     throws LibGuestFSException
2627   {
2628     if (g == 0)
2629       throw new LibGuestFSException ("lvremove: handle is closed");
2630     _lvremove (g, device);
2631   }
2632   private native void _lvremove (long g, String device)
2633     throws LibGuestFSException;
2634
2635   /**
2636    * remove an LVM volume group
2637    * <p>
2638    * Remove an LVM volume group "vgname", (for example "VG").
2639    * <p>
2640    * This also forcibly removes all logical volumes in the
2641    * volume group (if any).
2642    * <p>
2643    * @throws LibGuestFSException
2644    */
2645   public void vgremove (String vgname)
2646     throws LibGuestFSException
2647   {
2648     if (g == 0)
2649       throw new LibGuestFSException ("vgremove: handle is closed");
2650     _vgremove (g, vgname);
2651   }
2652   private native void _vgremove (long g, String vgname)
2653     throws LibGuestFSException;
2654
2655   /**
2656    * remove an LVM physical volume
2657    * <p>
2658    * This wipes a physical volume "device" so that LVM will
2659    * no longer recognise it.
2660    * <p>
2661    * The implementation uses the "pvremove" command which
2662    * refuses to wipe physical volumes that contain any volume
2663    * groups, so you have to remove those first.
2664    * <p>
2665    * @throws LibGuestFSException
2666    */
2667   public void pvremove (String device)
2668     throws LibGuestFSException
2669   {
2670     if (g == 0)
2671       throw new LibGuestFSException ("pvremove: handle is closed");
2672     _pvremove (g, device);
2673   }
2674   private native void _pvremove (long g, String device)
2675     throws LibGuestFSException;
2676
2677   /**
2678    * set the ext2/3/4 filesystem label
2679    * <p>
2680    * This sets the ext2/3/4 filesystem label of the
2681    * filesystem on "device" to "label". Filesystem labels are
2682    * limited to 16 characters.
2683    * <p>
2684    * You can use either "g.tune2fs_l" or "g.get_e2label" to
2685    * return the existing label on a filesystem.
2686    * <p>
2687    * @throws LibGuestFSException
2688    */
2689   public void set_e2label (String device, String label)
2690     throws LibGuestFSException
2691   {
2692     if (g == 0)
2693       throw new LibGuestFSException ("set_e2label: handle is closed");
2694     _set_e2label (g, device, label);
2695   }
2696   private native void _set_e2label (long g, String device, String label)
2697     throws LibGuestFSException;
2698
2699   /**
2700    * get the ext2/3/4 filesystem label
2701    * <p>
2702    * This returns the ext2/3/4 filesystem label of the
2703    * filesystem on "device".
2704    * <p>
2705    * @throws LibGuestFSException
2706    */
2707   public String get_e2label (String device)
2708     throws LibGuestFSException
2709   {
2710     if (g == 0)
2711       throw new LibGuestFSException ("get_e2label: handle is closed");
2712     return _get_e2label (g, device);
2713   }
2714   private native String _get_e2label (long g, String device)
2715     throws LibGuestFSException;
2716
2717   /**
2718    * set the ext2/3/4 filesystem UUID
2719    * <p>
2720    * This sets the ext2/3/4 filesystem UUID of the filesystem
2721    * on "device" to "uuid". The format of the UUID and
2722    * alternatives such as "clear", "random" and "time" are
2723    * described in the tune2fs(8) manpage.
2724    * <p>
2725    * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2726    * return the existing UUID of a filesystem.
2727    * <p>
2728    * @throws LibGuestFSException
2729    */
2730   public void set_e2uuid (String device, String uuid)
2731     throws LibGuestFSException
2732   {
2733     if (g == 0)
2734       throw new LibGuestFSException ("set_e2uuid: handle is closed");
2735     _set_e2uuid (g, device, uuid);
2736   }
2737   private native void _set_e2uuid (long g, String device, String uuid)
2738     throws LibGuestFSException;
2739
2740   /**
2741    * get the ext2/3/4 filesystem UUID
2742    * <p>
2743    * This returns the ext2/3/4 filesystem UUID of the
2744    * filesystem on "device".
2745    * <p>
2746    * @throws LibGuestFSException
2747    */
2748   public String get_e2uuid (String device)
2749     throws LibGuestFSException
2750   {
2751     if (g == 0)
2752       throw new LibGuestFSException ("get_e2uuid: handle is closed");
2753     return _get_e2uuid (g, device);
2754   }
2755   private native String _get_e2uuid (long g, String device)
2756     throws LibGuestFSException;
2757
2758   /**
2759    * run the filesystem checker
2760    * <p>
2761    * This runs the filesystem checker (fsck) on "device"
2762    * which should have filesystem type "fstype".
2763    * <p>
2764    * The returned integer is the status. See fsck(8) for the
2765    * list of status codes from "fsck".
2766    * <p>
2767    * Notes:
2768    * <p>
2769    * *   Multiple status codes can be summed together.
2770    * <p>
2771    * *   A non-zero return code can mean "success", for
2772    * example if errors have been corrected on the
2773    * filesystem.
2774    * <p>
2775    * *   Checking or repairing NTFS volumes is not supported
2776    * (by linux-ntfs).
2777    * <p>
2778    * This command is entirely equivalent to running "fsck -a
2779    * -t fstype device".
2780    * <p>
2781    * @throws LibGuestFSException
2782    */
2783   public int fsck (String fstype, String device)
2784     throws LibGuestFSException
2785   {
2786     if (g == 0)
2787       throw new LibGuestFSException ("fsck: handle is closed");
2788     return _fsck (g, fstype, device);
2789   }
2790   private native int _fsck (long g, String fstype, String device)
2791     throws LibGuestFSException;
2792
2793   /**
2794    * write zeroes to the device
2795    * <p>
2796    * This command writes zeroes over the first few blocks of
2797    * "device".
2798    * <p>
2799    * How many blocks are zeroed isn't specified (but it's
2800    * *not* enough to securely wipe the device). It should be
2801    * sufficient to remove any partition tables, filesystem
2802    * superblocks and so on.
2803    * <p>
2804    * @throws LibGuestFSException
2805    */
2806   public void zero (String device)
2807     throws LibGuestFSException
2808   {
2809     if (g == 0)
2810       throw new LibGuestFSException ("zero: handle is closed");
2811     _zero (g, device);
2812   }
2813   private native void _zero (long g, String device)
2814     throws LibGuestFSException;
2815
2816   /**
2817    * install GRUB
2818    * <p>
2819    * This command installs GRUB (the Grand Unified
2820    * Bootloader) on "device", with the root directory being
2821    * "root".
2822    * <p>
2823    * @throws LibGuestFSException
2824    */
2825   public void grub_install (String root, String device)
2826     throws LibGuestFSException
2827   {
2828     if (g == 0)
2829       throw new LibGuestFSException ("grub_install: handle is closed");
2830     _grub_install (g, root, device);
2831   }
2832   private native void _grub_install (long g, String root, String device)
2833     throws LibGuestFSException;
2834
2835   /**
2836    * copy a file
2837    * <p>
2838    * This copies a file from "src" to "dest" where "dest" is
2839    * either a destination filename or destination directory.
2840    * <p>
2841    * @throws LibGuestFSException
2842    */
2843   public void cp (String src, String dest)
2844     throws LibGuestFSException
2845   {
2846     if (g == 0)
2847       throw new LibGuestFSException ("cp: handle is closed");
2848     _cp (g, src, dest);
2849   }
2850   private native void _cp (long g, String src, String dest)
2851     throws LibGuestFSException;
2852
2853   /**
2854    * copy a file or directory recursively
2855    * <p>
2856    * This copies a file or directory from "src" to "dest"
2857    * recursively using the "cp -a" command.
2858    * <p>
2859    * @throws LibGuestFSException
2860    */
2861   public void cp_a (String src, String dest)
2862     throws LibGuestFSException
2863   {
2864     if (g == 0)
2865       throw new LibGuestFSException ("cp_a: handle is closed");
2866     _cp_a (g, src, dest);
2867   }
2868   private native void _cp_a (long g, String src, String dest)
2869     throws LibGuestFSException;
2870
2871   /**
2872    * move a file
2873    * <p>
2874    * This moves a file from "src" to "dest" where "dest" is
2875    * either a destination filename or destination directory.
2876    * <p>
2877    * @throws LibGuestFSException
2878    */
2879   public void mv (String src, String dest)
2880     throws LibGuestFSException
2881   {
2882     if (g == 0)
2883       throw new LibGuestFSException ("mv: handle is closed");
2884     _mv (g, src, dest);
2885   }
2886   private native void _mv (long g, String src, String dest)
2887     throws LibGuestFSException;
2888
2889   /**
2890    * drop kernel page cache, dentries and inodes
2891    * <p>
2892    * This instructs the guest kernel to drop its page cache,
2893    * and/or dentries and inode caches. The parameter
2894    * "whattodrop" tells the kernel what precisely to drop,
2895    * see <http://linux-mm.org/Drop_Caches>
2896    * <p>
2897    * Setting "whattodrop" to 3 should drop everything.
2898    * <p>
2899    * This automatically calls sync(2) before the operation,
2900    * so that the maximum guest memory is freed.
2901    * <p>
2902    * @throws LibGuestFSException
2903    */
2904   public void drop_caches (int whattodrop)
2905     throws LibGuestFSException
2906   {
2907     if (g == 0)
2908       throw new LibGuestFSException ("drop_caches: handle is closed");
2909     _drop_caches (g, whattodrop);
2910   }
2911   private native void _drop_caches (long g, int whattodrop)
2912     throws LibGuestFSException;
2913
2914   /**
2915    * return kernel messages
2916    * <p>
2917    * This returns the kernel messages ("dmesg" output) from
2918    * the guest kernel. This is sometimes useful for extended
2919    * debugging of problems.
2920    * <p>
2921    * Another way to get the same information is to enable
2922    * verbose messages with "g.set_verbose" or by setting the
2923    * environment variable "LIBGUESTFS_DEBUG=1" before running
2924    * the program.
2925    * <p>
2926    * @throws LibGuestFSException
2927    */
2928   public String dmesg ()
2929     throws LibGuestFSException
2930   {
2931     if (g == 0)
2932       throw new LibGuestFSException ("dmesg: handle is closed");
2933     return _dmesg (g);
2934   }
2935   private native String _dmesg (long g)
2936     throws LibGuestFSException;
2937
2938   /**
2939    * ping the guest daemon
2940    * <p>
2941    * This is a test probe into the guestfs daemon running
2942    * inside the qemu subprocess. Calling this function checks
2943    * that the daemon responds to the ping message, without
2944    * affecting the daemon or attached block device(s) in any
2945    * other way.
2946    * <p>
2947    * @throws LibGuestFSException
2948    */
2949   public void ping_daemon ()
2950     throws LibGuestFSException
2951   {
2952     if (g == 0)
2953       throw new LibGuestFSException ("ping_daemon: handle is closed");
2954     _ping_daemon (g);
2955   }
2956   private native void _ping_daemon (long g)
2957     throws LibGuestFSException;
2958
2959   /**
2960    * test if two files have equal contents
2961    * <p>
2962    * This compares the two files "file1" and "file2" and
2963    * returns true if their content is exactly equal, or false
2964    * otherwise.
2965    * <p>
2966    * The external cmp(1) program is used for the comparison.
2967    * <p>
2968    * @throws LibGuestFSException
2969    */
2970   public boolean equal (String file1, String file2)
2971     throws LibGuestFSException
2972   {
2973     if (g == 0)
2974       throw new LibGuestFSException ("equal: handle is closed");
2975     return _equal (g, file1, file2);
2976   }
2977   private native boolean _equal (long g, String file1, String file2)
2978     throws LibGuestFSException;
2979
2980   /**
2981    * print the printable strings in a file
2982    * <p>
2983    * This runs the strings(1) command on a file and returns
2984    * the list of printable strings found.
2985    * <p>
2986    * Because of the message protocol, there is a transfer
2987    * limit of somewhere between 2MB and 4MB. To transfer
2988    * large files you should use FTP.
2989    * <p>
2990    * @throws LibGuestFSException
2991    */
2992   public String[] strings (String path)
2993     throws LibGuestFSException
2994   {
2995     if (g == 0)
2996       throw new LibGuestFSException ("strings: handle is closed");
2997     return _strings (g, path);
2998   }
2999   private native String[] _strings (long g, String path)
3000     throws LibGuestFSException;
3001
3002   /**
3003    * print the printable strings in a file
3004    * <p>
3005    * This is like the "g.strings" command, but allows you to
3006    * specify the encoding.
3007    * <p>
3008    * See the strings(1) manpage for the full list of
3009    * encodings.
3010    * <p>
3011    * Commonly useful encodings are "l" (lower case L) which
3012    * will show strings inside Windows/x86 files.
3013    * <p>
3014    * The returned strings are transcoded to UTF-8.
3015    * <p>
3016    * Because of the message protocol, there is a transfer
3017    * limit of somewhere between 2MB and 4MB. To transfer
3018    * large files you should use FTP.
3019    * <p>
3020    * @throws LibGuestFSException
3021    */
3022   public String[] strings_e (String encoding, String path)
3023     throws LibGuestFSException
3024   {
3025     if (g == 0)
3026       throw new LibGuestFSException ("strings_e: handle is closed");
3027     return _strings_e (g, encoding, path);
3028   }
3029   private native String[] _strings_e (long g, String encoding, String path)
3030     throws LibGuestFSException;
3031
3032   /**
3033    * dump a file in hexadecimal
3034    * <p>
3035    * This runs "hexdump -C" on the given "path". The result
3036    * is the human-readable, canonical hex dump of the file.
3037    * <p>
3038    * Because of the message protocol, there is a transfer
3039    * limit of somewhere between 2MB and 4MB. To transfer
3040    * large files you should use FTP.
3041    * <p>
3042    * @throws LibGuestFSException
3043    */
3044   public String hexdump (String path)
3045     throws LibGuestFSException
3046   {
3047     if (g == 0)
3048       throw new LibGuestFSException ("hexdump: handle is closed");
3049     return _hexdump (g, path);
3050   }
3051   private native String _hexdump (long g, String path)
3052     throws LibGuestFSException;
3053
3054   /**
3055    * zero unused inodes and disk blocks on ext2/3 filesystem
3056    * <p>
3057    * This runs the *zerofree* program on "device". This
3058    * program claims to zero unused inodes and disk blocks on
3059    * an ext2/3 filesystem, thus making it possible to
3060    * compress the filesystem more effectively.
3061    * <p>
3062    * You should not run this program if the filesystem is
3063    * mounted.
3064    * <p>
3065    * It is possible that using this program can damage the
3066    * filesystem or data on the filesystem.
3067    * <p>
3068    * @throws LibGuestFSException
3069    */
3070   public void zerofree (String device)
3071     throws LibGuestFSException
3072   {
3073     if (g == 0)
3074       throw new LibGuestFSException ("zerofree: handle is closed");
3075     _zerofree (g, device);
3076   }
3077   private native void _zerofree (long g, String device)
3078     throws LibGuestFSException;
3079
3080   /**
3081    * resize an LVM physical volume
3082    * <p>
3083    * This resizes (expands or shrinks) an existing LVM
3084    * physical volume to match the new size of the underlying
3085    * device.
3086    * <p>
3087    * @throws LibGuestFSException
3088    */
3089   public void pvresize (String device)
3090     throws LibGuestFSException
3091   {
3092     if (g == 0)
3093       throw new LibGuestFSException ("pvresize: handle is closed");
3094     _pvresize (g, device);
3095   }
3096   private native void _pvresize (long g, String device)
3097     throws LibGuestFSException;
3098
3099   /**
3100    * modify a single partition on a block device
3101    * <p>
3102    * This runs sfdisk(8) option to modify just the single
3103    * partition "n" (note: "n" counts from 1).
3104    * <p>
3105    * For other parameters, see "g.sfdisk". You should usually
3106    * pass 0 for the cyls/heads/sectors parameters.
3107    * <p>
3108    * This command is dangerous. Without careful use you can
3109    * easily destroy all your data.
3110    * <p>
3111    * @throws LibGuestFSException
3112    */
3113   public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
3114     throws LibGuestFSException
3115   {
3116     if (g == 0)
3117       throw new LibGuestFSException ("sfdisk_N: handle is closed");
3118     _sfdisk_N (g, device, n, cyls, heads, sectors, line);
3119   }
3120   private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
3121     throws LibGuestFSException;
3122
3123   /**
3124    * display the partition table
3125    * <p>
3126    * This displays the partition table on "device", in the
3127    * human-readable output of the sfdisk(8) command. It is
3128    * not intended to be parsed.
3129    * <p>
3130    * @throws LibGuestFSException
3131    */
3132   public String sfdisk_l (String device)
3133     throws LibGuestFSException
3134   {
3135     if (g == 0)
3136       throw new LibGuestFSException ("sfdisk_l: handle is closed");
3137     return _sfdisk_l (g, device);
3138   }
3139   private native String _sfdisk_l (long g, String device)
3140     throws LibGuestFSException;
3141
3142   /**
3143    * display the kernel geometry
3144    * <p>
3145    * This displays the kernel's idea of the geometry of
3146    * "device".
3147    * <p>
3148    * The result is in human-readable format, and not designed
3149    * to be parsed.
3150    * <p>
3151    * @throws LibGuestFSException
3152    */
3153   public String sfdisk_kernel_geometry (String device)
3154     throws LibGuestFSException
3155   {
3156     if (g == 0)
3157       throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3158     return _sfdisk_kernel_geometry (g, device);
3159   }
3160   private native String _sfdisk_kernel_geometry (long g, String device)
3161     throws LibGuestFSException;
3162
3163   /**
3164    * display the disk geometry from the partition table
3165    * <p>
3166    * This displays the disk geometry of "device" read from
3167    * the partition table. Especially in the case where the
3168    * underlying block device has been resized, this can be
3169    * different from the kernel's idea of the geometry (see
3170    * "g.sfdisk_kernel_geometry").
3171    * <p>
3172    * The result is in human-readable format, and not designed
3173    * to be parsed.
3174    * <p>
3175    * @throws LibGuestFSException
3176    */
3177   public String sfdisk_disk_geometry (String device)
3178     throws LibGuestFSException
3179   {
3180     if (g == 0)
3181       throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3182     return _sfdisk_disk_geometry (g, device);
3183   }
3184   private native String _sfdisk_disk_geometry (long g, String device)
3185     throws LibGuestFSException;
3186
3187   /**
3188    * activate or deactivate all volume groups
3189    * <p>
3190    * This command activates or (if "activate" is false)
3191    * deactivates all logical volumes in all volume groups. If
3192    * activated, then they are made known to the kernel, ie.
3193    * they appear as "/dev/mapper" devices. If deactivated,
3194    * then those devices disappear.
3195    * <p>
3196    * This command is the same as running "vgchange -a y|n"
3197    * <p>
3198    * @throws LibGuestFSException
3199    */
3200   public void vg_activate_all (boolean activate)
3201     throws LibGuestFSException
3202   {
3203     if (g == 0)
3204       throw new LibGuestFSException ("vg_activate_all: handle is closed");
3205     _vg_activate_all (g, activate);
3206   }
3207   private native void _vg_activate_all (long g, boolean activate)
3208     throws LibGuestFSException;
3209
3210   /**
3211    * activate or deactivate some volume groups
3212    * <p>
3213    * This command activates or (if "activate" is false)
3214    * deactivates all logical volumes in the listed volume
3215    * groups "volgroups". If activated, then they are made
3216    * known to the kernel, ie. they appear as "/dev/mapper"
3217    * devices. If deactivated, then those devices disappear.
3218    * <p>
3219    * This command is the same as running "vgchange -a y|n
3220    * volgroups..."
3221    * <p>
3222    * Note that if "volgroups" is an empty list then all
3223    * volume groups are activated or deactivated.
3224    * <p>
3225    * @throws LibGuestFSException
3226    */
3227   public void vg_activate (boolean activate, String[] volgroups)
3228     throws LibGuestFSException
3229   {
3230     if (g == 0)
3231       throw new LibGuestFSException ("vg_activate: handle is closed");
3232     _vg_activate (g, activate, volgroups);
3233   }
3234   private native void _vg_activate (long g, boolean activate, String[] volgroups)
3235     throws LibGuestFSException;
3236
3237   /**
3238    * resize an LVM logical volume
3239    * <p>
3240    * This resizes (expands or shrinks) an existing LVM
3241    * logical volume to "mbytes". When reducing, data in the
3242    * reduced part is lost.
3243    * <p>
3244    * @throws LibGuestFSException
3245    */
3246   public void lvresize (String device, int mbytes)
3247     throws LibGuestFSException
3248   {
3249     if (g == 0)
3250       throw new LibGuestFSException ("lvresize: handle is closed");
3251     _lvresize (g, device, mbytes);
3252   }
3253   private native void _lvresize (long g, String device, int mbytes)
3254     throws LibGuestFSException;
3255
3256   /**
3257    * resize an ext2/ext3 filesystem
3258    * <p>
3259    * This resizes an ext2 or ext3 filesystem to match the
3260    * size of the underlying device.
3261    * <p>
3262    * *Note:* It is sometimes required that you run
3263    * "g.e2fsck_f" on the "device" before calling this
3264    * command. For unknown reasons "resize2fs" sometimes gives
3265    * an error about this and sometimes not. In any case, it
3266    * is always safe to call "g.e2fsck_f" before calling this
3267    * function.
3268    * <p>
3269    * @throws LibGuestFSException
3270    */
3271   public void resize2fs (String device)
3272     throws LibGuestFSException
3273   {
3274     if (g == 0)
3275       throw new LibGuestFSException ("resize2fs: handle is closed");
3276     _resize2fs (g, device);
3277   }
3278   private native void _resize2fs (long g, String device)
3279     throws LibGuestFSException;
3280
3281   /**
3282    * find all files and directories
3283    * <p>
3284    * This command lists out all files and directories,
3285    * recursively, starting at "directory". It is essentially
3286    * equivalent to running the shell command "find directory
3287    * -print" but some post-processing happens on the output,
3288    * described below.
3289    * <p>
3290    * This returns a list of strings *without any prefix*.
3291    * Thus if the directory structure was:
3292    * <p>
3293    * /tmp/a
3294    * /tmp/b
3295    * /tmp/c/d
3296    * <p>
3297    * then the returned list from "g.find" "/tmp" would be 4
3298    * elements:
3299    * <p>
3300    * a
3301    * b
3302    * c
3303    * c/d
3304    * <p>
3305    * If "directory" is not a directory, then this command
3306    * returns an error.
3307    * <p>
3308    * The returned list is sorted.
3309    * <p>
3310    * @throws LibGuestFSException
3311    */
3312   public String[] find (String directory)
3313     throws LibGuestFSException
3314   {
3315     if (g == 0)
3316       throw new LibGuestFSException ("find: handle is closed");
3317     return _find (g, directory);
3318   }
3319   private native String[] _find (long g, String directory)
3320     throws LibGuestFSException;
3321
3322   /**
3323    * check an ext2/ext3 filesystem
3324    * <p>
3325    * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3326    * filesystem checker on "device", noninteractively ("-p"),
3327    * even if the filesystem appears to be clean ("-f").
3328    * <p>
3329    * This command is only needed because of "g.resize2fs"
3330    * (q.v.). Normally you should use "g.fsck".
3331    * <p>
3332    * @throws LibGuestFSException
3333    */
3334   public void e2fsck_f (String device)
3335     throws LibGuestFSException
3336   {
3337     if (g == 0)
3338       throw new LibGuestFSException ("e2fsck_f: handle is closed");
3339     _e2fsck_f (g, device);
3340   }
3341   private native void _e2fsck_f (long g, String device)
3342     throws LibGuestFSException;
3343
3344   /**
3345    * sleep for some seconds
3346    * <p>
3347    * Sleep for "secs" seconds.
3348    * <p>
3349    * @throws LibGuestFSException
3350    */
3351   public void sleep (int secs)
3352     throws LibGuestFSException
3353   {
3354     if (g == 0)
3355       throw new LibGuestFSException ("sleep: handle is closed");
3356     _sleep (g, secs);
3357   }
3358   private native void _sleep (long g, int secs)
3359     throws LibGuestFSException;
3360
3361   /**
3362    * probe NTFS volume
3363    * <p>
3364    * This command runs the ntfs-3g.probe(8) command which
3365    * probes an NTFS "device" for mountability. (Not all NTFS
3366    * volumes can be mounted read-write, and some cannot be
3367    * mounted at all).
3368    * <p>
3369    * "rw" is a boolean flag. Set it to true if you want to
3370    * test if the volume can be mounted read-write. Set it to
3371    * false if you want to test if the volume can be mounted
3372    * read-only.
3373    * <p>
3374    * The return value is an integer which 0 if the operation
3375    * would succeed, or some non-zero value documented in the
3376    * ntfs-3g.probe(8) manual page.
3377    * <p>
3378    * @throws LibGuestFSException
3379    */
3380   public int ntfs_3g_probe (boolean rw, String device)
3381     throws LibGuestFSException
3382   {
3383     if (g == 0)
3384       throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
3385     return _ntfs_3g_probe (g, rw, device);
3386   }
3387   private native int _ntfs_3g_probe (long g, boolean rw, String device)
3388     throws LibGuestFSException;
3389
3390   /**
3391    * run a command via the shell
3392    * <p>
3393    * This call runs a command from the guest filesystem via
3394    * the guest's "/bin/sh".
3395    * <p>
3396    * This is like "g.command", but passes the command to:
3397    * <p>
3398    * /bin/sh -c "command"
3399    * <p>
3400    * Depending on the guest's shell, this usually results in
3401    * wildcards being expanded, shell expressions being
3402    * interpolated and so on.
3403    * <p>
3404    * All the provisos about "g.command" apply to this call.
3405    * <p>
3406    * @throws LibGuestFSException
3407    */
3408   public String sh (String command)
3409     throws LibGuestFSException
3410   {
3411     if (g == 0)
3412       throw new LibGuestFSException ("sh: handle is closed");
3413     return _sh (g, command);
3414   }
3415   private native String _sh (long g, String command)
3416     throws LibGuestFSException;
3417
3418   /**
3419    * run a command via the shell returning lines
3420    * <p>
3421    * This is the same as "g.sh", but splits the result into a
3422    * list of lines.
3423    * <p>
3424    * See also: "g.command_lines"
3425    * <p>
3426    * @throws LibGuestFSException
3427    */
3428   public String[] sh_lines (String command)
3429     throws LibGuestFSException
3430   {
3431     if (g == 0)
3432       throw new LibGuestFSException ("sh_lines: handle is closed");
3433     return _sh_lines (g, command);
3434   }
3435   private native String[] _sh_lines (long g, String command)
3436     throws LibGuestFSException;
3437
3438   /**
3439    * expand a wildcard path
3440    * <p>
3441    * This command searches for all the pathnames matching
3442    * "pattern" according to the wildcard expansion rules used
3443    * by the shell.
3444    * <p>
3445    * If no paths match, then this returns an empty list
3446    * (note: not an error).
3447    * <p>
3448    * It is just a wrapper around the C glob(3) function with
3449    * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
3450    * more details.
3451    * <p>
3452    * @throws LibGuestFSException
3453    */
3454   public String[] glob_expand (String pattern)
3455     throws LibGuestFSException
3456   {
3457     if (g == 0)
3458       throw new LibGuestFSException ("glob_expand: handle is closed");
3459     return _glob_expand (g, pattern);
3460   }
3461   private native String[] _glob_expand (long g, String pattern)
3462     throws LibGuestFSException;
3463
3464 }