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
85 * launch the qemu subprocess
87 * Internally libguestfs is implemented by running a
88 * virtual machine using qemu(1).
90 * You should call this after configuring the handle (eg.
91 * adding drives) but before performing any actions.
93 * @throws LibGuestFSException
96 throws LibGuestFSException
99 throw new LibGuestFSException ("launch: handle is closed");
102 private native void _launch (long g)
103 throws LibGuestFSException;
106 * wait until the qemu subprocess launches
108 * Internally libguestfs is implemented by running a
109 * virtual machine using qemu(1).
111 * You should call this after "g.launch" to wait for the
112 * launch to complete.
114 * @throws LibGuestFSException
116 public void wait_ready ()
117 throws LibGuestFSException
120 throw new LibGuestFSException ("wait_ready: handle is closed");
123 private native void _wait_ready (long g)
124 throws LibGuestFSException;
127 * kill the qemu subprocess
129 * This kills the qemu subprocess. You should never need to
132 * @throws LibGuestFSException
134 public void kill_subprocess ()
135 throws LibGuestFSException
138 throw new LibGuestFSException ("kill_subprocess: handle is closed");
139 _kill_subprocess (g);
141 private native void _kill_subprocess (long g)
142 throws LibGuestFSException;
145 * add an image to examine or modify
147 * This function adds a virtual machine disk image
148 * "filename" to the guest. The first time you call this
149 * function, the disk appears as IDE disk 0 ("/dev/sda") in
150 * the guest, the second time as "/dev/sdb", and so on.
152 * You don't necessarily need to be root when using
153 * libguestfs. However you obviously do need sufficient
154 * permissions to access the filename for whatever
155 * operations you want to perform (ie. read access if you
156 * just want to read the image or write access if you want
157 * to modify the image).
159 * This is equivalent to the qemu parameter "-drive
162 * @throws LibGuestFSException
164 public void add_drive (String filename)
165 throws LibGuestFSException
168 throw new LibGuestFSException ("add_drive: handle is closed");
169 _add_drive (g, filename);
171 private native void _add_drive (long g, String filename)
172 throws LibGuestFSException;
175 * add a CD-ROM disk image to examine
177 * This function adds a virtual CD-ROM disk image to the
180 * This is equivalent to the qemu parameter "-cdrom
183 * @throws LibGuestFSException
185 public void add_cdrom (String filename)
186 throws LibGuestFSException
189 throw new LibGuestFSException ("add_cdrom: handle is closed");
190 _add_cdrom (g, filename);
192 private native void _add_cdrom (long g, String filename)
193 throws LibGuestFSException;
196 * add qemu parameters
198 * This can be used to add arbitrary qemu command line
199 * parameters of the form "-param value". Actually it's not
200 * quite arbitrary - we prevent you from setting some
201 * parameters which would interfere with parameters that we
204 * The first character of "param" string must be a "-"
207 * "value" can be NULL.
209 * @throws LibGuestFSException
211 public void config (String qemuparam, String qemuvalue)
212 throws LibGuestFSException
215 throw new LibGuestFSException ("config: handle is closed");
216 _config (g, qemuparam, qemuvalue);
218 private native void _config (long g, String qemuparam, String qemuvalue)
219 throws LibGuestFSException;
222 * set the qemu binary
224 * Set the qemu binary that we will use.
226 * The default is chosen when the library was compiled by
227 * the configure script.
229 * You can also override this by setting the
230 * "LIBGUESTFS_QEMU" environment variable.
232 * The string "qemu" is stashed in the libguestfs handle,
233 * so the caller must make sure it remains valid for the
234 * lifetime of the handle.
236 * Setting "qemu" to "NULL" restores the default qemu
239 * @throws LibGuestFSException
241 public void set_qemu (String qemu)
242 throws LibGuestFSException
245 throw new LibGuestFSException ("set_qemu: handle is closed");
248 private native void _set_qemu (long g, String qemu)
249 throws LibGuestFSException;
252 * get the qemu binary
254 * Return the current qemu binary.
256 * This is always non-NULL. If it wasn't set already, then
257 * this will return the default qemu binary name.
259 * @throws LibGuestFSException
261 public String get_qemu ()
262 throws LibGuestFSException
265 throw new LibGuestFSException ("get_qemu: handle is closed");
266 return _get_qemu (g);
268 private native String _get_qemu (long g)
269 throws LibGuestFSException;
272 * set the search path
274 * Set the path that libguestfs searches for kernel and
277 * The default is "$libdir/guestfs" unless overridden by
278 * setting "LIBGUESTFS_PATH" environment variable.
280 * The string "path" is stashed in the libguestfs handle,
281 * so the caller must make sure it remains valid for the
282 * lifetime of the handle.
284 * Setting "path" to "NULL" restores the default path.
286 * @throws LibGuestFSException
288 public void set_path (String path)
289 throws LibGuestFSException
292 throw new LibGuestFSException ("set_path: handle is closed");
295 private native void _set_path (long g, String path)
296 throws LibGuestFSException;
299 * get the search path
301 * Return the current search path.
303 * This is always non-NULL. If it wasn't set already, then
304 * this will return the default path.
306 * @throws LibGuestFSException
308 public String get_path ()
309 throws LibGuestFSException
312 throw new LibGuestFSException ("get_path: handle is closed");
313 return _get_path (g);
315 private native String _get_path (long g)
316 throws LibGuestFSException;
321 * If "autosync" is true, this enables autosync. Libguestfs
322 * will make a best effort attempt to run "g.umount_all"
323 * followed by "g.sync" when the handle is closed (also if
324 * the program exits without closing handles).
326 * This is disabled by default (except in guestfish where
327 * it is enabled by default).
329 * @throws LibGuestFSException
331 public void set_autosync (boolean autosync)
332 throws LibGuestFSException
335 throw new LibGuestFSException ("set_autosync: handle is closed");
336 _set_autosync (g, autosync);
338 private native void _set_autosync (long g, boolean autosync)
339 throws LibGuestFSException;
344 * Get the autosync flag.
346 * @throws LibGuestFSException
348 public boolean get_autosync ()
349 throws LibGuestFSException
352 throw new LibGuestFSException ("get_autosync: handle is closed");
353 return _get_autosync (g);
355 private native boolean _get_autosync (long g)
356 throws LibGuestFSException;
361 * If "verbose" is true, this turns on verbose messages (to
364 * Verbose messages are disabled unless the environment
365 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
367 * @throws LibGuestFSException
369 public void set_verbose (boolean verbose)
370 throws LibGuestFSException
373 throw new LibGuestFSException ("set_verbose: handle is closed");
374 _set_verbose (g, verbose);
376 private native void _set_verbose (long g, boolean verbose)
377 throws LibGuestFSException;
382 * This returns the verbose messages flag.
384 * @throws LibGuestFSException
386 public boolean get_verbose ()
387 throws LibGuestFSException
390 throw new LibGuestFSException ("get_verbose: handle is closed");
391 return _get_verbose (g);
393 private native boolean _get_verbose (long g)
394 throws LibGuestFSException;
397 * is ready to accept commands
399 * This returns true iff this handle is ready to accept
400 * commands (in the "READY" state).
402 * For more information on states, see guestfs(3).
404 * @throws LibGuestFSException
406 public boolean is_ready ()
407 throws LibGuestFSException
410 throw new LibGuestFSException ("is_ready: handle is closed");
411 return _is_ready (g);
413 private native boolean _is_ready (long g)
414 throws LibGuestFSException;
417 * is in configuration state
419 * This returns true iff this handle is being configured
420 * (in the "CONFIG" state).
422 * For more information on states, see guestfs(3).
424 * @throws LibGuestFSException
426 public boolean is_config ()
427 throws LibGuestFSException
430 throw new LibGuestFSException ("is_config: handle is closed");
431 return _is_config (g);
433 private native boolean _is_config (long g)
434 throws LibGuestFSException;
437 * is launching subprocess
439 * This returns true iff this handle is launching the
440 * subprocess (in the "LAUNCHING" state).
442 * For more information on states, see guestfs(3).
444 * @throws LibGuestFSException
446 public boolean is_launching ()
447 throws LibGuestFSException
450 throw new LibGuestFSException ("is_launching: handle is closed");
451 return _is_launching (g);
453 private native boolean _is_launching (long g)
454 throws LibGuestFSException;
457 * is busy processing a command
459 * This returns true iff this handle is busy processing a
460 * command (in the "BUSY" state).
462 * For more information on states, see guestfs(3).
464 * @throws LibGuestFSException
466 public boolean is_busy ()
467 throws LibGuestFSException
470 throw new LibGuestFSException ("is_busy: handle is closed");
473 private native boolean _is_busy (long g)
474 throws LibGuestFSException;
477 * get the current state
479 * This returns the current state as an opaque integer.
480 * This is only useful for printing debug and internal
483 * For more information on states, see guestfs(3).
485 * @throws LibGuestFSException
487 public int get_state ()
488 throws LibGuestFSException
491 throw new LibGuestFSException ("get_state: handle is closed");
492 return _get_state (g);
494 private native int _get_state (long g)
495 throws LibGuestFSException;
500 * This sets the state to "BUSY". This is only used when
501 * implementing actions using the low-level API.
503 * For more information on states, see guestfs(3).
505 * @throws LibGuestFSException
507 public void set_busy ()
508 throws LibGuestFSException
511 throw new LibGuestFSException ("set_busy: handle is closed");
514 private native void _set_busy (long g)
515 throws LibGuestFSException;
520 * This sets the state to "READY". This is only used when
521 * implementing actions using the low-level API.
523 * For more information on states, see guestfs(3).
525 * @throws LibGuestFSException
527 public void set_ready ()
528 throws LibGuestFSException
531 throw new LibGuestFSException ("set_ready: handle is closed");
534 private native void _set_ready (long g)
535 throws LibGuestFSException;
538 * leave the busy state
540 * This sets the state to "READY", or if in "CONFIG" then
541 * it leaves the state as is. This is only used when
542 * implementing actions using the low-level API.
544 * For more information on states, see guestfs(3).
546 * @throws LibGuestFSException
548 public void end_busy ()
549 throws LibGuestFSException
552 throw new LibGuestFSException ("end_busy: handle is closed");
555 private native void _end_busy (long g)
556 throws LibGuestFSException;
559 * mount a guest disk at a position in the filesystem
561 * Mount a guest disk at a position in the filesystem.
562 * Block devices are named "/dev/sda", "/dev/sdb" and so
563 * on, as they were added to the guest. If those block
564 * devices contain partitions, they will have the usual
565 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
568 * The rules are the same as for mount(2): A filesystem
569 * must first be mounted on "/" before others can be
570 * mounted. Other filesystems can only be mounted on
571 * directories which already exist.
573 * The mounted filesystem is writable, if we have
574 * sufficient permissions on the underlying device.
576 * The filesystem options "sync" and "noatime" are set with
577 * this call, in order to improve reliability.
579 * @throws LibGuestFSException
581 public void mount (String device, String mountpoint)
582 throws LibGuestFSException
585 throw new LibGuestFSException ("mount: handle is closed");
586 _mount (g, device, mountpoint);
588 private native void _mount (long g, String device, String mountpoint)
589 throws LibGuestFSException;
592 * sync disks, writes are flushed through to the disk image
594 * This syncs the disk, so that any writes are flushed
595 * through to the underlying disk image.
597 * You should always call this if you have modified a disk
598 * image, before closing the handle.
600 * @throws LibGuestFSException
603 throws LibGuestFSException
606 throw new LibGuestFSException ("sync: handle is closed");
609 private native void _sync (long g)
610 throws LibGuestFSException;
613 * update file timestamps or create a new file
615 * Touch acts like the touch(1) command. It can be used to
616 * update the timestamps on a file, or, if the file does
617 * not exist, to create a new zero-length file.
619 * @throws LibGuestFSException
621 public void touch (String path)
622 throws LibGuestFSException
625 throw new LibGuestFSException ("touch: handle is closed");
628 private native void _touch (long g, String path)
629 throws LibGuestFSException;
632 * list the contents of a file
634 * Return the contents of the file named "path".
636 * Note that this function cannot correctly handle binary
637 * files (specifically, files containing "\0" character
638 * which is treated as end of string). For those you need
639 * to use the "g.download" function which has a more
642 * Because of the message protocol, there is a transfer
643 * limit of somewhere between 2MB and 4MB. To transfer
644 * large files you should use FTP.
646 * @throws LibGuestFSException
648 public String cat (String path)
649 throws LibGuestFSException
652 throw new LibGuestFSException ("cat: handle is closed");
653 return _cat (g, path);
655 private native String _cat (long g, String path)
656 throws LibGuestFSException;
659 * list the files in a directory (long format)
661 * List the files in "directory" (relative to the root
662 * directory, there is no cwd) in the format of 'ls -la'.
664 * This command is mostly useful for interactive sessions.
665 * It is *not* intended that you try to parse the output
668 * @throws LibGuestFSException
670 public String ll (String directory)
671 throws LibGuestFSException
674 throw new LibGuestFSException ("ll: handle is closed");
675 return _ll (g, directory);
677 private native String _ll (long g, String directory)
678 throws LibGuestFSException;
681 * list the files in a directory
683 * List the files in "directory" (relative to the root
684 * directory, there is no cwd). The '.' and '..' entries
685 * are not returned, but hidden files are shown.
687 * This command is mostly useful for interactive sessions.
688 * Programs should probably use "g.readdir" instead.
690 * @throws LibGuestFSException
692 public String[] ls (String directory)
693 throws LibGuestFSException
696 throw new LibGuestFSException ("ls: handle is closed");
697 return _ls (g, directory);
699 private native String[] _ls (long g, String directory)
700 throws LibGuestFSException;
703 * list the block devices
705 * List all the block devices.
707 * The full block device names are returned, eg. "/dev/sda"
709 * @throws LibGuestFSException
711 public String[] list_devices ()
712 throws LibGuestFSException
715 throw new LibGuestFSException ("list_devices: handle is closed");
716 return _list_devices (g);
718 private native String[] _list_devices (long g)
719 throws LibGuestFSException;
722 * list the partitions
724 * List all the partitions detected on all block devices.
726 * The full partition device names are returned, eg.
729 * This does not return logical volumes. For that you will
730 * need to call "g.lvs".
732 * @throws LibGuestFSException
734 public String[] list_partitions ()
735 throws LibGuestFSException
738 throw new LibGuestFSException ("list_partitions: handle is closed");
739 return _list_partitions (g);
741 private native String[] _list_partitions (long g)
742 throws LibGuestFSException;
745 * list the LVM physical volumes (PVs)
747 * List all the physical volumes detected. This is the
748 * equivalent of the pvs(8) command.
750 * This returns a list of just the device names that
751 * contain PVs (eg. "/dev/sda2").
753 * See also "g.pvs_full".
755 * @throws LibGuestFSException
757 public String[] pvs ()
758 throws LibGuestFSException
761 throw new LibGuestFSException ("pvs: handle is closed");
764 private native String[] _pvs (long g)
765 throws LibGuestFSException;
768 * list the LVM volume groups (VGs)
770 * List all the volumes groups detected. This is the
771 * equivalent of the vgs(8) command.
773 * This returns a list of just the volume group names that
774 * were detected (eg. "VolGroup00").
776 * See also "g.vgs_full".
778 * @throws LibGuestFSException
780 public String[] vgs ()
781 throws LibGuestFSException
784 throw new LibGuestFSException ("vgs: handle is closed");
787 private native String[] _vgs (long g)
788 throws LibGuestFSException;
791 * list the LVM logical volumes (LVs)
793 * List all the logical volumes detected. This is the
794 * equivalent of the lvs(8) command.
796 * This returns a list of the logical volume device names
797 * (eg. "/dev/VolGroup00/LogVol00").
799 * See also "g.lvs_full".
801 * @throws LibGuestFSException
803 public String[] lvs ()
804 throws LibGuestFSException
807 throw new LibGuestFSException ("lvs: handle is closed");
810 private native String[] _lvs (long g)
811 throws LibGuestFSException;
814 * list the LVM physical volumes (PVs)
816 * List all the physical volumes detected. This is the
817 * equivalent of the pvs(8) command. The "full" version
818 * includes all fields.
820 * @throws LibGuestFSException
822 public PV[] pvs_full ()
823 throws LibGuestFSException
826 throw new LibGuestFSException ("pvs_full: handle is closed");
827 return _pvs_full (g);
829 private native PV[] _pvs_full (long g)
830 throws LibGuestFSException;
833 * list the LVM volume groups (VGs)
835 * List all the volumes groups detected. This is the
836 * equivalent of the vgs(8) command. The "full" version
837 * includes all fields.
839 * @throws LibGuestFSException
841 public VG[] vgs_full ()
842 throws LibGuestFSException
845 throw new LibGuestFSException ("vgs_full: handle is closed");
846 return _vgs_full (g);
848 private native VG[] _vgs_full (long g)
849 throws LibGuestFSException;
852 * list the LVM logical volumes (LVs)
854 * List all the logical volumes detected. This is the
855 * equivalent of the lvs(8) command. The "full" version
856 * includes all fields.
858 * @throws LibGuestFSException
860 public LV[] lvs_full ()
861 throws LibGuestFSException
864 throw new LibGuestFSException ("lvs_full: handle is closed");
865 return _lvs_full (g);
867 private native LV[] _lvs_full (long g)
868 throws LibGuestFSException;
873 * Return the contents of the file named "path".
875 * The file contents are returned as a list of lines.
876 * Trailing "LF" and "CRLF" character sequences are *not*
879 * Note that this function cannot correctly handle binary
880 * files (specifically, files containing "\0" character
881 * which is treated as end of line). For those you need to
882 * use the "g.read_file" function which has a more complex
885 * @throws LibGuestFSException
887 public String[] read_lines (String path)
888 throws LibGuestFSException
891 throw new LibGuestFSException ("read_lines: handle is closed");
892 return _read_lines (g, path);
894 private native String[] _read_lines (long g, String path)
895 throws LibGuestFSException;
898 * create a new Augeas handle
900 * Create a new Augeas handle for editing configuration
901 * files. If there was any previous Augeas handle
902 * associated with this guestfs session, then it is closed.
904 * You must call this before using any other "g.aug_*"
907 * "root" is the filesystem root. "root" must not be NULL,
910 * The flags are the same as the flags defined in
911 * <augeas.h>, the logical *or* of the following integers:
913 * "AUG_SAVE_BACKUP" = 1
914 * Keep the original file with a ".augsave" extension.
916 * "AUG_SAVE_NEWFILE" = 2
917 * Save changes into a file with extension ".augnew",
918 * and do not overwrite original. Overrides
921 * "AUG_TYPE_CHECK" = 4
922 * Typecheck lenses (can be expensive).
924 * "AUG_NO_STDINC" = 8
925 * Do not use standard load path for modules.
927 * "AUG_SAVE_NOOP" = 16
928 * Make save a no-op, just record what would have been
932 * Do not load the tree in "g.aug_init".
934 * To close the handle, you can call "g.aug_close".
936 * To find out more about Augeas, see <http://augeas.net/>.
938 * @throws LibGuestFSException
940 public void aug_init (String root, int flags)
941 throws LibGuestFSException
944 throw new LibGuestFSException ("aug_init: handle is closed");
945 _aug_init (g, root, flags);
947 private native void _aug_init (long g, String root, int flags)
948 throws LibGuestFSException;
951 * close the current Augeas handle
953 * Close the current Augeas handle and free up any
954 * resources used by it. After calling this, you have to
955 * call "g.aug_init" again before you can use any other
958 * @throws LibGuestFSException
960 public void aug_close ()
961 throws LibGuestFSException
964 throw new LibGuestFSException ("aug_close: handle is closed");
967 private native void _aug_close (long g)
968 throws LibGuestFSException;
971 * define an Augeas variable
973 * Defines an Augeas variable "name" whose value is the
974 * result of evaluating "expr". If "expr" is NULL, then
975 * "name" is undefined.
977 * On success this returns the number of nodes in "expr",
978 * or 0 if "expr" evaluates to something which is not a
981 * @throws LibGuestFSException
983 public int aug_defvar (String name, String expr)
984 throws LibGuestFSException
987 throw new LibGuestFSException ("aug_defvar: handle is closed");
988 return _aug_defvar (g, name, expr);
990 private native int _aug_defvar (long g, String name, String expr)
991 throws LibGuestFSException;
994 * define an Augeas node
996 * Defines a variable "name" whose value is the result of
999 * If "expr" evaluates to an empty nodeset, a node is
1000 * created, equivalent to calling "g.aug_set" "expr",
1001 * "value". "name" will be the nodeset containing that
1004 * On success this returns a pair containing the number of
1005 * nodes in the nodeset, and a boolean flag if a node was
1008 * @throws LibGuestFSException
1010 public IntBool aug_defnode (String name, String expr, String val)
1011 throws LibGuestFSException
1014 throw new LibGuestFSException ("aug_defnode: handle is closed");
1015 return _aug_defnode (g, name, expr, val);
1017 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1018 throws LibGuestFSException;
1021 * look up the value of an Augeas path
1023 * Look up the value associated with "path". If "path"
1024 * matches exactly one node, the "value" is returned.
1026 * @throws LibGuestFSException
1028 public String aug_get (String path)
1029 throws LibGuestFSException
1032 throw new LibGuestFSException ("aug_get: handle is closed");
1033 return _aug_get (g, path);
1035 private native String _aug_get (long g, String path)
1036 throws LibGuestFSException;
1039 * set Augeas path to value
1041 * Set the value associated with "path" to "value".
1043 * @throws LibGuestFSException
1045 public void aug_set (String path, String val)
1046 throws LibGuestFSException
1049 throw new LibGuestFSException ("aug_set: handle is closed");
1050 _aug_set (g, path, val);
1052 private native void _aug_set (long g, String path, String val)
1053 throws LibGuestFSException;
1056 * insert a sibling Augeas node
1058 * Create a new sibling "label" for "path", inserting it
1059 * into the tree before or after "path" (depending on the
1060 * boolean flag "before").
1062 * "path" must match exactly one existing node in the tree,
1063 * and "label" must be a label, ie. not contain "/", "*" or
1064 * end with a bracketed index "[N]".
1066 * @throws LibGuestFSException
1068 public void aug_insert (String path, String label, boolean before)
1069 throws LibGuestFSException
1072 throw new LibGuestFSException ("aug_insert: handle is closed");
1073 _aug_insert (g, path, label, before);
1075 private native void _aug_insert (long g, String path, String label, boolean before)
1076 throws LibGuestFSException;
1079 * remove an Augeas path
1081 * Remove "path" and all of its children.
1083 * On success this returns the number of entries which were
1086 * @throws LibGuestFSException
1088 public int aug_rm (String path)
1089 throws LibGuestFSException
1092 throw new LibGuestFSException ("aug_rm: handle is closed");
1093 return _aug_rm (g, path);
1095 private native int _aug_rm (long g, String path)
1096 throws LibGuestFSException;
1101 * Move the node "src" to "dest". "src" must match exactly
1102 * one node. "dest" is overwritten if it exists.
1104 * @throws LibGuestFSException
1106 public void aug_mv (String src, String dest)
1107 throws LibGuestFSException
1110 throw new LibGuestFSException ("aug_mv: handle is closed");
1111 _aug_mv (g, src, dest);
1113 private native void _aug_mv (long g, String src, String dest)
1114 throws LibGuestFSException;
1117 * return Augeas nodes which match path
1119 * Returns a list of paths which match the path expression
1120 * "path". The returned paths are sufficiently qualified so
1121 * that they match exactly one node in the current tree.
1123 * @throws LibGuestFSException
1125 public String[] aug_match (String path)
1126 throws LibGuestFSException
1129 throw new LibGuestFSException ("aug_match: handle is closed");
1130 return _aug_match (g, path);
1132 private native String[] _aug_match (long g, String path)
1133 throws LibGuestFSException;
1136 * write all pending Augeas changes to disk
1138 * This writes all pending changes to disk.
1140 * The flags which were passed to "g.aug_init" affect
1141 * exactly how files are saved.
1143 * @throws LibGuestFSException
1145 public void aug_save ()
1146 throws LibGuestFSException
1149 throw new LibGuestFSException ("aug_save: handle is closed");
1152 private native void _aug_save (long g)
1153 throws LibGuestFSException;
1156 * load files into the tree
1158 * Load files into the tree.
1160 * See "aug_load" in the Augeas documentation for the full
1163 * @throws LibGuestFSException
1165 public void aug_load ()
1166 throws LibGuestFSException
1169 throw new LibGuestFSException ("aug_load: handle is closed");
1172 private native void _aug_load (long g)
1173 throws LibGuestFSException;
1176 * list Augeas nodes under a path
1178 * This is just a shortcut for listing "g.aug_match"
1179 * "path/*" and sorting the resulting nodes into
1180 * alphabetical order.
1182 * @throws LibGuestFSException
1184 public String[] aug_ls (String path)
1185 throws LibGuestFSException
1188 throw new LibGuestFSException ("aug_ls: handle is closed");
1189 return _aug_ls (g, path);
1191 private native String[] _aug_ls (long g, String path)
1192 throws LibGuestFSException;
1197 * Remove the single file "path".
1199 * @throws LibGuestFSException
1201 public void rm (String path)
1202 throws LibGuestFSException
1205 throw new LibGuestFSException ("rm: handle is closed");
1208 private native void _rm (long g, String path)
1209 throws LibGuestFSException;
1212 * remove a directory
1214 * Remove the single directory "path".
1216 * @throws LibGuestFSException
1218 public void rmdir (String path)
1219 throws LibGuestFSException
1222 throw new LibGuestFSException ("rmdir: handle is closed");
1225 private native void _rmdir (long g, String path)
1226 throws LibGuestFSException;
1229 * remove a file or directory recursively
1231 * Remove the file or directory "path", recursively
1232 * removing the contents if its a directory. This is like
1233 * the "rm -rf" shell command.
1235 * @throws LibGuestFSException
1237 public void rm_rf (String path)
1238 throws LibGuestFSException
1241 throw new LibGuestFSException ("rm_rf: handle is closed");
1244 private native void _rm_rf (long g, String path)
1245 throws LibGuestFSException;
1248 * create a directory
1250 * Create a directory named "path".
1252 * @throws LibGuestFSException
1254 public void mkdir (String path)
1255 throws LibGuestFSException
1258 throw new LibGuestFSException ("mkdir: handle is closed");
1261 private native void _mkdir (long g, String path)
1262 throws LibGuestFSException;
1265 * create a directory and parents
1267 * Create a directory named "path", creating any parent
1268 * directories as necessary. This is like the "mkdir -p"
1271 * @throws LibGuestFSException
1273 public void mkdir_p (String path)
1274 throws LibGuestFSException
1277 throw new LibGuestFSException ("mkdir_p: handle is closed");
1280 private native void _mkdir_p (long g, String path)
1281 throws LibGuestFSException;
1286 * Change the mode (permissions) of "path" to "mode". Only
1287 * numeric modes are supported.
1289 * @throws LibGuestFSException
1291 public void chmod (int mode, String path)
1292 throws LibGuestFSException
1295 throw new LibGuestFSException ("chmod: handle is closed");
1296 _chmod (g, mode, path);
1298 private native void _chmod (long g, int mode, String path)
1299 throws LibGuestFSException;
1302 * change file owner and group
1304 * Change the file owner to "owner" and group to "group".
1306 * Only numeric uid and gid are supported. If you want to
1307 * use names, you will need to locate and parse the
1308 * password file yourself (Augeas support makes this
1311 * @throws LibGuestFSException
1313 public void chown (int owner, int group, String path)
1314 throws LibGuestFSException
1317 throw new LibGuestFSException ("chown: handle is closed");
1318 _chown (g, owner, group, path);
1320 private native void _chown (long g, int owner, int group, String path)
1321 throws LibGuestFSException;
1324 * test if file or directory exists
1326 * This returns "true" if and only if there is a file,
1327 * directory (or anything) with the given "path" name.
1329 * See also "g.is_file", "g.is_dir", "g.stat".
1331 * @throws LibGuestFSException
1333 public boolean exists (String path)
1334 throws LibGuestFSException
1337 throw new LibGuestFSException ("exists: handle is closed");
1338 return _exists (g, path);
1340 private native boolean _exists (long g, String path)
1341 throws LibGuestFSException;
1344 * test if file exists
1346 * This returns "true" if and only if there is a file with
1347 * the given "path" name. Note that it returns false for
1348 * other objects like directories.
1350 * See also "g.stat".
1352 * @throws LibGuestFSException
1354 public boolean is_file (String path)
1355 throws LibGuestFSException
1358 throw new LibGuestFSException ("is_file: handle is closed");
1359 return _is_file (g, path);
1361 private native boolean _is_file (long g, String path)
1362 throws LibGuestFSException;
1365 * test if file exists
1367 * This returns "true" if and only if there is a directory
1368 * with the given "path" name. Note that it returns false
1369 * for other objects like files.
1371 * See also "g.stat".
1373 * @throws LibGuestFSException
1375 public boolean is_dir (String path)
1376 throws LibGuestFSException
1379 throw new LibGuestFSException ("is_dir: handle is closed");
1380 return _is_dir (g, path);
1382 private native boolean _is_dir (long g, String path)
1383 throws LibGuestFSException;
1386 * create an LVM physical volume
1388 * This creates an LVM physical volume on the named
1389 * "device", where "device" should usually be a partition
1390 * name such as "/dev/sda1".
1392 * @throws LibGuestFSException
1394 public void pvcreate (String device)
1395 throws LibGuestFSException
1398 throw new LibGuestFSException ("pvcreate: handle is closed");
1399 _pvcreate (g, device);
1401 private native void _pvcreate (long g, String device)
1402 throws LibGuestFSException;
1405 * create an LVM volume group
1407 * This creates an LVM volume group called "volgroup" from
1408 * the non-empty list of physical volumes "physvols".
1410 * @throws LibGuestFSException
1412 public void vgcreate (String volgroup, String[] physvols)
1413 throws LibGuestFSException
1416 throw new LibGuestFSException ("vgcreate: handle is closed");
1417 _vgcreate (g, volgroup, physvols);
1419 private native void _vgcreate (long g, String volgroup, String[] physvols)
1420 throws LibGuestFSException;
1423 * create an LVM volume group
1425 * This creates an LVM volume group called "logvol" on the
1426 * volume group "volgroup", with "size" megabytes.
1428 * @throws LibGuestFSException
1430 public void lvcreate (String logvol, String volgroup, int mbytes)
1431 throws LibGuestFSException
1434 throw new LibGuestFSException ("lvcreate: handle is closed");
1435 _lvcreate (g, logvol, volgroup, mbytes);
1437 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1438 throws LibGuestFSException;
1443 * This creates a filesystem on "device" (usually a
1444 * partition or LVM logical volume). The filesystem type is
1445 * "fstype", for example "ext3".
1447 * @throws LibGuestFSException
1449 public void mkfs (String fstype, String device)
1450 throws LibGuestFSException
1453 throw new LibGuestFSException ("mkfs: handle is closed");
1454 _mkfs (g, fstype, device);
1456 private native void _mkfs (long g, String fstype, String device)
1457 throws LibGuestFSException;
1460 * create partitions on a block device
1462 * This is a direct interface to the sfdisk(8) program for
1463 * creating partitions on block devices.
1465 * "device" should be a block device, for example
1468 * "cyls", "heads" and "sectors" are the number of
1469 * cylinders, heads and sectors on the device, which are
1470 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1471 * parameters. If you pass 0 for any of these, then the
1472 * corresponding parameter is omitted. Usually for 'large'
1473 * disks, you can just pass 0 for these, but for small
1474 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1475 * cannot work out the right geometry and you will need to
1478 * "lines" is a list of lines that we feed to "sfdisk". For
1479 * more information refer to the sfdisk(8) manpage.
1481 * To create a single partition occupying the whole disk,
1482 * you would pass "lines" as a single element list, when
1483 * the single element being the string "," (comma).
1485 * This command is dangerous. Without careful use you can
1486 * easily destroy all your data.
1488 * @throws LibGuestFSException
1490 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1491 throws LibGuestFSException
1494 throw new LibGuestFSException ("sfdisk: handle is closed");
1495 _sfdisk (g, device, cyls, heads, sectors, lines);
1497 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1498 throws LibGuestFSException;
1503 * This call creates a file called "path". The contents of
1504 * the file is the string "content" (which can contain any
1505 * 8 bit data), with length "size".
1507 * As a special case, if "size" is 0 then the length is
1508 * calculated using "strlen" (so in this case the content
1509 * cannot contain embedded ASCII NULs).
1511 * *NB.* Owing to a bug, writing content containing ASCII
1512 * NUL characters does *not* work, even if the length is
1513 * specified. We hope to resolve this bug in a future
1514 * version. In the meantime use "g.upload".
1516 * Because of the message protocol, there is a transfer
1517 * limit of somewhere between 2MB and 4MB. To transfer
1518 * large files you should use FTP.
1520 * @throws LibGuestFSException
1522 public void write_file (String path, String content, int size)
1523 throws LibGuestFSException
1526 throw new LibGuestFSException ("write_file: handle is closed");
1527 _write_file (g, path, content, size);
1529 private native void _write_file (long g, String path, String content, int size)
1530 throws LibGuestFSException;
1533 * unmount a filesystem
1535 * This unmounts the given filesystem. The filesystem may
1536 * be specified either by its mountpoint (path) or the
1537 * device which contains the filesystem.
1539 * @throws LibGuestFSException
1541 public void umount (String pathordevice)
1542 throws LibGuestFSException
1545 throw new LibGuestFSException ("umount: handle is closed");
1546 _umount (g, pathordevice);
1548 private native void _umount (long g, String pathordevice)
1549 throws LibGuestFSException;
1552 * show mounted filesystems
1554 * This returns the list of currently mounted filesystems.
1555 * It returns the list of devices (eg. "/dev/sda1",
1558 * Some internal mounts are not shown.
1560 * @throws LibGuestFSException
1562 public String[] mounts ()
1563 throws LibGuestFSException
1566 throw new LibGuestFSException ("mounts: handle is closed");
1569 private native String[] _mounts (long g)
1570 throws LibGuestFSException;
1573 * unmount all filesystems
1575 * This unmounts all mounted filesystems.
1577 * Some internal mounts are not unmounted by this call.
1579 * @throws LibGuestFSException
1581 public void umount_all ()
1582 throws LibGuestFSException
1585 throw new LibGuestFSException ("umount_all: handle is closed");
1588 private native void _umount_all (long g)
1589 throws LibGuestFSException;
1592 * remove all LVM LVs, VGs and PVs
1594 * This command removes all LVM logical volumes, volume
1595 * groups and physical volumes.
1597 * This command is dangerous. Without careful use you can
1598 * easily destroy all your data.
1600 * @throws LibGuestFSException
1602 public void lvm_remove_all ()
1603 throws LibGuestFSException
1606 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1607 _lvm_remove_all (g);
1609 private native void _lvm_remove_all (long g)
1610 throws LibGuestFSException;
1613 * determine file type
1615 * This call uses the standard file(1) command to determine
1616 * the type or contents of the file. This also works on
1617 * devices, for example to find out whether a partition
1618 * contains a filesystem.
1620 * The exact command which runs is "file -bsL path". Note
1621 * in particular that the filename is not prepended to the
1622 * output (the "-b" option).
1624 * @throws LibGuestFSException
1626 public String file (String path)
1627 throws LibGuestFSException
1630 throw new LibGuestFSException ("file: handle is closed");
1631 return _file (g, path);
1633 private native String _file (long g, String path)
1634 throws LibGuestFSException;
1637 * run a command from the guest filesystem
1639 * This call runs a command from the guest filesystem. The
1640 * filesystem must be mounted, and must contain a
1641 * compatible operating system (ie. something Linux, with
1642 * the same or compatible processor architecture).
1644 * The single parameter is an argv-style list of arguments.
1645 * The first element is the name of the program to run.
1646 * Subsequent elements are parameters. The list must be
1647 * non-empty (ie. must contain a program name).
1649 * The $PATH environment variable will contain at least
1650 * "/usr/bin" and "/bin". If you require a program from
1651 * another location, you should provide the full path in
1652 * the first parameter.
1654 * Shared libraries and data files required by the program
1655 * must be available on filesystems which are mounted in
1656 * the correct places. It is the caller's responsibility to
1657 * ensure all filesystems that are needed are mounted at
1658 * the right locations.
1660 * @throws LibGuestFSException
1662 public String command (String[] arguments)
1663 throws LibGuestFSException
1666 throw new LibGuestFSException ("command: handle is closed");
1667 return _command (g, arguments);
1669 private native String _command (long g, String[] arguments)
1670 throws LibGuestFSException;
1673 * run a command, returning lines
1675 * This is the same as "g.command", but splits the result
1676 * into a list of lines.
1678 * @throws LibGuestFSException
1680 public String[] command_lines (String[] arguments)
1681 throws LibGuestFSException
1684 throw new LibGuestFSException ("command_lines: handle is closed");
1685 return _command_lines (g, arguments);
1687 private native String[] _command_lines (long g, String[] arguments)
1688 throws LibGuestFSException;
1691 * get file information
1693 * Returns file information for the given "path".
1695 * This is the same as the stat(2) system call.
1697 * @throws LibGuestFSException
1699 public Stat stat (String path)
1700 throws LibGuestFSException
1703 throw new LibGuestFSException ("stat: handle is closed");
1704 return _stat (g, path);
1706 private native Stat _stat (long g, String path)
1707 throws LibGuestFSException;
1710 * get file information for a symbolic link
1712 * Returns file information for the given "path".
1714 * This is the same as "g.stat" except that if "path" is a
1715 * symbolic link, then the link is stat-ed, not the file it
1718 * This is the same as the lstat(2) system call.
1720 * @throws LibGuestFSException
1722 public Stat lstat (String path)
1723 throws LibGuestFSException
1726 throw new LibGuestFSException ("lstat: handle is closed");
1727 return _lstat (g, path);
1729 private native Stat _lstat (long g, String path)
1730 throws LibGuestFSException;
1733 * get file system statistics
1735 * Returns file system statistics for any mounted file
1736 * system. "path" should be a file or directory in the
1737 * mounted file system (typically it is the mount point
1738 * itself, but it doesn't need to be).
1740 * This is the same as the statvfs(2) system call.
1742 * @throws LibGuestFSException
1744 public StatVFS statvfs (String path)
1745 throws LibGuestFSException
1748 throw new LibGuestFSException ("statvfs: handle is closed");
1749 return _statvfs (g, path);
1751 private native StatVFS _statvfs (long g, String path)
1752 throws LibGuestFSException;
1755 * get ext2/ext3/ext4 superblock details
1757 * This returns the contents of the ext2, ext3 or ext4
1758 * filesystem superblock on "device".
1760 * It is the same as running "tune2fs -l device". See
1761 * tune2fs(8) manpage for more details. The list of fields
1762 * returned isn't clearly defined, and depends on both the
1763 * version of "tune2fs" that libguestfs was built against,
1764 * and the filesystem itself.
1766 * @throws LibGuestFSException
1768 public HashMap<String,String> tune2fs_l (String device)
1769 throws LibGuestFSException
1772 throw new LibGuestFSException ("tune2fs_l: handle is closed");
1773 return _tune2fs_l (g, device);
1775 private native HashMap<String,String> _tune2fs_l (long g, String device)
1776 throws LibGuestFSException;
1779 * set block device to read-only
1781 * Sets the block device named "device" to read-only.
1783 * This uses the blockdev(8) command.
1785 * @throws LibGuestFSException
1787 public void blockdev_setro (String device)
1788 throws LibGuestFSException
1791 throw new LibGuestFSException ("blockdev_setro: handle is closed");
1792 _blockdev_setro (g, device);
1794 private native void _blockdev_setro (long g, String device)
1795 throws LibGuestFSException;
1798 * set block device to read-write
1800 * Sets the block device named "device" to read-write.
1802 * This uses the blockdev(8) command.
1804 * @throws LibGuestFSException
1806 public void blockdev_setrw (String device)
1807 throws LibGuestFSException
1810 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1811 _blockdev_setrw (g, device);
1813 private native void _blockdev_setrw (long g, String device)
1814 throws LibGuestFSException;
1817 * is block device set to read-only
1819 * Returns a boolean indicating if the block device is
1820 * read-only (true if read-only, false if not).
1822 * This uses the blockdev(8) command.
1824 * @throws LibGuestFSException
1826 public boolean blockdev_getro (String device)
1827 throws LibGuestFSException
1830 throw new LibGuestFSException ("blockdev_getro: handle is closed");
1831 return _blockdev_getro (g, device);
1833 private native boolean _blockdev_getro (long g, String device)
1834 throws LibGuestFSException;
1837 * get sectorsize of block device
1839 * This returns the size of sectors on a block device.
1840 * Usually 512, but can be larger for modern devices.
1842 * (Note, this is not the size in sectors, use
1843 * "g.blockdev_getsz" for that).
1845 * This uses the blockdev(8) command.
1847 * @throws LibGuestFSException
1849 public int blockdev_getss (String device)
1850 throws LibGuestFSException
1853 throw new LibGuestFSException ("blockdev_getss: handle is closed");
1854 return _blockdev_getss (g, device);
1856 private native int _blockdev_getss (long g, String device)
1857 throws LibGuestFSException;
1860 * get blocksize of block device
1862 * This returns the block size of a device.
1864 * (Note this is different from both *size in blocks* and
1865 * *filesystem block size*).
1867 * This uses the blockdev(8) command.
1869 * @throws LibGuestFSException
1871 public int blockdev_getbsz (String device)
1872 throws LibGuestFSException
1875 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1876 return _blockdev_getbsz (g, device);
1878 private native int _blockdev_getbsz (long g, String device)
1879 throws LibGuestFSException;
1882 * set blocksize of block device
1884 * This sets the block size of a device.
1886 * (Note this is different from both *size in blocks* and
1887 * *filesystem block size*).
1889 * This uses the blockdev(8) command.
1891 * @throws LibGuestFSException
1893 public void blockdev_setbsz (String device, int blocksize)
1894 throws LibGuestFSException
1897 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1898 _blockdev_setbsz (g, device, blocksize);
1900 private native void _blockdev_setbsz (long g, String device, int blocksize)
1901 throws LibGuestFSException;
1904 * get total size of device in 512-byte sectors
1906 * This returns the size of the device in units of 512-byte
1907 * sectors (even if the sectorsize isn't 512 bytes ...
1910 * See also "g.blockdev_getss" for the real sector size of
1911 * the device, and "g.blockdev_getsize64" for the more
1912 * useful *size in bytes*.
1914 * This uses the blockdev(8) command.
1916 * @throws LibGuestFSException
1918 public long blockdev_getsz (String device)
1919 throws LibGuestFSException
1922 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1923 return _blockdev_getsz (g, device);
1925 private native long _blockdev_getsz (long g, String device)
1926 throws LibGuestFSException;
1929 * get total size of device in bytes
1931 * This returns the size of the device in bytes.
1933 * See also "g.blockdev_getsz".
1935 * This uses the blockdev(8) command.
1937 * @throws LibGuestFSException
1939 public long blockdev_getsize64 (String device)
1940 throws LibGuestFSException
1943 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1944 return _blockdev_getsize64 (g, device);
1946 private native long _blockdev_getsize64 (long g, String device)
1947 throws LibGuestFSException;
1950 * flush device buffers
1952 * This tells the kernel to flush internal buffers
1953 * associated with "device".
1955 * This uses the blockdev(8) command.
1957 * @throws LibGuestFSException
1959 public void blockdev_flushbufs (String device)
1960 throws LibGuestFSException
1963 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
1964 _blockdev_flushbufs (g, device);
1966 private native void _blockdev_flushbufs (long g, String device)
1967 throws LibGuestFSException;
1970 * reread partition table
1972 * Reread the partition table on "device".
1974 * This uses the blockdev(8) command.
1976 * @throws LibGuestFSException
1978 public void blockdev_rereadpt (String device)
1979 throws LibGuestFSException
1982 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
1983 _blockdev_rereadpt (g, device);
1985 private native void _blockdev_rereadpt (long g, String device)
1986 throws LibGuestFSException;
1989 * upload a file from the local machine
1991 * Upload local file "filename" to "remotefilename" on the
1994 * "filename" can also be a named pipe.
1996 * See also "g.download".
1998 * @throws LibGuestFSException
2000 public void upload (String filename, String remotefilename)
2001 throws LibGuestFSException
2004 throw new LibGuestFSException ("upload: handle is closed");
2005 _upload (g, filename, remotefilename);
2007 private native void _upload (long g, String filename, String remotefilename)
2008 throws LibGuestFSException;
2011 * download a file to the local machine
2013 * Download file "remotefilename" and save it as "filename"
2014 * on the local machine.
2016 * "filename" can also be a named pipe.
2018 * See also "g.upload", "g.cat".
2020 * @throws LibGuestFSException
2022 public void download (String remotefilename, String filename)
2023 throws LibGuestFSException
2026 throw new LibGuestFSException ("download: handle is closed");
2027 _download (g, remotefilename, filename);
2029 private native void _download (long g, String remotefilename, String filename)
2030 throws LibGuestFSException;
2033 * compute MD5, SHAx or CRC checksum of file
2035 * This call computes the MD5, SHAx or CRC checksum of the
2036 * file named "path".
2038 * The type of checksum to compute is given by the
2039 * "csumtype" parameter which must have one of the
2043 * Compute the cyclic redundancy check (CRC) specified
2044 * by POSIX for the "cksum" command.
2047 * Compute the MD5 hash (using the "md5sum" program).
2050 * Compute the SHA1 hash (using the "sha1sum" program).
2053 * Compute the SHA224 hash (using the "sha224sum"
2057 * Compute the SHA256 hash (using the "sha256sum"
2061 * Compute the SHA384 hash (using the "sha384sum"
2065 * Compute the SHA512 hash (using the "sha512sum"
2068 * The checksum is returned as a printable string.
2070 * @throws LibGuestFSException
2072 public String checksum (String csumtype, String path)
2073 throws LibGuestFSException
2076 throw new LibGuestFSException ("checksum: handle is closed");
2077 return _checksum (g, csumtype, path);
2079 private native String _checksum (long g, String csumtype, String path)
2080 throws LibGuestFSException;
2083 * unpack tarfile to directory
2085 * This command uploads and unpacks local file "tarfile"
2086 * (an *uncompressed* tar file) into "directory".
2088 * To upload a compressed tarball, use "g.tgz_in".
2090 * @throws LibGuestFSException
2092 public void tar_in (String tarfile, String directory)
2093 throws LibGuestFSException
2096 throw new LibGuestFSException ("tar_in: handle is closed");
2097 _tar_in (g, tarfile, directory);
2099 private native void _tar_in (long g, String tarfile, String directory)
2100 throws LibGuestFSException;
2103 * pack directory into tarfile
2105 * This command packs the contents of "directory" and
2106 * downloads it to local file "tarfile".
2108 * To download a compressed tarball, use "g.tgz_out".
2110 * @throws LibGuestFSException
2112 public void tar_out (String directory, String tarfile)
2113 throws LibGuestFSException
2116 throw new LibGuestFSException ("tar_out: handle is closed");
2117 _tar_out (g, directory, tarfile);
2119 private native void _tar_out (long g, String directory, String tarfile)
2120 throws LibGuestFSException;
2123 * unpack compressed tarball to directory
2125 * This command uploads and unpacks local file "tarball" (a
2126 * *gzip compressed* tar file) into "directory".
2128 * To upload an uncompressed tarball, use "g.tar_in".
2130 * @throws LibGuestFSException
2132 public void tgz_in (String tarball, String directory)
2133 throws LibGuestFSException
2136 throw new LibGuestFSException ("tgz_in: handle is closed");
2137 _tgz_in (g, tarball, directory);
2139 private native void _tgz_in (long g, String tarball, String directory)
2140 throws LibGuestFSException;
2143 * pack directory into compressed tarball
2145 * This command packs the contents of "directory" and
2146 * downloads it to local file "tarball".
2148 * To download an uncompressed tarball, use "g.tar_out".
2150 * @throws LibGuestFSException
2152 public void tgz_out (String directory, String tarball)
2153 throws LibGuestFSException
2156 throw new LibGuestFSException ("tgz_out: handle is closed");
2157 _tgz_out (g, directory, tarball);
2159 private native void _tgz_out (long g, String directory, String tarball)
2160 throws LibGuestFSException;
2163 * mount a guest disk, read-only
2165 * This is the same as the "g.mount" command, but it mounts
2166 * the filesystem with the read-only (*-o ro*) flag.
2168 * @throws LibGuestFSException
2170 public void mount_ro (String device, String mountpoint)
2171 throws LibGuestFSException
2174 throw new LibGuestFSException ("mount_ro: handle is closed");
2175 _mount_ro (g, device, mountpoint);
2177 private native void _mount_ro (long g, String device, String mountpoint)
2178 throws LibGuestFSException;
2181 * mount a guest disk with mount options
2183 * This is the same as the "g.mount" command, but it allows
2184 * you to set the mount options as for the mount(8) *-o*
2187 * @throws LibGuestFSException
2189 public void mount_options (String options, String device, String mountpoint)
2190 throws LibGuestFSException
2193 throw new LibGuestFSException ("mount_options: handle is closed");
2194 _mount_options (g, options, device, mountpoint);
2196 private native void _mount_options (long g, String options, String device, String mountpoint)
2197 throws LibGuestFSException;
2200 * mount a guest disk with mount options and vfstype
2202 * This is the same as the "g.mount" command, but it allows
2203 * you to set both the mount options and the vfstype as for
2204 * the mount(8) *-o* and *-t* flags.
2206 * @throws LibGuestFSException
2208 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2209 throws LibGuestFSException
2212 throw new LibGuestFSException ("mount_vfs: handle is closed");
2213 _mount_vfs (g, options, vfstype, device, mountpoint);
2215 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2216 throws LibGuestFSException;
2219 * debugging and internals
2221 * The "g.debug" command exposes some internals of
2222 * "guestfsd" (the guestfs daemon) that runs inside the
2225 * There is no comprehensive help for this command. You
2226 * have to look at the file "daemon/debug.c" in the
2227 * libguestfs source to find out what you can do.
2229 * @throws LibGuestFSException
2231 public String debug (String subcmd, String[] extraargs)
2232 throws LibGuestFSException
2235 throw new LibGuestFSException ("debug: handle is closed");
2236 return _debug (g, subcmd, extraargs);
2238 private native String _debug (long g, String subcmd, String[] extraargs)
2239 throws LibGuestFSException;
2242 * remove an LVM logical volume
2244 * Remove an LVM logical volume "device", where "device" is
2245 * the path to the LV, such as "/dev/VG/LV".
2247 * You can also remove all LVs in a volume group by
2248 * specifying the VG name, "/dev/VG".
2250 * @throws LibGuestFSException
2252 public void lvremove (String device)
2253 throws LibGuestFSException
2256 throw new LibGuestFSException ("lvremove: handle is closed");
2257 _lvremove (g, device);
2259 private native void _lvremove (long g, String device)
2260 throws LibGuestFSException;
2263 * remove an LVM volume group
2265 * Remove an LVM volume group "vgname", (for example "VG").
2267 * This also forcibly removes all logical volumes in the
2268 * volume group (if any).
2270 * @throws LibGuestFSException
2272 public void vgremove (String vgname)
2273 throws LibGuestFSException
2276 throw new LibGuestFSException ("vgremove: handle is closed");
2277 _vgremove (g, vgname);
2279 private native void _vgremove (long g, String vgname)
2280 throws LibGuestFSException;
2283 * remove an LVM physical volume
2285 * This wipes a physical volume "device" so that LVM will
2286 * no longer recognise it.
2288 * The implementation uses the "pvremove" command which
2289 * refuses to wipe physical volumes that contain any volume
2290 * groups, so you have to remove those first.
2292 * @throws LibGuestFSException
2294 public void pvremove (String device)
2295 throws LibGuestFSException
2298 throw new LibGuestFSException ("pvremove: handle is closed");
2299 _pvremove (g, device);
2301 private native void _pvremove (long g, String device)
2302 throws LibGuestFSException;
2305 * set the ext2/3/4 filesystem label
2307 * This sets the ext2/3/4 filesystem label of the
2308 * filesystem on "device" to "label". Filesystem labels are
2309 * limited to 16 characters.
2311 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2312 * return the existing label on a filesystem.
2314 * @throws LibGuestFSException
2316 public void set_e2label (String device, String label)
2317 throws LibGuestFSException
2320 throw new LibGuestFSException ("set_e2label: handle is closed");
2321 _set_e2label (g, device, label);
2323 private native void _set_e2label (long g, String device, String label)
2324 throws LibGuestFSException;
2327 * get the ext2/3/4 filesystem label
2329 * This returns the ext2/3/4 filesystem label of the
2330 * filesystem on "device".
2332 * @throws LibGuestFSException
2334 public String get_e2label (String device)
2335 throws LibGuestFSException
2338 throw new LibGuestFSException ("get_e2label: handle is closed");
2339 return _get_e2label (g, device);
2341 private native String _get_e2label (long g, String device)
2342 throws LibGuestFSException;
2345 * set the ext2/3/4 filesystem UUID
2347 * This sets the ext2/3/4 filesystem UUID of the filesystem
2348 * on "device" to "uuid". The format of the UUID and
2349 * alternatives such as "clear", "random" and "time" are
2350 * described in the tune2fs(8) manpage.
2352 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2353 * return the existing UUID of a filesystem.
2355 * @throws LibGuestFSException
2357 public void set_e2uuid (String device, String uuid)
2358 throws LibGuestFSException
2361 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2362 _set_e2uuid (g, device, uuid);
2364 private native void _set_e2uuid (long g, String device, String uuid)
2365 throws LibGuestFSException;
2368 * get the ext2/3/4 filesystem UUID
2370 * This returns the ext2/3/4 filesystem UUID of the
2371 * filesystem on "device".
2373 * @throws LibGuestFSException
2375 public String get_e2uuid (String device)
2376 throws LibGuestFSException
2379 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2380 return _get_e2uuid (g, device);
2382 private native String _get_e2uuid (long g, String device)
2383 throws LibGuestFSException;
2386 * run the filesystem checker
2388 * This runs the filesystem checker (fsck) on "device"
2389 * which should have filesystem type "fstype".
2391 * The returned integer is the status. See fsck(8) for the
2392 * list of status codes from "fsck".
2396 * * Multiple status codes can be summed together.
2398 * * A non-zero return code can mean "success", for
2399 * example if errors have been corrected on the
2402 * * Checking or repairing NTFS volumes is not supported
2405 * This command is entirely equivalent to running "fsck -a
2406 * -t fstype device".
2408 * @throws LibGuestFSException
2410 public int fsck (String fstype, String device)
2411 throws LibGuestFSException
2414 throw new LibGuestFSException ("fsck: handle is closed");
2415 return _fsck (g, fstype, device);
2417 private native int _fsck (long g, String fstype, String device)
2418 throws LibGuestFSException;
2421 * write zeroes to the device
2423 * This command writes zeroes over the first few blocks of
2426 * How many blocks are zeroed isn't specified (but it's
2427 * *not* enough to securely wipe the device). It should be
2428 * sufficient to remove any partition tables, filesystem
2429 * superblocks and so on.
2431 * @throws LibGuestFSException
2433 public void zero (String device)
2434 throws LibGuestFSException
2437 throw new LibGuestFSException ("zero: handle is closed");
2440 private native void _zero (long g, String device)
2441 throws LibGuestFSException;
2446 * This command installs GRUB (the Grand Unified
2447 * Bootloader) on "device", with the root directory being
2450 * @throws LibGuestFSException
2452 public void grub_install (String root, String device)
2453 throws LibGuestFSException
2456 throw new LibGuestFSException ("grub_install: handle is closed");
2457 _grub_install (g, root, device);
2459 private native void _grub_install (long g, String root, String device)
2460 throws LibGuestFSException;
2465 * This copies a file from "src" to "dest" where "dest" is
2466 * either a destination filename or destination directory.
2468 * @throws LibGuestFSException
2470 public void cp (String src, String dest)
2471 throws LibGuestFSException
2474 throw new LibGuestFSException ("cp: handle is closed");
2477 private native void _cp (long g, String src, String dest)
2478 throws LibGuestFSException;
2481 * copy a file or directory recursively
2483 * This copies a file or directory from "src" to "dest"
2484 * recursively using the "cp -a" command.
2486 * @throws LibGuestFSException
2488 public void cp_a (String src, String dest)
2489 throws LibGuestFSException
2492 throw new LibGuestFSException ("cp_a: handle is closed");
2493 _cp_a (g, src, dest);
2495 private native void _cp_a (long g, String src, String dest)
2496 throws LibGuestFSException;
2501 * This moves a file from "src" to "dest" where "dest" is
2502 * either a destination filename or destination directory.
2504 * @throws LibGuestFSException
2506 public void mv (String src, String dest)
2507 throws LibGuestFSException
2510 throw new LibGuestFSException ("mv: handle is closed");
2513 private native void _mv (long g, String src, String dest)
2514 throws LibGuestFSException;
2517 * drop kernel page cache, dentries and inodes
2519 * This instructs the guest kernel to drop its page cache,
2520 * and/or dentries and inode caches. The parameter
2521 * "whattodrop" tells the kernel what precisely to drop,
2522 * see <http://linux-mm.org/Drop_Caches>
2524 * Setting "whattodrop" to 3 should drop everything.
2526 * This automatically calls sync(2) before the operation,
2527 * so that the maximum guest memory is freed.
2529 * @throws LibGuestFSException
2531 public void drop_caches (int whattodrop)
2532 throws LibGuestFSException
2535 throw new LibGuestFSException ("drop_caches: handle is closed");
2536 _drop_caches (g, whattodrop);
2538 private native void _drop_caches (long g, int whattodrop)
2539 throws LibGuestFSException;
2542 * return kernel messages
2544 * This returns the kernel messages ("dmesg" output) from
2545 * the guest kernel. This is sometimes useful for extended
2546 * debugging of problems.
2548 * Another way to get the same information is to enable
2549 * verbose messages with "g.set_verbose" or by setting the
2550 * environment variable "LIBGUESTFS_DEBUG=1" before running
2553 * @throws LibGuestFSException
2555 public String dmesg ()
2556 throws LibGuestFSException
2559 throw new LibGuestFSException ("dmesg: handle is closed");
2562 private native String _dmesg (long g)
2563 throws LibGuestFSException;
2566 * ping the guest daemon
2568 * This is a test probe into the guestfs daemon running
2569 * inside the qemu subprocess. Calling this function checks
2570 * that the daemon responds to the ping message, without
2571 * affecting the daemon or attached block device(s) in any
2574 * @throws LibGuestFSException
2576 public void ping_daemon ()
2577 throws LibGuestFSException
2580 throw new LibGuestFSException ("ping_daemon: handle is closed");
2583 private native void _ping_daemon (long g)
2584 throws LibGuestFSException;
2587 * test if two files have equal contents
2589 * This compares the two files "file1" and "file2" and
2590 * returns true if their content is exactly equal, or false
2593 * The external cmp(1) program is used for the comparison.
2595 * @throws LibGuestFSException
2597 public boolean equal (String file1, String file2)
2598 throws LibGuestFSException
2601 throw new LibGuestFSException ("equal: handle is closed");
2602 return _equal (g, file1, file2);
2604 private native boolean _equal (long g, String file1, String file2)
2605 throws LibGuestFSException;
2608 * print the printable strings in a file
2610 * This runs the strings(1) command on a file and returns
2611 * the list of printable strings found.
2613 * Because of the message protocol, there is a transfer
2614 * limit of somewhere between 2MB and 4MB. To transfer
2615 * large files you should use FTP.
2617 * @throws LibGuestFSException
2619 public String[] strings (String path)
2620 throws LibGuestFSException
2623 throw new LibGuestFSException ("strings: handle is closed");
2624 return _strings (g, path);
2626 private native String[] _strings (long g, String path)
2627 throws LibGuestFSException;
2630 * print the printable strings in a file
2632 * This is like the "g.strings" command, but allows you to
2633 * specify the encoding.
2635 * See the strings(1) manpage for the full list of
2638 * Commonly useful encodings are "l" (lower case L) which
2639 * will show strings inside Windows/x86 files.
2641 * The returned strings are transcoded to UTF-8.
2643 * Because of the message protocol, there is a transfer
2644 * limit of somewhere between 2MB and 4MB. To transfer
2645 * large files you should use FTP.
2647 * @throws LibGuestFSException
2649 public String[] strings_e (String encoding, String path)
2650 throws LibGuestFSException
2653 throw new LibGuestFSException ("strings_e: handle is closed");
2654 return _strings_e (g, encoding, path);
2656 private native String[] _strings_e (long g, String encoding, String path)
2657 throws LibGuestFSException;
2660 * dump a file in hexadecimal
2662 * This runs "hexdump -C" on the given "path". The result
2663 * is the human-readable, canonical hex dump of the file.
2665 * Because of the message protocol, there is a transfer
2666 * limit of somewhere between 2MB and 4MB. To transfer
2667 * large files you should use FTP.
2669 * @throws LibGuestFSException
2671 public String hexdump (String path)
2672 throws LibGuestFSException
2675 throw new LibGuestFSException ("hexdump: handle is closed");
2676 return _hexdump (g, path);
2678 private native String _hexdump (long g, String path)
2679 throws LibGuestFSException;