1 =head2 guestfs_add_cdrom
3 int guestfs_add_cdrom (guestfs_h *handle,
6 This function adds a virtual CD-ROM disk image to the guest.
8 This is equivalent to the qemu parameter C<-cdrom filename>.
10 This function returns 0 on success or -1 on error.
12 =head2 guestfs_add_drive
14 int guestfs_add_drive (guestfs_h *handle,
15 const char *filename);
17 This function adds a virtual machine disk image C<filename> to the
18 guest. The first time you call this function, the disk appears as IDE
19 disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
22 You don't necessarily need to be root when using libguestfs. However
23 you obviously do need sufficient permissions to access the filename
24 for whatever operations you want to perform (ie. read access if you
25 just want to read the image or write access if you want to modify the
28 This is equivalent to the qemu parameter C<-drive file=filename>.
30 This function returns 0 on success or -1 on error.
32 =head2 guestfs_aug_close
34 int guestfs_aug_close (guestfs_h *handle);
36 Close the current Augeas handle and free up any resources
37 used by it. After calling this, you have to call
38 C<guestfs_aug_init> again before you can use any other
41 This function returns 0 on success or -1 on error.
43 =head2 guestfs_aug_defnode
45 struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *handle,
50 Defines a variable C<name> whose value is the result of
53 If C<expr> evaluates to an empty nodeset, a node is created,
54 equivalent to calling C<guestfs_aug_set> C<expr>, C<value>.
55 C<name> will be the nodeset containing that single node.
57 On success this returns a pair containing the
58 number of nodes in the nodeset, and a boolean flag
59 if a node was created.
61 This function returns a C<struct guestfs_int_bool *>,
62 or NULL if there was an error.
63 I<The caller must call C<guestfs_free_int_bool> after use>.
65 =head2 guestfs_aug_defvar
67 int guestfs_aug_defvar (guestfs_h *handle,
71 Defines an Augeas variable C<name> whose value is the result
72 of evaluating C<expr>. If C<expr> is NULL, then C<name> is
75 On success this returns the number of nodes in C<expr>, or
76 C<0> if C<expr> evaluates to something which is not a nodeset.
78 On error this function returns -1.
80 =head2 guestfs_aug_get
82 char *guestfs_aug_get (guestfs_h *handle,
85 Look up the value associated with C<path>. If C<path>
86 matches exactly one node, the C<value> is returned.
88 This function returns a string, or NULL on error.
89 I<The caller must free the returned string after use>.
91 =head2 guestfs_aug_init
93 int guestfs_aug_init (guestfs_h *handle,
97 Create a new Augeas handle for editing configuration files.
98 If there was any previous Augeas handle associated with this
99 guestfs session, then it is closed.
101 You must call this before using any other C<guestfs_aug_*>
104 C<root> is the filesystem root. C<root> must not be NULL,
107 The flags are the same as the flags defined in
108 E<lt>augeas.hE<gt>, the logical I<or> of the following
113 =item C<AUG_SAVE_BACKUP> = 1
115 Keep the original file with a C<.augsave> extension.
117 =item C<AUG_SAVE_NEWFILE> = 2
119 Save changes into a file with extension C<.augnew>, and
120 do not overwrite original. Overrides C<AUG_SAVE_BACKUP>.
122 =item C<AUG_TYPE_CHECK> = 4
124 Typecheck lenses (can be expensive).
126 =item C<AUG_NO_STDINC> = 8
128 Do not use standard load path for modules.
130 =item C<AUG_SAVE_NOOP> = 16
132 Make save a no-op, just record what would have been changed.
134 =item C<AUG_NO_LOAD> = 32
136 Do not load the tree in C<guestfs_aug_init>.
140 To close the handle, you can call C<guestfs_aug_close>.
142 To find out more about Augeas, see L<http://augeas.net/>.
144 This function returns 0 on success or -1 on error.
146 =head2 guestfs_aug_insert
148 int guestfs_aug_insert (guestfs_h *handle,
153 Create a new sibling C<label> for C<path>, inserting it into
154 the tree before or after C<path> (depending on the boolean
157 C<path> must match exactly one existing node in the tree, and
158 C<label> must be a label, ie. not contain C</>, C<*> or end
159 with a bracketed index C<[N]>.
161 This function returns 0 on success or -1 on error.
163 =head2 guestfs_aug_load
165 int guestfs_aug_load (guestfs_h *handle);
167 Load files into the tree.
169 See C<aug_load> in the Augeas documentation for the full gory
172 This function returns 0 on success or -1 on error.
174 =head2 guestfs_aug_ls
176 char **guestfs_aug_ls (guestfs_h *handle,
179 This is just a shortcut for listing C<guestfs_aug_match>
180 C<path/*> and sorting the resulting nodes into alphabetical order.
182 This function returns a NULL-terminated array of strings
183 (like L<environ(3)>), or NULL if there was an error.
184 I<The caller must free the strings and the array after use>.
186 =head2 guestfs_aug_match
188 char **guestfs_aug_match (guestfs_h *handle,
191 Returns a list of paths which match the path expression C<path>.
192 The returned paths are sufficiently qualified so that they match
193 exactly one node in the current tree.
195 This function returns a NULL-terminated array of strings
196 (like L<environ(3)>), or NULL if there was an error.
197 I<The caller must free the strings and the array after use>.
199 =head2 guestfs_aug_mv
201 int guestfs_aug_mv (guestfs_h *handle,
205 Move the node C<src> to C<dest>. C<src> must match exactly
206 one node. C<dest> is overwritten if it exists.
208 This function returns 0 on success or -1 on error.
210 =head2 guestfs_aug_rm
212 int guestfs_aug_rm (guestfs_h *handle,
215 Remove C<path> and all of its children.
217 On success this returns the number of entries which were removed.
219 On error this function returns -1.
221 =head2 guestfs_aug_save
223 int guestfs_aug_save (guestfs_h *handle);
225 This writes all pending changes to disk.
227 The flags which were passed to C<guestfs_aug_init> affect exactly
230 This function returns 0 on success or -1 on error.
232 =head2 guestfs_aug_set
234 int guestfs_aug_set (guestfs_h *handle,
238 Set the value associated with C<path> to C<value>.
240 This function returns 0 on success or -1 on error.
242 =head2 guestfs_blockdev_flushbufs
244 int guestfs_blockdev_flushbufs (guestfs_h *handle,
247 This tells the kernel to flush internal buffers associated
250 This uses the L<blockdev(8)> command.
252 This function returns 0 on success or -1 on error.
254 =head2 guestfs_blockdev_getbsz
256 int guestfs_blockdev_getbsz (guestfs_h *handle,
259 This returns the block size of a device.
261 (Note this is different from both I<size in blocks> and
262 I<filesystem block size>).
264 This uses the L<blockdev(8)> command.
266 On error this function returns -1.
268 =head2 guestfs_blockdev_getro
270 int guestfs_blockdev_getro (guestfs_h *handle,
273 Returns a boolean indicating if the block device is read-only
274 (true if read-only, false if not).
276 This uses the L<blockdev(8)> command.
278 This function returns a C truth value on success or -1 on error.
280 =head2 guestfs_blockdev_getsize64
282 int64_t guestfs_blockdev_getsize64 (guestfs_h *handle,
285 This returns the size of the device in bytes.
287 See also C<guestfs_blockdev_getsz>.
289 This uses the L<blockdev(8)> command.
291 On error this function returns -1.
293 =head2 guestfs_blockdev_getss
295 int guestfs_blockdev_getss (guestfs_h *handle,
298 This returns the size of sectors on a block device.
299 Usually 512, but can be larger for modern devices.
301 (Note, this is not the size in sectors, use C<guestfs_blockdev_getsz>
304 This uses the L<blockdev(8)> command.
306 On error this function returns -1.
308 =head2 guestfs_blockdev_getsz
310 int64_t guestfs_blockdev_getsz (guestfs_h *handle,
313 This returns the size of the device in units of 512-byte sectors
314 (even if the sectorsize isn't 512 bytes ... weird).
316 See also C<guestfs_blockdev_getss> for the real sector size of
317 the device, and C<guestfs_blockdev_getsize64> for the more
318 useful I<size in bytes>.
320 This uses the L<blockdev(8)> command.
322 On error this function returns -1.
324 =head2 guestfs_blockdev_rereadpt
326 int guestfs_blockdev_rereadpt (guestfs_h *handle,
329 Reread the partition table on C<device>.
331 This uses the L<blockdev(8)> command.
333 This function returns 0 on success or -1 on error.
335 =head2 guestfs_blockdev_setbsz
337 int guestfs_blockdev_setbsz (guestfs_h *handle,
341 This sets the block size of a device.
343 (Note this is different from both I<size in blocks> and
344 I<filesystem block size>).
346 This uses the L<blockdev(8)> command.
348 This function returns 0 on success or -1 on error.
350 =head2 guestfs_blockdev_setro
352 int guestfs_blockdev_setro (guestfs_h *handle,
355 Sets the block device named C<device> to read-only.
357 This uses the L<blockdev(8)> command.
359 This function returns 0 on success or -1 on error.
361 =head2 guestfs_blockdev_setrw
363 int guestfs_blockdev_setrw (guestfs_h *handle,
366 Sets the block device named C<device> to read-write.
368 This uses the L<blockdev(8)> command.
370 This function returns 0 on success or -1 on error.
374 char *guestfs_cat (guestfs_h *handle,
377 Return the contents of the file named C<path>.
379 Note that this function cannot correctly handle binary files
380 (specifically, files containing C<\0> character which is treated
381 as end of string). For those you need to use the C<guestfs_download>
382 function which has a more complex interface.
384 This function returns a string, or NULL on error.
385 I<The caller must free the returned string after use>.
387 Because of the message protocol, there is a transfer limit
388 of somewhere between 2MB and 4MB. To transfer large files you should use
391 =head2 guestfs_checksum
393 char *guestfs_checksum (guestfs_h *handle,
394 const char *csumtype,
397 This call computes the MD5, SHAx or CRC checksum of the
400 The type of checksum to compute is given by the C<csumtype>
401 parameter which must have one of the following values:
407 Compute the cyclic redundancy check (CRC) specified by POSIX
408 for the C<cksum> command.
412 Compute the MD5 hash (using the C<md5sum> program).
416 Compute the SHA1 hash (using the C<sha1sum> program).
420 Compute the SHA224 hash (using the C<sha224sum> program).
424 Compute the SHA256 hash (using the C<sha256sum> program).
428 Compute the SHA384 hash (using the C<sha384sum> program).
432 Compute the SHA512 hash (using the C<sha512sum> program).
436 The checksum is returned as a printable string.
438 This function returns a string, or NULL on error.
439 I<The caller must free the returned string after use>.
443 int guestfs_chmod (guestfs_h *handle,
447 Change the mode (permissions) of C<path> to C<mode>. Only
448 numeric modes are supported.
450 This function returns 0 on success or -1 on error.
454 int guestfs_chown (guestfs_h *handle,
459 Change the file owner to C<owner> and group to C<group>.
461 Only numeric uid and gid are supported. If you want to use
462 names, you will need to locate and parse the password file
463 yourself (Augeas support makes this relatively easy).
465 This function returns 0 on success or -1 on error.
467 =head2 guestfs_command
469 char *guestfs_command (guestfs_h *handle,
470 char * const* const arguments);
472 This call runs a command from the guest filesystem. The
473 filesystem must be mounted, and must contain a compatible
474 operating system (ie. something Linux, with the same
475 or compatible processor architecture).
477 The single parameter is an argv-style list of arguments.
478 The first element is the name of the program to run.
479 Subsequent elements are parameters. The list must be
480 non-empty (ie. must contain a program name).
482 The return value is anything printed to I<stdout> by
485 If the command returns a non-zero exit status, then
486 this function returns an error message. The error message
487 string is the content of I<stderr> from the command.
489 The C<$PATH> environment variable will contain at least
490 C</usr/bin> and C</bin>. If you require a program from
491 another location, you should provide the full path in the
494 Shared libraries and data files required by the program
495 must be available on filesystems which are mounted in the
496 correct places. It is the caller's responsibility to ensure
497 all filesystems that are needed are mounted at the right
500 This function returns a string, or NULL on error.
501 I<The caller must free the returned string after use>.
503 Because of the message protocol, there is a transfer limit
504 of somewhere between 2MB and 4MB. To transfer large files you should use
507 =head2 guestfs_command_lines
509 char **guestfs_command_lines (guestfs_h *handle,
510 char * const* const arguments);
512 This is the same as C<guestfs_command>, but splits the
513 result into a list of lines.
515 This function returns a NULL-terminated array of strings
516 (like L<environ(3)>), or NULL if there was an error.
517 I<The caller must free the strings and the array after use>.
519 Because of the message protocol, there is a transfer limit
520 of somewhere between 2MB and 4MB. To transfer large files you should use
523 =head2 guestfs_config
525 int guestfs_config (guestfs_h *handle,
526 const char *qemuparam,
527 const char *qemuvalue);
529 This can be used to add arbitrary qemu command line parameters
530 of the form C<-param value>. Actually it's not quite arbitrary - we
531 prevent you from setting some parameters which would interfere with
532 parameters that we use.
534 The first character of C<param> string must be a C<-> (dash).
536 C<value> can be NULL.
538 This function returns 0 on success or -1 on error.
542 int guestfs_cp (guestfs_h *handle,
546 This copies a file from C<src> to C<dest> where C<dest> is
547 either a destination filename or destination directory.
549 This function returns 0 on success or -1 on error.
553 int guestfs_cp_a (guestfs_h *handle,
557 This copies a file or directory from C<src> to C<dest>
558 recursively using the C<cp -a> command.
560 This function returns 0 on success or -1 on error.
564 char *guestfs_debug (guestfs_h *handle,
566 char * const* const extraargs);
568 The C<guestfs_debug> command exposes some internals of
569 C<guestfsd> (the guestfs daemon) that runs inside the
572 There is no comprehensive help for this command. You have
573 to look at the file C<daemon/debug.c> in the libguestfs source
574 to find out what you can do.
576 This function returns a string, or NULL on error.
577 I<The caller must free the returned string after use>.
581 char *guestfs_dmesg (guestfs_h *handle);
583 This returns the kernel messages (C<dmesg> output) from
584 the guest kernel. This is sometimes useful for extended
585 debugging of problems.
587 Another way to get the same information is to enable
588 verbose messages with C<guestfs_set_verbose> or by setting
589 the environment variable C<LIBGUESTFS_DEBUG=1> before
592 This function returns a string, or NULL on error.
593 I<The caller must free the returned string after use>.
595 =head2 guestfs_download
597 int guestfs_download (guestfs_h *handle,
598 const char *remotefilename,
599 const char *filename);
601 Download file C<remotefilename> and save it as C<filename>
602 on the local machine.
604 C<filename> can also be a named pipe.
606 See also C<guestfs_upload>, C<guestfs_cat>.
608 This function returns 0 on success or -1 on error.
610 =head2 guestfs_drop_caches
612 int guestfs_drop_caches (guestfs_h *handle,
615 This instructs the guest kernel to drop its page cache,
616 and/or dentries and inode caches. The parameter C<whattodrop>
617 tells the kernel what precisely to drop, see
618 L<http://linux-mm.org/Drop_Caches>
620 Setting C<whattodrop> to 3 should drop everything.
622 This automatically calls L<sync(2)> before the operation,
623 so that the maximum guest memory is freed.
625 This function returns 0 on success or -1 on error.
627 =head2 guestfs_end_busy
629 int guestfs_end_busy (guestfs_h *handle);
631 This sets the state to C<READY>, or if in C<CONFIG> then it leaves the
632 state as is. This is only used when implementing
633 actions using the low-level API.
635 For more information on states, see L<guestfs(3)>.
637 This function returns 0 on success or -1 on error.
641 int guestfs_equal (guestfs_h *handle,
645 This compares the two files C<file1> and C<file2> and returns
646 true if their content is exactly equal, or false otherwise.
648 The external L<cmp(1)> program is used for the comparison.
650 This function returns a C truth value on success or -1 on error.
652 =head2 guestfs_exists
654 int guestfs_exists (guestfs_h *handle,
657 This returns C<true> if and only if there is a file, directory
658 (or anything) with the given C<path> name.
660 See also C<guestfs_is_file>, C<guestfs_is_dir>, C<guestfs_stat>.
662 This function returns a C truth value on success or -1 on error.
666 char *guestfs_file (guestfs_h *handle,
669 This call uses the standard L<file(1)> command to determine
670 the type or contents of the file. This also works on devices,
671 for example to find out whether a partition contains a filesystem.
673 The exact command which runs is C<file -bsL path>. Note in
674 particular that the filename is not prepended to the output
677 This function returns a string, or NULL on error.
678 I<The caller must free the returned string after use>.
682 char **guestfs_find (guestfs_h *handle,
683 const char *directory);
685 This command lists out all files and directories, recursively,
686 starting at C<directory>. It is essentially equivalent to
687 running the shell command C<find directory -print> but some
688 post-processing happens on the output, described below.
690 This returns a list of strings I<without any prefix>. Thus
691 if the directory structure was:
697 then the returned list from C<guestfs_find> C</tmp> would be
705 If C<directory> is not a directory, then this command returns
708 The returned list is sorted.
710 This function returns a NULL-terminated array of strings
711 (like L<environ(3)>), or NULL if there was an error.
712 I<The caller must free the strings and the array after use>.
716 int guestfs_fsck (guestfs_h *handle,
720 This runs the filesystem checker (fsck) on C<device> which
721 should have filesystem type C<fstype>.
723 The returned integer is the status. See L<fsck(8)> for the
724 list of status codes from C<fsck>.
732 Multiple status codes can be summed together.
736 A non-zero return code can mean "success", for example if
737 errors have been corrected on the filesystem.
741 Checking or repairing NTFS volumes is not supported
746 This command is entirely equivalent to running C<fsck -a -t fstype device>.
748 On error this function returns -1.
750 =head2 guestfs_get_append
752 const char *guestfs_get_append (guestfs_h *handle);
754 Return the additional kernel options which are added to the
755 guest kernel command line.
757 If C<NULL> then no options are added.
759 This function returns a string, or NULL on error.
760 The string is owned by the guest handle and must I<not> be freed.
762 =head2 guestfs_get_autosync
764 int guestfs_get_autosync (guestfs_h *handle);
766 Get the autosync flag.
768 This function returns a C truth value on success or -1 on error.
770 =head2 guestfs_get_e2label
772 char *guestfs_get_e2label (guestfs_h *handle,
775 This returns the ext2/3/4 filesystem label of the filesystem on
778 This function returns a string, or NULL on error.
779 I<The caller must free the returned string after use>.
781 =head2 guestfs_get_e2uuid
783 char *guestfs_get_e2uuid (guestfs_h *handle,
786 This returns the ext2/3/4 filesystem UUID of the filesystem on
789 This function returns a string, or NULL on error.
790 I<The caller must free the returned string after use>.
792 =head2 guestfs_get_path
794 const char *guestfs_get_path (guestfs_h *handle);
796 Return the current search path.
798 This is always non-NULL. If it wasn't set already, then this will
799 return the default path.
801 This function returns a string, or NULL on error.
802 The string is owned by the guest handle and must I<not> be freed.
804 =head2 guestfs_get_qemu
806 const char *guestfs_get_qemu (guestfs_h *handle);
808 Return the current qemu binary.
810 This is always non-NULL. If it wasn't set already, then this will
811 return the default qemu binary name.
813 This function returns a string, or NULL on error.
814 The string is owned by the guest handle and must I<not> be freed.
816 =head2 guestfs_get_state
818 int guestfs_get_state (guestfs_h *handle);
820 This returns the current state as an opaque integer. This is
821 only useful for printing debug and internal error messages.
823 For more information on states, see L<guestfs(3)>.
825 On error this function returns -1.
827 =head2 guestfs_get_verbose
829 int guestfs_get_verbose (guestfs_h *handle);
831 This returns the verbose messages flag.
833 This function returns a C truth value on success or -1 on error.
835 =head2 guestfs_grub_install
837 int guestfs_grub_install (guestfs_h *handle,
841 This command installs GRUB (the Grand Unified Bootloader) on
842 C<device>, with the root directory being C<root>.
844 This function returns 0 on success or -1 on error.
846 =head2 guestfs_hexdump
848 char *guestfs_hexdump (guestfs_h *handle,
851 This runs C<hexdump -C> on the given C<path>. The result is
852 the human-readable, canonical hex dump of the file.
854 This function returns a string, or NULL on error.
855 I<The caller must free the returned string after use>.
857 Because of the message protocol, there is a transfer limit
858 of somewhere between 2MB and 4MB. To transfer large files you should use
861 =head2 guestfs_is_busy
863 int guestfs_is_busy (guestfs_h *handle);
865 This returns true iff this handle is busy processing a command
866 (in the C<BUSY> state).
868 For more information on states, see L<guestfs(3)>.
870 This function returns a C truth value on success or -1 on error.
872 =head2 guestfs_is_config
874 int guestfs_is_config (guestfs_h *handle);
876 This returns true iff this handle is being configured
877 (in the C<CONFIG> state).
879 For more information on states, see L<guestfs(3)>.
881 This function returns a C truth value on success or -1 on error.
883 =head2 guestfs_is_dir
885 int guestfs_is_dir (guestfs_h *handle,
888 This returns C<true> if and only if there is a directory
889 with the given C<path> name. Note that it returns false for
890 other objects like files.
892 See also C<guestfs_stat>.
894 This function returns a C truth value on success or -1 on error.
896 =head2 guestfs_is_file
898 int guestfs_is_file (guestfs_h *handle,
901 This returns C<true> if and only if there is a file
902 with the given C<path> name. Note that it returns false for
903 other objects like directories.
905 See also C<guestfs_stat>.
907 This function returns a C truth value on success or -1 on error.
909 =head2 guestfs_is_launching
911 int guestfs_is_launching (guestfs_h *handle);
913 This returns true iff this handle is launching the subprocess
914 (in the C<LAUNCHING> state).
916 For more information on states, see L<guestfs(3)>.
918 This function returns a C truth value on success or -1 on error.
920 =head2 guestfs_is_ready
922 int guestfs_is_ready (guestfs_h *handle);
924 This returns true iff this handle is ready to accept commands
925 (in the C<READY> state).
927 For more information on states, see L<guestfs(3)>.
929 This function returns a C truth value on success or -1 on error.
931 =head2 guestfs_kill_subprocess
933 int guestfs_kill_subprocess (guestfs_h *handle);
935 This kills the qemu subprocess. You should never need to call this.
937 This function returns 0 on success or -1 on error.
939 =head2 guestfs_launch
941 int guestfs_launch (guestfs_h *handle);
943 Internally libguestfs is implemented by running a virtual machine
946 You should call this after configuring the handle
947 (eg. adding drives) but before performing any actions.
949 This function returns 0 on success or -1 on error.
951 =head2 guestfs_list_devices
953 char **guestfs_list_devices (guestfs_h *handle);
955 List all the block devices.
957 The full block device names are returned, eg. C</dev/sda>
959 This function returns a NULL-terminated array of strings
960 (like L<environ(3)>), or NULL if there was an error.
961 I<The caller must free the strings and the array after use>.
963 =head2 guestfs_list_partitions
965 char **guestfs_list_partitions (guestfs_h *handle);
967 List all the partitions detected on all block devices.
969 The full partition device names are returned, eg. C</dev/sda1>
971 This does not return logical volumes. For that you will need to
974 This function returns a NULL-terminated array of strings
975 (like L<environ(3)>), or NULL if there was an error.
976 I<The caller must free the strings and the array after use>.
980 char *guestfs_ll (guestfs_h *handle,
981 const char *directory);
983 List the files in C<directory> (relative to the root directory,
984 there is no cwd) in the format of 'ls -la'.
986 This command is mostly useful for interactive sessions. It
987 is I<not> intended that you try to parse the output string.
989 This function returns a string, or NULL on error.
990 I<The caller must free the returned string after use>.
994 char **guestfs_ls (guestfs_h *handle,
995 const char *directory);
997 List the files in C<directory> (relative to the root directory,
998 there is no cwd). The '.' and '..' entries are not returned, but
999 hidden files are shown.
1001 This command is mostly useful for interactive sessions. Programs
1002 should probably use C<guestfs_readdir> instead.
1004 This function returns a NULL-terminated array of strings
1005 (like L<environ(3)>), or NULL if there was an error.
1006 I<The caller must free the strings and the array after use>.
1008 =head2 guestfs_lstat
1010 struct guestfs_stat *guestfs_lstat (guestfs_h *handle,
1013 Returns file information for the given C<path>.
1015 This is the same as C<guestfs_stat> except that if C<path>
1016 is a symbolic link, then the link is stat-ed, not the file it
1019 This is the same as the C<lstat(2)> system call.
1021 This function returns a C<struct guestfs_stat *>
1022 (see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
1023 or NULL if there was an error.
1024 I<The caller must call C<free> after use>.
1026 =head2 guestfs_lvcreate
1028 int guestfs_lvcreate (guestfs_h *handle,
1030 const char *volgroup,
1033 This creates an LVM volume group called C<logvol>
1034 on the volume group C<volgroup>, with C<size> megabytes.
1036 This function returns 0 on success or -1 on error.
1038 =head2 guestfs_lvm_remove_all
1040 int guestfs_lvm_remove_all (guestfs_h *handle);
1042 This command removes all LVM logical volumes, volume groups
1043 and physical volumes.
1045 This function returns 0 on success or -1 on error.
1047 B<This command is dangerous. Without careful use you
1048 can easily destroy all your data>.
1050 =head2 guestfs_lvremove
1052 int guestfs_lvremove (guestfs_h *handle,
1053 const char *device);
1055 Remove an LVM logical volume C<device>, where C<device> is
1056 the path to the LV, such as C</dev/VG/LV>.
1058 You can also remove all LVs in a volume group by specifying
1059 the VG name, C</dev/VG>.
1061 This function returns 0 on success or -1 on error.
1063 =head2 guestfs_lvresize
1065 int guestfs_lvresize (guestfs_h *handle,
1069 This resizes (expands or shrinks) an existing LVM logical
1070 volume to C<mbytes>. When reducing, data in the reduced part
1073 This function returns 0 on success or -1 on error.
1077 char **guestfs_lvs (guestfs_h *handle);
1079 List all the logical volumes detected. This is the equivalent
1080 of the L<lvs(8)> command.
1082 This returns a list of the logical volume device names
1083 (eg. C</dev/VolGroup00/LogVol00>).
1085 See also C<guestfs_lvs_full>.
1087 This function returns a NULL-terminated array of strings
1088 (like L<environ(3)>), or NULL if there was an error.
1089 I<The caller must free the strings and the array after use>.
1091 =head2 guestfs_lvs_full
1093 struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle);
1095 List all the logical volumes detected. This is the equivalent
1096 of the L<lvs(8)> command. The "full" version includes all fields.
1098 This function returns a C<struct guestfs_lvm_lv_list *>
1099 (see E<lt>guestfs-structs.hE<gt>),
1100 or NULL if there was an error.
1101 I<The caller must call C<guestfs_free_lvm_lv_list> after use>.
1103 =head2 guestfs_mkdir
1105 int guestfs_mkdir (guestfs_h *handle,
1108 Create a directory named C<path>.
1110 This function returns 0 on success or -1 on error.
1112 =head2 guestfs_mkdir_p
1114 int guestfs_mkdir_p (guestfs_h *handle,
1117 Create a directory named C<path>, creating any parent directories
1118 as necessary. This is like the C<mkdir -p> shell command.
1120 This function returns 0 on success or -1 on error.
1124 int guestfs_mkfs (guestfs_h *handle,
1126 const char *device);
1128 This creates a filesystem on C<device> (usually a partition
1129 or LVM logical volume). The filesystem type is C<fstype>, for
1132 This function returns 0 on success or -1 on error.
1134 =head2 guestfs_mount
1136 int guestfs_mount (guestfs_h *handle,
1138 const char *mountpoint);
1140 Mount a guest disk at a position in the filesystem. Block devices
1141 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
1142 the guest. If those block devices contain partitions, they will have
1143 the usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style
1146 The rules are the same as for L<mount(2)>: A filesystem must
1147 first be mounted on C</> before others can be mounted. Other
1148 filesystems can only be mounted on directories which already
1151 The mounted filesystem is writable, if we have sufficient permissions
1152 on the underlying device.
1154 The filesystem options C<sync> and C<noatime> are set with this
1155 call, in order to improve reliability.
1157 This function returns 0 on success or -1 on error.
1159 =head2 guestfs_mount_options
1161 int guestfs_mount_options (guestfs_h *handle,
1162 const char *options,
1164 const char *mountpoint);
1166 This is the same as the C<guestfs_mount> command, but it
1167 allows you to set the mount options as for the
1168 L<mount(8)> I<-o> flag.
1170 This function returns 0 on success or -1 on error.
1172 =head2 guestfs_mount_ro
1174 int guestfs_mount_ro (guestfs_h *handle,
1176 const char *mountpoint);
1178 This is the same as the C<guestfs_mount> command, but it
1179 mounts the filesystem with the read-only (I<-o ro>) flag.
1181 This function returns 0 on success or -1 on error.
1183 =head2 guestfs_mount_vfs
1185 int guestfs_mount_vfs (guestfs_h *handle,
1186 const char *options,
1187 const char *vfstype,
1189 const char *mountpoint);
1191 This is the same as the C<guestfs_mount> command, but it
1192 allows you to set both the mount options and the vfstype
1193 as for the L<mount(8)> I<-o> and I<-t> flags.
1195 This function returns 0 on success or -1 on error.
1197 =head2 guestfs_mounts
1199 char **guestfs_mounts (guestfs_h *handle);
1201 This returns the list of currently mounted filesystems. It returns
1202 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
1204 Some internal mounts are not shown.
1206 This function returns a NULL-terminated array of strings
1207 (like L<environ(3)>), or NULL if there was an error.
1208 I<The caller must free the strings and the array after use>.
1212 int guestfs_mv (guestfs_h *handle,
1216 This moves a file from C<src> to C<dest> where C<dest> is
1217 either a destination filename or destination directory.
1219 This function returns 0 on success or -1 on error.
1221 =head2 guestfs_ping_daemon
1223 int guestfs_ping_daemon (guestfs_h *handle);
1225 This is a test probe into the guestfs daemon running inside
1226 the qemu subprocess. Calling this function checks that the
1227 daemon responds to the ping message, without affecting the daemon
1228 or attached block device(s) in any other way.
1230 This function returns 0 on success or -1 on error.
1232 =head2 guestfs_pvcreate
1234 int guestfs_pvcreate (guestfs_h *handle,
1235 const char *device);
1237 This creates an LVM physical volume on the named C<device>,
1238 where C<device> should usually be a partition name such
1241 This function returns 0 on success or -1 on error.
1243 =head2 guestfs_pvremove
1245 int guestfs_pvremove (guestfs_h *handle,
1246 const char *device);
1248 This wipes a physical volume C<device> so that LVM will no longer
1251 The implementation uses the C<pvremove> command which refuses to
1252 wipe physical volumes that contain any volume groups, so you have
1253 to remove those first.
1255 This function returns 0 on success or -1 on error.
1257 =head2 guestfs_pvresize
1259 int guestfs_pvresize (guestfs_h *handle,
1260 const char *device);
1262 This resizes (expands or shrinks) an existing LVM physical
1263 volume to match the new size of the underlying device.
1265 This function returns 0 on success or -1 on error.
1269 char **guestfs_pvs (guestfs_h *handle);
1271 List all the physical volumes detected. This is the equivalent
1272 of the L<pvs(8)> command.
1274 This returns a list of just the device names that contain
1275 PVs (eg. C</dev/sda2>).
1277 See also C<guestfs_pvs_full>.
1279 This function returns a NULL-terminated array of strings
1280 (like L<environ(3)>), or NULL if there was an error.
1281 I<The caller must free the strings and the array after use>.
1283 =head2 guestfs_pvs_full
1285 struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle);
1287 List all the physical volumes detected. This is the equivalent
1288 of the L<pvs(8)> command. The "full" version includes all fields.
1290 This function returns a C<struct guestfs_lvm_pv_list *>
1291 (see E<lt>guestfs-structs.hE<gt>),
1292 or NULL if there was an error.
1293 I<The caller must call C<guestfs_free_lvm_pv_list> after use>.
1295 =head2 guestfs_read_lines
1297 char **guestfs_read_lines (guestfs_h *handle,
1300 Return the contents of the file named C<path>.
1302 The file contents are returned as a list of lines. Trailing
1303 C<LF> and C<CRLF> character sequences are I<not> returned.
1305 Note that this function cannot correctly handle binary files
1306 (specifically, files containing C<\0> character which is treated
1307 as end of line). For those you need to use the C<guestfs_read_file>
1308 function which has a more complex interface.
1310 This function returns a NULL-terminated array of strings
1311 (like L<environ(3)>), or NULL if there was an error.
1312 I<The caller must free the strings and the array after use>.
1314 =head2 guestfs_resize2fs
1316 int guestfs_resize2fs (guestfs_h *handle,
1317 const char *device);
1319 This resizes an ext2 or ext3 filesystem to match the size of
1320 the underlying device.
1322 This function returns 0 on success or -1 on error.
1326 int guestfs_rm (guestfs_h *handle,
1329 Remove the single file C<path>.
1331 This function returns 0 on success or -1 on error.
1333 =head2 guestfs_rm_rf
1335 int guestfs_rm_rf (guestfs_h *handle,
1338 Remove the file or directory C<path>, recursively removing the
1339 contents if its a directory. This is like the C<rm -rf> shell
1342 This function returns 0 on success or -1 on error.
1344 =head2 guestfs_rmdir
1346 int guestfs_rmdir (guestfs_h *handle,
1349 Remove the single directory C<path>.
1351 This function returns 0 on success or -1 on error.
1353 =head2 guestfs_set_append
1355 int guestfs_set_append (guestfs_h *handle,
1356 const char *append);
1358 This function is used to add additional options to the
1359 guest kernel command line.
1361 The default is C<NULL> unless overridden by setting
1362 C<LIBGUESTFS_APPEND> environment variable.
1364 Setting C<append> to C<NULL> means I<no> additional options
1365 are passed (libguestfs always adds a few of its own).
1367 This function returns 0 on success or -1 on error.
1369 =head2 guestfs_set_autosync
1371 int guestfs_set_autosync (guestfs_h *handle,
1374 If C<autosync> is true, this enables autosync. Libguestfs will make a
1375 best effort attempt to run C<guestfs_umount_all> followed by
1376 C<guestfs_sync> when the handle is closed
1377 (also if the program exits without closing handles).
1379 This is disabled by default (except in guestfish where it is
1380 enabled by default).
1382 This function returns 0 on success or -1 on error.
1384 =head2 guestfs_set_busy
1386 int guestfs_set_busy (guestfs_h *handle);
1388 This sets the state to C<BUSY>. This is only used when implementing
1389 actions using the low-level API.
1391 For more information on states, see L<guestfs(3)>.
1393 This function returns 0 on success or -1 on error.
1395 =head2 guestfs_set_e2label
1397 int guestfs_set_e2label (guestfs_h *handle,
1401 This sets the ext2/3/4 filesystem label of the filesystem on
1402 C<device> to C<label>. Filesystem labels are limited to
1405 You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2label>
1406 to return the existing label on a filesystem.
1408 This function returns 0 on success or -1 on error.
1410 =head2 guestfs_set_e2uuid
1412 int guestfs_set_e2uuid (guestfs_h *handle,
1416 This sets the ext2/3/4 filesystem UUID of the filesystem on
1417 C<device> to C<uuid>. The format of the UUID and alternatives
1418 such as C<clear>, C<random> and C<time> are described in the
1419 L<tune2fs(8)> manpage.
1421 You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2uuid>
1422 to return the existing UUID of a filesystem.
1424 This function returns 0 on success or -1 on error.
1426 =head2 guestfs_set_path
1428 int guestfs_set_path (guestfs_h *handle,
1431 Set the path that libguestfs searches for kernel and initrd.img.
1433 The default is C<$libdir/guestfs> unless overridden by setting
1434 C<LIBGUESTFS_PATH> environment variable.
1436 Setting C<path> to C<NULL> restores the default path.
1438 This function returns 0 on success or -1 on error.
1440 =head2 guestfs_set_qemu
1442 int guestfs_set_qemu (guestfs_h *handle,
1445 Set the qemu binary that we will use.
1447 The default is chosen when the library was compiled by the
1450 You can also override this by setting the C<LIBGUESTFS_QEMU>
1451 environment variable.
1453 Setting C<qemu> to C<NULL> restores the default qemu binary.
1455 This function returns 0 on success or -1 on error.
1457 =head2 guestfs_set_ready
1459 int guestfs_set_ready (guestfs_h *handle);
1461 This sets the state to C<READY>. This is only used when implementing
1462 actions using the low-level API.
1464 For more information on states, see L<guestfs(3)>.
1466 This function returns 0 on success or -1 on error.
1468 =head2 guestfs_set_verbose
1470 int guestfs_set_verbose (guestfs_h *handle,
1473 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
1475 Verbose messages are disabled unless the environment variable
1476 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
1478 This function returns 0 on success or -1 on error.
1480 =head2 guestfs_sfdisk
1482 int guestfs_sfdisk (guestfs_h *handle,
1487 char * const* const lines);
1489 This is a direct interface to the L<sfdisk(8)> program for creating
1490 partitions on block devices.
1492 C<device> should be a block device, for example C</dev/sda>.
1494 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
1495 and sectors on the device, which are passed directly to sfdisk as
1496 the I<-C>, I<-H> and I<-S> parameters. If you pass C<0> for any
1497 of these, then the corresponding parameter is omitted. Usually for
1498 'large' disks, you can just pass C<0> for these, but for small
1499 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
1500 out the right geometry and you will need to tell it.
1502 C<lines> is a list of lines that we feed to C<sfdisk>. For more
1503 information refer to the L<sfdisk(8)> manpage.
1505 To create a single partition occupying the whole disk, you would
1506 pass C<lines> as a single element list, when the single element being
1507 the string C<,> (comma).
1509 See also: C<guestfs_sfdisk_l>, C<guestfs_sfdisk_N>
1511 This function returns 0 on success or -1 on error.
1513 B<This command is dangerous. Without careful use you
1514 can easily destroy all your data>.
1516 =head2 guestfs_sfdisk_N
1518 int guestfs_sfdisk_N (guestfs_h *handle,
1526 This runs L<sfdisk(8)> option to modify just the single
1527 partition C<n> (note: C<n> counts from 1).
1529 For other parameters, see C<guestfs_sfdisk>. You should usually
1530 pass C<0> for the cyls/heads/sectors parameters.
1532 This function returns 0 on success or -1 on error.
1534 B<This command is dangerous. Without careful use you
1535 can easily destroy all your data>.
1537 =head2 guestfs_sfdisk_disk_geometry
1539 char *guestfs_sfdisk_disk_geometry (guestfs_h *handle,
1540 const char *device);
1542 This displays the disk geometry of C<device> read from the
1543 partition table. Especially in the case where the underlying
1544 block device has been resized, this can be different from the
1545 kernel's idea of the geometry (see C<guestfs_sfdisk_kernel_geometry>).
1547 The result is in human-readable format, and not designed to
1550 This function returns a string, or NULL on error.
1551 I<The caller must free the returned string after use>.
1553 =head2 guestfs_sfdisk_kernel_geometry
1555 char *guestfs_sfdisk_kernel_geometry (guestfs_h *handle,
1556 const char *device);
1558 This displays the kernel's idea of the geometry of C<device>.
1560 The result is in human-readable format, and not designed to
1563 This function returns a string, or NULL on error.
1564 I<The caller must free the returned string after use>.
1566 =head2 guestfs_sfdisk_l
1568 char *guestfs_sfdisk_l (guestfs_h *handle,
1569 const char *device);
1571 This displays the partition table on C<device>, in the
1572 human-readable output of the L<sfdisk(8)> command. It is
1573 not intended to be parsed.
1575 This function returns a string, or NULL on error.
1576 I<The caller must free the returned string after use>.
1580 struct guestfs_stat *guestfs_stat (guestfs_h *handle,
1583 Returns file information for the given C<path>.
1585 This is the same as the C<stat(2)> system call.
1587 This function returns a C<struct guestfs_stat *>
1588 (see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
1589 or NULL if there was an error.
1590 I<The caller must call C<free> after use>.
1592 =head2 guestfs_statvfs
1594 struct guestfs_statvfs *guestfs_statvfs (guestfs_h *handle,
1597 Returns file system statistics for any mounted file system.
1598 C<path> should be a file or directory in the mounted file system
1599 (typically it is the mount point itself, but it doesn't need to be).
1601 This is the same as the C<statvfs(2)> system call.
1603 This function returns a C<struct guestfs_statvfs *>
1604 (see L<statvfs(2)> and E<lt>guestfs-structs.hE<gt>),
1605 or NULL if there was an error.
1606 I<The caller must call C<free> after use>.
1608 =head2 guestfs_strings
1610 char **guestfs_strings (guestfs_h *handle,
1613 This runs the L<strings(1)> command on a file and returns
1614 the list of printable strings found.
1616 This function returns a NULL-terminated array of strings
1617 (like L<environ(3)>), or NULL if there was an error.
1618 I<The caller must free the strings and the array after use>.
1620 Because of the message protocol, there is a transfer limit
1621 of somewhere between 2MB and 4MB. To transfer large files you should use
1624 =head2 guestfs_strings_e
1626 char **guestfs_strings_e (guestfs_h *handle,
1627 const char *encoding,
1630 This is like the C<guestfs_strings> command, but allows you to
1631 specify the encoding.
1633 See the L<strings(1)> manpage for the full list of encodings.
1635 Commonly useful encodings are C<l> (lower case L) which will
1636 show strings inside Windows/x86 files.
1638 The returned strings are transcoded to UTF-8.
1640 This function returns a NULL-terminated array of strings
1641 (like L<environ(3)>), or NULL if there was an error.
1642 I<The caller must free the strings and the array after use>.
1644 Because of the message protocol, there is a transfer limit
1645 of somewhere between 2MB and 4MB. To transfer large files you should use
1650 int guestfs_sync (guestfs_h *handle);
1652 This syncs the disk, so that any writes are flushed through to the
1653 underlying disk image.
1655 You should always call this if you have modified a disk image, before
1658 This function returns 0 on success or -1 on error.
1660 =head2 guestfs_tar_in
1662 int guestfs_tar_in (guestfs_h *handle,
1663 const char *tarfile,
1664 const char *directory);
1666 This command uploads and unpacks local file C<tarfile> (an
1667 I<uncompressed> tar file) into C<directory>.
1669 To upload a compressed tarball, use C<guestfs_tgz_in>.
1671 This function returns 0 on success or -1 on error.
1673 =head2 guestfs_tar_out
1675 int guestfs_tar_out (guestfs_h *handle,
1676 const char *directory,
1677 const char *tarfile);
1679 This command packs the contents of C<directory> and downloads
1680 it to local file C<tarfile>.
1682 To download a compressed tarball, use C<guestfs_tgz_out>.
1684 This function returns 0 on success or -1 on error.
1686 =head2 guestfs_tgz_in
1688 int guestfs_tgz_in (guestfs_h *handle,
1689 const char *tarball,
1690 const char *directory);
1692 This command uploads and unpacks local file C<tarball> (a
1693 I<gzip compressed> tar file) into C<directory>.
1695 To upload an uncompressed tarball, use C<guestfs_tar_in>.
1697 This function returns 0 on success or -1 on error.
1699 =head2 guestfs_tgz_out
1701 int guestfs_tgz_out (guestfs_h *handle,
1702 const char *directory,
1703 const char *tarball);
1705 This command packs the contents of C<directory> and downloads
1706 it to local file C<tarball>.
1708 To download an uncompressed tarball, use C<guestfs_tar_out>.
1710 This function returns 0 on success or -1 on error.
1712 =head2 guestfs_touch
1714 int guestfs_touch (guestfs_h *handle,
1717 Touch acts like the L<touch(1)> command. It can be used to
1718 update the timestamps on a file, or, if the file does not exist,
1719 to create a new zero-length file.
1721 This function returns 0 on success or -1 on error.
1723 =head2 guestfs_tune2fs_l
1725 char **guestfs_tune2fs_l (guestfs_h *handle,
1726 const char *device);
1728 This returns the contents of the ext2, ext3 or ext4 filesystem
1729 superblock on C<device>.
1731 It is the same as running C<tune2fs -l device>. See L<tune2fs(8)>
1732 manpage for more details. The list of fields returned isn't
1733 clearly defined, and depends on both the version of C<tune2fs>
1734 that libguestfs was built against, and the filesystem itself.
1736 This function returns a NULL-terminated array of
1737 strings, or NULL if there was an error.
1738 The array of strings will always have length C<2n+1>, where
1739 C<n> keys and values alternate, followed by the trailing NULL entry.
1740 I<The caller must free the strings and the array after use>.
1742 =head2 guestfs_umount
1744 int guestfs_umount (guestfs_h *handle,
1745 const char *pathordevice);
1747 This unmounts the given filesystem. The filesystem may be
1748 specified either by its mountpoint (path) or the device which
1749 contains the filesystem.
1751 This function returns 0 on success or -1 on error.
1753 =head2 guestfs_umount_all
1755 int guestfs_umount_all (guestfs_h *handle);
1757 This unmounts all mounted filesystems.
1759 Some internal mounts are not unmounted by this call.
1761 This function returns 0 on success or -1 on error.
1763 =head2 guestfs_upload
1765 int guestfs_upload (guestfs_h *handle,
1766 const char *filename,
1767 const char *remotefilename);
1769 Upload local file C<filename> to C<remotefilename> on the
1772 C<filename> can also be a named pipe.
1774 See also C<guestfs_download>.
1776 This function returns 0 on success or -1 on error.
1778 =head2 guestfs_vg_activate
1780 int guestfs_vg_activate (guestfs_h *handle,
1782 char * const* const volgroups);
1784 This command activates or (if C<activate> is false) deactivates
1785 all logical volumes in the listed volume groups C<volgroups>.
1786 If activated, then they are made known to the
1787 kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
1788 then those devices disappear.
1790 This command is the same as running C<vgchange -a y|n volgroups...>
1792 Note that if C<volgroups> is an empty list then B<all> volume groups
1793 are activated or deactivated.
1795 This function returns 0 on success or -1 on error.
1797 =head2 guestfs_vg_activate_all
1799 int guestfs_vg_activate_all (guestfs_h *handle,
1802 This command activates or (if C<activate> is false) deactivates
1803 all logical volumes in all volume groups.
1804 If activated, then they are made known to the
1805 kernel, ie. they appear as C</dev/mapper> devices. If deactivated,
1806 then those devices disappear.
1808 This command is the same as running C<vgchange -a y|n>
1810 This function returns 0 on success or -1 on error.
1812 =head2 guestfs_vgcreate
1814 int guestfs_vgcreate (guestfs_h *handle,
1815 const char *volgroup,
1816 char * const* const physvols);
1818 This creates an LVM volume group called C<volgroup>
1819 from the non-empty list of physical volumes C<physvols>.
1821 This function returns 0 on success or -1 on error.
1823 =head2 guestfs_vgremove
1825 int guestfs_vgremove (guestfs_h *handle,
1826 const char *vgname);
1828 Remove an LVM volume group C<vgname>, (for example C<VG>).
1830 This also forcibly removes all logical volumes in the volume
1833 This function returns 0 on success or -1 on error.
1837 char **guestfs_vgs (guestfs_h *handle);
1839 List all the volumes groups detected. This is the equivalent
1840 of the L<vgs(8)> command.
1842 This returns a list of just the volume group names that were
1843 detected (eg. C<VolGroup00>).
1845 See also C<guestfs_vgs_full>.
1847 This function returns a NULL-terminated array of strings
1848 (like L<environ(3)>), or NULL if there was an error.
1849 I<The caller must free the strings and the array after use>.
1851 =head2 guestfs_vgs_full
1853 struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *handle);
1855 List all the volumes groups detected. This is the equivalent
1856 of the L<vgs(8)> command. The "full" version includes all fields.
1858 This function returns a C<struct guestfs_lvm_vg_list *>
1859 (see E<lt>guestfs-structs.hE<gt>),
1860 or NULL if there was an error.
1861 I<The caller must call C<guestfs_free_lvm_vg_list> after use>.
1863 =head2 guestfs_wait_ready
1865 int guestfs_wait_ready (guestfs_h *handle);
1867 Internally libguestfs is implemented by running a virtual machine
1870 You should call this after C<guestfs_launch> to wait for the launch
1873 This function returns 0 on success or -1 on error.
1875 =head2 guestfs_write_file
1877 int guestfs_write_file (guestfs_h *handle,
1879 const char *content,
1882 This call creates a file called C<path>. The contents of the
1883 file is the string C<content> (which can contain any 8 bit data),
1884 with length C<size>.
1886 As a special case, if C<size> is C<0>
1887 then the length is calculated using C<strlen> (so in this case
1888 the content cannot contain embedded ASCII NULs).
1890 I<NB.> Owing to a bug, writing content containing ASCII NUL
1891 characters does I<not> work, even if the length is specified.
1892 We hope to resolve this bug in a future version. In the meantime
1893 use C<guestfs_upload>.
1895 This function returns 0 on success or -1 on error.
1897 Because of the message protocol, there is a transfer limit
1898 of somewhere between 2MB and 4MB. To transfer large files you should use
1903 int guestfs_zero (guestfs_h *handle,
1904 const char *device);
1906 This command writes zeroes over the first few blocks of C<device>.
1908 How many blocks are zeroed isn't specified (but it's I<not> enough
1909 to securely wipe the device). It should be sufficient to remove
1910 any partition tables, filesystem superblocks and so on.
1912 This function returns 0 on success or -1 on error.
1914 =head2 guestfs_zerofree
1916 int guestfs_zerofree (guestfs_h *handle,
1917 const char *device);
1919 This runs the I<zerofree> program on C<device>. This program
1920 claims to zero unused inodes and disk blocks on an ext2/3
1921 filesystem, thus making it possible to compress the filesystem
1924 You should B<not> run this program if the filesystem is
1927 It is possible that using this program can damage the filesystem
1928 or data on the filesystem.
1930 This function returns 0 on success or -1 on error.