X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=java%2Fcom%2Fredhat%2Fet%2Flibguestfs%2FGuestFS.java;h=3cb1c7f38093d2ad6cd6af7e9410dfac5635d591;hp=844c3b33e30bca5d643f86698171d46dabbaa7f1;hb=0884d8bbae6d76a603ec1385ada2938f88981c5c;hpb=0703248d233744047515418893dac05ce013a642 diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index 844c3b3..3cb1c7f 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -81,15 +81,285 @@ public class GuestFS { close (); } +public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0: handle is closed"); + _test0 (g, str, optstr, strlist, b, integer, filein, fileout); + } + private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout) + throws LibGuestFSException; + +public int test0rint (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint: handle is closed"); + return _test0rint (g, val); + } + private native int _test0rint (long g, String val) + throws LibGuestFSException; + +public int test0rinterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rinterr: handle is closed"); + return _test0rinterr (g); + } + private native int _test0rinterr (long g) + throws LibGuestFSException; + +public long test0rint64 (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint64: handle is closed"); + return _test0rint64 (g, val); + } + private native long _test0rint64 (long g, String val) + throws LibGuestFSException; + +public long test0rint64err () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rint64err: handle is closed"); + return _test0rint64err (g); + } + private native long _test0rint64err (long g) + throws LibGuestFSException; + +public boolean test0rbool (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rbool: handle is closed"); + return _test0rbool (g, val); + } + private native boolean _test0rbool (long g, String val) + throws LibGuestFSException; + +public boolean test0rboolerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rboolerr: handle is closed"); + return _test0rboolerr (g); + } + private native boolean _test0rboolerr (long g) + throws LibGuestFSException; + +public String test0rconststring (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rconststring: handle is closed"); + return _test0rconststring (g, val); + } + private native String _test0rconststring (long g, String val) + throws LibGuestFSException; + +public String test0rconststringerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rconststringerr: handle is closed"); + return _test0rconststringerr (g); + } + private native String _test0rconststringerr (long g) + throws LibGuestFSException; + +public String test0rstring (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstring: handle is closed"); + return _test0rstring (g, val); + } + private native String _test0rstring (long g, String val) + throws LibGuestFSException; + +public String test0rstringerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringerr: handle is closed"); + return _test0rstringerr (g); + } + private native String _test0rstringerr (long g) + throws LibGuestFSException; + +public String[] test0rstringlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringlist: handle is closed"); + return _test0rstringlist (g, val); + } + private native String[] _test0rstringlist (long g, String val) + throws LibGuestFSException; + +public String[] test0rstringlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstringlisterr: handle is closed"); + return _test0rstringlisterr (g); + } + private native String[] _test0rstringlisterr (long g) + throws LibGuestFSException; + +public IntBool test0rintbool (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rintbool: handle is closed"); + return _test0rintbool (g, val); + } + private native IntBool _test0rintbool (long g, String val) + throws LibGuestFSException; + +public IntBool test0rintboolerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rintboolerr: handle is closed"); + return _test0rintboolerr (g); + } + private native IntBool _test0rintboolerr (long g) + throws LibGuestFSException; + +public PV[] test0rpvlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rpvlist: handle is closed"); + return _test0rpvlist (g, val); + } + private native PV[] _test0rpvlist (long g, String val) + throws LibGuestFSException; + +public PV[] test0rpvlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rpvlisterr: handle is closed"); + return _test0rpvlisterr (g); + } + private native PV[] _test0rpvlisterr (long g) + throws LibGuestFSException; + +public VG[] test0rvglist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rvglist: handle is closed"); + return _test0rvglist (g, val); + } + private native VG[] _test0rvglist (long g, String val) + throws LibGuestFSException; + +public VG[] test0rvglisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rvglisterr: handle is closed"); + return _test0rvglisterr (g); + } + private native VG[] _test0rvglisterr (long g) + throws LibGuestFSException; + +public LV[] test0rlvlist (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rlvlist: handle is closed"); + return _test0rlvlist (g, val); + } + private native LV[] _test0rlvlist (long g, String val) + throws LibGuestFSException; + +public LV[] test0rlvlisterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rlvlisterr: handle is closed"); + return _test0rlvlisterr (g); + } + private native LV[] _test0rlvlisterr (long g) + throws LibGuestFSException; + +public Stat test0rstat (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstat: handle is closed"); + return _test0rstat (g, val); + } + private native Stat _test0rstat (long g, String val) + throws LibGuestFSException; + +public Stat test0rstaterr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstaterr: handle is closed"); + return _test0rstaterr (g); + } + private native Stat _test0rstaterr (long g) + throws LibGuestFSException; + +public StatVFS test0rstatvfs (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstatvfs: handle is closed"); + return _test0rstatvfs (g, val); + } + private native StatVFS _test0rstatvfs (long g, String val) + throws LibGuestFSException; + +public StatVFS test0rstatvfserr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rstatvfserr: handle is closed"); + return _test0rstatvfserr (g); + } + private native StatVFS _test0rstatvfserr (long g) + throws LibGuestFSException; + +public HashMap test0rhashtable (String val) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rhashtable: handle is closed"); + return _test0rhashtable (g, val); + } + private native HashMap _test0rhashtable (long g, String val) + throws LibGuestFSException; + +public HashMap test0rhashtableerr () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("test0rhashtableerr: handle is closed"); + return _test0rhashtableerr (g); + } + private native HashMap _test0rhashtableerr (long g) + throws LibGuestFSException; + /** * launch the qemu subprocess - * + *

* Internally libguestfs is implemented by running a * virtual machine using qemu(1). - * + *

* You should call this after configuring the handle (eg. * adding drives) but before performing any actions. - * + *

* @throws LibGuestFSException */ public void launch () @@ -104,13 +374,13 @@ public class GuestFS { /** * wait until the qemu subprocess launches - * + *

* Internally libguestfs is implemented by running a * virtual machine using qemu(1). - * + *

* You should call this after "g.launch" to wait for the * launch to complete. - * + *

* @throws LibGuestFSException */ public void wait_ready () @@ -125,10 +395,10 @@ public class GuestFS { /** * kill the qemu subprocess - * + *

* This kills the qemu subprocess. You should never need to * call this. - * + *

* @throws LibGuestFSException */ public void kill_subprocess () @@ -143,22 +413,28 @@ public class GuestFS { /** * add an image to examine or modify - * + *

* This function adds a virtual machine disk image * "filename" to the guest. The first time you call this * function, the disk appears as IDE disk 0 ("/dev/sda") in * the guest, the second time as "/dev/sdb", and so on. - * + *

* You don't necessarily need to be root when using * libguestfs. However you obviously do need sufficient * permissions to access the filename for whatever * operations you want to perform (ie. read access if you * just want to read the image or write access if you want * to modify the image). - * + *

* This is equivalent to the qemu parameter "-drive - * file=filename". - * + * file=filename,cache=off". + *

+ * Note that this call checks for the existence of + * "filename". This stops you from specifying other types + * of drive which are supported by qemu such as "nbd:" and + * "http:" URLs. To specify those, use the general + * "g.config" call instead. + *

* @throws LibGuestFSException */ public void add_drive (String filename) @@ -173,13 +449,19 @@ public class GuestFS { /** * add a CD-ROM disk image to examine - * + *

* This function adds a virtual CD-ROM disk image to the * guest. - * + *

* This is equivalent to the qemu parameter "-cdrom * filename". - * + *

+ * Note that this call checks for the existence of + * "filename". This stops you from specifying other types + * of drive which are supported by qemu such as "nbd:" and + * "http:" URLs. To specify those, use the general + * "g.config" call instead. + *

* @throws LibGuestFSException */ public void add_cdrom (String filename) @@ -193,19 +475,53 @@ public class GuestFS { throws LibGuestFSException; /** + * add a drive in snapshot mode (read-only) + *

+ * This adds a drive in snapshot mode, making it + * effectively read-only. + *

+ * Note that writes to the device are allowed, and will be + * seen for the duration of the guestfs handle, but they + * are written to a temporary file which is discarded as + * soon as the guestfs handle is closed. We don't currently + * have any method to enable changes to be committed, + * although qemu can support this. + *

+ * This is equivalent to the qemu parameter "-drive + * file=filename,snapshot=on". + *

+ * Note that this call checks for the existence of + * "filename". This stops you from specifying other types + * of drive which are supported by qemu such as "nbd:" and + * "http:" URLs. To specify those, use the general + * "g.config" call instead. + *

+ * @throws LibGuestFSException + */ + public void add_drive_ro (String filename) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("add_drive_ro: handle is closed"); + _add_drive_ro (g, filename); + } + private native void _add_drive_ro (long g, String filename) + throws LibGuestFSException; + + /** * add qemu parameters - * + *

* This can be used to add arbitrary qemu command line * parameters of the form "-param value". Actually it's not * quite arbitrary - we prevent you from setting some * parameters which would interfere with parameters that we * use. - * + *

* The first character of "param" string must be a "-" * (dash). - * + *

* "value" can be NULL. - * + *

* @throws LibGuestFSException */ public void config (String qemuparam, String qemuvalue) @@ -220,22 +536,18 @@ public class GuestFS { /** * set the qemu binary - * + *

* Set the qemu binary that we will use. - * + *

* The default is chosen when the library was compiled by * the configure script. - * + *

* You can also override this by setting the * "LIBGUESTFS_QEMU" environment variable. - * - * The string "qemu" is stashed in the libguestfs handle, - * so the caller must make sure it remains valid for the - * lifetime of the handle. - * + *

* Setting "qemu" to "NULL" restores the default qemu * binary. - * + *

* @throws LibGuestFSException */ public void set_qemu (String qemu) @@ -250,12 +562,12 @@ public class GuestFS { /** * get the qemu binary - * + *

* Return the current qemu binary. - * + *

* This is always non-NULL. If it wasn't set already, then * this will return the default qemu binary name. - * + *

* @throws LibGuestFSException */ public String get_qemu () @@ -270,19 +582,15 @@ public class GuestFS { /** * set the search path - * + *

* Set the path that libguestfs searches for kernel and * initrd.img. - * + *

* The default is "$libdir/guestfs" unless overridden by * setting "LIBGUESTFS_PATH" environment variable. - * - * The string "path" is stashed in the libguestfs handle, - * so the caller must make sure it remains valid for the - * lifetime of the handle. - * + *

* Setting "path" to "NULL" restores the default path. - * + *

* @throws LibGuestFSException */ public void set_path (String path) @@ -297,12 +605,12 @@ public class GuestFS { /** * get the search path - * + *

* Return the current search path. - * + *

* This is always non-NULL. If it wasn't set already, then * this will return the default path. - * + *

* @throws LibGuestFSException */ public String get_path () @@ -316,16 +624,60 @@ public class GuestFS { throws LibGuestFSException; /** + * add options to kernel command line + *

+ * This function is used to add additional options to the + * guest kernel command line. + *

+ * The default is "NULL" unless overridden by setting + * "LIBGUESTFS_APPEND" environment variable. + *

+ * Setting "append" to "NULL" means *no* additional options + * are passed (libguestfs always adds a few of its own). + *

+ * @throws LibGuestFSException + */ + public void set_append (String append) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("set_append: handle is closed"); + _set_append (g, append); + } + private native void _set_append (long g, String append) + throws LibGuestFSException; + + /** + * get the additional kernel options + *

+ * Return the additional kernel options which are added to + * the guest kernel command line. + *

+ * If "NULL" then no options are added. + *

+ * @throws LibGuestFSException + */ + public String get_append () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("get_append: handle is closed"); + return _get_append (g); + } + private native String _get_append (long g) + throws LibGuestFSException; + + /** * set autosync mode - * + *

* If "autosync" is true, this enables autosync. Libguestfs * will make a best effort attempt to run "g.umount_all" * followed by "g.sync" when the handle is closed (also if * the program exits without closing handles). - * + *

* This is disabled by default (except in guestfish where * it is enabled by default). - * + *

* @throws LibGuestFSException */ public void set_autosync (boolean autosync) @@ -340,9 +692,9 @@ public class GuestFS { /** * get autosync mode - * + *

* Get the autosync flag. - * + *

* @throws LibGuestFSException */ public boolean get_autosync () @@ -357,13 +709,13 @@ public class GuestFS { /** * set verbose mode - * + *

* If "verbose" is true, this turns on verbose messages (to * "stderr"). - * + *

* Verbose messages are disabled unless the environment * variable "LIBGUESTFS_DEBUG" is defined and set to 1. - * + *

* @throws LibGuestFSException */ public void set_verbose (boolean verbose) @@ -378,9 +730,9 @@ public class GuestFS { /** * get verbose mode - * + *

* This returns the verbose messages flag. - * + *

* @throws LibGuestFSException */ public boolean get_verbose () @@ -395,12 +747,12 @@ public class GuestFS { /** * is ready to accept commands - * + *

* This returns true iff this handle is ready to accept * commands (in the "READY" state). - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public boolean is_ready () @@ -415,12 +767,12 @@ public class GuestFS { /** * is in configuration state - * + *

* This returns true iff this handle is being configured * (in the "CONFIG" state). - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public boolean is_config () @@ -435,12 +787,12 @@ public class GuestFS { /** * is launching subprocess - * + *

* This returns true iff this handle is launching the * subprocess (in the "LAUNCHING" state). - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public boolean is_launching () @@ -455,12 +807,12 @@ public class GuestFS { /** * is busy processing a command - * + *

* This returns true iff this handle is busy processing a * command (in the "BUSY" state). - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public boolean is_busy () @@ -475,13 +827,13 @@ public class GuestFS { /** * get the current state - * + *

* This returns the current state as an opaque integer. * This is only useful for printing debug and internal * error messages. - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public int get_state () @@ -496,12 +848,12 @@ public class GuestFS { /** * set state to busy - * + *

* This sets the state to "BUSY". This is only used when * implementing actions using the low-level API. - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public void set_busy () @@ -516,12 +868,12 @@ public class GuestFS { /** * set state to ready - * + *

* This sets the state to "READY". This is only used when * implementing actions using the low-level API. - * + *

* For more information on states, see guestfs(3). - * + *

* @throws LibGuestFSException */ public void set_ready () @@ -535,26 +887,98 @@ public class GuestFS { throws LibGuestFSException; /** + * leave the busy state + *

+ * This sets the state to "READY", or if in "CONFIG" then + * it leaves the state as is. This is only used when + * implementing actions using the low-level API. + *

+ * For more information on states, see guestfs(3). + *

+ * @throws LibGuestFSException + */ + public void end_busy () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("end_busy: handle is closed"); + _end_busy (g); + } + private native void _end_busy (long g) + throws LibGuestFSException; + + /** + * set memory allocated to the qemu subprocess + *

+ * This sets the memory size in megabytes allocated to the + * qemu subprocess. This only has any effect if called + * before "g.launch". + *

+ * You can also change this by setting the environment + * variable "LIBGUESTFS_MEMSIZE" before the handle is + * created. + *

+ * For more information on the architecture of libguestfs, + * see guestfs(3). + *

+ * @throws LibGuestFSException + */ + public void set_memsize (int memsize) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("set_memsize: handle is closed"); + _set_memsize (g, memsize); + } + private native void _set_memsize (long g, int memsize) + throws LibGuestFSException; + + /** + * get memory allocated to the qemu subprocess + *

+ * This gets the memory size in megabytes allocated to the + * qemu subprocess. + *

+ * If "g.set_memsize" was not called on this handle, and if + * "LIBGUESTFS_MEMSIZE" was not set, then this returns the + * compiled-in default value for memsize. + *

+ * For more information on the architecture of libguestfs, + * see guestfs(3). + *

+ * @throws LibGuestFSException + */ + public int get_memsize () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("get_memsize: handle is closed"); + return _get_memsize (g); + } + private native int _get_memsize (long g) + throws LibGuestFSException; + + /** * mount a guest disk at a position in the filesystem - * + *

* Mount a guest disk at a position in the filesystem. * Block devices are named "/dev/sda", "/dev/sdb" and so * on, as they were added to the guest. If those block * devices contain partitions, they will have the usual * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style * names can be used. - * + *

* The rules are the same as for mount(2): A filesystem * must first be mounted on "/" before others can be * mounted. Other filesystems can only be mounted on * directories which already exist. - * + *

* The mounted filesystem is writable, if we have * sufficient permissions on the underlying device. - * + *

* The filesystem options "sync" and "noatime" are set with * this call, in order to improve reliability. - * + *

* @throws LibGuestFSException */ public void mount (String device, String mountpoint) @@ -569,13 +993,13 @@ public class GuestFS { /** * sync disks, writes are flushed through to the disk image - * + *

* This syncs the disk, so that any writes are flushed * through to the underlying disk image. - * + *

* You should always call this if you have modified a disk * image, before closing the handle. - * + *

* @throws LibGuestFSException */ public void sync () @@ -590,11 +1014,11 @@ public class GuestFS { /** * update file timestamps or create a new file - * + *

* Touch acts like the touch(1) command. It can be used to * update the timestamps on a file, or, if the file does * not exist, to create a new zero-length file. - * + *

* @throws LibGuestFSException */ public void touch (String path) @@ -609,19 +1033,19 @@ public class GuestFS { /** * list the contents of a file - * + *

* Return the contents of the file named "path". - * + *

* Note that this function cannot correctly handle binary * files (specifically, files containing "\0" character * which is treated as end of string). For those you need * to use the "g.download" function which has a more * complex interface. - * + *

* Because of the message protocol, there is a transfer * limit of somewhere between 2MB and 4MB. To transfer * large files you should use FTP. - * + *

* @throws LibGuestFSException */ public String cat (String path) @@ -636,14 +1060,14 @@ public class GuestFS { /** * list the files in a directory (long format) - * + *

* List the files in "directory" (relative to the root * directory, there is no cwd) in the format of 'ls -la'. - * + *

* This command is mostly useful for interactive sessions. * It is *not* intended that you try to parse the output * string. - * + *

* @throws LibGuestFSException */ public String ll (String directory) @@ -658,14 +1082,14 @@ public class GuestFS { /** * list the files in a directory - * + *

* List the files in "directory" (relative to the root * directory, there is no cwd). The '.' and '..' entries * are not returned, but hidden files are shown. - * + *

* This command is mostly useful for interactive sessions. * Programs should probably use "g.readdir" instead. - * + *

* @throws LibGuestFSException */ public String[] ls (String directory) @@ -680,11 +1104,11 @@ public class GuestFS { /** * list the block devices - * + *

* List all the block devices. - * + *

* The full block device names are returned, eg. "/dev/sda" - * + *

* @throws LibGuestFSException */ public String[] list_devices () @@ -699,15 +1123,15 @@ public class GuestFS { /** * list the partitions - * + *

* List all the partitions detected on all block devices. - * + *

* The full partition device names are returned, eg. * "/dev/sda1" - * + *

* This does not return logical volumes. For that you will * need to call "g.lvs". - * + *

* @throws LibGuestFSException */ public String[] list_partitions () @@ -722,15 +1146,15 @@ public class GuestFS { /** * list the LVM physical volumes (PVs) - * + *

* List all the physical volumes detected. This is the * equivalent of the pvs(8) command. - * + *

* This returns a list of just the device names that * contain PVs (eg. "/dev/sda2"). - * + *

* See also "g.pvs_full". - * + *

* @throws LibGuestFSException */ public String[] pvs () @@ -745,15 +1169,15 @@ public class GuestFS { /** * list the LVM volume groups (VGs) - * + *

* List all the volumes groups detected. This is the * equivalent of the vgs(8) command. - * + *

* This returns a list of just the volume group names that * were detected (eg. "VolGroup00"). - * + *

* See also "g.vgs_full". - * + *

* @throws LibGuestFSException */ public String[] vgs () @@ -768,15 +1192,15 @@ public class GuestFS { /** * list the LVM logical volumes (LVs) - * + *

* List all the logical volumes detected. This is the * equivalent of the lvs(8) command. - * + *

* This returns a list of the logical volume device names * (eg. "/dev/VolGroup00/LogVol00"). - * + *

* See also "g.lvs_full". - * + *

* @throws LibGuestFSException */ public String[] lvs () @@ -791,11 +1215,11 @@ public class GuestFS { /** * list the LVM physical volumes (PVs) - * + *

* List all the physical volumes detected. This is the * equivalent of the pvs(8) command. The "full" version * includes all fields. - * + *

* @throws LibGuestFSException */ public PV[] pvs_full () @@ -810,11 +1234,11 @@ public class GuestFS { /** * list the LVM volume groups (VGs) - * + *

* List all the volumes groups detected. This is the * equivalent of the vgs(8) command. The "full" version * includes all fields. - * + *

* @throws LibGuestFSException */ public VG[] vgs_full () @@ -829,11 +1253,11 @@ public class GuestFS { /** * list the LVM logical volumes (LVs) - * + *

* List all the logical volumes detected. This is the * equivalent of the lvs(8) command. The "full" version * includes all fields. - * + *

* @throws LibGuestFSException */ public LV[] lvs_full () @@ -848,19 +1272,19 @@ public class GuestFS { /** * read file as lines - * + *

* Return the contents of the file named "path". - * + *

* The file contents are returned as a list of lines. * Trailing "LF" and "CRLF" character sequences are *not* * returned. - * + *

* Note that this function cannot correctly handle binary * files (specifically, files containing "\0" character * which is treated as end of line). For those you need to * use the "g.read_file" function which has a more complex * interface. - * + *

* @throws LibGuestFSException */ public String[] read_lines (String path) @@ -875,45 +1299,45 @@ public class GuestFS { /** * create a new Augeas handle - * + *

* Create a new Augeas handle for editing configuration * files. If there was any previous Augeas handle * associated with this guestfs session, then it is closed. - * + *

* You must call this before using any other "g.aug_*" * commands. - * + *

* "root" is the filesystem root. "root" must not be NULL, * use "/" instead. - * + *

* The flags are the same as the flags defined in * , the logical *or* of the following integers: - * + *

* "AUG_SAVE_BACKUP" = 1 * Keep the original file with a ".augsave" extension. - * + *

* "AUG_SAVE_NEWFILE" = 2 * Save changes into a file with extension ".augnew", * and do not overwrite original. Overrides * "AUG_SAVE_BACKUP". - * + *

* "AUG_TYPE_CHECK" = 4 * Typecheck lenses (can be expensive). - * + *

* "AUG_NO_STDINC" = 8 * Do not use standard load path for modules. - * + *

* "AUG_SAVE_NOOP" = 16 * Make save a no-op, just record what would have been * changed. - * + *

* "AUG_NO_LOAD" = 32 * Do not load the tree in "g.aug_init". - * + *

* To close the handle, you can call "g.aug_close". - * + *

* To find out more about Augeas, see . - * + *

* @throws LibGuestFSException */ public void aug_init (String root, int flags) @@ -928,12 +1352,12 @@ public class GuestFS { /** * close the current Augeas handle - * + *

* Close the current Augeas handle and free up any * resources used by it. After calling this, you have to * call "g.aug_init" again before you can use any other * Augeas functions. - * + *

* @throws LibGuestFSException */ public void aug_close () @@ -948,15 +1372,15 @@ public class GuestFS { /** * define an Augeas variable - * + *

* Defines an Augeas variable "name" whose value is the * result of evaluating "expr". If "expr" is NULL, then * "name" is undefined. - * + *

* On success this returns the number of nodes in "expr", * or 0 if "expr" evaluates to something which is not a * nodeset. - * + *

* @throws LibGuestFSException */ public int aug_defvar (String name, String expr) @@ -971,19 +1395,19 @@ public class GuestFS { /** * define an Augeas node - * + *

* Defines a variable "name" whose value is the result of * evaluating "expr". - * + *

* If "expr" evaluates to an empty nodeset, a node is * created, equivalent to calling "g.aug_set" "expr", * "value". "name" will be the nodeset containing that * single node. - * + *

* On success this returns a pair containing the number of * nodes in the nodeset, and a boolean flag if a node was * created. - * + *

* @throws LibGuestFSException */ public IntBool aug_defnode (String name, String expr, String val) @@ -998,10 +1422,10 @@ public class GuestFS { /** * look up the value of an Augeas path - * + *

* Look up the value associated with "path". If "path" * matches exactly one node, the "value" is returned. - * + *

* @throws LibGuestFSException */ public String aug_get (String path) @@ -1016,9 +1440,9 @@ public class GuestFS { /** * set Augeas path to value - * + *

* Set the value associated with "path" to "value". - * + *

* @throws LibGuestFSException */ public void aug_set (String path, String val) @@ -1033,15 +1457,15 @@ public class GuestFS { /** * insert a sibling Augeas node - * + *

* Create a new sibling "label" for "path", inserting it * into the tree before or after "path" (depending on the * boolean flag "before"). - * + *

* "path" must match exactly one existing node in the tree, * and "label" must be a label, ie. not contain "/", "*" or * end with a bracketed index "[N]". - * + *

* @throws LibGuestFSException */ public void aug_insert (String path, String label, boolean before) @@ -1056,12 +1480,12 @@ public class GuestFS { /** * remove an Augeas path - * + *

* Remove "path" and all of its children. - * + *

* On success this returns the number of entries which were * removed. - * + *

* @throws LibGuestFSException */ public int aug_rm (String path) @@ -1076,10 +1500,10 @@ public class GuestFS { /** * move Augeas node - * + *

* Move the node "src" to "dest". "src" must match exactly * one node. "dest" is overwritten if it exists. - * + *

* @throws LibGuestFSException */ public void aug_mv (String src, String dest) @@ -1094,11 +1518,11 @@ public class GuestFS { /** * return Augeas nodes which match path - * + *

* Returns a list of paths which match the path expression * "path". The returned paths are sufficiently qualified so * that they match exactly one node in the current tree. - * + *

* @throws LibGuestFSException */ public String[] aug_match (String path) @@ -1113,12 +1537,12 @@ public class GuestFS { /** * write all pending Augeas changes to disk - * + *

* This writes all pending changes to disk. - * + *

* The flags which were passed to "g.aug_init" affect * exactly how files are saved. - * + *

* @throws LibGuestFSException */ public void aug_save () @@ -1133,12 +1557,12 @@ public class GuestFS { /** * load files into the tree - * + *

* Load files into the tree. - * + *

* See "aug_load" in the Augeas documentation for the full * gory details. - * + *

* @throws LibGuestFSException */ public void aug_load () @@ -1153,11 +1577,11 @@ public class GuestFS { /** * list Augeas nodes under a path - * + *

* This is just a shortcut for listing "g.aug_match" * "path/*" and sorting the resulting nodes into * alphabetical order. - * + *

* @throws LibGuestFSException */ public String[] aug_ls (String path) @@ -1172,9 +1596,9 @@ public class GuestFS { /** * remove a file - * + *

* Remove the single file "path". - * + *

* @throws LibGuestFSException */ public void rm (String path) @@ -1189,9 +1613,9 @@ public class GuestFS { /** * remove a directory - * + *

* Remove the single directory "path". - * + *

* @throws LibGuestFSException */ public void rmdir (String path) @@ -1206,11 +1630,11 @@ public class GuestFS { /** * remove a file or directory recursively - * + *

* Remove the file or directory "path", recursively * removing the contents if its a directory. This is like * the "rm -rf" shell command. - * + *

* @throws LibGuestFSException */ public void rm_rf (String path) @@ -1225,9 +1649,9 @@ public class GuestFS { /** * create a directory - * + *

* Create a directory named "path". - * + *

* @throws LibGuestFSException */ public void mkdir (String path) @@ -1242,11 +1666,11 @@ public class GuestFS { /** * create a directory and parents - * + *

* Create a directory named "path", creating any parent * directories as necessary. This is like the "mkdir -p" * shell command. - * + *

* @throws LibGuestFSException */ public void mkdir_p (String path) @@ -1261,10 +1685,10 @@ public class GuestFS { /** * change file mode - * + *

* Change the mode (permissions) of "path" to "mode". Only * numeric modes are supported. - * + *

* @throws LibGuestFSException */ public void chmod (int mode, String path) @@ -1279,14 +1703,14 @@ public class GuestFS { /** * change file owner and group - * + *

* Change the file owner to "owner" and group to "group". - * + *

* Only numeric uid and gid are supported. If you want to * use names, you will need to locate and parse the * password file yourself (Augeas support makes this * relatively easy). - * + *

* @throws LibGuestFSException */ public void chown (int owner, int group, String path) @@ -1301,12 +1725,12 @@ public class GuestFS { /** * test if file or directory exists - * + *

* This returns "true" if and only if there is a file, * directory (or anything) with the given "path" name. - * + *

* See also "g.is_file", "g.is_dir", "g.stat". - * + *

* @throws LibGuestFSException */ public boolean exists (String path) @@ -1321,13 +1745,13 @@ public class GuestFS { /** * test if file exists - * + *

* This returns "true" if and only if there is a file with * the given "path" name. Note that it returns false for * other objects like directories. - * + *

* See also "g.stat". - * + *

* @throws LibGuestFSException */ public boolean is_file (String path) @@ -1342,13 +1766,13 @@ public class GuestFS { /** * test if file exists - * + *

* This returns "true" if and only if there is a directory * with the given "path" name. Note that it returns false * for other objects like files. - * + *

* See also "g.stat". - * + *

* @throws LibGuestFSException */ public boolean is_dir (String path) @@ -1363,11 +1787,11 @@ public class GuestFS { /** * create an LVM physical volume - * + *

* This creates an LVM physical volume on the named * "device", where "device" should usually be a partition * name such as "/dev/sda1". - * + *

* @throws LibGuestFSException */ public void pvcreate (String device) @@ -1382,10 +1806,10 @@ public class GuestFS { /** * create an LVM volume group - * + *

* This creates an LVM volume group called "volgroup" from * the non-empty list of physical volumes "physvols". - * + *

* @throws LibGuestFSException */ public void vgcreate (String volgroup, String[] physvols) @@ -1400,10 +1824,10 @@ public class GuestFS { /** * create an LVM volume group - * + *

* This creates an LVM volume group called "logvol" on the * volume group "volgroup", with "size" megabytes. - * + *

* @throws LibGuestFSException */ public void lvcreate (String logvol, String volgroup, int mbytes) @@ -1418,11 +1842,11 @@ public class GuestFS { /** * make a filesystem - * + *

* This creates a filesystem on "device" (usually a - * partition of LVM logical volume). The filesystem type is + * partition or LVM logical volume). The filesystem type is * "fstype", for example "ext3". - * + *

* @throws LibGuestFSException */ public void mkfs (String fstype, String device) @@ -1437,13 +1861,13 @@ public class GuestFS { /** * create partitions on a block device - * + *

* This is a direct interface to the sfdisk(8) program for * creating partitions on block devices. - * + *

* "device" should be a block device, for example * "/dev/sda". - * + *

* "cyls", "heads" and "sectors" are the number of * cylinders, heads and sectors on the device, which are * passed directly to sfdisk as the *-C*, *-H* and *-S* @@ -1453,17 +1877,19 @@ public class GuestFS { * (floppy-sized) disks, sfdisk (or rather, the kernel) * cannot work out the right geometry and you will need to * tell it. - * + *

* "lines" is a list of lines that we feed to "sfdisk". For * more information refer to the sfdisk(8) manpage. - * + *

* To create a single partition occupying the whole disk, * you would pass "lines" as a single element list, when * the single element being the string "," (comma). - * + *

+ * See also: "g.sfdisk_l", "g.sfdisk_N" + *

* This command is dangerous. Without careful use you can * easily destroy all your data. - * + *

* @throws LibGuestFSException */ public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines) @@ -1478,19 +1904,24 @@ public class GuestFS { /** * create a file - * + *

* This call creates a file called "path". The contents of * the file is the string "content" (which can contain any * 8 bit data), with length "size". - * + *

* As a special case, if "size" is 0 then the length is * calculated using "strlen" (so in this case the content * cannot contain embedded ASCII NULs). - * + *

+ * *NB.* Owing to a bug, writing content containing ASCII + * NUL characters does *not* work, even if the length is + * specified. We hope to resolve this bug in a future + * version. In the meantime use "g.upload". + *

* Because of the message protocol, there is a transfer * limit of somewhere between 2MB and 4MB. To transfer * large files you should use FTP. - * + *

* @throws LibGuestFSException */ public void write_file (String path, String content, int size) @@ -1505,11 +1936,11 @@ public class GuestFS { /** * unmount a filesystem - * + *

* This unmounts the given filesystem. The filesystem may * be specified either by its mountpoint (path) or the * device which contains the filesystem. - * + *

* @throws LibGuestFSException */ public void umount (String pathordevice) @@ -1524,13 +1955,13 @@ public class GuestFS { /** * show mounted filesystems - * + *

* This returns the list of currently mounted filesystems. * It returns the list of devices (eg. "/dev/sda1", * "/dev/VG/LV"). - * + *

* Some internal mounts are not shown. - * + *

* @throws LibGuestFSException */ public String[] mounts () @@ -1545,11 +1976,11 @@ public class GuestFS { /** * unmount all filesystems - * + *

* This unmounts all mounted filesystems. - * + *

* Some internal mounts are not unmounted by this call. - * + *

* @throws LibGuestFSException */ public void umount_all () @@ -1564,13 +1995,13 @@ public class GuestFS { /** * remove all LVM LVs, VGs and PVs - * + *

* This command removes all LVM logical volumes, volume * groups and physical volumes. - * + *

* This command is dangerous. Without careful use you can * easily destroy all your data. - * + *

* @throws LibGuestFSException */ public void lvm_remove_all () @@ -1585,16 +2016,16 @@ public class GuestFS { /** * determine file type - * + *

* This call uses the standard file(1) command to determine * the type or contents of the file. This also works on * devices, for example to find out whether a partition * contains a filesystem. - * + *

* The exact command which runs is "file -bsL path". Note * in particular that the filename is not prepended to the * output (the "-b" option). - * + *

* @throws LibGuestFSException */ public String file (String path) @@ -1609,28 +2040,41 @@ public class GuestFS { /** * run a command from the guest filesystem - * + *

* This call runs a command from the guest filesystem. The * filesystem must be mounted, and must contain a * compatible operating system (ie. something Linux, with * the same or compatible processor architecture). - * + *

* The single parameter is an argv-style list of arguments. * The first element is the name of the program to run. * Subsequent elements are parameters. The list must be - * non-empty (ie. must contain a program name). - * + * non-empty (ie. must contain a program name). Note that + * the command runs directly, and is *not* invoked via the + * shell (see "g.sh"). + *

+ * The return value is anything printed to *stdout* by the + * command. + *

+ * If the command returns a non-zero exit status, then this + * function returns an error message. The error message + * string is the content of *stderr* from the command. + *

* The $PATH environment variable will contain at least * "/usr/bin" and "/bin". If you require a program from * another location, you should provide the full path in * the first parameter. - * + *

* Shared libraries and data files required by the program * must be available on filesystems which are mounted in * the correct places. It is the caller's responsibility to * ensure all filesystems that are needed are mounted at * the right locations. - * + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

* @throws LibGuestFSException */ public String command (String[] arguments) @@ -1645,10 +2089,16 @@ public class GuestFS { /** * run a command, returning lines - * + *

* This is the same as "g.command", but splits the result * into a list of lines. - * + *

+ * See also: "g.sh_lines" + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

* @throws LibGuestFSException */ public String[] command_lines (String[] arguments) @@ -1663,11 +2113,11 @@ public class GuestFS { /** * get file information - * + *

* Returns file information for the given "path". - * + *

* This is the same as the stat(2) system call. - * + *

* @throws LibGuestFSException */ public Stat stat (String path) @@ -1682,15 +2132,15 @@ public class GuestFS { /** * get file information for a symbolic link - * + *

* Returns file information for the given "path". - * + *

* This is the same as "g.stat" except that if "path" is a * symbolic link, then the link is stat-ed, not the file it * refers to. - * + *

* This is the same as the lstat(2) system call. - * + *

* @throws LibGuestFSException */ public Stat lstat (String path) @@ -1705,14 +2155,14 @@ public class GuestFS { /** * get file system statistics - * + *

* Returns file system statistics for any mounted file * system. "path" should be a file or directory in the * mounted file system (typically it is the mount point * itself, but it doesn't need to be). - * + *

* This is the same as the statvfs(2) system call. - * + *

* @throws LibGuestFSException */ public StatVFS statvfs (String path) @@ -1727,16 +2177,16 @@ public class GuestFS { /** * get ext2/ext3/ext4 superblock details - * + *

* This returns the contents of the ext2, ext3 or ext4 * filesystem superblock on "device". - * + *

* It is the same as running "tune2fs -l device". See * tune2fs(8) manpage for more details. The list of fields * returned isn't clearly defined, and depends on both the * version of "tune2fs" that libguestfs was built against, * and the filesystem itself. - * + *

* @throws LibGuestFSException */ public HashMap tune2fs_l (String device) @@ -1751,11 +2201,11 @@ public class GuestFS { /** * set block device to read-only - * + *

* Sets the block device named "device" to read-only. - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public void blockdev_setro (String device) @@ -1770,11 +2220,11 @@ public class GuestFS { /** * set block device to read-write - * + *

* Sets the block device named "device" to read-write. - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public void blockdev_setrw (String device) @@ -1789,12 +2239,12 @@ public class GuestFS { /** * is block device set to read-only - * + *

* Returns a boolean indicating if the block device is * read-only (true if read-only, false if not). - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public boolean blockdev_getro (String device) @@ -1809,15 +2259,15 @@ public class GuestFS { /** * get sectorsize of block device - * + *

* This returns the size of sectors on a block device. * Usually 512, but can be larger for modern devices. - * + *

* (Note, this is not the size in sectors, use * "g.blockdev_getsz" for that). - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public int blockdev_getss (String device) @@ -1832,14 +2282,14 @@ public class GuestFS { /** * get blocksize of block device - * + *

* This returns the block size of a device. - * + *

* (Note this is different from both *size in blocks* and * *filesystem block size*). - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public int blockdev_getbsz (String device) @@ -1854,14 +2304,14 @@ public class GuestFS { /** * set blocksize of block device - * + *

* This sets the block size of a device. - * + *

* (Note this is different from both *size in blocks* and * *filesystem block size*). - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public void blockdev_setbsz (String device, int blocksize) @@ -1876,17 +2326,17 @@ public class GuestFS { /** * get total size of device in 512-byte sectors - * + *

* This returns the size of the device in units of 512-byte * sectors (even if the sectorsize isn't 512 bytes ... * weird). - * + *

* See also "g.blockdev_getss" for the real sector size of * the device, and "g.blockdev_getsize64" for the more * useful *size in bytes*. - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public long blockdev_getsz (String device) @@ -1901,13 +2351,13 @@ public class GuestFS { /** * get total size of device in bytes - * + *

* This returns the size of the device in bytes. - * + *

* See also "g.blockdev_getsz". - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public long blockdev_getsize64 (String device) @@ -1922,12 +2372,12 @@ public class GuestFS { /** * flush device buffers - * + *

* This tells the kernel to flush internal buffers * associated with "device". - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public void blockdev_flushbufs (String device) @@ -1942,11 +2392,11 @@ public class GuestFS { /** * reread partition table - * + *

* Reread the partition table on "device". - * + *

* This uses the blockdev(8) command. - * + *

* @throws LibGuestFSException */ public void blockdev_rereadpt (String device) @@ -1961,14 +2411,14 @@ public class GuestFS { /** * upload a file from the local machine - * + *

* Upload local file "filename" to "remotefilename" on the * filesystem. - * + *

* "filename" can also be a named pipe. - * + *

* See also "g.download". - * + *

* @throws LibGuestFSException */ public void upload (String filename, String remotefilename) @@ -1983,14 +2433,14 @@ public class GuestFS { /** * download a file to the local machine - * + *

* Download file "remotefilename" and save it as "filename" * on the local machine. - * + *

* "filename" can also be a named pipe. - * + *

* See also "g.upload", "g.cat". - * + *

* @throws LibGuestFSException */ public void download (String remotefilename, String filename) @@ -2005,42 +2455,42 @@ public class GuestFS { /** * compute MD5, SHAx or CRC checksum of file - * + *

* This call computes the MD5, SHAx or CRC checksum of the * file named "path". - * + *

* The type of checksum to compute is given by the * "csumtype" parameter which must have one of the * following values: - * + *

* "crc" * Compute the cyclic redundancy check (CRC) specified * by POSIX for the "cksum" command. - * + *

* "md5" * Compute the MD5 hash (using the "md5sum" program). - * + *

* "sha1" * Compute the SHA1 hash (using the "sha1sum" program). - * + *

* "sha224" * Compute the SHA224 hash (using the "sha224sum" * program). - * + *

* "sha256" * Compute the SHA256 hash (using the "sha256sum" * program). - * + *

* "sha384" * Compute the SHA384 hash (using the "sha384sum" * program). - * + *

* "sha512" * Compute the SHA512 hash (using the "sha512sum" * program). - * + *

* The checksum is returned as a printable string. - * + *

* @throws LibGuestFSException */ public String checksum (String csumtype, String path) @@ -2055,12 +2505,12 @@ public class GuestFS { /** * unpack tarfile to directory - * + *

* This command uploads and unpacks local file "tarfile" * (an *uncompressed* tar file) into "directory". - * + *

* To upload a compressed tarball, use "g.tgz_in". - * + *

* @throws LibGuestFSException */ public void tar_in (String tarfile, String directory) @@ -2075,12 +2525,12 @@ public class GuestFS { /** * pack directory into tarfile - * + *

* This command packs the contents of "directory" and * downloads it to local file "tarfile". - * + *

* To download a compressed tarball, use "g.tgz_out". - * + *

* @throws LibGuestFSException */ public void tar_out (String directory, String tarfile) @@ -2095,12 +2545,12 @@ public class GuestFS { /** * unpack compressed tarball to directory - * + *

* This command uploads and unpacks local file "tarball" (a * *gzip compressed* tar file) into "directory". - * + *

* To upload an uncompressed tarball, use "g.tar_in". - * + *

* @throws LibGuestFSException */ public void tgz_in (String tarball, String directory) @@ -2115,12 +2565,12 @@ public class GuestFS { /** * pack directory into compressed tarball - * + *

* This command packs the contents of "directory" and * downloads it to local file "tarball". - * + *

* To download an uncompressed tarball, use "g.tar_out". - * + *

* @throws LibGuestFSException */ public void tgz_out (String directory, String tarball) @@ -2135,10 +2585,10 @@ public class GuestFS { /** * mount a guest disk, read-only - * + *

* This is the same as the "g.mount" command, but it mounts * the filesystem with the read-only (*-o ro*) flag. - * + *

* @throws LibGuestFSException */ public void mount_ro (String device, String mountpoint) @@ -2153,11 +2603,11 @@ public class GuestFS { /** * mount a guest disk with mount options - * + *

* This is the same as the "g.mount" command, but it allows * you to set the mount options as for the mount(8) *-o* * flag. - * + *

* @throws LibGuestFSException */ public void mount_options (String options, String device, String mountpoint) @@ -2172,11 +2622,11 @@ public class GuestFS { /** * mount a guest disk with mount options and vfstype - * + *

* This is the same as the "g.mount" command, but it allows * you to set both the mount options and the vfstype as for * the mount(8) *-o* and *-t* flags. - * + *

* @throws LibGuestFSException */ public void mount_vfs (String options, String vfstype, String device, String mountpoint) @@ -2191,15 +2641,15 @@ public class GuestFS { /** * debugging and internals - * + *

* The "g.debug" command exposes some internals of * "guestfsd" (the guestfs daemon) that runs inside the * qemu subprocess. - * + *

* There is no comprehensive help for this command. You * have to look at the file "daemon/debug.c" in the * libguestfs source to find out what you can do. - * + *

* @throws LibGuestFSException */ public String debug (String subcmd, String[] extraargs) @@ -2214,13 +2664,13 @@ public class GuestFS { /** * remove an LVM logical volume - * + *

* Remove an LVM logical volume "device", where "device" is * the path to the LV, such as "/dev/VG/LV". - * + *

* You can also remove all LVs in a volume group by * specifying the VG name, "/dev/VG". - * + *

* @throws LibGuestFSException */ public void lvremove (String device) @@ -2235,12 +2685,12 @@ public class GuestFS { /** * remove an LVM volume group - * + *

* Remove an LVM volume group "vgname", (for example "VG"). - * + *

* This also forcibly removes all logical volumes in the * volume group (if any). - * + *

* @throws LibGuestFSException */ public void vgremove (String vgname) @@ -2255,14 +2705,14 @@ public class GuestFS { /** * remove an LVM physical volume - * + *

* This wipes a physical volume "device" so that LVM will * no longer recognise it. - * + *

* The implementation uses the "pvremove" command which * refuses to wipe physical volumes that contain any volume * groups, so you have to remove those first. - * + *

* @throws LibGuestFSException */ public void pvremove (String device) @@ -2277,14 +2727,14 @@ public class GuestFS { /** * set the ext2/3/4 filesystem label - * + *

* This sets the ext2/3/4 filesystem label of the * filesystem on "device" to "label". Filesystem labels are * limited to 16 characters. - * + *

* You can use either "g.tune2fs_l" or "g.get_e2label" to * return the existing label on a filesystem. - * + *

* @throws LibGuestFSException */ public void set_e2label (String device, String label) @@ -2299,10 +2749,10 @@ public class GuestFS { /** * get the ext2/3/4 filesystem label - * + *

* This returns the ext2/3/4 filesystem label of the * filesystem on "device". - * + *

* @throws LibGuestFSException */ public String get_e2label (String device) @@ -2317,15 +2767,15 @@ public class GuestFS { /** * set the ext2/3/4 filesystem UUID - * + *

* This sets the ext2/3/4 filesystem UUID of the filesystem * on "device" to "uuid". The format of the UUID and * alternatives such as "clear", "random" and "time" are * described in the tune2fs(8) manpage. - * + *

* You can use either "g.tune2fs_l" or "g.get_e2uuid" to * return the existing UUID of a filesystem. - * + *

* @throws LibGuestFSException */ public void set_e2uuid (String device, String uuid) @@ -2340,10 +2790,10 @@ public class GuestFS { /** * get the ext2/3/4 filesystem UUID - * + *

* This returns the ext2/3/4 filesystem UUID of the * filesystem on "device". - * + *

* @throws LibGuestFSException */ public String get_e2uuid (String device) @@ -2358,18 +2808,27 @@ public class GuestFS { /** * run the filesystem checker - * + *

* This runs the filesystem checker (fsck) on "device" * which should have filesystem type "fstype". - * + *

* The returned integer is the status. See fsck(8) for the - * list of status codes from "fsck", and note that multiple - * status codes can be summed together. - * - * It is entirely equivalent to running "fsck -a -t fstype - * device". Note that checking or repairing NTFS volumes is - * not supported (by linux-ntfs). - * + * list of status codes from "fsck". + *

+ * Notes: + *

+ * * Multiple status codes can be summed together. + *

+ * * A non-zero return code can mean "success", for + * example if errors have been corrected on the + * filesystem. + *

+ * * Checking or repairing NTFS volumes is not supported + * (by linux-ntfs). + *

+ * This command is entirely equivalent to running "fsck -a + * -t fstype device". + *

* @throws LibGuestFSException */ public int fsck (String fstype, String device) @@ -2382,4 +2841,1213 @@ public class GuestFS { private native int _fsck (long g, String fstype, String device) throws LibGuestFSException; + /** + * write zeroes to the device + *

+ * This command writes zeroes over the first few blocks of + * "device". + *

+ * How many blocks are zeroed isn't specified (but it's + * *not* enough to securely wipe the device). It should be + * sufficient to remove any partition tables, filesystem + * superblocks and so on. + *

+ * See also: "g.scrub_device". + *

+ * @throws LibGuestFSException + */ + public void zero (String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("zero: handle is closed"); + _zero (g, device); + } + private native void _zero (long g, String device) + throws LibGuestFSException; + + /** + * install GRUB + *

+ * This command installs GRUB (the Grand Unified + * Bootloader) on "device", with the root directory being + * "root". + *

+ * @throws LibGuestFSException + */ + public void grub_install (String root, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("grub_install: handle is closed"); + _grub_install (g, root, device); + } + private native void _grub_install (long g, String root, String device) + throws LibGuestFSException; + + /** + * copy a file + *

+ * This copies a file from "src" to "dest" where "dest" is + * either a destination filename or destination directory. + *

+ * @throws LibGuestFSException + */ + public void cp (String src, String dest) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("cp: handle is closed"); + _cp (g, src, dest); + } + private native void _cp (long g, String src, String dest) + throws LibGuestFSException; + + /** + * copy a file or directory recursively + *

+ * This copies a file or directory from "src" to "dest" + * recursively using the "cp -a" command. + *

+ * @throws LibGuestFSException + */ + public void cp_a (String src, String dest) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("cp_a: handle is closed"); + _cp_a (g, src, dest); + } + private native void _cp_a (long g, String src, String dest) + throws LibGuestFSException; + + /** + * move a file + *

+ * This moves a file from "src" to "dest" where "dest" is + * either a destination filename or destination directory. + *

+ * @throws LibGuestFSException + */ + public void mv (String src, String dest) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mv: handle is closed"); + _mv (g, src, dest); + } + private native void _mv (long g, String src, String dest) + throws LibGuestFSException; + + /** + * drop kernel page cache, dentries and inodes + *

+ * This instructs the guest kernel to drop its page cache, + * and/or dentries and inode caches. The parameter + * "whattodrop" tells the kernel what precisely to drop, + * see + *

+ * Setting "whattodrop" to 3 should drop everything. + *

+ * This automatically calls sync(2) before the operation, + * so that the maximum guest memory is freed. + *

+ * @throws LibGuestFSException + */ + public void drop_caches (int whattodrop) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("drop_caches: handle is closed"); + _drop_caches (g, whattodrop); + } + private native void _drop_caches (long g, int whattodrop) + throws LibGuestFSException; + + /** + * return kernel messages + *

+ * This returns the kernel messages ("dmesg" output) from + * the guest kernel. This is sometimes useful for extended + * debugging of problems. + *

+ * Another way to get the same information is to enable + * verbose messages with "g.set_verbose" or by setting the + * environment variable "LIBGUESTFS_DEBUG=1" before running + * the program. + *

+ * @throws LibGuestFSException + */ + public String dmesg () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("dmesg: handle is closed"); + return _dmesg (g); + } + private native String _dmesg (long g) + throws LibGuestFSException; + + /** + * ping the guest daemon + *

+ * 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. + *

+ * @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 + *

+ * This compares the two files "file1" and "file2" and + * returns true if their content is exactly equal, or false + * otherwise. + *

+ * The external cmp(1) program is used for the comparison. + *

+ * @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 + *

+ * This runs the strings(1) command on a file and returns + * the list of printable strings found. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @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 + *

+ * This is like the "g.strings" command, but allows you to + * specify the encoding. + *

+ * See the strings(1) manpage for the full list of + * encodings. + *

+ * Commonly useful encodings are "l" (lower case L) which + * will show strings inside Windows/x86 files. + *

+ * The returned strings are transcoded to UTF-8. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @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 + *

+ * This runs "hexdump -C" on the given "path". The result + * is the human-readable, canonical hex dump of the file. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @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 + *

+ * 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. + *

+ * You should not run this program if the filesystem is + * mounted. + *

+ * It is possible that using this program can damage the + * filesystem or data on the filesystem. + *

+ * @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 + *

+ * This resizes (expands or shrinks) an existing LVM + * physical volume to match the new size of the underlying + * device. + *

+ * @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 + *

+ * This runs sfdisk(8) option to modify just the single + * partition "n" (note: "n" counts from 1). + *

+ * For other parameters, see "g.sfdisk". You should usually + * pass 0 for the cyls/heads/sectors parameters. + *

+ * This command is dangerous. Without careful use you can + * easily destroy all your data. + *

+ * @throws LibGuestFSException + */ + public void sfdisk_N (String device, int partnum, 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, partnum, cyls, heads, sectors, line); + } + private native void _sfdisk_N (long g, String device, int partnum, int cyls, int heads, int sectors, String line) + throws LibGuestFSException; + + /** + * display the partition table + *

+ * This displays the partition table on "device", in the + * human-readable output of the sfdisk(8) command. It is + * not intended to be parsed. + *

+ * @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 + *

+ * This displays the kernel's idea of the geometry of + * "device". + *

+ * The result is in human-readable format, and not designed + * to be parsed. + *

+ * @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 + *

+ * 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"). + *

+ * The result is in human-readable format, and not designed + * to be parsed. + *

+ * @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 + *

+ * 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. + *

+ * This command is the same as running "vgchange -a y|n" + *

+ * @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 + *

+ * 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. + *

+ * This command is the same as running "vgchange -a y|n + * volgroups..." + *

+ * Note that if "volgroups" is an empty list then all + * volume groups are activated or deactivated. + *

+ * @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 + *

+ * This resizes (expands or shrinks) an existing LVM + * logical volume to "mbytes". When reducing, data in the + * reduced part is lost. + *

+ * @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 + *

+ * This resizes an ext2 or ext3 filesystem to match the + * size of the underlying device. + *

+ * *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. + *

+ * @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 + *

+ * 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. + *

+ * This returns a list of strings *without any prefix*. + * Thus if the directory structure was: + *

+ * /tmp/a + * /tmp/b + * /tmp/c/d + *

+ * then the returned list from "g.find" "/tmp" would be 4 + * elements: + *

+ * a + * b + * c + * c/d + *

+ * If "directory" is not a directory, then this command + * returns an error. + *

+ * The returned list is sorted. + *

+ * @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 + *

+ * 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"). + *

+ * This command is only needed because of "g.resize2fs" + * (q.v.). Normally you should use "g.fsck". + *

+ * @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 + *

+ * Sleep for "secs" seconds. + *

+ * @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 + *

+ * 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). + *

+ * "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. + *

+ * 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. + *

+ * @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 + *

+ * This call runs a command from the guest filesystem via + * the guest's "/bin/sh". + *

+ * This is like "g.command", but passes the command to: + *

+ * /bin/sh -c "command" + *

+ * Depending on the guest's shell, this usually results in + * wildcards being expanded, shell expressions being + * interpolated and so on. + *

+ * All the provisos about "g.command" apply to this call. + *

+ * @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 + *

+ * This is the same as "g.sh", but splits the result into a + * list of lines. + *

+ * See also: "g.command_lines" + *

+ * @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 + *

+ * This command searches for all the pathnames matching + * "pattern" according to the wildcard expansion rules used + * by the shell. + *

+ * If no paths match, then this returns an empty list + * (note: not an error). + *

+ * It is just a wrapper around the C glob(3) function with + * flags "GLOB_MARK|GLOB_BRACE". See that manual page for + * more details. + *

+ * @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; + + /** + * scrub (securely wipe) a device + *

+ * This command writes patterns over "device" to make data + * retrieval more difficult. + *

+ * It is an interface to the scrub(1) program. See that + * manual page for more details. + *

+ * This command is dangerous. Without careful use you can + * easily destroy all your data. + *

+ * @throws LibGuestFSException + */ + public void scrub_device (String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("scrub_device: handle is closed"); + _scrub_device (g, device); + } + private native void _scrub_device (long g, String device) + throws LibGuestFSException; + + /** + * scrub (securely wipe) a file + *

+ * This command writes patterns over a file to make data + * retrieval more difficult. + *

+ * The file is *removed* after scrubbing. + *

+ * It is an interface to the scrub(1) program. See that + * manual page for more details. + *

+ * @throws LibGuestFSException + */ + public void scrub_file (String file) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("scrub_file: handle is closed"); + _scrub_file (g, file); + } + private native void _scrub_file (long g, String file) + throws LibGuestFSException; + + /** + * scrub (securely wipe) free space + *

+ * This command creates the directory "dir" and then fills + * it with files until the filesystem is full, and scrubs + * the files as for "g.scrub_file", and deletes them. The + * intention is to scrub any free space on the partition + * containing "dir". + *

+ * It is an interface to the scrub(1) program. See that + * manual page for more details. + *

+ * @throws LibGuestFSException + */ + public void scrub_freespace (String dir) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("scrub_freespace: handle is closed"); + _scrub_freespace (g, dir); + } + private native void _scrub_freespace (long g, String dir) + throws LibGuestFSException; + + /** + * create a temporary directory + *

+ * This command creates a temporary directory. The + * "template" parameter should be a full pathname for the + * temporary directory name with the final six characters + * being "XXXXXX". + *

+ * For example: "/tmp/myprogXXXXXX" or + * "/Temp/myprogXXXXXX", the second one being suitable for + * Windows filesystems. + *

+ * The name of the temporary directory that was created is + * returned. + *

+ * The temporary directory is created with mode 0700 and is + * owned by root. + *

+ * The caller is responsible for deleting the temporary + * directory and its contents after use. + *

+ * See also: mkdtemp(3) + *

+ * @throws LibGuestFSException + */ + public String mkdtemp (String template) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkdtemp: handle is closed"); + return _mkdtemp (g, template); + } + private native String _mkdtemp (long g, String template) + throws LibGuestFSException; + + /** + * count lines in a file + *

+ * This command counts the lines in a file, using the "wc + * -l" external command. + *

+ * @throws LibGuestFSException + */ + public int wc_l (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("wc_l: handle is closed"); + return _wc_l (g, path); + } + private native int _wc_l (long g, String path) + throws LibGuestFSException; + + /** + * count words in a file + *

+ * This command counts the words in a file, using the "wc + * -w" external command. + *

+ * @throws LibGuestFSException + */ + public int wc_w (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("wc_w: handle is closed"); + return _wc_w (g, path); + } + private native int _wc_w (long g, String path) + throws LibGuestFSException; + + /** + * count characters in a file + *

+ * This command counts the characters in a file, using the + * "wc -c" external command. + *

+ * @throws LibGuestFSException + */ + public int wc_c (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("wc_c: handle is closed"); + return _wc_c (g, path); + } + private native int _wc_c (long g, String path) + throws LibGuestFSException; + + /** + * return first 10 lines of a file + *

+ * This command returns up to the first 10 lines of a file + * as a list of strings. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @throws LibGuestFSException + */ + public String[] head (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("head: handle is closed"); + return _head (g, path); + } + private native String[] _head (long g, String path) + throws LibGuestFSException; + + /** + * return first N lines of a file + *

+ * If the parameter "nrlines" is a positive number, this + * returns the first "nrlines" lines of the file "path". + *

+ * If the parameter "nrlines" is a negative number, this + * returns lines from the file "path", excluding the last + * "nrlines" lines. + *

+ * If the parameter "nrlines" is zero, this returns an + * empty list. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @throws LibGuestFSException + */ + public String[] head_n (int nrlines, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("head_n: handle is closed"); + return _head_n (g, nrlines, path); + } + private native String[] _head_n (long g, int nrlines, String path) + throws LibGuestFSException; + + /** + * return last 10 lines of a file + *

+ * This command returns up to the last 10 lines of a file + * as a list of strings. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @throws LibGuestFSException + */ + public String[] tail (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("tail: handle is closed"); + return _tail (g, path); + } + private native String[] _tail (long g, String path) + throws LibGuestFSException; + + /** + * return last N lines of a file + *

+ * If the parameter "nrlines" is a positive number, this + * returns the last "nrlines" lines of the file "path". + *

+ * If the parameter "nrlines" is a negative number, this + * returns lines from the file "path", starting with the + * "-nrlines"th line. + *

+ * If the parameter "nrlines" is zero, this returns an + * empty list. + *

+ * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + *

+ * @throws LibGuestFSException + */ + public String[] tail_n (int nrlines, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("tail_n: handle is closed"); + return _tail_n (g, nrlines, path); + } + private native String[] _tail_n (long g, int nrlines, String path) + throws LibGuestFSException; + + /** + * report file system disk space usage + *

+ * This command runs the "df" command to report disk space + * used. + *

+ * This command is mostly useful for interactive sessions. + * It is *not* intended that you try to parse the output + * string. Use "statvfs" from programs. + *

+ * @throws LibGuestFSException + */ + public String df () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("df: handle is closed"); + return _df (g); + } + private native String _df (long g) + throws LibGuestFSException; + + /** + * report file system disk space usage (human readable) + *

+ * This command runs the "df -h" command to report disk + * space used in human-readable format. + *

+ * This command is mostly useful for interactive sessions. + * It is *not* intended that you try to parse the output + * string. Use "statvfs" from programs. + *

+ * @throws LibGuestFSException + */ + public String df_h () + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("df_h: handle is closed"); + return _df_h (g); + } + private native String _df_h (long g) + throws LibGuestFSException; + + /** + * estimate file space usage + *

+ * This command runs the "du -s" command to estimate file + * space usage for "path". + *

+ * "path" can be a file or a directory. If "path" is a + * directory then the estimate includes the contents of the + * directory and all subdirectories (recursively). + *

+ * The result is the estimated size in *kilobytes* (ie. + * units of 1024 bytes). + *

+ * @throws LibGuestFSException + */ + public long du (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("du: handle is closed"); + return _du (g, path); + } + private native long _du (long g, String path) + throws LibGuestFSException; + + /** + * list files in an initrd + *

+ * This command lists out files contained in an initrd. + *

+ * The files are listed without any initial "/" character. + * The files are listed in the order they appear (not + * necessarily alphabetical). Directory names are listed as + * separate items. + *

+ * Old Linux kernels (2.4 and earlier) used a compressed + * ext2 filesystem as initrd. We *only* support the newer + * initramfs format (compressed cpio files). + *

+ * @throws LibGuestFSException + */ + public String[] initrd_list (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("initrd_list: handle is closed"); + return _initrd_list (g, path); + } + private native String[] _initrd_list (long g, String path) + throws LibGuestFSException; + + /** + * mount a file using the loop device + *

+ * This command lets you mount "file" (a filesystem image + * in a file) on a mount point. It is entirely equivalent + * to the command "mount -o loop file mountpoint". + *

+ * @throws LibGuestFSException + */ + public void mount_loop (String file, String mountpoint) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mount_loop: handle is closed"); + _mount_loop (g, file, mountpoint); + } + private native void _mount_loop (long g, String file, String mountpoint) + throws LibGuestFSException; + + /** + * create a swap partition + *

+ * Create a swap partition on "device". + *

+ * @throws LibGuestFSException + */ + public void mkswap (String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap: handle is closed"); + _mkswap (g, device); + } + private native void _mkswap (long g, String device) + throws LibGuestFSException; + + /** + * create a swap partition with a label + *

+ * Create a swap partition on "device" with label "label". + *

+ * @throws LibGuestFSException + */ + public void mkswap_L (String label, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap_L: handle is closed"); + _mkswap_L (g, label, device); + } + private native void _mkswap_L (long g, String label, String device) + throws LibGuestFSException; + + /** + * create a swap partition with an explicit UUID + *

+ * Create a swap partition on "device" with UUID "uuid". + *

+ * @throws LibGuestFSException + */ + public void mkswap_U (String uuid, String device) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkswap_U: handle is closed"); + _mkswap_U (g, uuid, device); + } + private native void _mkswap_U (long g, String uuid, String device) + throws LibGuestFSException; + + /** + * make block, character or FIFO devices + *

+ * This call creates block or character special devices, or + * named pipes (FIFOs). + *

+ * The "mode" parameter should be the mode, using the + * standard constants. "devmajor" and "devminor" are the + * device major and minor numbers, only used when creating + * block and character special devices. + *

+ * @throws LibGuestFSException + */ + public void mknod (int mode, int devmajor, int devminor, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mknod: handle is closed"); + _mknod (g, mode, devmajor, devminor, path); + } + private native void _mknod (long g, int mode, int devmajor, int devminor, String path) + throws LibGuestFSException; + + /** + * make FIFO (named pipe) + *

+ * This call creates a FIFO (named pipe) called "path" with + * mode "mode". It is just a convenient wrapper around + * "g.mknod". + *

+ * @throws LibGuestFSException + */ + public void mkfifo (int mode, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mkfifo: handle is closed"); + _mkfifo (g, mode, path); + } + private native void _mkfifo (long g, int mode, String path) + throws LibGuestFSException; + + /** + * make block device node + *

+ * This call creates a block device node called "path" with + * mode "mode" and device major/minor "devmajor" and + * "devminor". It is just a convenient wrapper around + * "g.mknod". + *

+ * @throws LibGuestFSException + */ + public void mknod_b (int mode, int devmajor, int devminor, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mknod_b: handle is closed"); + _mknod_b (g, mode, devmajor, devminor, path); + } + private native void _mknod_b (long g, int mode, int devmajor, int devminor, String path) + throws LibGuestFSException; + + /** + * make char device node + *

+ * This call creates a char device node called "path" with + * mode "mode" and device major/minor "devmajor" and + * "devminor". It is just a convenient wrapper around + * "g.mknod". + *

+ * @throws LibGuestFSException + */ + public void mknod_c (int mode, int devmajor, int devminor, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("mknod_c: handle is closed"); + _mknod_c (g, mode, devmajor, devminor, path); + } + private native void _mknod_c (long g, int mode, int devmajor, int devminor, String path) + throws LibGuestFSException; + + /** + * set file mode creation mask (umask) + *

+ * This function sets the mask used for creating new files + * and device nodes to "mask & 0777". + *

+ * Typical umask values would be 022 which creates new + * files with permissions like "-rw-r--r--" or + * "-rwxr-xr-x", and 002 which creates new files with + * permissions like "-rw-rw-r--" or "-rwxrwxr-x". + *

+ * See also umask(2), "g.mknod", "g.mkdir". + *

+ * This call returns the previous umask. + *

+ * @throws LibGuestFSException + */ + public int umask (int mask) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("umask: handle is closed"); + return _umask (g, mask); + } + private native int _umask (long g, int mask) + throws LibGuestFSException; + }