1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 package com.redhat.et.libguestfs;
24 import java.util.HashMap;
25 import com.redhat.et.libguestfs.LibGuestFSException;
26 import com.redhat.et.libguestfs.PV;
27 import com.redhat.et.libguestfs.VG;
28 import com.redhat.et.libguestfs.LV;
29 import com.redhat.et.libguestfs.Stat;
30 import com.redhat.et.libguestfs.StatVFS;
31 import com.redhat.et.libguestfs.IntBool;
34 * The GuestFS object is a libguestfs handle.
38 public class GuestFS {
39 // Load the native code.
41 System.loadLibrary ("guestfs_jni");
45 * The native guestfs_h pointer.
50 * Create a libguestfs handle.
52 * @throws LibGuestFSException
54 public GuestFS () throws LibGuestFSException
58 private native long _create () throws LibGuestFSException;
61 * Close a libguestfs handle.
63 * You can also leave handles to be collected by the garbage
64 * collector, but this method ensures that the resources used
65 * by the handle are freed up immediately. If you call any
66 * other methods after closing the handle, you will get an
69 * @throws LibGuestFSException
71 public void close () throws LibGuestFSException
77 private native void _close (long g) throws LibGuestFSException;
79 public void finalize () throws LibGuestFSException
85 * launch the qemu subprocess
87 * Internally libguestfs is implemented by running a
88 * virtual machine using qemu(1).
90 * You should call this after configuring the handle (eg.
91 * adding drives) but before performing any actions.
93 * @throws LibGuestFSException
96 throws LibGuestFSException
99 throw new LibGuestFSException ("launch: handle is closed");
102 private native void _launch (long g)
103 throws LibGuestFSException;
106 * wait until the qemu subprocess launches
108 * Internally libguestfs is implemented by running a
109 * virtual machine using qemu(1).
111 * You should call this after "g.launch" to wait for the
112 * launch to complete.
114 * @throws LibGuestFSException
116 public void wait_ready ()
117 throws LibGuestFSException
120 throw new LibGuestFSException ("wait_ready: handle is closed");
123 private native void _wait_ready (long g)
124 throws LibGuestFSException;
127 * kill the qemu subprocess
129 * This kills the qemu subprocess. You should never need to
132 * @throws LibGuestFSException
134 public void kill_subprocess ()
135 throws LibGuestFSException
138 throw new LibGuestFSException ("kill_subprocess: handle is closed");
139 _kill_subprocess (g);
141 private native void _kill_subprocess (long g)
142 throws LibGuestFSException;
145 * add an image to examine or modify
147 * This function adds a virtual machine disk image
148 * "filename" to the guest. The first time you call this
149 * function, the disk appears as IDE disk 0 ("/dev/sda") in
150 * the guest, the second time as "/dev/sdb", and so on.
152 * You don't necessarily need to be root when using
153 * libguestfs. However you obviously do need sufficient
154 * permissions to access the filename for whatever
155 * operations you want to perform (ie. read access if you
156 * just want to read the image or write access if you want
157 * to modify the image).
159 * This is equivalent to the qemu parameter "-drive
162 * @throws LibGuestFSException
164 public void add_drive (String filename)
165 throws LibGuestFSException
168 throw new LibGuestFSException ("add_drive: handle is closed");
169 _add_drive (g, filename);
171 private native void _add_drive (long g, String filename)
172 throws LibGuestFSException;
175 * add a CD-ROM disk image to examine
177 * This function adds a virtual CD-ROM disk image to the
180 * This is equivalent to the qemu parameter "-cdrom
183 * @throws LibGuestFSException
185 public void add_cdrom (String filename)
186 throws LibGuestFSException
189 throw new LibGuestFSException ("add_cdrom: handle is closed");
190 _add_cdrom (g, filename);
192 private native void _add_cdrom (long g, String filename)
193 throws LibGuestFSException;
196 * add qemu parameters
198 * This can be used to add arbitrary qemu command line
199 * parameters of the form "-param value". Actually it's not
200 * quite arbitrary - we prevent you from setting some
201 * parameters which would interfere with parameters that we
204 * The first character of "param" string must be a "-"
207 * "value" can be NULL.
209 * @throws LibGuestFSException
211 public void config (String qemuparam, String qemuvalue)
212 throws LibGuestFSException
215 throw new LibGuestFSException ("config: handle is closed");
216 _config (g, qemuparam, qemuvalue);
218 private native void _config (long g, String qemuparam, String qemuvalue)
219 throws LibGuestFSException;
222 * set the qemu binary
224 * Set the qemu binary that we will use.
226 * The default is chosen when the library was compiled by
227 * the configure script.
229 * You can also override this by setting the
230 * "LIBGUESTFS_QEMU" environment variable.
232 * The string "qemu" is stashed in the libguestfs handle,
233 * so the caller must make sure it remains valid for the
234 * lifetime of the handle.
236 * Setting "qemu" to "NULL" restores the default qemu
239 * @throws LibGuestFSException
241 public void set_qemu (String qemu)
242 throws LibGuestFSException
245 throw new LibGuestFSException ("set_qemu: handle is closed");
248 private native void _set_qemu (long g, String qemu)
249 throws LibGuestFSException;
252 * get the qemu binary
254 * Return the current qemu binary.
256 * This is always non-NULL. If it wasn't set already, then
257 * this will return the default qemu binary name.
259 * @throws LibGuestFSException
261 public String get_qemu ()
262 throws LibGuestFSException
265 throw new LibGuestFSException ("get_qemu: handle is closed");
266 return _get_qemu (g);
268 private native String _get_qemu (long g)
269 throws LibGuestFSException;
272 * set the search path
274 * Set the path that libguestfs searches for kernel and
277 * The default is "$libdir/guestfs" unless overridden by
278 * setting "LIBGUESTFS_PATH" environment variable.
280 * The string "path" is stashed in the libguestfs handle,
281 * so the caller must make sure it remains valid for the
282 * lifetime of the handle.
284 * Setting "path" to "NULL" restores the default path.
286 * @throws LibGuestFSException
288 public void set_path (String path)
289 throws LibGuestFSException
292 throw new LibGuestFSException ("set_path: handle is closed");
295 private native void _set_path (long g, String path)
296 throws LibGuestFSException;
299 * get the search path
301 * Return the current search path.
303 * This is always non-NULL. If it wasn't set already, then
304 * this will return the default path.
306 * @throws LibGuestFSException
308 public String get_path ()
309 throws LibGuestFSException
312 throw new LibGuestFSException ("get_path: handle is closed");
313 return _get_path (g);
315 private native String _get_path (long g)
316 throws LibGuestFSException;
321 * If "autosync" is true, this enables autosync. Libguestfs
322 * will make a best effort attempt to run "g.umount_all"
323 * followed by "g.sync" when the handle is closed (also if
324 * the program exits without closing handles).
326 * This is disabled by default (except in guestfish where
327 * it is enabled by default).
329 * @throws LibGuestFSException
331 public void set_autosync (boolean autosync)
332 throws LibGuestFSException
335 throw new LibGuestFSException ("set_autosync: handle is closed");
336 _set_autosync (g, autosync);
338 private native void _set_autosync (long g, boolean autosync)
339 throws LibGuestFSException;
344 * Get the autosync flag.
346 * @throws LibGuestFSException
348 public boolean get_autosync ()
349 throws LibGuestFSException
352 throw new LibGuestFSException ("get_autosync: handle is closed");
353 return _get_autosync (g);
355 private native boolean _get_autosync (long g)
356 throws LibGuestFSException;
361 * If "verbose" is true, this turns on verbose messages (to
364 * Verbose messages are disabled unless the environment
365 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
367 * @throws LibGuestFSException
369 public void set_verbose (boolean verbose)
370 throws LibGuestFSException
373 throw new LibGuestFSException ("set_verbose: handle is closed");
374 _set_verbose (g, verbose);
376 private native void _set_verbose (long g, boolean verbose)
377 throws LibGuestFSException;
382 * This returns the verbose messages flag.
384 * @throws LibGuestFSException
386 public boolean get_verbose ()
387 throws LibGuestFSException
390 throw new LibGuestFSException ("get_verbose: handle is closed");
391 return _get_verbose (g);
393 private native boolean _get_verbose (long g)
394 throws LibGuestFSException;
397 * is ready to accept commands
399 * This returns true iff this handle is ready to accept
400 * commands (in the "READY" state).
402 * For more information on states, see guestfs(3).
404 * @throws LibGuestFSException
406 public boolean is_ready ()
407 throws LibGuestFSException
410 throw new LibGuestFSException ("is_ready: handle is closed");
411 return _is_ready (g);
413 private native boolean _is_ready (long g)
414 throws LibGuestFSException;
417 * is in configuration state
419 * This returns true iff this handle is being configured
420 * (in the "CONFIG" state).
422 * For more information on states, see guestfs(3).
424 * @throws LibGuestFSException
426 public boolean is_config ()
427 throws LibGuestFSException
430 throw new LibGuestFSException ("is_config: handle is closed");
431 return _is_config (g);
433 private native boolean _is_config (long g)
434 throws LibGuestFSException;
437 * is launching subprocess
439 * This returns true iff this handle is launching the
440 * subprocess (in the "LAUNCHING" state).
442 * For more information on states, see guestfs(3).
444 * @throws LibGuestFSException
446 public boolean is_launching ()
447 throws LibGuestFSException
450 throw new LibGuestFSException ("is_launching: handle is closed");
451 return _is_launching (g);
453 private native boolean _is_launching (long g)
454 throws LibGuestFSException;
457 * is busy processing a command
459 * This returns true iff this handle is busy processing a
460 * command (in the "BUSY" state).
462 * For more information on states, see guestfs(3).
464 * @throws LibGuestFSException
466 public boolean is_busy ()
467 throws LibGuestFSException
470 throw new LibGuestFSException ("is_busy: handle is closed");
473 private native boolean _is_busy (long g)
474 throws LibGuestFSException;
477 * get the current state
479 * This returns the current state as an opaque integer.
480 * This is only useful for printing debug and internal
483 * For more information on states, see guestfs(3).
485 * @throws LibGuestFSException
487 public int get_state ()
488 throws LibGuestFSException
491 throw new LibGuestFSException ("get_state: handle is closed");
492 return _get_state (g);
494 private native int _get_state (long g)
495 throws LibGuestFSException;
500 * This sets the state to "BUSY". This is only used when
501 * implementing actions using the low-level API.
503 * For more information on states, see guestfs(3).
505 * @throws LibGuestFSException
507 public void set_busy ()
508 throws LibGuestFSException
511 throw new LibGuestFSException ("set_busy: handle is closed");
514 private native void _set_busy (long g)
515 throws LibGuestFSException;
520 * This sets the state to "READY". This is only used when
521 * implementing actions using the low-level API.
523 * For more information on states, see guestfs(3).
525 * @throws LibGuestFSException
527 public void set_ready ()
528 throws LibGuestFSException
531 throw new LibGuestFSException ("set_ready: handle is closed");
534 private native void _set_ready (long g)
535 throws LibGuestFSException;
538 * mount a guest disk at a position in the filesystem
540 * Mount a guest disk at a position in the filesystem.
541 * Block devices are named "/dev/sda", "/dev/sdb" and so
542 * on, as they were added to the guest. If those block
543 * devices contain partitions, they will have the usual
544 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
547 * The rules are the same as for mount(2): A filesystem
548 * must first be mounted on "/" before others can be
549 * mounted. Other filesystems can only be mounted on
550 * directories which already exist.
552 * The mounted filesystem is writable, if we have
553 * sufficient permissions on the underlying device.
555 * The filesystem options "sync" and "noatime" are set with
556 * this call, in order to improve reliability.
558 * @throws LibGuestFSException
560 public void mount (String device, String mountpoint)
561 throws LibGuestFSException
564 throw new LibGuestFSException ("mount: handle is closed");
565 _mount (g, device, mountpoint);
567 private native void _mount (long g, String device, String mountpoint)
568 throws LibGuestFSException;
571 * sync disks, writes are flushed through to the disk image
573 * This syncs the disk, so that any writes are flushed
574 * through to the underlying disk image.
576 * You should always call this if you have modified a disk
577 * image, before closing the handle.
579 * @throws LibGuestFSException
582 throws LibGuestFSException
585 throw new LibGuestFSException ("sync: handle is closed");
588 private native void _sync (long g)
589 throws LibGuestFSException;
592 * update file timestamps or create a new file
594 * Touch acts like the touch(1) command. It can be used to
595 * update the timestamps on a file, or, if the file does
596 * not exist, to create a new zero-length file.
598 * @throws LibGuestFSException
600 public void touch (String path)
601 throws LibGuestFSException
604 throw new LibGuestFSException ("touch: handle is closed");
607 private native void _touch (long g, String path)
608 throws LibGuestFSException;
611 * list the contents of a file
613 * Return the contents of the file named "path".
615 * Note that this function cannot correctly handle binary
616 * files (specifically, files containing "\0" character
617 * which is treated as end of string). For those you need
618 * to use the "g.download" function which has a more
621 * Because of the message protocol, there is a transfer
622 * limit of somewhere between 2MB and 4MB. To transfer
623 * large files you should use FTP.
625 * @throws LibGuestFSException
627 public String cat (String path)
628 throws LibGuestFSException
631 throw new LibGuestFSException ("cat: handle is closed");
632 return _cat (g, path);
634 private native String _cat (long g, String path)
635 throws LibGuestFSException;
638 * list the files in a directory (long format)
640 * List the files in "directory" (relative to the root
641 * directory, there is no cwd) in the format of 'ls -la'.
643 * This command is mostly useful for interactive sessions.
644 * It is *not* intended that you try to parse the output
647 * @throws LibGuestFSException
649 public String ll (String directory)
650 throws LibGuestFSException
653 throw new LibGuestFSException ("ll: handle is closed");
654 return _ll (g, directory);
656 private native String _ll (long g, String directory)
657 throws LibGuestFSException;
660 * list the files in a directory
662 * List the files in "directory" (relative to the root
663 * directory, there is no cwd). The '.' and '..' entries
664 * are not returned, but hidden files are shown.
666 * This command is mostly useful for interactive sessions.
667 * Programs should probably use "g.readdir" instead.
669 * @throws LibGuestFSException
671 public String[] ls (String directory)
672 throws LibGuestFSException
675 throw new LibGuestFSException ("ls: handle is closed");
676 return _ls (g, directory);
678 private native String[] _ls (long g, String directory)
679 throws LibGuestFSException;
682 * list the block devices
684 * List all the block devices.
686 * The full block device names are returned, eg. "/dev/sda"
688 * @throws LibGuestFSException
690 public String[] list_devices ()
691 throws LibGuestFSException
694 throw new LibGuestFSException ("list_devices: handle is closed");
695 return _list_devices (g);
697 private native String[] _list_devices (long g)
698 throws LibGuestFSException;
701 * list the partitions
703 * List all the partitions detected on all block devices.
705 * The full partition device names are returned, eg.
708 * This does not return logical volumes. For that you will
709 * need to call "g.lvs".
711 * @throws LibGuestFSException
713 public String[] list_partitions ()
714 throws LibGuestFSException
717 throw new LibGuestFSException ("list_partitions: handle is closed");
718 return _list_partitions (g);
720 private native String[] _list_partitions (long g)
721 throws LibGuestFSException;
724 * list the LVM physical volumes (PVs)
726 * List all the physical volumes detected. This is the
727 * equivalent of the pvs(8) command.
729 * This returns a list of just the device names that
730 * contain PVs (eg. "/dev/sda2").
732 * See also "g.pvs_full".
734 * @throws LibGuestFSException
736 public String[] pvs ()
737 throws LibGuestFSException
740 throw new LibGuestFSException ("pvs: handle is closed");
743 private native String[] _pvs (long g)
744 throws LibGuestFSException;
747 * list the LVM volume groups (VGs)
749 * List all the volumes groups detected. This is the
750 * equivalent of the vgs(8) command.
752 * This returns a list of just the volume group names that
753 * were detected (eg. "VolGroup00").
755 * See also "g.vgs_full".
757 * @throws LibGuestFSException
759 public String[] vgs ()
760 throws LibGuestFSException
763 throw new LibGuestFSException ("vgs: handle is closed");
766 private native String[] _vgs (long g)
767 throws LibGuestFSException;
770 * list the LVM logical volumes (LVs)
772 * List all the logical volumes detected. This is the
773 * equivalent of the lvs(8) command.
775 * This returns a list of the logical volume device names
776 * (eg. "/dev/VolGroup00/LogVol00").
778 * See also "g.lvs_full".
780 * @throws LibGuestFSException
782 public String[] lvs ()
783 throws LibGuestFSException
786 throw new LibGuestFSException ("lvs: handle is closed");
789 private native String[] _lvs (long g)
790 throws LibGuestFSException;
793 * list the LVM physical volumes (PVs)
795 * List all the physical volumes detected. This is the
796 * equivalent of the pvs(8) command. The "full" version
797 * includes all fields.
799 * @throws LibGuestFSException
801 public PV[] pvs_full ()
802 throws LibGuestFSException
805 throw new LibGuestFSException ("pvs_full: handle is closed");
806 return _pvs_full (g);
808 private native PV[] _pvs_full (long g)
809 throws LibGuestFSException;
812 * list the LVM volume groups (VGs)
814 * List all the volumes groups detected. This is the
815 * equivalent of the vgs(8) command. The "full" version
816 * includes all fields.
818 * @throws LibGuestFSException
820 public VG[] vgs_full ()
821 throws LibGuestFSException
824 throw new LibGuestFSException ("vgs_full: handle is closed");
825 return _vgs_full (g);
827 private native VG[] _vgs_full (long g)
828 throws LibGuestFSException;
831 * list the LVM logical volumes (LVs)
833 * List all the logical volumes detected. This is the
834 * equivalent of the lvs(8) command. The "full" version
835 * includes all fields.
837 * @throws LibGuestFSException
839 public LV[] lvs_full ()
840 throws LibGuestFSException
843 throw new LibGuestFSException ("lvs_full: handle is closed");
844 return _lvs_full (g);
846 private native LV[] _lvs_full (long g)
847 throws LibGuestFSException;
852 * Return the contents of the file named "path".
854 * The file contents are returned as a list of lines.
855 * Trailing "LF" and "CRLF" character sequences are *not*
858 * Note that this function cannot correctly handle binary
859 * files (specifically, files containing "\0" character
860 * which is treated as end of line). For those you need to
861 * use the "g.read_file" function which has a more complex
864 * @throws LibGuestFSException
866 public String[] read_lines (String path)
867 throws LibGuestFSException
870 throw new LibGuestFSException ("read_lines: handle is closed");
871 return _read_lines (g, path);
873 private native String[] _read_lines (long g, String path)
874 throws LibGuestFSException;
877 * create a new Augeas handle
879 * Create a new Augeas handle for editing configuration
880 * files. If there was any previous Augeas handle
881 * associated with this guestfs session, then it is closed.
883 * You must call this before using any other "g.aug_*"
886 * "root" is the filesystem root. "root" must not be NULL,
889 * The flags are the same as the flags defined in
890 * <augeas.h>, the logical *or* of the following integers:
892 * "AUG_SAVE_BACKUP" = 1
893 * Keep the original file with a ".augsave" extension.
895 * "AUG_SAVE_NEWFILE" = 2
896 * Save changes into a file with extension ".augnew",
897 * and do not overwrite original. Overrides
900 * "AUG_TYPE_CHECK" = 4
901 * Typecheck lenses (can be expensive).
903 * "AUG_NO_STDINC" = 8
904 * Do not use standard load path for modules.
906 * "AUG_SAVE_NOOP" = 16
907 * Make save a no-op, just record what would have been
911 * Do not load the tree in "g.aug_init".
913 * To close the handle, you can call "g.aug_close".
915 * To find out more about Augeas, see <http://augeas.net/>.
917 * @throws LibGuestFSException
919 public void aug_init (String root, int flags)
920 throws LibGuestFSException
923 throw new LibGuestFSException ("aug_init: handle is closed");
924 _aug_init (g, root, flags);
926 private native void _aug_init (long g, String root, int flags)
927 throws LibGuestFSException;
930 * close the current Augeas handle
932 * Close the current Augeas handle and free up any
933 * resources used by it. After calling this, you have to
934 * call "g.aug_init" again before you can use any other
937 * @throws LibGuestFSException
939 public void aug_close ()
940 throws LibGuestFSException
943 throw new LibGuestFSException ("aug_close: handle is closed");
946 private native void _aug_close (long g)
947 throws LibGuestFSException;
950 * define an Augeas variable
952 * Defines an Augeas variable "name" whose value is the
953 * result of evaluating "expr". If "expr" is NULL, then
954 * "name" is undefined.
956 * On success this returns the number of nodes in "expr",
957 * or 0 if "expr" evaluates to something which is not a
960 * @throws LibGuestFSException
962 public int aug_defvar (String name, String expr)
963 throws LibGuestFSException
966 throw new LibGuestFSException ("aug_defvar: handle is closed");
967 return _aug_defvar (g, name, expr);
969 private native int _aug_defvar (long g, String name, String expr)
970 throws LibGuestFSException;
973 * define an Augeas node
975 * Defines a variable "name" whose value is the result of
978 * If "expr" evaluates to an empty nodeset, a node is
979 * created, equivalent to calling "g.aug_set" "expr",
980 * "value". "name" will be the nodeset containing that
983 * On success this returns a pair containing the number of
984 * nodes in the nodeset, and a boolean flag if a node was
987 * @throws LibGuestFSException
989 public IntBool aug_defnode (String name, String expr, String val)
990 throws LibGuestFSException
993 throw new LibGuestFSException ("aug_defnode: handle is closed");
994 return _aug_defnode (g, name, expr, val);
996 private native IntBool _aug_defnode (long g, String name, String expr, String val)
997 throws LibGuestFSException;
1000 * look up the value of an Augeas path
1002 * Look up the value associated with "path". If "path"
1003 * matches exactly one node, the "value" is returned.
1005 * @throws LibGuestFSException
1007 public String aug_get (String path)
1008 throws LibGuestFSException
1011 throw new LibGuestFSException ("aug_get: handle is closed");
1012 return _aug_get (g, path);
1014 private native String _aug_get (long g, String path)
1015 throws LibGuestFSException;
1018 * set Augeas path to value
1020 * Set the value associated with "path" to "value".
1022 * @throws LibGuestFSException
1024 public void aug_set (String path, String val)
1025 throws LibGuestFSException
1028 throw new LibGuestFSException ("aug_set: handle is closed");
1029 _aug_set (g, path, val);
1031 private native void _aug_set (long g, String path, String val)
1032 throws LibGuestFSException;
1035 * insert a sibling Augeas node
1037 * Create a new sibling "label" for "path", inserting it
1038 * into the tree before or after "path" (depending on the
1039 * boolean flag "before").
1041 * "path" must match exactly one existing node in the tree,
1042 * and "label" must be a label, ie. not contain "/", "*" or
1043 * end with a bracketed index "[N]".
1045 * @throws LibGuestFSException
1047 public void aug_insert (String path, String label, boolean before)
1048 throws LibGuestFSException
1051 throw new LibGuestFSException ("aug_insert: handle is closed");
1052 _aug_insert (g, path, label, before);
1054 private native void _aug_insert (long g, String path, String label, boolean before)
1055 throws LibGuestFSException;
1058 * remove an Augeas path
1060 * Remove "path" and all of its children.
1062 * On success this returns the number of entries which were
1065 * @throws LibGuestFSException
1067 public int aug_rm (String path)
1068 throws LibGuestFSException
1071 throw new LibGuestFSException ("aug_rm: handle is closed");
1072 return _aug_rm (g, path);
1074 private native int _aug_rm (long g, String path)
1075 throws LibGuestFSException;
1080 * Move the node "src" to "dest". "src" must match exactly
1081 * one node. "dest" is overwritten if it exists.
1083 * @throws LibGuestFSException
1085 public void aug_mv (String src, String dest)
1086 throws LibGuestFSException
1089 throw new LibGuestFSException ("aug_mv: handle is closed");
1090 _aug_mv (g, src, dest);
1092 private native void _aug_mv (long g, String src, String dest)
1093 throws LibGuestFSException;
1096 * return Augeas nodes which match path
1098 * Returns a list of paths which match the path expression
1099 * "path". The returned paths are sufficiently qualified so
1100 * that they match exactly one node in the current tree.
1102 * @throws LibGuestFSException
1104 public String[] aug_match (String path)
1105 throws LibGuestFSException
1108 throw new LibGuestFSException ("aug_match: handle is closed");
1109 return _aug_match (g, path);
1111 private native String[] _aug_match (long g, String path)
1112 throws LibGuestFSException;
1115 * write all pending Augeas changes to disk
1117 * This writes all pending changes to disk.
1119 * The flags which were passed to "g.aug_init" affect
1120 * exactly how files are saved.
1122 * @throws LibGuestFSException
1124 public void aug_save ()
1125 throws LibGuestFSException
1128 throw new LibGuestFSException ("aug_save: handle is closed");
1131 private native void _aug_save (long g)
1132 throws LibGuestFSException;
1135 * load files into the tree
1137 * Load files into the tree.
1139 * See "aug_load" in the Augeas documentation for the full
1142 * @throws LibGuestFSException
1144 public void aug_load ()
1145 throws LibGuestFSException
1148 throw new LibGuestFSException ("aug_load: handle is closed");
1151 private native void _aug_load (long g)
1152 throws LibGuestFSException;
1155 * list Augeas nodes under a path
1157 * This is just a shortcut for listing "g.aug_match"
1158 * "path/*" and sorting the resulting nodes into
1159 * alphabetical order.
1161 * @throws LibGuestFSException
1163 public String[] aug_ls (String path)
1164 throws LibGuestFSException
1167 throw new LibGuestFSException ("aug_ls: handle is closed");
1168 return _aug_ls (g, path);
1170 private native String[] _aug_ls (long g, String path)
1171 throws LibGuestFSException;
1176 * Remove the single file "path".
1178 * @throws LibGuestFSException
1180 public void rm (String path)
1181 throws LibGuestFSException
1184 throw new LibGuestFSException ("rm: handle is closed");
1187 private native void _rm (long g, String path)
1188 throws LibGuestFSException;
1191 * remove a directory
1193 * Remove the single directory "path".
1195 * @throws LibGuestFSException
1197 public void rmdir (String path)
1198 throws LibGuestFSException
1201 throw new LibGuestFSException ("rmdir: handle is closed");
1204 private native void _rmdir (long g, String path)
1205 throws LibGuestFSException;
1208 * remove a file or directory recursively
1210 * Remove the file or directory "path", recursively
1211 * removing the contents if its a directory. This is like
1212 * the "rm -rf" shell command.
1214 * @throws LibGuestFSException
1216 public void rm_rf (String path)
1217 throws LibGuestFSException
1220 throw new LibGuestFSException ("rm_rf: handle is closed");
1223 private native void _rm_rf (long g, String path)
1224 throws LibGuestFSException;
1227 * create a directory
1229 * Create a directory named "path".
1231 * @throws LibGuestFSException
1233 public void mkdir (String path)
1234 throws LibGuestFSException
1237 throw new LibGuestFSException ("mkdir: handle is closed");
1240 private native void _mkdir (long g, String path)
1241 throws LibGuestFSException;
1244 * create a directory and parents
1246 * Create a directory named "path", creating any parent
1247 * directories as necessary. This is like the "mkdir -p"
1250 * @throws LibGuestFSException
1252 public void mkdir_p (String path)
1253 throws LibGuestFSException
1256 throw new LibGuestFSException ("mkdir_p: handle is closed");
1259 private native void _mkdir_p (long g, String path)
1260 throws LibGuestFSException;
1265 * Change the mode (permissions) of "path" to "mode". Only
1266 * numeric modes are supported.
1268 * @throws LibGuestFSException
1270 public void chmod (int mode, String path)
1271 throws LibGuestFSException
1274 throw new LibGuestFSException ("chmod: handle is closed");
1275 _chmod (g, mode, path);
1277 private native void _chmod (long g, int mode, String path)
1278 throws LibGuestFSException;
1281 * change file owner and group
1283 * Change the file owner to "owner" and group to "group".
1285 * Only numeric uid and gid are supported. If you want to
1286 * use names, you will need to locate and parse the
1287 * password file yourself (Augeas support makes this
1290 * @throws LibGuestFSException
1292 public void chown (int owner, int group, String path)
1293 throws LibGuestFSException
1296 throw new LibGuestFSException ("chown: handle is closed");
1297 _chown (g, owner, group, path);
1299 private native void _chown (long g, int owner, int group, String path)
1300 throws LibGuestFSException;
1303 * test if file or directory exists
1305 * This returns "true" if and only if there is a file,
1306 * directory (or anything) with the given "path" name.
1308 * See also "g.is_file", "g.is_dir", "g.stat".
1310 * @throws LibGuestFSException
1312 public boolean exists (String path)
1313 throws LibGuestFSException
1316 throw new LibGuestFSException ("exists: handle is closed");
1317 return _exists (g, path);
1319 private native boolean _exists (long g, String path)
1320 throws LibGuestFSException;
1323 * test if file exists
1325 * This returns "true" if and only if there is a file with
1326 * the given "path" name. Note that it returns false for
1327 * other objects like directories.
1329 * See also "g.stat".
1331 * @throws LibGuestFSException
1333 public boolean is_file (String path)
1334 throws LibGuestFSException
1337 throw new LibGuestFSException ("is_file: handle is closed");
1338 return _is_file (g, path);
1340 private native boolean _is_file (long g, String path)
1341 throws LibGuestFSException;
1344 * test if file exists
1346 * This returns "true" if and only if there is a directory
1347 * with the given "path" name. Note that it returns false
1348 * for other objects like files.
1350 * See also "g.stat".
1352 * @throws LibGuestFSException
1354 public boolean is_dir (String path)
1355 throws LibGuestFSException
1358 throw new LibGuestFSException ("is_dir: handle is closed");
1359 return _is_dir (g, path);
1361 private native boolean _is_dir (long g, String path)
1362 throws LibGuestFSException;
1365 * create an LVM physical volume
1367 * This creates an LVM physical volume on the named
1368 * "device", where "device" should usually be a partition
1369 * name such as "/dev/sda1".
1371 * @throws LibGuestFSException
1373 public void pvcreate (String device)
1374 throws LibGuestFSException
1377 throw new LibGuestFSException ("pvcreate: handle is closed");
1378 _pvcreate (g, device);
1380 private native void _pvcreate (long g, String device)
1381 throws LibGuestFSException;
1384 * create an LVM volume group
1386 * This creates an LVM volume group called "volgroup" from
1387 * the non-empty list of physical volumes "physvols".
1389 * @throws LibGuestFSException
1391 public void vgcreate (String volgroup, String[] physvols)
1392 throws LibGuestFSException
1395 throw new LibGuestFSException ("vgcreate: handle is closed");
1396 _vgcreate (g, volgroup, physvols);
1398 private native void _vgcreate (long g, String volgroup, String[] physvols)
1399 throws LibGuestFSException;
1402 * create an LVM volume group
1404 * This creates an LVM volume group called "logvol" on the
1405 * volume group "volgroup", with "size" megabytes.
1407 * @throws LibGuestFSException
1409 public void lvcreate (String logvol, String volgroup, int mbytes)
1410 throws LibGuestFSException
1413 throw new LibGuestFSException ("lvcreate: handle is closed");
1414 _lvcreate (g, logvol, volgroup, mbytes);
1416 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1417 throws LibGuestFSException;
1422 * This creates a filesystem on "device" (usually a
1423 * partition of LVM logical volume). The filesystem type is
1424 * "fstype", for example "ext3".
1426 * @throws LibGuestFSException
1428 public void mkfs (String fstype, String device)
1429 throws LibGuestFSException
1432 throw new LibGuestFSException ("mkfs: handle is closed");
1433 _mkfs (g, fstype, device);
1435 private native void _mkfs (long g, String fstype, String device)
1436 throws LibGuestFSException;
1439 * create partitions on a block device
1441 * This is a direct interface to the sfdisk(8) program for
1442 * creating partitions on block devices.
1444 * "device" should be a block device, for example
1447 * "cyls", "heads" and "sectors" are the number of
1448 * cylinders, heads and sectors on the device, which are
1449 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1450 * parameters. If you pass 0 for any of these, then the
1451 * corresponding parameter is omitted. Usually for 'large'
1452 * disks, you can just pass 0 for these, but for small
1453 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1454 * cannot work out the right geometry and you will need to
1457 * "lines" is a list of lines that we feed to "sfdisk". For
1458 * more information refer to the sfdisk(8) manpage.
1460 * To create a single partition occupying the whole disk,
1461 * you would pass "lines" as a single element list, when
1462 * the single element being the string "," (comma).
1464 * This command is dangerous. Without careful use you can
1465 * easily destroy all your data.
1467 * @throws LibGuestFSException
1469 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1470 throws LibGuestFSException
1473 throw new LibGuestFSException ("sfdisk: handle is closed");
1474 _sfdisk (g, device, cyls, heads, sectors, lines);
1476 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1477 throws LibGuestFSException;
1482 * This call creates a file called "path". The contents of
1483 * the file is the string "content" (which can contain any
1484 * 8 bit data), with length "size".
1486 * As a special case, if "size" is 0 then the length is
1487 * calculated using "strlen" (so in this case the content
1488 * cannot contain embedded ASCII NULs).
1490 * Because of the message protocol, there is a transfer
1491 * limit of somewhere between 2MB and 4MB. To transfer
1492 * large files you should use FTP.
1494 * @throws LibGuestFSException
1496 public void write_file (String path, String content, int size)
1497 throws LibGuestFSException
1500 throw new LibGuestFSException ("write_file: handle is closed");
1501 _write_file (g, path, content, size);
1503 private native void _write_file (long g, String path, String content, int size)
1504 throws LibGuestFSException;
1507 * unmount a filesystem
1509 * This unmounts the given filesystem. The filesystem may
1510 * be specified either by its mountpoint (path) or the
1511 * device which contains the filesystem.
1513 * @throws LibGuestFSException
1515 public void umount (String pathordevice)
1516 throws LibGuestFSException
1519 throw new LibGuestFSException ("umount: handle is closed");
1520 _umount (g, pathordevice);
1522 private native void _umount (long g, String pathordevice)
1523 throws LibGuestFSException;
1526 * show mounted filesystems
1528 * This returns the list of currently mounted filesystems.
1529 * It returns the list of devices (eg. "/dev/sda1",
1532 * Some internal mounts are not shown.
1534 * @throws LibGuestFSException
1536 public String[] mounts ()
1537 throws LibGuestFSException
1540 throw new LibGuestFSException ("mounts: handle is closed");
1543 private native String[] _mounts (long g)
1544 throws LibGuestFSException;
1547 * unmount all filesystems
1549 * This unmounts all mounted filesystems.
1551 * Some internal mounts are not unmounted by this call.
1553 * @throws LibGuestFSException
1555 public void umount_all ()
1556 throws LibGuestFSException
1559 throw new LibGuestFSException ("umount_all: handle is closed");
1562 private native void _umount_all (long g)
1563 throws LibGuestFSException;
1566 * remove all LVM LVs, VGs and PVs
1568 * This command removes all LVM logical volumes, volume
1569 * groups and physical volumes.
1571 * This command is dangerous. Without careful use you can
1572 * easily destroy all your data.
1574 * @throws LibGuestFSException
1576 public void lvm_remove_all ()
1577 throws LibGuestFSException
1580 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1581 _lvm_remove_all (g);
1583 private native void _lvm_remove_all (long g)
1584 throws LibGuestFSException;
1587 * determine file type
1589 * This call uses the standard file(1) command to determine
1590 * the type or contents of the file. This also works on
1591 * devices, for example to find out whether a partition
1592 * contains a filesystem.
1594 * The exact command which runs is "file -bsL path". Note
1595 * in particular that the filename is not prepended to the
1596 * output (the "-b" option).
1598 * @throws LibGuestFSException
1600 public String file (String path)
1601 throws LibGuestFSException
1604 throw new LibGuestFSException ("file: handle is closed");
1605 return _file (g, path);
1607 private native String _file (long g, String path)
1608 throws LibGuestFSException;
1611 * run a command from the guest filesystem
1613 * This call runs a command from the guest filesystem. The
1614 * filesystem must be mounted, and must contain a
1615 * compatible operating system (ie. something Linux, with
1616 * the same or compatible processor architecture).
1618 * The single parameter is an argv-style list of arguments.
1619 * The first element is the name of the program to run.
1620 * Subsequent elements are parameters. The list must be
1621 * non-empty (ie. must contain a program name).
1623 * The $PATH environment variable will contain at least
1624 * "/usr/bin" and "/bin". If you require a program from
1625 * another location, you should provide the full path in
1626 * the first parameter.
1628 * Shared libraries and data files required by the program
1629 * must be available on filesystems which are mounted in
1630 * the correct places. It is the caller's responsibility to
1631 * ensure all filesystems that are needed are mounted at
1632 * the right locations.
1634 * @throws LibGuestFSException
1636 public String command (String[] arguments)
1637 throws LibGuestFSException
1640 throw new LibGuestFSException ("command: handle is closed");
1641 return _command (g, arguments);
1643 private native String _command (long g, String[] arguments)
1644 throws LibGuestFSException;
1647 * run a command, returning lines
1649 * This is the same as "g.command", but splits the result
1650 * into a list of lines.
1652 * @throws LibGuestFSException
1654 public String[] command_lines (String[] arguments)
1655 throws LibGuestFSException
1658 throw new LibGuestFSException ("command_lines: handle is closed");
1659 return _command_lines (g, arguments);
1661 private native String[] _command_lines (long g, String[] arguments)
1662 throws LibGuestFSException;
1665 * get file information
1667 * Returns file information for the given "path".
1669 * This is the same as the stat(2) system call.
1671 * @throws LibGuestFSException
1673 public Stat stat (String path)
1674 throws LibGuestFSException
1677 throw new LibGuestFSException ("stat: handle is closed");
1678 return _stat (g, path);
1680 private native Stat _stat (long g, String path)
1681 throws LibGuestFSException;
1684 * get file information for a symbolic link
1686 * Returns file information for the given "path".
1688 * This is the same as "g.stat" except that if "path" is a
1689 * symbolic link, then the link is stat-ed, not the file it
1692 * This is the same as the lstat(2) system call.
1694 * @throws LibGuestFSException
1696 public Stat lstat (String path)
1697 throws LibGuestFSException
1700 throw new LibGuestFSException ("lstat: handle is closed");
1701 return _lstat (g, path);
1703 private native Stat _lstat (long g, String path)
1704 throws LibGuestFSException;
1707 * get file system statistics
1709 * Returns file system statistics for any mounted file
1710 * system. "path" should be a file or directory in the
1711 * mounted file system (typically it is the mount point
1712 * itself, but it doesn't need to be).
1714 * This is the same as the statvfs(2) system call.
1716 * @throws LibGuestFSException
1718 public StatVFS statvfs (String path)
1719 throws LibGuestFSException
1722 throw new LibGuestFSException ("statvfs: handle is closed");
1723 return _statvfs (g, path);
1725 private native StatVFS _statvfs (long g, String path)
1726 throws LibGuestFSException;
1729 * get ext2/ext3/ext4 superblock details
1731 * This returns the contents of the ext2, ext3 or ext4
1732 * filesystem superblock on "device".
1734 * It is the same as running "tune2fs -l device". See
1735 * tune2fs(8) manpage for more details. The list of fields
1736 * returned isn't clearly defined, and depends on both the
1737 * version of "tune2fs" that libguestfs was built against,
1738 * and the filesystem itself.
1740 * @throws LibGuestFSException
1742 public HashMap<String,String> tune2fs_l (String device)
1743 throws LibGuestFSException
1746 throw new LibGuestFSException ("tune2fs_l: handle is closed");
1747 return _tune2fs_l (g, device);
1749 private native HashMap<String,String> _tune2fs_l (long g, String device)
1750 throws LibGuestFSException;
1753 * set block device to read-only
1755 * Sets the block device named "device" to read-only.
1757 * This uses the blockdev(8) command.
1759 * @throws LibGuestFSException
1761 public void blockdev_setro (String device)
1762 throws LibGuestFSException
1765 throw new LibGuestFSException ("blockdev_setro: handle is closed");
1766 _blockdev_setro (g, device);
1768 private native void _blockdev_setro (long g, String device)
1769 throws LibGuestFSException;
1772 * set block device to read-write
1774 * Sets the block device named "device" to read-write.
1776 * This uses the blockdev(8) command.
1778 * @throws LibGuestFSException
1780 public void blockdev_setrw (String device)
1781 throws LibGuestFSException
1784 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
1785 _blockdev_setrw (g, device);
1787 private native void _blockdev_setrw (long g, String device)
1788 throws LibGuestFSException;
1791 * is block device set to read-only
1793 * Returns a boolean indicating if the block device is
1794 * read-only (true if read-only, false if not).
1796 * This uses the blockdev(8) command.
1798 * @throws LibGuestFSException
1800 public boolean blockdev_getro (String device)
1801 throws LibGuestFSException
1804 throw new LibGuestFSException ("blockdev_getro: handle is closed");
1805 return _blockdev_getro (g, device);
1807 private native boolean _blockdev_getro (long g, String device)
1808 throws LibGuestFSException;
1811 * get sectorsize of block device
1813 * This returns the size of sectors on a block device.
1814 * Usually 512, but can be larger for modern devices.
1816 * (Note, this is not the size in sectors, use
1817 * "g.blockdev_getsz" for that).
1819 * This uses the blockdev(8) command.
1821 * @throws LibGuestFSException
1823 public int blockdev_getss (String device)
1824 throws LibGuestFSException
1827 throw new LibGuestFSException ("blockdev_getss: handle is closed");
1828 return _blockdev_getss (g, device);
1830 private native int _blockdev_getss (long g, String device)
1831 throws LibGuestFSException;
1834 * get blocksize of block device
1836 * This returns the block size of a device.
1838 * (Note this is different from both *size in blocks* and
1839 * *filesystem block size*).
1841 * This uses the blockdev(8) command.
1843 * @throws LibGuestFSException
1845 public int blockdev_getbsz (String device)
1846 throws LibGuestFSException
1849 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
1850 return _blockdev_getbsz (g, device);
1852 private native int _blockdev_getbsz (long g, String device)
1853 throws LibGuestFSException;
1856 * set blocksize of block device
1858 * This sets the block size of a device.
1860 * (Note this is different from both *size in blocks* and
1861 * *filesystem block size*).
1863 * This uses the blockdev(8) command.
1865 * @throws LibGuestFSException
1867 public void blockdev_setbsz (String device, int blocksize)
1868 throws LibGuestFSException
1871 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
1872 _blockdev_setbsz (g, device, blocksize);
1874 private native void _blockdev_setbsz (long g, String device, int blocksize)
1875 throws LibGuestFSException;
1878 * get total size of device in 512-byte sectors
1880 * This returns the size of the device in units of 512-byte
1881 * sectors (even if the sectorsize isn't 512 bytes ...
1884 * See also "g.blockdev_getss" for the real sector size of
1885 * the device, and "g.blockdev_getsize64" for the more
1886 * useful *size in bytes*.
1888 * This uses the blockdev(8) command.
1890 * @throws LibGuestFSException
1892 public long blockdev_getsz (String device)
1893 throws LibGuestFSException
1896 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
1897 return _blockdev_getsz (g, device);
1899 private native long _blockdev_getsz (long g, String device)
1900 throws LibGuestFSException;
1903 * get total size of device in bytes
1905 * This returns the size of the device in bytes.
1907 * See also "g.blockdev_getsz".
1909 * This uses the blockdev(8) command.
1911 * @throws LibGuestFSException
1913 public long blockdev_getsize64 (String device)
1914 throws LibGuestFSException
1917 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
1918 return _blockdev_getsize64 (g, device);
1920 private native long _blockdev_getsize64 (long g, String device)
1921 throws LibGuestFSException;
1924 * flush device buffers
1926 * This tells the kernel to flush internal buffers
1927 * associated with "device".
1929 * This uses the blockdev(8) command.
1931 * @throws LibGuestFSException
1933 public void blockdev_flushbufs (String device)
1934 throws LibGuestFSException
1937 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
1938 _blockdev_flushbufs (g, device);
1940 private native void _blockdev_flushbufs (long g, String device)
1941 throws LibGuestFSException;
1944 * reread partition table
1946 * Reread the partition table on "device".
1948 * This uses the blockdev(8) command.
1950 * @throws LibGuestFSException
1952 public void blockdev_rereadpt (String device)
1953 throws LibGuestFSException
1956 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
1957 _blockdev_rereadpt (g, device);
1959 private native void _blockdev_rereadpt (long g, String device)
1960 throws LibGuestFSException;
1963 * upload a file from the local machine
1965 * Upload local file "filename" to "remotefilename" on the
1968 * "filename" can also be a named pipe.
1970 * See also "g.download".
1972 * @throws LibGuestFSException
1974 public void upload (String filename, String remotefilename)
1975 throws LibGuestFSException
1978 throw new LibGuestFSException ("upload: handle is closed");
1979 _upload (g, filename, remotefilename);
1981 private native void _upload (long g, String filename, String remotefilename)
1982 throws LibGuestFSException;
1985 * download a file to the local machine
1987 * Download file "remotefilename" and save it as "filename"
1988 * on the local machine.
1990 * "filename" can also be a named pipe.
1992 * See also "g.upload", "g.cat".
1994 * @throws LibGuestFSException
1996 public void download (String remotefilename, String filename)
1997 throws LibGuestFSException
2000 throw new LibGuestFSException ("download: handle is closed");
2001 _download (g, remotefilename, filename);
2003 private native void _download (long g, String remotefilename, String filename)
2004 throws LibGuestFSException;
2007 * compute MD5, SHAx or CRC checksum of file
2009 * This call computes the MD5, SHAx or CRC checksum of the
2010 * file named "path".
2012 * The type of checksum to compute is given by the
2013 * "csumtype" parameter which must have one of the
2017 * Compute the cyclic redundancy check (CRC) specified
2018 * by POSIX for the "cksum" command.
2021 * Compute the MD5 hash (using the "md5sum" program).
2024 * Compute the SHA1 hash (using the "sha1sum" program).
2027 * Compute the SHA224 hash (using the "sha224sum"
2031 * Compute the SHA256 hash (using the "sha256sum"
2035 * Compute the SHA384 hash (using the "sha384sum"
2039 * Compute the SHA512 hash (using the "sha512sum"
2042 * The checksum is returned as a printable string.
2044 * @throws LibGuestFSException
2046 public String checksum (String csumtype, String path)
2047 throws LibGuestFSException
2050 throw new LibGuestFSException ("checksum: handle is closed");
2051 return _checksum (g, csumtype, path);
2053 private native String _checksum (long g, String csumtype, String path)
2054 throws LibGuestFSException;
2057 * unpack tarfile to directory
2059 * This command uploads and unpacks local file "tarfile"
2060 * (an *uncompressed* tar file) into "directory".
2062 * To upload a compressed tarball, use "g.tgz_in".
2064 * @throws LibGuestFSException
2066 public void tar_in (String tarfile, String directory)
2067 throws LibGuestFSException
2070 throw new LibGuestFSException ("tar_in: handle is closed");
2071 _tar_in (g, tarfile, directory);
2073 private native void _tar_in (long g, String tarfile, String directory)
2074 throws LibGuestFSException;
2077 * pack directory into tarfile
2079 * This command packs the contents of "directory" and
2080 * downloads it to local file "tarfile".
2082 * To download a compressed tarball, use "g.tgz_out".
2084 * @throws LibGuestFSException
2086 public void tar_out (String directory, String tarfile)
2087 throws LibGuestFSException
2090 throw new LibGuestFSException ("tar_out: handle is closed");
2091 _tar_out (g, directory, tarfile);
2093 private native void _tar_out (long g, String directory, String tarfile)
2094 throws LibGuestFSException;
2097 * unpack compressed tarball to directory
2099 * This command uploads and unpacks local file "tarball" (a
2100 * *gzip compressed* tar file) into "directory".
2102 * To upload an uncompressed tarball, use "g.tar_in".
2104 * @throws LibGuestFSException
2106 public void tgz_in (String tarball, String directory)
2107 throws LibGuestFSException
2110 throw new LibGuestFSException ("tgz_in: handle is closed");
2111 _tgz_in (g, tarball, directory);
2113 private native void _tgz_in (long g, String tarball, String directory)
2114 throws LibGuestFSException;
2117 * pack directory into compressed tarball
2119 * This command packs the contents of "directory" and
2120 * downloads it to local file "tarball".
2122 * To download an uncompressed tarball, use "g.tar_out".
2124 * @throws LibGuestFSException
2126 public void tgz_out (String directory, String tarball)
2127 throws LibGuestFSException
2130 throw new LibGuestFSException ("tgz_out: handle is closed");
2131 _tgz_out (g, directory, tarball);
2133 private native void _tgz_out (long g, String directory, String tarball)
2134 throws LibGuestFSException;
2137 * mount a guest disk, read-only
2139 * This is the same as the "g.mount" command, but it mounts
2140 * the filesystem with the read-only (*-o ro*) flag.
2142 * @throws LibGuestFSException
2144 public void mount_ro (String device, String mountpoint)
2145 throws LibGuestFSException
2148 throw new LibGuestFSException ("mount_ro: handle is closed");
2149 _mount_ro (g, device, mountpoint);
2151 private native void _mount_ro (long g, String device, String mountpoint)
2152 throws LibGuestFSException;
2155 * mount a guest disk with mount options
2157 * This is the same as the "g.mount" command, but it allows
2158 * you to set the mount options as for the mount(8) *-o*
2161 * @throws LibGuestFSException
2163 public void mount_options (String options, String device, String mountpoint)
2164 throws LibGuestFSException
2167 throw new LibGuestFSException ("mount_options: handle is closed");
2168 _mount_options (g, options, device, mountpoint);
2170 private native void _mount_options (long g, String options, String device, String mountpoint)
2171 throws LibGuestFSException;
2174 * mount a guest disk with mount options and vfstype
2176 * This is the same as the "g.mount" command, but it allows
2177 * you to set both the mount options and the vfstype as for
2178 * the mount(8) *-o* and *-t* flags.
2180 * @throws LibGuestFSException
2182 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2183 throws LibGuestFSException
2186 throw new LibGuestFSException ("mount_vfs: handle is closed");
2187 _mount_vfs (g, options, vfstype, device, mountpoint);
2189 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2190 throws LibGuestFSException;
2193 * debugging and internals
2195 * The "g.debug" command exposes some internals of
2196 * "guestfsd" (the guestfs daemon) that runs inside the
2199 * There is no comprehensive help for this command. You
2200 * have to look at the file "daemon/debug.c" in the
2201 * libguestfs source to find out what you can do.
2203 * @throws LibGuestFSException
2205 public String debug (String subcmd, String[] extraargs)
2206 throws LibGuestFSException
2209 throw new LibGuestFSException ("debug: handle is closed");
2210 return _debug (g, subcmd, extraargs);
2212 private native String _debug (long g, String subcmd, String[] extraargs)
2213 throws LibGuestFSException;
2216 * remove an LVM logical volume
2218 * Remove an LVM logical volume "device", where "device" is
2219 * the path to the LV, such as "/dev/VG/LV".
2221 * You can also remove all LVs in a volume group by
2222 * specifying the VG name, "/dev/VG".
2224 * @throws LibGuestFSException
2226 public void lvremove (String device)
2227 throws LibGuestFSException
2230 throw new LibGuestFSException ("lvremove: handle is closed");
2231 _lvremove (g, device);
2233 private native void _lvremove (long g, String device)
2234 throws LibGuestFSException;
2237 * remove an LVM volume group
2239 * Remove an LVM volume group "vgname", (for example "VG").
2241 * This also forcibly removes all logical volumes in the
2242 * volume group (if any).
2244 * @throws LibGuestFSException
2246 public void vgremove (String vgname)
2247 throws LibGuestFSException
2250 throw new LibGuestFSException ("vgremove: handle is closed");
2251 _vgremove (g, vgname);
2253 private native void _vgremove (long g, String vgname)
2254 throws LibGuestFSException;
2257 * remove an LVM physical volume
2259 * This wipes a physical volume "device" so that LVM will
2260 * no longer recognise it.
2262 * The implementation uses the "pvremove" command which
2263 * refuses to wipe physical volumes that contain any volume
2264 * groups, so you have to remove those first.
2266 * @throws LibGuestFSException
2268 public void pvremove (String device)
2269 throws LibGuestFSException
2272 throw new LibGuestFSException ("pvremove: handle is closed");
2273 _pvremove (g, device);
2275 private native void _pvremove (long g, String device)
2276 throws LibGuestFSException;
2279 * set the ext2/3/4 filesystem label
2281 * This sets the ext2/3/4 filesystem label of the
2282 * filesystem on "device" to "label". Filesystem labels are
2283 * limited to 16 characters.
2285 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2286 * return the existing label on a filesystem.
2288 * @throws LibGuestFSException
2290 public void set_e2label (String device, String label)
2291 throws LibGuestFSException
2294 throw new LibGuestFSException ("set_e2label: handle is closed");
2295 _set_e2label (g, device, label);
2297 private native void _set_e2label (long g, String device, String label)
2298 throws LibGuestFSException;
2301 * get the ext2/3/4 filesystem label
2303 * This returns the ext2/3/4 filesystem label of the
2304 * filesystem on "device".
2306 * @throws LibGuestFSException
2308 public String get_e2label (String device)
2309 throws LibGuestFSException
2312 throw new LibGuestFSException ("get_e2label: handle is closed");
2313 return _get_e2label (g, device);
2315 private native String _get_e2label (long g, String device)
2316 throws LibGuestFSException;
2319 * set the ext2/3/4 filesystem UUID
2321 * This sets the ext2/3/4 filesystem UUID of the filesystem
2322 * on "device" to "uuid". The format of the UUID and
2323 * alternatives such as "clear", "random" and "time" are
2324 * described in the tune2fs(8) manpage.
2326 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2327 * return the existing UUID of a filesystem.
2329 * @throws LibGuestFSException
2331 public void set_e2uuid (String device, String uuid)
2332 throws LibGuestFSException
2335 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2336 _set_e2uuid (g, device, uuid);
2338 private native void _set_e2uuid (long g, String device, String uuid)
2339 throws LibGuestFSException;
2342 * get the ext2/3/4 filesystem UUID
2344 * This returns the ext2/3/4 filesystem UUID of the
2345 * filesystem on "device".
2347 * @throws LibGuestFSException
2349 public String get_e2uuid (String device)
2350 throws LibGuestFSException
2353 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2354 return _get_e2uuid (g, device);
2356 private native String _get_e2uuid (long g, String device)
2357 throws LibGuestFSException;
2360 * run the filesystem checker
2362 * This runs the filesystem checker (fsck) on "device"
2363 * which should have filesystem type "fstype".
2365 * The returned integer is the status. See fsck(8) for the
2366 * list of status codes from "fsck".
2370 * * Multiple status codes can be summed together.
2372 * * A non-zero return code can mean "success", for
2373 * example if errors have been corrected on the
2376 * * Checking or repairing NTFS volumes is not supported
2379 * This command is entirely equivalent to running "fsck -a
2380 * -t fstype device".
2382 * @throws LibGuestFSException
2384 public int fsck (String fstype, String device)
2385 throws LibGuestFSException
2388 throw new LibGuestFSException ("fsck: handle is closed");
2389 return _fsck (g, fstype, device);
2391 private native int _fsck (long g, String fstype, String device)
2392 throws LibGuestFSException;
2395 * write zeroes to the device
2397 * This command writes zeroes over the first few blocks of
2400 * How many blocks are zeroed isn't specified (but it's
2401 * *not* enough to securely wipe the device). It should be
2402 * sufficient to remove any partition tables, filesystem
2403 * superblocks and so on.
2405 * @throws LibGuestFSException
2407 public void zero (String device)
2408 throws LibGuestFSException
2411 throw new LibGuestFSException ("zero: handle is closed");
2414 private native void _zero (long g, String device)
2415 throws LibGuestFSException;
2420 * This command installs GRUB (the Grand Unified
2421 * Bootloader) on "device", with the root directory being
2424 * @throws LibGuestFSException
2426 public void grub_install (String root, String device)
2427 throws LibGuestFSException
2430 throw new LibGuestFSException ("grub_install: handle is closed");
2431 _grub_install (g, root, device);
2433 private native void _grub_install (long g, String root, String device)
2434 throws LibGuestFSException;
2439 * This copies a file from "src" to "dest" where "dest" is
2440 * either a destination filename or destination directory.
2442 * @throws LibGuestFSException
2444 public void cp (String src, String dest)
2445 throws LibGuestFSException
2448 throw new LibGuestFSException ("cp: handle is closed");
2451 private native void _cp (long g, String src, String dest)
2452 throws LibGuestFSException;
2455 * copy a file or directory recursively
2457 * This copies a file or directory from "src" to "dest"
2458 * recursively using the "cp -a" command.
2460 * @throws LibGuestFSException
2462 public void cp_a (String src, String dest)
2463 throws LibGuestFSException
2466 throw new LibGuestFSException ("cp_a: handle is closed");
2467 _cp_a (g, src, dest);
2469 private native void _cp_a (long g, String src, String dest)
2470 throws LibGuestFSException;
2475 * This moves a file from "src" to "dest" where "dest" is
2476 * either a destination filename or destination directory.
2478 * @throws LibGuestFSException
2480 public void mv (String src, String dest)
2481 throws LibGuestFSException
2484 throw new LibGuestFSException ("mv: handle is closed");
2487 private native void _mv (long g, String src, String dest)
2488 throws LibGuestFSException;
2491 * drop kernel page cache, dentries and inodes
2493 * This instructs the guest kernel to drop its page cache,
2494 * and/or dentries and inode caches. The parameter
2495 * "whattodrop" tells the kernel what precisely to drop,
2496 * see <http://linux-mm.org/Drop_Caches>
2498 * Setting "whattodrop" to 3 should drop everything.
2500 * This automatically calls sync(2) before the operation,
2501 * so that the maximum guest memory is freed.
2503 * @throws LibGuestFSException
2505 public void drop_caches (int whattodrop)
2506 throws LibGuestFSException
2509 throw new LibGuestFSException ("drop_caches: handle is closed");
2510 _drop_caches (g, whattodrop);
2512 private native void _drop_caches (long g, int whattodrop)
2513 throws LibGuestFSException;