551b3e32f3b37def172568ec645d8eb280c15be3
[libguestfs.git] / guestfs-actions.pod
1 =head2 guestfs_add_cdrom
2
3  int guestfs_add_cdrom (guestfs_h *handle,
4                 const char *filename);
5
6 This function adds a virtual CD-ROM disk image to the guest.
7
8 This is equivalent to the qemu parameter C<-cdrom filename>.
9
10 This function returns 0 on success or -1 on error.
11
12 =head2 guestfs_add_drive
13
14  int guestfs_add_drive (guestfs_h *handle,
15                 const char *filename);
16
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
20 so on.
21
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
26 image).
27
28 This is equivalent to the qemu parameter C<-drive file=filename>.
29
30 This function returns 0 on success or -1 on error.
31
32 =head2 guestfs_aug_close
33
34  int guestfs_aug_close (guestfs_h *handle);
35
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
39 Augeas functions.
40
41 This function returns 0 on success or -1 on error.
42
43 =head2 guestfs_aug_defnode
44
45  struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *handle,
46                 const char *name,
47                 const char *expr,
48                 const char *val);
49
50 Defines a variable C<name> whose value is the result of
51 evaluating C<expr>.
52
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.
56
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.
60
61 This function returns a C<struct guestfs_int_bool *>.
62 I<The caller must call C<guestfs_free_int_bool> after use>.
63
64 =head2 guestfs_aug_defvar
65
66  int guestfs_aug_defvar (guestfs_h *handle,
67                 const char *name,
68                 const char *expr);
69
70 Defines an Augeas variable C<name> whose value is the result
71 of evaluating C<expr>.  If C<expr> is NULL, then C<name> is
72 undefined.
73
74 On success this returns the number of nodes in C<expr>, or
75 C<0> if C<expr> evaluates to something which is not a nodeset.
76
77 On error this function returns -1.
78
79 =head2 guestfs_aug_get
80
81  char *guestfs_aug_get (guestfs_h *handle,
82                 const char *path);
83
84 Look up the value associated with C<path>.  If C<path>
85 matches exactly one node, the C<value> is returned.
86
87 This function returns a string or NULL on error.
88 I<The caller must free the returned string after use>.
89
90 =head2 guestfs_aug_init
91
92  int guestfs_aug_init (guestfs_h *handle,
93                 const char *root,
94                 int flags);
95
96 Create a new Augeas handle for editing configuration files.
97 If there was any previous Augeas handle associated with this
98 guestfs session, then it is closed.
99
100 You must call this before using any other C<guestfs_aug_*>
101 commands.
102
103 C<root> is the filesystem root.  C<root> must not be NULL,
104 use C</> instead.
105
106 The flags are the same as the flags defined in
107 E<lt>augeas.hE<gt>, the logical I<or> of the following
108 integers:
109
110 =over 4
111
112 =item C<AUG_SAVE_BACKUP> = 1
113
114 Keep the original file with a C<.augsave> extension.
115
116 =item C<AUG_SAVE_NEWFILE> = 2
117
118 Save changes into a file with extension C<.augnew>, and
119 do not overwrite original.  Overrides C<AUG_SAVE_BACKUP>.
120
121 =item C<AUG_TYPE_CHECK> = 4
122
123 Typecheck lenses (can be expensive).
124
125 =item C<AUG_NO_STDINC> = 8
126
127 Do not use standard load path for modules.
128
129 =item C<AUG_SAVE_NOOP> = 16
130
131 Make save a no-op, just record what would have been changed.
132
133 =item C<AUG_NO_LOAD> = 32
134
135 Do not load the tree in C<guestfs_aug_init>.
136
137 =back
138
139 To close the handle, you can call C<guestfs_aug_close>.
140
141 To find out more about Augeas, see L<http://augeas.net/>.
142
143 This function returns 0 on success or -1 on error.
144
145 =head2 guestfs_aug_insert
146
147  int guestfs_aug_insert (guestfs_h *handle,
148                 const char *path,
149                 const char *label,
150                 int before);
151
152 Create a new sibling C<label> for C<path>, inserting it into
153 the tree before or after C<path> (depending on the boolean
154 flag C<before>).
155
156 C<path> must match exactly one existing node in the tree, and
157 C<label> must be a label, ie. not contain C</>, C<*> or end
158 with a bracketed index C<[N]>.
159
160 This function returns 0 on success or -1 on error.
161
162 =head2 guestfs_aug_load
163
164  int guestfs_aug_load (guestfs_h *handle);
165
166 Load files into the tree.
167
168 See C<aug_load> in the Augeas documentation for the full gory
169 details.
170
171 This function returns 0 on success or -1 on error.
172
173 =head2 guestfs_aug_ls
174
175  char **guestfs_aug_ls (guestfs_h *handle,
176                 const char *path);
177
178 This is just a shortcut for listing C<guestfs_aug_match>
179 C<path/*> and sorting the resulting nodes into alphabetical order.
180
181 This function returns a NULL-terminated array of strings
182 (like L<environ(3)>), or NULL if there was an error.
183 I<The caller must free the strings and the array after use>.
184
185 =head2 guestfs_aug_match
186
187  char **guestfs_aug_match (guestfs_h *handle,
188                 const char *path);
189
190 Returns a list of paths which match the path expression C<path>.
191 The returned paths are sufficiently qualified so that they match
192 exactly one node in the current tree.
193
194 This function returns a NULL-terminated array of strings
195 (like L<environ(3)>), or NULL if there was an error.
196 I<The caller must free the strings and the array after use>.
197
198 =head2 guestfs_aug_mv
199
200  int guestfs_aug_mv (guestfs_h *handle,
201                 const char *src,
202                 const char *dest);
203
204 Move the node C<src> to C<dest>.  C<src> must match exactly
205 one node.  C<dest> is overwritten if it exists.
206
207 This function returns 0 on success or -1 on error.
208
209 =head2 guestfs_aug_rm
210
211  int guestfs_aug_rm (guestfs_h *handle,
212                 const char *path);
213
214 Remove C<path> and all of its children.
215
216 On success this returns the number of entries which were removed.
217
218 On error this function returns -1.
219
220 =head2 guestfs_aug_save
221
222  int guestfs_aug_save (guestfs_h *handle);
223
224 This writes all pending changes to disk.
225
226 The flags which were passed to C<guestfs_aug_init> affect exactly
227 how files are saved.
228
229 This function returns 0 on success or -1 on error.
230
231 =head2 guestfs_aug_set
232
233  int guestfs_aug_set (guestfs_h *handle,
234                 const char *path,
235                 const char *val);
236
237 Set the value associated with C<path> to C<value>.
238
239 This function returns 0 on success or -1 on error.
240
241 =head2 guestfs_cat
242
243  char *guestfs_cat (guestfs_h *handle,
244                 const char *path);
245
246 Return the contents of the file named C<path>.
247
248 Note that this function cannot correctly handle binary files
249 (specifically, files containing C<\0> character which is treated
250 as end of string).  For those you need to use the C<guestfs_read_file>
251 function which has a more complex interface.
252
253 This function returns a string or NULL on error.
254 I<The caller must free the returned string after use>.
255
256 Because of the message protocol, there is a transfer limit 
257 of somewhere between 2MB and 4MB.  To transfer large files you should use
258 FTP.
259
260 =head2 guestfs_chmod
261
262  int guestfs_chmod (guestfs_h *handle,
263                 int mode,
264                 const char *path);
265
266 Change the mode (permissions) of C<path> to C<mode>.  Only
267 numeric modes are supported.
268
269 This function returns 0 on success or -1 on error.
270
271 =head2 guestfs_chown
272
273  int guestfs_chown (guestfs_h *handle,
274                 int owner,
275                 int group,
276                 const char *path);
277
278 Change the file owner to C<owner> and group to C<group>.
279
280 Only numeric uid and gid are supported.  If you want to use
281 names, you will need to locate and parse the password file
282 yourself (Augeas support makes this relatively easy).
283
284 This function returns 0 on success or -1 on error.
285
286 =head2 guestfs_command
287
288  char *guestfs_command (guestfs_h *handle,
289                 char * const* const arguments);
290
291 This calls runs a command from the guest filesystem.  The
292 filesystem must be mounted, and must contain a compatible
293 operating system (ie. something Linux, with the same
294 or compatible processor architecture).
295
296 The single parameter is an argv-style list of arguments.
297 The first element is the name of the program to run.
298 Subsequent elements are parameters.  The list must be
299 non-empty (ie. must contain a program name).
300
301 The C<$PATH> environment variable will contain at least
302 C</usr/bin> and C</bin>.  If you require a program from
303 another location, you should provide the full path in the
304 first parameter.
305
306 Shared libraries and data files required by the program
307 must be available on filesystems which are mounted in the
308 correct places.  It is the caller's responsibility to ensure
309 all filesystems that are needed are mounted at the right
310 locations.
311
312 This function returns a string or NULL on error.
313 I<The caller must free the returned string after use>.
314
315 =head2 guestfs_command_lines
316
317  char **guestfs_command_lines (guestfs_h *handle,
318                 char * const* const arguments);
319
320 This is the same as C<guestfs_command>, but splits the
321 result into a list of lines.
322
323 This function returns a NULL-terminated array of strings
324 (like L<environ(3)>), or NULL if there was an error.
325 I<The caller must free the strings and the array after use>.
326
327 =head2 guestfs_config
328
329  int guestfs_config (guestfs_h *handle,
330                 const char *qemuparam,
331                 const char *qemuvalue);
332
333 This can be used to add arbitrary qemu command line parameters
334 of the form C<-param value>.  Actually it's not quite arbitrary - we
335 prevent you from setting some parameters which would interfere with
336 parameters that we use.
337
338 The first character of C<param> string must be a C<-> (dash).
339
340 C<value> can be NULL.
341
342 This function returns 0 on success or -1 on error.
343
344 =head2 guestfs_exists
345
346  int guestfs_exists (guestfs_h *handle,
347                 const char *path);
348
349 This returns C<true> if and only if there is a file, directory
350 (or anything) with the given C<path> name.
351
352 See also C<guestfs_is_file>, C<guestfs_is_dir>, C<guestfs_stat>.
353
354 This function returns a C truth value on success or -1 on error.
355
356 =head2 guestfs_file
357
358  char *guestfs_file (guestfs_h *handle,
359                 const char *path);
360
361 This call uses the standard L<file(1)> command to determine
362 the type or contents of the file.  This also works on devices,
363 for example to find out whether a partition contains a filesystem.
364
365 The exact command which runs is C<file -bsL path>.  Note in
366 particular that the filename is not prepended to the output
367 (the C<-b> option).
368
369 This function returns a string or NULL on error.
370 I<The caller must free the returned string after use>.
371
372 =head2 guestfs_get_autosync
373
374  int guestfs_get_autosync (guestfs_h *handle);
375
376 Get the autosync flag.
377
378 This function returns a C truth value on success or -1 on error.
379
380 =head2 guestfs_get_path
381
382  const char *guestfs_get_path (guestfs_h *handle);
383
384 Return the current search path.
385
386 This is always non-NULL.  If it wasn't set already, then this will
387 return the default path.
388
389 This function returns a string or NULL on error.
390 The string is owned by the guest handle and must I<not> be freed.
391
392 =head2 guestfs_get_verbose
393
394  int guestfs_get_verbose (guestfs_h *handle);
395
396 This returns the verbose messages flag.
397
398 This function returns a C truth value on success or -1 on error.
399
400 =head2 guestfs_is_dir
401
402  int guestfs_is_dir (guestfs_h *handle,
403                 const char *path);
404
405 This returns C<true> if and only if there is a directory
406 with the given C<path> name.  Note that it returns false for
407 other objects like files.
408
409 See also C<guestfs_stat>.
410
411 This function returns a C truth value on success or -1 on error.
412
413 =head2 guestfs_is_file
414
415  int guestfs_is_file (guestfs_h *handle,
416                 const char *path);
417
418 This returns C<true> if and only if there is a file
419 with the given C<path> name.  Note that it returns false for
420 other objects like directories.
421
422 See also C<guestfs_stat>.
423
424 This function returns a C truth value on success or -1 on error.
425
426 =head2 guestfs_kill_subprocess
427
428  int guestfs_kill_subprocess (guestfs_h *handle);
429
430 This kills the qemu subprocess.  You should never need to call this.
431
432 This function returns 0 on success or -1 on error.
433
434 =head2 guestfs_launch
435
436  int guestfs_launch (guestfs_h *handle);
437
438 Internally libguestfs is implemented by running a virtual machine
439 using L<qemu(1)>.
440
441 You should call this after configuring the handle
442 (eg. adding drives) but before performing any actions.
443
444 This function returns 0 on success or -1 on error.
445
446 =head2 guestfs_list_devices
447
448  char **guestfs_list_devices (guestfs_h *handle);
449
450 List all the block devices.
451
452 The full block device names are returned, eg. C</dev/sda>
453
454 This function returns a NULL-terminated array of strings
455 (like L<environ(3)>), or NULL if there was an error.
456 I<The caller must free the strings and the array after use>.
457
458 =head2 guestfs_list_partitions
459
460  char **guestfs_list_partitions (guestfs_h *handle);
461
462 List all the partitions detected on all block devices.
463
464 The full partition device names are returned, eg. C</dev/sda1>
465
466 This does not return logical volumes.  For that you will need to
467 call C<guestfs_lvs>.
468
469 This function returns a NULL-terminated array of strings
470 (like L<environ(3)>), or NULL if there was an error.
471 I<The caller must free the strings and the array after use>.
472
473 =head2 guestfs_ll
474
475  char *guestfs_ll (guestfs_h *handle,
476                 const char *directory);
477
478 List the files in C<directory> (relative to the root directory,
479 there is no cwd) in the format of 'ls -la'.
480
481 This command is mostly useful for interactive sessions.  It
482 is I<not> intended that you try to parse the output string.
483
484 This function returns a string or NULL on error.
485 I<The caller must free the returned string after use>.
486
487 =head2 guestfs_ls
488
489  char **guestfs_ls (guestfs_h *handle,
490                 const char *directory);
491
492 List the files in C<directory> (relative to the root directory,
493 there is no cwd).  The '.' and '..' entries are not returned, but
494 hidden files are shown.
495
496 This command is mostly useful for interactive sessions.  Programs
497 should probably use C<guestfs_readdir> instead.
498
499 This function returns a NULL-terminated array of strings
500 (like L<environ(3)>), or NULL if there was an error.
501 I<The caller must free the strings and the array after use>.
502
503 =head2 guestfs_lvcreate
504
505  int guestfs_lvcreate (guestfs_h *handle,
506                 const char *logvol,
507                 const char *volgroup,
508                 int mbytes);
509
510 This creates an LVM volume group called C<logvol>
511 on the volume group C<volgroup>, with C<size> megabytes.
512
513 This function returns 0 on success or -1 on error.
514
515 =head2 guestfs_lvm_remove_all
516
517  int guestfs_lvm_remove_all (guestfs_h *handle);
518
519 This command removes all LVM logical volumes, volume groups
520 and physical volumes.
521
522 This function returns 0 on success or -1 on error.
523
524 B<This command is dangerous.  Without careful use you
525 can easily destroy all your data>.
526
527 =head2 guestfs_lvs
528
529  char **guestfs_lvs (guestfs_h *handle);
530
531 List all the logical volumes detected.  This is the equivalent
532 of the L<lvs(8)> command.
533
534 This returns a list of the logical volume device names
535 (eg. C</dev/VolGroup00/LogVol00>).
536
537 See also C<guestfs_lvs_full>.
538
539 This function returns a NULL-terminated array of strings
540 (like L<environ(3)>), or NULL if there was an error.
541 I<The caller must free the strings and the array after use>.
542
543 =head2 guestfs_lvs_full
544
545  struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle);
546
547 List all the logical volumes detected.  This is the equivalent
548 of the L<lvs(8)> command.  The "full" version includes all fields.
549
550 This function returns a C<struct guestfs_lvm_lv_list *>.
551 I<The caller must call C<guestfs_free_lvm_lv_list> after use>.
552
553 =head2 guestfs_mkdir
554
555  int guestfs_mkdir (guestfs_h *handle,
556                 const char *path);
557
558 Create a directory named C<path>.
559
560 This function returns 0 on success or -1 on error.
561
562 =head2 guestfs_mkdir_p
563
564  int guestfs_mkdir_p (guestfs_h *handle,
565                 const char *path);
566
567 Create a directory named C<path>, creating any parent directories
568 as necessary.  This is like the C<mkdir -p> shell command.
569
570 This function returns 0 on success or -1 on error.
571
572 =head2 guestfs_mkfs
573
574  int guestfs_mkfs (guestfs_h *handle,
575                 const char *fstype,
576                 const char *device);
577
578 This creates a filesystem on C<device> (usually a partition
579 of LVM logical volume).  The filesystem type is C<fstype>, for
580 example C<ext3>.
581
582 This function returns 0 on success or -1 on error.
583
584 =head2 guestfs_mount
585
586  int guestfs_mount (guestfs_h *handle,
587                 const char *device,
588                 const char *mountpoint);
589
590 Mount a guest disk at a position in the filesystem.  Block devices
591 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
592 the guest.  If those block devices contain partitions, they will have
593 the usual names (eg. C</dev/sda1>).  Also LVM C</dev/VG/LV>-style
594 names can be used.
595
596 The rules are the same as for L<mount(2)>:  A filesystem must
597 first be mounted on C</> before others can be mounted.  Other
598 filesystems can only be mounted on directories which already
599 exist.
600
601 The mounted filesystem is writable, if we have sufficient permissions
602 on the underlying device.
603
604 The filesystem options C<sync> and C<noatime> are set with this
605 call, in order to improve reliability.
606
607 This function returns 0 on success or -1 on error.
608
609 =head2 guestfs_mounts
610
611  char **guestfs_mounts (guestfs_h *handle);
612
613 This returns the list of currently mounted filesystems.  It returns
614 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
615
616 Some internal mounts are not shown.
617
618 This function returns a NULL-terminated array of strings
619 (like L<environ(3)>), or NULL if there was an error.
620 I<The caller must free the strings and the array after use>.
621
622 =head2 guestfs_pvcreate
623
624  int guestfs_pvcreate (guestfs_h *handle,
625                 const char *device);
626
627 This creates an LVM physical volume on the named C<device>,
628 where C<device> should usually be a partition name such
629 as C</dev/sda1>.
630
631 This function returns 0 on success or -1 on error.
632
633 =head2 guestfs_pvs
634
635  char **guestfs_pvs (guestfs_h *handle);
636
637 List all the physical volumes detected.  This is the equivalent
638 of the L<pvs(8)> command.
639
640 This returns a list of just the device names that contain
641 PVs (eg. C</dev/sda2>).
642
643 See also C<guestfs_pvs_full>.
644
645 This function returns a NULL-terminated array of strings
646 (like L<environ(3)>), or NULL if there was an error.
647 I<The caller must free the strings and the array after use>.
648
649 =head2 guestfs_pvs_full
650
651  struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle);
652
653 List all the physical volumes detected.  This is the equivalent
654 of the L<pvs(8)> command.  The "full" version includes all fields.
655
656 This function returns a C<struct guestfs_lvm_pv_list *>.
657 I<The caller must call C<guestfs_free_lvm_pv_list> after use>.
658
659 =head2 guestfs_read_lines
660
661  char **guestfs_read_lines (guestfs_h *handle,
662                 const char *path);
663
664 Return the contents of the file named C<path>.
665
666 The file contents are returned as a list of lines.  Trailing
667 C<LF> and C<CRLF> character sequences are I<not> returned.
668
669 Note that this function cannot correctly handle binary files
670 (specifically, files containing C<\0> character which is treated
671 as end of line).  For those you need to use the C<guestfs_read_file>
672 function which has a more complex interface.
673
674 This function returns a NULL-terminated array of strings
675 (like L<environ(3)>), or NULL if there was an error.
676 I<The caller must free the strings and the array after use>.
677
678 =head2 guestfs_rm
679
680  int guestfs_rm (guestfs_h *handle,
681                 const char *path);
682
683 Remove the single file C<path>.
684
685 This function returns 0 on success or -1 on error.
686
687 =head2 guestfs_rm_rf
688
689  int guestfs_rm_rf (guestfs_h *handle,
690                 const char *path);
691
692 Remove the file or directory C<path>, recursively removing the
693 contents if its a directory.  This is like the C<rm -rf> shell
694 command.
695
696 This function returns 0 on success or -1 on error.
697
698 =head2 guestfs_rmdir
699
700  int guestfs_rmdir (guestfs_h *handle,
701                 const char *path);
702
703 Remove the single directory C<path>.
704
705 This function returns 0 on success or -1 on error.
706
707 =head2 guestfs_set_autosync
708
709  int guestfs_set_autosync (guestfs_h *handle,
710                 int autosync);
711
712 If C<autosync> is true, this enables autosync.  Libguestfs will make a
713 best effort attempt to run C<guestfs_sync> when the handle is closed
714 (also if the program exits without closing handles).
715
716 This function returns 0 on success or -1 on error.
717
718 =head2 guestfs_set_path
719
720  int guestfs_set_path (guestfs_h *handle,
721                 const char *path);
722
723 Set the path that libguestfs searches for kernel and initrd.img.
724
725 The default is C<$libdir/guestfs> unless overridden by setting
726 C<LIBGUESTFS_PATH> environment variable.
727
728 The string C<path> is stashed in the libguestfs handle, so the caller
729 must make sure it remains valid for the lifetime of the handle.
730
731 Setting C<path> to C<NULL> restores the default path.
732
733 This function returns 0 on success or -1 on error.
734
735 =head2 guestfs_set_verbose
736
737  int guestfs_set_verbose (guestfs_h *handle,
738                 int verbose);
739
740 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
741
742 Verbose messages are disabled unless the environment variable
743 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
744
745 This function returns 0 on success or -1 on error.
746
747 =head2 guestfs_sfdisk
748
749  int guestfs_sfdisk (guestfs_h *handle,
750                 const char *device,
751                 int cyls,
752                 int heads,
753                 int sectors,
754                 char * const* const lines);
755
756 This is a direct interface to the L<sfdisk(8)> program for creating
757 partitions on block devices.
758
759 C<device> should be a block device, for example C</dev/sda>.
760
761 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
762 and sectors on the device, which are passed directly to sfdisk as
763 the I<-C>, I<-H> and I<-S> parameters.  If you pass C<0> for any
764 of these, then the corresponding parameter is omitted.  Usually for
765 'large' disks, you can just pass C<0> for these, but for small
766 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
767 out the right geometry and you will need to tell it.
768
769 C<lines> is a list of lines that we feed to C<sfdisk>.  For more
770 information refer to the L<sfdisk(8)> manpage.
771
772 To create a single partition occupying the whole disk, you would
773 pass C<lines> as a single element list, when the single element being
774 the string C<,> (comma).
775
776 This function returns 0 on success or -1 on error.
777
778 B<This command is dangerous.  Without careful use you
779 can easily destroy all your data>.
780
781 =head2 guestfs_sync
782
783  int guestfs_sync (guestfs_h *handle);
784
785 This syncs the disk, so that any writes are flushed through to the
786 underlying disk image.
787
788 You should always call this if you have modified a disk image, before
789 closing the handle.
790
791 This function returns 0 on success or -1 on error.
792
793 =head2 guestfs_touch
794
795  int guestfs_touch (guestfs_h *handle,
796                 const char *path);
797
798 Touch acts like the L<touch(1)> command.  It can be used to
799 update the timestamps on a file, or, if the file does not exist,
800 to create a new zero-length file.
801
802 This function returns 0 on success or -1 on error.
803
804 =head2 guestfs_umount
805
806  int guestfs_umount (guestfs_h *handle,
807                 const char *pathordevice);
808
809 This unmounts the given filesystem.  The filesystem may be
810 specified either by its mountpoint (path) or the device which
811 contains the filesystem.
812
813 This function returns 0 on success or -1 on error.
814
815 =head2 guestfs_umount_all
816
817  int guestfs_umount_all (guestfs_h *handle);
818
819 This unmounts all mounted filesystems.
820
821 Some internal mounts are not unmounted by this call.
822
823 This function returns 0 on success or -1 on error.
824
825 =head2 guestfs_vgcreate
826
827  int guestfs_vgcreate (guestfs_h *handle,
828                 const char *volgroup,
829                 char * const* const physvols);
830
831 This creates an LVM volume group called C<volgroup>
832 from the non-empty list of physical volumes C<physvols>.
833
834 This function returns 0 on success or -1 on error.
835
836 =head2 guestfs_vgs
837
838  char **guestfs_vgs (guestfs_h *handle);
839
840 List all the volumes groups detected.  This is the equivalent
841 of the L<vgs(8)> command.
842
843 This returns a list of just the volume group names that were
844 detected (eg. C<VolGroup00>).
845
846 See also C<guestfs_vgs_full>.
847
848 This function returns a NULL-terminated array of strings
849 (like L<environ(3)>), or NULL if there was an error.
850 I<The caller must free the strings and the array after use>.
851
852 =head2 guestfs_vgs_full
853
854  struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *handle);
855
856 List all the volumes groups detected.  This is the equivalent
857 of the L<vgs(8)> command.  The "full" version includes all fields.
858
859 This function returns a C<struct guestfs_lvm_vg_list *>.
860 I<The caller must call C<guestfs_free_lvm_vg_list> after use>.
861
862 =head2 guestfs_wait_ready
863
864  int guestfs_wait_ready (guestfs_h *handle);
865
866 Internally libguestfs is implemented by running a virtual machine
867 using L<qemu(1)>.
868
869 You should call this after C<guestfs_launch> to wait for the launch
870 to complete.
871
872 This function returns 0 on success or -1 on error.
873
874 =head2 guestfs_write_file
875
876  int guestfs_write_file (guestfs_h *handle,
877                 const char *path,
878                 const char *content,
879                 int size);
880
881 This call creates a file called C<path>.  The contents of the
882 file is the string C<content> (which can contain any 8 bit data),
883 with length C<size>.
884
885 As a special case, if C<size> is C<0>
886 then the length is calculated using C<strlen> (so in this case
887 the content cannot contain embedded ASCII NULs).
888
889 This function returns 0 on success or -1 on error.
890
891 Because of the message protocol, there is a transfer limit 
892 of somewhere between 2MB and 4MB.  To transfer large files you should use
893 FTP.
894