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;
319 * add options to kernel command line
321 * This function is used to add additional options to the
322 * guest kernel command line.
324 * The default is "NULL" unless overridden by setting
325 * "LIBGUESTFS_APPEND" environment variable.
327 * The string "append" is stashed in the libguestfs handle,
328 * so the caller must make sure it remains valid for the
329 * lifetime of the handle.
331 * Setting "append" to "NULL" means *no* additional options
332 * are passed (libguestfs always adds a few of its own).
334 * @throws LibGuestFSException
336 public void set_append (String append)
337 throws LibGuestFSException
340 throw new LibGuestFSException ("set_append: handle is closed");
341 _set_append (g, append);
343 private native void _set_append (long g, String append)
344 throws LibGuestFSException;
347 * get the additional kernel options
349 * Return the additional kernel options which are added to
350 * the guest kernel command line.
352 * If "NULL" then no options are added.
354 * @throws LibGuestFSException
356 public String get_append ()
357 throws LibGuestFSException
360 throw new LibGuestFSException ("get_append: handle is closed");
361 return _get_append (g);
363 private native String _get_append (long g)
364 throws LibGuestFSException;
369 * If "autosync" is true, this enables autosync. Libguestfs
370 * will make a best effort attempt to run "g.umount_all"
371 * followed by "g.sync" when the handle is closed (also if
372 * the program exits without closing handles).
374 * This is disabled by default (except in guestfish where
375 * it is enabled by default).
377 * @throws LibGuestFSException
379 public void set_autosync (boolean autosync)
380 throws LibGuestFSException
383 throw new LibGuestFSException ("set_autosync: handle is closed");
384 _set_autosync (g, autosync);
386 private native void _set_autosync (long g, boolean autosync)
387 throws LibGuestFSException;
392 * Get the autosync flag.
394 * @throws LibGuestFSException
396 public boolean get_autosync ()
397 throws LibGuestFSException
400 throw new LibGuestFSException ("get_autosync: handle is closed");
401 return _get_autosync (g);
403 private native boolean _get_autosync (long g)
404 throws LibGuestFSException;
409 * If "verbose" is true, this turns on verbose messages (to
412 * Verbose messages are disabled unless the environment
413 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
415 * @throws LibGuestFSException
417 public void set_verbose (boolean verbose)
418 throws LibGuestFSException
421 throw new LibGuestFSException ("set_verbose: handle is closed");
422 _set_verbose (g, verbose);
424 private native void _set_verbose (long g, boolean verbose)
425 throws LibGuestFSException;
430 * This returns the verbose messages flag.
432 * @throws LibGuestFSException
434 public boolean get_verbose ()
435 throws LibGuestFSException
438 throw new LibGuestFSException ("get_verbose: handle is closed");
439 return _get_verbose (g);
441 private native boolean _get_verbose (long g)
442 throws LibGuestFSException;
445 * is ready to accept commands
447 * This returns true iff this handle is ready to accept
448 * commands (in the "READY" state).
450 * For more information on states, see guestfs(3).
452 * @throws LibGuestFSException
454 public boolean is_ready ()
455 throws LibGuestFSException
458 throw new LibGuestFSException ("is_ready: handle is closed");
459 return _is_ready (g);
461 private native boolean _is_ready (long g)
462 throws LibGuestFSException;
465 * is in configuration state
467 * This returns true iff this handle is being configured
468 * (in the "CONFIG" state).
470 * For more information on states, see guestfs(3).
472 * @throws LibGuestFSException
474 public boolean is_config ()
475 throws LibGuestFSException
478 throw new LibGuestFSException ("is_config: handle is closed");
479 return _is_config (g);
481 private native boolean _is_config (long g)
482 throws LibGuestFSException;
485 * is launching subprocess
487 * This returns true iff this handle is launching the
488 * subprocess (in the "LAUNCHING" state).
490 * For more information on states, see guestfs(3).
492 * @throws LibGuestFSException
494 public boolean is_launching ()
495 throws LibGuestFSException
498 throw new LibGuestFSException ("is_launching: handle is closed");
499 return _is_launching (g);
501 private native boolean _is_launching (long g)
502 throws LibGuestFSException;
505 * is busy processing a command
507 * This returns true iff this handle is busy processing a
508 * command (in the "BUSY" state).
510 * For more information on states, see guestfs(3).
512 * @throws LibGuestFSException
514 public boolean is_busy ()
515 throws LibGuestFSException
518 throw new LibGuestFSException ("is_busy: handle is closed");
521 private native boolean _is_busy (long g)
522 throws LibGuestFSException;
525 * get the current state
527 * This returns the current state as an opaque integer.
528 * This is only useful for printing debug and internal
531 * For more information on states, see guestfs(3).
533 * @throws LibGuestFSException
535 public int get_state ()
536 throws LibGuestFSException
539 throw new LibGuestFSException ("get_state: handle is closed");
540 return _get_state (g);
542 private native int _get_state (long g)
543 throws LibGuestFSException;
548 * This sets the state to "BUSY". This is only used when
549 * implementing actions using the low-level API.
551 * For more information on states, see guestfs(3).
553 * @throws LibGuestFSException
555 public void set_busy ()
556 throws LibGuestFSException
559 throw new LibGuestFSException ("set_busy: handle is closed");
562 private native void _set_busy (long g)
563 throws LibGuestFSException;
568 * This sets the state to "READY". This is only used when
569 * implementing actions using the low-level API.
571 * For more information on states, see guestfs(3).
573 * @throws LibGuestFSException
575 public void set_ready ()
576 throws LibGuestFSException
579 throw new LibGuestFSException ("set_ready: handle is closed");
582 private native void _set_ready (long g)
583 throws LibGuestFSException;
586 * leave the busy state
588 * This sets the state to "READY", or if in "CONFIG" then
589 * it leaves the state as is. This is only used when
590 * implementing actions using the low-level API.
592 * For more information on states, see guestfs(3).
594 * @throws LibGuestFSException
596 public void end_busy ()
597 throws LibGuestFSException
600 throw new LibGuestFSException ("end_busy: handle is closed");
603 private native void _end_busy (long g)
604 throws LibGuestFSException;
607 * mount a guest disk at a position in the filesystem
609 * Mount a guest disk at a position in the filesystem.
610 * Block devices are named "/dev/sda", "/dev/sdb" and so
611 * on, as they were added to the guest. If those block
612 * devices contain partitions, they will have the usual
613 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
616 * The rules are the same as for mount(2): A filesystem
617 * must first be mounted on "/" before others can be
618 * mounted. Other filesystems can only be mounted on
619 * directories which already exist.
621 * The mounted filesystem is writable, if we have
622 * sufficient permissions on the underlying device.
624 * The filesystem options "sync" and "noatime" are set with
625 * this call, in order to improve reliability.
627 * @throws LibGuestFSException
629 public void mount (String device, String mountpoint)
630 throws LibGuestFSException
633 throw new LibGuestFSException ("mount: handle is closed");
634 _mount (g, device, mountpoint);
636 private native void _mount (long g, String device, String mountpoint)
637 throws LibGuestFSException;
640 * sync disks, writes are flushed through to the disk image
642 * This syncs the disk, so that any writes are flushed
643 * through to the underlying disk image.
645 * You should always call this if you have modified a disk
646 * image, before closing the handle.
648 * @throws LibGuestFSException
651 throws LibGuestFSException
654 throw new LibGuestFSException ("sync: handle is closed");
657 private native void _sync (long g)
658 throws LibGuestFSException;
661 * update file timestamps or create a new file
663 * Touch acts like the touch(1) command. It can be used to
664 * update the timestamps on a file, or, if the file does
665 * not exist, to create a new zero-length file.
667 * @throws LibGuestFSException
669 public void touch (String path)
670 throws LibGuestFSException
673 throw new LibGuestFSException ("touch: handle is closed");
676 private native void _touch (long g, String path)
677 throws LibGuestFSException;
680 * list the contents of a file
682 * Return the contents of the file named "path".
684 * Note that this function cannot correctly handle binary
685 * files (specifically, files containing "\0" character
686 * which is treated as end of string). For those you need
687 * to use the "g.download" function which has a more
690 * Because of the message protocol, there is a transfer
691 * limit of somewhere between 2MB and 4MB. To transfer
692 * large files you should use FTP.
694 * @throws LibGuestFSException
696 public String cat (String path)
697 throws LibGuestFSException
700 throw new LibGuestFSException ("cat: handle is closed");
701 return _cat (g, path);
703 private native String _cat (long g, String path)
704 throws LibGuestFSException;
707 * list the files in a directory (long format)
709 * List the files in "directory" (relative to the root
710 * directory, there is no cwd) in the format of 'ls -la'.
712 * This command is mostly useful for interactive sessions.
713 * It is *not* intended that you try to parse the output
716 * @throws LibGuestFSException
718 public String ll (String directory)
719 throws LibGuestFSException
722 throw new LibGuestFSException ("ll: handle is closed");
723 return _ll (g, directory);
725 private native String _ll (long g, String directory)
726 throws LibGuestFSException;
729 * list the files in a directory
731 * List the files in "directory" (relative to the root
732 * directory, there is no cwd). The '.' and '..' entries
733 * are not returned, but hidden files are shown.
735 * This command is mostly useful for interactive sessions.
736 * Programs should probably use "g.readdir" instead.
738 * @throws LibGuestFSException
740 public String[] ls (String directory)
741 throws LibGuestFSException
744 throw new LibGuestFSException ("ls: handle is closed");
745 return _ls (g, directory);
747 private native String[] _ls (long g, String directory)
748 throws LibGuestFSException;
751 * list the block devices
753 * List all the block devices.
755 * The full block device names are returned, eg. "/dev/sda"
757 * @throws LibGuestFSException
759 public String[] list_devices ()
760 throws LibGuestFSException
763 throw new LibGuestFSException ("list_devices: handle is closed");
764 return _list_devices (g);
766 private native String[] _list_devices (long g)
767 throws LibGuestFSException;
770 * list the partitions
772 * List all the partitions detected on all block devices.
774 * The full partition device names are returned, eg.
777 * This does not return logical volumes. For that you will
778 * need to call "g.lvs".
780 * @throws LibGuestFSException
782 public String[] list_partitions ()
783 throws LibGuestFSException
786 throw new LibGuestFSException ("list_partitions: handle is closed");
787 return _list_partitions (g);
789 private native String[] _list_partitions (long g)
790 throws LibGuestFSException;
793 * list the LVM physical volumes (PVs)
795 * List all the physical volumes detected. This is the
796 * equivalent of the pvs(8) command.
798 * This returns a list of just the device names that
799 * contain PVs (eg. "/dev/sda2").
801 * See also "g.pvs_full".
803 * @throws LibGuestFSException
805 public String[] pvs ()
806 throws LibGuestFSException
809 throw new LibGuestFSException ("pvs: handle is closed");
812 private native String[] _pvs (long g)
813 throws LibGuestFSException;
816 * list the LVM volume groups (VGs)
818 * List all the volumes groups detected. This is the
819 * equivalent of the vgs(8) command.
821 * This returns a list of just the volume group names that
822 * were detected (eg. "VolGroup00").
824 * See also "g.vgs_full".
826 * @throws LibGuestFSException
828 public String[] vgs ()
829 throws LibGuestFSException
832 throw new LibGuestFSException ("vgs: handle is closed");
835 private native String[] _vgs (long g)
836 throws LibGuestFSException;
839 * list the LVM logical volumes (LVs)
841 * List all the logical volumes detected. This is the
842 * equivalent of the lvs(8) command.
844 * This returns a list of the logical volume device names
845 * (eg. "/dev/VolGroup00/LogVol00").
847 * See also "g.lvs_full".
849 * @throws LibGuestFSException
851 public String[] lvs ()
852 throws LibGuestFSException
855 throw new LibGuestFSException ("lvs: handle is closed");
858 private native String[] _lvs (long g)
859 throws LibGuestFSException;
862 * list the LVM physical volumes (PVs)
864 * List all the physical volumes detected. This is the
865 * equivalent of the pvs(8) command. The "full" version
866 * includes all fields.
868 * @throws LibGuestFSException
870 public PV[] pvs_full ()
871 throws LibGuestFSException
874 throw new LibGuestFSException ("pvs_full: handle is closed");
875 return _pvs_full (g);
877 private native PV[] _pvs_full (long g)
878 throws LibGuestFSException;
881 * list the LVM volume groups (VGs)
883 * List all the volumes groups detected. This is the
884 * equivalent of the vgs(8) command. The "full" version
885 * includes all fields.
887 * @throws LibGuestFSException
889 public VG[] vgs_full ()
890 throws LibGuestFSException
893 throw new LibGuestFSException ("vgs_full: handle is closed");
894 return _vgs_full (g);
896 private native VG[] _vgs_full (long g)
897 throws LibGuestFSException;
900 * list the LVM logical volumes (LVs)
902 * List all the logical volumes detected. This is the
903 * equivalent of the lvs(8) command. The "full" version
904 * includes all fields.
906 * @throws LibGuestFSException
908 public LV[] lvs_full ()
909 throws LibGuestFSException
912 throw new LibGuestFSException ("lvs_full: handle is closed");
913 return _lvs_full (g);
915 private native LV[] _lvs_full (long g)
916 throws LibGuestFSException;
921 * Return the contents of the file named "path".
923 * The file contents are returned as a list of lines.
924 * Trailing "LF" and "CRLF" character sequences are *not*
927 * Note that this function cannot correctly handle binary
928 * files (specifically, files containing "\0" character
929 * which is treated as end of line). For those you need to
930 * use the "g.read_file" function which has a more complex
933 * @throws LibGuestFSException
935 public String[] read_lines (String path)
936 throws LibGuestFSException
939 throw new LibGuestFSException ("read_lines: handle is closed");
940 return _read_lines (g, path);
942 private native String[] _read_lines (long g, String path)
943 throws LibGuestFSException;
946 * create a new Augeas handle
948 * Create a new Augeas handle for editing configuration
949 * files. If there was any previous Augeas handle
950 * associated with this guestfs session, then it is closed.
952 * You must call this before using any other "g.aug_*"
955 * "root" is the filesystem root. "root" must not be NULL,
958 * The flags are the same as the flags defined in
959 * <augeas.h>, the logical *or* of the following integers:
961 * "AUG_SAVE_BACKUP" = 1
962 * Keep the original file with a ".augsave" extension.
964 * "AUG_SAVE_NEWFILE" = 2
965 * Save changes into a file with extension ".augnew",
966 * and do not overwrite original. Overrides
969 * "AUG_TYPE_CHECK" = 4
970 * Typecheck lenses (can be expensive).
972 * "AUG_NO_STDINC" = 8
973 * Do not use standard load path for modules.
975 * "AUG_SAVE_NOOP" = 16
976 * Make save a no-op, just record what would have been
980 * Do not load the tree in "g.aug_init".
982 * To close the handle, you can call "g.aug_close".
984 * To find out more about Augeas, see <http://augeas.net/>.
986 * @throws LibGuestFSException
988 public void aug_init (String root, int flags)
989 throws LibGuestFSException
992 throw new LibGuestFSException ("aug_init: handle is closed");
993 _aug_init (g, root, flags);
995 private native void _aug_init (long g, String root, int flags)
996 throws LibGuestFSException;
999 * close the current Augeas handle
1001 * Close the current Augeas handle and free up any
1002 * resources used by it. After calling this, you have to
1003 * call "g.aug_init" again before you can use any other
1006 * @throws LibGuestFSException
1008 public void aug_close ()
1009 throws LibGuestFSException
1012 throw new LibGuestFSException ("aug_close: handle is closed");
1015 private native void _aug_close (long g)
1016 throws LibGuestFSException;
1019 * define an Augeas variable
1021 * Defines an Augeas variable "name" whose value is the
1022 * result of evaluating "expr". If "expr" is NULL, then
1023 * "name" is undefined.
1025 * On success this returns the number of nodes in "expr",
1026 * or 0 if "expr" evaluates to something which is not a
1029 * @throws LibGuestFSException
1031 public int aug_defvar (String name, String expr)
1032 throws LibGuestFSException
1035 throw new LibGuestFSException ("aug_defvar: handle is closed");
1036 return _aug_defvar (g, name, expr);
1038 private native int _aug_defvar (long g, String name, String expr)
1039 throws LibGuestFSException;
1042 * define an Augeas node
1044 * Defines a variable "name" whose value is the result of
1045 * evaluating "expr".
1047 * If "expr" evaluates to an empty nodeset, a node is
1048 * created, equivalent to calling "g.aug_set" "expr",
1049 * "value". "name" will be the nodeset containing that
1052 * On success this returns a pair containing the number of
1053 * nodes in the nodeset, and a boolean flag if a node was
1056 * @throws LibGuestFSException
1058 public IntBool aug_defnode (String name, String expr, String val)
1059 throws LibGuestFSException
1062 throw new LibGuestFSException ("aug_defnode: handle is closed");
1063 return _aug_defnode (g, name, expr, val);
1065 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1066 throws LibGuestFSException;
1069 * look up the value of an Augeas path
1071 * Look up the value associated with "path". If "path"
1072 * matches exactly one node, the "value" is returned.
1074 * @throws LibGuestFSException
1076 public String aug_get (String path)
1077 throws LibGuestFSException
1080 throw new LibGuestFSException ("aug_get: handle is closed");
1081 return _aug_get (g, path);
1083 private native String _aug_get (long g, String path)
1084 throws LibGuestFSException;
1087 * set Augeas path to value
1089 * Set the value associated with "path" to "value".
1091 * @throws LibGuestFSException
1093 public void aug_set (String path, String val)
1094 throws LibGuestFSException
1097 throw new LibGuestFSException ("aug_set: handle is closed");
1098 _aug_set (g, path, val);
1100 private native void _aug_set (long g, String path, String val)
1101 throws LibGuestFSException;
1104 * insert a sibling Augeas node
1106 * Create a new sibling "label" for "path", inserting it
1107 * into the tree before or after "path" (depending on the
1108 * boolean flag "before").
1110 * "path" must match exactly one existing node in the tree,
1111 * and "label" must be a label, ie. not contain "/", "*" or
1112 * end with a bracketed index "[N]".
1114 * @throws LibGuestFSException
1116 public void aug_insert (String path, String label, boolean before)
1117 throws LibGuestFSException
1120 throw new LibGuestFSException ("aug_insert: handle is closed");
1121 _aug_insert (g, path, label, before);
1123 private native void _aug_insert (long g, String path, String label, boolean before)
1124 throws LibGuestFSException;
1127 * remove an Augeas path
1129 * Remove "path" and all of its children.
1131 * On success this returns the number of entries which were
1134 * @throws LibGuestFSException
1136 public int aug_rm (String path)
1137 throws LibGuestFSException
1140 throw new LibGuestFSException ("aug_rm: handle is closed");
1141 return _aug_rm (g, path);
1143 private native int _aug_rm (long g, String path)
1144 throws LibGuestFSException;
1149 * Move the node "src" to "dest". "src" must match exactly
1150 * one node. "dest" is overwritten if it exists.
1152 * @throws LibGuestFSException
1154 public void aug_mv (String src, String dest)
1155 throws LibGuestFSException
1158 throw new LibGuestFSException ("aug_mv: handle is closed");
1159 _aug_mv (g, src, dest);
1161 private native void _aug_mv (long g, String src, String dest)
1162 throws LibGuestFSException;
1165 * return Augeas nodes which match path
1167 * Returns a list of paths which match the path expression
1168 * "path". The returned paths are sufficiently qualified so
1169 * that they match exactly one node in the current tree.
1171 * @throws LibGuestFSException
1173 public String[] aug_match (String path)
1174 throws LibGuestFSException
1177 throw new LibGuestFSException ("aug_match: handle is closed");
1178 return _aug_match (g, path);
1180 private native String[] _aug_match (long g, String path)
1181 throws LibGuestFSException;
1184 * write all pending Augeas changes to disk
1186 * This writes all pending changes to disk.
1188 * The flags which were passed to "g.aug_init" affect
1189 * exactly how files are saved.
1191 * @throws LibGuestFSException
1193 public void aug_save ()
1194 throws LibGuestFSException
1197 throw new LibGuestFSException ("aug_save: handle is closed");
1200 private native void _aug_save (long g)
1201 throws LibGuestFSException;
1204 * load files into the tree
1206 * Load files into the tree.
1208 * See "aug_load" in the Augeas documentation for the full
1211 * @throws LibGuestFSException
1213 public void aug_load ()
1214 throws LibGuestFSException
1217 throw new LibGuestFSException ("aug_load: handle is closed");
1220 private native void _aug_load (long g)
1221 throws LibGuestFSException;
1224 * list Augeas nodes under a path
1226 * This is just a shortcut for listing "g.aug_match"
1227 * "path/*" and sorting the resulting nodes into
1228 * alphabetical order.
1230 * @throws LibGuestFSException
1232 public String[] aug_ls (String path)
1233 throws LibGuestFSException
1236 throw new LibGuestFSException ("aug_ls: handle is closed");
1237 return _aug_ls (g, path);
1239 private native String[] _aug_ls (long g, String path)
1240 throws LibGuestFSException;
1245 * Remove the single file "path".
1247 * @throws LibGuestFSException
1249 public void rm (String path)
1250 throws LibGuestFSException
1253 throw new LibGuestFSException ("rm: handle is closed");
1256 private native void _rm (long g, String path)
1257 throws LibGuestFSException;
1260 * remove a directory
1262 * Remove the single directory "path".
1264 * @throws LibGuestFSException
1266 public void rmdir (String path)
1267 throws LibGuestFSException
1270 throw new LibGuestFSException ("rmdir: handle is closed");
1273 private native void _rmdir (long g, String path)
1274 throws LibGuestFSException;
1277 * remove a file or directory recursively
1279 * Remove the file or directory "path", recursively
1280 * removing the contents if its a directory. This is like
1281 * the "rm -rf" shell command.
1283 * @throws LibGuestFSException
1285 public void rm_rf (String path)
1286 throws LibGuestFSException
1289 throw new LibGuestFSException ("rm_rf: handle is closed");
1292 private native void _rm_rf (long g, String path)
1293 throws LibGuestFSException;
1296 * create a directory
1298 * Create a directory named "path".
1300 * @throws LibGuestFSException
1302 public void mkdir (String path)
1303 throws LibGuestFSException
1306 throw new LibGuestFSException ("mkdir: handle is closed");
1309 private native void _mkdir (long g, String path)
1310 throws LibGuestFSException;
1313 * create a directory and parents
1315 * Create a directory named "path", creating any parent
1316 * directories as necessary. This is like the "mkdir -p"
1319 * @throws LibGuestFSException
1321 public void mkdir_p (String path)
1322 throws LibGuestFSException
1325 throw new LibGuestFSException ("mkdir_p: handle is closed");
1328 private native void _mkdir_p (long g, String path)
1329 throws LibGuestFSException;
1334 * Change the mode (permissions) of "path" to "mode". Only
1335 * numeric modes are supported.
1337 * @throws LibGuestFSException
1339 public void chmod (int mode, String path)
1340 throws LibGuestFSException
1343 throw new LibGuestFSException ("chmod: handle is closed");
1344 _chmod (g, mode, path);
1346 private native void _chmod (long g, int mode, String path)
1347 throws LibGuestFSException;
1350 * change file owner and group
1352 * Change the file owner to "owner" and group to "group".
1354 * Only numeric uid and gid are supported. If you want to
1355 * use names, you will need to locate and parse the
1356 * password file yourself (Augeas support makes this
1359 * @throws LibGuestFSException
1361 public void chown (int owner, int group, String path)
1362 throws LibGuestFSException
1365 throw new LibGuestFSException ("chown: handle is closed");
1366 _chown (g, owner, group, path);
1368 private native void _chown (long g, int owner, int group, String path)
1369 throws LibGuestFSException;
1372 * test if file or directory exists
1374 * This returns "true" if and only if there is a file,
1375 * directory (or anything) with the given "path" name.
1377 * See also "g.is_file", "g.is_dir", "g.stat".
1379 * @throws LibGuestFSException
1381 public boolean exists (String path)
1382 throws LibGuestFSException
1385 throw new LibGuestFSException ("exists: handle is closed");
1386 return _exists (g, path);
1388 private native boolean _exists (long g, String path)
1389 throws LibGuestFSException;
1392 * test if file exists
1394 * This returns "true" if and only if there is a file with
1395 * the given "path" name. Note that it returns false for
1396 * other objects like directories.
1398 * See also "g.stat".
1400 * @throws LibGuestFSException
1402 public boolean is_file (String path)
1403 throws LibGuestFSException
1406 throw new LibGuestFSException ("is_file: handle is closed");
1407 return _is_file (g, path);
1409 private native boolean _is_file (long g, String path)
1410 throws LibGuestFSException;
1413 * test if file exists
1415 * This returns "true" if and only if there is a directory
1416 * with the given "path" name. Note that it returns false
1417 * for other objects like files.
1419 * See also "g.stat".
1421 * @throws LibGuestFSException
1423 public boolean is_dir (String path)
1424 throws LibGuestFSException
1427 throw new LibGuestFSException ("is_dir: handle is closed");
1428 return _is_dir (g, path);
1430 private native boolean _is_dir (long g, String path)
1431 throws LibGuestFSException;
1434 * create an LVM physical volume
1436 * This creates an LVM physical volume on the named
1437 * "device", where "device" should usually be a partition
1438 * name such as "/dev/sda1".
1440 * @throws LibGuestFSException
1442 public void pvcreate (String device)
1443 throws LibGuestFSException
1446 throw new LibGuestFSException ("pvcreate: handle is closed");
1447 _pvcreate (g, device);
1449 private native void _pvcreate (long g, String device)
1450 throws LibGuestFSException;
1453 * create an LVM volume group
1455 * This creates an LVM volume group called "volgroup" from
1456 * the non-empty list of physical volumes "physvols".
1458 * @throws LibGuestFSException
1460 public void vgcreate (String volgroup, String[] physvols)
1461 throws LibGuestFSException
1464 throw new LibGuestFSException ("vgcreate: handle is closed");
1465 _vgcreate (g, volgroup, physvols);
1467 private native void _vgcreate (long g, String volgroup, String[] physvols)
1468 throws LibGuestFSException;
1471 * create an LVM volume group
1473 * This creates an LVM volume group called "logvol" on the
1474 * volume group "volgroup", with "size" megabytes.
1476 * @throws LibGuestFSException
1478 public void lvcreate (String logvol, String volgroup, int mbytes)
1479 throws LibGuestFSException
1482 throw new LibGuestFSException ("lvcreate: handle is closed");
1483 _lvcreate (g, logvol, volgroup, mbytes);
1485 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1486 throws LibGuestFSException;
1491 * This creates a filesystem on "device" (usually a
1492 * partition or LVM logical volume). The filesystem type is
1493 * "fstype", for example "ext3".
1495 * @throws LibGuestFSException
1497 public void mkfs (String fstype, String device)
1498 throws LibGuestFSException
1501 throw new LibGuestFSException ("mkfs: handle is closed");
1502 _mkfs (g, fstype, device);
1504 private native void _mkfs (long g, String fstype, String device)
1505 throws LibGuestFSException;
1508 * create partitions on a block device
1510 * This is a direct interface to the sfdisk(8) program for
1511 * creating partitions on block devices.
1513 * "device" should be a block device, for example
1516 * "cyls", "heads" and "sectors" are the number of
1517 * cylinders, heads and sectors on the device, which are
1518 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1519 * parameters. If you pass 0 for any of these, then the
1520 * corresponding parameter is omitted. Usually for 'large'
1521 * disks, you can just pass 0 for these, but for small
1522 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1523 * cannot work out the right geometry and you will need to
1526 * "lines" is a list of lines that we feed to "sfdisk". For
1527 * more information refer to the sfdisk(8) manpage.
1529 * To create a single partition occupying the whole disk,
1530 * you would pass "lines" as a single element list, when
1531 * the single element being the string "," (comma).
1533 * This command is dangerous. Without careful use you can
1534 * easily destroy all your data.
1536 * @throws LibGuestFSException
1538 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1539 throws LibGuestFSException
1542 throw new LibGuestFSException ("sfdisk: handle is closed");
1543 _sfdisk (g, device, cyls, heads, sectors, lines);
1545 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1546 throws LibGuestFSException;
1551 * This call creates a file called "path". The contents of
1552 * the file is the string "content" (which can contain any
1553 * 8 bit data), with length "size".
1555 * As a special case, if "size" is 0 then the length is
1556 * calculated using "strlen" (so in this case the content
1557 * cannot contain embedded ASCII NULs).
1559 * *NB.* Owing to a bug, writing content containing ASCII
1560 * NUL characters does *not* work, even if the length is
1561 * specified. We hope to resolve this bug in a future
1562 * version. In the meantime use "g.upload".
1564 * Because of the message protocol, there is a transfer
1565 * limit of somewhere between 2MB and 4MB. To transfer
1566 * large files you should use FTP.
1568 * @throws LibGuestFSException
1570 public void write_file (String path, String content, int size)
1571 throws LibGuestFSException
1574 throw new LibGuestFSException ("write_file: handle is closed");
1575 _write_file (g, path, content, size);
1577 private native void _write_file (long g, String path, String content, int size)
1578 throws LibGuestFSException;
1581 * unmount a filesystem
1583 * This unmounts the given filesystem. The filesystem may
1584 * be specified either by its mountpoint (path) or the
1585 * device which contains the filesystem.
1587 * @throws LibGuestFSException
1589 public void umount (String pathordevice)
1590 throws LibGuestFSException
1593 throw new LibGuestFSException ("umount: handle is closed");
1594 _umount (g, pathordevice);
1596 private native void _umount (long g, String pathordevice)
1597 throws LibGuestFSException;
1600 * show mounted filesystems
1602 * This returns the list of currently mounted filesystems.
1603 * It returns the list of devices (eg. "/dev/sda1",
1606 * Some internal mounts are not shown.
1608 * @throws LibGuestFSException
1610 public String[] mounts ()
1611 throws LibGuestFSException
1614 throw new LibGuestFSException ("mounts: handle is closed");
1617 private native String[] _mounts (long g)
1618 throws LibGuestFSException;
1621 * unmount all filesystems
1623 * This unmounts all mounted filesystems.
1625 * Some internal mounts are not unmounted by this call.
1627 * @throws LibGuestFSException
1629 public void umount_all ()
1630 throws LibGuestFSException
1633 throw new LibGuestFSException ("umount_all: handle is closed");
1636 private native void _umount_all (long g)
1637 throws LibGuestFSException;
1640 * remove all LVM LVs, VGs and PVs
1642 * This command removes all LVM logical volumes, volume
1643 * groups and physical volumes.
1645 * This command is dangerous. Without careful use you can
1646 * easily destroy all your data.
1648 * @throws LibGuestFSException
1650 public void lvm_remove_all ()
1651 throws LibGuestFSException
1654 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1655 _lvm_remove_all (g);
1657 private native void _lvm_remove_all (long g)
1658 throws LibGuestFSException;
1661 * determine file type
1663 * This call uses the standard file(1) command to determine
1664 * the type or contents of the file. This also works on
1665 * devices, for example to find out whether a partition
1666 * contains a filesystem.
1668 * The exact command which runs is "file -bsL path". Note
1669 * in particular that the filename is not prepended to the
1670 * output (the "-b" option).
1672 * @throws LibGuestFSException
1674 public String file (String path)
1675 throws LibGuestFSException
1678 throw new LibGuestFSException ("file: handle is closed");
1679 return _file (g, path);
1681 private native String _file (long g, String path)
1682 throws LibGuestFSException;
1685 * run a command from the guest filesystem
1687 * This call runs a command from the guest filesystem. The
1688 * filesystem must be mounted, and must contain a
1689 * compatible operating system (ie. something Linux, with
1690 * the same or compatible processor architecture).
1692 * The single parameter is an argv-style list of arguments.
1693 * The first element is the name of the program to run.
1694 * Subsequent elements are parameters. The list must be
1695 * non-empty (ie. must contain a program name).
1697 * The return value is anything printed to *stdout* by the
1700 * If the command returns a non-zero exit status, then this
1701 * function returns an error message. The error message
1702 * string is the content of *stderr* from the command.
1704 * The $PATH environment variable will contain at least
1705 * "/usr/bin" and "/bin". If you require a program from
1706 * another location, you should provide the full path in
1707 * the first parameter.
1709 * Shared libraries and data files required by the program
1710 * must be available on filesystems which are mounted in
1711 * the correct places. It is the caller's responsibility to
1712 * ensure all filesystems that are needed are mounted at
1713 * the right locations.
1715 * Because of the message protocol, there is a transfer
1716 * limit of somewhere between 2MB and 4MB. To transfer
1717 * large files you should use FTP.
1719 * @throws LibGuestFSException
1721 public String command (String[] arguments)
1722 throws LibGuestFSException
1725 throw new LibGuestFSException ("command: handle is closed");
1726 return _command (g, arguments);
1728 private native String _command (long g, String[] arguments)
1729 throws LibGuestFSException;
1732 * run a command, returning lines
1734 * This is the same as "g.command", but splits the result
1735 * into a list of lines.
1737 * Because of the message protocol, there is a transfer
1738 * limit of somewhere between 2MB and 4MB. To transfer
1739 * large files you should use FTP.
1741 * @throws LibGuestFSException
1743 public String[] command_lines (String[] arguments)
1744 throws LibGuestFSException
1747 throw new LibGuestFSException ("command_lines: handle is closed");
1748 return _command_lines (g, arguments);
1750 private native String[] _command_lines (long g, String[] arguments)
1751 throws LibGuestFSException;
1754 * get file information
1756 * Returns file information for the given "path".
1758 * This is the same as the stat(2) system call.
1760 * @throws LibGuestFSException
1762 public Stat stat (String path)
1763 throws LibGuestFSException
1766 throw new LibGuestFSException ("stat: handle is closed");
1767 return _stat (g, path);
1769 private native Stat _stat (long g, String path)
1770 throws LibGuestFSException;
1773 * get file information for a symbolic link
1775 * Returns file information for the given "path".
1777 * This is the same as "g.stat" except that if "path" is a
1778 * symbolic link, then the link is stat-ed, not the file it
1781 * This is the same as the lstat(2) system call.
1783 * @throws LibGuestFSException
1785 public Stat lstat (String path)
1786 throws LibGuestFSException
1789 throw new LibGuestFSException ("lstat: handle is closed");
1790 return _lstat (g, path);
1792 private native Stat _lstat (long g, String path)
1793 throws LibGuestFSException;
1796 * get file system statistics
1798 * Returns file system statistics for any mounted file
1799 * system. "path" should be a file or directory in the
1800 * mounted file system (typically it is the mount point
1801 * itself, but it doesn't need to be).
1803 * This is the same as the statvfs(2) system call.
1805 * @throws LibGuestFSException
1807 public StatVFS statvfs (String path)
1808 throws LibGuestFSException
1811 throw new LibGuestFSException ("statvfs: handle is closed");
1812 return _statvfs (g, path);
1814 private native StatVFS _statvfs (long g, String path)
1815 throws LibGuestFSException;
1818 * get ext2/ext3/ext4 superblock details
1820 * This returns the contents of the ext2, ext3 or ext4
1821 * filesystem superblock on "device".
1823 * It is the same as running "tune2fs -l device". See
1824 * tune2fs(8) manpage for more details. The list of fields
1825 * returned isn't clearly defined, and depends on both the
1826 * version of "tune2fs" that libguestfs was built against,
1827 * and the filesystem itself.
1829 * @throws LibGuestFSException
1831 public HashMap<String,String> tune2fs_l (String device)
1832 throws LibGuestFSException
1835 throw new LibGuestFSException ("tune2fs_l: handle is closed");
1836 return _tune2fs_l (g, device);
1838 private native HashMap<String,String> _tune2fs_l (long g, String device)
1839 throws LibGuestFSException;
1842 * set block device to read-only
1844 * Sets the block device named "device" to read-only.
1846 * This uses the blockdev(8) command.
1848 * @throws LibGuestFSException
1850 public void blockdev_setro (String device)
1851 throws LibGuestFSException
1854 throw new LibGuestFSException ("blockdev_setro: handle is closed");
1855 _blockdev_setro (g, device);
1857 private native void _blockdev_setro (long g, String device)
1858 throws LibGuestFSException;
1861 * set block device to read-write
1863 * Sets the block device named "device" to read-write.
1865 * This uses the blockdev(8) command.
1867 * @throws LibGuestFSException
1869 public void blockdev_setrw (String device)
1870 throws LibGuestFSException
1873 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1874 _blockdev_setrw (g, device);
1876 private native void _blockdev_setrw (long g, String device)
1877 throws LibGuestFSException;
1880 * is block device set to read-only
1882 * Returns a boolean indicating if the block device is
1883 * read-only (true if read-only, false if not).
1885 * This uses the blockdev(8) command.
1887 * @throws LibGuestFSException
1889 public boolean blockdev_getro (String device)
1890 throws LibGuestFSException
1893 throw new LibGuestFSException ("blockdev_getro: handle is closed");
1894 return _blockdev_getro (g, device);
1896 private native boolean _blockdev_getro (long g, String device)
1897 throws LibGuestFSException;
1900 * get sectorsize of block device
1902 * This returns the size of sectors on a block device.
1903 * Usually 512, but can be larger for modern devices.
1905 * (Note, this is not the size in sectors, use
1906 * "g.blockdev_getsz" for that).
1908 * This uses the blockdev(8) command.
1910 * @throws LibGuestFSException
1912 public int blockdev_getss (String device)
1913 throws LibGuestFSException
1916 throw new LibGuestFSException ("blockdev_getss: handle is closed");
1917 return _blockdev_getss (g, device);
1919 private native int _blockdev_getss (long g, String device)
1920 throws LibGuestFSException;
1923 * get blocksize of block device
1925 * This returns the block size of a device.
1927 * (Note this is different from both *size in blocks* and
1928 * *filesystem block size*).
1930 * This uses the blockdev(8) command.
1932 * @throws LibGuestFSException
1934 public int blockdev_getbsz (String device)
1935 throws LibGuestFSException
1938 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1939 return _blockdev_getbsz (g, device);
1941 private native int _blockdev_getbsz (long g, String device)
1942 throws LibGuestFSException;
1945 * set blocksize of block device
1947 * This sets the block size of a device.
1949 * (Note this is different from both *size in blocks* and
1950 * *filesystem block size*).
1952 * This uses the blockdev(8) command.
1954 * @throws LibGuestFSException
1956 public void blockdev_setbsz (String device, int blocksize)
1957 throws LibGuestFSException
1960 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1961 _blockdev_setbsz (g, device, blocksize);
1963 private native void _blockdev_setbsz (long g, String device, int blocksize)
1964 throws LibGuestFSException;
1967 * get total size of device in 512-byte sectors
1969 * This returns the size of the device in units of 512-byte
1970 * sectors (even if the sectorsize isn't 512 bytes ...
1973 * See also "g.blockdev_getss" for the real sector size of
1974 * the device, and "g.blockdev_getsize64" for the more
1975 * useful *size in bytes*.
1977 * This uses the blockdev(8) command.
1979 * @throws LibGuestFSException
1981 public long blockdev_getsz (String device)
1982 throws LibGuestFSException
1985 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1986 return _blockdev_getsz (g, device);
1988 private native long _blockdev_getsz (long g, String device)
1989 throws LibGuestFSException;
1992 * get total size of device in bytes
1994 * This returns the size of the device in bytes.
1996 * See also "g.blockdev_getsz".
1998 * This uses the blockdev(8) command.
2000 * @throws LibGuestFSException
2002 public long blockdev_getsize64 (String device)
2003 throws LibGuestFSException
2006 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2007 return _blockdev_getsize64 (g, device);
2009 private native long _blockdev_getsize64 (long g, String device)
2010 throws LibGuestFSException;
2013 * flush device buffers
2015 * This tells the kernel to flush internal buffers
2016 * associated with "device".
2018 * This uses the blockdev(8) command.
2020 * @throws LibGuestFSException
2022 public void blockdev_flushbufs (String device)
2023 throws LibGuestFSException
2026 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2027 _blockdev_flushbufs (g, device);
2029 private native void _blockdev_flushbufs (long g, String device)
2030 throws LibGuestFSException;
2033 * reread partition table
2035 * Reread the partition table on "device".
2037 * This uses the blockdev(8) command.
2039 * @throws LibGuestFSException
2041 public void blockdev_rereadpt (String device)
2042 throws LibGuestFSException
2045 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2046 _blockdev_rereadpt (g, device);
2048 private native void _blockdev_rereadpt (long g, String device)
2049 throws LibGuestFSException;
2052 * upload a file from the local machine
2054 * Upload local file "filename" to "remotefilename" on the
2057 * "filename" can also be a named pipe.
2059 * See also "g.download".
2061 * @throws LibGuestFSException
2063 public void upload (String filename, String remotefilename)
2064 throws LibGuestFSException
2067 throw new LibGuestFSException ("upload: handle is closed");
2068 _upload (g, filename, remotefilename);
2070 private native void _upload (long g, String filename, String remotefilename)
2071 throws LibGuestFSException;
2074 * download a file to the local machine
2076 * Download file "remotefilename" and save it as "filename"
2077 * on the local machine.
2079 * "filename" can also be a named pipe.
2081 * See also "g.upload", "g.cat".
2083 * @throws LibGuestFSException
2085 public void download (String remotefilename, String filename)
2086 throws LibGuestFSException
2089 throw new LibGuestFSException ("download: handle is closed");
2090 _download (g, remotefilename, filename);
2092 private native void _download (long g, String remotefilename, String filename)
2093 throws LibGuestFSException;
2096 * compute MD5, SHAx or CRC checksum of file
2098 * This call computes the MD5, SHAx or CRC checksum of the
2099 * file named "path".
2101 * The type of checksum to compute is given by the
2102 * "csumtype" parameter which must have one of the
2106 * Compute the cyclic redundancy check (CRC) specified
2107 * by POSIX for the "cksum" command.
2110 * Compute the MD5 hash (using the "md5sum" program).
2113 * Compute the SHA1 hash (using the "sha1sum" program).
2116 * Compute the SHA224 hash (using the "sha224sum"
2120 * Compute the SHA256 hash (using the "sha256sum"
2124 * Compute the SHA384 hash (using the "sha384sum"
2128 * Compute the SHA512 hash (using the "sha512sum"
2131 * The checksum is returned as a printable string.
2133 * @throws LibGuestFSException
2135 public String checksum (String csumtype, String path)
2136 throws LibGuestFSException
2139 throw new LibGuestFSException ("checksum: handle is closed");
2140 return _checksum (g, csumtype, path);
2142 private native String _checksum (long g, String csumtype, String path)
2143 throws LibGuestFSException;
2146 * unpack tarfile to directory
2148 * This command uploads and unpacks local file "tarfile"
2149 * (an *uncompressed* tar file) into "directory".
2151 * To upload a compressed tarball, use "g.tgz_in".
2153 * @throws LibGuestFSException
2155 public void tar_in (String tarfile, String directory)
2156 throws LibGuestFSException
2159 throw new LibGuestFSException ("tar_in: handle is closed");
2160 _tar_in (g, tarfile, directory);
2162 private native void _tar_in (long g, String tarfile, String directory)
2163 throws LibGuestFSException;
2166 * pack directory into tarfile
2168 * This command packs the contents of "directory" and
2169 * downloads it to local file "tarfile".
2171 * To download a compressed tarball, use "g.tgz_out".
2173 * @throws LibGuestFSException
2175 public void tar_out (String directory, String tarfile)
2176 throws LibGuestFSException
2179 throw new LibGuestFSException ("tar_out: handle is closed");
2180 _tar_out (g, directory, tarfile);
2182 private native void _tar_out (long g, String directory, String tarfile)
2183 throws LibGuestFSException;
2186 * unpack compressed tarball to directory
2188 * This command uploads and unpacks local file "tarball" (a
2189 * *gzip compressed* tar file) into "directory".
2191 * To upload an uncompressed tarball, use "g.tar_in".
2193 * @throws LibGuestFSException
2195 public void tgz_in (String tarball, String directory)
2196 throws LibGuestFSException
2199 throw new LibGuestFSException ("tgz_in: handle is closed");
2200 _tgz_in (g, tarball, directory);
2202 private native void _tgz_in (long g, String tarball, String directory)
2203 throws LibGuestFSException;
2206 * pack directory into compressed tarball
2208 * This command packs the contents of "directory" and
2209 * downloads it to local file "tarball".
2211 * To download an uncompressed tarball, use "g.tar_out".
2213 * @throws LibGuestFSException
2215 public void tgz_out (String directory, String tarball)
2216 throws LibGuestFSException
2219 throw new LibGuestFSException ("tgz_out: handle is closed");
2220 _tgz_out (g, directory, tarball);
2222 private native void _tgz_out (long g, String directory, String tarball)
2223 throws LibGuestFSException;
2226 * mount a guest disk, read-only
2228 * This is the same as the "g.mount" command, but it mounts
2229 * the filesystem with the read-only (*-o ro*) flag.
2231 * @throws LibGuestFSException
2233 public void mount_ro (String device, String mountpoint)
2234 throws LibGuestFSException
2237 throw new LibGuestFSException ("mount_ro: handle is closed");
2238 _mount_ro (g, device, mountpoint);
2240 private native void _mount_ro (long g, String device, String mountpoint)
2241 throws LibGuestFSException;
2244 * mount a guest disk with mount options
2246 * This is the same as the "g.mount" command, but it allows
2247 * you to set the mount options as for the mount(8) *-o*
2250 * @throws LibGuestFSException
2252 public void mount_options (String options, String device, String mountpoint)
2253 throws LibGuestFSException
2256 throw new LibGuestFSException ("mount_options: handle is closed");
2257 _mount_options (g, options, device, mountpoint);
2259 private native void _mount_options (long g, String options, String device, String mountpoint)
2260 throws LibGuestFSException;
2263 * mount a guest disk with mount options and vfstype
2265 * This is the same as the "g.mount" command, but it allows
2266 * you to set both the mount options and the vfstype as for
2267 * the mount(8) *-o* and *-t* flags.
2269 * @throws LibGuestFSException
2271 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2272 throws LibGuestFSException
2275 throw new LibGuestFSException ("mount_vfs: handle is closed");
2276 _mount_vfs (g, options, vfstype, device, mountpoint);
2278 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2279 throws LibGuestFSException;
2282 * debugging and internals
2284 * The "g.debug" command exposes some internals of
2285 * "guestfsd" (the guestfs daemon) that runs inside the
2288 * There is no comprehensive help for this command. You
2289 * have to look at the file "daemon/debug.c" in the
2290 * libguestfs source to find out what you can do.
2292 * @throws LibGuestFSException
2294 public String debug (String subcmd, String[] extraargs)
2295 throws LibGuestFSException
2298 throw new LibGuestFSException ("debug: handle is closed");
2299 return _debug (g, subcmd, extraargs);
2301 private native String _debug (long g, String subcmd, String[] extraargs)
2302 throws LibGuestFSException;
2305 * remove an LVM logical volume
2307 * Remove an LVM logical volume "device", where "device" is
2308 * the path to the LV, such as "/dev/VG/LV".
2310 * You can also remove all LVs in a volume group by
2311 * specifying the VG name, "/dev/VG".
2313 * @throws LibGuestFSException
2315 public void lvremove (String device)
2316 throws LibGuestFSException
2319 throw new LibGuestFSException ("lvremove: handle is closed");
2320 _lvremove (g, device);
2322 private native void _lvremove (long g, String device)
2323 throws LibGuestFSException;
2326 * remove an LVM volume group
2328 * Remove an LVM volume group "vgname", (for example "VG").
2330 * This also forcibly removes all logical volumes in the
2331 * volume group (if any).
2333 * @throws LibGuestFSException
2335 public void vgremove (String vgname)
2336 throws LibGuestFSException
2339 throw new LibGuestFSException ("vgremove: handle is closed");
2340 _vgremove (g, vgname);
2342 private native void _vgremove (long g, String vgname)
2343 throws LibGuestFSException;
2346 * remove an LVM physical volume
2348 * This wipes a physical volume "device" so that LVM will
2349 * no longer recognise it.
2351 * The implementation uses the "pvremove" command which
2352 * refuses to wipe physical volumes that contain any volume
2353 * groups, so you have to remove those first.
2355 * @throws LibGuestFSException
2357 public void pvremove (String device)
2358 throws LibGuestFSException
2361 throw new LibGuestFSException ("pvremove: handle is closed");
2362 _pvremove (g, device);
2364 private native void _pvremove (long g, String device)
2365 throws LibGuestFSException;
2368 * set the ext2/3/4 filesystem label
2370 * This sets the ext2/3/4 filesystem label of the
2371 * filesystem on "device" to "label". Filesystem labels are
2372 * limited to 16 characters.
2374 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2375 * return the existing label on a filesystem.
2377 * @throws LibGuestFSException
2379 public void set_e2label (String device, String label)
2380 throws LibGuestFSException
2383 throw new LibGuestFSException ("set_e2label: handle is closed");
2384 _set_e2label (g, device, label);
2386 private native void _set_e2label (long g, String device, String label)
2387 throws LibGuestFSException;
2390 * get the ext2/3/4 filesystem label
2392 * This returns the ext2/3/4 filesystem label of the
2393 * filesystem on "device".
2395 * @throws LibGuestFSException
2397 public String get_e2label (String device)
2398 throws LibGuestFSException
2401 throw new LibGuestFSException ("get_e2label: handle is closed");
2402 return _get_e2label (g, device);
2404 private native String _get_e2label (long g, String device)
2405 throws LibGuestFSException;
2408 * set the ext2/3/4 filesystem UUID
2410 * This sets the ext2/3/4 filesystem UUID of the filesystem
2411 * on "device" to "uuid". The format of the UUID and
2412 * alternatives such as "clear", "random" and "time" are
2413 * described in the tune2fs(8) manpage.
2415 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2416 * return the existing UUID of a filesystem.
2418 * @throws LibGuestFSException
2420 public void set_e2uuid (String device, String uuid)
2421 throws LibGuestFSException
2424 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2425 _set_e2uuid (g, device, uuid);
2427 private native void _set_e2uuid (long g, String device, String uuid)
2428 throws LibGuestFSException;
2431 * get the ext2/3/4 filesystem UUID
2433 * This returns the ext2/3/4 filesystem UUID of the
2434 * filesystem on "device".
2436 * @throws LibGuestFSException
2438 public String get_e2uuid (String device)
2439 throws LibGuestFSException
2442 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2443 return _get_e2uuid (g, device);
2445 private native String _get_e2uuid (long g, String device)
2446 throws LibGuestFSException;
2449 * run the filesystem checker
2451 * This runs the filesystem checker (fsck) on "device"
2452 * which should have filesystem type "fstype".
2454 * The returned integer is the status. See fsck(8) for the
2455 * list of status codes from "fsck".
2459 * * Multiple status codes can be summed together.
2461 * * A non-zero return code can mean "success", for
2462 * example if errors have been corrected on the
2465 * * Checking or repairing NTFS volumes is not supported
2468 * This command is entirely equivalent to running "fsck -a
2469 * -t fstype device".
2471 * @throws LibGuestFSException
2473 public int fsck (String fstype, String device)
2474 throws LibGuestFSException
2477 throw new LibGuestFSException ("fsck: handle is closed");
2478 return _fsck (g, fstype, device);
2480 private native int _fsck (long g, String fstype, String device)
2481 throws LibGuestFSException;
2484 * write zeroes to the device
2486 * This command writes zeroes over the first few blocks of
2489 * How many blocks are zeroed isn't specified (but it's
2490 * *not* enough to securely wipe the device). It should be
2491 * sufficient to remove any partition tables, filesystem
2492 * superblocks and so on.
2494 * @throws LibGuestFSException
2496 public void zero (String device)
2497 throws LibGuestFSException
2500 throw new LibGuestFSException ("zero: handle is closed");
2503 private native void _zero (long g, String device)
2504 throws LibGuestFSException;
2509 * This command installs GRUB (the Grand Unified
2510 * Bootloader) on "device", with the root directory being
2513 * @throws LibGuestFSException
2515 public void grub_install (String root, String device)
2516 throws LibGuestFSException
2519 throw new LibGuestFSException ("grub_install: handle is closed");
2520 _grub_install (g, root, device);
2522 private native void _grub_install (long g, String root, String device)
2523 throws LibGuestFSException;
2528 * This copies a file from "src" to "dest" where "dest" is
2529 * either a destination filename or destination directory.
2531 * @throws LibGuestFSException
2533 public void cp (String src, String dest)
2534 throws LibGuestFSException
2537 throw new LibGuestFSException ("cp: handle is closed");
2540 private native void _cp (long g, String src, String dest)
2541 throws LibGuestFSException;
2544 * copy a file or directory recursively
2546 * This copies a file or directory from "src" to "dest"
2547 * recursively using the "cp -a" command.
2549 * @throws LibGuestFSException
2551 public void cp_a (String src, String dest)
2552 throws LibGuestFSException
2555 throw new LibGuestFSException ("cp_a: handle is closed");
2556 _cp_a (g, src, dest);
2558 private native void _cp_a (long g, String src, String dest)
2559 throws LibGuestFSException;
2564 * This moves a file from "src" to "dest" where "dest" is
2565 * either a destination filename or destination directory.
2567 * @throws LibGuestFSException
2569 public void mv (String src, String dest)
2570 throws LibGuestFSException
2573 throw new LibGuestFSException ("mv: handle is closed");
2576 private native void _mv (long g, String src, String dest)
2577 throws LibGuestFSException;
2580 * drop kernel page cache, dentries and inodes
2582 * This instructs the guest kernel to drop its page cache,
2583 * and/or dentries and inode caches. The parameter
2584 * "whattodrop" tells the kernel what precisely to drop,
2585 * see <http://linux-mm.org/Drop_Caches>
2587 * Setting "whattodrop" to 3 should drop everything.
2589 * This automatically calls sync(2) before the operation,
2590 * so that the maximum guest memory is freed.
2592 * @throws LibGuestFSException
2594 public void drop_caches (int whattodrop)
2595 throws LibGuestFSException
2598 throw new LibGuestFSException ("drop_caches: handle is closed");
2599 _drop_caches (g, whattodrop);
2601 private native void _drop_caches (long g, int whattodrop)
2602 throws LibGuestFSException;
2605 * return kernel messages
2607 * This returns the kernel messages ("dmesg" output) from
2608 * the guest kernel. This is sometimes useful for extended
2609 * debugging of problems.
2611 * Another way to get the same information is to enable
2612 * verbose messages with "g.set_verbose" or by setting the
2613 * environment variable "LIBGUESTFS_DEBUG=1" before running
2616 * @throws LibGuestFSException
2618 public String dmesg ()
2619 throws LibGuestFSException
2622 throw new LibGuestFSException ("dmesg: handle is closed");
2625 private native String _dmesg (long g)
2626 throws LibGuestFSException;
2629 * ping the guest daemon
2631 * This is a test probe into the guestfs daemon running
2632 * inside the qemu subprocess. Calling this function checks
2633 * that the daemon responds to the ping message, without
2634 * affecting the daemon or attached block device(s) in any
2637 * @throws LibGuestFSException
2639 public void ping_daemon ()
2640 throws LibGuestFSException
2643 throw new LibGuestFSException ("ping_daemon: handle is closed");
2646 private native void _ping_daemon (long g)
2647 throws LibGuestFSException;
2650 * test if two files have equal contents
2652 * This compares the two files "file1" and "file2" and
2653 * returns true if their content is exactly equal, or false
2656 * The external cmp(1) program is used for the comparison.
2658 * @throws LibGuestFSException
2660 public boolean equal (String file1, String file2)
2661 throws LibGuestFSException
2664 throw new LibGuestFSException ("equal: handle is closed");
2665 return _equal (g, file1, file2);
2667 private native boolean _equal (long g, String file1, String file2)
2668 throws LibGuestFSException;
2671 * print the printable strings in a file
2673 * This runs the strings(1) command on a file and returns
2674 * the list of printable strings found.
2676 * Because of the message protocol, there is a transfer
2677 * limit of somewhere between 2MB and 4MB. To transfer
2678 * large files you should use FTP.
2680 * @throws LibGuestFSException
2682 public String[] strings (String path)
2683 throws LibGuestFSException
2686 throw new LibGuestFSException ("strings: handle is closed");
2687 return _strings (g, path);
2689 private native String[] _strings (long g, String path)
2690 throws LibGuestFSException;
2693 * print the printable strings in a file
2695 * This is like the "g.strings" command, but allows you to
2696 * specify the encoding.
2698 * See the strings(1) manpage for the full list of
2701 * Commonly useful encodings are "l" (lower case L) which
2702 * will show strings inside Windows/x86 files.
2704 * The returned strings are transcoded to UTF-8.
2706 * Because of the message protocol, there is a transfer
2707 * limit of somewhere between 2MB and 4MB. To transfer
2708 * large files you should use FTP.
2710 * @throws LibGuestFSException
2712 public String[] strings_e (String encoding, String path)
2713 throws LibGuestFSException
2716 throw new LibGuestFSException ("strings_e: handle is closed");
2717 return _strings_e (g, encoding, path);
2719 private native String[] _strings_e (long g, String encoding, String path)
2720 throws LibGuestFSException;
2723 * dump a file in hexadecimal
2725 * This runs "hexdump -C" on the given "path". The result
2726 * is the human-readable, canonical hex dump of the file.
2728 * Because of the message protocol, there is a transfer
2729 * limit of somewhere between 2MB and 4MB. To transfer
2730 * large files you should use FTP.
2732 * @throws LibGuestFSException
2734 public String hexdump (String path)
2735 throws LibGuestFSException
2738 throw new LibGuestFSException ("hexdump: handle is closed");
2739 return _hexdump (g, path);
2741 private native String _hexdump (long g, String path)
2742 throws LibGuestFSException;