Generated code for 'add_drive_ro' call.
[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 Note that this call checks for the existence of C<filename>.  This
11 stops you from specifying other types of drive which are supported
12 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
13 the general C<guestfs_config> call instead.
14
15 This function returns 0 on success or -1 on error.
16
17 =head2 guestfs_add_drive
18
19  int guestfs_add_drive (guestfs_h *handle,
20                 const char *filename);
21
22 This function adds a virtual machine disk image C<filename> to the
23 guest.  The first time you call this function, the disk appears as IDE
24 disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
25 so on.
26
27 You don't necessarily need to be root when using libguestfs.  However
28 you obviously do need sufficient permissions to access the filename
29 for whatever operations you want to perform (ie. read access if you
30 just want to read the image or write access if you want to modify the
31 image).
32
33 This is equivalent to the qemu parameter C<-drive file=filename>.
34
35 Note that this call checks for the existence of C<filename>.  This
36 stops you from specifying other types of drive which are supported
37 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
38 the general C<guestfs_config> call instead.
39
40 This function returns 0 on success or -1 on error.
41
42 =head2 guestfs_add_drive_ro
43
44  int guestfs_add_drive_ro (guestfs_h *handle,
45                 const char *filename);
46
47 This adds a drive in snapshot mode, making it effectively
48 read-only.
49
50 Note that writes to the device are allowed, and will be seen for
51 the duration of the guestfs handle, but they are written
52 to a temporary file which is discarded as soon as the guestfs
53 handle is closed.  We don't currently have any method to enable
54 changes to be committed, although qemu can support this.
55
56 This is equivalent to the qemu parameter
57 C<-drive file=filename,snapshot=on>.
58
59 Note that this call checks for the existence of C<filename>.  This
60 stops you from specifying other types of drive which are supported
61 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
62 the general C<guestfs_config> call instead.
63
64 This function returns 0 on success or -1 on error.
65
66 =head2 guestfs_aug_close
67
68  int guestfs_aug_close (guestfs_h *handle);
69
70 Close the current Augeas handle and free up any resources
71 used by it.  After calling this, you have to call
72 C<guestfs_aug_init> again before you can use any other
73 Augeas functions.
74
75 This function returns 0 on success or -1 on error.
76
77 =head2 guestfs_aug_defnode
78
79  struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *handle,
80                 const char *name,
81                 const char *expr,
82                 const char *val);
83
84 Defines a variable C<name> whose value is the result of
85 evaluating C<expr>.
86
87 If C<expr> evaluates to an empty nodeset, a node is created,
88 equivalent to calling C<guestfs_aug_set> C<expr>, C<value>.
89 C<name> will be the nodeset containing that single node.
90
91 On success this returns a pair containing the
92 number of nodes in the nodeset, and a boolean flag
93 if a node was created.
94
95 This function returns a C<struct guestfs_int_bool *>,
96 or NULL if there was an error.
97 I<The caller must call C<guestfs_free_int_bool> after use>.
98
99 =head2 guestfs_aug_defvar
100
101  int guestfs_aug_defvar (guestfs_h *handle,
102                 const char *name,
103                 const char *expr);
104
105 Defines an Augeas variable C<name> whose value is the result
106 of evaluating C<expr>.  If C<expr> is NULL, then C<name> is
107 undefined.
108
109 On success this returns the number of nodes in C<expr>, or
110 C<0> if C<expr> evaluates to something which is not a nodeset.
111
112 On error this function returns -1.
113
114 =head2 guestfs_aug_get
115
116  char *guestfs_aug_get (guestfs_h *handle,
117                 const char *path);
118
119 Look up the value associated with C<path>.  If C<path>
120 matches exactly one node, the C<value> is returned.
121
122 This function returns a string, or NULL on error.
123 I<The caller must free the returned string after use>.
124
125 =head2 guestfs_aug_init
126
127  int guestfs_aug_init (guestfs_h *handle,
128                 const char *root,
129                 int flags);
130
131 Create a new Augeas handle for editing configuration files.
132 If there was any previous Augeas handle associated with this
133 guestfs session, then it is closed.
134
135 You must call this before using any other C<guestfs_aug_*>
136 commands.
137
138 C<root> is the filesystem root.  C<root> must not be NULL,
139 use C</> instead.
140
141 The flags are the same as the flags defined in
142 E<lt>augeas.hE<gt>, the logical I<or> of the following
143 integers:
144
145 =over 4
146
147 =item C<AUG_SAVE_BACKUP> = 1
148
149 Keep the original file with a C<.augsave> extension.
150
151 =item C<AUG_SAVE_NEWFILE> = 2
152
153 Save changes into a file with extension C<.augnew>, and
154 do not overwrite original.  Overrides C<AUG_SAVE_BACKUP>.
155
156 =item C<AUG_TYPE_CHECK> = 4
157
158 Typecheck lenses (can be expensive).
159
160 =item C<AUG_NO_STDINC> = 8
161
162 Do not use standard load path for modules.
163
164 =item C<AUG_SAVE_NOOP> = 16
165
166 Make save a no-op, just record what would have been changed.
167
168 =item C<AUG_NO_LOAD> = 32
169
170 Do not load the tree in C<guestfs_aug_init>.
171
172 =back
173
174 To close the handle, you can call C<guestfs_aug_close>.
175
176 To find out more about Augeas, see L<http://augeas.net/>.
177
178 This function returns 0 on success or -1 on error.
179
180 =head2 guestfs_aug_insert
181
182  int guestfs_aug_insert (guestfs_h *handle,
183                 const char *path,
184                 const char *label,
185                 int before);
186
187 Create a new sibling C<label> for C<path>, inserting it into
188 the tree before or after C<path> (depending on the boolean
189 flag C<before>).
190
191 C<path> must match exactly one existing node in the tree, and
192 C<label> must be a label, ie. not contain C</>, C<*> or end
193 with a bracketed index C<[N]>.
194
195 This function returns 0 on success or -1 on error.
196
197 =head2 guestfs_aug_load
198
199  int guestfs_aug_load (guestfs_h *handle);
200
201 Load files into the tree.
202
203 See C<aug_load> in the Augeas documentation for the full gory
204 details.
205
206 This function returns 0 on success or -1 on error.
207
208 =head2 guestfs_aug_ls
209
210  char **guestfs_aug_ls (guestfs_h *handle,
211                 const char *path);
212
213 This is just a shortcut for listing C<guestfs_aug_match>
214 C<path/*> and sorting the resulting nodes into alphabetical order.
215
216 This function returns a NULL-terminated array of strings
217 (like L<environ(3)>), or NULL if there was an error.
218 I<The caller must free the strings and the array after use>.
219
220 =head2 guestfs_aug_match
221
222  char **guestfs_aug_match (guestfs_h *handle,
223                 const char *path);
224
225 Returns a list of paths which match the path expression C<path>.
226 The returned paths are sufficiently qualified so that they match
227 exactly one node in the current tree.
228
229 This function returns a NULL-terminated array of strings
230 (like L<environ(3)>), or NULL if there was an error.
231 I<The caller must free the strings and the array after use>.
232
233 =head2 guestfs_aug_mv
234
235  int guestfs_aug_mv (guestfs_h *handle,
236                 const char *src,
237                 const char *dest);
238
239 Move the node C<src> to C<dest>.  C<src> must match exactly
240 one node.  C<dest> is overwritten if it exists.
241
242 This function returns 0 on success or -1 on error.
243
244 =head2 guestfs_aug_rm
245
246  int guestfs_aug_rm (guestfs_h *handle,
247                 const char *path);
248
249 Remove C<path> and all of its children.
250
251 On success this returns the number of entries which were removed.
252
253 On error this function returns -1.
254
255 =head2 guestfs_aug_save
256
257  int guestfs_aug_save (guestfs_h *handle);
258
259 This writes all pending changes to disk.
260
261 The flags which were passed to C<guestfs_aug_init> affect exactly
262 how files are saved.
263
264 This function returns 0 on success or -1 on error.
265
266 =head2 guestfs_aug_set
267
268  int guestfs_aug_set (guestfs_h *handle,
269                 const char *path,
270                 const char *val);
271
272 Set the value associated with C<path> to C<value>.
273
274 This function returns 0 on success or -1 on error.
275
276 =head2 guestfs_blockdev_flushbufs
277
278  int guestfs_blockdev_flushbufs (guestfs_h *handle,
279                 const char *device);
280
281 This tells the kernel to flush internal buffers associated
282 with C<device>.
283
284 This uses the L<blockdev(8)> command.
285
286 This function returns 0 on success or -1 on error.
287
288 =head2 guestfs_blockdev_getbsz
289
290  int guestfs_blockdev_getbsz (guestfs_h *handle,
291                 const char *device);
292
293 This returns the block size of a device.
294
295 (Note this is different from both I<size in blocks> and
296 I<filesystem block size>).
297
298 This uses the L<blockdev(8)> command.
299
300 On error this function returns -1.
301
302 =head2 guestfs_blockdev_getro
303
304  int guestfs_blockdev_getro (guestfs_h *handle,
305                 const char *device);
306
307 Returns a boolean indicating if the block device is read-only
308 (true if read-only, false if not).
309
310 This uses the L<blockdev(8)> command.
311
312 This function returns a C truth value on success or -1 on error.
313
314 =head2 guestfs_blockdev_getsize64
315
316  int64_t guestfs_blockdev_getsize64 (guestfs_h *handle,
317                 const char *device);
318
319 This returns the size of the device in bytes.
320
321 See also C<guestfs_blockdev_getsz>.
322
323 This uses the L<blockdev(8)> command.
324
325 On error this function returns -1.
326
327 =head2 guestfs_blockdev_getss
328
329  int guestfs_blockdev_getss (guestfs_h *handle,
330                 const char *device);
331
332 This returns the size of sectors on a block device.
333 Usually 512, but can be larger for modern devices.
334
335 (Note, this is not the size in sectors, use C<guestfs_blockdev_getsz>
336 for that).
337
338 This uses the L<blockdev(8)> command.
339
340 On error this function returns -1.
341
342 =head2 guestfs_blockdev_getsz
343
344  int64_t guestfs_blockdev_getsz (guestfs_h *handle,
345                 const char *device);
346
347 This returns the size of the device in units of 512-byte sectors
348 (even if the sectorsize isn't 512 bytes ... weird).
349
350 See also C<guestfs_blockdev_getss> for the real sector size of
351 the device, and C<guestfs_blockdev_getsize64> for the more
352 useful I<size in bytes>.
353
354 This uses the L<blockdev(8)> command.
355
356 On error this function returns -1.
357
358 =head2 guestfs_blockdev_rereadpt
359
360  int guestfs_blockdev_rereadpt (guestfs_h *handle,
361                 const char *device);
362
363 Reread the partition table on C<device>.
364
365 This uses the L<blockdev(8)> command.
366
367 This function returns 0 on success or -1 on error.
368
369 =head2 guestfs_blockdev_setbsz
370
371  int guestfs_blockdev_setbsz (guestfs_h *handle,
372                 const char *device,
373                 int blocksize);
374
375 This sets the block size of a device.
376
377 (Note this is different from both I<size in blocks> and
378 I<filesystem block size>).
379
380 This uses the L<blockdev(8)> command.
381
382 This function returns 0 on success or -1 on error.
383
384 =head2 guestfs_blockdev_setro
385
386  int guestfs_blockdev_setro (guestfs_h *handle,
387                 const char *device);
388
389 Sets the block device named C<device> to read-only.
390
391 This uses the L<blockdev(8)> command.
392
393 This function returns 0 on success or -1 on error.
394
395 =head2 guestfs_blockdev_setrw
396
397  int guestfs_blockdev_setrw (guestfs_h *handle,
398                 const char *device);
399
400 Sets the block device named C<device> to read-write.
401
402 This uses the L<blockdev(8)> command.
403
404 This function returns 0 on success or -1 on error.
405
406 =head2 guestfs_cat
407
408  char *guestfs_cat (guestfs_h *handle,
409                 const char *path);
410
411 Return the contents of the file named C<path>.
412
413 Note that this function cannot correctly handle binary files
414 (specifically, files containing C<\0> character which is treated
415 as end of string).  For those you need to use the C<guestfs_download>
416 function which has a more complex interface.
417
418 This function returns a string, or NULL on error.
419 I<The caller must free the returned string after use>.
420
421 Because of the message protocol, there is a transfer limit 
422 of somewhere between 2MB and 4MB.  To transfer large files you should use
423 FTP.
424
425 =head2 guestfs_checksum
426
427  char *guestfs_checksum (guestfs_h *handle,
428                 const char *csumtype,
429                 const char *path);
430
431 This call computes the MD5, SHAx or CRC checksum of the
432 file named C<path>.
433
434 The type of checksum to compute is given by the C<csumtype>
435 parameter which must have one of the following values:
436
437 =over 4
438
439 =item C<crc>
440
441 Compute the cyclic redundancy check (CRC) specified by POSIX
442 for the C<cksum> command.
443
444 =item C<md5>
445
446 Compute the MD5 hash (using the C<md5sum> program).
447
448 =item C<sha1>
449
450 Compute the SHA1 hash (using the C<sha1sum> program).
451
452 =item C<sha224>
453
454 Compute the SHA224 hash (using the C<sha224sum> program).
455
456 =item C<sha256>
457
458 Compute the SHA256 hash (using the C<sha256sum> program).
459
460 =item C<sha384>
461
462 Compute the SHA384 hash (using the C<sha384sum> program).
463
464 =item C<sha512>
465
466 Compute the SHA512 hash (using the C<sha512sum> program).
467
468 =back
469
470 The checksum is returned as a printable string.
471
472 This function returns a string, or NULL on error.
473 I<The caller must free the returned string after use>.
474
475 =head2 guestfs_chmod
476
477  int guestfs_chmod (guestfs_h *handle,
478                 int mode,
479                 const char *path);
480
481 Change the mode (permissions) of C<path> to C<mode>.  Only
482 numeric modes are supported.
483
484 This function returns 0 on success or -1 on error.
485
486 =head2 guestfs_chown
487
488  int guestfs_chown (guestfs_h *handle,
489                 int owner,
490                 int group,
491                 const char *path);
492
493 Change the file owner to C<owner> and group to C<group>.
494
495 Only numeric uid and gid are supported.  If you want to use
496 names, you will need to locate and parse the password file
497 yourself (Augeas support makes this relatively easy).
498
499 This function returns 0 on success or -1 on error.
500
501 =head2 guestfs_command
502
503  char *guestfs_command (guestfs_h *handle,
504                 char * const* const arguments);
505
506 This call runs a command from the guest filesystem.  The
507 filesystem must be mounted, and must contain a compatible
508 operating system (ie. something Linux, with the same
509 or compatible processor architecture).
510
511 The single parameter is an argv-style list of arguments.
512 The first element is the name of the program to run.
513 Subsequent elements are parameters.  The list must be
514 non-empty (ie. must contain a program name).
515
516 The return value is anything printed to I<stdout> by
517 the command.
518
519 If the command returns a non-zero exit status, then
520 this function returns an error message.  The error message
521 string is the content of I<stderr> from the command.
522
523 The C<$PATH> environment variable will contain at least
524 C</usr/bin> and C</bin>.  If you require a program from
525 another location, you should provide the full path in the
526 first parameter.
527
528 Shared libraries and data files required by the program
529 must be available on filesystems which are mounted in the
530 correct places.  It is the caller's responsibility to ensure
531 all filesystems that are needed are mounted at the right
532 locations.
533
534 This function returns a string, or NULL on error.
535 I<The caller must free the returned string after use>.
536
537 Because of the message protocol, there is a transfer limit 
538 of somewhere between 2MB and 4MB.  To transfer large files you should use
539 FTP.
540
541 =head2 guestfs_command_lines
542
543  char **guestfs_command_lines (guestfs_h *handle,
544                 char * const* const arguments);
545
546 This is the same as C<guestfs_command>, but splits the
547 result into a list of lines.
548
549 This function returns a NULL-terminated array of strings
550 (like L<environ(3)>), or NULL if there was an error.
551 I<The caller must free the strings and the array after use>.
552
553 Because of the message protocol, there is a transfer limit 
554 of somewhere between 2MB and 4MB.  To transfer large files you should use
555 FTP.
556
557 =head2 guestfs_config
558
559  int guestfs_config (guestfs_h *handle,
560                 const char *qemuparam,
561                 const char *qemuvalue);
562
563 This can be used to add arbitrary qemu command line parameters
564 of the form C<-param value>.  Actually it's not quite arbitrary - we
565 prevent you from setting some parameters which would interfere with
566 parameters that we use.
567
568 The first character of C<param> string must be a C<-> (dash).
569
570 C<value> can be NULL.
571
572 This function returns 0 on success or -1 on error.
573
574 =head2 guestfs_cp
575
576  int guestfs_cp (guestfs_h *handle,
577                 const char *src,
578                 const char *dest);
579
580 This copies a file from C<src> to C<dest> where C<dest> is
581 either a destination filename or destination directory.
582
583 This function returns 0 on success or -1 on error.
584
585 =head2 guestfs_cp_a
586
587  int guestfs_cp_a (guestfs_h *handle,
588                 const char *src,
589                 const char *dest);
590
591 This copies a file or directory from C<src> to C<dest>
592 recursively using the C<cp -a> command.
593
594 This function returns 0 on success or -1 on error.
595
596 =head2 guestfs_debug
597
598  char *guestfs_debug (guestfs_h *handle,
599                 const char *subcmd,
600                 char * const* const extraargs);
601
602 The C<guestfs_debug> command exposes some internals of
603 C<guestfsd> (the guestfs daemon) that runs inside the
604 qemu subprocess.
605
606 There is no comprehensive help for this command.  You have
607 to look at the file C<daemon/debug.c> in the libguestfs source
608 to find out what you can do.
609
610 This function returns a string, or NULL on error.
611 I<The caller must free the returned string after use>.
612
613 =head2 guestfs_dmesg
614
615  char *guestfs_dmesg (guestfs_h *handle);
616
617 This returns the kernel messages (C<dmesg> output) from
618 the guest kernel.  This is sometimes useful for extended
619 debugging of problems.
620
621 Another way to get the same information is to enable
622 verbose messages with C<guestfs_set_verbose> or by setting
623 the environment variable C<LIBGUESTFS_DEBUG=1> before
624 running the program.
625
626 This function returns a string, or NULL on error.
627 I<The caller must free the returned string after use>.
628
629 =head2 guestfs_download
630
631  int guestfs_download (guestfs_h *handle,
632                 const char *remotefilename,
633                 const char *filename);
634
635 Download file C<remotefilename> and save it as C<filename>
636 on the local machine.
637
638 C<filename> can also be a named pipe.
639
640 See also C<guestfs_upload>, C<guestfs_cat>.
641
642 This function returns 0 on success or -1 on error.
643
644 =head2 guestfs_drop_caches
645
646  int guestfs_drop_caches (guestfs_h *handle,
647                 int whattodrop);
648
649 This instructs the guest kernel to drop its page cache,
650 and/or dentries and inode caches.  The parameter C<whattodrop>
651 tells the kernel what precisely to drop, see
652 L<http://linux-mm.org/Drop_Caches>
653
654 Setting C<whattodrop> to 3 should drop everything.
655
656 This automatically calls L<sync(2)> before the operation,
657 so that the maximum guest memory is freed.
658
659 This function returns 0 on success or -1 on error.
660
661 =head2 guestfs_e2fsck_f
662
663  int guestfs_e2fsck_f (guestfs_h *handle,
664                 const char *device);
665
666 This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
667 filesystem checker on C<device>, noninteractively (C<-p>),
668 even if the filesystem appears to be clean (C<-f>).
669
670 This command is only needed because of C<guestfs_resize2fs>
671 (q.v.).  Normally you should use C<guestfs_fsck>.
672
673 This function returns 0 on success or -1 on error.
674
675 =head2 guestfs_end_busy
676
677  int guestfs_end_busy (guestfs_h *handle);
678
679 This sets the state to C<READY>, or if in C<CONFIG> then it leaves the
680 state as is.  This is only used when implementing
681 actions using the low-level API.
682
683 For more information on states, see L<guestfs(3)>.
684
685 This function returns 0 on success or -1 on error.
686
687 =head2 guestfs_equal
688
689  int guestfs_equal (guestfs_h *handle,
690                 const char *file1,
691                 const char *file2);
692
693 This compares the two files C<file1> and C<file2> and returns
694 true if their content is exactly equal, or false otherwise.
695
696 The external L<cmp(1)> program is used for the comparison.
697
698 This function returns a C truth value on success or -1 on error.
699
700 =head2 guestfs_exists
701
702  int guestfs_exists (guestfs_h *handle,
703                 const char *path);
704
705 This returns C<true> if and only if there is a file, directory
706 (or anything) with the given C<path> name.
707
708 See also C<guestfs_is_file>, C<guestfs_is_dir>, C<guestfs_stat>.
709
710 This function returns a C truth value on success or -1 on error.
711
712 =head2 guestfs_file
713
714  char *guestfs_file (guestfs_h *handle,
715                 const char *path);
716
717 This call uses the standard L<file(1)> command to determine
718 the type or contents of the file.  This also works on devices,
719 for example to find out whether a partition contains a filesystem.
720
721 The exact command which runs is C<file -bsL path>.  Note in
722 particular that the filename is not prepended to the output
723 (the C<-b> option).
724
725 This function returns a string, or NULL on error.
726 I<The caller must free the returned string after use>.
727
728 =head2 guestfs_find
729
730  char **guestfs_find (guestfs_h *handle,
731                 const char *directory);
732
733 This command lists out all files and directories, recursively,
734 starting at C<directory>.  It is essentially equivalent to
735 running the shell command C<find directory -print> but some
736 post-processing happens on the output, described below.
737
738 This returns a list of strings I<without any prefix>.  Thus
739 if the directory structure was:
740
741  /tmp/a
742  /tmp/b
743  /tmp/c/d
744
745 then the returned list from C<guestfs_find> C</tmp> would be
746 4 elements:
747
748  a
749  b
750  c
751  c/d
752
753 If C<directory> is not a directory, then this command returns
754 an error.
755
756 The returned list is sorted.
757
758 This function returns a NULL-terminated array of strings
759 (like L<environ(3)>), or NULL if there was an error.
760 I<The caller must free the strings and the array after use>.
761
762 =head2 guestfs_fsck
763
764  int guestfs_fsck (guestfs_h *handle,
765                 const char *fstype,
766                 const char *device);
767
768 This runs the filesystem checker (fsck) on C<device> which
769 should have filesystem type C<fstype>.
770
771 The returned integer is the status.  See L<fsck(8)> for the
772 list of status codes from C<fsck>.
773
774 Notes:
775
776 =over 4
777
778 =item *
779
780 Multiple status codes can be summed together.
781
782 =item *
783
784 A non-zero return code can mean "success", for example if
785 errors have been corrected on the filesystem.
786
787 =item *
788
789 Checking or repairing NTFS volumes is not supported
790 (by linux-ntfs).
791
792 =back
793
794 This command is entirely equivalent to running C<fsck -a -t fstype device>.
795
796 On error this function returns -1.
797
798 =head2 guestfs_get_append
799
800  const char *guestfs_get_append (guestfs_h *handle);
801
802 Return the additional kernel options which are added to the
803 guest kernel command line.
804
805 If C<NULL> then no options are added.
806
807 This function returns a string, or NULL on error.
808 The string is owned by the guest handle and must I<not> be freed.
809
810 =head2 guestfs_get_autosync
811
812  int guestfs_get_autosync (guestfs_h *handle);
813
814 Get the autosync flag.
815
816 This function returns a C truth value on success or -1 on error.
817
818 =head2 guestfs_get_e2label
819
820  char *guestfs_get_e2label (guestfs_h *handle,
821                 const char *device);
822
823 This returns the ext2/3/4 filesystem label of the filesystem on
824 C<device>.
825
826 This function returns a string, or NULL on error.
827 I<The caller must free the returned string after use>.
828
829 =head2 guestfs_get_e2uuid
830
831  char *guestfs_get_e2uuid (guestfs_h *handle,
832                 const char *device);
833
834 This returns the ext2/3/4 filesystem UUID of the filesystem on
835 C<device>.
836
837 This function returns a string, or NULL on error.
838 I<The caller must free the returned string after use>.
839
840 =head2 guestfs_get_path
841
842  const char *guestfs_get_path (guestfs_h *handle);
843
844 Return the current search path.
845
846 This is always non-NULL.  If it wasn't set already, then this will
847 return the default path.
848
849 This function returns a string, or NULL on error.
850 The string is owned by the guest handle and must I<not> be freed.
851
852 =head2 guestfs_get_qemu
853
854  const char *guestfs_get_qemu (guestfs_h *handle);
855
856 Return the current qemu binary.
857
858 This is always non-NULL.  If it wasn't set already, then this will
859 return the default qemu binary name.
860
861 This function returns a string, or NULL on error.
862 The string is owned by the guest handle and must I<not> be freed.
863
864 =head2 guestfs_get_state
865
866  int guestfs_get_state (guestfs_h *handle);
867
868 This returns the current state as an opaque integer.  This is
869 only useful for printing debug and internal error messages.
870
871 For more information on states, see L<guestfs(3)>.
872
873 On error this function returns -1.
874
875 =head2 guestfs_get_verbose
876
877  int guestfs_get_verbose (guestfs_h *handle);
878
879 This returns the verbose messages flag.
880
881 This function returns a C truth value on success or -1 on error.
882
883 =head2 guestfs_grub_install
884
885  int guestfs_grub_install (guestfs_h *handle,
886                 const char *root,
887                 const char *device);
888
889 This command installs GRUB (the Grand Unified Bootloader) on
890 C<device>, with the root directory being C<root>.
891
892 This function returns 0 on success or -1 on error.
893
894 =head2 guestfs_hexdump
895
896  char *guestfs_hexdump (guestfs_h *handle,
897                 const char *path);
898
899 This runs C<hexdump -C> on the given C<path>.  The result is
900 the human-readable, canonical hex dump of the file.
901
902 This function returns a string, or NULL on error.
903 I<The caller must free the returned string after use>.
904
905 Because of the message protocol, there is a transfer limit 
906 of somewhere between 2MB and 4MB.  To transfer large files you should use
907 FTP.
908
909 =head2 guestfs_is_busy
910
911  int guestfs_is_busy (guestfs_h *handle);
912
913 This returns true iff this handle is busy processing a command
914 (in the C<BUSY> state).
915
916 For more information on states, see L<guestfs(3)>.
917
918 This function returns a C truth value on success or -1 on error.
919
920 =head2 guestfs_is_config
921
922  int guestfs_is_config (guestfs_h *handle);
923
924 This returns true iff this handle is being configured
925 (in the C<CONFIG> state).
926
927 For more information on states, see L<guestfs(3)>.
928
929 This function returns a C truth value on success or -1 on error.
930
931 =head2 guestfs_is_dir
932
933  int guestfs_is_dir (guestfs_h *handle,
934                 const char *path);
935
936 This returns C<true> if and only if there is a directory
937 with the given C<path> name.  Note that it returns false for
938 other objects like files.
939
940 See also C<guestfs_stat>.
941
942 This function returns a C truth value on success or -1 on error.
943
944 =head2 guestfs_is_file
945
946  int guestfs_is_file (guestfs_h *handle,
947                 const char *path);
948
949 This returns C<true> if and only if there is a file
950 with the given C<path> name.  Note that it returns false for
951 other objects like directories.
952
953 See also C<guestfs_stat>.
954
955 This function returns a C truth value on success or -1 on error.
956
957 =head2 guestfs_is_launching
958
959  int guestfs_is_launching (guestfs_h *handle);
960
961 This returns true iff this handle is launching the subprocess
962 (in the C<LAUNCHING> state).
963
964 For more information on states, see L<guestfs(3)>.
965
966 This function returns a C truth value on success or -1 on error.
967
968 =head2 guestfs_is_ready
969
970  int guestfs_is_ready (guestfs_h *handle);
971
972 This returns true iff this handle is ready to accept commands
973 (in the C<READY> state).
974
975 For more information on states, see L<guestfs(3)>.
976
977 This function returns a C truth value on success or -1 on error.
978
979 =head2 guestfs_kill_subprocess
980
981  int guestfs_kill_subprocess (guestfs_h *handle);
982
983 This kills the qemu subprocess.  You should never need to call this.
984
985 This function returns 0 on success or -1 on error.
986
987 =head2 guestfs_launch
988
989  int guestfs_launch (guestfs_h *handle);
990
991 Internally libguestfs is implemented by running a virtual machine
992 using L<qemu(1)>.
993
994 You should call this after configuring the handle
995 (eg. adding drives) but before performing any actions.
996
997 This function returns 0 on success or -1 on error.
998
999 =head2 guestfs_list_devices
1000
1001  char **guestfs_list_devices (guestfs_h *handle);
1002
1003 List all the block devices.
1004
1005 The full block device names are returned, eg. C</dev/sda>
1006
1007 This function returns a NULL-terminated array of strings
1008 (like L<environ(3)>), or NULL if there was an error.
1009 I<The caller must free the strings and the array after use>.
1010
1011 =head2 guestfs_list_partitions
1012
1013  char **guestfs_list_partitions (guestfs_h *handle);
1014
1015 List all the partitions detected on all block devices.
1016
1017 The full partition device names are returned, eg. C</dev/sda1>
1018
1019 This does not return logical volumes.  For that you will need to
1020 call C<guestfs_lvs>.
1021
1022 This function returns a NULL-terminated array of strings
1023 (like L<environ(3)>), or NULL if there was an error.
1024 I<The caller must free the strings and the array after use>.
1025
1026 =head2 guestfs_ll
1027
1028  char *guestfs_ll (guestfs_h *handle,
1029                 const char *directory);
1030
1031 List the files in C<directory> (relative to the root directory,
1032 there is no cwd) in the format of 'ls -la'.
1033
1034 This command is mostly useful for interactive sessions.  It
1035 is I<not> intended that you try to parse the output string.
1036
1037 This function returns a string, or NULL on error.
1038 I<The caller must free the returned string after use>.
1039
1040 =head2 guestfs_ls
1041
1042  char **guestfs_ls (guestfs_h *handle,
1043                 const char *directory);
1044
1045 List the files in C<directory> (relative to the root directory,
1046 there is no cwd).  The '.' and '..' entries are not returned, but
1047 hidden files are shown.
1048
1049 This command is mostly useful for interactive sessions.  Programs
1050 should probably use C<guestfs_readdir> instead.
1051
1052 This function returns a NULL-terminated array of strings
1053 (like L<environ(3)>), or NULL if there was an error.
1054 I<The caller must free the strings and the array after use>.
1055
1056 =head2 guestfs_lstat
1057
1058  struct guestfs_stat *guestfs_lstat (guestfs_h *handle,
1059                 const char *path);
1060
1061 Returns file information for the given C<path>.
1062
1063 This is the same as C<guestfs_stat> except that if C<path>
1064 is a symbolic link, then the link is stat-ed, not the file it
1065 refers to.
1066
1067 This is the same as the C<lstat(2)> system call.
1068
1069 This function returns a C<struct guestfs_stat *>
1070 (see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
1071 or NULL if there was an error.
1072 I<The caller must call C<free> after use>.
1073
1074 =head2 guestfs_lvcreate
1075
1076  int guestfs_lvcreate (guestfs_h *handle,
1077                 const char *logvol,
1078                 const char *volgroup,
1079                 int mbytes);
1080
1081 This creates an LVM volume group called C<logvol>
1082 on the volume group C<volgroup>, with C<size> megabytes.
1083
1084 This function returns 0 on success or -1 on error.
1085
1086 =head2 guestfs_lvm_remove_all
1087
1088  int guestfs_lvm_remove_all (guestfs_h *handle);
1089
1090 This command removes all LVM logical volumes, volume groups
1091 and physical volumes.
1092
1093 This function returns 0 on success or -1 on error.
1094
1095 B<This command is dangerous.  Without careful use you
1096 can easily destroy all your data>.
1097
1098 =head2 guestfs_lvremove
1099
1100  int guestfs_lvremove (guestfs_h *handle,
1101                 const char *device);
1102
1103 Remove an LVM logical volume C<device>, where C<device> is
1104 the path to the LV, such as C</dev/VG/LV>.
1105
1106 You can also remove all LVs in a volume group by specifying
1107 the VG name, C</dev/VG>.
1108
1109 This function returns 0 on success or -1 on error.
1110
1111 =head2 guestfs_lvresize
1112
1113  int guestfs_lvresize (guestfs_h *handle,
1114                 const char *device,
1115                 int mbytes);
1116
1117 This resizes (expands or shrinks) an existing LVM logical
1118 volume to C<mbytes>.  When reducing, data in the reduced part
1119 is lost.
1120
1121 This function returns 0 on success or -1 on error.
1122
1123 =head2 guestfs_lvs
1124
1125  char **guestfs_lvs (guestfs_h *handle);
1126
1127 List all the logical volumes detected.  This is the equivalent
1128 of the L<lvs(8)> command.
1129
1130 This returns a list of the logical volume device names
1131 (eg. C</dev/VolGroup00/LogVol00>).
1132
1133 See also C<guestfs_lvs_full>.
1134
1135 This function returns a NULL-terminated array of strings
1136 (like L<environ(3)>), or NULL if there was an error.
1137 I<The caller must free the strings and the array after use>.
1138
1139 =head2 guestfs_lvs_full
1140
1141  struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle);
1142
1143 List all the logical volumes detected.  This is the equivalent
1144 of the L<lvs(8)> command.  The "full" version includes all fields.
1145
1146 This function returns a C<struct guestfs_lvm_lv_list *>
1147 (see E<lt>guestfs-structs.hE<gt>),
1148 or NULL if there was an error.
1149 I<The caller must call C<guestfs_free_lvm_lv_list> after use>.
1150
1151 =head2 guestfs_mkdir
1152
1153  int guestfs_mkdir (guestfs_h *handle,
1154                 const char *path);
1155
1156 Create a directory named C<path>.
1157
1158 This function returns 0 on success or -1 on error.
1159
1160 =head2 guestfs_mkdir_p
1161
1162  int guestfs_mkdir_p (guestfs_h *handle,
1163                 const char *path);
1164
1165 Create a directory named C<path>, creating any parent directories
1166 as necessary.  This is like the C<mkdir -p> shell command.
1167
1168 This function returns 0 on success or -1 on error.
1169
1170 =head2 guestfs_mkfs
1171
1172  int guestfs_mkfs (guestfs_h *handle,
1173                 const char *fstype,
1174                 const char *device);
1175
1176 This creates a filesystem on C<device> (usually a partition
1177 or LVM logical volume).  The filesystem type is C<fstype>, for
1178 example C<ext3>.
1179
1180 This function returns 0 on success or -1 on error.
1181
1182 =head2 guestfs_mount
1183
1184  int guestfs_mount (guestfs_h *handle,
1185                 const char *device,
1186                 const char *mountpoint);
1187
1188 Mount a guest disk at a position in the filesystem.  Block devices
1189 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
1190 the guest.  If those block devices contain partitions, they will have
1191 the usual names (eg. C</dev/sda1>).  Also LVM C</dev/VG/LV>-style
1192 names can be used.
1193
1194 The rules are the same as for L<mount(2)>:  A filesystem must
1195 first be mounted on C</> before others can be mounted.  Other
1196 filesystems can only be mounted on directories which already
1197 exist.
1198
1199 The mounted filesystem is writable, if we have sufficient permissions
1200 on the underlying device.
1201
1202 The filesystem options C<sync> and C<noatime> are set with this
1203 call, in order to improve reliability.
1204
1205 This function returns 0 on success or -1 on error.
1206
1207 =head2 guestfs_mount_options
1208
1209  int guestfs_mount_options (guestfs_h *handle,
1210                 const char *options,
1211                 const char *device,
1212                 const char *mountpoint);
1213
1214 This is the same as the C<guestfs_mount> command, but it
1215 allows you to set the mount options as for the
1216 L<mount(8)> I<-o> flag.
1217
1218 This function returns 0 on success or -1 on error.
1219
1220 =head2 guestfs_mount_ro
1221
1222  int guestfs_mount_ro (guestfs_h *handle,
1223                 const char *device,
1224                 const char *mountpoint);
1225
1226 This is the same as the C<guestfs_mount> command, but it
1227 mounts the filesystem with the read-only (I<-o ro>) flag.
1228
1229 This function returns 0 on success or -1 on error.
1230
1231 =head2 guestfs_mount_vfs
1232
1233  int guestfs_mount_vfs (guestfs_h *handle,
1234                 const char *options,
1235                 const char *vfstype,
1236                 const char *device,
1237                 const char *mountpoint);
1238
1239 This is the same as the C<guestfs_mount> command, but it
1240 allows you to set both the mount options and the vfstype
1241 as for the L<mount(8)> I<-o> and I<-t> flags.
1242
1243 This function returns 0 on success or -1 on error.
1244
1245 =head2 guestfs_mounts
1246
1247  char **guestfs_mounts (guestfs_h *handle);
1248
1249 This returns the list of currently mounted filesystems.  It returns
1250 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
1251
1252 Some internal mounts are not shown.
1253
1254 This function returns a NULL-terminated array of strings
1255 (like L<environ(3)>), or NULL if there was an error.
1256 I<The caller must free the strings and the array after use>.
1257
1258 =head2 guestfs_mv
1259
1260  int guestfs_mv (guestfs_h *handle,
1261                 const char *src,
1262                 const char *dest);
1263
1264 This moves a file from C<src> to C<dest> where C<dest> is
1265 either a destination filename or destination directory.
1266
1267 This function returns 0 on success or -1 on error.
1268
1269 =head2 guestfs_ping_daemon
1270
1271  int guestfs_ping_daemon (guestfs_h *handle);
1272
1273 This is a test probe into the guestfs daemon running inside
1274 the qemu subprocess.  Calling this function checks that the
1275 daemon responds to the ping message, without affecting the daemon
1276 or attached block device(s) in any other way.
1277
1278 This function returns 0 on success or -1 on error.
1279
1280 =head2 guestfs_pvcreate
1281
1282  int guestfs_pvcreate (guestfs_h *handle,
1283                 const char *device);
1284
1285 This creates an LVM physical volume on the named C<device>,
1286 where C<device> should usually be a partition name such
1287 as C</dev/sda1>.
1288
1289 This function returns 0 on success or -1 on error.
1290
1291 =head2 guestfs_pvremove
1292
1293  int guestfs_pvremove (guestfs_h *handle,
1294                 const char *device);
1295
1296 This wipes a physical volume C<device> so that LVM will no longer
1297 recognise it.
1298
1299 The implementation uses the C<pvremove> command which refuses to
1300 wipe physical volumes that contain any volume groups, so you have
1301 to remove those first.
1302
1303 This function returns 0 on success or -1 on error.
1304
1305 =head2 guestfs_pvresize
1306
1307  int guestfs_pvresize (guestfs_h *handle,
1308                 const char *device);
1309
1310 This resizes (expands or shrinks) an existing LVM physical
1311 volume to match the new size of the underlying device.
1312
1313 This function returns 0 on success or -1 on error.
1314
1315 =head2 guestfs_pvs
1316
1317  char **guestfs_pvs (guestfs_h *handle);
1318
1319 List all the physical volumes detected.  This is the equivalent
1320 of the L<pvs(8)> command.
1321
1322 This returns a list of just the device names that contain
1323 PVs (eg. C</dev/sda2>).
1324
1325 See also C<guestfs_pvs_full>.
1326
1327 This function returns a NULL-terminated array of strings
1328 (like L<environ(3)>), or NULL if there was an error.
1329 I<The caller must free the strings and the array after use>.
1330
1331 =head2 guestfs_pvs_full
1332
1333  struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle);
1334
1335 List all the physical volumes detected.  This is the equivalent
1336 of the L<pvs(8)> command.  The "full" version includes all fields.
1337
1338 This function returns a C<struct guestfs_lvm_pv_list *>
1339 (see E<lt>guestfs-structs.hE<gt>),
1340 or NULL if there was an error.
1341 I<The caller must call C<guestfs_free_lvm_pv_list> after use>.
1342
1343 =head2 guestfs_read_lines
1344
1345  char **guestfs_read_lines (guestfs_h *handle,
1346                 const char *path);
1347
1348 Return the contents of the file named C<path>.
1349
1350 The file contents are returned as a list of lines.  Trailing
1351 C<LF> and C<CRLF> character sequences are I<not> returned.
1352
1353 Note that this function cannot correctly handle binary files
1354 (specifically, files containing C<\0> character which is treated
1355 as end of line).  For those you need to use the C<guestfs_read_file>
1356 function which has a more complex interface.
1357
1358 This function returns a NULL-terminated array of strings
1359 (like L<environ(3)>), or NULL if there was an error.
1360 I<The caller must free the strings and the array after use>.
1361
1362 =head2 guestfs_resize2fs
1363
1364  int guestfs_resize2fs (guestfs_h *handle,
1365                 const char *device);
1366
1367 This resizes an ext2 or ext3 filesystem to match the size of
1368 the underlying device.
1369
1370 I<Note:> It is sometimes required that you run C<guestfs_e2fsck_f>
1371 on the C<device> before calling this command.  For unknown reasons
1372 C<resize2fs> sometimes gives an error about this and sometimes not.
1373 In any case, it is always safe to call C<guestfs_e2fsck_f> before
1374 calling this function.
1375
1376 This function returns 0 on success or -1 on error.
1377
1378 =head2 guestfs_rm
1379
1380  int guestfs_rm (guestfs_h *handle,
1381                 const char *path);
1382
1383 Remove the single file C<path>.
1384
1385 This function returns 0 on success or -1 on error.
1386
1387 =head2 guestfs_rm_rf
1388
1389  int guestfs_rm_rf (guestfs_h *handle,
1390                 const char *path);
1391
1392 Remove the file or directory C<path>, recursively removing the
1393 contents if its a directory.  This is like the C<rm -rf> shell
1394 command.
1395
1396 This function returns 0 on success or -1 on error.
1397
1398 =head2 guestfs_rmdir
1399
1400  int guestfs_rmdir (guestfs_h *handle,
1401                 const char *path);
1402
1403 Remove the single directory C<path>.
1404
1405 This function returns 0 on success or -1 on error.
1406
1407 =head2 guestfs_set_append
1408
1409  int guestfs_set_append (guestfs_h *handle,
1410                 const char *append);
1411
1412 This function is used to add additional options to the
1413 guest kernel command line.
1414
1415 The default is C<NULL> unless overridden by setting
1416 C<LIBGUESTFS_APPEND> environment variable.
1417
1418 Setting C<append> to C<NULL> means I<no> additional options
1419 are passed (libguestfs always adds a few of its own).
1420
1421 This function returns 0 on success or -1 on error.
1422
1423 =head2 guestfs_set_autosync
1424
1425  int guestfs_set_autosync (guestfs_h *handle,
1426                 int autosync);
1427
1428 If C<autosync> is true, this enables autosync.  Libguestfs will make a
1429 best effort attempt to run C<guestfs_umount_all> followed by
1430 C<guestfs_sync> when the handle is closed
1431 (also if the program exits without closing handles).
1432
1433 This is disabled by default (except in guestfish where it is
1434 enabled by default).
1435
1436 This function returns 0 on success or -1 on error.
1437
1438 =head2 guestfs_set_busy
1439
1440  int guestfs_set_busy (guestfs_h *handle);
1441
1442 This sets the state to C<BUSY>.  This is only used when implementing
1443 actions using the low-level API.
1444
1445 For more information on states, see L<guestfs(3)>.
1446
1447 This function returns 0 on success or -1 on error.
1448
1449 =head2 guestfs_set_e2label
1450
1451  int guestfs_set_e2label (guestfs_h *handle,
1452                 const char *device,
1453                 const char *label);
1454
1455 This sets the ext2/3/4 filesystem label of the filesystem on
1456 C<device> to C<label>.  Filesystem labels are limited to
1457 16 characters.
1458
1459 You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2label>
1460 to return the existing label on a filesystem.
1461
1462 This function returns 0 on success or -1 on error.
1463
1464 =head2 guestfs_set_e2uuid
1465
1466  int guestfs_set_e2uuid (guestfs_h *handle,
1467                 const char *device,
1468                 const char *uuid);
1469
1470 This sets the ext2/3/4 filesystem UUID of the filesystem on
1471 C<device> to C<uuid>.  The format of the UUID and alternatives
1472 such as C<clear>, C<random> and C<time> are described in the
1473 L<tune2fs(8)> manpage.
1474
1475 You can use either C<guestfs_tune2fs_l> or C<guestfs_get_e2uuid>
1476 to return the existing UUID of a filesystem.
1477
1478 This function returns 0 on success or -1 on error.
1479
1480 =head2 guestfs_set_path
1481
1482  int guestfs_set_path (guestfs_h *handle,
1483                 const char *path);
1484
1485 Set the path that libguestfs searches for kernel and initrd.img.
1486
1487 The default is C<$libdir/guestfs> unless overridden by setting
1488 C<LIBGUESTFS_PATH> environment variable.
1489
1490 Setting C<path> to C<NULL> restores the default path.
1491
1492 This function returns 0 on success or -1 on error.
1493
1494 =head2 guestfs_set_qemu
1495
1496  int guestfs_set_qemu (guestfs_h *handle,
1497                 const char *qemu);
1498
1499 Set the qemu binary that we will use.
1500
1501 The default is chosen when the library was compiled by the
1502 configure script.
1503
1504 You can also override this by setting the C<LIBGUESTFS_QEMU>
1505 environment variable.
1506
1507 Setting C<qemu> to C<NULL> restores the default qemu binary.
1508
1509 This function returns 0 on success or -1 on error.
1510
1511 =head2 guestfs_set_ready
1512
1513  int guestfs_set_ready (guestfs_h *handle);
1514
1515 This sets the state to C<READY>.  This is only used when implementing
1516 actions using the low-level API.
1517
1518 For more information on states, see L<guestfs(3)>.
1519
1520 This function returns 0 on success or -1 on error.
1521
1522 =head2 guestfs_set_verbose
1523
1524  int guestfs_set_verbose (guestfs_h *handle,
1525                 int verbose);
1526
1527 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
1528
1529 Verbose messages are disabled unless the environment variable
1530 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
1531
1532 This function returns 0 on success or -1 on error.
1533
1534 =head2 guestfs_sfdisk
1535
1536  int guestfs_sfdisk (guestfs_h *handle,
1537                 const char *device,
1538                 int cyls,
1539                 int heads,
1540                 int sectors,
1541                 char * const* const lines);
1542
1543 This is a direct interface to the L<sfdisk(8)> program for creating
1544 partitions on block devices.
1545
1546 C<device> should be a block device, for example C</dev/sda>.
1547
1548 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
1549 and sectors on the device, which are passed directly to sfdisk as
1550 the I<-C>, I<-H> and I<-S> parameters.  If you pass C<0> for any
1551 of these, then the corresponding parameter is omitted.  Usually for
1552 'large' disks, you can just pass C<0> for these, but for small
1553 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
1554 out the right geometry and you will need to tell it.
1555
1556 C<lines> is a list of lines that we feed to C<sfdisk>.  For more
1557 information refer to the L<sfdisk(8)> manpage.
1558
1559 To create a single partition occupying the whole disk, you would
1560 pass C<lines> as a single element list, when the single element being
1561 the string C<,> (comma).
1562
1563 See also: C<guestfs_sfdisk_l>, C<guestfs_sfdisk_N>
1564
1565 This function returns 0 on success or -1 on error.
1566
1567 B<This command is dangerous.  Without careful use you
1568 can easily destroy all your data>.
1569
1570 =head2 guestfs_sfdisk_N
1571
1572  int guestfs_sfdisk_N (guestfs_h *handle,
1573                 const char *device,
1574                 int n,
1575                 int cyls,
1576                 int heads,
1577                 int sectors,
1578                 const char *line);
1579
1580 This runs L<sfdisk(8)> option to modify just the single
1581 partition C<n> (note: C<n> counts from 1).
1582
1583 For other parameters, see C<guestfs_sfdisk>.  You should usually
1584 pass C<0> for the cyls/heads/sectors parameters.
1585
1586 This function returns 0 on success or -1 on error.
1587
1588 B<This command is dangerous.  Without careful use you
1589 can easily destroy all your data>.
1590
1591 =head2 guestfs_sfdisk_disk_geometry
1592
1593  char *guestfs_sfdisk_disk_geometry (guestfs_h *handle,
1594                 const char *device);
1595
1596 This displays the disk geometry of C<device> read from the
1597 partition table.  Especially in the case where the underlying
1598 block device has been resized, this can be different from the
1599 kernel's idea of the geometry (see C<guestfs_sfdisk_kernel_geometry>).
1600
1601 The result is in human-readable format, and not designed to
1602 be parsed.
1603
1604 This function returns a string, or NULL on error.
1605 I<The caller must free the returned string after use>.
1606
1607 =head2 guestfs_sfdisk_kernel_geometry
1608
1609  char *guestfs_sfdisk_kernel_geometry (guestfs_h *handle,
1610                 const char *device);
1611
1612 This displays the kernel's idea of the geometry of C<device>.
1613
1614 The result is in human-readable format, and not designed to
1615 be parsed.
1616
1617 This function returns a string, or NULL on error.
1618 I<The caller must free the returned string after use>.
1619
1620 =head2 guestfs_sfdisk_l
1621
1622  char *guestfs_sfdisk_l (guestfs_h *handle,
1623                 const char *device);
1624
1625 This displays the partition table on C<device>, in the
1626 human-readable output of the L<sfdisk(8)> command.  It is
1627 not intended to be parsed.
1628
1629 This function returns a string, or NULL on error.
1630 I<The caller must free the returned string after use>.
1631
1632 =head2 guestfs_stat
1633
1634  struct guestfs_stat *guestfs_stat (guestfs_h *handle,
1635                 const char *path);
1636
1637 Returns file information for the given C<path>.
1638
1639 This is the same as the C<stat(2)> system call.
1640
1641 This function returns a C<struct guestfs_stat *>
1642 (see L<stat(2)> and E<lt>guestfs-structs.hE<gt>),
1643 or NULL if there was an error.
1644 I<The caller must call C<free> after use>.
1645
1646 =head2 guestfs_statvfs
1647
1648  struct guestfs_statvfs *guestfs_statvfs (guestfs_h *handle,
1649                 const char *path);
1650
1651 Returns file system statistics for any mounted file system.
1652 C<path> should be a file or directory in the mounted file system
1653 (typically it is the mount point itself, but it doesn't need to be).
1654
1655 This is the same as the C<statvfs(2)> system call.
1656
1657 This function returns a C<struct guestfs_statvfs *>
1658 (see L<statvfs(2)> and E<lt>guestfs-structs.hE<gt>),
1659 or NULL if there was an error.
1660 I<The caller must call C<free> after use>.
1661
1662 =head2 guestfs_strings
1663
1664  char **guestfs_strings (guestfs_h *handle,
1665                 const char *path);
1666
1667 This runs the L<strings(1)> command on a file and returns
1668 the list of printable strings found.
1669
1670 This function returns a NULL-terminated array of strings
1671 (like L<environ(3)>), or NULL if there was an error.
1672 I<The caller must free the strings and the array after use>.
1673
1674 Because of the message protocol, there is a transfer limit 
1675 of somewhere between 2MB and 4MB.  To transfer large files you should use
1676 FTP.
1677
1678 =head2 guestfs_strings_e
1679
1680  char **guestfs_strings_e (guestfs_h *handle,
1681                 const char *encoding,
1682                 const char *path);
1683
1684 This is like the C<guestfs_strings> command, but allows you to
1685 specify the encoding.
1686
1687 See the L<strings(1)> manpage for the full list of encodings.
1688
1689 Commonly useful encodings are C<l> (lower case L) which will
1690 show strings inside Windows/x86 files.
1691
1692 The returned strings are transcoded to UTF-8.
1693
1694 This function returns a NULL-terminated array of strings
1695 (like L<environ(3)>), or NULL if there was an error.
1696 I<The caller must free the strings and the array after use>.
1697
1698 Because of the message protocol, there is a transfer limit 
1699 of somewhere between 2MB and 4MB.  To transfer large files you should use
1700 FTP.
1701
1702 =head2 guestfs_sync
1703
1704  int guestfs_sync (guestfs_h *handle);
1705
1706 This syncs the disk, so that any writes are flushed through to the
1707 underlying disk image.
1708
1709 You should always call this if you have modified a disk image, before
1710 closing the handle.
1711
1712 This function returns 0 on success or -1 on error.
1713
1714 =head2 guestfs_tar_in
1715
1716  int guestfs_tar_in (guestfs_h *handle,
1717                 const char *tarfile,
1718                 const char *directory);
1719
1720 This command uploads and unpacks local file C<tarfile> (an
1721 I<uncompressed> tar file) into C<directory>.
1722
1723 To upload a compressed tarball, use C<guestfs_tgz_in>.
1724
1725 This function returns 0 on success or -1 on error.
1726
1727 =head2 guestfs_tar_out
1728
1729  int guestfs_tar_out (guestfs_h *handle,
1730                 const char *directory,
1731                 const char *tarfile);
1732
1733 This command packs the contents of C<directory> and downloads
1734 it to local file C<tarfile>.
1735
1736 To download a compressed tarball, use C<guestfs_tgz_out>.
1737
1738 This function returns 0 on success or -1 on error.
1739
1740 =head2 guestfs_tgz_in
1741
1742  int guestfs_tgz_in (guestfs_h *handle,
1743                 const char *tarball,
1744                 const char *directory);
1745
1746 This command uploads and unpacks local file C<tarball> (a
1747 I<gzip compressed> tar file) into C<directory>.
1748
1749 To upload an uncompressed tarball, use C<guestfs_tar_in>.
1750
1751 This function returns 0 on success or -1 on error.
1752
1753 =head2 guestfs_tgz_out
1754
1755  int guestfs_tgz_out (guestfs_h *handle,
1756                 const char *directory,
1757                 const char *tarball);
1758
1759 This command packs the contents of C<directory> and downloads
1760 it to local file C<tarball>.
1761
1762 To download an uncompressed tarball, use C<guestfs_tar_out>.
1763
1764 This function returns 0 on success or -1 on error.
1765
1766 =head2 guestfs_touch
1767
1768  int guestfs_touch (guestfs_h *handle,
1769                 const char *path);
1770
1771 Touch acts like the L<touch(1)> command.  It can be used to
1772 update the timestamps on a file, or, if the file does not exist,
1773 to create a new zero-length file.
1774
1775 This function returns 0 on success or -1 on error.
1776
1777 =head2 guestfs_tune2fs_l
1778
1779  char **guestfs_tune2fs_l (guestfs_h *handle,
1780                 const char *device);
1781
1782 This returns the contents of the ext2, ext3 or ext4 filesystem
1783 superblock on C<device>.
1784
1785 It is the same as running C<tune2fs -l device>.  See L<tune2fs(8)>
1786 manpage for more details.  The list of fields returned isn't
1787 clearly defined, and depends on both the version of C<tune2fs>
1788 that libguestfs was built against, and the filesystem itself.
1789
1790 This function returns a NULL-terminated array of
1791 strings, or NULL if there was an error.
1792 The array of strings will always have length C<2n+1>, where
1793 C<n> keys and values alternate, followed by the trailing NULL entry.
1794 I<The caller must free the strings and the array after use>.
1795
1796 =head2 guestfs_umount
1797
1798  int guestfs_umount (guestfs_h *handle,
1799                 const char *pathordevice);
1800
1801 This unmounts the given filesystem.  The filesystem may be
1802 specified either by its mountpoint (path) or the device which
1803 contains the filesystem.
1804
1805 This function returns 0 on success or -1 on error.
1806
1807 =head2 guestfs_umount_all
1808
1809  int guestfs_umount_all (guestfs_h *handle);
1810
1811 This unmounts all mounted filesystems.
1812
1813 Some internal mounts are not unmounted by this call.
1814
1815 This function returns 0 on success or -1 on error.
1816
1817 =head2 guestfs_upload
1818
1819  int guestfs_upload (guestfs_h *handle,
1820                 const char *filename,
1821                 const char *remotefilename);
1822
1823 Upload local file C<filename> to C<remotefilename> on the
1824 filesystem.
1825
1826 C<filename> can also be a named pipe.
1827
1828 See also C<guestfs_download>.
1829
1830 This function returns 0 on success or -1 on error.
1831
1832 =head2 guestfs_vg_activate
1833
1834  int guestfs_vg_activate (guestfs_h *handle,
1835                 int activate,
1836                 char * const* const volgroups);
1837
1838 This command activates or (if C<activate> is false) deactivates
1839 all logical volumes in the listed volume groups C<volgroups>.
1840 If activated, then they are made known to the
1841 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1842 then those devices disappear.
1843
1844 This command is the same as running C<vgchange -a y|n volgroups...>
1845
1846 Note that if C<volgroups> is an empty list then B<all> volume groups
1847 are activated or deactivated.
1848
1849 This function returns 0 on success or -1 on error.
1850
1851 =head2 guestfs_vg_activate_all
1852
1853  int guestfs_vg_activate_all (guestfs_h *handle,
1854                 int activate);
1855
1856 This command activates or (if C<activate> is false) deactivates
1857 all logical volumes in all volume groups.
1858 If activated, then they are made known to the
1859 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1860 then those devices disappear.
1861
1862 This command is the same as running C<vgchange -a y|n>
1863
1864 This function returns 0 on success or -1 on error.
1865
1866 =head2 guestfs_vgcreate
1867
1868  int guestfs_vgcreate (guestfs_h *handle,
1869                 const char *volgroup,
1870                 char * const* const physvols);
1871
1872 This creates an LVM volume group called C<volgroup>
1873 from the non-empty list of physical volumes C<physvols>.
1874
1875 This function returns 0 on success or -1 on error.
1876
1877 =head2 guestfs_vgremove
1878
1879  int guestfs_vgremove (guestfs_h *handle,
1880                 const char *vgname);
1881
1882 Remove an LVM volume group C<vgname>, (for example C<VG>).
1883
1884 This also forcibly removes all logical volumes in the volume
1885 group (if any).
1886
1887 This function returns 0 on success or -1 on error.
1888
1889 =head2 guestfs_vgs
1890
1891  char **guestfs_vgs (guestfs_h *handle);
1892
1893 List all the volumes groups detected.  This is the equivalent
1894 of the L<vgs(8)> command.
1895
1896 This returns a list of just the volume group names that were
1897 detected (eg. C<VolGroup00>).
1898
1899 See also C<guestfs_vgs_full>.
1900
1901 This function returns a NULL-terminated array of strings
1902 (like L<environ(3)>), or NULL if there was an error.
1903 I<The caller must free the strings and the array after use>.
1904
1905 =head2 guestfs_vgs_full
1906
1907  struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *handle);
1908
1909 List all the volumes groups detected.  This is the equivalent
1910 of the L<vgs(8)> command.  The "full" version includes all fields.
1911
1912 This function returns a C<struct guestfs_lvm_vg_list *>
1913 (see E<lt>guestfs-structs.hE<gt>),
1914 or NULL if there was an error.
1915 I<The caller must call C<guestfs_free_lvm_vg_list> after use>.
1916
1917 =head2 guestfs_wait_ready
1918
1919  int guestfs_wait_ready (guestfs_h *handle);
1920
1921 Internally libguestfs is implemented by running a virtual machine
1922 using L<qemu(1)>.
1923
1924 You should call this after C<guestfs_launch> to wait for the launch
1925 to complete.
1926
1927 This function returns 0 on success or -1 on error.
1928
1929 =head2 guestfs_write_file
1930
1931  int guestfs_write_file (guestfs_h *handle,
1932                 const char *path,
1933                 const char *content,
1934                 int size);
1935
1936 This call creates a file called C<path>.  The contents of the
1937 file is the string C<content> (which can contain any 8 bit data),
1938 with length C<size>.
1939
1940 As a special case, if C<size> is C<0>
1941 then the length is calculated using C<strlen> (so in this case
1942 the content cannot contain embedded ASCII NULs).
1943
1944 I<NB.> Owing to a bug, writing content containing ASCII NUL
1945 characters does I<not> work, even if the length is specified.
1946 We hope to resolve this bug in a future version.  In the meantime
1947 use C<guestfs_upload>.
1948
1949 This function returns 0 on success or -1 on error.
1950
1951 Because of the message protocol, there is a transfer limit 
1952 of somewhere between 2MB and 4MB.  To transfer large files you should use
1953 FTP.
1954
1955 =head2 guestfs_zero
1956
1957  int guestfs_zero (guestfs_h *handle,
1958                 const char *device);
1959
1960 This command writes zeroes over the first few blocks of C<device>.
1961
1962 How many blocks are zeroed isn't specified (but it's I<not> enough
1963 to securely wipe the device).  It should be sufficient to remove
1964 any partition tables, filesystem superblocks and so on.
1965
1966 This function returns 0 on success or -1 on error.
1967
1968 =head2 guestfs_zerofree
1969
1970  int guestfs_zerofree (guestfs_h *handle,
1971                 const char *device);
1972
1973 This runs the I<zerofree> program on C<device>.  This program
1974 claims to zero unused inodes and disk blocks on an ext2/3
1975 filesystem, thus making it possible to compress the filesystem
1976 more effectively.
1977
1978 You should B<not> run this program if the filesystem is
1979 mounted.
1980
1981 It is possible that using this program can damage the filesystem
1982 or data on the filesystem.
1983
1984 This function returns 0 on success or -1 on error.
1985