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 search path
224 * Set the path that libguestfs searches for kernel and
227 * The default is "$libdir/guestfs" unless overridden by
228 * setting "LIBGUESTFS_PATH" environment variable.
230 * The string "path" is stashed in the libguestfs handle,
231 * so the caller must make sure it remains valid for the
232 * lifetime of the handle.
234 * Setting "path" to "NULL" restores the default path.
236 * @throws LibGuestFSException
238 public void set_path (String path)
239 throws LibGuestFSException
242 throw new LibGuestFSException ("set_path: handle is closed");
245 private native void _set_path (long g, String path)
246 throws LibGuestFSException;
249 * get the search path
251 * Return the current search path.
253 * This is always non-NULL. If it wasn't set already, then
254 * this will return the default path.
256 * @throws LibGuestFSException
258 public String get_path ()
259 throws LibGuestFSException
262 throw new LibGuestFSException ("get_path: handle is closed");
263 return _get_path (g);
265 private native String _get_path (long g)
266 throws LibGuestFSException;
271 * If "autosync" is true, this enables autosync. Libguestfs
272 * will make a best effort attempt to run "g.sync" when the
273 * handle is closed (also if the program exits without
276 * @throws LibGuestFSException
278 public void set_autosync (boolean autosync)
279 throws LibGuestFSException
282 throw new LibGuestFSException ("set_autosync: handle is closed");
283 _set_autosync (g, autosync);
285 private native void _set_autosync (long g, boolean autosync)
286 throws LibGuestFSException;
291 * Get the autosync flag.
293 * @throws LibGuestFSException
295 public boolean get_autosync ()
296 throws LibGuestFSException
299 throw new LibGuestFSException ("get_autosync: handle is closed");
300 return _get_autosync (g);
302 private native boolean _get_autosync (long g)
303 throws LibGuestFSException;
308 * If "verbose" is true, this turns on verbose messages (to
311 * Verbose messages are disabled unless the environment
312 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
314 * @throws LibGuestFSException
316 public void set_verbose (boolean verbose)
317 throws LibGuestFSException
320 throw new LibGuestFSException ("set_verbose: handle is closed");
321 _set_verbose (g, verbose);
323 private native void _set_verbose (long g, boolean verbose)
324 throws LibGuestFSException;
329 * This returns the verbose messages flag.
331 * @throws LibGuestFSException
333 public boolean get_verbose ()
334 throws LibGuestFSException
337 throw new LibGuestFSException ("get_verbose: handle is closed");
338 return _get_verbose (g);
340 private native boolean _get_verbose (long g)
341 throws LibGuestFSException;
344 * is ready to accept commands
346 * This returns true iff this handle is ready to accept
347 * commands (in the "READY" state).
349 * For more information on states, see guestfs(3).
351 * @throws LibGuestFSException
353 public boolean is_ready ()
354 throws LibGuestFSException
357 throw new LibGuestFSException ("is_ready: handle is closed");
358 return _is_ready (g);
360 private native boolean _is_ready (long g)
361 throws LibGuestFSException;
364 * is in configuration state
366 * This returns true iff this handle is being configured
367 * (in the "CONFIG" state).
369 * For more information on states, see guestfs(3).
371 * @throws LibGuestFSException
373 public boolean is_config ()
374 throws LibGuestFSException
377 throw new LibGuestFSException ("is_config: handle is closed");
378 return _is_config (g);
380 private native boolean _is_config (long g)
381 throws LibGuestFSException;
384 * is launching subprocess
386 * This returns true iff this handle is launching the
387 * subprocess (in the "LAUNCHING" state).
389 * For more information on states, see guestfs(3).
391 * @throws LibGuestFSException
393 public boolean is_launching ()
394 throws LibGuestFSException
397 throw new LibGuestFSException ("is_launching: handle is closed");
398 return _is_launching (g);
400 private native boolean _is_launching (long g)
401 throws LibGuestFSException;
404 * is busy processing a command
406 * This returns true iff this handle is busy processing a
407 * command (in the "BUSY" state).
409 * For more information on states, see guestfs(3).
411 * @throws LibGuestFSException
413 public boolean is_busy ()
414 throws LibGuestFSException
417 throw new LibGuestFSException ("is_busy: handle is closed");
420 private native boolean _is_busy (long g)
421 throws LibGuestFSException;
424 * get the current state
426 * This returns the current state as an opaque integer.
427 * This is only useful for printing debug and internal
430 * For more information on states, see guestfs(3).
432 * @throws LibGuestFSException
434 public int get_state ()
435 throws LibGuestFSException
438 throw new LibGuestFSException ("get_state: handle is closed");
439 return _get_state (g);
441 private native int _get_state (long g)
442 throws LibGuestFSException;
447 * This sets the state to "BUSY". This is only used when
448 * implementing actions using the low-level API.
450 * For more information on states, see guestfs(3).
452 * @throws LibGuestFSException
454 public void set_busy ()
455 throws LibGuestFSException
458 throw new LibGuestFSException ("set_busy: handle is closed");
461 private native void _set_busy (long g)
462 throws LibGuestFSException;
467 * This sets the state to "READY". This is only used when
468 * implementing actions using the low-level API.
470 * For more information on states, see guestfs(3).
472 * @throws LibGuestFSException
474 public void set_ready ()
475 throws LibGuestFSException
478 throw new LibGuestFSException ("set_ready: handle is closed");
481 private native void _set_ready (long g)
482 throws LibGuestFSException;
485 * mount a guest disk at a position in the filesystem
487 * Mount a guest disk at a position in the filesystem.
488 * Block devices are named "/dev/sda", "/dev/sdb" and so
489 * on, as they were added to the guest. If those block
490 * devices contain partitions, they will have the usual
491 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
494 * The rules are the same as for mount(2): A filesystem
495 * must first be mounted on "/" before others can be
496 * mounted. Other filesystems can only be mounted on
497 * directories which already exist.
499 * The mounted filesystem is writable, if we have
500 * sufficient permissions on the underlying device.
502 * The filesystem options "sync" and "noatime" are set with
503 * this call, in order to improve reliability.
505 * @throws LibGuestFSException
507 public void mount (String device, String mountpoint)
508 throws LibGuestFSException
511 throw new LibGuestFSException ("mount: handle is closed");
512 _mount (g, device, mountpoint);
514 private native void _mount (long g, String device, String mountpoint)
515 throws LibGuestFSException;
518 * sync disks, writes are flushed through to the disk image
520 * This syncs the disk, so that any writes are flushed
521 * through to the underlying disk image.
523 * You should always call this if you have modified a disk
524 * image, before closing the handle.
526 * @throws LibGuestFSException
529 throws LibGuestFSException
532 throw new LibGuestFSException ("sync: handle is closed");
535 private native void _sync (long g)
536 throws LibGuestFSException;
539 * update file timestamps or create a new file
541 * Touch acts like the touch(1) command. It can be used to
542 * update the timestamps on a file, or, if the file does
543 * not exist, to create a new zero-length file.
545 * @throws LibGuestFSException
547 public void touch (String path)
548 throws LibGuestFSException
551 throw new LibGuestFSException ("touch: handle is closed");
554 private native void _touch (long g, String path)
555 throws LibGuestFSException;
558 * list the contents of a file
560 * Return the contents of the file named "path".
562 * Note that this function cannot correctly handle binary
563 * files (specifically, files containing "\0" character
564 * which is treated as end of string). For those you need
565 * to use the "g.download" function which has a more
568 * Because of the message protocol, there is a transfer
569 * limit of somewhere between 2MB and 4MB. To transfer
570 * large files you should use FTP.
572 * @throws LibGuestFSException
574 public String cat (String path)
575 throws LibGuestFSException
578 throw new LibGuestFSException ("cat: handle is closed");
579 return _cat (g, path);
581 private native String _cat (long g, String path)
582 throws LibGuestFSException;
585 * list the files in a directory (long format)
587 * List the files in "directory" (relative to the root
588 * directory, there is no cwd) in the format of 'ls -la'.
590 * This command is mostly useful for interactive sessions.
591 * It is *not* intended that you try to parse the output
594 * @throws LibGuestFSException
596 public String ll (String directory)
597 throws LibGuestFSException
600 throw new LibGuestFSException ("ll: handle is closed");
601 return _ll (g, directory);
603 private native String _ll (long g, String directory)
604 throws LibGuestFSException;
607 * list the files in a directory
609 * List the files in "directory" (relative to the root
610 * directory, there is no cwd). The '.' and '..' entries
611 * are not returned, but hidden files are shown.
613 * This command is mostly useful for interactive sessions.
614 * Programs should probably use "g.readdir" instead.
616 * @throws LibGuestFSException
618 public String[] ls (String directory)
619 throws LibGuestFSException
622 throw new LibGuestFSException ("ls: handle is closed");
623 return _ls (g, directory);
625 private native String[] _ls (long g, String directory)
626 throws LibGuestFSException;
629 * list the block devices
631 * List all the block devices.
633 * The full block device names are returned, eg. "/dev/sda"
635 * @throws LibGuestFSException
637 public String[] list_devices ()
638 throws LibGuestFSException
641 throw new LibGuestFSException ("list_devices: handle is closed");
642 return _list_devices (g);
644 private native String[] _list_devices (long g)
645 throws LibGuestFSException;
648 * list the partitions
650 * List all the partitions detected on all block devices.
652 * The full partition device names are returned, eg.
655 * This does not return logical volumes. For that you will
656 * need to call "g.lvs".
658 * @throws LibGuestFSException
660 public String[] list_partitions ()
661 throws LibGuestFSException
664 throw new LibGuestFSException ("list_partitions: handle is closed");
665 return _list_partitions (g);
667 private native String[] _list_partitions (long g)
668 throws LibGuestFSException;
671 * list the LVM physical volumes (PVs)
673 * List all the physical volumes detected. This is the
674 * equivalent of the pvs(8) command.
676 * This returns a list of just the device names that
677 * contain PVs (eg. "/dev/sda2").
679 * See also "g.pvs_full".
681 * @throws LibGuestFSException
683 public String[] pvs ()
684 throws LibGuestFSException
687 throw new LibGuestFSException ("pvs: handle is closed");
690 private native String[] _pvs (long g)
691 throws LibGuestFSException;
694 * list the LVM volume groups (VGs)
696 * List all the volumes groups detected. This is the
697 * equivalent of the vgs(8) command.
699 * This returns a list of just the volume group names that
700 * were detected (eg. "VolGroup00").
702 * See also "g.vgs_full".
704 * @throws LibGuestFSException
706 public String[] vgs ()
707 throws LibGuestFSException
710 throw new LibGuestFSException ("vgs: handle is closed");
713 private native String[] _vgs (long g)
714 throws LibGuestFSException;
717 * list the LVM logical volumes (LVs)
719 * List all the logical volumes detected. This is the
720 * equivalent of the lvs(8) command.
722 * This returns a list of the logical volume device names
723 * (eg. "/dev/VolGroup00/LogVol00").
725 * See also "g.lvs_full".
727 * @throws LibGuestFSException
729 public String[] lvs ()
730 throws LibGuestFSException
733 throw new LibGuestFSException ("lvs: handle is closed");
736 private native String[] _lvs (long g)
737 throws LibGuestFSException;
740 * list the LVM physical volumes (PVs)
742 * List all the physical volumes detected. This is the
743 * equivalent of the pvs(8) command. The "full" version
744 * includes all fields.
746 * @throws LibGuestFSException
748 public PV[] pvs_full ()
749 throws LibGuestFSException
752 throw new LibGuestFSException ("pvs_full: handle is closed");
753 return _pvs_full (g);
755 private native PV[] _pvs_full (long g)
756 throws LibGuestFSException;
759 * list the LVM volume groups (VGs)
761 * List all the volumes groups detected. This is the
762 * equivalent of the vgs(8) command. The "full" version
763 * includes all fields.
765 * @throws LibGuestFSException
767 public VG[] vgs_full ()
768 throws LibGuestFSException
771 throw new LibGuestFSException ("vgs_full: handle is closed");
772 return _vgs_full (g);
774 private native VG[] _vgs_full (long g)
775 throws LibGuestFSException;
778 * list the LVM logical volumes (LVs)
780 * List all the logical volumes detected. This is the
781 * equivalent of the lvs(8) command. The "full" version
782 * includes all fields.
784 * @throws LibGuestFSException
786 public LV[] lvs_full ()
787 throws LibGuestFSException
790 throw new LibGuestFSException ("lvs_full: handle is closed");
791 return _lvs_full (g);
793 private native LV[] _lvs_full (long g)
794 throws LibGuestFSException;
799 * Return the contents of the file named "path".
801 * The file contents are returned as a list of lines.
802 * Trailing "LF" and "CRLF" character sequences are *not*
805 * Note that this function cannot correctly handle binary
806 * files (specifically, files containing "\0" character
807 * which is treated as end of line). For those you need to
808 * use the "g.read_file" function which has a more complex
811 * @throws LibGuestFSException
813 public String[] read_lines (String path)
814 throws LibGuestFSException
817 throw new LibGuestFSException ("read_lines: handle is closed");
818 return _read_lines (g, path);
820 private native String[] _read_lines (long g, String path)
821 throws LibGuestFSException;
824 * create a new Augeas handle
826 * Create a new Augeas handle for editing configuration
827 * files. If there was any previous Augeas handle
828 * associated with this guestfs session, then it is closed.
830 * You must call this before using any other "g.aug_*"
833 * "root" is the filesystem root. "root" must not be NULL,
836 * The flags are the same as the flags defined in
837 * <augeas.h>, the logical *or* of the following integers:
839 * "AUG_SAVE_BACKUP" = 1
840 * Keep the original file with a ".augsave" extension.
842 * "AUG_SAVE_NEWFILE" = 2
843 * Save changes into a file with extension ".augnew",
844 * and do not overwrite original. Overrides
847 * "AUG_TYPE_CHECK" = 4
848 * Typecheck lenses (can be expensive).
850 * "AUG_NO_STDINC" = 8
851 * Do not use standard load path for modules.
853 * "AUG_SAVE_NOOP" = 16
854 * Make save a no-op, just record what would have been
858 * Do not load the tree in "g.aug_init".
860 * To close the handle, you can call "g.aug_close".
862 * To find out more about Augeas, see <http://augeas.net/>.
864 * @throws LibGuestFSException
866 public void aug_init (String root, int flags)
867 throws LibGuestFSException
870 throw new LibGuestFSException ("aug_init: handle is closed");
871 _aug_init (g, root, flags);
873 private native void _aug_init (long g, String root, int flags)
874 throws LibGuestFSException;
877 * close the current Augeas handle
879 * Close the current Augeas handle and free up any
880 * resources used by it. After calling this, you have to
881 * call "g.aug_init" again before you can use any other
884 * @throws LibGuestFSException
886 public void aug_close ()
887 throws LibGuestFSException
890 throw new LibGuestFSException ("aug_close: handle is closed");
893 private native void _aug_close (long g)
894 throws LibGuestFSException;
897 * define an Augeas variable
899 * Defines an Augeas variable "name" whose value is the
900 * result of evaluating "expr". If "expr" is NULL, then
901 * "name" is undefined.
903 * On success this returns the number of nodes in "expr",
904 * or 0 if "expr" evaluates to something which is not a
907 * @throws LibGuestFSException
909 public int aug_defvar (String name, String expr)
910 throws LibGuestFSException
913 throw new LibGuestFSException ("aug_defvar: handle is closed");
914 return _aug_defvar (g, name, expr);
916 private native int _aug_defvar (long g, String name, String expr)
917 throws LibGuestFSException;
920 * define an Augeas node
922 * Defines a variable "name" whose value is the result of
925 * If "expr" evaluates to an empty nodeset, a node is
926 * created, equivalent to calling "g.aug_set" "expr",
927 * "value". "name" will be the nodeset containing that
930 * On success this returns a pair containing the number of
931 * nodes in the nodeset, and a boolean flag if a node was
934 * @throws LibGuestFSException
936 public IntBool aug_defnode (String name, String expr, String val)
937 throws LibGuestFSException
940 throw new LibGuestFSException ("aug_defnode: handle is closed");
941 return _aug_defnode (g, name, expr, val);
943 private native IntBool _aug_defnode (long g, String name, String expr, String val)
944 throws LibGuestFSException;
947 * look up the value of an Augeas path
949 * Look up the value associated with "path". If "path"
950 * matches exactly one node, the "value" is returned.
952 * @throws LibGuestFSException
954 public String aug_get (String path)
955 throws LibGuestFSException
958 throw new LibGuestFSException ("aug_get: handle is closed");
959 return _aug_get (g, path);
961 private native String _aug_get (long g, String path)
962 throws LibGuestFSException;
965 * set Augeas path to value
967 * Set the value associated with "path" to "value".
969 * @throws LibGuestFSException
971 public void aug_set (String path, String val)
972 throws LibGuestFSException
975 throw new LibGuestFSException ("aug_set: handle is closed");
976 _aug_set (g, path, val);
978 private native void _aug_set (long g, String path, String val)
979 throws LibGuestFSException;
982 * insert a sibling Augeas node
984 * Create a new sibling "label" for "path", inserting it
985 * into the tree before or after "path" (depending on the
986 * boolean flag "before").
988 * "path" must match exactly one existing node in the tree,
989 * and "label" must be a label, ie. not contain "/", "*" or
990 * end with a bracketed index "[N]".
992 * @throws LibGuestFSException
994 public void aug_insert (String path, String label, boolean before)
995 throws LibGuestFSException
998 throw new LibGuestFSException ("aug_insert: handle is closed");
999 _aug_insert (g, path, label, before);
1001 private native void _aug_insert (long g, String path, String label, boolean before)
1002 throws LibGuestFSException;
1005 * remove an Augeas path
1007 * Remove "path" and all of its children.
1009 * On success this returns the number of entries which were
1012 * @throws LibGuestFSException
1014 public int aug_rm (String path)
1015 throws LibGuestFSException
1018 throw new LibGuestFSException ("aug_rm: handle is closed");
1019 return _aug_rm (g, path);
1021 private native int _aug_rm (long g, String path)
1022 throws LibGuestFSException;
1027 * Move the node "src" to "dest". "src" must match exactly
1028 * one node. "dest" is overwritten if it exists.
1030 * @throws LibGuestFSException
1032 public void aug_mv (String src, String dest)
1033 throws LibGuestFSException
1036 throw new LibGuestFSException ("aug_mv: handle is closed");
1037 _aug_mv (g, src, dest);
1039 private native void _aug_mv (long g, String src, String dest)
1040 throws LibGuestFSException;
1043 * return Augeas nodes which match path
1045 * Returns a list of paths which match the path expression
1046 * "path". The returned paths are sufficiently qualified so
1047 * that they match exactly one node in the current tree.
1049 * @throws LibGuestFSException
1051 public String[] aug_match (String path)
1052 throws LibGuestFSException
1055 throw new LibGuestFSException ("aug_match: handle is closed");
1056 return _aug_match (g, path);
1058 private native String[] _aug_match (long g, String path)
1059 throws LibGuestFSException;
1062 * write all pending Augeas changes to disk
1064 * This writes all pending changes to disk.
1066 * The flags which were passed to "g.aug_init" affect
1067 * exactly how files are saved.
1069 * @throws LibGuestFSException
1071 public void aug_save ()
1072 throws LibGuestFSException
1075 throw new LibGuestFSException ("aug_save: handle is closed");
1078 private native void _aug_save (long g)
1079 throws LibGuestFSException;
1082 * load files into the tree
1084 * Load files into the tree.
1086 * See "aug_load" in the Augeas documentation for the full
1089 * @throws LibGuestFSException
1091 public void aug_load ()
1092 throws LibGuestFSException
1095 throw new LibGuestFSException ("aug_load: handle is closed");
1098 private native void _aug_load (long g)
1099 throws LibGuestFSException;
1102 * list Augeas nodes under a path
1104 * This is just a shortcut for listing "g.aug_match"
1105 * "path/*" and sorting the resulting nodes into
1106 * alphabetical order.
1108 * @throws LibGuestFSException
1110 public String[] aug_ls (String path)
1111 throws LibGuestFSException
1114 throw new LibGuestFSException ("aug_ls: handle is closed");
1115 return _aug_ls (g, path);
1117 private native String[] _aug_ls (long g, String path)
1118 throws LibGuestFSException;
1123 * Remove the single file "path".
1125 * @throws LibGuestFSException
1127 public void rm (String path)
1128 throws LibGuestFSException
1131 throw new LibGuestFSException ("rm: handle is closed");
1134 private native void _rm (long g, String path)
1135 throws LibGuestFSException;
1138 * remove a directory
1140 * Remove the single directory "path".
1142 * @throws LibGuestFSException
1144 public void rmdir (String path)
1145 throws LibGuestFSException
1148 throw new LibGuestFSException ("rmdir: handle is closed");
1151 private native void _rmdir (long g, String path)
1152 throws LibGuestFSException;
1155 * remove a file or directory recursively
1157 * Remove the file or directory "path", recursively
1158 * removing the contents if its a directory. This is like
1159 * the "rm -rf" shell command.
1161 * @throws LibGuestFSException
1163 public void rm_rf (String path)
1164 throws LibGuestFSException
1167 throw new LibGuestFSException ("rm_rf: handle is closed");
1170 private native void _rm_rf (long g, String path)
1171 throws LibGuestFSException;
1174 * create a directory
1176 * Create a directory named "path".
1178 * @throws LibGuestFSException
1180 public void mkdir (String path)
1181 throws LibGuestFSException
1184 throw new LibGuestFSException ("mkdir: handle is closed");
1187 private native void _mkdir (long g, String path)
1188 throws LibGuestFSException;
1191 * create a directory and parents
1193 * Create a directory named "path", creating any parent
1194 * directories as necessary. This is like the "mkdir -p"
1197 * @throws LibGuestFSException
1199 public void mkdir_p (String path)
1200 throws LibGuestFSException
1203 throw new LibGuestFSException ("mkdir_p: handle is closed");
1206 private native void _mkdir_p (long g, String path)
1207 throws LibGuestFSException;
1212 * Change the mode (permissions) of "path" to "mode". Only
1213 * numeric modes are supported.
1215 * @throws LibGuestFSException
1217 public void chmod (int mode, String path)
1218 throws LibGuestFSException
1221 throw new LibGuestFSException ("chmod: handle is closed");
1222 _chmod (g, mode, path);
1224 private native void _chmod (long g, int mode, String path)
1225 throws LibGuestFSException;
1228 * change file owner and group
1230 * Change the file owner to "owner" and group to "group".
1232 * Only numeric uid and gid are supported. If you want to
1233 * use names, you will need to locate and parse the
1234 * password file yourself (Augeas support makes this
1237 * @throws LibGuestFSException
1239 public void chown (int owner, int group, String path)
1240 throws LibGuestFSException
1243 throw new LibGuestFSException ("chown: handle is closed");
1244 _chown (g, owner, group, path);
1246 private native void _chown (long g, int owner, int group, String path)
1247 throws LibGuestFSException;
1250 * test if file or directory exists
1252 * This returns "true" if and only if there is a file,
1253 * directory (or anything) with the given "path" name.
1255 * See also "g.is_file", "g.is_dir", "g.stat".
1257 * @throws LibGuestFSException
1259 public boolean exists (String path)
1260 throws LibGuestFSException
1263 throw new LibGuestFSException ("exists: handle is closed");
1264 return _exists (g, path);
1266 private native boolean _exists (long g, String path)
1267 throws LibGuestFSException;
1270 * test if file exists
1272 * This returns "true" if and only if there is a file with
1273 * the given "path" name. Note that it returns false for
1274 * other objects like directories.
1276 * See also "g.stat".
1278 * @throws LibGuestFSException
1280 public boolean is_file (String path)
1281 throws LibGuestFSException
1284 throw new LibGuestFSException ("is_file: handle is closed");
1285 return _is_file (g, path);
1287 private native boolean _is_file (long g, String path)
1288 throws LibGuestFSException;
1291 * test if file exists
1293 * This returns "true" if and only if there is a directory
1294 * with the given "path" name. Note that it returns false
1295 * for other objects like files.
1297 * See also "g.stat".
1299 * @throws LibGuestFSException
1301 public boolean is_dir (String path)
1302 throws LibGuestFSException
1305 throw new LibGuestFSException ("is_dir: handle is closed");
1306 return _is_dir (g, path);
1308 private native boolean _is_dir (long g, String path)
1309 throws LibGuestFSException;
1312 * create an LVM physical volume
1314 * This creates an LVM physical volume on the named
1315 * "device", where "device" should usually be a partition
1316 * name such as "/dev/sda1".
1318 * @throws LibGuestFSException
1320 public void pvcreate (String device)
1321 throws LibGuestFSException
1324 throw new LibGuestFSException ("pvcreate: handle is closed");
1325 _pvcreate (g, device);
1327 private native void _pvcreate (long g, String device)
1328 throws LibGuestFSException;
1331 * create an LVM volume group
1333 * This creates an LVM volume group called "volgroup" from
1334 * the non-empty list of physical volumes "physvols".
1336 * @throws LibGuestFSException
1338 public void vgcreate (String volgroup, String[] physvols)
1339 throws LibGuestFSException
1342 throw new LibGuestFSException ("vgcreate: handle is closed");
1343 _vgcreate (g, volgroup, physvols);
1345 private native void _vgcreate (long g, String volgroup, String[] physvols)
1346 throws LibGuestFSException;
1349 * create an LVM volume group
1351 * This creates an LVM volume group called "logvol" on the
1352 * volume group "volgroup", with "size" megabytes.
1354 * @throws LibGuestFSException
1356 public void lvcreate (String logvol, String volgroup, int mbytes)
1357 throws LibGuestFSException
1360 throw new LibGuestFSException ("lvcreate: handle is closed");
1361 _lvcreate (g, logvol, volgroup, mbytes);
1363 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1364 throws LibGuestFSException;
1369 * This creates a filesystem on "device" (usually a
1370 * partition of LVM logical volume). The filesystem type is
1371 * "fstype", for example "ext3".
1373 * @throws LibGuestFSException
1375 public void mkfs (String fstype, String device)
1376 throws LibGuestFSException
1379 throw new LibGuestFSException ("mkfs: handle is closed");
1380 _mkfs (g, fstype, device);
1382 private native void _mkfs (long g, String fstype, String device)
1383 throws LibGuestFSException;
1386 * create partitions on a block device
1388 * This is a direct interface to the sfdisk(8) program for
1389 * creating partitions on block devices.
1391 * "device" should be a block device, for example
1394 * "cyls", "heads" and "sectors" are the number of
1395 * cylinders, heads and sectors on the device, which are
1396 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1397 * parameters. If you pass 0 for any of these, then the
1398 * corresponding parameter is omitted. Usually for 'large'
1399 * disks, you can just pass 0 for these, but for small
1400 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1401 * cannot work out the right geometry and you will need to
1404 * "lines" is a list of lines that we feed to "sfdisk". For
1405 * more information refer to the sfdisk(8) manpage.
1407 * To create a single partition occupying the whole disk,
1408 * you would pass "lines" as a single element list, when
1409 * the single element being the string "," (comma).
1411 * This command is dangerous. Without careful use you can
1412 * easily destroy all your data.
1414 * @throws LibGuestFSException
1416 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1417 throws LibGuestFSException
1420 throw new LibGuestFSException ("sfdisk: handle is closed");
1421 _sfdisk (g, device, cyls, heads, sectors, lines);
1423 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1424 throws LibGuestFSException;
1429 * This call creates a file called "path". The contents of
1430 * the file is the string "content" (which can contain any
1431 * 8 bit data), with length "size".
1433 * As a special case, if "size" is 0 then the length is
1434 * calculated using "strlen" (so in this case the content
1435 * cannot contain embedded ASCII NULs).
1437 * Because of the message protocol, there is a transfer
1438 * limit of somewhere between 2MB and 4MB. To transfer
1439 * large files you should use FTP.
1441 * @throws LibGuestFSException
1443 public void write_file (String path, String content, int size)
1444 throws LibGuestFSException
1447 throw new LibGuestFSException ("write_file: handle is closed");
1448 _write_file (g, path, content, size);
1450 private native void _write_file (long g, String path, String content, int size)
1451 throws LibGuestFSException;
1454 * unmount a filesystem
1456 * This unmounts the given filesystem. The filesystem may
1457 * be specified either by its mountpoint (path) or the
1458 * device which contains the filesystem.
1460 * @throws LibGuestFSException
1462 public void umount (String pathordevice)
1463 throws LibGuestFSException
1466 throw new LibGuestFSException ("umount: handle is closed");
1467 _umount (g, pathordevice);
1469 private native void _umount (long g, String pathordevice)
1470 throws LibGuestFSException;
1473 * show mounted filesystems
1475 * This returns the list of currently mounted filesystems.
1476 * It returns the list of devices (eg. "/dev/sda1",
1479 * Some internal mounts are not shown.
1481 * @throws LibGuestFSException
1483 public String[] mounts ()
1484 throws LibGuestFSException
1487 throw new LibGuestFSException ("mounts: handle is closed");
1490 private native String[] _mounts (long g)
1491 throws LibGuestFSException;
1494 * unmount all filesystems
1496 * This unmounts all mounted filesystems.
1498 * Some internal mounts are not unmounted by this call.
1500 * @throws LibGuestFSException
1502 public void umount_all ()
1503 throws LibGuestFSException
1506 throw new LibGuestFSException ("umount_all: handle is closed");
1509 private native void _umount_all (long g)
1510 throws LibGuestFSException;
1513 * remove all LVM LVs, VGs and PVs
1515 * This command removes all LVM logical volumes, volume
1516 * groups and physical volumes.
1518 * This command is dangerous. Without careful use you can
1519 * easily destroy all your data.
1521 * @throws LibGuestFSException
1523 public void lvm_remove_all ()
1524 throws LibGuestFSException
1527 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1528 _lvm_remove_all (g);
1530 private native void _lvm_remove_all (long g)
1531 throws LibGuestFSException;
1534 * determine file type
1536 * This call uses the standard file(1) command to determine
1537 * the type or contents of the file. This also works on
1538 * devices, for example to find out whether a partition
1539 * contains a filesystem.
1541 * The exact command which runs is "file -bsL path". Note
1542 * in particular that the filename is not prepended to the
1543 * output (the "-b" option).
1545 * @throws LibGuestFSException
1547 public String file (String path)
1548 throws LibGuestFSException
1551 throw new LibGuestFSException ("file: handle is closed");
1552 return _file (g, path);
1554 private native String _file (long g, String path)
1555 throws LibGuestFSException;
1558 * run a command from the guest filesystem
1560 * This call runs a command from the guest filesystem. The
1561 * filesystem must be mounted, and must contain a
1562 * compatible operating system (ie. something Linux, with
1563 * the same or compatible processor architecture).
1565 * The single parameter is an argv-style list of arguments.
1566 * The first element is the name of the program to run.
1567 * Subsequent elements are parameters. The list must be
1568 * non-empty (ie. must contain a program name).
1570 * The $PATH environment variable will contain at least
1571 * "/usr/bin" and "/bin". If you require a program from
1572 * another location, you should provide the full path in
1573 * the first parameter.
1575 * Shared libraries and data files required by the program
1576 * must be available on filesystems which are mounted in
1577 * the correct places. It is the caller's responsibility to
1578 * ensure all filesystems that are needed are mounted at
1579 * the right locations.
1581 * @throws LibGuestFSException
1583 public String command (String[] arguments)
1584 throws LibGuestFSException
1587 throw new LibGuestFSException ("command: handle is closed");
1588 return _command (g, arguments);
1590 private native String _command (long g, String[] arguments)
1591 throws LibGuestFSException;
1594 * run a command, returning lines
1596 * This is the same as "g.command", but splits the result
1597 * into a list of lines.
1599 * @throws LibGuestFSException
1601 public String[] command_lines (String[] arguments)
1602 throws LibGuestFSException
1605 throw new LibGuestFSException ("command_lines: handle is closed");
1606 return _command_lines (g, arguments);
1608 private native String[] _command_lines (long g, String[] arguments)
1609 throws LibGuestFSException;
1612 * get file information
1614 * Returns file information for the given "path".
1616 * This is the same as the stat(2) system call.
1618 * @throws LibGuestFSException
1620 public Stat stat (String path)
1621 throws LibGuestFSException
1624 throw new LibGuestFSException ("stat: handle is closed");
1625 return _stat (g, path);
1627 private native Stat _stat (long g, String path)
1628 throws LibGuestFSException;
1631 * get file information for a symbolic link
1633 * Returns file information for the given "path".
1635 * This is the same as "g.stat" except that if "path" is a
1636 * symbolic link, then the link is stat-ed, not the file it
1639 * This is the same as the lstat(2) system call.
1641 * @throws LibGuestFSException
1643 public Stat lstat (String path)
1644 throws LibGuestFSException
1647 throw new LibGuestFSException ("lstat: handle is closed");
1648 return _lstat (g, path);
1650 private native Stat _lstat (long g, String path)
1651 throws LibGuestFSException;
1654 * get file system statistics
1656 * Returns file system statistics for any mounted file
1657 * system. "path" should be a file or directory in the
1658 * mounted file system (typically it is the mount point
1659 * itself, but it doesn't need to be).
1661 * This is the same as the statvfs(2) system call.
1663 * @throws LibGuestFSException
1665 public StatVFS statvfs (String path)
1666 throws LibGuestFSException
1669 throw new LibGuestFSException ("statvfs: handle is closed");
1670 return _statvfs (g, path);
1672 private native StatVFS _statvfs (long g, String path)
1673 throws LibGuestFSException;
1676 * get ext2/ext3 superblock details
1678 * This returns the contents of the ext2 or ext3 filesystem
1679 * superblock on "device".
1681 * It is the same as running "tune2fs -l device". See
1682 * tune2fs(8) manpage for more details. The list of fields
1683 * returned isn't clearly defined, and depends on both the
1684 * version of "tune2fs" that libguestfs was built against,
1685 * and the filesystem itself.
1687 * @throws LibGuestFSException
1689 public HashMap<String,String> tune2fs_l (String device)
1690 throws LibGuestFSException
1693 throw new LibGuestFSException ("tune2fs_l: handle is closed");
1694 return _tune2fs_l (g, device);
1696 private native HashMap<String,String> _tune2fs_l (long g, String device)
1697 throws LibGuestFSException;
1700 * set block device to read-only
1702 * Sets the block device named "device" to read-only.
1704 * This uses the blockdev(8) command.
1706 * @throws LibGuestFSException
1708 public void blockdev_setro (String device)
1709 throws LibGuestFSException
1712 throw new LibGuestFSException ("blockdev_setro: handle is closed");
1713 _blockdev_setro (g, device);
1715 private native void _blockdev_setro (long g, String device)
1716 throws LibGuestFSException;
1719 * set block device to read-write
1721 * Sets the block device named "device" to read-write.
1723 * This uses the blockdev(8) command.
1725 * @throws LibGuestFSException
1727 public void blockdev_setrw (String device)
1728 throws LibGuestFSException
1731 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1732 _blockdev_setrw (g, device);
1734 private native void _blockdev_setrw (long g, String device)
1735 throws LibGuestFSException;
1738 * is block device set to read-only
1740 * Returns a boolean indicating if the block device is
1741 * read-only (true if read-only, false if not).
1743 * This uses the blockdev(8) command.
1745 * @throws LibGuestFSException
1747 public boolean blockdev_getro (String device)
1748 throws LibGuestFSException
1751 throw new LibGuestFSException ("blockdev_getro: handle is closed");
1752 return _blockdev_getro (g, device);
1754 private native boolean _blockdev_getro (long g, String device)
1755 throws LibGuestFSException;
1758 * get sectorsize of block device
1760 * This returns the size of sectors on a block device.
1761 * Usually 512, but can be larger for modern devices.
1763 * (Note, this is not the size in sectors, use
1764 * "g.blockdev_getsz" for that).
1766 * This uses the blockdev(8) command.
1768 * @throws LibGuestFSException
1770 public int blockdev_getss (String device)
1771 throws LibGuestFSException
1774 throw new LibGuestFSException ("blockdev_getss: handle is closed");
1775 return _blockdev_getss (g, device);
1777 private native int _blockdev_getss (long g, String device)
1778 throws LibGuestFSException;
1781 * get blocksize of block device
1783 * This returns the block size of a device.
1785 * (Note this is different from both *size in blocks* and
1786 * *filesystem block size*).
1788 * This uses the blockdev(8) command.
1790 * @throws LibGuestFSException
1792 public int blockdev_getbsz (String device)
1793 throws LibGuestFSException
1796 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1797 return _blockdev_getbsz (g, device);
1799 private native int _blockdev_getbsz (long g, String device)
1800 throws LibGuestFSException;
1803 * set blocksize of block device
1805 * This sets the block size of a device.
1807 * (Note this is different from both *size in blocks* and
1808 * *filesystem block size*).
1810 * This uses the blockdev(8) command.
1812 * @throws LibGuestFSException
1814 public void blockdev_setbsz (String device, int blocksize)
1815 throws LibGuestFSException
1818 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1819 _blockdev_setbsz (g, device, blocksize);
1821 private native void _blockdev_setbsz (long g, String device, int blocksize)
1822 throws LibGuestFSException;
1825 * get total size of device in 512-byte sectors
1827 * This returns the size of the device in units of 512-byte
1828 * sectors (even if the sectorsize isn't 512 bytes ...
1831 * See also "g.blockdev_getss" for the real sector size of
1832 * the device, and "g.blockdev_getsize64" for the more
1833 * useful *size in bytes*.
1835 * This uses the blockdev(8) command.
1837 * @throws LibGuestFSException
1839 public long blockdev_getsz (String device)
1840 throws LibGuestFSException
1843 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1844 return _blockdev_getsz (g, device);
1846 private native long _blockdev_getsz (long g, String device)
1847 throws LibGuestFSException;
1850 * get total size of device in bytes
1852 * This returns the size of the device in bytes.
1854 * See also "g.blockdev_getsz".
1856 * This uses the blockdev(8) command.
1858 * @throws LibGuestFSException
1860 public long blockdev_getsize64 (String device)
1861 throws LibGuestFSException
1864 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1865 return _blockdev_getsize64 (g, device);
1867 private native long _blockdev_getsize64 (long g, String device)
1868 throws LibGuestFSException;
1871 * flush device buffers
1873 * This tells the kernel to flush internal buffers
1874 * associated with "device".
1876 * This uses the blockdev(8) command.
1878 * @throws LibGuestFSException
1880 public void blockdev_flushbufs (String device)
1881 throws LibGuestFSException
1884 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
1885 _blockdev_flushbufs (g, device);
1887 private native void _blockdev_flushbufs (long g, String device)
1888 throws LibGuestFSException;
1891 * reread partition table
1893 * Reread the partition table on "device".
1895 * This uses the blockdev(8) command.
1897 * @throws LibGuestFSException
1899 public void blockdev_rereadpt (String device)
1900 throws LibGuestFSException
1903 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
1904 _blockdev_rereadpt (g, device);
1906 private native void _blockdev_rereadpt (long g, String device)
1907 throws LibGuestFSException;
1910 * upload a file from the local machine
1912 * Upload local file "filename" to "remotefilename" on the
1915 * "filename" can also be a named pipe.
1917 * See also "g.download".
1919 * @throws LibGuestFSException
1921 public void upload (String filename, String remotefilename)
1922 throws LibGuestFSException
1925 throw new LibGuestFSException ("upload: handle is closed");
1926 _upload (g, filename, remotefilename);
1928 private native void _upload (long g, String filename, String remotefilename)
1929 throws LibGuestFSException;
1932 * download a file to the local machine
1934 * Download file "remotefilename" and save it as "filename"
1935 * on the local machine.
1937 * "filename" can also be a named pipe.
1939 * See also "g.upload", "g.cat".
1941 * @throws LibGuestFSException
1943 public void download (String remotefilename, String filename)
1944 throws LibGuestFSException
1947 throw new LibGuestFSException ("download: handle is closed");
1948 _download (g, remotefilename, filename);
1950 private native void _download (long g, String remotefilename, String filename)
1951 throws LibGuestFSException;
1954 * compute MD5, SHAx or CRC checksum of file
1956 * This call computes the MD5, SHAx or CRC checksum of the
1957 * file named "path".
1959 * The type of checksum to compute is given by the
1960 * "csumtype" parameter which must have one of the
1964 * Compute the cyclic redundancy check (CRC) specified
1965 * by POSIX for the "cksum" command.
1968 * Compute the MD5 hash (using the "md5sum" program).
1971 * Compute the SHA1 hash (using the "sha1sum" program).
1974 * Compute the SHA224 hash (using the "sha224sum"
1978 * Compute the SHA256 hash (using the "sha256sum"
1982 * Compute the SHA384 hash (using the "sha384sum"
1986 * Compute the SHA512 hash (using the "sha512sum"
1989 * The checksum is returned as a printable string.
1991 * @throws LibGuestFSException
1993 public String checksum (String csumtype, String path)
1994 throws LibGuestFSException
1997 throw new LibGuestFSException ("checksum: handle is closed");
1998 return _checksum (g, csumtype, path);
2000 private native String _checksum (long g, String csumtype, String path)
2001 throws LibGuestFSException;
2004 * unpack tarfile to directory
2006 * This command uploads and unpacks local file "tarfile"
2007 * (an *uncompressed* tar file) into "directory".
2009 * To upload a compressed tarball, use "g.tgz_in".
2011 * @throws LibGuestFSException
2013 public void tar_in (String tarfile, String directory)
2014 throws LibGuestFSException
2017 throw new LibGuestFSException ("tar_in: handle is closed");
2018 _tar_in (g, tarfile, directory);
2020 private native void _tar_in (long g, String tarfile, String directory)
2021 throws LibGuestFSException;
2024 * pack directory into tarfile
2026 * This command packs the contents of "directory" and
2027 * downloads it to local file "tarfile".
2029 * To download a compressed tarball, use "g.tgz_out".
2031 * @throws LibGuestFSException
2033 public void tar_out (String directory, String tarfile)
2034 throws LibGuestFSException
2037 throw new LibGuestFSException ("tar_out: handle is closed");
2038 _tar_out (g, directory, tarfile);
2040 private native void _tar_out (long g, String directory, String tarfile)
2041 throws LibGuestFSException;
2044 * unpack compressed tarball to directory
2046 * This command uploads and unpacks local file "tarball" (a
2047 * *gzip compressed* tar file) into "directory".
2049 * To upload an uncompressed tarball, use "g.tar_in".
2051 * @throws LibGuestFSException
2053 public void tgz_in (String tarball, String directory)
2054 throws LibGuestFSException
2057 throw new LibGuestFSException ("tgz_in: handle is closed");
2058 _tgz_in (g, tarball, directory);
2060 private native void _tgz_in (long g, String tarball, String directory)
2061 throws LibGuestFSException;
2064 * pack directory into compressed tarball
2066 * This command packs the contents of "directory" and
2067 * downloads it to local file "tarball".
2069 * To download an uncompressed tarball, use "g.tar_out".
2071 * @throws LibGuestFSException
2073 public void tgz_out (String directory, String tarball)
2074 throws LibGuestFSException
2077 throw new LibGuestFSException ("tgz_out: handle is closed");
2078 _tgz_out (g, directory, tarball);
2080 private native void _tgz_out (long g, String directory, String tarball)
2081 throws LibGuestFSException;