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.
5 * Copyright (C) 2009 Red Hat Inc.
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.
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.
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
22 package com.redhat.et.libguestfs;
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;
34 * The GuestFS object is a libguestfs handle.
38 public class GuestFS {
39 // Load the native code.
41 System.loadLibrary ("guestfs_jni");
45 * The native guestfs_h pointer.
50 * Create a libguestfs handle.
52 * @throws LibGuestFSException
54 public GuestFS () throws LibGuestFSException
58 private native long _create () throws LibGuestFSException;
61 * Close a libguestfs handle.
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
69 * @throws LibGuestFSException
71 public void close () throws LibGuestFSException
77 private native void _close (long g) throws LibGuestFSException;
79 public void finalize () throws LibGuestFSException
84 public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
85 throws LibGuestFSException
88 throw new LibGuestFSException ("test0: handle is closed");
89 _test0 (g, str, optstr, strlist, b, integer, filein, fileout);
91 private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
92 throws LibGuestFSException;
94 public int test0rint (String val)
95 throws LibGuestFSException
98 throw new LibGuestFSException ("test0rint: handle is closed");
99 return _test0rint (g, val);
101 private native int _test0rint (long g, String val)
102 throws LibGuestFSException;
104 public int test0rinterr ()
105 throws LibGuestFSException
108 throw new LibGuestFSException ("test0rinterr: handle is closed");
109 return _test0rinterr (g);
111 private native int _test0rinterr (long g)
112 throws LibGuestFSException;
114 public long test0rint64 (String val)
115 throws LibGuestFSException
118 throw new LibGuestFSException ("test0rint64: handle is closed");
119 return _test0rint64 (g, val);
121 private native long _test0rint64 (long g, String val)
122 throws LibGuestFSException;
124 public long test0rint64err ()
125 throws LibGuestFSException
128 throw new LibGuestFSException ("test0rint64err: handle is closed");
129 return _test0rint64err (g);
131 private native long _test0rint64err (long g)
132 throws LibGuestFSException;
134 public boolean test0rbool (String val)
135 throws LibGuestFSException
138 throw new LibGuestFSException ("test0rbool: handle is closed");
139 return _test0rbool (g, val);
141 private native boolean _test0rbool (long g, String val)
142 throws LibGuestFSException;
144 public boolean test0rboolerr ()
145 throws LibGuestFSException
148 throw new LibGuestFSException ("test0rboolerr: handle is closed");
149 return _test0rboolerr (g);
151 private native boolean _test0rboolerr (long g)
152 throws LibGuestFSException;
154 public String test0rconststring (String val)
155 throws LibGuestFSException
158 throw new LibGuestFSException ("test0rconststring: handle is closed");
159 return _test0rconststring (g, val);
161 private native String _test0rconststring (long g, String val)
162 throws LibGuestFSException;
164 public String test0rconststringerr ()
165 throws LibGuestFSException
168 throw new LibGuestFSException ("test0rconststringerr: handle is closed");
169 return _test0rconststringerr (g);
171 private native String _test0rconststringerr (long g)
172 throws LibGuestFSException;
174 public String test0rstring (String val)
175 throws LibGuestFSException
178 throw new LibGuestFSException ("test0rstring: handle is closed");
179 return _test0rstring (g, val);
181 private native String _test0rstring (long g, String val)
182 throws LibGuestFSException;
184 public String test0rstringerr ()
185 throws LibGuestFSException
188 throw new LibGuestFSException ("test0rstringerr: handle is closed");
189 return _test0rstringerr (g);
191 private native String _test0rstringerr (long g)
192 throws LibGuestFSException;
194 public String[] test0rstringlist (String val)
195 throws LibGuestFSException
198 throw new LibGuestFSException ("test0rstringlist: handle is closed");
199 return _test0rstringlist (g, val);
201 private native String[] _test0rstringlist (long g, String val)
202 throws LibGuestFSException;
204 public String[] test0rstringlisterr ()
205 throws LibGuestFSException
208 throw new LibGuestFSException ("test0rstringlisterr: handle is closed");
209 return _test0rstringlisterr (g);
211 private native String[] _test0rstringlisterr (long g)
212 throws LibGuestFSException;
214 public IntBool test0rintbool (String val)
215 throws LibGuestFSException
218 throw new LibGuestFSException ("test0rintbool: handle is closed");
219 return _test0rintbool (g, val);
221 private native IntBool _test0rintbool (long g, String val)
222 throws LibGuestFSException;
224 public IntBool test0rintboolerr ()
225 throws LibGuestFSException
228 throw new LibGuestFSException ("test0rintboolerr: handle is closed");
229 return _test0rintboolerr (g);
231 private native IntBool _test0rintboolerr (long g)
232 throws LibGuestFSException;
234 public PV[] test0rpvlist (String val)
235 throws LibGuestFSException
238 throw new LibGuestFSException ("test0rpvlist: handle is closed");
239 return _test0rpvlist (g, val);
241 private native PV[] _test0rpvlist (long g, String val)
242 throws LibGuestFSException;
244 public PV[] test0rpvlisterr ()
245 throws LibGuestFSException
248 throw new LibGuestFSException ("test0rpvlisterr: handle is closed");
249 return _test0rpvlisterr (g);
251 private native PV[] _test0rpvlisterr (long g)
252 throws LibGuestFSException;
254 public VG[] test0rvglist (String val)
255 throws LibGuestFSException
258 throw new LibGuestFSException ("test0rvglist: handle is closed");
259 return _test0rvglist (g, val);
261 private native VG[] _test0rvglist (long g, String val)
262 throws LibGuestFSException;
264 public VG[] test0rvglisterr ()
265 throws LibGuestFSException
268 throw new LibGuestFSException ("test0rvglisterr: handle is closed");
269 return _test0rvglisterr (g);
271 private native VG[] _test0rvglisterr (long g)
272 throws LibGuestFSException;
274 public LV[] test0rlvlist (String val)
275 throws LibGuestFSException
278 throw new LibGuestFSException ("test0rlvlist: handle is closed");
279 return _test0rlvlist (g, val);
281 private native LV[] _test0rlvlist (long g, String val)
282 throws LibGuestFSException;
284 public LV[] test0rlvlisterr ()
285 throws LibGuestFSException
288 throw new LibGuestFSException ("test0rlvlisterr: handle is closed");
289 return _test0rlvlisterr (g);
291 private native LV[] _test0rlvlisterr (long g)
292 throws LibGuestFSException;
294 public Stat test0rstat (String val)
295 throws LibGuestFSException
298 throw new LibGuestFSException ("test0rstat: handle is closed");
299 return _test0rstat (g, val);
301 private native Stat _test0rstat (long g, String val)
302 throws LibGuestFSException;
304 public Stat test0rstaterr ()
305 throws LibGuestFSException
308 throw new LibGuestFSException ("test0rstaterr: handle is closed");
309 return _test0rstaterr (g);
311 private native Stat _test0rstaterr (long g)
312 throws LibGuestFSException;
314 public StatVFS test0rstatvfs (String val)
315 throws LibGuestFSException
318 throw new LibGuestFSException ("test0rstatvfs: handle is closed");
319 return _test0rstatvfs (g, val);
321 private native StatVFS _test0rstatvfs (long g, String val)
322 throws LibGuestFSException;
324 public StatVFS test0rstatvfserr ()
325 throws LibGuestFSException
328 throw new LibGuestFSException ("test0rstatvfserr: handle is closed");
329 return _test0rstatvfserr (g);
331 private native StatVFS _test0rstatvfserr (long g)
332 throws LibGuestFSException;
334 public HashMap<String,String> test0rhashtable (String val)
335 throws LibGuestFSException
338 throw new LibGuestFSException ("test0rhashtable: handle is closed");
339 return _test0rhashtable (g, val);
341 private native HashMap<String,String> _test0rhashtable (long g, String val)
342 throws LibGuestFSException;
344 public HashMap<String,String> test0rhashtableerr ()
345 throws LibGuestFSException
348 throw new LibGuestFSException ("test0rhashtableerr: handle is closed");
349 return _test0rhashtableerr (g);
351 private native HashMap<String,String> _test0rhashtableerr (long g)
352 throws LibGuestFSException;
355 * launch the qemu subprocess
357 * Internally libguestfs is implemented by running a
358 * virtual machine using qemu(1).
360 * You should call this after configuring the handle (eg.
361 * adding drives) but before performing any actions.
363 * @throws LibGuestFSException
365 public void launch ()
366 throws LibGuestFSException
369 throw new LibGuestFSException ("launch: handle is closed");
372 private native void _launch (long g)
373 throws LibGuestFSException;
376 * wait until the qemu subprocess launches
378 * Internally libguestfs is implemented by running a
379 * virtual machine using qemu(1).
381 * You should call this after "g.launch" to wait for the
382 * launch to complete.
384 * @throws LibGuestFSException
386 public void wait_ready ()
387 throws LibGuestFSException
390 throw new LibGuestFSException ("wait_ready: handle is closed");
393 private native void _wait_ready (long g)
394 throws LibGuestFSException;
397 * kill the qemu subprocess
399 * This kills the qemu subprocess. You should never need to
402 * @throws LibGuestFSException
404 public void kill_subprocess ()
405 throws LibGuestFSException
408 throw new LibGuestFSException ("kill_subprocess: handle is closed");
409 _kill_subprocess (g);
411 private native void _kill_subprocess (long g)
412 throws LibGuestFSException;
415 * add an image to examine or modify
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.
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).
429 * This is equivalent to the qemu parameter "-drive
430 * file=filename,cache=off".
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.
438 * @throws LibGuestFSException
440 public void add_drive (String filename)
441 throws LibGuestFSException
444 throw new LibGuestFSException ("add_drive: handle is closed");
445 _add_drive (g, filename);
447 private native void _add_drive (long g, String filename)
448 throws LibGuestFSException;
451 * add a CD-ROM disk image to examine
453 * This function adds a virtual CD-ROM disk image to the
456 * This is equivalent to the qemu parameter "-cdrom
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.
465 * @throws LibGuestFSException
467 public void add_cdrom (String filename)
468 throws LibGuestFSException
471 throw new LibGuestFSException ("add_cdrom: handle is closed");
472 _add_cdrom (g, filename);
474 private native void _add_cdrom (long g, String filename)
475 throws LibGuestFSException;
478 * add a drive in snapshot mode (read-only)
480 * This adds a drive in snapshot mode, making it
481 * effectively read-only.
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.
490 * This is equivalent to the qemu parameter "-drive
491 * file=filename,snapshot=on".
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.
499 * @throws LibGuestFSException
501 public void add_drive_ro (String filename)
502 throws LibGuestFSException
505 throw new LibGuestFSException ("add_drive_ro: handle is closed");
506 _add_drive_ro (g, filename);
508 private native void _add_drive_ro (long g, String filename)
509 throws LibGuestFSException;
512 * add qemu parameters
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
520 * The first character of "param" string must be a "-"
523 * "value" can be NULL.
525 * @throws LibGuestFSException
527 public void config (String qemuparam, String qemuvalue)
528 throws LibGuestFSException
531 throw new LibGuestFSException ("config: handle is closed");
532 _config (g, qemuparam, qemuvalue);
534 private native void _config (long g, String qemuparam, String qemuvalue)
535 throws LibGuestFSException;
538 * set the qemu binary
540 * Set the qemu binary that we will use.
542 * The default is chosen when the library was compiled by
543 * the configure script.
545 * You can also override this by setting the
546 * "LIBGUESTFS_QEMU" environment variable.
548 * Setting "qemu" to "NULL" restores the default qemu
551 * @throws LibGuestFSException
553 public void set_qemu (String qemu)
554 throws LibGuestFSException
557 throw new LibGuestFSException ("set_qemu: handle is closed");
560 private native void _set_qemu (long g, String qemu)
561 throws LibGuestFSException;
564 * get the qemu binary
566 * Return the current qemu binary.
568 * This is always non-NULL. If it wasn't set already, then
569 * this will return the default qemu binary name.
571 * @throws LibGuestFSException
573 public String get_qemu ()
574 throws LibGuestFSException
577 throw new LibGuestFSException ("get_qemu: handle is closed");
578 return _get_qemu (g);
580 private native String _get_qemu (long g)
581 throws LibGuestFSException;
584 * set the search path
586 * Set the path that libguestfs searches for kernel and
589 * The default is "$libdir/guestfs" unless overridden by
590 * setting "LIBGUESTFS_PATH" environment variable.
592 * Setting "path" to "NULL" restores the default path.
594 * @throws LibGuestFSException
596 public void set_path (String path)
597 throws LibGuestFSException
600 throw new LibGuestFSException ("set_path: handle is closed");
603 private native void _set_path (long g, String path)
604 throws LibGuestFSException;
607 * get the search path
609 * Return the current search path.
611 * This is always non-NULL. If it wasn't set already, then
612 * this will return the default path.
614 * @throws LibGuestFSException
616 public String get_path ()
617 throws LibGuestFSException
620 throw new LibGuestFSException ("get_path: handle is closed");
621 return _get_path (g);
623 private native String _get_path (long g)
624 throws LibGuestFSException;
627 * add options to kernel command line
629 * This function is used to add additional options to the
630 * guest kernel command line.
632 * The default is "NULL" unless overridden by setting
633 * "LIBGUESTFS_APPEND" environment variable.
635 * Setting "append" to "NULL" means *no* additional options
636 * are passed (libguestfs always adds a few of its own).
638 * @throws LibGuestFSException
640 public void set_append (String append)
641 throws LibGuestFSException
644 throw new LibGuestFSException ("set_append: handle is closed");
645 _set_append (g, append);
647 private native void _set_append (long g, String append)
648 throws LibGuestFSException;
651 * get the additional kernel options
653 * Return the additional kernel options which are added to
654 * the guest kernel command line.
656 * If "NULL" then no options are added.
658 * @throws LibGuestFSException
660 public String get_append ()
661 throws LibGuestFSException
664 throw new LibGuestFSException ("get_append: handle is closed");
665 return _get_append (g);
667 private native String _get_append (long g)
668 throws LibGuestFSException;
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).
678 * This is disabled by default (except in guestfish where
679 * it is enabled by default).
681 * @throws LibGuestFSException
683 public void set_autosync (boolean autosync)
684 throws LibGuestFSException
687 throw new LibGuestFSException ("set_autosync: handle is closed");
688 _set_autosync (g, autosync);
690 private native void _set_autosync (long g, boolean autosync)
691 throws LibGuestFSException;
696 * Get the autosync flag.
698 * @throws LibGuestFSException
700 public boolean get_autosync ()
701 throws LibGuestFSException
704 throw new LibGuestFSException ("get_autosync: handle is closed");
705 return _get_autosync (g);
707 private native boolean _get_autosync (long g)
708 throws LibGuestFSException;
713 * If "verbose" is true, this turns on verbose messages (to
716 * Verbose messages are disabled unless the environment
717 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
719 * @throws LibGuestFSException
721 public void set_verbose (boolean verbose)
722 throws LibGuestFSException
725 throw new LibGuestFSException ("set_verbose: handle is closed");
726 _set_verbose (g, verbose);
728 private native void _set_verbose (long g, boolean verbose)
729 throws LibGuestFSException;
734 * This returns the verbose messages flag.
736 * @throws LibGuestFSException
738 public boolean get_verbose ()
739 throws LibGuestFSException
742 throw new LibGuestFSException ("get_verbose: handle is closed");
743 return _get_verbose (g);
745 private native boolean _get_verbose (long g)
746 throws LibGuestFSException;
749 * is ready to accept commands
751 * This returns true iff this handle is ready to accept
752 * commands (in the "READY" state).
754 * For more information on states, see guestfs(3).
756 * @throws LibGuestFSException
758 public boolean is_ready ()
759 throws LibGuestFSException
762 throw new LibGuestFSException ("is_ready: handle is closed");
763 return _is_ready (g);
765 private native boolean _is_ready (long g)
766 throws LibGuestFSException;
769 * is in configuration state
771 * This returns true iff this handle is being configured
772 * (in the "CONFIG" state).
774 * For more information on states, see guestfs(3).
776 * @throws LibGuestFSException
778 public boolean is_config ()
779 throws LibGuestFSException
782 throw new LibGuestFSException ("is_config: handle is closed");
783 return _is_config (g);
785 private native boolean _is_config (long g)
786 throws LibGuestFSException;
789 * is launching subprocess
791 * This returns true iff this handle is launching the
792 * subprocess (in the "LAUNCHING" state).
794 * For more information on states, see guestfs(3).
796 * @throws LibGuestFSException
798 public boolean is_launching ()
799 throws LibGuestFSException
802 throw new LibGuestFSException ("is_launching: handle is closed");
803 return _is_launching (g);
805 private native boolean _is_launching (long g)
806 throws LibGuestFSException;
809 * is busy processing a command
811 * This returns true iff this handle is busy processing a
812 * command (in the "BUSY" state).
814 * For more information on states, see guestfs(3).
816 * @throws LibGuestFSException
818 public boolean is_busy ()
819 throws LibGuestFSException
822 throw new LibGuestFSException ("is_busy: handle is closed");
825 private native boolean _is_busy (long g)
826 throws LibGuestFSException;
829 * get the current state
831 * This returns the current state as an opaque integer.
832 * This is only useful for printing debug and internal
835 * For more information on states, see guestfs(3).
837 * @throws LibGuestFSException
839 public int get_state ()
840 throws LibGuestFSException
843 throw new LibGuestFSException ("get_state: handle is closed");
844 return _get_state (g);
846 private native int _get_state (long g)
847 throws LibGuestFSException;
852 * This sets the state to "BUSY". This is only used when
853 * implementing actions using the low-level API.
855 * For more information on states, see guestfs(3).
857 * @throws LibGuestFSException
859 public void set_busy ()
860 throws LibGuestFSException
863 throw new LibGuestFSException ("set_busy: handle is closed");
866 private native void _set_busy (long g)
867 throws LibGuestFSException;
872 * This sets the state to "READY". This is only used when
873 * implementing actions using the low-level API.
875 * For more information on states, see guestfs(3).
877 * @throws LibGuestFSException
879 public void set_ready ()
880 throws LibGuestFSException
883 throw new LibGuestFSException ("set_ready: handle is closed");
886 private native void _set_ready (long g)
887 throws LibGuestFSException;
890 * leave the busy state
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.
896 * For more information on states, see guestfs(3).
898 * @throws LibGuestFSException
900 public void end_busy ()
901 throws LibGuestFSException
904 throw new LibGuestFSException ("end_busy: handle is closed");
907 private native void _end_busy (long g)
908 throws LibGuestFSException;
911 * set memory allocated to the qemu subprocess
913 * This sets the memory size in megabytes allocated to the
914 * qemu subprocess. This only has any effect if called
917 * You can also change this by setting the environment
918 * variable "LIBGUESTFS_MEMSIZE" before the handle is
921 * For more information on the architecture of libguestfs,
924 * @throws LibGuestFSException
926 public void set_memsize (int memsize)
927 throws LibGuestFSException
930 throw new LibGuestFSException ("set_memsize: handle is closed");
931 _set_memsize (g, memsize);
933 private native void _set_memsize (long g, int memsize)
934 throws LibGuestFSException;
937 * get memory allocated to the qemu subprocess
939 * This gets the memory size in megabytes allocated to the
942 * If "g.set_memsize" was not called on this handle, and if
943 * "LIBGUESTFS_MEMSIZE" was not set, then this returns the
944 * compiled-in default value for memsize.
946 * For more information on the architecture of libguestfs,
949 * @throws LibGuestFSException
951 public int get_memsize ()
952 throws LibGuestFSException
955 throw new LibGuestFSException ("get_memsize: handle is closed");
956 return _get_memsize (g);
958 private native int _get_memsize (long g)
959 throws LibGuestFSException;
962 * mount a guest disk at a position in the filesystem
964 * Mount a guest disk at a position in the filesystem.
965 * Block devices are named "/dev/sda", "/dev/sdb" and so
966 * on, as they were added to the guest. If those block
967 * devices contain partitions, they will have the usual
968 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
971 * The rules are the same as for mount(2): A filesystem
972 * must first be mounted on "/" before others can be
973 * mounted. Other filesystems can only be mounted on
974 * directories which already exist.
976 * The mounted filesystem is writable, if we have
977 * sufficient permissions on the underlying device.
979 * The filesystem options "sync" and "noatime" are set with
980 * this call, in order to improve reliability.
982 * @throws LibGuestFSException
984 public void mount (String device, String mountpoint)
985 throws LibGuestFSException
988 throw new LibGuestFSException ("mount: handle is closed");
989 _mount (g, device, mountpoint);
991 private native void _mount (long g, String device, String mountpoint)
992 throws LibGuestFSException;
995 * sync disks, writes are flushed through to the disk image
997 * This syncs the disk, so that any writes are flushed
998 * through to the underlying disk image.
1000 * You should always call this if you have modified a disk
1001 * image, before closing the handle.
1003 * @throws LibGuestFSException
1006 throws LibGuestFSException
1009 throw new LibGuestFSException ("sync: handle is closed");
1012 private native void _sync (long g)
1013 throws LibGuestFSException;
1016 * update file timestamps or create a new file
1018 * Touch acts like the touch(1) command. It can be used to
1019 * update the timestamps on a file, or, if the file does
1020 * not exist, to create a new zero-length file.
1022 * @throws LibGuestFSException
1024 public void touch (String path)
1025 throws LibGuestFSException
1028 throw new LibGuestFSException ("touch: handle is closed");
1031 private native void _touch (long g, String path)
1032 throws LibGuestFSException;
1035 * list the contents of a file
1037 * Return the contents of the file named "path".
1039 * Note that this function cannot correctly handle binary
1040 * files (specifically, files containing "\0" character
1041 * which is treated as end of string). For those you need
1042 * to use the "g.download" function which has a more
1043 * complex interface.
1045 * Because of the message protocol, there is a transfer
1046 * limit of somewhere between 2MB and 4MB. To transfer
1047 * large files you should use FTP.
1049 * @throws LibGuestFSException
1051 public String cat (String path)
1052 throws LibGuestFSException
1055 throw new LibGuestFSException ("cat: handle is closed");
1056 return _cat (g, path);
1058 private native String _cat (long g, String path)
1059 throws LibGuestFSException;
1062 * list the files in a directory (long format)
1064 * List the files in "directory" (relative to the root
1065 * directory, there is no cwd) in the format of 'ls -la'.
1067 * This command is mostly useful for interactive sessions.
1068 * It is *not* intended that you try to parse the output
1071 * @throws LibGuestFSException
1073 public String ll (String directory)
1074 throws LibGuestFSException
1077 throw new LibGuestFSException ("ll: handle is closed");
1078 return _ll (g, directory);
1080 private native String _ll (long g, String directory)
1081 throws LibGuestFSException;
1084 * list the files in a directory
1086 * List the files in "directory" (relative to the root
1087 * directory, there is no cwd). The '.' and '..' entries
1088 * are not returned, but hidden files are shown.
1090 * This command is mostly useful for interactive sessions.
1091 * Programs should probably use "g.readdir" instead.
1093 * @throws LibGuestFSException
1095 public String[] ls (String directory)
1096 throws LibGuestFSException
1099 throw new LibGuestFSException ("ls: handle is closed");
1100 return _ls (g, directory);
1102 private native String[] _ls (long g, String directory)
1103 throws LibGuestFSException;
1106 * list the block devices
1108 * List all the block devices.
1110 * The full block device names are returned, eg. "/dev/sda"
1112 * @throws LibGuestFSException
1114 public String[] list_devices ()
1115 throws LibGuestFSException
1118 throw new LibGuestFSException ("list_devices: handle is closed");
1119 return _list_devices (g);
1121 private native String[] _list_devices (long g)
1122 throws LibGuestFSException;
1125 * list the partitions
1127 * List all the partitions detected on all block devices.
1129 * The full partition device names are returned, eg.
1132 * This does not return logical volumes. For that you will
1133 * need to call "g.lvs".
1135 * @throws LibGuestFSException
1137 public String[] list_partitions ()
1138 throws LibGuestFSException
1141 throw new LibGuestFSException ("list_partitions: handle is closed");
1142 return _list_partitions (g);
1144 private native String[] _list_partitions (long g)
1145 throws LibGuestFSException;
1148 * list the LVM physical volumes (PVs)
1150 * List all the physical volumes detected. This is the
1151 * equivalent of the pvs(8) command.
1153 * This returns a list of just the device names that
1154 * contain PVs (eg. "/dev/sda2").
1156 * See also "g.pvs_full".
1158 * @throws LibGuestFSException
1160 public String[] pvs ()
1161 throws LibGuestFSException
1164 throw new LibGuestFSException ("pvs: handle is closed");
1167 private native String[] _pvs (long g)
1168 throws LibGuestFSException;
1171 * list the LVM volume groups (VGs)
1173 * List all the volumes groups detected. This is the
1174 * equivalent of the vgs(8) command.
1176 * This returns a list of just the volume group names that
1177 * were detected (eg. "VolGroup00").
1179 * See also "g.vgs_full".
1181 * @throws LibGuestFSException
1183 public String[] vgs ()
1184 throws LibGuestFSException
1187 throw new LibGuestFSException ("vgs: handle is closed");
1190 private native String[] _vgs (long g)
1191 throws LibGuestFSException;
1194 * list the LVM logical volumes (LVs)
1196 * List all the logical volumes detected. This is the
1197 * equivalent of the lvs(8) command.
1199 * This returns a list of the logical volume device names
1200 * (eg. "/dev/VolGroup00/LogVol00").
1202 * See also "g.lvs_full".
1204 * @throws LibGuestFSException
1206 public String[] lvs ()
1207 throws LibGuestFSException
1210 throw new LibGuestFSException ("lvs: handle is closed");
1213 private native String[] _lvs (long g)
1214 throws LibGuestFSException;
1217 * list the LVM physical volumes (PVs)
1219 * List all the physical volumes detected. This is the
1220 * equivalent of the pvs(8) command. The "full" version
1221 * includes all fields.
1223 * @throws LibGuestFSException
1225 public PV[] pvs_full ()
1226 throws LibGuestFSException
1229 throw new LibGuestFSException ("pvs_full: handle is closed");
1230 return _pvs_full (g);
1232 private native PV[] _pvs_full (long g)
1233 throws LibGuestFSException;
1236 * list the LVM volume groups (VGs)
1238 * List all the volumes groups detected. This is the
1239 * equivalent of the vgs(8) command. The "full" version
1240 * includes all fields.
1242 * @throws LibGuestFSException
1244 public VG[] vgs_full ()
1245 throws LibGuestFSException
1248 throw new LibGuestFSException ("vgs_full: handle is closed");
1249 return _vgs_full (g);
1251 private native VG[] _vgs_full (long g)
1252 throws LibGuestFSException;
1255 * list the LVM logical volumes (LVs)
1257 * List all the logical volumes detected. This is the
1258 * equivalent of the lvs(8) command. The "full" version
1259 * includes all fields.
1261 * @throws LibGuestFSException
1263 public LV[] lvs_full ()
1264 throws LibGuestFSException
1267 throw new LibGuestFSException ("lvs_full: handle is closed");
1268 return _lvs_full (g);
1270 private native LV[] _lvs_full (long g)
1271 throws LibGuestFSException;
1274 * read file as lines
1276 * Return the contents of the file named "path".
1278 * The file contents are returned as a list of lines.
1279 * Trailing "LF" and "CRLF" character sequences are *not*
1282 * Note that this function cannot correctly handle binary
1283 * files (specifically, files containing "\0" character
1284 * which is treated as end of line). For those you need to
1285 * use the "g.read_file" function which has a more complex
1288 * @throws LibGuestFSException
1290 public String[] read_lines (String path)
1291 throws LibGuestFSException
1294 throw new LibGuestFSException ("read_lines: handle is closed");
1295 return _read_lines (g, path);
1297 private native String[] _read_lines (long g, String path)
1298 throws LibGuestFSException;
1301 * create a new Augeas handle
1303 * Create a new Augeas handle for editing configuration
1304 * files. If there was any previous Augeas handle
1305 * associated with this guestfs session, then it is closed.
1307 * You must call this before using any other "g.aug_*"
1310 * "root" is the filesystem root. "root" must not be NULL,
1313 * The flags are the same as the flags defined in
1314 * <augeas.h>, the logical *or* of the following integers:
1316 * "AUG_SAVE_BACKUP" = 1
1317 * Keep the original file with a ".augsave" extension.
1319 * "AUG_SAVE_NEWFILE" = 2
1320 * Save changes into a file with extension ".augnew",
1321 * and do not overwrite original. Overrides
1322 * "AUG_SAVE_BACKUP".
1324 * "AUG_TYPE_CHECK" = 4
1325 * Typecheck lenses (can be expensive).
1327 * "AUG_NO_STDINC" = 8
1328 * Do not use standard load path for modules.
1330 * "AUG_SAVE_NOOP" = 16
1331 * Make save a no-op, just record what would have been
1334 * "AUG_NO_LOAD" = 32
1335 * Do not load the tree in "g.aug_init".
1337 * To close the handle, you can call "g.aug_close".
1339 * To find out more about Augeas, see <http://augeas.net/>.
1341 * @throws LibGuestFSException
1343 public void aug_init (String root, int flags)
1344 throws LibGuestFSException
1347 throw new LibGuestFSException ("aug_init: handle is closed");
1348 _aug_init (g, root, flags);
1350 private native void _aug_init (long g, String root, int flags)
1351 throws LibGuestFSException;
1354 * close the current Augeas handle
1356 * Close the current Augeas handle and free up any
1357 * resources used by it. After calling this, you have to
1358 * call "g.aug_init" again before you can use any other
1361 * @throws LibGuestFSException
1363 public void aug_close ()
1364 throws LibGuestFSException
1367 throw new LibGuestFSException ("aug_close: handle is closed");
1370 private native void _aug_close (long g)
1371 throws LibGuestFSException;
1374 * define an Augeas variable
1376 * Defines an Augeas variable "name" whose value is the
1377 * result of evaluating "expr". If "expr" is NULL, then
1378 * "name" is undefined.
1380 * On success this returns the number of nodes in "expr",
1381 * or 0 if "expr" evaluates to something which is not a
1384 * @throws LibGuestFSException
1386 public int aug_defvar (String name, String expr)
1387 throws LibGuestFSException
1390 throw new LibGuestFSException ("aug_defvar: handle is closed");
1391 return _aug_defvar (g, name, expr);
1393 private native int _aug_defvar (long g, String name, String expr)
1394 throws LibGuestFSException;
1397 * define an Augeas node
1399 * Defines a variable "name" whose value is the result of
1400 * evaluating "expr".
1402 * If "expr" evaluates to an empty nodeset, a node is
1403 * created, equivalent to calling "g.aug_set" "expr",
1404 * "value". "name" will be the nodeset containing that
1407 * On success this returns a pair containing the number of
1408 * nodes in the nodeset, and a boolean flag if a node was
1411 * @throws LibGuestFSException
1413 public IntBool aug_defnode (String name, String expr, String val)
1414 throws LibGuestFSException
1417 throw new LibGuestFSException ("aug_defnode: handle is closed");
1418 return _aug_defnode (g, name, expr, val);
1420 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1421 throws LibGuestFSException;
1424 * look up the value of an Augeas path
1426 * Look up the value associated with "path". If "path"
1427 * matches exactly one node, the "value" is returned.
1429 * @throws LibGuestFSException
1431 public String aug_get (String path)
1432 throws LibGuestFSException
1435 throw new LibGuestFSException ("aug_get: handle is closed");
1436 return _aug_get (g, path);
1438 private native String _aug_get (long g, String path)
1439 throws LibGuestFSException;
1442 * set Augeas path to value
1444 * Set the value associated with "path" to "value".
1446 * @throws LibGuestFSException
1448 public void aug_set (String path, String val)
1449 throws LibGuestFSException
1452 throw new LibGuestFSException ("aug_set: handle is closed");
1453 _aug_set (g, path, val);
1455 private native void _aug_set (long g, String path, String val)
1456 throws LibGuestFSException;
1459 * insert a sibling Augeas node
1461 * Create a new sibling "label" for "path", inserting it
1462 * into the tree before or after "path" (depending on the
1463 * boolean flag "before").
1465 * "path" must match exactly one existing node in the tree,
1466 * and "label" must be a label, ie. not contain "/", "*" or
1467 * end with a bracketed index "[N]".
1469 * @throws LibGuestFSException
1471 public void aug_insert (String path, String label, boolean before)
1472 throws LibGuestFSException
1475 throw new LibGuestFSException ("aug_insert: handle is closed");
1476 _aug_insert (g, path, label, before);
1478 private native void _aug_insert (long g, String path, String label, boolean before)
1479 throws LibGuestFSException;
1482 * remove an Augeas path
1484 * Remove "path" and all of its children.
1486 * On success this returns the number of entries which were
1489 * @throws LibGuestFSException
1491 public int aug_rm (String path)
1492 throws LibGuestFSException
1495 throw new LibGuestFSException ("aug_rm: handle is closed");
1496 return _aug_rm (g, path);
1498 private native int _aug_rm (long g, String path)
1499 throws LibGuestFSException;
1504 * Move the node "src" to "dest". "src" must match exactly
1505 * one node. "dest" is overwritten if it exists.
1507 * @throws LibGuestFSException
1509 public void aug_mv (String src, String dest)
1510 throws LibGuestFSException
1513 throw new LibGuestFSException ("aug_mv: handle is closed");
1514 _aug_mv (g, src, dest);
1516 private native void _aug_mv (long g, String src, String dest)
1517 throws LibGuestFSException;
1520 * return Augeas nodes which match path
1522 * Returns a list of paths which match the path expression
1523 * "path". The returned paths are sufficiently qualified so
1524 * that they match exactly one node in the current tree.
1526 * @throws LibGuestFSException
1528 public String[] aug_match (String path)
1529 throws LibGuestFSException
1532 throw new LibGuestFSException ("aug_match: handle is closed");
1533 return _aug_match (g, path);
1535 private native String[] _aug_match (long g, String path)
1536 throws LibGuestFSException;
1539 * write all pending Augeas changes to disk
1541 * This writes all pending changes to disk.
1543 * The flags which were passed to "g.aug_init" affect
1544 * exactly how files are saved.
1546 * @throws LibGuestFSException
1548 public void aug_save ()
1549 throws LibGuestFSException
1552 throw new LibGuestFSException ("aug_save: handle is closed");
1555 private native void _aug_save (long g)
1556 throws LibGuestFSException;
1559 * load files into the tree
1561 * Load files into the tree.
1563 * See "aug_load" in the Augeas documentation for the full
1566 * @throws LibGuestFSException
1568 public void aug_load ()
1569 throws LibGuestFSException
1572 throw new LibGuestFSException ("aug_load: handle is closed");
1575 private native void _aug_load (long g)
1576 throws LibGuestFSException;
1579 * list Augeas nodes under a path
1581 * This is just a shortcut for listing "g.aug_match"
1582 * "path/*" and sorting the resulting nodes into
1583 * alphabetical order.
1585 * @throws LibGuestFSException
1587 public String[] aug_ls (String path)
1588 throws LibGuestFSException
1591 throw new LibGuestFSException ("aug_ls: handle is closed");
1592 return _aug_ls (g, path);
1594 private native String[] _aug_ls (long g, String path)
1595 throws LibGuestFSException;
1600 * Remove the single file "path".
1602 * @throws LibGuestFSException
1604 public void rm (String path)
1605 throws LibGuestFSException
1608 throw new LibGuestFSException ("rm: handle is closed");
1611 private native void _rm (long g, String path)
1612 throws LibGuestFSException;
1615 * remove a directory
1617 * Remove the single directory "path".
1619 * @throws LibGuestFSException
1621 public void rmdir (String path)
1622 throws LibGuestFSException
1625 throw new LibGuestFSException ("rmdir: handle is closed");
1628 private native void _rmdir (long g, String path)
1629 throws LibGuestFSException;
1632 * remove a file or directory recursively
1634 * Remove the file or directory "path", recursively
1635 * removing the contents if its a directory. This is like
1636 * the "rm -rf" shell command.
1638 * @throws LibGuestFSException
1640 public void rm_rf (String path)
1641 throws LibGuestFSException
1644 throw new LibGuestFSException ("rm_rf: handle is closed");
1647 private native void _rm_rf (long g, String path)
1648 throws LibGuestFSException;
1651 * create a directory
1653 * Create a directory named "path".
1655 * @throws LibGuestFSException
1657 public void mkdir (String path)
1658 throws LibGuestFSException
1661 throw new LibGuestFSException ("mkdir: handle is closed");
1664 private native void _mkdir (long g, String path)
1665 throws LibGuestFSException;
1668 * create a directory and parents
1670 * Create a directory named "path", creating any parent
1671 * directories as necessary. This is like the "mkdir -p"
1674 * @throws LibGuestFSException
1676 public void mkdir_p (String path)
1677 throws LibGuestFSException
1680 throw new LibGuestFSException ("mkdir_p: handle is closed");
1683 private native void _mkdir_p (long g, String path)
1684 throws LibGuestFSException;
1689 * Change the mode (permissions) of "path" to "mode". Only
1690 * numeric modes are supported.
1692 * @throws LibGuestFSException
1694 public void chmod (int mode, String path)
1695 throws LibGuestFSException
1698 throw new LibGuestFSException ("chmod: handle is closed");
1699 _chmod (g, mode, path);
1701 private native void _chmod (long g, int mode, String path)
1702 throws LibGuestFSException;
1705 * change file owner and group
1707 * Change the file owner to "owner" and group to "group".
1709 * Only numeric uid and gid are supported. If you want to
1710 * use names, you will need to locate and parse the
1711 * password file yourself (Augeas support makes this
1714 * @throws LibGuestFSException
1716 public void chown (int owner, int group, String path)
1717 throws LibGuestFSException
1720 throw new LibGuestFSException ("chown: handle is closed");
1721 _chown (g, owner, group, path);
1723 private native void _chown (long g, int owner, int group, String path)
1724 throws LibGuestFSException;
1727 * test if file or directory exists
1729 * This returns "true" if and only if there is a file,
1730 * directory (or anything) with the given "path" name.
1732 * See also "g.is_file", "g.is_dir", "g.stat".
1734 * @throws LibGuestFSException
1736 public boolean exists (String path)
1737 throws LibGuestFSException
1740 throw new LibGuestFSException ("exists: handle is closed");
1741 return _exists (g, path);
1743 private native boolean _exists (long g, String path)
1744 throws LibGuestFSException;
1747 * test if file exists
1749 * This returns "true" if and only if there is a file with
1750 * the given "path" name. Note that it returns false for
1751 * other objects like directories.
1753 * See also "g.stat".
1755 * @throws LibGuestFSException
1757 public boolean is_file (String path)
1758 throws LibGuestFSException
1761 throw new LibGuestFSException ("is_file: handle is closed");
1762 return _is_file (g, path);
1764 private native boolean _is_file (long g, String path)
1765 throws LibGuestFSException;
1768 * test if file exists
1770 * This returns "true" if and only if there is a directory
1771 * with the given "path" name. Note that it returns false
1772 * for other objects like files.
1774 * See also "g.stat".
1776 * @throws LibGuestFSException
1778 public boolean is_dir (String path)
1779 throws LibGuestFSException
1782 throw new LibGuestFSException ("is_dir: handle is closed");
1783 return _is_dir (g, path);
1785 private native boolean _is_dir (long g, String path)
1786 throws LibGuestFSException;
1789 * create an LVM physical volume
1791 * This creates an LVM physical volume on the named
1792 * "device", where "device" should usually be a partition
1793 * name such as "/dev/sda1".
1795 * @throws LibGuestFSException
1797 public void pvcreate (String device)
1798 throws LibGuestFSException
1801 throw new LibGuestFSException ("pvcreate: handle is closed");
1802 _pvcreate (g, device);
1804 private native void _pvcreate (long g, String device)
1805 throws LibGuestFSException;
1808 * create an LVM volume group
1810 * This creates an LVM volume group called "volgroup" from
1811 * the non-empty list of physical volumes "physvols".
1813 * @throws LibGuestFSException
1815 public void vgcreate (String volgroup, String[] physvols)
1816 throws LibGuestFSException
1819 throw new LibGuestFSException ("vgcreate: handle is closed");
1820 _vgcreate (g, volgroup, physvols);
1822 private native void _vgcreate (long g, String volgroup, String[] physvols)
1823 throws LibGuestFSException;
1826 * create an LVM volume group
1828 * This creates an LVM volume group called "logvol" on the
1829 * volume group "volgroup", with "size" megabytes.
1831 * @throws LibGuestFSException
1833 public void lvcreate (String logvol, String volgroup, int mbytes)
1834 throws LibGuestFSException
1837 throw new LibGuestFSException ("lvcreate: handle is closed");
1838 _lvcreate (g, logvol, volgroup, mbytes);
1840 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1841 throws LibGuestFSException;
1846 * This creates a filesystem on "device" (usually a
1847 * partition or LVM logical volume). The filesystem type is
1848 * "fstype", for example "ext3".
1850 * @throws LibGuestFSException
1852 public void mkfs (String fstype, String device)
1853 throws LibGuestFSException
1856 throw new LibGuestFSException ("mkfs: handle is closed");
1857 _mkfs (g, fstype, device);
1859 private native void _mkfs (long g, String fstype, String device)
1860 throws LibGuestFSException;
1863 * create partitions on a block device
1865 * This is a direct interface to the sfdisk(8) program for
1866 * creating partitions on block devices.
1868 * "device" should be a block device, for example
1871 * "cyls", "heads" and "sectors" are the number of
1872 * cylinders, heads and sectors on the device, which are
1873 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1874 * parameters. If you pass 0 for any of these, then the
1875 * corresponding parameter is omitted. Usually for 'large'
1876 * disks, you can just pass 0 for these, but for small
1877 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1878 * cannot work out the right geometry and you will need to
1881 * "lines" is a list of lines that we feed to "sfdisk". For
1882 * more information refer to the sfdisk(8) manpage.
1884 * To create a single partition occupying the whole disk,
1885 * you would pass "lines" as a single element list, when
1886 * the single element being the string "," (comma).
1888 * See also: "g.sfdisk_l", "g.sfdisk_N"
1890 * This command is dangerous. Without careful use you can
1891 * easily destroy all your data.
1893 * @throws LibGuestFSException
1895 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1896 throws LibGuestFSException
1899 throw new LibGuestFSException ("sfdisk: handle is closed");
1900 _sfdisk (g, device, cyls, heads, sectors, lines);
1902 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1903 throws LibGuestFSException;
1908 * This call creates a file called "path". The contents of
1909 * the file is the string "content" (which can contain any
1910 * 8 bit data), with length "size".
1912 * As a special case, if "size" is 0 then the length is
1913 * calculated using "strlen" (so in this case the content
1914 * cannot contain embedded ASCII NULs).
1916 * *NB.* Owing to a bug, writing content containing ASCII
1917 * NUL characters does *not* work, even if the length is
1918 * specified. We hope to resolve this bug in a future
1919 * version. In the meantime use "g.upload".
1921 * Because of the message protocol, there is a transfer
1922 * limit of somewhere between 2MB and 4MB. To transfer
1923 * large files you should use FTP.
1925 * @throws LibGuestFSException
1927 public void write_file (String path, String content, int size)
1928 throws LibGuestFSException
1931 throw new LibGuestFSException ("write_file: handle is closed");
1932 _write_file (g, path, content, size);
1934 private native void _write_file (long g, String path, String content, int size)
1935 throws LibGuestFSException;
1938 * unmount a filesystem
1940 * This unmounts the given filesystem. The filesystem may
1941 * be specified either by its mountpoint (path) or the
1942 * device which contains the filesystem.
1944 * @throws LibGuestFSException
1946 public void umount (String pathordevice)
1947 throws LibGuestFSException
1950 throw new LibGuestFSException ("umount: handle is closed");
1951 _umount (g, pathordevice);
1953 private native void _umount (long g, String pathordevice)
1954 throws LibGuestFSException;
1957 * show mounted filesystems
1959 * This returns the list of currently mounted filesystems.
1960 * It returns the list of devices (eg. "/dev/sda1",
1963 * Some internal mounts are not shown.
1965 * @throws LibGuestFSException
1967 public String[] mounts ()
1968 throws LibGuestFSException
1971 throw new LibGuestFSException ("mounts: handle is closed");
1974 private native String[] _mounts (long g)
1975 throws LibGuestFSException;
1978 * unmount all filesystems
1980 * This unmounts all mounted filesystems.
1982 * Some internal mounts are not unmounted by this call.
1984 * @throws LibGuestFSException
1986 public void umount_all ()
1987 throws LibGuestFSException
1990 throw new LibGuestFSException ("umount_all: handle is closed");
1993 private native void _umount_all (long g)
1994 throws LibGuestFSException;
1997 * remove all LVM LVs, VGs and PVs
1999 * This command removes all LVM logical volumes, volume
2000 * groups and physical volumes.
2002 * This command is dangerous. Without careful use you can
2003 * easily destroy all your data.
2005 * @throws LibGuestFSException
2007 public void lvm_remove_all ()
2008 throws LibGuestFSException
2011 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
2012 _lvm_remove_all (g);
2014 private native void _lvm_remove_all (long g)
2015 throws LibGuestFSException;
2018 * determine file type
2020 * This call uses the standard file(1) command to determine
2021 * the type or contents of the file. This also works on
2022 * devices, for example to find out whether a partition
2023 * contains a filesystem.
2025 * The exact command which runs is "file -bsL path". Note
2026 * in particular that the filename is not prepended to the
2027 * output (the "-b" option).
2029 * @throws LibGuestFSException
2031 public String file (String path)
2032 throws LibGuestFSException
2035 throw new LibGuestFSException ("file: handle is closed");
2036 return _file (g, path);
2038 private native String _file (long g, String path)
2039 throws LibGuestFSException;
2042 * run a command from the guest filesystem
2044 * This call runs a command from the guest filesystem. The
2045 * filesystem must be mounted, and must contain a
2046 * compatible operating system (ie. something Linux, with
2047 * the same or compatible processor architecture).
2049 * The single parameter is an argv-style list of arguments.
2050 * The first element is the name of the program to run.
2051 * Subsequent elements are parameters. The list must be
2052 * non-empty (ie. must contain a program name). Note that
2053 * the command runs directly, and is *not* invoked via the
2054 * shell (see "g.sh").
2056 * The return value is anything printed to *stdout* by the
2059 * If the command returns a non-zero exit status, then this
2060 * function returns an error message. The error message
2061 * string is the content of *stderr* from the command.
2063 * The $PATH environment variable will contain at least
2064 * "/usr/bin" and "/bin". If you require a program from
2065 * another location, you should provide the full path in
2066 * the first parameter.
2068 * Shared libraries and data files required by the program
2069 * must be available on filesystems which are mounted in
2070 * the correct places. It is the caller's responsibility to
2071 * ensure all filesystems that are needed are mounted at
2072 * the right locations.
2074 * Because of the message protocol, there is a transfer
2075 * limit of somewhere between 2MB and 4MB. To transfer
2076 * large files you should use FTP.
2078 * @throws LibGuestFSException
2080 public String command (String[] arguments)
2081 throws LibGuestFSException
2084 throw new LibGuestFSException ("command: handle is closed");
2085 return _command (g, arguments);
2087 private native String _command (long g, String[] arguments)
2088 throws LibGuestFSException;
2091 * run a command, returning lines
2093 * This is the same as "g.command", but splits the result
2094 * into a list of lines.
2096 * See also: "g.sh_lines"
2098 * Because of the message protocol, there is a transfer
2099 * limit of somewhere between 2MB and 4MB. To transfer
2100 * large files you should use FTP.
2102 * @throws LibGuestFSException
2104 public String[] command_lines (String[] arguments)
2105 throws LibGuestFSException
2108 throw new LibGuestFSException ("command_lines: handle is closed");
2109 return _command_lines (g, arguments);
2111 private native String[] _command_lines (long g, String[] arguments)
2112 throws LibGuestFSException;
2115 * get file information
2117 * Returns file information for the given "path".
2119 * This is the same as the stat(2) system call.
2121 * @throws LibGuestFSException
2123 public Stat stat (String path)
2124 throws LibGuestFSException
2127 throw new LibGuestFSException ("stat: handle is closed");
2128 return _stat (g, path);
2130 private native Stat _stat (long g, String path)
2131 throws LibGuestFSException;
2134 * get file information for a symbolic link
2136 * Returns file information for the given "path".
2138 * This is the same as "g.stat" except that if "path" is a
2139 * symbolic link, then the link is stat-ed, not the file it
2142 * This is the same as the lstat(2) system call.
2144 * @throws LibGuestFSException
2146 public Stat lstat (String path)
2147 throws LibGuestFSException
2150 throw new LibGuestFSException ("lstat: handle is closed");
2151 return _lstat (g, path);
2153 private native Stat _lstat (long g, String path)
2154 throws LibGuestFSException;
2157 * get file system statistics
2159 * Returns file system statistics for any mounted file
2160 * system. "path" should be a file or directory in the
2161 * mounted file system (typically it is the mount point
2162 * itself, but it doesn't need to be).
2164 * This is the same as the statvfs(2) system call.
2166 * @throws LibGuestFSException
2168 public StatVFS statvfs (String path)
2169 throws LibGuestFSException
2172 throw new LibGuestFSException ("statvfs: handle is closed");
2173 return _statvfs (g, path);
2175 private native StatVFS _statvfs (long g, String path)
2176 throws LibGuestFSException;
2179 * get ext2/ext3/ext4 superblock details
2181 * This returns the contents of the ext2, ext3 or ext4
2182 * filesystem superblock on "device".
2184 * It is the same as running "tune2fs -l device". See
2185 * tune2fs(8) manpage for more details. The list of fields
2186 * returned isn't clearly defined, and depends on both the
2187 * version of "tune2fs" that libguestfs was built against,
2188 * and the filesystem itself.
2190 * @throws LibGuestFSException
2192 public HashMap<String,String> tune2fs_l (String device)
2193 throws LibGuestFSException
2196 throw new LibGuestFSException ("tune2fs_l: handle is closed");
2197 return _tune2fs_l (g, device);
2199 private native HashMap<String,String> _tune2fs_l (long g, String device)
2200 throws LibGuestFSException;
2203 * set block device to read-only
2205 * Sets the block device named "device" to read-only.
2207 * This uses the blockdev(8) command.
2209 * @throws LibGuestFSException
2211 public void blockdev_setro (String device)
2212 throws LibGuestFSException
2215 throw new LibGuestFSException ("blockdev_setro: handle is closed");
2216 _blockdev_setro (g, device);
2218 private native void _blockdev_setro (long g, String device)
2219 throws LibGuestFSException;
2222 * set block device to read-write
2224 * Sets the block device named "device" to read-write.
2226 * This uses the blockdev(8) command.
2228 * @throws LibGuestFSException
2230 public void blockdev_setrw (String device)
2231 throws LibGuestFSException
2234 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2235 _blockdev_setrw (g, device);
2237 private native void _blockdev_setrw (long g, String device)
2238 throws LibGuestFSException;
2241 * is block device set to read-only
2243 * Returns a boolean indicating if the block device is
2244 * read-only (true if read-only, false if not).
2246 * This uses the blockdev(8) command.
2248 * @throws LibGuestFSException
2250 public boolean blockdev_getro (String device)
2251 throws LibGuestFSException
2254 throw new LibGuestFSException ("blockdev_getro: handle is closed");
2255 return _blockdev_getro (g, device);
2257 private native boolean _blockdev_getro (long g, String device)
2258 throws LibGuestFSException;
2261 * get sectorsize of block device
2263 * This returns the size of sectors on a block device.
2264 * Usually 512, but can be larger for modern devices.
2266 * (Note, this is not the size in sectors, use
2267 * "g.blockdev_getsz" for that).
2269 * This uses the blockdev(8) command.
2271 * @throws LibGuestFSException
2273 public int blockdev_getss (String device)
2274 throws LibGuestFSException
2277 throw new LibGuestFSException ("blockdev_getss: handle is closed");
2278 return _blockdev_getss (g, device);
2280 private native int _blockdev_getss (long g, String device)
2281 throws LibGuestFSException;
2284 * get blocksize of block device
2286 * This returns the block size of a device.
2288 * (Note this is different from both *size in blocks* and
2289 * *filesystem block size*).
2291 * This uses the blockdev(8) command.
2293 * @throws LibGuestFSException
2295 public int blockdev_getbsz (String device)
2296 throws LibGuestFSException
2299 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2300 return _blockdev_getbsz (g, device);
2302 private native int _blockdev_getbsz (long g, String device)
2303 throws LibGuestFSException;
2306 * set blocksize of block device
2308 * This sets the block size of a device.
2310 * (Note this is different from both *size in blocks* and
2311 * *filesystem block size*).
2313 * This uses the blockdev(8) command.
2315 * @throws LibGuestFSException
2317 public void blockdev_setbsz (String device, int blocksize)
2318 throws LibGuestFSException
2321 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2322 _blockdev_setbsz (g, device, blocksize);
2324 private native void _blockdev_setbsz (long g, String device, int blocksize)
2325 throws LibGuestFSException;
2328 * get total size of device in 512-byte sectors
2330 * This returns the size of the device in units of 512-byte
2331 * sectors (even if the sectorsize isn't 512 bytes ...
2334 * See also "g.blockdev_getss" for the real sector size of
2335 * the device, and "g.blockdev_getsize64" for the more
2336 * useful *size in bytes*.
2338 * This uses the blockdev(8) command.
2340 * @throws LibGuestFSException
2342 public long blockdev_getsz (String device)
2343 throws LibGuestFSException
2346 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2347 return _blockdev_getsz (g, device);
2349 private native long _blockdev_getsz (long g, String device)
2350 throws LibGuestFSException;
2353 * get total size of device in bytes
2355 * This returns the size of the device in bytes.
2357 * See also "g.blockdev_getsz".
2359 * This uses the blockdev(8) command.
2361 * @throws LibGuestFSException
2363 public long blockdev_getsize64 (String device)
2364 throws LibGuestFSException
2367 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2368 return _blockdev_getsize64 (g, device);
2370 private native long _blockdev_getsize64 (long g, String device)
2371 throws LibGuestFSException;
2374 * flush device buffers
2376 * This tells the kernel to flush internal buffers
2377 * associated with "device".
2379 * This uses the blockdev(8) command.
2381 * @throws LibGuestFSException
2383 public void blockdev_flushbufs (String device)
2384 throws LibGuestFSException
2387 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2388 _blockdev_flushbufs (g, device);
2390 private native void _blockdev_flushbufs (long g, String device)
2391 throws LibGuestFSException;
2394 * reread partition table
2396 * Reread the partition table on "device".
2398 * This uses the blockdev(8) command.
2400 * @throws LibGuestFSException
2402 public void blockdev_rereadpt (String device)
2403 throws LibGuestFSException
2406 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2407 _blockdev_rereadpt (g, device);
2409 private native void _blockdev_rereadpt (long g, String device)
2410 throws LibGuestFSException;
2413 * upload a file from the local machine
2415 * Upload local file "filename" to "remotefilename" on the
2418 * "filename" can also be a named pipe.
2420 * See also "g.download".
2422 * @throws LibGuestFSException
2424 public void upload (String filename, String remotefilename)
2425 throws LibGuestFSException
2428 throw new LibGuestFSException ("upload: handle is closed");
2429 _upload (g, filename, remotefilename);
2431 private native void _upload (long g, String filename, String remotefilename)
2432 throws LibGuestFSException;
2435 * download a file to the local machine
2437 * Download file "remotefilename" and save it as "filename"
2438 * on the local machine.
2440 * "filename" can also be a named pipe.
2442 * See also "g.upload", "g.cat".
2444 * @throws LibGuestFSException
2446 public void download (String remotefilename, String filename)
2447 throws LibGuestFSException
2450 throw new LibGuestFSException ("download: handle is closed");
2451 _download (g, remotefilename, filename);
2453 private native void _download (long g, String remotefilename, String filename)
2454 throws LibGuestFSException;
2457 * compute MD5, SHAx or CRC checksum of file
2459 * This call computes the MD5, SHAx or CRC checksum of the
2460 * file named "path".
2462 * The type of checksum to compute is given by the
2463 * "csumtype" parameter which must have one of the
2467 * Compute the cyclic redundancy check (CRC) specified
2468 * by POSIX for the "cksum" command.
2471 * Compute the MD5 hash (using the "md5sum" program).
2474 * Compute the SHA1 hash (using the "sha1sum" program).
2477 * Compute the SHA224 hash (using the "sha224sum"
2481 * Compute the SHA256 hash (using the "sha256sum"
2485 * Compute the SHA384 hash (using the "sha384sum"
2489 * Compute the SHA512 hash (using the "sha512sum"
2492 * The checksum is returned as a printable string.
2494 * @throws LibGuestFSException
2496 public String checksum (String csumtype, String path)
2497 throws LibGuestFSException
2500 throw new LibGuestFSException ("checksum: handle is closed");
2501 return _checksum (g, csumtype, path);
2503 private native String _checksum (long g, String csumtype, String path)
2504 throws LibGuestFSException;
2507 * unpack tarfile to directory
2509 * This command uploads and unpacks local file "tarfile"
2510 * (an *uncompressed* tar file) into "directory".
2512 * To upload a compressed tarball, use "g.tgz_in".
2514 * @throws LibGuestFSException
2516 public void tar_in (String tarfile, String directory)
2517 throws LibGuestFSException
2520 throw new LibGuestFSException ("tar_in: handle is closed");
2521 _tar_in (g, tarfile, directory);
2523 private native void _tar_in (long g, String tarfile, String directory)
2524 throws LibGuestFSException;
2527 * pack directory into tarfile
2529 * This command packs the contents of "directory" and
2530 * downloads it to local file "tarfile".
2532 * To download a compressed tarball, use "g.tgz_out".
2534 * @throws LibGuestFSException
2536 public void tar_out (String directory, String tarfile)
2537 throws LibGuestFSException
2540 throw new LibGuestFSException ("tar_out: handle is closed");
2541 _tar_out (g, directory, tarfile);
2543 private native void _tar_out (long g, String directory, String tarfile)
2544 throws LibGuestFSException;
2547 * unpack compressed tarball to directory
2549 * This command uploads and unpacks local file "tarball" (a
2550 * *gzip compressed* tar file) into "directory".
2552 * To upload an uncompressed tarball, use "g.tar_in".
2554 * @throws LibGuestFSException
2556 public void tgz_in (String tarball, String directory)
2557 throws LibGuestFSException
2560 throw new LibGuestFSException ("tgz_in: handle is closed");
2561 _tgz_in (g, tarball, directory);
2563 private native void _tgz_in (long g, String tarball, String directory)
2564 throws LibGuestFSException;
2567 * pack directory into compressed tarball
2569 * This command packs the contents of "directory" and
2570 * downloads it to local file "tarball".
2572 * To download an uncompressed tarball, use "g.tar_out".
2574 * @throws LibGuestFSException
2576 public void tgz_out (String directory, String tarball)
2577 throws LibGuestFSException
2580 throw new LibGuestFSException ("tgz_out: handle is closed");
2581 _tgz_out (g, directory, tarball);
2583 private native void _tgz_out (long g, String directory, String tarball)
2584 throws LibGuestFSException;
2587 * mount a guest disk, read-only
2589 * This is the same as the "g.mount" command, but it mounts
2590 * the filesystem with the read-only (*-o ro*) flag.
2592 * @throws LibGuestFSException
2594 public void mount_ro (String device, String mountpoint)
2595 throws LibGuestFSException
2598 throw new LibGuestFSException ("mount_ro: handle is closed");
2599 _mount_ro (g, device, mountpoint);
2601 private native void _mount_ro (long g, String device, String mountpoint)
2602 throws LibGuestFSException;
2605 * mount a guest disk with mount options
2607 * This is the same as the "g.mount" command, but it allows
2608 * you to set the mount options as for the mount(8) *-o*
2611 * @throws LibGuestFSException
2613 public void mount_options (String options, String device, String mountpoint)
2614 throws LibGuestFSException
2617 throw new LibGuestFSException ("mount_options: handle is closed");
2618 _mount_options (g, options, device, mountpoint);
2620 private native void _mount_options (long g, String options, String device, String mountpoint)
2621 throws LibGuestFSException;
2624 * mount a guest disk with mount options and vfstype
2626 * This is the same as the "g.mount" command, but it allows
2627 * you to set both the mount options and the vfstype as for
2628 * the mount(8) *-o* and *-t* flags.
2630 * @throws LibGuestFSException
2632 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2633 throws LibGuestFSException
2636 throw new LibGuestFSException ("mount_vfs: handle is closed");
2637 _mount_vfs (g, options, vfstype, device, mountpoint);
2639 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2640 throws LibGuestFSException;
2643 * debugging and internals
2645 * The "g.debug" command exposes some internals of
2646 * "guestfsd" (the guestfs daemon) that runs inside the
2649 * There is no comprehensive help for this command. You
2650 * have to look at the file "daemon/debug.c" in the
2651 * libguestfs source to find out what you can do.
2653 * @throws LibGuestFSException
2655 public String debug (String subcmd, String[] extraargs)
2656 throws LibGuestFSException
2659 throw new LibGuestFSException ("debug: handle is closed");
2660 return _debug (g, subcmd, extraargs);
2662 private native String _debug (long g, String subcmd, String[] extraargs)
2663 throws LibGuestFSException;
2666 * remove an LVM logical volume
2668 * Remove an LVM logical volume "device", where "device" is
2669 * the path to the LV, such as "/dev/VG/LV".
2671 * You can also remove all LVs in a volume group by
2672 * specifying the VG name, "/dev/VG".
2674 * @throws LibGuestFSException
2676 public void lvremove (String device)
2677 throws LibGuestFSException
2680 throw new LibGuestFSException ("lvremove: handle is closed");
2681 _lvremove (g, device);
2683 private native void _lvremove (long g, String device)
2684 throws LibGuestFSException;
2687 * remove an LVM volume group
2689 * Remove an LVM volume group "vgname", (for example "VG").
2691 * This also forcibly removes all logical volumes in the
2692 * volume group (if any).
2694 * @throws LibGuestFSException
2696 public void vgremove (String vgname)
2697 throws LibGuestFSException
2700 throw new LibGuestFSException ("vgremove: handle is closed");
2701 _vgremove (g, vgname);
2703 private native void _vgremove (long g, String vgname)
2704 throws LibGuestFSException;
2707 * remove an LVM physical volume
2709 * This wipes a physical volume "device" so that LVM will
2710 * no longer recognise it.
2712 * The implementation uses the "pvremove" command which
2713 * refuses to wipe physical volumes that contain any volume
2714 * groups, so you have to remove those first.
2716 * @throws LibGuestFSException
2718 public void pvremove (String device)
2719 throws LibGuestFSException
2722 throw new LibGuestFSException ("pvremove: handle is closed");
2723 _pvremove (g, device);
2725 private native void _pvremove (long g, String device)
2726 throws LibGuestFSException;
2729 * set the ext2/3/4 filesystem label
2731 * This sets the ext2/3/4 filesystem label of the
2732 * filesystem on "device" to "label". Filesystem labels are
2733 * limited to 16 characters.
2735 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2736 * return the existing label on a filesystem.
2738 * @throws LibGuestFSException
2740 public void set_e2label (String device, String label)
2741 throws LibGuestFSException
2744 throw new LibGuestFSException ("set_e2label: handle is closed");
2745 _set_e2label (g, device, label);
2747 private native void _set_e2label (long g, String device, String label)
2748 throws LibGuestFSException;
2751 * get the ext2/3/4 filesystem label
2753 * This returns the ext2/3/4 filesystem label of the
2754 * filesystem on "device".
2756 * @throws LibGuestFSException
2758 public String get_e2label (String device)
2759 throws LibGuestFSException
2762 throw new LibGuestFSException ("get_e2label: handle is closed");
2763 return _get_e2label (g, device);
2765 private native String _get_e2label (long g, String device)
2766 throws LibGuestFSException;
2769 * set the ext2/3/4 filesystem UUID
2771 * This sets the ext2/3/4 filesystem UUID of the filesystem
2772 * on "device" to "uuid". The format of the UUID and
2773 * alternatives such as "clear", "random" and "time" are
2774 * described in the tune2fs(8) manpage.
2776 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2777 * return the existing UUID of a filesystem.
2779 * @throws LibGuestFSException
2781 public void set_e2uuid (String device, String uuid)
2782 throws LibGuestFSException
2785 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2786 _set_e2uuid (g, device, uuid);
2788 private native void _set_e2uuid (long g, String device, String uuid)
2789 throws LibGuestFSException;
2792 * get the ext2/3/4 filesystem UUID
2794 * This returns the ext2/3/4 filesystem UUID of the
2795 * filesystem on "device".
2797 * @throws LibGuestFSException
2799 public String get_e2uuid (String device)
2800 throws LibGuestFSException
2803 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2804 return _get_e2uuid (g, device);
2806 private native String _get_e2uuid (long g, String device)
2807 throws LibGuestFSException;
2810 * run the filesystem checker
2812 * This runs the filesystem checker (fsck) on "device"
2813 * which should have filesystem type "fstype".
2815 * The returned integer is the status. See fsck(8) for the
2816 * list of status codes from "fsck".
2820 * * Multiple status codes can be summed together.
2822 * * A non-zero return code can mean "success", for
2823 * example if errors have been corrected on the
2826 * * Checking or repairing NTFS volumes is not supported
2829 * This command is entirely equivalent to running "fsck -a
2830 * -t fstype device".
2832 * @throws LibGuestFSException
2834 public int fsck (String fstype, String device)
2835 throws LibGuestFSException
2838 throw new LibGuestFSException ("fsck: handle is closed");
2839 return _fsck (g, fstype, device);
2841 private native int _fsck (long g, String fstype, String device)
2842 throws LibGuestFSException;
2845 * write zeroes to the device
2847 * This command writes zeroes over the first few blocks of
2850 * How many blocks are zeroed isn't specified (but it's
2851 * *not* enough to securely wipe the device). It should be
2852 * sufficient to remove any partition tables, filesystem
2853 * superblocks and so on.
2855 * See also: "g.scrub_device".
2857 * @throws LibGuestFSException
2859 public void zero (String device)
2860 throws LibGuestFSException
2863 throw new LibGuestFSException ("zero: handle is closed");
2866 private native void _zero (long g, String device)
2867 throws LibGuestFSException;
2872 * This command installs GRUB (the Grand Unified
2873 * Bootloader) on "device", with the root directory being
2876 * @throws LibGuestFSException
2878 public void grub_install (String root, String device)
2879 throws LibGuestFSException
2882 throw new LibGuestFSException ("grub_install: handle is closed");
2883 _grub_install (g, root, device);
2885 private native void _grub_install (long g, String root, String device)
2886 throws LibGuestFSException;
2891 * This copies a file from "src" to "dest" where "dest" is
2892 * either a destination filename or destination directory.
2894 * @throws LibGuestFSException
2896 public void cp (String src, String dest)
2897 throws LibGuestFSException
2900 throw new LibGuestFSException ("cp: handle is closed");
2903 private native void _cp (long g, String src, String dest)
2904 throws LibGuestFSException;
2907 * copy a file or directory recursively
2909 * This copies a file or directory from "src" to "dest"
2910 * recursively using the "cp -a" command.
2912 * @throws LibGuestFSException
2914 public void cp_a (String src, String dest)
2915 throws LibGuestFSException
2918 throw new LibGuestFSException ("cp_a: handle is closed");
2919 _cp_a (g, src, dest);
2921 private native void _cp_a (long g, String src, String dest)
2922 throws LibGuestFSException;
2927 * This moves a file from "src" to "dest" where "dest" is
2928 * either a destination filename or destination directory.
2930 * @throws LibGuestFSException
2932 public void mv (String src, String dest)
2933 throws LibGuestFSException
2936 throw new LibGuestFSException ("mv: handle is closed");
2939 private native void _mv (long g, String src, String dest)
2940 throws LibGuestFSException;
2943 * drop kernel page cache, dentries and inodes
2945 * This instructs the guest kernel to drop its page cache,
2946 * and/or dentries and inode caches. The parameter
2947 * "whattodrop" tells the kernel what precisely to drop,
2948 * see <http://linux-mm.org/Drop_Caches>
2950 * Setting "whattodrop" to 3 should drop everything.
2952 * This automatically calls sync(2) before the operation,
2953 * so that the maximum guest memory is freed.
2955 * @throws LibGuestFSException
2957 public void drop_caches (int whattodrop)
2958 throws LibGuestFSException
2961 throw new LibGuestFSException ("drop_caches: handle is closed");
2962 _drop_caches (g, whattodrop);
2964 private native void _drop_caches (long g, int whattodrop)
2965 throws LibGuestFSException;
2968 * return kernel messages
2970 * This returns the kernel messages ("dmesg" output) from
2971 * the guest kernel. This is sometimes useful for extended
2972 * debugging of problems.
2974 * Another way to get the same information is to enable
2975 * verbose messages with "g.set_verbose" or by setting the
2976 * environment variable "LIBGUESTFS_DEBUG=1" before running
2979 * @throws LibGuestFSException
2981 public String dmesg ()
2982 throws LibGuestFSException
2985 throw new LibGuestFSException ("dmesg: handle is closed");
2988 private native String _dmesg (long g)
2989 throws LibGuestFSException;
2992 * ping the guest daemon
2994 * This is a test probe into the guestfs daemon running
2995 * inside the qemu subprocess. Calling this function checks
2996 * that the daemon responds to the ping message, without
2997 * affecting the daemon or attached block device(s) in any
3000 * @throws LibGuestFSException
3002 public void ping_daemon ()
3003 throws LibGuestFSException
3006 throw new LibGuestFSException ("ping_daemon: handle is closed");
3009 private native void _ping_daemon (long g)
3010 throws LibGuestFSException;
3013 * test if two files have equal contents
3015 * This compares the two files "file1" and "file2" and
3016 * returns true if their content is exactly equal, or false
3019 * The external cmp(1) program is used for the comparison.
3021 * @throws LibGuestFSException
3023 public boolean equal (String file1, String file2)
3024 throws LibGuestFSException
3027 throw new LibGuestFSException ("equal: handle is closed");
3028 return _equal (g, file1, file2);
3030 private native boolean _equal (long g, String file1, String file2)
3031 throws LibGuestFSException;
3034 * print the printable strings in a file
3036 * This runs the strings(1) command on a file and returns
3037 * the list of printable strings found.
3039 * Because of the message protocol, there is a transfer
3040 * limit of somewhere between 2MB and 4MB. To transfer
3041 * large files you should use FTP.
3043 * @throws LibGuestFSException
3045 public String[] strings (String path)
3046 throws LibGuestFSException
3049 throw new LibGuestFSException ("strings: handle is closed");
3050 return _strings (g, path);
3052 private native String[] _strings (long g, String path)
3053 throws LibGuestFSException;
3056 * print the printable strings in a file
3058 * This is like the "g.strings" command, but allows you to
3059 * specify the encoding.
3061 * See the strings(1) manpage for the full list of
3064 * Commonly useful encodings are "l" (lower case L) which
3065 * will show strings inside Windows/x86 files.
3067 * The returned strings are transcoded to UTF-8.
3069 * Because of the message protocol, there is a transfer
3070 * limit of somewhere between 2MB and 4MB. To transfer
3071 * large files you should use FTP.
3073 * @throws LibGuestFSException
3075 public String[] strings_e (String encoding, String path)
3076 throws LibGuestFSException
3079 throw new LibGuestFSException ("strings_e: handle is closed");
3080 return _strings_e (g, encoding, path);
3082 private native String[] _strings_e (long g, String encoding, String path)
3083 throws LibGuestFSException;
3086 * dump a file in hexadecimal
3088 * This runs "hexdump -C" on the given "path". The result
3089 * is the human-readable, canonical hex dump of the file.
3091 * Because of the message protocol, there is a transfer
3092 * limit of somewhere between 2MB and 4MB. To transfer
3093 * large files you should use FTP.
3095 * @throws LibGuestFSException
3097 public String hexdump (String path)
3098 throws LibGuestFSException
3101 throw new LibGuestFSException ("hexdump: handle is closed");
3102 return _hexdump (g, path);
3104 private native String _hexdump (long g, String path)
3105 throws LibGuestFSException;
3108 * zero unused inodes and disk blocks on ext2/3 filesystem
3110 * This runs the *zerofree* program on "device". This
3111 * program claims to zero unused inodes and disk blocks on
3112 * an ext2/3 filesystem, thus making it possible to
3113 * compress the filesystem more effectively.
3115 * You should not run this program if the filesystem is
3118 * It is possible that using this program can damage the
3119 * filesystem or data on the filesystem.
3121 * @throws LibGuestFSException
3123 public void zerofree (String device)
3124 throws LibGuestFSException
3127 throw new LibGuestFSException ("zerofree: handle is closed");
3128 _zerofree (g, device);
3130 private native void _zerofree (long g, String device)
3131 throws LibGuestFSException;
3134 * resize an LVM physical volume
3136 * This resizes (expands or shrinks) an existing LVM
3137 * physical volume to match the new size of the underlying
3140 * @throws LibGuestFSException
3142 public void pvresize (String device)
3143 throws LibGuestFSException
3146 throw new LibGuestFSException ("pvresize: handle is closed");
3147 _pvresize (g, device);
3149 private native void _pvresize (long g, String device)
3150 throws LibGuestFSException;
3153 * modify a single partition on a block device
3155 * This runs sfdisk(8) option to modify just the single
3156 * partition "n" (note: "n" counts from 1).
3158 * For other parameters, see "g.sfdisk". You should usually
3159 * pass 0 for the cyls/heads/sectors parameters.
3161 * This command is dangerous. Without careful use you can
3162 * easily destroy all your data.
3164 * @throws LibGuestFSException
3166 public void sfdisk_N (String device, int partnum, int cyls, int heads, int sectors, String line)
3167 throws LibGuestFSException
3170 throw new LibGuestFSException ("sfdisk_N: handle is closed");
3171 _sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
3173 private native void _sfdisk_N (long g, String device, int partnum, int cyls, int heads, int sectors, String line)
3174 throws LibGuestFSException;
3177 * display the partition table
3179 * This displays the partition table on "device", in the
3180 * human-readable output of the sfdisk(8) command. It is
3181 * not intended to be parsed.
3183 * @throws LibGuestFSException
3185 public String sfdisk_l (String device)
3186 throws LibGuestFSException
3189 throw new LibGuestFSException ("sfdisk_l: handle is closed");
3190 return _sfdisk_l (g, device);
3192 private native String _sfdisk_l (long g, String device)
3193 throws LibGuestFSException;
3196 * display the kernel geometry
3198 * This displays the kernel's idea of the geometry of
3201 * The result is in human-readable format, and not designed
3204 * @throws LibGuestFSException
3206 public String sfdisk_kernel_geometry (String device)
3207 throws LibGuestFSException
3210 throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3211 return _sfdisk_kernel_geometry (g, device);
3213 private native String _sfdisk_kernel_geometry (long g, String device)
3214 throws LibGuestFSException;
3217 * display the disk geometry from the partition table
3219 * This displays the disk geometry of "device" read from
3220 * the partition table. Especially in the case where the
3221 * underlying block device has been resized, this can be
3222 * different from the kernel's idea of the geometry (see
3223 * "g.sfdisk_kernel_geometry").
3225 * The result is in human-readable format, and not designed
3228 * @throws LibGuestFSException
3230 public String sfdisk_disk_geometry (String device)
3231 throws LibGuestFSException
3234 throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3235 return _sfdisk_disk_geometry (g, device);
3237 private native String _sfdisk_disk_geometry (long g, String device)
3238 throws LibGuestFSException;
3241 * activate or deactivate all volume groups
3243 * This command activates or (if "activate" is false)
3244 * deactivates all logical volumes in all volume groups. If
3245 * activated, then they are made known to the kernel, ie.
3246 * they appear as "/dev/mapper" devices. If deactivated,
3247 * then those devices disappear.
3249 * This command is the same as running "vgchange -a y|n"
3251 * @throws LibGuestFSException
3253 public void vg_activate_all (boolean activate)
3254 throws LibGuestFSException
3257 throw new LibGuestFSException ("vg_activate_all: handle is closed");
3258 _vg_activate_all (g, activate);
3260 private native void _vg_activate_all (long g, boolean activate)
3261 throws LibGuestFSException;
3264 * activate or deactivate some volume groups
3266 * This command activates or (if "activate" is false)
3267 * deactivates all logical volumes in the listed volume
3268 * groups "volgroups". If activated, then they are made
3269 * known to the kernel, ie. they appear as "/dev/mapper"
3270 * devices. If deactivated, then those devices disappear.
3272 * This command is the same as running "vgchange -a y|n
3275 * Note that if "volgroups" is an empty list then all
3276 * volume groups are activated or deactivated.
3278 * @throws LibGuestFSException
3280 public void vg_activate (boolean activate, String[] volgroups)
3281 throws LibGuestFSException
3284 throw new LibGuestFSException ("vg_activate: handle is closed");
3285 _vg_activate (g, activate, volgroups);
3287 private native void _vg_activate (long g, boolean activate, String[] volgroups)
3288 throws LibGuestFSException;
3291 * resize an LVM logical volume
3293 * This resizes (expands or shrinks) an existing LVM
3294 * logical volume to "mbytes". When reducing, data in the
3295 * reduced part is lost.
3297 * @throws LibGuestFSException
3299 public void lvresize (String device, int mbytes)
3300 throws LibGuestFSException
3303 throw new LibGuestFSException ("lvresize: handle is closed");
3304 _lvresize (g, device, mbytes);
3306 private native void _lvresize (long g, String device, int mbytes)
3307 throws LibGuestFSException;
3310 * resize an ext2/ext3 filesystem
3312 * This resizes an ext2 or ext3 filesystem to match the
3313 * size of the underlying device.
3315 * *Note:* It is sometimes required that you run
3316 * "g.e2fsck_f" on the "device" before calling this
3317 * command. For unknown reasons "resize2fs" sometimes gives
3318 * an error about this and sometimes not. In any case, it
3319 * is always safe to call "g.e2fsck_f" before calling this
3322 * @throws LibGuestFSException
3324 public void resize2fs (String device)
3325 throws LibGuestFSException
3328 throw new LibGuestFSException ("resize2fs: handle is closed");
3329 _resize2fs (g, device);
3331 private native void _resize2fs (long g, String device)
3332 throws LibGuestFSException;
3335 * find all files and directories
3337 * This command lists out all files and directories,
3338 * recursively, starting at "directory". It is essentially
3339 * equivalent to running the shell command "find directory
3340 * -print" but some post-processing happens on the output,
3343 * This returns a list of strings *without any prefix*.
3344 * Thus if the directory structure was:
3350 * then the returned list from "g.find" "/tmp" would be 4
3358 * If "directory" is not a directory, then this command
3361 * The returned list is sorted.
3363 * @throws LibGuestFSException
3365 public String[] find (String directory)
3366 throws LibGuestFSException
3369 throw new LibGuestFSException ("find: handle is closed");
3370 return _find (g, directory);
3372 private native String[] _find (long g, String directory)
3373 throws LibGuestFSException;
3376 * check an ext2/ext3 filesystem
3378 * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3379 * filesystem checker on "device", noninteractively ("-p"),
3380 * even if the filesystem appears to be clean ("-f").
3382 * This command is only needed because of "g.resize2fs"
3383 * (q.v.). Normally you should use "g.fsck".
3385 * @throws LibGuestFSException
3387 public void e2fsck_f (String device)
3388 throws LibGuestFSException
3391 throw new LibGuestFSException ("e2fsck_f: handle is closed");
3392 _e2fsck_f (g, device);
3394 private native void _e2fsck_f (long g, String device)
3395 throws LibGuestFSException;
3398 * sleep for some seconds
3400 * Sleep for "secs" seconds.
3402 * @throws LibGuestFSException
3404 public void sleep (int secs)
3405 throws LibGuestFSException
3408 throw new LibGuestFSException ("sleep: handle is closed");
3411 private native void _sleep (long g, int secs)
3412 throws LibGuestFSException;
3417 * This command runs the ntfs-3g.probe(8) command which
3418 * probes an NTFS "device" for mountability. (Not all NTFS
3419 * volumes can be mounted read-write, and some cannot be
3422 * "rw" is a boolean flag. Set it to true if you want to
3423 * test if the volume can be mounted read-write. Set it to
3424 * false if you want to test if the volume can be mounted
3427 * The return value is an integer which 0 if the operation
3428 * would succeed, or some non-zero value documented in the
3429 * ntfs-3g.probe(8) manual page.
3431 * @throws LibGuestFSException
3433 public int ntfs_3g_probe (boolean rw, String device)
3434 throws LibGuestFSException
3437 throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
3438 return _ntfs_3g_probe (g, rw, device);
3440 private native int _ntfs_3g_probe (long g, boolean rw, String device)
3441 throws LibGuestFSException;
3444 * run a command via the shell
3446 * This call runs a command from the guest filesystem via
3447 * the guest's "/bin/sh".
3449 * This is like "g.command", but passes the command to:
3451 * /bin/sh -c "command"
3453 * Depending on the guest's shell, this usually results in
3454 * wildcards being expanded, shell expressions being
3455 * interpolated and so on.
3457 * All the provisos about "g.command" apply to this call.
3459 * @throws LibGuestFSException
3461 public String sh (String command)
3462 throws LibGuestFSException
3465 throw new LibGuestFSException ("sh: handle is closed");
3466 return _sh (g, command);
3468 private native String _sh (long g, String command)
3469 throws LibGuestFSException;
3472 * run a command via the shell returning lines
3474 * This is the same as "g.sh", but splits the result into a
3477 * See also: "g.command_lines"
3479 * @throws LibGuestFSException
3481 public String[] sh_lines (String command)
3482 throws LibGuestFSException
3485 throw new LibGuestFSException ("sh_lines: handle is closed");
3486 return _sh_lines (g, command);
3488 private native String[] _sh_lines (long g, String command)
3489 throws LibGuestFSException;
3492 * expand a wildcard path
3494 * This command searches for all the pathnames matching
3495 * "pattern" according to the wildcard expansion rules used
3498 * If no paths match, then this returns an empty list
3499 * (note: not an error).
3501 * It is just a wrapper around the C glob(3) function with
3502 * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
3505 * @throws LibGuestFSException
3507 public String[] glob_expand (String pattern)
3508 throws LibGuestFSException
3511 throw new LibGuestFSException ("glob_expand: handle is closed");
3512 return _glob_expand (g, pattern);
3514 private native String[] _glob_expand (long g, String pattern)
3515 throws LibGuestFSException;
3518 * scrub (securely wipe) a device
3520 * This command writes patterns over "device" to make data
3521 * retrieval more difficult.
3523 * It is an interface to the scrub(1) program. See that
3524 * manual page for more details.
3526 * This command is dangerous. Without careful use you can
3527 * easily destroy all your data.
3529 * @throws LibGuestFSException
3531 public void scrub_device (String device)
3532 throws LibGuestFSException
3535 throw new LibGuestFSException ("scrub_device: handle is closed");
3536 _scrub_device (g, device);
3538 private native void _scrub_device (long g, String device)
3539 throws LibGuestFSException;
3542 * scrub (securely wipe) a file
3544 * This command writes patterns over a file to make data
3545 * retrieval more difficult.
3547 * The file is *removed* after scrubbing.
3549 * It is an interface to the scrub(1) program. See that
3550 * manual page for more details.
3552 * @throws LibGuestFSException
3554 public void scrub_file (String file)
3555 throws LibGuestFSException
3558 throw new LibGuestFSException ("scrub_file: handle is closed");
3559 _scrub_file (g, file);
3561 private native void _scrub_file (long g, String file)
3562 throws LibGuestFSException;
3565 * scrub (securely wipe) free space
3567 * This command creates the directory "dir" and then fills
3568 * it with files until the filesystem is full, and scrubs
3569 * the files as for "g.scrub_file", and deletes them. The
3570 * intention is to scrub any free space on the partition
3573 * It is an interface to the scrub(1) program. See that
3574 * manual page for more details.
3576 * @throws LibGuestFSException
3578 public void scrub_freespace (String dir)
3579 throws LibGuestFSException
3582 throw new LibGuestFSException ("scrub_freespace: handle is closed");
3583 _scrub_freespace (g, dir);
3585 private native void _scrub_freespace (long g, String dir)
3586 throws LibGuestFSException;
3589 * create a temporary directory
3591 * This command creates a temporary directory. The
3592 * "template" parameter should be a full pathname for the
3593 * temporary directory name with the final six characters
3596 * For example: "/tmp/myprogXXXXXX" or
3597 * "/Temp/myprogXXXXXX", the second one being suitable for
3598 * Windows filesystems.
3600 * The name of the temporary directory that was created is
3603 * The temporary directory is created with mode 0700 and is
3606 * The caller is responsible for deleting the temporary
3607 * directory and its contents after use.
3609 * See also: mkdtemp(3)
3611 * @throws LibGuestFSException
3613 public String mkdtemp (String template)
3614 throws LibGuestFSException
3617 throw new LibGuestFSException ("mkdtemp: handle is closed");
3618 return _mkdtemp (g, template);
3620 private native String _mkdtemp (long g, String template)
3621 throws LibGuestFSException;
3624 * count lines in a file
3626 * This command counts the lines in a file, using the "wc
3627 * -l" external command.
3629 * @throws LibGuestFSException
3631 public int wc_l (String path)
3632 throws LibGuestFSException
3635 throw new LibGuestFSException ("wc_l: handle is closed");
3636 return _wc_l (g, path);
3638 private native int _wc_l (long g, String path)
3639 throws LibGuestFSException;
3642 * count words in a file
3644 * This command counts the words in a file, using the "wc
3645 * -w" external command.
3647 * @throws LibGuestFSException
3649 public int wc_w (String path)
3650 throws LibGuestFSException
3653 throw new LibGuestFSException ("wc_w: handle is closed");
3654 return _wc_w (g, path);
3656 private native int _wc_w (long g, String path)
3657 throws LibGuestFSException;
3660 * count characters in a file
3662 * This command counts the characters in a file, using the
3663 * "wc -c" external command.
3665 * @throws LibGuestFSException
3667 public int wc_c (String path)
3668 throws LibGuestFSException
3671 throw new LibGuestFSException ("wc_c: handle is closed");
3672 return _wc_c (g, path);
3674 private native int _wc_c (long g, String path)
3675 throws LibGuestFSException;
3678 * return first 10 lines of a file
3680 * This command returns up to the first 10 lines of a file
3681 * as a list of strings.
3683 * Because of the message protocol, there is a transfer
3684 * limit of somewhere between 2MB and 4MB. To transfer
3685 * large files you should use FTP.
3687 * @throws LibGuestFSException
3689 public String[] head (String path)
3690 throws LibGuestFSException
3693 throw new LibGuestFSException ("head: handle is closed");
3694 return _head (g, path);
3696 private native String[] _head (long g, String path)
3697 throws LibGuestFSException;
3700 * return first N lines of a file
3702 * If the parameter "nrlines" is a positive number, this
3703 * returns the first "nrlines" lines of the file "path".
3705 * If the parameter "nrlines" is a negative number, this
3706 * returns lines from the file "path", excluding the last
3709 * If the parameter "nrlines" is zero, this returns an
3712 * Because of the message protocol, there is a transfer
3713 * limit of somewhere between 2MB and 4MB. To transfer
3714 * large files you should use FTP.
3716 * @throws LibGuestFSException
3718 public String[] head_n (int nrlines, String path)
3719 throws LibGuestFSException
3722 throw new LibGuestFSException ("head_n: handle is closed");
3723 return _head_n (g, nrlines, path);
3725 private native String[] _head_n (long g, int nrlines, String path)
3726 throws LibGuestFSException;
3729 * return last 10 lines of a file
3731 * This command returns up to the last 10 lines of a file
3732 * as a list of strings.
3734 * Because of the message protocol, there is a transfer
3735 * limit of somewhere between 2MB and 4MB. To transfer
3736 * large files you should use FTP.
3738 * @throws LibGuestFSException
3740 public String[] tail (String path)
3741 throws LibGuestFSException
3744 throw new LibGuestFSException ("tail: handle is closed");
3745 return _tail (g, path);
3747 private native String[] _tail (long g, String path)
3748 throws LibGuestFSException;
3751 * return last N lines of a file
3753 * If the parameter "nrlines" is a positive number, this
3754 * returns the last "nrlines" lines of the file "path".
3756 * If the parameter "nrlines" is a negative number, this
3757 * returns lines from the file "path", starting with the
3758 * "-nrlines"th line.
3760 * If the parameter "nrlines" is zero, this returns an
3763 * Because of the message protocol, there is a transfer
3764 * limit of somewhere between 2MB and 4MB. To transfer
3765 * large files you should use FTP.
3767 * @throws LibGuestFSException
3769 public String[] tail_n (int nrlines, String path)
3770 throws LibGuestFSException
3773 throw new LibGuestFSException ("tail_n: handle is closed");
3774 return _tail_n (g, nrlines, path);
3776 private native String[] _tail_n (long g, int nrlines, String path)
3777 throws LibGuestFSException;
3780 * report file system disk space usage
3782 * This command runs the "df" command to report disk space
3785 * This command is mostly useful for interactive sessions.
3786 * It is *not* intended that you try to parse the output
3787 * string. Use "statvfs" from programs.
3789 * @throws LibGuestFSException
3792 throws LibGuestFSException
3795 throw new LibGuestFSException ("df: handle is closed");
3798 private native String _df (long g)
3799 throws LibGuestFSException;
3802 * report file system disk space usage (human readable)
3804 * This command runs the "df -h" command to report disk
3805 * space used in human-readable format.
3807 * This command is mostly useful for interactive sessions.
3808 * It is *not* intended that you try to parse the output
3809 * string. Use "statvfs" from programs.
3811 * @throws LibGuestFSException
3813 public String df_h ()
3814 throws LibGuestFSException
3817 throw new LibGuestFSException ("df_h: handle is closed");
3820 private native String _df_h (long g)
3821 throws LibGuestFSException;
3824 * estimate file space usage
3826 * This command runs the "du -s" command to estimate file
3827 * space usage for "path".
3829 * "path" can be a file or a directory. If "path" is a
3830 * directory then the estimate includes the contents of the
3831 * directory and all subdirectories (recursively).
3833 * The result is the estimated size in *kilobytes* (ie.
3834 * units of 1024 bytes).
3836 * @throws LibGuestFSException
3838 public long du (String path)
3839 throws LibGuestFSException
3842 throw new LibGuestFSException ("du: handle is closed");
3843 return _du (g, path);
3845 private native long _du (long g, String path)
3846 throws LibGuestFSException;
3849 * list files in an initrd
3851 * This command lists out files contained in an initrd.
3853 * The files are listed without any initial "/" character.
3854 * The files are listed in the order they appear (not
3855 * necessarily alphabetical). Directory names are listed as
3858 * Old Linux kernels (2.4 and earlier) used a compressed
3859 * ext2 filesystem as initrd. We *only* support the newer
3860 * initramfs format (compressed cpio files).
3862 * @throws LibGuestFSException
3864 public String[] initrd_list (String path)
3865 throws LibGuestFSException
3868 throw new LibGuestFSException ("initrd_list: handle is closed");
3869 return _initrd_list (g, path);
3871 private native String[] _initrd_list (long g, String path)
3872 throws LibGuestFSException;
3875 * mount a file using the loop device
3877 * This command lets you mount "file" (a filesystem image
3878 * in a file) on a mount point. It is entirely equivalent
3879 * to the command "mount -o loop file mountpoint".
3881 * @throws LibGuestFSException
3883 public void mount_loop (String file, String mountpoint)
3884 throws LibGuestFSException
3887 throw new LibGuestFSException ("mount_loop: handle is closed");
3888 _mount_loop (g, file, mountpoint);
3890 private native void _mount_loop (long g, String file, String mountpoint)
3891 throws LibGuestFSException;
3894 * create a swap partition
3896 * Create a swap partition on "device".
3898 * @throws LibGuestFSException
3900 public void mkswap (String device)
3901 throws LibGuestFSException
3904 throw new LibGuestFSException ("mkswap: handle is closed");
3905 _mkswap (g, device);
3907 private native void _mkswap (long g, String device)
3908 throws LibGuestFSException;
3911 * create a swap partition with a label
3913 * Create a swap partition on "device" with label "label".
3915 * @throws LibGuestFSException
3917 public void mkswap_L (String label, String device)
3918 throws LibGuestFSException
3921 throw new LibGuestFSException ("mkswap_L: handle is closed");
3922 _mkswap_L (g, label, device);
3924 private native void _mkswap_L (long g, String label, String device)
3925 throws LibGuestFSException;
3928 * create a swap partition with an explicit UUID
3930 * Create a swap partition on "device" with UUID "uuid".
3932 * @throws LibGuestFSException
3934 public void mkswap_U (String uuid, String device)
3935 throws LibGuestFSException
3938 throw new LibGuestFSException ("mkswap_U: handle is closed");
3939 _mkswap_U (g, uuid, device);
3941 private native void _mkswap_U (long g, String uuid, String device)
3942 throws LibGuestFSException;