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 * Setting "qemu" to "NULL" restores the default qemu
235 * @throws LibGuestFSException
237 public void set_qemu (String qemu)
238 throws LibGuestFSException
241 throw new LibGuestFSException ("set_qemu: handle is closed");
244 private native void _set_qemu (long g, String qemu)
245 throws LibGuestFSException;
248 * get the qemu binary
250 * Return the current qemu binary.
252 * This is always non-NULL. If it wasn't set already, then
253 * this will return the default qemu binary name.
255 * @throws LibGuestFSException
257 public String get_qemu ()
258 throws LibGuestFSException
261 throw new LibGuestFSException ("get_qemu: handle is closed");
262 return _get_qemu (g);
264 private native String _get_qemu (long g)
265 throws LibGuestFSException;
268 * set the search path
270 * Set the path that libguestfs searches for kernel and
273 * The default is "$libdir/guestfs" unless overridden by
274 * setting "LIBGUESTFS_PATH" environment variable.
276 * Setting "path" to "NULL" restores the default path.
278 * @throws LibGuestFSException
280 public void set_path (String path)
281 throws LibGuestFSException
284 throw new LibGuestFSException ("set_path: handle is closed");
287 private native void _set_path (long g, String path)
288 throws LibGuestFSException;
291 * get the search path
293 * Return the current search path.
295 * This is always non-NULL. If it wasn't set already, then
296 * this will return the default path.
298 * @throws LibGuestFSException
300 public String get_path ()
301 throws LibGuestFSException
304 throw new LibGuestFSException ("get_path: handle is closed");
305 return _get_path (g);
307 private native String _get_path (long g)
308 throws LibGuestFSException;
311 * add options to kernel command line
313 * This function is used to add additional options to the
314 * guest kernel command line.
316 * The default is "NULL" unless overridden by setting
317 * "LIBGUESTFS_APPEND" environment variable.
319 * Setting "append" to "NULL" means *no* additional options
320 * are passed (libguestfs always adds a few of its own).
322 * @throws LibGuestFSException
324 public void set_append (String append)
325 throws LibGuestFSException
328 throw new LibGuestFSException ("set_append: handle is closed");
329 _set_append (g, append);
331 private native void _set_append (long g, String append)
332 throws LibGuestFSException;
335 * get the additional kernel options
337 * Return the additional kernel options which are added to
338 * the guest kernel command line.
340 * If "NULL" then no options are added.
342 * @throws LibGuestFSException
344 public String get_append ()
345 throws LibGuestFSException
348 throw new LibGuestFSException ("get_append: handle is closed");
349 return _get_append (g);
351 private native String _get_append (long g)
352 throws LibGuestFSException;
357 * If "autosync" is true, this enables autosync. Libguestfs
358 * will make a best effort attempt to run "g.umount_all"
359 * followed by "g.sync" when the handle is closed (also if
360 * the program exits without closing handles).
362 * This is disabled by default (except in guestfish where
363 * it is enabled by default).
365 * @throws LibGuestFSException
367 public void set_autosync (boolean autosync)
368 throws LibGuestFSException
371 throw new LibGuestFSException ("set_autosync: handle is closed");
372 _set_autosync (g, autosync);
374 private native void _set_autosync (long g, boolean autosync)
375 throws LibGuestFSException;
380 * Get the autosync flag.
382 * @throws LibGuestFSException
384 public boolean get_autosync ()
385 throws LibGuestFSException
388 throw new LibGuestFSException ("get_autosync: handle is closed");
389 return _get_autosync (g);
391 private native boolean _get_autosync (long g)
392 throws LibGuestFSException;
397 * If "verbose" is true, this turns on verbose messages (to
400 * Verbose messages are disabled unless the environment
401 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
403 * @throws LibGuestFSException
405 public void set_verbose (boolean verbose)
406 throws LibGuestFSException
409 throw new LibGuestFSException ("set_verbose: handle is closed");
410 _set_verbose (g, verbose);
412 private native void _set_verbose (long g, boolean verbose)
413 throws LibGuestFSException;
418 * This returns the verbose messages flag.
420 * @throws LibGuestFSException
422 public boolean get_verbose ()
423 throws LibGuestFSException
426 throw new LibGuestFSException ("get_verbose: handle is closed");
427 return _get_verbose (g);
429 private native boolean _get_verbose (long g)
430 throws LibGuestFSException;
433 * is ready to accept commands
435 * This returns true iff this handle is ready to accept
436 * commands (in the "READY" state).
438 * For more information on states, see guestfs(3).
440 * @throws LibGuestFSException
442 public boolean is_ready ()
443 throws LibGuestFSException
446 throw new LibGuestFSException ("is_ready: handle is closed");
447 return _is_ready (g);
449 private native boolean _is_ready (long g)
450 throws LibGuestFSException;
453 * is in configuration state
455 * This returns true iff this handle is being configured
456 * (in the "CONFIG" state).
458 * For more information on states, see guestfs(3).
460 * @throws LibGuestFSException
462 public boolean is_config ()
463 throws LibGuestFSException
466 throw new LibGuestFSException ("is_config: handle is closed");
467 return _is_config (g);
469 private native boolean _is_config (long g)
470 throws LibGuestFSException;
473 * is launching subprocess
475 * This returns true iff this handle is launching the
476 * subprocess (in the "LAUNCHING" state).
478 * For more information on states, see guestfs(3).
480 * @throws LibGuestFSException
482 public boolean is_launching ()
483 throws LibGuestFSException
486 throw new LibGuestFSException ("is_launching: handle is closed");
487 return _is_launching (g);
489 private native boolean _is_launching (long g)
490 throws LibGuestFSException;
493 * is busy processing a command
495 * This returns true iff this handle is busy processing a
496 * command (in the "BUSY" state).
498 * For more information on states, see guestfs(3).
500 * @throws LibGuestFSException
502 public boolean is_busy ()
503 throws LibGuestFSException
506 throw new LibGuestFSException ("is_busy: handle is closed");
509 private native boolean _is_busy (long g)
510 throws LibGuestFSException;
513 * get the current state
515 * This returns the current state as an opaque integer.
516 * This is only useful for printing debug and internal
519 * For more information on states, see guestfs(3).
521 * @throws LibGuestFSException
523 public int get_state ()
524 throws LibGuestFSException
527 throw new LibGuestFSException ("get_state: handle is closed");
528 return _get_state (g);
530 private native int _get_state (long g)
531 throws LibGuestFSException;
536 * This sets the state to "BUSY". This is only used when
537 * implementing actions using the low-level API.
539 * For more information on states, see guestfs(3).
541 * @throws LibGuestFSException
543 public void set_busy ()
544 throws LibGuestFSException
547 throw new LibGuestFSException ("set_busy: handle is closed");
550 private native void _set_busy (long g)
551 throws LibGuestFSException;
556 * This sets the state to "READY". This is only used when
557 * implementing actions using the low-level API.
559 * For more information on states, see guestfs(3).
561 * @throws LibGuestFSException
563 public void set_ready ()
564 throws LibGuestFSException
567 throw new LibGuestFSException ("set_ready: handle is closed");
570 private native void _set_ready (long g)
571 throws LibGuestFSException;
574 * leave the busy state
576 * This sets the state to "READY", or if in "CONFIG" then
577 * it leaves the state as is. This is only used when
578 * implementing actions using the low-level API.
580 * For more information on states, see guestfs(3).
582 * @throws LibGuestFSException
584 public void end_busy ()
585 throws LibGuestFSException
588 throw new LibGuestFSException ("end_busy: handle is closed");
591 private native void _end_busy (long g)
592 throws LibGuestFSException;
595 * mount a guest disk at a position in the filesystem
597 * Mount a guest disk at a position in the filesystem.
598 * Block devices are named "/dev/sda", "/dev/sdb" and so
599 * on, as they were added to the guest. If those block
600 * devices contain partitions, they will have the usual
601 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
604 * The rules are the same as for mount(2): A filesystem
605 * must first be mounted on "/" before others can be
606 * mounted. Other filesystems can only be mounted on
607 * directories which already exist.
609 * The mounted filesystem is writable, if we have
610 * sufficient permissions on the underlying device.
612 * The filesystem options "sync" and "noatime" are set with
613 * this call, in order to improve reliability.
615 * @throws LibGuestFSException
617 public void mount (String device, String mountpoint)
618 throws LibGuestFSException
621 throw new LibGuestFSException ("mount: handle is closed");
622 _mount (g, device, mountpoint);
624 private native void _mount (long g, String device, String mountpoint)
625 throws LibGuestFSException;
628 * sync disks, writes are flushed through to the disk image
630 * This syncs the disk, so that any writes are flushed
631 * through to the underlying disk image.
633 * You should always call this if you have modified a disk
634 * image, before closing the handle.
636 * @throws LibGuestFSException
639 throws LibGuestFSException
642 throw new LibGuestFSException ("sync: handle is closed");
645 private native void _sync (long g)
646 throws LibGuestFSException;
649 * update file timestamps or create a new file
651 * Touch acts like the touch(1) command. It can be used to
652 * update the timestamps on a file, or, if the file does
653 * not exist, to create a new zero-length file.
655 * @throws LibGuestFSException
657 public void touch (String path)
658 throws LibGuestFSException
661 throw new LibGuestFSException ("touch: handle is closed");
664 private native void _touch (long g, String path)
665 throws LibGuestFSException;
668 * list the contents of a file
670 * Return the contents of the file named "path".
672 * Note that this function cannot correctly handle binary
673 * files (specifically, files containing "\0" character
674 * which is treated as end of string). For those you need
675 * to use the "g.download" function which has a more
678 * Because of the message protocol, there is a transfer
679 * limit of somewhere between 2MB and 4MB. To transfer
680 * large files you should use FTP.
682 * @throws LibGuestFSException
684 public String cat (String path)
685 throws LibGuestFSException
688 throw new LibGuestFSException ("cat: handle is closed");
689 return _cat (g, path);
691 private native String _cat (long g, String path)
692 throws LibGuestFSException;
695 * list the files in a directory (long format)
697 * List the files in "directory" (relative to the root
698 * directory, there is no cwd) in the format of 'ls -la'.
700 * This command is mostly useful for interactive sessions.
701 * It is *not* intended that you try to parse the output
704 * @throws LibGuestFSException
706 public String ll (String directory)
707 throws LibGuestFSException
710 throw new LibGuestFSException ("ll: handle is closed");
711 return _ll (g, directory);
713 private native String _ll (long g, String directory)
714 throws LibGuestFSException;
717 * list the files in a directory
719 * List the files in "directory" (relative to the root
720 * directory, there is no cwd). The '.' and '..' entries
721 * are not returned, but hidden files are shown.
723 * This command is mostly useful for interactive sessions.
724 * Programs should probably use "g.readdir" instead.
726 * @throws LibGuestFSException
728 public String[] ls (String directory)
729 throws LibGuestFSException
732 throw new LibGuestFSException ("ls: handle is closed");
733 return _ls (g, directory);
735 private native String[] _ls (long g, String directory)
736 throws LibGuestFSException;
739 * list the block devices
741 * List all the block devices.
743 * The full block device names are returned, eg. "/dev/sda"
745 * @throws LibGuestFSException
747 public String[] list_devices ()
748 throws LibGuestFSException
751 throw new LibGuestFSException ("list_devices: handle is closed");
752 return _list_devices (g);
754 private native String[] _list_devices (long g)
755 throws LibGuestFSException;
758 * list the partitions
760 * List all the partitions detected on all block devices.
762 * The full partition device names are returned, eg.
765 * This does not return logical volumes. For that you will
766 * need to call "g.lvs".
768 * @throws LibGuestFSException
770 public String[] list_partitions ()
771 throws LibGuestFSException
774 throw new LibGuestFSException ("list_partitions: handle is closed");
775 return _list_partitions (g);
777 private native String[] _list_partitions (long g)
778 throws LibGuestFSException;
781 * list the LVM physical volumes (PVs)
783 * List all the physical volumes detected. This is the
784 * equivalent of the pvs(8) command.
786 * This returns a list of just the device names that
787 * contain PVs (eg. "/dev/sda2").
789 * See also "g.pvs_full".
791 * @throws LibGuestFSException
793 public String[] pvs ()
794 throws LibGuestFSException
797 throw new LibGuestFSException ("pvs: handle is closed");
800 private native String[] _pvs (long g)
801 throws LibGuestFSException;
804 * list the LVM volume groups (VGs)
806 * List all the volumes groups detected. This is the
807 * equivalent of the vgs(8) command.
809 * This returns a list of just the volume group names that
810 * were detected (eg. "VolGroup00").
812 * See also "g.vgs_full".
814 * @throws LibGuestFSException
816 public String[] vgs ()
817 throws LibGuestFSException
820 throw new LibGuestFSException ("vgs: handle is closed");
823 private native String[] _vgs (long g)
824 throws LibGuestFSException;
827 * list the LVM logical volumes (LVs)
829 * List all the logical volumes detected. This is the
830 * equivalent of the lvs(8) command.
832 * This returns a list of the logical volume device names
833 * (eg. "/dev/VolGroup00/LogVol00").
835 * See also "g.lvs_full".
837 * @throws LibGuestFSException
839 public String[] lvs ()
840 throws LibGuestFSException
843 throw new LibGuestFSException ("lvs: handle is closed");
846 private native String[] _lvs (long g)
847 throws LibGuestFSException;
850 * list the LVM physical volumes (PVs)
852 * List all the physical volumes detected. This is the
853 * equivalent of the pvs(8) command. The "full" version
854 * includes all fields.
856 * @throws LibGuestFSException
858 public PV[] pvs_full ()
859 throws LibGuestFSException
862 throw new LibGuestFSException ("pvs_full: handle is closed");
863 return _pvs_full (g);
865 private native PV[] _pvs_full (long g)
866 throws LibGuestFSException;
869 * list the LVM volume groups (VGs)
871 * List all the volumes groups detected. This is the
872 * equivalent of the vgs(8) command. The "full" version
873 * includes all fields.
875 * @throws LibGuestFSException
877 public VG[] vgs_full ()
878 throws LibGuestFSException
881 throw new LibGuestFSException ("vgs_full: handle is closed");
882 return _vgs_full (g);
884 private native VG[] _vgs_full (long g)
885 throws LibGuestFSException;
888 * list the LVM logical volumes (LVs)
890 * List all the logical volumes detected. This is the
891 * equivalent of the lvs(8) command. The "full" version
892 * includes all fields.
894 * @throws LibGuestFSException
896 public LV[] lvs_full ()
897 throws LibGuestFSException
900 throw new LibGuestFSException ("lvs_full: handle is closed");
901 return _lvs_full (g);
903 private native LV[] _lvs_full (long g)
904 throws LibGuestFSException;
909 * Return the contents of the file named "path".
911 * The file contents are returned as a list of lines.
912 * Trailing "LF" and "CRLF" character sequences are *not*
915 * Note that this function cannot correctly handle binary
916 * files (specifically, files containing "\0" character
917 * which is treated as end of line). For those you need to
918 * use the "g.read_file" function which has a more complex
921 * @throws LibGuestFSException
923 public String[] read_lines (String path)
924 throws LibGuestFSException
927 throw new LibGuestFSException ("read_lines: handle is closed");
928 return _read_lines (g, path);
930 private native String[] _read_lines (long g, String path)
931 throws LibGuestFSException;
934 * create a new Augeas handle
936 * Create a new Augeas handle for editing configuration
937 * files. If there was any previous Augeas handle
938 * associated with this guestfs session, then it is closed.
940 * You must call this before using any other "g.aug_*"
943 * "root" is the filesystem root. "root" must not be NULL,
946 * The flags are the same as the flags defined in
947 * <augeas.h>, the logical *or* of the following integers:
949 * "AUG_SAVE_BACKUP" = 1
950 * Keep the original file with a ".augsave" extension.
952 * "AUG_SAVE_NEWFILE" = 2
953 * Save changes into a file with extension ".augnew",
954 * and do not overwrite original. Overrides
957 * "AUG_TYPE_CHECK" = 4
958 * Typecheck lenses (can be expensive).
960 * "AUG_NO_STDINC" = 8
961 * Do not use standard load path for modules.
963 * "AUG_SAVE_NOOP" = 16
964 * Make save a no-op, just record what would have been
968 * Do not load the tree in "g.aug_init".
970 * To close the handle, you can call "g.aug_close".
972 * To find out more about Augeas, see <http://augeas.net/>.
974 * @throws LibGuestFSException
976 public void aug_init (String root, int flags)
977 throws LibGuestFSException
980 throw new LibGuestFSException ("aug_init: handle is closed");
981 _aug_init (g, root, flags);
983 private native void _aug_init (long g, String root, int flags)
984 throws LibGuestFSException;
987 * close the current Augeas handle
989 * Close the current Augeas handle and free up any
990 * resources used by it. After calling this, you have to
991 * call "g.aug_init" again before you can use any other
994 * @throws LibGuestFSException
996 public void aug_close ()
997 throws LibGuestFSException
1000 throw new LibGuestFSException ("aug_close: handle is closed");
1003 private native void _aug_close (long g)
1004 throws LibGuestFSException;
1007 * define an Augeas variable
1009 * Defines an Augeas variable "name" whose value is the
1010 * result of evaluating "expr". If "expr" is NULL, then
1011 * "name" is undefined.
1013 * On success this returns the number of nodes in "expr",
1014 * or 0 if "expr" evaluates to something which is not a
1017 * @throws LibGuestFSException
1019 public int aug_defvar (String name, String expr)
1020 throws LibGuestFSException
1023 throw new LibGuestFSException ("aug_defvar: handle is closed");
1024 return _aug_defvar (g, name, expr);
1026 private native int _aug_defvar (long g, String name, String expr)
1027 throws LibGuestFSException;
1030 * define an Augeas node
1032 * Defines a variable "name" whose value is the result of
1033 * evaluating "expr".
1035 * If "expr" evaluates to an empty nodeset, a node is
1036 * created, equivalent to calling "g.aug_set" "expr",
1037 * "value". "name" will be the nodeset containing that
1040 * On success this returns a pair containing the number of
1041 * nodes in the nodeset, and a boolean flag if a node was
1044 * @throws LibGuestFSException
1046 public IntBool aug_defnode (String name, String expr, String val)
1047 throws LibGuestFSException
1050 throw new LibGuestFSException ("aug_defnode: handle is closed");
1051 return _aug_defnode (g, name, expr, val);
1053 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1054 throws LibGuestFSException;
1057 * look up the value of an Augeas path
1059 * Look up the value associated with "path". If "path"
1060 * matches exactly one node, the "value" is returned.
1062 * @throws LibGuestFSException
1064 public String aug_get (String path)
1065 throws LibGuestFSException
1068 throw new LibGuestFSException ("aug_get: handle is closed");
1069 return _aug_get (g, path);
1071 private native String _aug_get (long g, String path)
1072 throws LibGuestFSException;
1075 * set Augeas path to value
1077 * Set the value associated with "path" to "value".
1079 * @throws LibGuestFSException
1081 public void aug_set (String path, String val)
1082 throws LibGuestFSException
1085 throw new LibGuestFSException ("aug_set: handle is closed");
1086 _aug_set (g, path, val);
1088 private native void _aug_set (long g, String path, String val)
1089 throws LibGuestFSException;
1092 * insert a sibling Augeas node
1094 * Create a new sibling "label" for "path", inserting it
1095 * into the tree before or after "path" (depending on the
1096 * boolean flag "before").
1098 * "path" must match exactly one existing node in the tree,
1099 * and "label" must be a label, ie. not contain "/", "*" or
1100 * end with a bracketed index "[N]".
1102 * @throws LibGuestFSException
1104 public void aug_insert (String path, String label, boolean before)
1105 throws LibGuestFSException
1108 throw new LibGuestFSException ("aug_insert: handle is closed");
1109 _aug_insert (g, path, label, before);
1111 private native void _aug_insert (long g, String path, String label, boolean before)
1112 throws LibGuestFSException;
1115 * remove an Augeas path
1117 * Remove "path" and all of its children.
1119 * On success this returns the number of entries which were
1122 * @throws LibGuestFSException
1124 public int aug_rm (String path)
1125 throws LibGuestFSException
1128 throw new LibGuestFSException ("aug_rm: handle is closed");
1129 return _aug_rm (g, path);
1131 private native int _aug_rm (long g, String path)
1132 throws LibGuestFSException;
1137 * Move the node "src" to "dest". "src" must match exactly
1138 * one node. "dest" is overwritten if it exists.
1140 * @throws LibGuestFSException
1142 public void aug_mv (String src, String dest)
1143 throws LibGuestFSException
1146 throw new LibGuestFSException ("aug_mv: handle is closed");
1147 _aug_mv (g, src, dest);
1149 private native void _aug_mv (long g, String src, String dest)
1150 throws LibGuestFSException;
1153 * return Augeas nodes which match path
1155 * Returns a list of paths which match the path expression
1156 * "path". The returned paths are sufficiently qualified so
1157 * that they match exactly one node in the current tree.
1159 * @throws LibGuestFSException
1161 public String[] aug_match (String path)
1162 throws LibGuestFSException
1165 throw new LibGuestFSException ("aug_match: handle is closed");
1166 return _aug_match (g, path);
1168 private native String[] _aug_match (long g, String path)
1169 throws LibGuestFSException;
1172 * write all pending Augeas changes to disk
1174 * This writes all pending changes to disk.
1176 * The flags which were passed to "g.aug_init" affect
1177 * exactly how files are saved.
1179 * @throws LibGuestFSException
1181 public void aug_save ()
1182 throws LibGuestFSException
1185 throw new LibGuestFSException ("aug_save: handle is closed");
1188 private native void _aug_save (long g)
1189 throws LibGuestFSException;
1192 * load files into the tree
1194 * Load files into the tree.
1196 * See "aug_load" in the Augeas documentation for the full
1199 * @throws LibGuestFSException
1201 public void aug_load ()
1202 throws LibGuestFSException
1205 throw new LibGuestFSException ("aug_load: handle is closed");
1208 private native void _aug_load (long g)
1209 throws LibGuestFSException;
1212 * list Augeas nodes under a path
1214 * This is just a shortcut for listing "g.aug_match"
1215 * "path/*" and sorting the resulting nodes into
1216 * alphabetical order.
1218 * @throws LibGuestFSException
1220 public String[] aug_ls (String path)
1221 throws LibGuestFSException
1224 throw new LibGuestFSException ("aug_ls: handle is closed");
1225 return _aug_ls (g, path);
1227 private native String[] _aug_ls (long g, String path)
1228 throws LibGuestFSException;
1233 * Remove the single file "path".
1235 * @throws LibGuestFSException
1237 public void rm (String path)
1238 throws LibGuestFSException
1241 throw new LibGuestFSException ("rm: handle is closed");
1244 private native void _rm (long g, String path)
1245 throws LibGuestFSException;
1248 * remove a directory
1250 * Remove the single directory "path".
1252 * @throws LibGuestFSException
1254 public void rmdir (String path)
1255 throws LibGuestFSException
1258 throw new LibGuestFSException ("rmdir: handle is closed");
1261 private native void _rmdir (long g, String path)
1262 throws LibGuestFSException;
1265 * remove a file or directory recursively
1267 * Remove the file or directory "path", recursively
1268 * removing the contents if its a directory. This is like
1269 * the "rm -rf" shell command.
1271 * @throws LibGuestFSException
1273 public void rm_rf (String path)
1274 throws LibGuestFSException
1277 throw new LibGuestFSException ("rm_rf: handle is closed");
1280 private native void _rm_rf (long g, String path)
1281 throws LibGuestFSException;
1284 * create a directory
1286 * Create a directory named "path".
1288 * @throws LibGuestFSException
1290 public void mkdir (String path)
1291 throws LibGuestFSException
1294 throw new LibGuestFSException ("mkdir: handle is closed");
1297 private native void _mkdir (long g, String path)
1298 throws LibGuestFSException;
1301 * create a directory and parents
1303 * Create a directory named "path", creating any parent
1304 * directories as necessary. This is like the "mkdir -p"
1307 * @throws LibGuestFSException
1309 public void mkdir_p (String path)
1310 throws LibGuestFSException
1313 throw new LibGuestFSException ("mkdir_p: handle is closed");
1316 private native void _mkdir_p (long g, String path)
1317 throws LibGuestFSException;
1322 * Change the mode (permissions) of "path" to "mode". Only
1323 * numeric modes are supported.
1325 * @throws LibGuestFSException
1327 public void chmod (int mode, String path)
1328 throws LibGuestFSException
1331 throw new LibGuestFSException ("chmod: handle is closed");
1332 _chmod (g, mode, path);
1334 private native void _chmod (long g, int mode, String path)
1335 throws LibGuestFSException;
1338 * change file owner and group
1340 * Change the file owner to "owner" and group to "group".
1342 * Only numeric uid and gid are supported. If you want to
1343 * use names, you will need to locate and parse the
1344 * password file yourself (Augeas support makes this
1347 * @throws LibGuestFSException
1349 public void chown (int owner, int group, String path)
1350 throws LibGuestFSException
1353 throw new LibGuestFSException ("chown: handle is closed");
1354 _chown (g, owner, group, path);
1356 private native void _chown (long g, int owner, int group, String path)
1357 throws LibGuestFSException;
1360 * test if file or directory exists
1362 * This returns "true" if and only if there is a file,
1363 * directory (or anything) with the given "path" name.
1365 * See also "g.is_file", "g.is_dir", "g.stat".
1367 * @throws LibGuestFSException
1369 public boolean exists (String path)
1370 throws LibGuestFSException
1373 throw new LibGuestFSException ("exists: handle is closed");
1374 return _exists (g, path);
1376 private native boolean _exists (long g, String path)
1377 throws LibGuestFSException;
1380 * test if file exists
1382 * This returns "true" if and only if there is a file with
1383 * the given "path" name. Note that it returns false for
1384 * other objects like directories.
1386 * See also "g.stat".
1388 * @throws LibGuestFSException
1390 public boolean is_file (String path)
1391 throws LibGuestFSException
1394 throw new LibGuestFSException ("is_file: handle is closed");
1395 return _is_file (g, path);
1397 private native boolean _is_file (long g, String path)
1398 throws LibGuestFSException;
1401 * test if file exists
1403 * This returns "true" if and only if there is a directory
1404 * with the given "path" name. Note that it returns false
1405 * for other objects like files.
1407 * See also "g.stat".
1409 * @throws LibGuestFSException
1411 public boolean is_dir (String path)
1412 throws LibGuestFSException
1415 throw new LibGuestFSException ("is_dir: handle is closed");
1416 return _is_dir (g, path);
1418 private native boolean _is_dir (long g, String path)
1419 throws LibGuestFSException;
1422 * create an LVM physical volume
1424 * This creates an LVM physical volume on the named
1425 * "device", where "device" should usually be a partition
1426 * name such as "/dev/sda1".
1428 * @throws LibGuestFSException
1430 public void pvcreate (String device)
1431 throws LibGuestFSException
1434 throw new LibGuestFSException ("pvcreate: handle is closed");
1435 _pvcreate (g, device);
1437 private native void _pvcreate (long g, String device)
1438 throws LibGuestFSException;
1441 * create an LVM volume group
1443 * This creates an LVM volume group called "volgroup" from
1444 * the non-empty list of physical volumes "physvols".
1446 * @throws LibGuestFSException
1448 public void vgcreate (String volgroup, String[] physvols)
1449 throws LibGuestFSException
1452 throw new LibGuestFSException ("vgcreate: handle is closed");
1453 _vgcreate (g, volgroup, physvols);
1455 private native void _vgcreate (long g, String volgroup, String[] physvols)
1456 throws LibGuestFSException;
1459 * create an LVM volume group
1461 * This creates an LVM volume group called "logvol" on the
1462 * volume group "volgroup", with "size" megabytes.
1464 * @throws LibGuestFSException
1466 public void lvcreate (String logvol, String volgroup, int mbytes)
1467 throws LibGuestFSException
1470 throw new LibGuestFSException ("lvcreate: handle is closed");
1471 _lvcreate (g, logvol, volgroup, mbytes);
1473 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1474 throws LibGuestFSException;
1479 * This creates a filesystem on "device" (usually a
1480 * partition or LVM logical volume). The filesystem type is
1481 * "fstype", for example "ext3".
1483 * @throws LibGuestFSException
1485 public void mkfs (String fstype, String device)
1486 throws LibGuestFSException
1489 throw new LibGuestFSException ("mkfs: handle is closed");
1490 _mkfs (g, fstype, device);
1492 private native void _mkfs (long g, String fstype, String device)
1493 throws LibGuestFSException;
1496 * create partitions on a block device
1498 * This is a direct interface to the sfdisk(8) program for
1499 * creating partitions on block devices.
1501 * "device" should be a block device, for example
1504 * "cyls", "heads" and "sectors" are the number of
1505 * cylinders, heads and sectors on the device, which are
1506 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1507 * parameters. If you pass 0 for any of these, then the
1508 * corresponding parameter is omitted. Usually for 'large'
1509 * disks, you can just pass 0 for these, but for small
1510 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1511 * cannot work out the right geometry and you will need to
1514 * "lines" is a list of lines that we feed to "sfdisk". For
1515 * more information refer to the sfdisk(8) manpage.
1517 * To create a single partition occupying the whole disk,
1518 * you would pass "lines" as a single element list, when
1519 * the single element being the string "," (comma).
1521 * This command is dangerous. Without careful use you can
1522 * easily destroy all your data.
1524 * @throws LibGuestFSException
1526 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1527 throws LibGuestFSException
1530 throw new LibGuestFSException ("sfdisk: handle is closed");
1531 _sfdisk (g, device, cyls, heads, sectors, lines);
1533 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1534 throws LibGuestFSException;
1539 * This call creates a file called "path". The contents of
1540 * the file is the string "content" (which can contain any
1541 * 8 bit data), with length "size".
1543 * As a special case, if "size" is 0 then the length is
1544 * calculated using "strlen" (so in this case the content
1545 * cannot contain embedded ASCII NULs).
1547 * *NB.* Owing to a bug, writing content containing ASCII
1548 * NUL characters does *not* work, even if the length is
1549 * specified. We hope to resolve this bug in a future
1550 * version. In the meantime use "g.upload".
1552 * Because of the message protocol, there is a transfer
1553 * limit of somewhere between 2MB and 4MB. To transfer
1554 * large files you should use FTP.
1556 * @throws LibGuestFSException
1558 public void write_file (String path, String content, int size)
1559 throws LibGuestFSException
1562 throw new LibGuestFSException ("write_file: handle is closed");
1563 _write_file (g, path, content, size);
1565 private native void _write_file (long g, String path, String content, int size)
1566 throws LibGuestFSException;
1569 * unmount a filesystem
1571 * This unmounts the given filesystem. The filesystem may
1572 * be specified either by its mountpoint (path) or the
1573 * device which contains the filesystem.
1575 * @throws LibGuestFSException
1577 public void umount (String pathordevice)
1578 throws LibGuestFSException
1581 throw new LibGuestFSException ("umount: handle is closed");
1582 _umount (g, pathordevice);
1584 private native void _umount (long g, String pathordevice)
1585 throws LibGuestFSException;
1588 * show mounted filesystems
1590 * This returns the list of currently mounted filesystems.
1591 * It returns the list of devices (eg. "/dev/sda1",
1594 * Some internal mounts are not shown.
1596 * @throws LibGuestFSException
1598 public String[] mounts ()
1599 throws LibGuestFSException
1602 throw new LibGuestFSException ("mounts: handle is closed");
1605 private native String[] _mounts (long g)
1606 throws LibGuestFSException;
1609 * unmount all filesystems
1611 * This unmounts all mounted filesystems.
1613 * Some internal mounts are not unmounted by this call.
1615 * @throws LibGuestFSException
1617 public void umount_all ()
1618 throws LibGuestFSException
1621 throw new LibGuestFSException ("umount_all: handle is closed");
1624 private native void _umount_all (long g)
1625 throws LibGuestFSException;
1628 * remove all LVM LVs, VGs and PVs
1630 * This command removes all LVM logical volumes, volume
1631 * groups and physical volumes.
1633 * This command is dangerous. Without careful use you can
1634 * easily destroy all your data.
1636 * @throws LibGuestFSException
1638 public void lvm_remove_all ()
1639 throws LibGuestFSException
1642 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1643 _lvm_remove_all (g);
1645 private native void _lvm_remove_all (long g)
1646 throws LibGuestFSException;
1649 * determine file type
1651 * This call uses the standard file(1) command to determine
1652 * the type or contents of the file. This also works on
1653 * devices, for example to find out whether a partition
1654 * contains a filesystem.
1656 * The exact command which runs is "file -bsL path". Note
1657 * in particular that the filename is not prepended to the
1658 * output (the "-b" option).
1660 * @throws LibGuestFSException
1662 public String file (String path)
1663 throws LibGuestFSException
1666 throw new LibGuestFSException ("file: handle is closed");
1667 return _file (g, path);
1669 private native String _file (long g, String path)
1670 throws LibGuestFSException;
1673 * run a command from the guest filesystem
1675 * This call runs a command from the guest filesystem. The
1676 * filesystem must be mounted, and must contain a
1677 * compatible operating system (ie. something Linux, with
1678 * the same or compatible processor architecture).
1680 * The single parameter is an argv-style list of arguments.
1681 * The first element is the name of the program to run.
1682 * Subsequent elements are parameters. The list must be
1683 * non-empty (ie. must contain a program name).
1685 * The return value is anything printed to *stdout* by the
1688 * If the command returns a non-zero exit status, then this
1689 * function returns an error message. The error message
1690 * string is the content of *stderr* from the command.
1692 * The $PATH environment variable will contain at least
1693 * "/usr/bin" and "/bin". If you require a program from
1694 * another location, you should provide the full path in
1695 * the first parameter.
1697 * Shared libraries and data files required by the program
1698 * must be available on filesystems which are mounted in
1699 * the correct places. It is the caller's responsibility to
1700 * ensure all filesystems that are needed are mounted at
1701 * the right locations.
1703 * Because of the message protocol, there is a transfer
1704 * limit of somewhere between 2MB and 4MB. To transfer
1705 * large files you should use FTP.
1707 * @throws LibGuestFSException
1709 public String command (String[] arguments)
1710 throws LibGuestFSException
1713 throw new LibGuestFSException ("command: handle is closed");
1714 return _command (g, arguments);
1716 private native String _command (long g, String[] arguments)
1717 throws LibGuestFSException;
1720 * run a command, returning lines
1722 * This is the same as "g.command", but splits the result
1723 * into a list of lines.
1725 * Because of the message protocol, there is a transfer
1726 * limit of somewhere between 2MB and 4MB. To transfer
1727 * large files you should use FTP.
1729 * @throws LibGuestFSException
1731 public String[] command_lines (String[] arguments)
1732 throws LibGuestFSException
1735 throw new LibGuestFSException ("command_lines: handle is closed");
1736 return _command_lines (g, arguments);
1738 private native String[] _command_lines (long g, String[] arguments)
1739 throws LibGuestFSException;
1742 * get file information
1744 * Returns file information for the given "path".
1746 * This is the same as the stat(2) system call.
1748 * @throws LibGuestFSException
1750 public Stat stat (String path)
1751 throws LibGuestFSException
1754 throw new LibGuestFSException ("stat: handle is closed");
1755 return _stat (g, path);
1757 private native Stat _stat (long g, String path)
1758 throws LibGuestFSException;
1761 * get file information for a symbolic link
1763 * Returns file information for the given "path".
1765 * This is the same as "g.stat" except that if "path" is a
1766 * symbolic link, then the link is stat-ed, not the file it
1769 * This is the same as the lstat(2) system call.
1771 * @throws LibGuestFSException
1773 public Stat lstat (String path)
1774 throws LibGuestFSException
1777 throw new LibGuestFSException ("lstat: handle is closed");
1778 return _lstat (g, path);
1780 private native Stat _lstat (long g, String path)
1781 throws LibGuestFSException;
1784 * get file system statistics
1786 * Returns file system statistics for any mounted file
1787 * system. "path" should be a file or directory in the
1788 * mounted file system (typically it is the mount point
1789 * itself, but it doesn't need to be).
1791 * This is the same as the statvfs(2) system call.
1793 * @throws LibGuestFSException
1795 public StatVFS statvfs (String path)
1796 throws LibGuestFSException
1799 throw new LibGuestFSException ("statvfs: handle is closed");
1800 return _statvfs (g, path);
1802 private native StatVFS _statvfs (long g, String path)
1803 throws LibGuestFSException;
1806 * get ext2/ext3/ext4 superblock details
1808 * This returns the contents of the ext2, ext3 or ext4
1809 * filesystem superblock on "device".
1811 * It is the same as running "tune2fs -l device". See
1812 * tune2fs(8) manpage for more details. The list of fields
1813 * returned isn't clearly defined, and depends on both the
1814 * version of "tune2fs" that libguestfs was built against,
1815 * and the filesystem itself.
1817 * @throws LibGuestFSException
1819 public HashMap<String,String> tune2fs_l (String device)
1820 throws LibGuestFSException
1823 throw new LibGuestFSException ("tune2fs_l: handle is closed");
1824 return _tune2fs_l (g, device);
1826 private native HashMap<String,String> _tune2fs_l (long g, String device)
1827 throws LibGuestFSException;
1830 * set block device to read-only
1832 * Sets the block device named "device" to read-only.
1834 * This uses the blockdev(8) command.
1836 * @throws LibGuestFSException
1838 public void blockdev_setro (String device)
1839 throws LibGuestFSException
1842 throw new LibGuestFSException ("blockdev_setro: handle is closed");
1843 _blockdev_setro (g, device);
1845 private native void _blockdev_setro (long g, String device)
1846 throws LibGuestFSException;
1849 * set block device to read-write
1851 * Sets the block device named "device" to read-write.
1853 * This uses the blockdev(8) command.
1855 * @throws LibGuestFSException
1857 public void blockdev_setrw (String device)
1858 throws LibGuestFSException
1861 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1862 _blockdev_setrw (g, device);
1864 private native void _blockdev_setrw (long g, String device)
1865 throws LibGuestFSException;
1868 * is block device set to read-only
1870 * Returns a boolean indicating if the block device is
1871 * read-only (true if read-only, false if not).
1873 * This uses the blockdev(8) command.
1875 * @throws LibGuestFSException
1877 public boolean blockdev_getro (String device)
1878 throws LibGuestFSException
1881 throw new LibGuestFSException ("blockdev_getro: handle is closed");
1882 return _blockdev_getro (g, device);
1884 private native boolean _blockdev_getro (long g, String device)
1885 throws LibGuestFSException;
1888 * get sectorsize of block device
1890 * This returns the size of sectors on a block device.
1891 * Usually 512, but can be larger for modern devices.
1893 * (Note, this is not the size in sectors, use
1894 * "g.blockdev_getsz" for that).
1896 * This uses the blockdev(8) command.
1898 * @throws LibGuestFSException
1900 public int blockdev_getss (String device)
1901 throws LibGuestFSException
1904 throw new LibGuestFSException ("blockdev_getss: handle is closed");
1905 return _blockdev_getss (g, device);
1907 private native int _blockdev_getss (long g, String device)
1908 throws LibGuestFSException;
1911 * get blocksize of block device
1913 * This returns the block size of a device.
1915 * (Note this is different from both *size in blocks* and
1916 * *filesystem block size*).
1918 * This uses the blockdev(8) command.
1920 * @throws LibGuestFSException
1922 public int blockdev_getbsz (String device)
1923 throws LibGuestFSException
1926 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1927 return _blockdev_getbsz (g, device);
1929 private native int _blockdev_getbsz (long g, String device)
1930 throws LibGuestFSException;
1933 * set blocksize of block device
1935 * This sets the block size of a device.
1937 * (Note this is different from both *size in blocks* and
1938 * *filesystem block size*).
1940 * This uses the blockdev(8) command.
1942 * @throws LibGuestFSException
1944 public void blockdev_setbsz (String device, int blocksize)
1945 throws LibGuestFSException
1948 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1949 _blockdev_setbsz (g, device, blocksize);
1951 private native void _blockdev_setbsz (long g, String device, int blocksize)
1952 throws LibGuestFSException;
1955 * get total size of device in 512-byte sectors
1957 * This returns the size of the device in units of 512-byte
1958 * sectors (even if the sectorsize isn't 512 bytes ...
1961 * See also "g.blockdev_getss" for the real sector size of
1962 * the device, and "g.blockdev_getsize64" for the more
1963 * useful *size in bytes*.
1965 * This uses the blockdev(8) command.
1967 * @throws LibGuestFSException
1969 public long blockdev_getsz (String device)
1970 throws LibGuestFSException
1973 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1974 return _blockdev_getsz (g, device);
1976 private native long _blockdev_getsz (long g, String device)
1977 throws LibGuestFSException;
1980 * get total size of device in bytes
1982 * This returns the size of the device in bytes.
1984 * See also "g.blockdev_getsz".
1986 * This uses the blockdev(8) command.
1988 * @throws LibGuestFSException
1990 public long blockdev_getsize64 (String device)
1991 throws LibGuestFSException
1994 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1995 return _blockdev_getsize64 (g, device);
1997 private native long _blockdev_getsize64 (long g, String device)
1998 throws LibGuestFSException;
2001 * flush device buffers
2003 * This tells the kernel to flush internal buffers
2004 * associated with "device".
2006 * This uses the blockdev(8) command.
2008 * @throws LibGuestFSException
2010 public void blockdev_flushbufs (String device)
2011 throws LibGuestFSException
2014 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2015 _blockdev_flushbufs (g, device);
2017 private native void _blockdev_flushbufs (long g, String device)
2018 throws LibGuestFSException;
2021 * reread partition table
2023 * Reread the partition table on "device".
2025 * This uses the blockdev(8) command.
2027 * @throws LibGuestFSException
2029 public void blockdev_rereadpt (String device)
2030 throws LibGuestFSException
2033 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2034 _blockdev_rereadpt (g, device);
2036 private native void _blockdev_rereadpt (long g, String device)
2037 throws LibGuestFSException;
2040 * upload a file from the local machine
2042 * Upload local file "filename" to "remotefilename" on the
2045 * "filename" can also be a named pipe.
2047 * See also "g.download".
2049 * @throws LibGuestFSException
2051 public void upload (String filename, String remotefilename)
2052 throws LibGuestFSException
2055 throw new LibGuestFSException ("upload: handle is closed");
2056 _upload (g, filename, remotefilename);
2058 private native void _upload (long g, String filename, String remotefilename)
2059 throws LibGuestFSException;
2062 * download a file to the local machine
2064 * Download file "remotefilename" and save it as "filename"
2065 * on the local machine.
2067 * "filename" can also be a named pipe.
2069 * See also "g.upload", "g.cat".
2071 * @throws LibGuestFSException
2073 public void download (String remotefilename, String filename)
2074 throws LibGuestFSException
2077 throw new LibGuestFSException ("download: handle is closed");
2078 _download (g, remotefilename, filename);
2080 private native void _download (long g, String remotefilename, String filename)
2081 throws LibGuestFSException;
2084 * compute MD5, SHAx or CRC checksum of file
2086 * This call computes the MD5, SHAx or CRC checksum of the
2087 * file named "path".
2089 * The type of checksum to compute is given by the
2090 * "csumtype" parameter which must have one of the
2094 * Compute the cyclic redundancy check (CRC) specified
2095 * by POSIX for the "cksum" command.
2098 * Compute the MD5 hash (using the "md5sum" program).
2101 * Compute the SHA1 hash (using the "sha1sum" program).
2104 * Compute the SHA224 hash (using the "sha224sum"
2108 * Compute the SHA256 hash (using the "sha256sum"
2112 * Compute the SHA384 hash (using the "sha384sum"
2116 * Compute the SHA512 hash (using the "sha512sum"
2119 * The checksum is returned as a printable string.
2121 * @throws LibGuestFSException
2123 public String checksum (String csumtype, String path)
2124 throws LibGuestFSException
2127 throw new LibGuestFSException ("checksum: handle is closed");
2128 return _checksum (g, csumtype, path);
2130 private native String _checksum (long g, String csumtype, String path)
2131 throws LibGuestFSException;
2134 * unpack tarfile to directory
2136 * This command uploads and unpacks local file "tarfile"
2137 * (an *uncompressed* tar file) into "directory".
2139 * To upload a compressed tarball, use "g.tgz_in".
2141 * @throws LibGuestFSException
2143 public void tar_in (String tarfile, String directory)
2144 throws LibGuestFSException
2147 throw new LibGuestFSException ("tar_in: handle is closed");
2148 _tar_in (g, tarfile, directory);
2150 private native void _tar_in (long g, String tarfile, String directory)
2151 throws LibGuestFSException;
2154 * pack directory into tarfile
2156 * This command packs the contents of "directory" and
2157 * downloads it to local file "tarfile".
2159 * To download a compressed tarball, use "g.tgz_out".
2161 * @throws LibGuestFSException
2163 public void tar_out (String directory, String tarfile)
2164 throws LibGuestFSException
2167 throw new LibGuestFSException ("tar_out: handle is closed");
2168 _tar_out (g, directory, tarfile);
2170 private native void _tar_out (long g, String directory, String tarfile)
2171 throws LibGuestFSException;
2174 * unpack compressed tarball to directory
2176 * This command uploads and unpacks local file "tarball" (a
2177 * *gzip compressed* tar file) into "directory".
2179 * To upload an uncompressed tarball, use "g.tar_in".
2181 * @throws LibGuestFSException
2183 public void tgz_in (String tarball, String directory)
2184 throws LibGuestFSException
2187 throw new LibGuestFSException ("tgz_in: handle is closed");
2188 _tgz_in (g, tarball, directory);
2190 private native void _tgz_in (long g, String tarball, String directory)
2191 throws LibGuestFSException;
2194 * pack directory into compressed tarball
2196 * This command packs the contents of "directory" and
2197 * downloads it to local file "tarball".
2199 * To download an uncompressed tarball, use "g.tar_out".
2201 * @throws LibGuestFSException
2203 public void tgz_out (String directory, String tarball)
2204 throws LibGuestFSException
2207 throw new LibGuestFSException ("tgz_out: handle is closed");
2208 _tgz_out (g, directory, tarball);
2210 private native void _tgz_out (long g, String directory, String tarball)
2211 throws LibGuestFSException;
2214 * mount a guest disk, read-only
2216 * This is the same as the "g.mount" command, but it mounts
2217 * the filesystem with the read-only (*-o ro*) flag.
2219 * @throws LibGuestFSException
2221 public void mount_ro (String device, String mountpoint)
2222 throws LibGuestFSException
2225 throw new LibGuestFSException ("mount_ro: handle is closed");
2226 _mount_ro (g, device, mountpoint);
2228 private native void _mount_ro (long g, String device, String mountpoint)
2229 throws LibGuestFSException;
2232 * mount a guest disk with mount options
2234 * This is the same as the "g.mount" command, but it allows
2235 * you to set the mount options as for the mount(8) *-o*
2238 * @throws LibGuestFSException
2240 public void mount_options (String options, String device, String mountpoint)
2241 throws LibGuestFSException
2244 throw new LibGuestFSException ("mount_options: handle is closed");
2245 _mount_options (g, options, device, mountpoint);
2247 private native void _mount_options (long g, String options, String device, String mountpoint)
2248 throws LibGuestFSException;
2251 * mount a guest disk with mount options and vfstype
2253 * This is the same as the "g.mount" command, but it allows
2254 * you to set both the mount options and the vfstype as for
2255 * the mount(8) *-o* and *-t* flags.
2257 * @throws LibGuestFSException
2259 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2260 throws LibGuestFSException
2263 throw new LibGuestFSException ("mount_vfs: handle is closed");
2264 _mount_vfs (g, options, vfstype, device, mountpoint);
2266 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2267 throws LibGuestFSException;
2270 * debugging and internals
2272 * The "g.debug" command exposes some internals of
2273 * "guestfsd" (the guestfs daemon) that runs inside the
2276 * There is no comprehensive help for this command. You
2277 * have to look at the file "daemon/debug.c" in the
2278 * libguestfs source to find out what you can do.
2280 * @throws LibGuestFSException
2282 public String debug (String subcmd, String[] extraargs)
2283 throws LibGuestFSException
2286 throw new LibGuestFSException ("debug: handle is closed");
2287 return _debug (g, subcmd, extraargs);
2289 private native String _debug (long g, String subcmd, String[] extraargs)
2290 throws LibGuestFSException;
2293 * remove an LVM logical volume
2295 * Remove an LVM logical volume "device", where "device" is
2296 * the path to the LV, such as "/dev/VG/LV".
2298 * You can also remove all LVs in a volume group by
2299 * specifying the VG name, "/dev/VG".
2301 * @throws LibGuestFSException
2303 public void lvremove (String device)
2304 throws LibGuestFSException
2307 throw new LibGuestFSException ("lvremove: handle is closed");
2308 _lvremove (g, device);
2310 private native void _lvremove (long g, String device)
2311 throws LibGuestFSException;
2314 * remove an LVM volume group
2316 * Remove an LVM volume group "vgname", (for example "VG").
2318 * This also forcibly removes all logical volumes in the
2319 * volume group (if any).
2321 * @throws LibGuestFSException
2323 public void vgremove (String vgname)
2324 throws LibGuestFSException
2327 throw new LibGuestFSException ("vgremove: handle is closed");
2328 _vgremove (g, vgname);
2330 private native void _vgremove (long g, String vgname)
2331 throws LibGuestFSException;
2334 * remove an LVM physical volume
2336 * This wipes a physical volume "device" so that LVM will
2337 * no longer recognise it.
2339 * The implementation uses the "pvremove" command which
2340 * refuses to wipe physical volumes that contain any volume
2341 * groups, so you have to remove those first.
2343 * @throws LibGuestFSException
2345 public void pvremove (String device)
2346 throws LibGuestFSException
2349 throw new LibGuestFSException ("pvremove: handle is closed");
2350 _pvremove (g, device);
2352 private native void _pvremove (long g, String device)
2353 throws LibGuestFSException;
2356 * set the ext2/3/4 filesystem label
2358 * This sets the ext2/3/4 filesystem label of the
2359 * filesystem on "device" to "label". Filesystem labels are
2360 * limited to 16 characters.
2362 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2363 * return the existing label on a filesystem.
2365 * @throws LibGuestFSException
2367 public void set_e2label (String device, String label)
2368 throws LibGuestFSException
2371 throw new LibGuestFSException ("set_e2label: handle is closed");
2372 _set_e2label (g, device, label);
2374 private native void _set_e2label (long g, String device, String label)
2375 throws LibGuestFSException;
2378 * get the ext2/3/4 filesystem label
2380 * This returns the ext2/3/4 filesystem label of the
2381 * filesystem on "device".
2383 * @throws LibGuestFSException
2385 public String get_e2label (String device)
2386 throws LibGuestFSException
2389 throw new LibGuestFSException ("get_e2label: handle is closed");
2390 return _get_e2label (g, device);
2392 private native String _get_e2label (long g, String device)
2393 throws LibGuestFSException;
2396 * set the ext2/3/4 filesystem UUID
2398 * This sets the ext2/3/4 filesystem UUID of the filesystem
2399 * on "device" to "uuid". The format of the UUID and
2400 * alternatives such as "clear", "random" and "time" are
2401 * described in the tune2fs(8) manpage.
2403 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2404 * return the existing UUID of a filesystem.
2406 * @throws LibGuestFSException
2408 public void set_e2uuid (String device, String uuid)
2409 throws LibGuestFSException
2412 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2413 _set_e2uuid (g, device, uuid);
2415 private native void _set_e2uuid (long g, String device, String uuid)
2416 throws LibGuestFSException;
2419 * get the ext2/3/4 filesystem UUID
2421 * This returns the ext2/3/4 filesystem UUID of the
2422 * filesystem on "device".
2424 * @throws LibGuestFSException
2426 public String get_e2uuid (String device)
2427 throws LibGuestFSException
2430 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2431 return _get_e2uuid (g, device);
2433 private native String _get_e2uuid (long g, String device)
2434 throws LibGuestFSException;
2437 * run the filesystem checker
2439 * This runs the filesystem checker (fsck) on "device"
2440 * which should have filesystem type "fstype".
2442 * The returned integer is the status. See fsck(8) for the
2443 * list of status codes from "fsck".
2447 * * Multiple status codes can be summed together.
2449 * * A non-zero return code can mean "success", for
2450 * example if errors have been corrected on the
2453 * * Checking or repairing NTFS volumes is not supported
2456 * This command is entirely equivalent to running "fsck -a
2457 * -t fstype device".
2459 * @throws LibGuestFSException
2461 public int fsck (String fstype, String device)
2462 throws LibGuestFSException
2465 throw new LibGuestFSException ("fsck: handle is closed");
2466 return _fsck (g, fstype, device);
2468 private native int _fsck (long g, String fstype, String device)
2469 throws LibGuestFSException;
2472 * write zeroes to the device
2474 * This command writes zeroes over the first few blocks of
2477 * How many blocks are zeroed isn't specified (but it's
2478 * *not* enough to securely wipe the device). It should be
2479 * sufficient to remove any partition tables, filesystem
2480 * superblocks and so on.
2482 * @throws LibGuestFSException
2484 public void zero (String device)
2485 throws LibGuestFSException
2488 throw new LibGuestFSException ("zero: handle is closed");
2491 private native void _zero (long g, String device)
2492 throws LibGuestFSException;
2497 * This command installs GRUB (the Grand Unified
2498 * Bootloader) on "device", with the root directory being
2501 * @throws LibGuestFSException
2503 public void grub_install (String root, String device)
2504 throws LibGuestFSException
2507 throw new LibGuestFSException ("grub_install: handle is closed");
2508 _grub_install (g, root, device);
2510 private native void _grub_install (long g, String root, String device)
2511 throws LibGuestFSException;
2516 * This copies a file from "src" to "dest" where "dest" is
2517 * either a destination filename or destination directory.
2519 * @throws LibGuestFSException
2521 public void cp (String src, String dest)
2522 throws LibGuestFSException
2525 throw new LibGuestFSException ("cp: handle is closed");
2528 private native void _cp (long g, String src, String dest)
2529 throws LibGuestFSException;
2532 * copy a file or directory recursively
2534 * This copies a file or directory from "src" to "dest"
2535 * recursively using the "cp -a" command.
2537 * @throws LibGuestFSException
2539 public void cp_a (String src, String dest)
2540 throws LibGuestFSException
2543 throw new LibGuestFSException ("cp_a: handle is closed");
2544 _cp_a (g, src, dest);
2546 private native void _cp_a (long g, String src, String dest)
2547 throws LibGuestFSException;
2552 * This moves a file from "src" to "dest" where "dest" is
2553 * either a destination filename or destination directory.
2555 * @throws LibGuestFSException
2557 public void mv (String src, String dest)
2558 throws LibGuestFSException
2561 throw new LibGuestFSException ("mv: handle is closed");
2564 private native void _mv (long g, String src, String dest)
2565 throws LibGuestFSException;
2568 * drop kernel page cache, dentries and inodes
2570 * This instructs the guest kernel to drop its page cache,
2571 * and/or dentries and inode caches. The parameter
2572 * "whattodrop" tells the kernel what precisely to drop,
2573 * see <http://linux-mm.org/Drop_Caches>
2575 * Setting "whattodrop" to 3 should drop everything.
2577 * This automatically calls sync(2) before the operation,
2578 * so that the maximum guest memory is freed.
2580 * @throws LibGuestFSException
2582 public void drop_caches (int whattodrop)
2583 throws LibGuestFSException
2586 throw new LibGuestFSException ("drop_caches: handle is closed");
2587 _drop_caches (g, whattodrop);
2589 private native void _drop_caches (long g, int whattodrop)
2590 throws LibGuestFSException;
2593 * return kernel messages
2595 * This returns the kernel messages ("dmesg" output) from
2596 * the guest kernel. This is sometimes useful for extended
2597 * debugging of problems.
2599 * Another way to get the same information is to enable
2600 * verbose messages with "g.set_verbose" or by setting the
2601 * environment variable "LIBGUESTFS_DEBUG=1" before running
2604 * @throws LibGuestFSException
2606 public String dmesg ()
2607 throws LibGuestFSException
2610 throw new LibGuestFSException ("dmesg: handle is closed");
2613 private native String _dmesg (long g)
2614 throws LibGuestFSException;
2617 * ping the guest daemon
2619 * This is a test probe into the guestfs daemon running
2620 * inside the qemu subprocess. Calling this function checks
2621 * that the daemon responds to the ping message, without
2622 * affecting the daemon or attached block device(s) in any
2625 * @throws LibGuestFSException
2627 public void ping_daemon ()
2628 throws LibGuestFSException
2631 throw new LibGuestFSException ("ping_daemon: handle is closed");
2634 private native void _ping_daemon (long g)
2635 throws LibGuestFSException;
2638 * test if two files have equal contents
2640 * This compares the two files "file1" and "file2" and
2641 * returns true if their content is exactly equal, or false
2644 * The external cmp(1) program is used for the comparison.
2646 * @throws LibGuestFSException
2648 public boolean equal (String file1, String file2)
2649 throws LibGuestFSException
2652 throw new LibGuestFSException ("equal: handle is closed");
2653 return _equal (g, file1, file2);
2655 private native boolean _equal (long g, String file1, String file2)
2656 throws LibGuestFSException;
2659 * print the printable strings in a file
2661 * This runs the strings(1) command on a file and returns
2662 * the list of printable strings found.
2664 * Because of the message protocol, there is a transfer
2665 * limit of somewhere between 2MB and 4MB. To transfer
2666 * large files you should use FTP.
2668 * @throws LibGuestFSException
2670 public String[] strings (String path)
2671 throws LibGuestFSException
2674 throw new LibGuestFSException ("strings: handle is closed");
2675 return _strings (g, path);
2677 private native String[] _strings (long g, String path)
2678 throws LibGuestFSException;
2681 * print the printable strings in a file
2683 * This is like the "g.strings" command, but allows you to
2684 * specify the encoding.
2686 * See the strings(1) manpage for the full list of
2689 * Commonly useful encodings are "l" (lower case L) which
2690 * will show strings inside Windows/x86 files.
2692 * The returned strings are transcoded to UTF-8.
2694 * Because of the message protocol, there is a transfer
2695 * limit of somewhere between 2MB and 4MB. To transfer
2696 * large files you should use FTP.
2698 * @throws LibGuestFSException
2700 public String[] strings_e (String encoding, String path)
2701 throws LibGuestFSException
2704 throw new LibGuestFSException ("strings_e: handle is closed");
2705 return _strings_e (g, encoding, path);
2707 private native String[] _strings_e (long g, String encoding, String path)
2708 throws LibGuestFSException;
2711 * dump a file in hexadecimal
2713 * This runs "hexdump -C" on the given "path". The result
2714 * is the human-readable, canonical hex dump of the file.
2716 * Because of the message protocol, there is a transfer
2717 * limit of somewhere between 2MB and 4MB. To transfer
2718 * large files you should use FTP.
2720 * @throws LibGuestFSException
2722 public String hexdump (String path)
2723 throws LibGuestFSException
2726 throw new LibGuestFSException ("hexdump: handle is closed");
2727 return _hexdump (g, path);
2729 private native String _hexdump (long g, String path)
2730 throws LibGuestFSException;
2733 * zero unused inodes and disk blocks on ext2/3 filesystem
2735 * This runs the *zerofree* program on "device". This
2736 * program claims to zero unused inodes and disk blocks on
2737 * an ext2/3 filesystem, thus making it possible to
2738 * compress the filesystem more effectively.
2740 * You should not run this program if the filesystem is
2743 * It is possible that using this program can damage the
2744 * filesystem or data on the filesystem.
2746 * @throws LibGuestFSException
2748 public void zerofree (String device)
2749 throws LibGuestFSException
2752 throw new LibGuestFSException ("zerofree: handle is closed");
2753 _zerofree (g, device);
2755 private native void _zerofree (long g, String device)
2756 throws LibGuestFSException;