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