X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=guestfs-actions.pod;h=8f602b8956ffa571e25d32b732f2c041eff68c47;hp=f990654fc9a47b3d29592b0ee5cf0ffdbf4682cb;hb=d43dac69483e8ec62e8356d93f761684ce2f5cc8;hpb=fb19874b1e1c40f3f5efafb39151b1bfc3ef725e diff --git a/guestfs-actions.pod b/guestfs-actions.pod index f990654..8f602b8 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -58,8 +58,9 @@ On success this returns a pair containing the number of nodes in the nodeset, and a boolean flag if a node was created. -This function returns a C. -I after use.>. +This function returns a C, +or NULL if there was an error. +I after use>. =head2 guestfs_aug_defvar @@ -84,7 +85,7 @@ On error this function returns -1. Look up the value associated with C. If C matches exactly one node, the C is returned. -This function returns a string or NULL on error. +This function returns a string, or NULL on error. I. =head2 guestfs_aug_init @@ -238,6 +239,136 @@ Set the value associated with C to C. This function returns 0 on success or -1 on error. +=head2 guestfs_blockdev_flushbufs + + int guestfs_blockdev_flushbufs (guestfs_h *handle, + const char *device); + +This tells the kernel to flush internal buffers associated +with C. + +This uses the L command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_blockdev_getbsz + + int guestfs_blockdev_getbsz (guestfs_h *handle, + const char *device); + +This returns the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +On error this function returns -1. + +=head2 guestfs_blockdev_getro + + int guestfs_blockdev_getro (guestfs_h *handle, + const char *device); + +Returns a boolean indicating if the block device is read-only +(true if read-only, false if not). + +This uses the L command. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_blockdev_getsize64 + + int64_t guestfs_blockdev_getsize64 (guestfs_h *handle, + const char *device); + +This returns the size of the device in bytes. + +See also C. + +This uses the L command. + +On error this function returns -1. + +=head2 guestfs_blockdev_getss + + int guestfs_blockdev_getss (guestfs_h *handle, + const char *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 C +for that). + +This uses the L command. + +On error this function returns -1. + +=head2 guestfs_blockdev_getsz + + int64_t guestfs_blockdev_getsz (guestfs_h *handle, + const char *device); + +This returns the size of the device in units of 512-byte sectors +(even if the sectorsize isn't 512 bytes ... weird). + +See also C for the real sector size of +the device, and C for the more +useful I. + +This uses the L command. + +On error this function returns -1. + +=head2 guestfs_blockdev_rereadpt + + int guestfs_blockdev_rereadpt (guestfs_h *handle, + const char *device); + +Reread the partition table on C. + +This uses the L command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_blockdev_setbsz + + int guestfs_blockdev_setbsz (guestfs_h *handle, + const char *device, + int blocksize); + +This sets the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_blockdev_setro + + int guestfs_blockdev_setro (guestfs_h *handle, + const char *device); + +Sets the block device named C to read-only. + +This uses the L command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_blockdev_setrw + + int guestfs_blockdev_setrw (guestfs_h *handle, + const char *device); + +Sets the block device named C to read-write. + +This uses the L command. + +This function returns 0 on success or -1 on error. + =head2 guestfs_cat char *guestfs_cat (guestfs_h *handle, @@ -247,16 +378,133 @@ Return the contents of the file named C. Note that this function cannot correctly handle binary files (specifically, files containing C<\0> character which is treated -as end of string). For those you need to use the C +as end of string). For those you need to use the C function which has a more complex interface. -This function returns a string or NULL on error. +This function returns a string, or NULL on error. I. Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. To transfer large files you should use FTP. +=head2 guestfs_checksum + + char *guestfs_checksum (guestfs_h *handle, + const char *csumtype, + const char *path); + +This call computes the MD5, SHAx or CRC checksum of the +file named C. + +The type of checksum to compute is given by the C +parameter which must have one of the following values: + +=over 4 + +=item C + +Compute the cyclic redundancy check (CRC) specified by POSIX +for the C command. + +=item C + +Compute the MD5 hash (using the C program). + +=item C + +Compute the SHA1 hash (using the C program). + +=item C + +Compute the SHA224 hash (using the C program). + +=item C + +Compute the SHA256 hash (using the C program). + +=item C + +Compute the SHA384 hash (using the C program). + +=item C + +Compute the SHA512 hash (using the C program). + +=back + +The checksum is returned as a printable string. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_chmod + + int guestfs_chmod (guestfs_h *handle, + int mode, + const char *path); + +Change the mode (permissions) of C to C. Only +numeric modes are supported. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_chown + + int guestfs_chown (guestfs_h *handle, + int owner, + int group, + const char *path); + +Change the file owner to C and group to C. + +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). + +This function returns 0 on success or -1 on error. + +=head2 guestfs_command + + char *guestfs_command (guestfs_h *handle, + char * const* const arguments); + +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). + +The C<$PATH> environment variable will contain at least +C and C. 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. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_command_lines + + char **guestfs_command_lines (guestfs_h *handle, + char * const* const arguments); + +This is the same as C, but splits the +result into a list of lines. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + =head2 guestfs_config int guestfs_config (guestfs_h *handle, @@ -274,6 +522,182 @@ C can be NULL. This function returns 0 on success or -1 on error. +=head2 guestfs_cp + + int guestfs_cp (guestfs_h *handle, + const char *src, + const char *dest); + +This copies a file from C to C where C is +either a destination filename or destination directory. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_cp_a + + int guestfs_cp_a (guestfs_h *handle, + const char *src, + const char *dest); + +This copies a file or directory from C to C +recursively using the C command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_debug + + char *guestfs_debug (guestfs_h *handle, + const char *subcmd, + char * const* const extraargs); + +The C command exposes some internals of +C (the guestfs daemon) that runs inside the +qemu subprocess. + +There is no comprehensive help for this command. You have +to look at the file C in the libguestfs source +to find out what you can do. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_dmesg + + char *guestfs_dmesg (guestfs_h *handle); + +This returns the kernel messages (C 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 C or by setting +the environment variable C before +running the program. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_download + + int guestfs_download (guestfs_h *handle, + const char *remotefilename, + const char *filename); + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +See also C, C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_drop_caches + + int guestfs_drop_caches (guestfs_h *handle, + int whattodrop); + +This instructs the guest kernel to drop its page cache, +and/or dentries and inode caches. The parameter C +tells the kernel what precisely to drop, see +L + +Setting C to 3 should drop everything. + +This automatically calls L before the operation, +so that the maximum guest memory is freed. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_end_busy + + int guestfs_end_busy (guestfs_h *handle); + +This sets the state to C, or if in C 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 L. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_equal + + int guestfs_equal (guestfs_h *handle, + const char *file1, + const char *file2); + +This compares the two files C and C and returns +true if their content is exactly equal, or false otherwise. + +The external L program is used for the comparison. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_exists + + int guestfs_exists (guestfs_h *handle, + const char *path); + +This returns C if and only if there is a file, directory +(or anything) with the given C name. + +See also C, C, C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_file + + char *guestfs_file (guestfs_h *handle, + const char *path); + +This call uses the standard L 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 C. Note in +particular that the filename is not prepended to the output +(the C<-b> option). + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_fsck + + int guestfs_fsck (guestfs_h *handle, + const char *fstype, + const char *device); + +This runs the filesystem checker (fsck) on C which +should have filesystem type C. + +The returned integer is the status. See L for the +list of status codes from C. + +Notes: + +=over 4 + +=item * + +Multiple status codes can be summed together. + +=item * + +A non-zero return code can mean "success", for example if +errors have been corrected on the filesystem. + +=item * + +Checking or repairing NTFS volumes is not supported +(by linux-ntfs). + +=back + +This command is entirely equivalent to running C. + +On error this function returns -1. + =head2 guestfs_get_autosync int guestfs_get_autosync (guestfs_h *handle); @@ -282,6 +706,28 @@ Get the autosync flag. This function returns a C truth value on success or -1 on error. +=head2 guestfs_get_e2label + + char *guestfs_get_e2label (guestfs_h *handle, + const char *device); + +This returns the ext2/3/4 filesystem label of the filesystem on +C. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_get_e2uuid + + char *guestfs_get_e2uuid (guestfs_h *handle, + const char *device); + +This returns the ext2/3/4 filesystem UUID of the filesystem on +C. + +This function returns a string, or NULL on error. +I. + =head2 guestfs_get_path const char *guestfs_get_path (guestfs_h *handle); @@ -291,9 +737,32 @@ Return the current search path. This is always non-NULL. If it wasn't set already, then this will return the default path. -This function returns a string or NULL on error. +This function returns a string, or NULL on error. The string is owned by the guest handle and must I be freed. +=head2 guestfs_get_qemu + + const char *guestfs_get_qemu (guestfs_h *handle); + +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. + +This function returns a string, or NULL on error. +The string is owned by the guest handle and must I be freed. + +=head2 guestfs_get_state + + int guestfs_get_state (guestfs_h *handle); + +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 L. + +On error this function returns -1. + =head2 guestfs_get_verbose int guestfs_get_verbose (guestfs_h *handle); @@ -302,6 +771,102 @@ This returns the verbose messages flag. This function returns a C truth value on success or -1 on error. +=head2 guestfs_grub_install + + int guestfs_grub_install (guestfs_h *handle, + const char *root, + const char *device); + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_hexdump + + char *guestfs_hexdump (guestfs_h *handle, + const char *path); + +This runs C on the given C. The result is +the human-readable, canonical hex dump of the file. + +This function returns a string, or NULL on error. +I. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + +=head2 guestfs_is_busy + + int guestfs_is_busy (guestfs_h *handle); + +This returns true iff this handle is busy processing a command +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_config + + int guestfs_is_config (guestfs_h *handle); + +This returns true iff this handle is being configured +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_dir + + int guestfs_is_dir (guestfs_h *handle, + const char *path); + +This returns C if and only if there is a directory +with the given C name. Note that it returns false for +other objects like files. + +See also C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_file + + int guestfs_is_file (guestfs_h *handle, + const char *path); + +This returns C if and only if there is a file +with the given C name. Note that it returns false for +other objects like directories. + +See also C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_launching + + int guestfs_is_launching (guestfs_h *handle); + +This returns true iff this handle is launching the subprocess +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_ready + + int guestfs_is_ready (guestfs_h *handle); + +This returns true iff this handle is ready to accept commands +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + =head2 guestfs_kill_subprocess int guestfs_kill_subprocess (guestfs_h *handle); @@ -360,7 +925,7 @@ there is no cwd) in the format of 'ls -la'. This command is mostly useful for interactive sessions. It is I intended that you try to parse the output string. -This function returns a string or NULL on error. +This function returns a string, or NULL on error. I. =head2 guestfs_ls @@ -379,6 +944,61 @@ This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +=head2 guestfs_lstat + + struct guestfs_stat *guestfs_lstat (guestfs_h *handle, + const char *path); + +Returns file information for the given C. + +This is the same as C except that if C +is a symbolic link, then the link is stat-ed, not the file it +refers to. + +This is the same as the C system call. + +This function returns a C +(see L and Eguestfs-structs.hE), +or NULL if there was an error. +I after use>. + +=head2 guestfs_lvcreate + + int guestfs_lvcreate (guestfs_h *handle, + const char *logvol, + const char *volgroup, + int mbytes); + +This creates an LVM volume group called C +on the volume group C, with C megabytes. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_lvm_remove_all + + int guestfs_lvm_remove_all (guestfs_h *handle); + +This command removes all LVM logical volumes, volume groups +and physical volumes. + +This function returns 0 on success or -1 on error. + +B. + +=head2 guestfs_lvremove + + int guestfs_lvremove (guestfs_h *handle, + const char *device); + +Remove an LVM logical volume C, where C is +the path to the LV, such as C. + +You can also remove all LVs in a volume group by specifying +the VG name, C. + +This function returns 0 on success or -1 on error. + =head2 guestfs_lvs char **guestfs_lvs (guestfs_h *handle); @@ -402,8 +1022,41 @@ I. List all the logical volumes detected. This is the equivalent of the L command. The "full" version includes all fields. -This function returns a C. -I after use.>. +This function returns a C +(see Eguestfs-structs.hE), +or NULL if there was an error. +I after use>. + +=head2 guestfs_mkdir + + int guestfs_mkdir (guestfs_h *handle, + const char *path); + +Create a directory named C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mkdir_p + + int guestfs_mkdir_p (guestfs_h *handle, + const char *path); + +Create a directory named C, creating any parent directories +as necessary. This is like the C shell command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mkfs + + int guestfs_mkfs (guestfs_h *handle, + const char *fstype, + const char *device); + +This creates a filesystem on C (usually a partition +or LVM logical volume). The filesystem type is C, for +example C. + +This function returns 0 on success or -1 on error. =head2 guestfs_mount @@ -430,6 +1083,104 @@ call, in order to improve reliability. This function returns 0 on success or -1 on error. +=head2 guestfs_mount_options + + int guestfs_mount_options (guestfs_h *handle, + const char *options, + const char *device, + const char *mountpoint); + +This is the same as the C command, but it +allows you to set the mount options as for the +L I<-o> flag. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mount_ro + + int guestfs_mount_ro (guestfs_h *handle, + const char *device, + const char *mountpoint); + +This is the same as the C command, but it +mounts the filesystem with the read-only (I<-o ro>) flag. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mount_vfs + + int guestfs_mount_vfs (guestfs_h *handle, + const char *options, + const char *vfstype, + const char *device, + const char *mountpoint); + +This is the same as the C command, but it +allows you to set both the mount options and the vfstype +as for the L I<-o> and I<-t> flags. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mounts + + char **guestfs_mounts (guestfs_h *handle); + +This returns the list of currently mounted filesystems. It returns +the list of devices (eg. C, C). + +Some internal mounts are not shown. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_mv + + int guestfs_mv (guestfs_h *handle, + const char *src, + const char *dest); + +This moves a file from C to C where C is +either a destination filename or destination directory. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_ping_daemon + + int guestfs_ping_daemon (guestfs_h *handle); + +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. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_pvcreate + + int guestfs_pvcreate (guestfs_h *handle, + const char *device); + +This creates an LVM physical volume on the named C, +where C should usually be a partition name such +as C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_pvremove + + int guestfs_pvremove (guestfs_h *handle, + const char *device); + +This wipes a physical volume C so that LVM will no longer +recognise it. + +The implementation uses the C command which refuses to +wipe physical volumes that contain any volume groups, so you have +to remove those first. + +This function returns 0 on success or -1 on error. + =head2 guestfs_pvs char **guestfs_pvs (guestfs_h *handle); @@ -453,8 +1204,10 @@ I. List all the physical volumes detected. This is the equivalent of the L command. The "full" version includes all fields. -This function returns a C. -I after use.>. +This function returns a C +(see Eguestfs-structs.hE), +or NULL if there was an error. +I after use>. =head2 guestfs_read_lines @@ -475,15 +1228,90 @@ This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +=head2 guestfs_rm + + int guestfs_rm (guestfs_h *handle, + const char *path); + +Remove the single file C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_rm_rf + + int guestfs_rm_rf (guestfs_h *handle, + const char *path); + +Remove the file or directory C, recursively removing the +contents if its a directory. This is like the C shell +command. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_rmdir + + int guestfs_rmdir (guestfs_h *handle, + const char *path); + +Remove the single directory C. + +This function returns 0 on success or -1 on error. + =head2 guestfs_set_autosync int guestfs_set_autosync (guestfs_h *handle, int autosync); If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C when the handle is closed +best effort attempt to run C followed by +C 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). + +This function returns 0 on success or -1 on error. + +=head2 guestfs_set_busy + + int guestfs_set_busy (guestfs_h *handle); + +This sets the state to C. This is only used when implementing +actions using the low-level API. + +For more information on states, see L. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_set_e2label + + int guestfs_set_e2label (guestfs_h *handle, + const char *device, + const char *label); + +This sets the ext2/3/4 filesystem label of the filesystem on +C to C