+ /**
+ * ping the guest daemon
+ * <p>
+ * This is a test probe into the guestfs daemon running
+ * inside the qemu subprocess. Calling this function checks
+ * that the daemon responds to the ping message, without
+ * affecting the daemon or attached block device(s) in any
+ * other way.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void ping_daemon ()
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("ping_daemon: handle is closed");
+ _ping_daemon (g);
+ }
+ private native void _ping_daemon (long g)
+ throws LibGuestFSException;
+
+ /**
+ * test if two files have equal contents
+ * <p>
+ * This compares the two files "file1" and "file2" and
+ * returns true if their content is exactly equal, or false
+ * otherwise.
+ * <p>
+ * The external cmp(1) program is used for the comparison.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public boolean equal (String file1, String file2)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("equal: handle is closed");
+ return _equal (g, file1, file2);
+ }
+ private native boolean _equal (long g, String file1, String file2)
+ throws LibGuestFSException;
+
+ /**
+ * print the printable strings in a file
+ * <p>
+ * This runs the strings(1) command on a file and returns
+ * the list of printable strings found.
+ * <p>
+ * Because of the message protocol, there is a transfer
+ * limit of somewhere between 2MB and 4MB. To transfer
+ * large files you should use FTP.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String[] strings (String path)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("strings: handle is closed");
+ return _strings (g, path);
+ }
+ private native String[] _strings (long g, String path)
+ throws LibGuestFSException;
+
+ /**
+ * print the printable strings in a file
+ * <p>
+ * This is like the "g.strings" command, but allows you to
+ * specify the encoding.
+ * <p>
+ * See the strings(1) manpage for the full list of
+ * encodings.
+ * <p>
+ * Commonly useful encodings are "l" (lower case L) which
+ * will show strings inside Windows/x86 files.
+ * <p>
+ * The returned strings are transcoded to UTF-8.
+ * <p>
+ * Because of the message protocol, there is a transfer
+ * limit of somewhere between 2MB and 4MB. To transfer
+ * large files you should use FTP.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String[] strings_e (String encoding, String path)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("strings_e: handle is closed");
+ return _strings_e (g, encoding, path);
+ }
+ private native String[] _strings_e (long g, String encoding, String path)
+ throws LibGuestFSException;
+
+ /**
+ * dump a file in hexadecimal
+ * <p>
+ * This runs "hexdump -C" on the given "path". The result
+ * is the human-readable, canonical hex dump of the file.
+ * <p>
+ * Because of the message protocol, there is a transfer
+ * limit of somewhere between 2MB and 4MB. To transfer
+ * large files you should use FTP.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String hexdump (String path)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("hexdump: handle is closed");
+ return _hexdump (g, path);
+ }
+ private native String _hexdump (long g, String path)
+ throws LibGuestFSException;
+
+ /**
+ * zero unused inodes and disk blocks on ext2/3 filesystem
+ * <p>
+ * This runs the *zerofree* program on "device". This
+ * program claims to zero unused inodes and disk blocks on
+ * an ext2/3 filesystem, thus making it possible to
+ * compress the filesystem more effectively.
+ * <p>
+ * You should not run this program if the filesystem is
+ * mounted.
+ * <p>
+ * It is possible that using this program can damage the
+ * filesystem or data on the filesystem.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void zerofree (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("zerofree: handle is closed");
+ _zerofree (g, device);
+ }
+ private native void _zerofree (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * resize an LVM physical volume
+ * <p>
+ * This resizes (expands or shrinks) an existing LVM
+ * physical volume to match the new size of the underlying
+ * device.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void pvresize (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("pvresize: handle is closed");
+ _pvresize (g, device);
+ }
+ private native void _pvresize (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * modify a single partition on a block device
+ * <p>
+ * This runs sfdisk(8) option to modify just the single
+ * partition "n" (note: "n" counts from 1).
+ * <p>
+ * For other parameters, see "g.sfdisk". You should usually
+ * pass 0 for the cyls/heads/sectors parameters.
+ * <p>
+ * This command is dangerous. Without careful use you can
+ * easily destroy all your data.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sfdisk_N: handle is closed");
+ _sfdisk_N (g, device, n, cyls, heads, sectors, line);
+ }
+ private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
+ throws LibGuestFSException;
+
+ /**
+ * display the partition table
+ * <p>
+ * This displays the partition table on "device", in the
+ * human-readable output of the sfdisk(8) command. It is
+ * not intended to be parsed.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String sfdisk_l (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sfdisk_l: handle is closed");
+ return _sfdisk_l (g, device);
+ }
+ private native String _sfdisk_l (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * display the kernel geometry
+ * <p>
+ * This displays the kernel's idea of the geometry of
+ * "device".
+ * <p>
+ * The result is in human-readable format, and not designed
+ * to be parsed.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String sfdisk_kernel_geometry (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
+ return _sfdisk_kernel_geometry (g, device);
+ }
+ private native String _sfdisk_kernel_geometry (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * display the disk geometry from the partition table
+ * <p>
+ * This displays the disk geometry of "device" read from
+ * the partition table. Especially in the case where the
+ * underlying block device has been resized, this can be
+ * different from the kernel's idea of the geometry (see
+ * "g.sfdisk_kernel_geometry").
+ * <p>
+ * The result is in human-readable format, and not designed
+ * to be parsed.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String sfdisk_disk_geometry (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
+ return _sfdisk_disk_geometry (g, device);
+ }
+ private native String _sfdisk_disk_geometry (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * activate or deactivate all volume groups
+ * <p>
+ * This command activates or (if "activate" is false)
+ * deactivates all logical volumes in all volume groups. If
+ * activated, then they are made known to the kernel, ie.
+ * they appear as "/dev/mapper" devices. If deactivated,
+ * then those devices disappear.
+ * <p>
+ * This command is the same as running "vgchange -a y|n"
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void vg_activate_all (boolean activate)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("vg_activate_all: handle is closed");
+ _vg_activate_all (g, activate);
+ }
+ private native void _vg_activate_all (long g, boolean activate)
+ throws LibGuestFSException;
+
+ /**
+ * activate or deactivate some volume groups
+ * <p>
+ * This command activates or (if "activate" is false)
+ * deactivates all logical volumes in the listed volume
+ * groups "volgroups". If activated, then they are made
+ * known to the kernel, ie. they appear as "/dev/mapper"
+ * devices. If deactivated, then those devices disappear.
+ * <p>
+ * This command is the same as running "vgchange -a y|n
+ * volgroups..."
+ * <p>
+ * Note that if "volgroups" is an empty list then all
+ * volume groups are activated or deactivated.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void vg_activate (boolean activate, String[] volgroups)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("vg_activate: handle is closed");
+ _vg_activate (g, activate, volgroups);
+ }
+ private native void _vg_activate (long g, boolean activate, String[] volgroups)
+ throws LibGuestFSException;
+
+ /**
+ * resize an LVM logical volume
+ * <p>
+ * This resizes (expands or shrinks) an existing LVM
+ * logical volume to "mbytes". When reducing, data in the
+ * reduced part is lost.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void lvresize (String device, int mbytes)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("lvresize: handle is closed");
+ _lvresize (g, device, mbytes);
+ }
+ private native void _lvresize (long g, String device, int mbytes)
+ throws LibGuestFSException;
+
+ /**
+ * resize an ext2/ext3 filesystem
+ * <p>
+ * This resizes an ext2 or ext3 filesystem to match the
+ * size of the underlying device.
+ * <p>
+ * *Note:* It is sometimes required that you run
+ * "g.e2fsck_f" on the "device" before calling this
+ * command. For unknown reasons "resize2fs" sometimes gives
+ * an error about this and sometimes not. In any case, it
+ * is always safe to call "g.e2fsck_f" before calling this
+ * function.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void resize2fs (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("resize2fs: handle is closed");
+ _resize2fs (g, device);
+ }
+ private native void _resize2fs (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * find all files and directories
+ * <p>
+ * This command lists out all files and directories,
+ * recursively, starting at "directory". It is essentially
+ * equivalent to running the shell command "find directory
+ * -print" but some post-processing happens on the output,
+ * described below.
+ * <p>
+ * This returns a list of strings *without any prefix*.
+ * Thus if the directory structure was:
+ * <p>
+ * /tmp/a
+ * /tmp/b
+ * /tmp/c/d
+ * <p>
+ * then the returned list from "g.find" "/tmp" would be 4
+ * elements:
+ * <p>
+ * a
+ * b
+ * c
+ * c/d
+ * <p>
+ * If "directory" is not a directory, then this command
+ * returns an error.
+ * <p>
+ * The returned list is sorted.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String[] find (String directory)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("find: handle is closed");
+ return _find (g, directory);
+ }
+ private native String[] _find (long g, String directory)
+ throws LibGuestFSException;
+
+ /**
+ * check an ext2/ext3 filesystem
+ * <p>
+ * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
+ * filesystem checker on "device", noninteractively ("-p"),
+ * even if the filesystem appears to be clean ("-f").
+ * <p>
+ * This command is only needed because of "g.resize2fs"
+ * (q.v.). Normally you should use "g.fsck".
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void e2fsck_f (String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("e2fsck_f: handle is closed");
+ _e2fsck_f (g, device);
+ }
+ private native void _e2fsck_f (long g, String device)
+ throws LibGuestFSException;
+
+ /**
+ * sleep for some seconds
+ * <p>
+ * Sleep for "secs" seconds.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void sleep (int secs)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sleep: handle is closed");
+ _sleep (g, secs);
+ }
+ private native void _sleep (long g, int secs)
+ throws LibGuestFSException;
+
+ /**
+ * probe NTFS volume
+ * <p>
+ * This command runs the ntfs-3g.probe(8) command which
+ * probes an NTFS "device" for mountability. (Not all NTFS
+ * volumes can be mounted read-write, and some cannot be
+ * mounted at all).
+ * <p>
+ * "rw" is a boolean flag. Set it to true if you want to
+ * test if the volume can be mounted read-write. Set it to
+ * false if you want to test if the volume can be mounted
+ * read-only.
+ * <p>
+ * The return value is an integer which 0 if the operation
+ * would succeed, or some non-zero value documented in the
+ * ntfs-3g.probe(8) manual page.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public int ntfs_3g_probe (boolean rw, String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
+ return _ntfs_3g_probe (g, rw, device);
+ }
+ private native int _ntfs_3g_probe (long g, boolean rw, String device)
+ throws LibGuestFSException;
+
+ /**
+ * run a command via the shell
+ * <p>
+ * This call runs a command from the guest filesystem via
+ * the guest's "/bin/sh".
+ * <p>
+ * This is like "g.command", but passes the command to:
+ * <p>
+ * /bin/sh -c "command"
+ * <p>
+ * Depending on the guest's shell, this usually results in
+ * wildcards being expanded, shell expressions being
+ * interpolated and so on.
+ * <p>
+ * All the provisos about "g.command" apply to this call.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String sh (String command)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sh: handle is closed");
+ return _sh (g, command);
+ }
+ private native String _sh (long g, String command)
+ throws LibGuestFSException;
+
+ /**
+ * run a command via the shell returning lines
+ * <p>
+ * This is the same as "g.sh", but splits the result into a
+ * list of lines.
+ * <p>
+ * See also: "g.command_lines"
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String[] sh_lines (String command)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("sh_lines: handle is closed");
+ return _sh_lines (g, command);
+ }
+ private native String[] _sh_lines (long g, String command)
+ throws LibGuestFSException;
+
+ /**
+ * expand a wildcard path
+ * <p>
+ * This command searches for all the pathnames matching
+ * "pattern" according to the wildcard expansion rules used
+ * by the shell.
+ * <p>
+ * If no paths match, then this returns an empty list
+ * (note: not an error).
+ * <p>
+ * It is just a wrapper around the C glob(3) function with
+ * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
+ * more details.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public String[] glob_expand (String pattern)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("glob_expand: handle is closed");
+ return _glob_expand (g, pattern);
+ }
+ private native String[] _glob_expand (long g, String pattern)
+ throws LibGuestFSException;
+