1guestfs(3)                  Virtualization Support                  guestfs(3)
2
3
4

NAME

6       guestfs - Library for accessing and modifying virtual machine images
7

SYNOPSIS

9        #include <guestfs.h>
10
11        guestfs_h *g = guestfs_create ();
12        guestfs_add_drive (g, "guest.img");
13        guestfs_launch (g);
14        guestfs_mount (g, "/dev/sda1", "/");
15        guestfs_touch (g, "/hello");
16        guestfs_umount (g, "/");
17        guestfs_shutdown (g);
18        guestfs_close (g);
19
20        cc prog.c -o prog -lguestfs
21       or:
22        cc prog.c -o prog `pkg-config libguestfs --cflags --libs`
23

DESCRIPTION

25       Libguestfs is a library for accessing and modifying disk images and
26       virtual machines.
27
28       This manual page documents the C API.
29
30       If you are looking for an introduction to libguestfs, see the web site:
31       http://libguestfs.org/
32
33       Each virt tool has its own man page (for a full list, go to "SEE ALSO"
34       at the end of this file).
35
36       Other libguestfs manual pages:
37
38       guestfs-faq(1)
39           Frequently Asked Questions (FAQ).
40
41       guestfs-examples(3)
42           Examples of using the API from C.  For examples in other languages,
43           see "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES" below.
44
45       guestfs-recipes(1)
46           Tips and recipes.
47
48       guestfs-performance(1)
49           Performance tips and solutions.
50
51       libguestfs-test-tool(1)
52       guestfs-testing(1)
53           Help testing libguestfs.
54
55       guestfs-building(1)
56           How to build libguestfs from source.
57
58       guestfs-hacking(1)
59           Contribute code to libguestfs.
60
61       guestfs-internals(1)
62           How libguestfs works.
63
64       guestfs-security(1)
65           Security information, including CVEs affecting libguestfs.
66

API OVERVIEW

68       This section provides a gentler overview of the libguestfs API.  We
69       also try to group API calls together, where that may not be obvious
70       from reading about the individual calls in the main section of this
71       manual.
72
73   HANDLES
74       Before you can use libguestfs calls, you have to create a handle.  Then
75       you must add at least one disk image to the handle, followed by
76       launching the handle, then performing whatever operations you want, and
77       finally closing the handle.  By convention we use the single letter "g"
78       for the name of the handle variable, although of course you can use any
79       name you want.
80
81       The general structure of all libguestfs-using programs looks like this:
82
83        guestfs_h *g = guestfs_create ();
84
85        /* Call guestfs_add_drive additional times if there are
86         * multiple disk images.
87         */
88        guestfs_add_drive (g, "guest.img");
89
90        /* Most manipulation calls won't work until you've launched
91         * the handle 'g'.  You have to do this _after_ adding drives
92         * and _before_ other commands.
93         */
94        guestfs_launch (g);
95
96        /* Either: examine what partitions, LVs etc are available: */
97        char **partitions = guestfs_list_partitions (g);
98        char **logvols = guestfs_lvs (g);
99
100        /* Or: ask libguestfs to find filesystems for you: */
101        char **filesystems = guestfs_list_filesystems (g);
102
103        /* Or: use inspection (see INSPECTION section below). */
104
105        /* To access a filesystem in the image, you must mount it. */
106        guestfs_mount (g, "/dev/sda1", "/");
107
108        /* Now you can perform filesystem actions on the guest
109         * disk image.
110         */
111        guestfs_touch (g, "/hello");
112
113        /* Synchronize the disk.  This is the opposite of guestfs_launch. */
114        guestfs_shutdown (g);
115
116        /* Close and free the handle 'g'. */
117        guestfs_close (g);
118
119       The code above doesn't include any error checking.  In real code you
120       should check return values carefully for errors.  In general all
121       functions that return integers return "-1" on error, and all functions
122       that return pointers return "NULL" on error.  See section "ERROR
123       HANDLING" below for how to handle errors, and consult the documentation
124       for each function call below to see precisely how they return error
125       indications.
126
127       The code above does not free(3) the strings and arrays returned from
128       functions.  Consult the documentation for each function to find out how
129       to free the return value.
130
131       See guestfs-examples(3) for fully worked examples.
132
133   DISK IMAGES
134       The image filename ("guest.img" in the example above) could be a disk
135       image from a virtual machine, a dd(1) copy of a physical hard disk, an
136       actual block device, or simply an empty file of zeroes that you have
137       created through posix_fallocate(3).  Libguestfs lets you do useful
138       things to all of these.
139
140       The call you should use in modern code for adding drives is
141       "guestfs_add_drive_opts".  To add a disk image, allowing writes, and
142       specifying that the format is raw, do:
143
144        guestfs_add_drive_opts (g, filename,
145                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
146                                -1);
147
148       You can add a disk read-only using:
149
150        guestfs_add_drive_opts (g, filename,
151                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
152                                GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
153                                -1);
154
155       or by calling the older function "guestfs_add_drive_ro".  If you use
156       the readonly flag, libguestfs won't modify the file.  (See also "DISK
157       IMAGE FORMATS" below).
158
159       Be extremely cautious if the disk image is in use, eg. if it is being
160       used by a virtual machine.  Adding it read-write will almost certainly
161       cause disk corruption, but adding it read-only is safe.
162
163       You should usually add at least one disk image, and you may add
164       multiple disk images.  If adding multiple disk images, they usually
165       have to be "related", ie. from the same guest.  In the API, the disk
166       images are usually referred to as /dev/sda (for the first one you
167       added), /dev/sdb (for the second one you added), etc.
168
169       Once "guestfs_launch" has been called you cannot add any more images.
170       You can call "guestfs_list_devices" to get a list of the device names,
171       in the order that you added them.  See also "BLOCK DEVICE NAMING"
172       below.
173
174       There are slightly different rules when hotplugging disks (in
175       libguestfs ≥ 1.20).  See "HOTPLUGGING" below.
176
177   MOUNTING
178       Before you can read or write files, create directories and so on in a
179       disk image that contains filesystems, you have to mount those
180       filesystems using "guestfs_mount" or "guestfs_mount_ro".  If you
181       already know that a disk image contains (for example) one partition
182       with a filesystem on that partition, then you can mount it directly:
183
184        guestfs_mount (g, "/dev/sda1", "/");
185
186       where /dev/sda1 means literally the first partition (1) of the first
187       disk image that we added (/dev/sda).  If the disk contains Linux LVM2
188       logical volumes you could refer to those instead (eg. /dev/VG/LV).
189       Note that these are libguestfs virtual devices, and are nothing to do
190       with host devices.
191
192       If you are given a disk image and you don’t know what it contains then
193       you have to find out.  Libguestfs can do that too: use
194       "guestfs_list_partitions" and "guestfs_lvs" to list possible partitions
195       and LVs, and either try mounting each to see what is mountable, or else
196       examine them with "guestfs_vfs_type" or "guestfs_file".  To list just
197       filesystems, use "guestfs_list_filesystems".
198
199       Libguestfs also has a set of APIs for inspection of unknown disk images
200       (see "INSPECTION" below).  You might also want to look at higher level
201       programs built on top of libguestfs, in particular virt-inspector(1).
202
203       To mount a filesystem read-only, use "guestfs_mount_ro".  There are
204       several other variations of the "guestfs_mount_*" call.
205
206   FILESYSTEM ACCESS AND MODIFICATION
207       The majority of the libguestfs API consists of fairly low-level calls
208       for accessing and modifying the files, directories, symlinks etc on
209       mounted filesystems.  There are over a hundred such calls which you can
210       find listed in detail below in this man page, and we don't even pretend
211       to cover them all in this overview.
212
213       Specify filenames as full paths, starting with "/" and including the
214       mount point.
215
216       For example, if you mounted a filesystem at "/" and you want to read
217       the file called "etc/passwd" then you could do:
218
219        char *data = guestfs_cat (g, "/etc/passwd");
220
221       This would return "data" as a newly allocated buffer containing the
222       full content of that file (with some conditions: see also "DOWNLOADING"
223       below), or "NULL" if there was an error.
224
225       As another example, to create a top-level directory on that filesystem
226       called "var" you would do:
227
228        guestfs_mkdir (g, "/var");
229
230       To create a symlink you could do:
231
232        guestfs_ln_s (g, "/etc/init.d/portmap",
233                      "/etc/rc3.d/S30portmap");
234
235       Libguestfs will reject attempts to use relative paths and there is no
236       concept of a current working directory.
237
238       Libguestfs can return errors in many situations: for example if the
239       filesystem isn't writable, or if a file or directory that you requested
240       doesn't exist.  If you are using the C API (documented here) you have
241       to check for those error conditions after each call.  (Other language
242       bindings turn these errors into exceptions).
243
244       File writes are affected by the per-handle umask, set by calling
245       "guestfs_umask" and defaulting to 022.  See "UMASK".
246
247       Since libguestfs 1.18, it is possible to mount the libguestfs
248       filesystem on a local directory, subject to some restrictions.  See
249       "MOUNT LOCAL" below.
250
251   PARTITIONING
252       Libguestfs contains API calls to read, create and modify partition
253       tables on disk images.
254
255       In the common case where you want to create a single partition covering
256       the whole disk, you should use the "guestfs_part_disk" call:
257
258        const char *parttype = "mbr";
259        if (disk_is_larger_than_2TB)
260          parttype = "gpt";
261        guestfs_part_disk (g, "/dev/sda", parttype);
262
263       Obviously this effectively wipes anything that was on that disk image
264       before.
265
266   LVM2
267       Libguestfs provides access to a large part of the LVM2 API, such as
268       "guestfs_lvcreate" and "guestfs_vgremove".  It won't make much sense
269       unless you familiarize yourself with the concepts of physical volumes,
270       volume groups and logical volumes.
271
272       This author strongly recommends reading the LVM HOWTO, online at
273       http://tldp.org/HOWTO/LVM-HOWTO/.
274
275   DOWNLOADING
276       Use "guestfs_cat" to download small, text only files.  This call cannot
277       handle files containing any ASCII NUL ("\0") characters.  However the
278       API is very simple to use.
279
280       "guestfs_read_file" can be used to read files which contain arbitrary 8
281       bit data, since it returns a (pointer, size) pair.
282
283       "guestfs_download" can be used to download any file, with no limits on
284       content or size.
285
286       To download multiple files, see "guestfs_tar_out" and
287       "guestfs_tgz_out".
288
289   UPLOADING
290       To write a small file with fixed content, use "guestfs_write".  To
291       create a file of all zeroes, use "guestfs_truncate_size" (sparse) or
292       "guestfs_fallocate64" (with all disk blocks allocated).  There are a
293       variety of other functions for creating test files, for example
294       "guestfs_fill" and "guestfs_fill_pattern".
295
296       To upload a single file, use "guestfs_upload".  This call has no limits
297       on file content or size.
298
299       To upload multiple files, see "guestfs_tar_in" and "guestfs_tgz_in".
300
301       However the fastest way to upload large numbers of arbitrary files is
302       to turn them into a squashfs or CD ISO (see mksquashfs(8) and
303       mkisofs(8)), then attach this using "guestfs_add_drive_ro".  If you add
304       the drive in a predictable way (eg. adding it last after all other
305       drives) then you can get the device name from "guestfs_list_devices"
306       and mount it directly using "guestfs_mount_ro".  Note that squashfs
307       images are sometimes non-portable between kernel versions, and they
308       don't support labels or UUIDs.  If you want to pre-build an image or
309       you need to mount it using a label or UUID, use an ISO image instead.
310
311   COPYING
312       There are various different commands for copying between files and
313       devices and in and out of the guest filesystem.  These are summarised
314       in the table below.
315
316       file to file
317           Use "guestfs_cp" to copy a single file, or "guestfs_cp_a" to copy
318           directories recursively.
319
320           To copy part of a file (offset and size) use
321           "guestfs_copy_file_to_file".
322
323       file to device
324       device to file
325       device to device
326           Use "guestfs_copy_file_to_device", "guestfs_copy_device_to_file",
327           or "guestfs_copy_device_to_device".
328
329           Example: duplicate the contents of an LV:
330
331            guestfs_copy_device_to_device (g,
332                    "/dev/VG/Original", "/dev/VG/Copy",
333                    /* -1 marks the end of the list of optional parameters */
334                    -1);
335
336           The destination (/dev/VG/Copy) must be at least as large as the
337           source (/dev/VG/Original).  To copy less than the whole source
338           device, use the optional "size" parameter:
339
340            guestfs_copy_device_to_device (g,
341                    "/dev/VG/Original", "/dev/VG/Copy",
342                    GUESTFS_COPY_DEVICE_TO_DEVICE_SIZE, 10000,
343                    -1);
344
345       file on the host to file or device
346           Use "guestfs_upload".  See "UPLOADING" above.
347
348       file or device to file on the host
349           Use "guestfs_download".  See "DOWNLOADING" above.
350
351   UPLOADING AND DOWNLOADING TO PIPES AND FILE DESCRIPTORS
352       Calls like "guestfs_upload", "guestfs_download", "guestfs_tar_in",
353       "guestfs_tar_out" etc appear to only take filenames as arguments, so it
354       appears you can only upload and download to files.  However many
355       Un*x-like hosts let you use the special device files /dev/stdin,
356       /dev/stdout, /dev/stderr and /dev/fd/N to read and write from stdin,
357       stdout, stderr, and arbitrary file descriptor N.
358
359       For example, virt-cat(1) writes its output to stdout by doing:
360
361        guestfs_download (g, filename, "/dev/stdout");
362
363       and you can write tar output to a file descriptor "fd" by doing:
364
365        char devfd[64];
366        snprintf (devfd, sizeof devfd, "/dev/fd/%d", fd);
367        guestfs_tar_out (g, "/", devfd);
368
369   LISTING FILES
370       "guestfs_ll" is just designed for humans to read (mainly when using the
371       guestfish(1)-equivalent command "ll").
372
373       "guestfs_ls" is a quick way to get a list of files in a directory from
374       programs, as a flat list of strings.
375
376       "guestfs_readdir" is a programmatic way to get a list of files in a
377       directory, plus additional information about each one.  It is more
378       equivalent to using the readdir(3) call on a local filesystem.
379
380       "guestfs_find" and "guestfs_find0" can be used to recursively list
381       files.
382
383   RUNNING COMMANDS
384       Although libguestfs is primarily an API for manipulating files inside
385       guest images, we also provide some limited facilities for running
386       commands inside guests.
387
388       There are many limitations to this:
389
390       ·   The kernel version that the command runs under will be different
391           from what it expects.
392
393       ·   If the command needs to communicate with daemons, then most likely
394           they won't be running.
395
396       ·   The command will be running in limited memory.
397
398       ·   The network may not be available unless you enable it (see
399           "guestfs_set_network").
400
401       ·   Only supports Linux guests (not Windows, BSD, etc).
402
403       ·   Architecture limitations (eg. won’t work for a PPC guest on an X86
404           host).
405
406       ·   For SELinux guests, you may need to relabel the guest after
407           creating new files.  See "SELINUX" below.
408
409       ·   Security: It is not safe to run commands from untrusted, possibly
410           malicious guests.  These commands may attempt to exploit your
411           program by sending unexpected output.  They could also try to
412           exploit the Linux kernel or qemu provided by the libguestfs
413           appliance.  They could use the network provided by the libguestfs
414           appliance to bypass ordinary network partitions and firewalls.
415           They could use the elevated privileges or different SELinux context
416           of your program to their advantage.
417
418           A secure alternative is to use libguestfs to install a "firstboot"
419           script (a script which runs when the guest next boots normally),
420           and to have this script run the commands you want in the normal
421           context of the running guest, network security and so on.  For
422           information about other security issues, see guestfs-security(1).
423
424       The two main API calls to run commands are "guestfs_command" and
425       "guestfs_sh" (there are also variations).
426
427       The difference is that "guestfs_sh" runs commands using the shell, so
428       any shell globs, redirections, etc will work.
429
430   CONFIGURATION FILES
431       To read and write configuration files in Linux guest filesystems, we
432       strongly recommend using Augeas.  For example, Augeas understands how
433       to read and write, say, a Linux shadow password file or X.org
434       configuration file, and so avoids you having to write that code.
435
436       The main Augeas calls are bound through the "guestfs_aug_*" APIs.  We
437       don't document Augeas itself here because there is excellent
438       documentation on the http://augeas.net/ website.
439
440       If you don’t want to use Augeas (you fool!) then try calling
441       "guestfs_read_lines" to get the file as a list of lines which you can
442       iterate over.
443
444   SYSTEMD JOURNAL FILES
445       To read the systemd journal from a Linux guest, use the
446       "guestfs_journal_*" APIs starting with "guestfs_journal_open".
447
448       Consult the journal documentation here: sd-journal(3),
449       sd_journal_open(3).
450
451   SELINUX
452       We support SELinux guests.  However it is not possible to load the
453       SELinux policy of the guest into the appliance kernel.  Therefore the
454       strategy for dealing with SELinux guests is to relabel them after
455       making changes.
456
457       In libguestfs ≥ 1.34 there is a new API, "guestfs_setfiles", which can
458       be used for this.  To properly use this API you have to parse the guest
459       SELinux configuration.  See the virt-customize(1) module
460       customize/SELinux_relabel.ml for how to do this.
461
462       A simpler but slower alternative is to touch /.autorelabel in the
463       guest, which means that the guest will relabel itself at next boot.
464
465       Libguestfs ≤ 1.32 had APIs "guestfs_set_selinux",
466       "guestfs_get_selinux", "guestfs_setcon" and "guestfs_getcon".  These
467       did not work properly, are deprecated, and should not be used in new
468       code.
469
470   UMASK
471       Certain calls are affected by the current file mode creation mask (the
472       "umask").  In particular ones which create files or directories, such
473       as "guestfs_touch", "guestfs_mknod" or "guestfs_mkdir".  This affects
474       either the default mode that the file is created with or modifies the
475       mode that you supply.
476
477       The default umask is 022, so files are created with modes such as 0644
478       and directories with 0755.
479
480       There are two ways to avoid being affected by umask.  Either set umask
481       to 0 (call "guestfs_umask (g, 0)" early after launching).  Or call
482       "guestfs_chmod" after creating each file or directory.
483
484       For more information about umask, see umask(2).
485
486   LABELS AND UUIDS
487       Many filesystems, devices and logical volumes support either labels
488       (short strings like "BOOT" which might not be unique) and/or UUIDs
489       (globally unique IDs).
490
491       For filesystems, use "guestfs_vfs_label" or "guestfs_vfs_uuid" to read
492       the label or UUID.  Some filesystems let you call "guestfs_set_label"
493       or "guestfs_set_uuid" to change the label or UUID.
494
495       You can locate a filesystem by its label or UUID using
496       "guestfs_findfs_label" or "guestfs_findfs_uuid".
497
498       For LVM2 (which supports only UUIDs), there is a rich set of APIs for
499       fetching UUIDs, fetching UUIDs of the contained objects, and changing
500       UUIDs.  See: "guestfs_lvuuid", "guestfs_vguuid", "guestfs_pvuuid",
501       "guestfs_vglvuuids", "guestfs_vgpvuuids", "guestfs_vgchange_uuid",
502       "guestfs_vgchange_uuid_all", "guestfs_pvchange_uuid",
503       "guestfs_pvchange_uuid_all".
504
505       Note when cloning a filesystem, device or whole guest, it is a good
506       idea to set new randomly generated UUIDs on the copy.
507
508   ENCRYPTED DISKS
509       Libguestfs allows you to access Linux guests which have been encrypted
510       using whole disk encryption that conforms to the Linux Unified Key
511       Setup (LUKS) standard.  This includes nearly all whole disk encryption
512       systems used by modern Linux guests.
513
514       Use "guestfs_vfs_type" to identify LUKS-encrypted block devices (it
515       returns the string "crypto_LUKS").
516
517       Then open these devices by calling "guestfs_luks_open".  Obviously you
518       will require the passphrase!
519
520       Opening a LUKS device creates a new device mapper device called
521       /dev/mapper/mapname (where "mapname" is the string you supply to
522       "guestfs_luks_open").  Reads and writes to this mapper device are
523       decrypted from and encrypted to the underlying block device
524       respectively.
525
526       LVM volume groups on the device can be made visible by calling
527       "guestfs_vgscan" followed by "guestfs_vg_activate_all".  The logical
528       volume(s) can now be mounted in the usual way.
529
530       Use the reverse process to close a LUKS device.  Unmount any logical
531       volumes on it, deactivate the volume groups by calling
532       "guestfs_vg_activate (g, 0, ["/dev/VG"])".  Then close the mapper
533       device by calling "guestfs_luks_close" on the /dev/mapper/mapname
534       device (not the underlying encrypted block device).
535
536   MOUNT LOCAL
537       In libguestfs ≥ 1.18, it is possible to mount the libguestfs filesystem
538       on a local directory and access it using ordinary POSIX calls and
539       programs.
540
541       Availability of this is subject to a number of restrictions: it
542       requires FUSE (the Filesystem in USErspace), and libfuse must also have
543       been available when libguestfs was compiled.  FUSE may require that a
544       kernel module is loaded, and it may be necessary to add the current
545       user to a special "fuse" group.  See the documentation for your
546       distribution and http://fuse.sf.net for further information.
547
548       The call to mount the libguestfs filesystem on a local directory is
549       "guestfs_mount_local" (q.v.) followed by "guestfs_mount_local_run".
550       The latter does not return until you unmount the filesystem.  The
551       reason is that the call enters the FUSE main loop and processes kernel
552       requests, turning them into libguestfs calls.  An alternative design
553       would have been to create a background thread to do this, but
554       libguestfs doesn't require pthreads.  This way is also more flexible:
555       for example the user can create another thread for
556       "guestfs_mount_local_run".
557
558       "guestfs_mount_local" needs a certain amount of time to set up the
559       mountpoint.  The mountpoint is not ready to use until the call returns.
560       At this point, accesses to the filesystem will block until the main
561       loop is entered (ie. "guestfs_mount_local_run").  So if you need to
562       start another process to access the filesystem, put the fork between
563       "guestfs_mount_local" and "guestfs_mount_local_run".
564
565       MOUNT LOCAL COMPATIBILITY
566
567       Since local mounting was only added in libguestfs 1.18, and may not be
568       available even in these builds, you should consider writing code so
569       that it doesn't depend on this feature, and can fall back to using
570       libguestfs file system calls.
571
572       If libguestfs was compiled without support for "guestfs_mount_local"
573       then calling it will return an error with errno set to "ENOTSUP" (see
574       "guestfs_last_errno").
575
576       MOUNT LOCAL PERFORMANCE
577
578       Libguestfs on top of FUSE performs quite poorly.  For best performance
579       do not use it.  Use ordinary libguestfs filesystem calls, upload,
580       download etc. instead.
581
582   HOTPLUGGING
583       In libguestfs ≥ 1.20, you may add drives and remove after calling
584       "guestfs_launch".  There are some restrictions, see below.  This is
585       called hotplugging.
586
587       Only a subset of the backends support hotplugging (currently only the
588       libvirt backend has support).  It also requires that you use libvirt ≥
589       0.10.3 and qemu ≥ 1.2.
590
591       To hot-add a disk, simply call "guestfs_add_drive_opts" after
592       "guestfs_launch".  It is mandatory to specify the "label" parameter so
593       that the newly added disk has a predictable name.  For example:
594
595        if (guestfs_launch (g) == -1)
596          error ("launch failed");
597
598        if (guestfs_add_drive_opts (g, filename,
599                                    GUESTFS_ADD_DRIVE_OPTS_LABEL, "newdisk",
600                                    -1) == -1)
601          error ("hot-add of disk failed");
602
603        if (guestfs_part_disk ("/dev/disk/guestfs/newdisk", "mbr") == -1)
604          error ("partitioning of hot-added disk failed");
605
606       To hot-remove a disk, call "guestfs_remove_drive".  You can call this
607       before or after "guestfs_launch".  You can only remove disks that were
608       previously added with a label.
609
610       Backends that support hotplugging do not require that you add ≥ 1 disk
611       before calling launch.  When hotplugging is supported you don't need to
612       add any disks.
613
614   REMOTE STORAGE
615       CEPH
616
617       Libguestfs can access Ceph (librbd/RBD) disks.
618
619       To do this, set the optional "protocol" and "server" parameters of
620       "guestfs_add_drive_opts" like this:
621
622        char **servers = { "ceph1.example.org:3000", /* ... */, NULL };
623        guestfs_add_drive_opts (g, "pool/image",
624                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
625                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "rbd",
626                                GUESTFS_ADD_DRIVE_OPTS_SERVER, servers,
627                                GUESTFS_ADD_DRIVE_OPTS_USERNAME, "rbduser",
628                                GUESTFS_ADD_DRIVE_OPTS_SECRET, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
629                                -1);
630
631       "servers" (the "server" parameter) is a list of one or more Ceph
632       servers.  The server string is documented in "guestfs_add_drive_opts".
633       The "username" and "secret" parameters are also optional, and if not
634       given, then no authentication will be used.
635
636       FTP, HTTP AND TFTP
637
638       Libguestfs can access remote disks over FTP, FTPS, HTTP, HTTPS or TFTP
639       protocols.
640
641       To do this, set the optional "protocol" and "server" parameters of
642       "guestfs_add_drive_opts" like this:
643
644        char **servers = { "www.example.org", NULL };
645        guestfs_add_drive_opts (g, "/disk.img",
646                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
647                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "http",
648                                GUESTFS_ADD_DRIVE_OPTS_SERVER, servers,
649                                -1);
650
651       The "protocol" can be one of "ftp", "ftps", "http", "https" or "tftp".
652
653       "servers" (the "server" parameter) is a list which must have a single
654       element.  The single element is a string defining the web, FTP or TFTP
655       server.  The format of this string is documented in
656       "guestfs_add_drive_opts".
657
658       GLUSTER
659
660       Libguestfs can access Gluster disks.
661
662       To do this, set the optional "protocol" and "server" parameters of
663       "guestfs_add_drive_opts" like this:
664
665        char **servers = { "gluster.example.org:24007", NULL };
666        guestfs_add_drive_opts (g, "volname/image",
667                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
668                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "gluster",
669                                GUESTFS_ADD_DRIVE_OPTS_SERVER, servers,
670                                -1);
671
672       "servers" (the "server" parameter) is a list which must have a single
673       element.  The single element is a string defining the Gluster server.
674       The format of this string is documented in "guestfs_add_drive_opts".
675
676       Note that gluster usually requires the client process (ie. libguestfs)
677       to run as root and will give unfathomable errors if it is not (eg. "No
678       data available").
679
680       ISCSI
681
682       Libguestfs can access iSCSI disks remotely.
683
684       To do this, set the optional "protocol" and "server" parameters like
685       this:
686
687        char **server = { "iscsi.example.org:3000", NULL };
688        guestfs_add_drive_opts (g, "target-iqn-name/lun",
689                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
690                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "iscsi",
691                                GUESTFS_ADD_DRIVE_OPTS_SERVER, server,
692                                -1);
693
694       The "server" parameter is a list which must have a single element.  The
695       single element is a string defining the iSCSI server.  The format of
696       this string is documented in "guestfs_add_drive_opts".
697
698       NETWORK BLOCK DEVICE
699
700       Libguestfs can access Network Block Device (NBD) disks remotely.
701
702       To do this, set the optional "protocol" and "server" parameters of
703       "guestfs_add_drive_opts" like this:
704
705        char **server = { "nbd.example.org:3000", NULL };
706        guestfs_add_drive_opts (g, "" /* export name - see below */,
707                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
708                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "nbd",
709                                GUESTFS_ADD_DRIVE_OPTS_SERVER, server,
710                                -1);
711
712       Notes:
713
714       ·   "server" is in fact a list of servers.  For NBD you must always
715           supply a list with a single element.  (Other remote protocols
716           require zero or more than one server, hence the requirement for
717           this parameter to be a list).
718
719       ·   The "server" string is documented in "guestfs_add_drive_opts".  To
720           connect to a local qemu-nbd instance over a Unix domain socket, use
721           "unix:/path/to/socket".
722
723       ·   The "filename" parameter is the NBD export name.  Use an empty
724           string to mean the default export.  Many NBD servers, including
725           qemu-nbd, do not support export names.
726
727       ·   If using qemu-nbd as your server, you should always specify the
728           "-t" option.  The reason is that libguestfs may open several
729           connections to the server.
730
731       ·   The libvirt backend requires that you set the "format" parameter of
732           "guestfs_add_drive_opts" accurately when you use writable NBD
733           disks.
734
735       ·   The libvirt backend has a bug that stops Unix domain socket
736           connections from working:
737           https://bugzilla.redhat.com/show_bug.cgi?id=922888
738
739       ·   The direct backend does not support readonly connections because of
740           a bug in qemu: https://bugs.launchpad.net/qemu/+bug/1155677
741
742       SHEEPDOG
743
744       Libguestfs can access Sheepdog disks.
745
746       To do this, set the optional "protocol" and "server" parameters of
747       "guestfs_add_drive_opts" like this:
748
749        char **servers = { /* optional servers ... */ NULL };
750        guestfs_add_drive_opts (g, "volume",
751                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
752                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "sheepdog",
753                                GUESTFS_ADD_DRIVE_OPTS_SERVER, servers,
754                                -1);
755
756       The optional list of "servers" may be zero or more server addresses
757       ("hostname:port").  The format of the server strings is documented in
758       "guestfs_add_drive_opts".
759
760       SSH
761
762       Libguestfs can access disks over a Secure Shell (SSH) connection.
763
764       To do this, set the "protocol" and "server" and (optionally) "username"
765       parameters of "guestfs_add_drive_opts" like this:
766
767        char **server = { "remote.example.com", NULL };
768        guestfs_add_drive_opts (g, "/path/to/disk.img",
769                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
770                                GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, "ssh",
771                                GUESTFS_ADD_DRIVE_OPTS_SERVER, server,
772                                GUESTFS_ADD_DRIVE_OPTS_USERNAME, "remoteuser",
773                                -1);
774
775       The format of the server string is documented in
776       "guestfs_add_drive_opts".
777
778   INSPECTION
779       Libguestfs has APIs for inspecting an unknown disk image to find out if
780       it contains operating systems, an install CD or a live CD.
781
782       Add all disks belonging to the unknown virtual machine and call
783       "guestfs_launch" in the usual way.
784
785       Then call "guestfs_inspect_os".  This function uses other libguestfs
786       calls and certain heuristics, and returns a list of operating systems
787       that were found.  An empty list means none were found.  A single
788       element is the root filesystem of the operating system.  For dual- or
789       multi-boot guests, multiple roots can be returned, each one
790       corresponding to a separate operating system.  (Multi-boot virtual
791       machines are extremely rare in the world of virtualization, but since
792       this scenario can happen, we have built libguestfs to deal with it.)
793
794       For each root, you can then call various "guestfs_inspect_get_*"
795       functions to get additional details about that operating system.  For
796       example, call "guestfs_inspect_get_type" to return the string "windows"
797       or "linux" for Windows and Linux-based operating systems respectively.
798
799       Un*x-like and Linux-based operating systems usually consist of several
800       filesystems which are mounted at boot time (for example, a separate
801       boot partition mounted on /boot).  The inspection rules are able to
802       detect how filesystems correspond to mount points.  Call
803       "guestfs_inspect_get_mountpoints" to get this mapping.  It might return
804       a hash table like this example:
805
806        /boot => /dev/sda1
807        /     => /dev/vg_guest/lv_root
808        /usr  => /dev/vg_guest/lv_usr
809
810       The caller can then make calls to "guestfs_mount" to mount the
811       filesystems as suggested.
812
813       Be careful to mount filesystems in the right order (eg. / before /usr).
814       Sorting the keys of the hash by length, shortest first, should work.
815
816       Inspection currently only works for some common operating systems.
817       Contributors are welcome to send patches for other operating systems
818       that we currently cannot detect.
819
820       Encrypted disks must be opened before inspection.  See "ENCRYPTED
821       DISKS" for more details.  The "guestfs_inspect_os" function just
822       ignores any encrypted devices.
823
824       A note on the implementation: The call "guestfs_inspect_os" performs
825       inspection and caches the results in the guest handle.  Subsequent
826       calls to "guestfs_inspect_get_*" return this cached information, but do
827       not re-read the disks.  If you change the content of the guest disks,
828       you can redo inspection by calling "guestfs_inspect_os" again.
829       ("guestfs_inspect_list_applications2" works a little differently from
830       the other calls and does read the disks.  See documentation for that
831       function for details).
832
833       INSPECTING INSTALL DISKS
834
835       Libguestfs (since 1.9.4) can detect some install disks, install CDs,
836       live CDs and more.
837
838       Further information is available about the operating system that can be
839       installed using the regular inspection APIs like
840       "guestfs_inspect_get_product_name", "guestfs_inspect_get_major_version"
841       etc.
842
843   SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS
844       Libguestfs can mount NTFS partitions.  It does this using the
845       http://www.ntfs-3g.org/ driver.
846
847       DRIVE LETTERS AND PATHS
848
849       DOS and Windows still use drive letters, and the filesystems are always
850       treated as case insensitive by Windows itself, and therefore you might
851       find a Windows configuration file referring to a path like
852       "c:\windows\system32".  When the filesystem is mounted in libguestfs,
853       that directory might be referred to as /WINDOWS/System32.
854
855       Drive letter mappings can be found using inspection (see "INSPECTION"
856       and "guestfs_inspect_get_drive_mappings")
857
858       Dealing with separator characters (backslash vs forward slash) is
859       outside the scope of libguestfs, but usually a simple character
860       replacement will work.
861
862       To resolve the case insensitivity of paths, call
863       "guestfs_case_sensitive_path".
864
865       LONG FILENAMES ON NTFS
866
867       NTFS supports filenames up to 255 characters long.  "Character" means a
868       2 byte UTF-16 codepoint which can encode the most common Unicode
869       codepoints.
870
871       Most Linux filesystems support filenames up to 255 bytes.  This means
872       you may get an error:
873
874        File name too long
875
876       when you copy a file from NTFS to a Linux filesystem if the name, when
877       reencoded as UTF-8, would exceed 255 bytes in length.
878
879       This will most often happen when using non-ASCII names that are longer
880       than ~127 characters (eg. Greek, Cyrillic) or longer than ~85
881       characters (Asian languages).
882
883       A workaround is not to try to store such long filenames on Linux native
884       filesystems.  Since the tar(1) format can store unlimited length
885       filenames, keep the files in a tarball.
886
887       ACCESSING THE WINDOWS REGISTRY
888
889       Libguestfs also provides some help for decoding Windows Registry "hive"
890       files, through a separate C library called hivex(3).
891
892       Before libguestfs 1.19.35 you had to download the hive file, operate on
893       it locally using hivex, and upload it again.  Since this version, we
894       have included the major hivex APIs directly in the libguestfs API (see
895       "guestfs_hivex_open").  This means that if you have opened a Windows
896       guest, you can read and write the registry directly.
897
898       See also virt-win-reg(1).
899
900       SYMLINKS ON NTFS-3G FILESYSTEMS
901
902       Ntfs-3g tries to rewrite "Junction Points" and NTFS "symbolic links" to
903       provide something which looks like a Linux symlink.  The way it tries
904       to do the rewriting is described here:
905
906       http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-symbolic-links/
907
908       The essential problem is that ntfs-3g simply does not have enough
909       information to do a correct job.  NTFS links can contain drive letters
910       and references to external device GUIDs that ntfs-3g has no way of
911       resolving.  It is almost certainly the case that libguestfs callers
912       should ignore what ntfs-3g does (ie. don't use "guestfs_readlink" on
913       NTFS volumes).
914
915       Instead if you encounter a symbolic link on an ntfs-3g filesystem, use
916       "guestfs_lgetxattr" to read the "system.ntfs_reparse_data" extended
917       attribute, and read the raw reparse data from that (you can find the
918       format documented in various places around the web).
919
920       EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS
921
922       There are other useful extended attributes that can be read from
923       ntfs-3g filesystems (using "guestfs_getxattr").  See:
924
925       http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/
926
927       WINDOWS HIBERNATION AND WINDOWS 8 FAST STARTUP
928
929       Windows guests which have been hibernated (instead of fully shut down)
930       cannot be mounted.  This is a limitation of ntfs-3g.  You will see an
931       error like this:
932
933        The disk contains an unclean file system (0, 0).
934        Metadata kept in Windows cache, refused to mount.
935        Failed to mount '/dev/sda2': Operation not permitted
936        The NTFS partition is in an unsafe state. Please resume
937        and shutdown Windows fully (no hibernation or fast
938        restarting), or mount the volume read-only with the
939        'ro' mount option.
940
941       In Windows 8, the shutdown button does not shut down the guest at all.
942       Instead it usually hibernates the guest.  This is known as "fast
943       startup".
944
945       Some suggested workarounds are:
946
947       ·   Mount read-only (eg. "guestfs_mount_ro").
948
949       ·   On Windows 8, turn off fast startup.  It is in the Control Panel →
950           Power Options → Choose what the power buttons do → Change settings
951           that are currently unavailable → Turn on fast startup.
952
953       ·   On Windows 7 and earlier, shut the guest off properly instead of
954           hibernating it.
955
956   RESIZE2FS ERRORS
957       The "guestfs_resize2fs", "guestfs_resize2fs_size" and
958       "guestfs_resize2fs_M" calls are used to resize ext2/3/4 filesystems.
959
960       The underlying program (resize2fs(8)) requires that the filesystem is
961       clean and recently fsck'd before you can resize it.  Also, if the
962       resize operation fails for some reason, then you had to call fsck the
963       filesystem again to fix it.
964
965       In libguestfs "lt" 1.17.14, you usually had to call "guestfs_e2fsck_f"
966       before the resize.  However, in "ge" 1.17.14, e2fsck(8) is called
967       automatically before the resize, so you no longer need to do this.
968
969       The resize2fs(8) program can still fail, in which case it prints an
970       error message similar to:
971
972        Please run 'e2fsck -fy <device>' to fix the filesystem
973        after the aborted resize operation.
974
975       You can do this by calling "guestfs_e2fsck" with the "forceall" option.
976       However in the context of disk images, it is usually better to avoid
977       this situation, eg. by rolling back to an earlier snapshot, or by
978       copying and resizing and on failure going back to the original.
979
980   USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES
981       Although we don’t want to discourage you from using the C API, we will
982       mention here that the same API is also available in other languages.
983
984       The API is broadly identical in all supported languages.  This means
985       that the C call "guestfs_add_drive_ro(g,file)" is
986       "$g->add_drive_ro($file)" in Perl, "g.add_drive_ro(file)" in Python,
987       and "g#add_drive_ro file" in OCaml.  In other words, a straightforward,
988       predictable isomorphism between each language.
989
990       Error messages are automatically transformed into exceptions if the
991       language supports it.
992
993       We don’t try to "object orientify" parts of the API in OO languages,
994       although contributors are welcome to write higher level APIs above what
995       we provide in their favourite languages if they wish.
996
997       C++ You can use the guestfs.h header file from C++ programs.  The C++
998           API is identical to the C API.  C++ classes and exceptions are not
999           used.
1000
1001       C#  The C# bindings are highly experimental.  Please read the warnings
1002           at the top of csharp/Libguestfs.cs.
1003
1004       Erlang
1005           See guestfs-erlang(3).
1006
1007       GObject
1008           Experimental GObject bindings (with GObject Introspection support)
1009           are available.
1010
1011           See guestfs-gobject(3).
1012
1013       Go  See guestfs-golang(3).
1014
1015       Haskell
1016           This language binding is working but incomplete:
1017
1018           ·   Functions with optional arguments are not bound.  Implementing
1019               optional arguments in Haskell seems to be very complex.
1020
1021           ·   Events are not bound.
1022
1023           ·   Functions with the following return types are not bound:
1024
1025               ·   Any function returning a struct.
1026
1027               ·   Any function returning a list of structs.
1028
1029               ·   A few functions that return fixed length buffers
1030                   (specifically ones declared "RBufferOut" in the generator).
1031
1032               ·   A tiny number of obscure functions that return constant
1033                   strings (specifically ones declared "RConstOptString" in
1034                   the generator).
1035
1036       Java
1037           Full documentation is contained in the Javadoc which is distributed
1038           with libguestfs.  For examples, see guestfs-java(3).
1039
1040       Lua See guestfs-lua(3).
1041
1042       OCaml
1043           See guestfs-ocaml(3).
1044
1045       Perl
1046           See guestfs-perl(3) and Sys::Guestfs(3).
1047
1048       PHP For documentation see "README-PHP" supplied with libguestfs sources
1049           or in the php-libguestfs package for your distribution.
1050
1051           The PHP binding only works correctly on 64 bit machines.
1052
1053       Python
1054           See guestfs-python(3).
1055
1056       Ruby
1057           See guestfs-ruby(3).
1058
1059           For JRuby, use the Java bindings.
1060
1061       shell scripts
1062           See guestfish(1).
1063
1064   LIBGUESTFS GOTCHAS
1065       http://en.wikipedia.org/wiki/Gotcha_(programming): "A feature of a
1066       system [...] that works in the way it is documented but is
1067       counterintuitive and almost invites mistakes."
1068
1069       Since we developed libguestfs and the associated tools, there are
1070       several things we would have designed differently, but are now stuck
1071       with for backwards compatibility or other reasons.  If there is ever a
1072       libguestfs 2.0 release, you can expect these to change.  Beware of
1073       them.
1074
1075       Read-only should be the default.
1076           In guestfish(3), --ro should be the default, and you should have to
1077           specify --rw if you want to make changes to the image.
1078
1079           This would reduce the potential to corrupt live VM images.
1080
1081           Note that many filesystems change the disk when you just mount and
1082           unmount, even if you didn't perform any writes.  You need to use
1083           "guestfs_add_drive_ro" to guarantee that the disk is not changed.
1084
1085       guestfish command line is hard to use.
1086           guestfish disk.img doesn't do what people expect (open disk.img for
1087           examination).  It tries to run a guestfish command disk.img which
1088           doesn't exist, so it fails.  In earlier versions of guestfish the
1089           error message was also unintuitive, but we have corrected this
1090           since.  Like the Bourne shell, we should have used "guestfish -c
1091           command" to run commands.
1092
1093       guestfish megabyte modifiers don’t work right on all commands
1094           In recent guestfish you can use "1M" to mean 1 megabyte (and
1095           similarly for other modifiers).  What guestfish actually does is to
1096           multiply the number part by the modifier part and pass the result
1097           to the C API.  However this doesn't work for a few APIs which
1098           aren't expecting bytes, but are already expecting some other unit
1099           (eg. megabytes).
1100
1101           The most common is "guestfs_lvcreate".  The guestfish command:
1102
1103            lvcreate LV VG 100M
1104
1105           does not do what you might expect.  Instead because
1106           "guestfs_lvcreate" is already expecting megabytes, this tries to
1107           create a 100 terabyte (100 megabytes * megabytes) logical volume.
1108           The error message you get from this is also a little obscure.
1109
1110           This could be fixed in the generator by specially marking
1111           parameters and return values which take bytes or other units.
1112
1113       Ambiguity between devices and paths
1114           There is a subtle ambiguity in the API between a device name (eg.
1115           /dev/sdb2) and a similar pathname.  A file might just happen to be
1116           called "sdb2" in the directory /dev (consider some non-Unix VM
1117           image).
1118
1119           In the current API we usually resolve this ambiguity by having two
1120           separate calls, for example "guestfs_checksum" and
1121           "guestfs_checksum_device".  Some API calls are ambiguous and
1122           (incorrectly) resolve the problem by detecting if the path supplied
1123           begins with /dev/.
1124
1125           To avoid both the ambiguity and the need to duplicate some calls,
1126           we could make paths/devices into structured names.  One way to do
1127           this would be to use a notation like grub ("hd(0,0)"), although
1128           nobody really likes this aspect of grub.  Another way would be to
1129           use a structured type, equivalent to this OCaml type:
1130
1131            type path = Path of string | Device of int | Partition of int * int
1132
1133           which would allow you to pass arguments like:
1134
1135            Path "/foo/bar"
1136            Device 1            (* /dev/sdb, or perhaps /dev/sda *)
1137            Partition (1, 2)    (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)
1138            Path "/dev/sdb2"    (* not a device *)
1139
1140           As you can see there are still problems to resolve even with this
1141           representation.  Also consider how it might work in guestfish.
1142
1143   KEYS AND PASSPHRASES
1144       Certain libguestfs calls take a parameter that contains sensitive key
1145       material, passed in as a C string.
1146
1147       In the future we would hope to change the libguestfs implementation so
1148       that keys are mlock(2)-ed into physical RAM, and thus can never end up
1149       in swap.  However this is not done at the moment, because of the
1150       complexity of such an implementation.
1151
1152       Therefore you should be aware that any key parameter you pass to
1153       libguestfs might end up being written out to the swap partition.  If
1154       this is a concern, scrub the swap partition or don't use libguestfs on
1155       encrypted devices.
1156
1157   MULTIPLE HANDLES AND MULTIPLE THREADS
1158       All high-level libguestfs actions are synchronous.  If you want to use
1159       libguestfs asynchronously then you must create a thread.
1160
1161       Threads in libguestfs  1.38
1162
1163       In libguestfs ≥ 1.38, each handle ("guestfs_h") contains a lock which
1164       is acquired automatically when you call a libguestfs function.  The
1165       practical effect of this is you can call libguestfs functions with the
1166       same handle from multiple threads without needing to do any locking.
1167
1168       Also in libguestfs ≥ 1.38, the last error on the handle
1169       ("guestfs_last_error", "guestfs_last_errno") is stored in thread-local
1170       storage, so it is safe to write code like:
1171
1172        if (guestfs_add_drive_ro (g, drive) == -1)
1173          fprintf (stderr, "error was: %s\n", guestfs_last_error (g));
1174
1175       even when other threads may be concurrently using the same handle "g".
1176
1177       Threads in libguestfs < 1.38
1178
1179       In libguestfs < 1.38, you must use the handle only from a single
1180       thread.  Either use the handle exclusively from one thread, or provide
1181       your own mutex so that two threads cannot issue calls on the same
1182       handle at the same time.  Even apparently innocent functions like
1183       "guestfs_get_trace" are not safe to be called from multiple threads
1184       without a mutex in libguestfs < 1.38.
1185
1186       Use "guestfs_set_identifier" to make it simpler to identify threads in
1187       trace output.
1188
1189   PATH
1190       Libguestfs needs a supermin appliance, which it finds by looking along
1191       an internal path.
1192
1193       By default it looks for these in the directory "$libdir/guestfs" (eg.
1194       /usr/local/lib/guestfs or /usr/lib64/guestfs).
1195
1196       Use "guestfs_set_path" or set the environment variable
1197       "LIBGUESTFS_PATH" to change the directories that libguestfs will search
1198       in.  The value is a colon-separated list of paths.  The current
1199       directory is not searched unless the path contains an empty element or
1200       ".".  For example "LIBGUESTFS_PATH=:/usr/lib/guestfs" would search the
1201       current directory and then /usr/lib/guestfs.
1202
1203   QEMU WRAPPERS
1204       If you want to compile your own qemu, run qemu from a non-standard
1205       location, or pass extra arguments to qemu, then you can write a shell-
1206       script wrapper around qemu.
1207
1208       There is one important rule to remember: you must "exec qemu" as the
1209       last command in the shell script (so that qemu replaces the shell and
1210       becomes the direct child of the libguestfs-using program).  If you
1211       don't do this, then the qemu process won't be cleaned up correctly.
1212
1213       Here is an example of a wrapper, where I have built my own copy of qemu
1214       from source:
1215
1216        #!/bin/sh -
1217        qemudir=/home/rjones/d/qemu
1218        exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "$@"
1219
1220       Save this script as /tmp/qemu.wrapper (or wherever), "chmod +x", and
1221       then use it by setting the LIBGUESTFS_HV environment variable.  For
1222       example:
1223
1224        LIBGUESTFS_HV=/tmp/qemu.wrapper guestfish
1225
1226       Note that libguestfs also calls qemu with the -help and -version
1227       options in order to determine features.
1228
1229       Wrappers can also be used to edit the options passed to qemu.  In the
1230       following example, the "-machine ..." option ("-machine" and the
1231       following argument) are removed from the command line and replaced with
1232       "-machine pc,accel=tcg".  The while loop iterates over the options
1233       until it finds the right one to remove, putting the remaining options
1234       into the "args" array.
1235
1236        #!/bin/bash -
1237
1238        i=0
1239        while [ $# -gt 0 ]; do
1240            case "$1" in
1241            -machine)
1242                shift 2;;
1243            *)
1244                args[i]="$1"
1245                (( i++ ))
1246                shift ;;
1247            esac
1248        done
1249
1250        exec qemu-kvm -machine pc,accel=tcg "${args[@]}"
1251
1252   BACKEND
1253       The backend (previously known as the "attach method") controls how
1254       libguestfs creates and/or connects to the backend daemon, eg. by
1255       starting qemu directly, or using libvirt to manage an appliance,
1256       running User-Mode Linux, or connecting to an already running daemon.
1257
1258       You can set the backend by calling "guestfs_set_backend", or by setting
1259       the environment variable "LIBGUESTFS_BACKEND".
1260
1261       Possible backends are described below:
1262
1263       "direct"
1264       "appliance"
1265           Run qemu directly to launch an appliance.
1266
1267           "direct" and "appliance" are synonyms.
1268
1269           This is the ordinary method and normally the default, but see the
1270           note below.
1271
1272       "libvirt"
1273       "libvirt:null"
1274       "libvirt:URI"
1275           Use libvirt to launch and manage the appliance.
1276
1277           "libvirt" causes libguestfs to choose a suitable URI for creating
1278           session guests.  If using the libvirt backend, you almost always
1279           should use this.
1280
1281           "libvirt:null" causes libguestfs to use the "NULL" connection URI,
1282           which causes libvirt to try to guess what the user meant.  You
1283           probably don't want to use this.
1284
1285           "libvirt:URI" uses URI as the libvirt connection URI (see
1286           http://libvirt.org/uri.html).  The typical libvirt backend with a
1287           URI would be "libvirt:qemu:///session"
1288
1289           The libvirt backend supports more features, including hotplugging
1290           (see "HOTPLUGGING") and sVirt.
1291
1292       "uml"
1293           Run the User-Mode Linux kernel.  The location of the kernel is set
1294           using $LIBGUESTFS_HV or using the "guestfs_set_qemu" API (note that
1295           qemu is not involved, we just reuse the same variable in the handle
1296           for convenience).
1297
1298           User-Mode Linux can be much faster, simpler and more lightweight
1299           than using a full-blown virtual machine, but it also has some
1300           shortcomings.  See "USER-MODE LINUX BACKEND" below.
1301
1302       "unix:path"
1303           Connect to the Unix domain socket path.
1304
1305           This method lets you connect to an existing daemon or (using
1306           virtio-serial) to a live guest.  For more information, see
1307           "ATTACHING TO RUNNING DAEMONS".
1308
1309       "direct" is usually the default backend.  However since libguestfs ≥
1310       1.19.24, libguestfs can be built with a different default by doing:
1311
1312        ./configure --with-default-backend=...
1313
1314       To find out if libguestfs was compiled with a different default
1315       backend, do:
1316
1317        unset LIBGUESTFS_BACKEND
1318        guestfish get-backend
1319
1320   BACKEND SETTINGS
1321       Each backend can be configured by passing a list of strings.  You can
1322       either call "guestfs_set_backend_settings" with a list of strings, or
1323       set the "LIBGUESTFS_BACKEND_SETTINGS" environment variable to a colon-
1324       separated list of strings (before creating the handle).
1325
1326       force_tcg
1327
1328       Using:
1329
1330        export LIBGUESTFS_BACKEND_SETTINGS=force_tcg
1331
1332       will force the direct and libvirt backends to use TCG (software
1333       emulation) instead of KVM (hardware accelerated virtualization).
1334
1335       gdb
1336
1337       The direct backend supports:
1338
1339        export LIBGUESTFS_BACKEND_SETTINGS=gdb
1340
1341       When this is set, qemu will not start running the appliance
1342       immediately.  It will wait for you to connect to it using gdb:
1343
1344        $ gdb
1345        (gdb) symbol-file /path/to/vmlinux
1346        (gdb) target remote tcp::1234
1347        (gdb) cont
1348
1349       You can then debug the appliance kernel, which is useful to debug boot
1350       failures (especially ones where there are no debug messages printed -
1351       tip: look in the kernel "log_buf").
1352
1353       On Fedora, install "kernel-debuginfo" for the "vmlinux" file
1354       (containing symbols).  Make sure the symbols precisely match the kernel
1355       being used.
1356
1357   ATTACHING TO RUNNING DAEMONS
1358       Note (1): This is highly experimental and has a tendency to eat babies.
1359       Use with caution.
1360
1361       Note (2): This section explains how to attach to a running daemon from
1362       a low level perspective.  For most users, simply using virt tools such
1363       as guestfish(1) with the --live option will "just work".
1364
1365       Using guestfs_set_backend
1366
1367       By calling "guestfs_set_backend" you can change how the library
1368       connects to the "guestfsd" daemon in "guestfs_launch" (read
1369       "ARCHITECTURE" in guestfs-internals(1) for some background).
1370
1371       The normal backend is "direct", where a small appliance is created
1372       containing the daemon, and then the library connects to this.
1373       "libvirt" or "libvirt:URI" are alternatives that use libvirt to start
1374       the appliance.
1375
1376       Setting the backend to "unix:path" (where path is the path of a Unix
1377       domain socket) causes "guestfs_launch" to connect to an existing daemon
1378       over the Unix domain socket.
1379
1380       The normal use for this is to connect to a running virtual machine that
1381       contains a "guestfsd" daemon, and send commands so you can read and
1382       write files inside the live virtual machine.
1383
1384       Using guestfs_add_domain with live flag
1385
1386       "guestfs_add_domain" provides some help for getting the correct
1387       backend.  If you pass the "live" option to this function, then (if the
1388       virtual machine is running) it will examine the libvirt XML looking for
1389       a virtio-serial channel to connect to:
1390
1391        <domain>
1392          ...
1393          <devices>
1394            ...
1395            <channel type='unix'>
1396              <source mode='bind' path='/path/to/socket'/>
1397              <target type='virtio' name='org.libguestfs.channel.0'/>
1398            </channel>
1399            ...
1400          </devices>
1401        </domain>
1402
1403       "guestfs_add_domain" extracts /path/to/socket and sets the backend to
1404       "unix:/path/to/socket".
1405
1406       Some of the libguestfs tools (including guestfish) support a --live
1407       option which is passed through to "guestfs_add_domain" thus allowing
1408       you to attach to and modify live virtual machines.
1409
1410       The virtual machine needs to have been set up beforehand so that it has
1411       the virtio-serial channel and so that guestfsd is running inside it.
1412
1413   USER-MODE LINUX BACKEND
1414       Setting the following environment variables (or the equivalent in the
1415       API) selects the User-Mode Linux backend:
1416
1417        export LIBGUESTFS_BACKEND=uml
1418        export LIBGUESTFS_HV=/path/to/vmlinux
1419
1420       "vmlinux" (or it may be called "linux") is the Linux binary, compiled
1421       to run as a userspace process.  Note that we reuse the qemu variable in
1422       the handle for convenience; qemu is not involved.
1423
1424       User-Mode Linux can be faster and more lightweight than running a full-
1425       blown virtual machine as the backend (especially if you are already
1426       running libguestfs in a virtual machine or cloud instance), but it also
1427       has some shortcomings compared to the usual qemu/KVM-based backend.
1428
1429       BUILDING USER-MODE LINUX FROM SOURCE
1430
1431       Your Linux distro may provide UML in which case you can ignore this
1432       section.
1433
1434       These instructions are adapted from:
1435       http://user-mode-linux.sourceforge.net/source.html
1436
1437       1. Check out Linux sources
1438           Clone the Linux git repository or download the Linux source
1439           tarball.
1440
1441       2. Configure the kernel
1442           Note: All ‘make’ commands must have "ARCH=um" added.
1443
1444            make menuconfig ARCH=um
1445
1446           Make sure any filesystem drivers that you need are compiled into
1447           the kernel.
1448
1449           Currently, it needs a large amount of extra work to get modules
1450           working.  It’s recommended that you disable module support in the
1451           kernel configuration, which will cause everything to be compiled
1452           into the image.
1453
1454       3. Build the kernel
1455            make ARCH=um
1456
1457           This will leave a file called "linux" or "vmlinux" in the top-level
1458           directory.  This is the UML kernel.  You should set "LIBGUESTFS_HV"
1459           to point to this file.
1460
1461       USER-MODE LINUX DIFFERENCES FROM KVM
1462
1463       UML only supports raw-format images
1464           Only plain raw-format images will work.  No qcow2, no backing
1465           files.
1466
1467       UML does not support any remote drives
1468           No NBD, etc.
1469
1470       UML only works on ix86 and x86-64
1471       UML is experimental
1472           In particular, support for UML in libguestfs depends on support for
1473           UML in the upstream kernel.  If UML was ever removed from the
1474           upstream Linux kernel, then we might remove it from libguestfs too.
1475
1476   ABI GUARANTEE
1477       We guarantee the libguestfs ABI (binary interface), for public, high-
1478       level actions as outlined in this section.  Although we will deprecate
1479       some actions, for example if they get replaced by newer calls, we will
1480       keep the old actions forever.  This allows you the developer to program
1481       in confidence against the libguestfs API.
1482
1483   BLOCK DEVICE NAMING
1484       Libguestfs defines /dev/sd* as the standard naming scheme for devices
1485       passed to API calls.  So /dev/sda means "the first device added by
1486       "guestfs_add_drive_opts"", and /dev/sdb3 means "the third partition on
1487       the second device".
1488
1489       Internally device names are sometimes translated, but this should not
1490       be visible at the API level.
1491
1492       DISK LABELS
1493
1494       In libguestfs ≥ 1.20, you can give a label to a disk when you add it,
1495       using the optional "label" parameter to "guestfs_add_drive_opts".
1496       (Note that disk labels are different from and not related to filesystem
1497       labels).
1498
1499       Not all versions of libguestfs support setting a disk label, and when
1500       it is supported, it is limited to 20 ASCII characters "[a-zA-Z]".
1501
1502       When you add a disk with a label, it can either be addressed using
1503       /dev/sd*, or using /dev/disk/guestfs/label.  Partitions on the disk can
1504       be addressed using /dev/disk/guestfs/labelpartnum.
1505
1506       Listing devices ("guestfs_list_devices") and partitions
1507       ("guestfs_list_partitions") returns the block device names.  However
1508       you can use "guestfs_list_disk_labels" to map disk labels to block
1509       device and partition names.
1510
1511   NULL DISKS
1512       When adding a disk using, eg., "guestfs_add_drive", you can set the
1513       filename to "/dev/null".  This string is treated specially by
1514       libguestfs, causing it to add a "null disk".
1515
1516       A null disk has the following properties:
1517
1518       ·   A null disk will appear as a normal device, eg. in calls to
1519           "guestfs_list_devices".
1520
1521       ·   You may add "/dev/null" multiple times.
1522
1523       ·   You should not try to access a null disk in any way.  For example,
1524           you shouldn't try to read it or mount it.
1525
1526       Null disks are used for three main purposes:
1527
1528       1.  Performance testing of libguestfs (see guestfs-performance(1)).
1529
1530       2.  The internal test suite.
1531
1532       3.  If you want to use libguestfs APIs that don’t refer to disks, since
1533           libguestfs requires that at least one disk is added, you should add
1534           a null disk.
1535
1536           For example, to test if a feature is available, use code like this:
1537
1538            guestfs_h *g;
1539            char **groups = [ "btrfs", NULL ];
1540
1541            g = guestfs_create ();
1542            guestfs_add_drive (g, "/dev/null");
1543            guestfs_launch (g);
1544            if (guestfs_available (g, groups) == 0) {
1545              // group(s) are available
1546            } else {
1547              // group(s) are not available
1548            }
1549            guestfs_close (g);
1550
1551   DISK IMAGE FORMATS
1552       Virtual disks come in a variety of formats.  Some common formats are
1553       listed below.
1554
1555       Note that libguestfs itself is not responsible for handling the disk
1556       format: this is done using qemu(1).  If support for a particular format
1557       is missing or broken, this has to be fixed in qemu.
1558
1559       COMMON VIRTUAL DISK IMAGE FORMATS
1560
1561       raw Raw format is simply a dump of the sequential bytes of the virtual
1562           hard disk.  There is no header, container, compression or
1563           processing of any sort.
1564
1565           Since raw format requires no translation to read or write, it is
1566           both fast and very well supported by qemu and all other
1567           hypervisors.  You can consider it to be a universal format that any
1568           hypervisor can access.
1569
1570           Raw format files are not compressed and so take up the full space
1571           of the original disk image even when they are empty.  A variation
1572           (on Linux/Unix at least) is to not store ranges of all-zero bytes
1573           by storing the file as a sparse file.  This "variant format" is
1574           sometimes called raw sparse.  Many utilities, including
1575           virt-sparsify(1), can make raw disk images sparse.
1576
1577       qcow2
1578           Qcow2 is the native disk image format used by qemu.  Internally it
1579           uses a two-level directory structure so that only blocks containing
1580           data are stored in the file.  It also has many other features such
1581           as compression, snapshots and backing files.
1582
1583           There are at least two distinct variants of this format, although
1584           qemu (and hence libguestfs) handles both transparently to the user.
1585
1586       vmdk
1587           VMDK is VMware’s native disk image format.  There are many
1588           variations.  Modern qemu (hence libguestfs) supports most
1589           variations, but you should be aware that older versions of qemu had
1590           some very bad data-corrupting bugs in this area.
1591
1592           Note that VMware ESX exposes files with the name guest-flat.vmdk.
1593           These are not VMDK.  They are raw format files which happen to have
1594           a ".vmdk" extension.
1595
1596       vdi VDI is VirtualBox’s native disk image format.  Qemu (hence
1597           libguestfs) has generally good support for this.
1598
1599       vpc
1600       vhd VPC (old) and VHD (modern) are the native disk image format of
1601           Microsoft (and previously, Connectix) Virtual PC and Hyper-V.
1602
1603       Obsolete formats
1604           The following formats are obsolete and should not be used: qcow
1605           (aka qcow1), cow, bochs.
1606
1607       DETECTING THE FORMAT OF A DISK IMAGE
1608
1609       Firstly note there is a security issue with auto-detecting the format
1610       of a disk image.  It may or may not apply in your use case.  Read
1611       "CVE-2010-3851" below.
1612
1613       Libguestfs offers an API to get the format of a disk image
1614       ("guestfs_disk_format"), and it is safest to use this.
1615
1616       Don’t be tempted to try parsing the text / human-readable output of
1617       "qemu-img" since it cannot be parsed reliably and securely.  Also do
1618       not use the "file" command since the output of that changes over time.
1619

CONNECTION MANAGEMENT

1621   guestfs_h *
1622       "guestfs_h" is the opaque type representing a connection handle.
1623       Create a handle by calling "guestfs_create" or "guestfs_create_flags".
1624       Call "guestfs_close" to free the handle and release all resources used.
1625
1626       For information on using multiple handles and threads, see the section
1627       "MULTIPLE HANDLES AND MULTIPLE THREADS" above.
1628
1629   guestfs_create
1630        guestfs_h *guestfs_create (void);
1631
1632       Create a connection handle.
1633
1634       On success this returns a non-NULL pointer to a handle.  On error it
1635       returns NULL.
1636
1637       You have to "configure" the handle after creating it.  This includes
1638       calling "guestfs_add_drive_opts" (or one of the equivalent calls) on
1639       the handle at least once.
1640
1641       After configuring the handle, you have to call "guestfs_launch".
1642
1643       You may also want to configure error handling for the handle.  See the
1644       "ERROR HANDLING" section below.
1645
1646   guestfs_create_flags
1647        guestfs_h *guestfs_create_flags (unsigned flags [, ...]);
1648
1649       Create a connection handle, supplying extra flags and extra arguments
1650       to control how the handle is created.
1651
1652       On success this returns a non-NULL pointer to a handle.  On error it
1653       returns NULL.
1654
1655       "guestfs_create" is equivalent to calling guestfs_create_flags(0).
1656
1657       The following flags may be logically ORed together.  (Currently no
1658       extra arguments are used).
1659
1660       "GUESTFS_CREATE_NO_ENVIRONMENT"
1661           Don’t parse any environment variables (such as "LIBGUESTFS_DEBUG"
1662           etc).
1663
1664           You can call "guestfs_parse_environment" or
1665           "guestfs_parse_environment_list" afterwards to parse environment
1666           variables.  Alternately, don't call these functions if you want the
1667           handle to be unaffected by environment variables.  See the example
1668           below.
1669
1670           The default (if this flag is not given) is to implicitly call
1671           "guestfs_parse_environment".
1672
1673       "GUESTFS_CREATE_NO_CLOSE_ON_EXIT"
1674           Don’t try to close the handle in an atexit(3) handler if the
1675           program exits without explicitly closing the handle.
1676
1677           The default (if this flag is not given) is to install such an
1678           atexit handler.
1679
1680       USING "GUESTFS_CREATE_NO_ENVIRONMENT"
1681
1682       You might use "GUESTFS_CREATE_NO_ENVIRONMENT" and an explicit call to
1683       "guestfs_parse_environment" like this:
1684
1685        guestfs_h *g;
1686        int r;
1687
1688        g = guestfs_create_flags (GUESTFS_CREATE_NO_ENVIRONMENT);
1689        if (!g) {
1690          perror ("guestfs_create_flags");
1691          exit (EXIT_FAILURE);
1692        }
1693        r = guestfs_parse_environment (g);
1694        if (r == -1)
1695          exit (EXIT_FAILURE);
1696
1697       Or to create a handle which is unaffected by environment variables,
1698       omit the call to "guestfs_parse_environment" from the above code.
1699
1700       The above code has another advantage which is that any errors from
1701       parsing the environment are passed through the error handler, whereas
1702       "guestfs_create" prints errors on stderr and ignores them.
1703
1704   guestfs_close
1705        void guestfs_close (guestfs_h *g);
1706
1707       This closes the connection handle and frees up all resources used.  If
1708       a close callback was set on the handle, then it is called.
1709
1710       The correct way to close the handle is:
1711
1712        if (guestfs_shutdown (g) == -1) {
1713          /* handle write errors here */
1714        }
1715        guestfs_close (g);
1716
1717       "guestfs_shutdown" is only needed if all of the following are true:
1718
1719       1.  one or more disks were added in read-write mode, and
1720
1721       2.  guestfs_launch was called, and
1722
1723       3.  you made some changes, and
1724
1725       4.  you have a way to handle write errors (eg. by exiting with an error
1726           code or reporting something to the user).
1727

ERROR HANDLING

1729       API functions can return errors.  For example, almost all functions
1730       that return "int" will return "-1" to indicate an error.
1731
1732       Additional information is available for errors: an error message string
1733       and optionally an error number (errno) if the thing that failed was a
1734       system call.
1735
1736       You can get at the additional information about the last error on the
1737       handle by calling "guestfs_last_error", "guestfs_last_errno", and/or by
1738       setting up an error handler with "guestfs_set_error_handler".
1739
1740       When the handle is created, a default error handler is installed which
1741       prints the error message string to "stderr".  For small short-running
1742       command line programs it is sufficient to do:
1743
1744        if (guestfs_launch (g) == -1)
1745          exit (EXIT_FAILURE);
1746
1747       since the default error handler will ensure that an error message has
1748       been printed to "stderr" before the program exits.
1749
1750       For other programs the caller will almost certainly want to install an
1751       alternate error handler or do error handling in-line as in the example
1752       below.  The non-C language bindings all install NULL error handlers and
1753       turn errors into exceptions using code similar to this:
1754
1755        const char *msg;
1756        int errnum;
1757
1758        /* This disables the default behaviour of printing errors
1759           on stderr. */
1760        guestfs_set_error_handler (g, NULL, NULL);
1761
1762        if (guestfs_launch (g) == -1) {
1763          /* Examine the error message and print it, throw it,
1764             etc. */
1765          msg = guestfs_last_error (g);
1766          errnum = guestfs_last_errno (g);
1767
1768          fprintf (stderr, "%s", msg);
1769          if (errnum != 0)
1770            fprintf (stderr, ": %s", strerror (errnum));
1771          fprintf (stderr, "\n");
1772
1773          /* ... */
1774        }
1775
1776       "guestfs_create" returns "NULL" if the handle cannot be created, and
1777       because there is no handle if this happens there is no way to get
1778       additional error information.  Since libguestfs ≥ 1.20, you can use
1779       "guestfs_create_flags" to properly deal with errors during handle
1780       creation, although the vast majority of programs can continue to use
1781       "guestfs_create" and not worry about this situation.
1782
1783       Out of memory errors are handled differently.  The default action is to
1784       call abort(3).  If this is undesirable, then you can set a handler
1785       using "guestfs_set_out_of_memory_handler".
1786
1787   guestfs_last_error
1788        const char *guestfs_last_error (guestfs_h *g);
1789
1790       This returns the last error message that happened on "g".  If there has
1791       not been an error since the handle was created, then this returns
1792       "NULL".
1793
1794       Note the returned string does not have a newline character at the end.
1795       Most error messages are single lines.  Some are split over multiple
1796       lines and contain "\n" characters within the string but not at the end.
1797
1798       The lifetime of the returned string is until the next error occurs on
1799       the same handle, or "guestfs_close" is called.  If you need to keep it
1800       longer, copy it.
1801
1802   guestfs_last_errno
1803        int guestfs_last_errno (guestfs_h *g);
1804
1805       This returns the last error number (errno) that happened on "g".
1806
1807       If successful, an errno integer not equal to zero is returned.
1808
1809       In many cases the special errno "ENOTSUP" is returned if you tried to
1810       call a function or use a feature which is not supported.
1811
1812       If no error number is available, this returns 0.  This call can return
1813       0 in three situations:
1814
1815       1.  There has not been any error on the handle.
1816
1817       2.  There has been an error but the errno was meaningless.  This
1818           corresponds to the case where the error did not come from a failed
1819           system call, but for some other reason.
1820
1821       3.  There was an error from a failed system call, but for some reason
1822           the errno was not captured and returned.  This usually indicates a
1823           bug in libguestfs.
1824
1825       Libguestfs tries to convert the errno from inside the appliance into a
1826       corresponding errno for the caller (not entirely trivial: the appliance
1827       might be running a completely different operating system from the
1828       library and error numbers are not standardized across Un*xen).  If this
1829       could not be done, then the error is translated to "EINVAL".  In
1830       practice this should only happen in very rare circumstances.
1831
1832   guestfs_set_error_handler
1833        typedef void (*guestfs_error_handler_cb) (guestfs_h *g,
1834                                                  void *opaque,
1835                                                  const char *msg);
1836        void guestfs_set_error_handler (guestfs_h *g,
1837                                        guestfs_error_handler_cb cb,
1838                                        void *opaque);
1839
1840       The callback "cb" will be called if there is an error.  The parameters
1841       passed to the callback are an opaque data pointer and the error message
1842       string.
1843
1844       "errno" is not passed to the callback.  To get that the callback must
1845       call "guestfs_last_errno".
1846
1847       Note that the message string "msg" is freed as soon as the callback
1848       function returns, so if you want to stash it somewhere you must make
1849       your own copy.
1850
1851       The default handler prints messages on "stderr".
1852
1853       If you set "cb" to "NULL" then no handler is called.
1854
1855   guestfs_get_error_handler
1856        guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,
1857                                                            void **opaque_rtn);
1858
1859       Returns the current error handler callback.
1860
1861   guestfs_push_error_handler
1862        void guestfs_push_error_handler (guestfs_h *g,
1863                                         guestfs_error_handler_cb cb,
1864                                         void *opaque);
1865
1866       This is the same as "guestfs_set_error_handler", except that the old
1867       error handler is stashed away in a stack inside the handle.  You can
1868       restore the previous error handler by calling
1869       "guestfs_pop_error_handler".
1870
1871       Use the following code to temporarily disable errors around a function:
1872
1873        guestfs_push_error_handler (g, NULL, NULL);
1874        guestfs_mkdir (g, "/foo"); /* We don't care if this fails. */
1875        guestfs_pop_error_handler (g);
1876
1877   guestfs_pop_error_handler
1878        void guestfs_pop_error_handler (guestfs_h *g);
1879
1880       Restore the previous error handler (see "guestfs_push_error_handler").
1881
1882       If you pop the stack too many times, then the default error handler is
1883       restored.
1884
1885   guestfs_set_out_of_memory_handler
1886        typedef void (*guestfs_abort_cb) (void);
1887        void guestfs_set_out_of_memory_handler (guestfs_h *g,
1888                                                guestfs_abort_cb);
1889
1890       The callback "cb" will be called if there is an out of memory
1891       situation.  Note this callback must not return.
1892
1893       The default is to call abort(3).
1894
1895       You cannot set "cb" to "NULL".  You can’t ignore out of memory
1896       situations.
1897
1898   guestfs_get_out_of_memory_handler
1899        guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);
1900
1901       This returns the current out of memory handler.
1902

API CALLS

1904   guestfs_acl_delete_def_file
1905        int
1906        guestfs_acl_delete_def_file (guestfs_h *g,
1907                                     const char *dir);
1908
1909       This function deletes the default POSIX Access Control List (ACL)
1910       attached to directory "dir".
1911
1912       This function returns 0 on success or -1 on error.
1913
1914       This function depends on the feature "acl".  See also
1915       "guestfs_feature_available".
1916
1917       (Added in 1.19.63)
1918
1919   guestfs_acl_get_file
1920        char *
1921        guestfs_acl_get_file (guestfs_h *g,
1922                              const char *path,
1923                              const char *acltype);
1924
1925       This function returns the POSIX Access Control List (ACL) attached to
1926       "path".  The ACL is returned in "long text form" (see acl(5)).
1927
1928       The "acltype" parameter may be:
1929
1930       "access"
1931           Return the ordinary (access) ACL for any file, directory or other
1932           filesystem object.
1933
1934       "default"
1935           Return the default ACL.  Normally this only makes sense if "path"
1936           is a directory.
1937
1938       This function returns a string, or NULL on error.  The caller must free
1939       the returned string after use.
1940
1941       This function depends on the feature "acl".  See also
1942       "guestfs_feature_available".
1943
1944       (Added in 1.19.63)
1945
1946   guestfs_acl_set_file
1947        int
1948        guestfs_acl_set_file (guestfs_h *g,
1949                              const char *path,
1950                              const char *acltype,
1951                              const char *acl);
1952
1953       This function sets the POSIX Access Control List (ACL) attached to
1954       "path".
1955
1956       The "acltype" parameter may be:
1957
1958       "access"
1959           Set the ordinary (access) ACL for any file, directory or other
1960           filesystem object.
1961
1962       "default"
1963           Set the default ACL.  Normally this only makes sense if "path" is a
1964           directory.
1965
1966       The "acl" parameter is the new ACL in either "long text form" or "short
1967       text form" (see acl(5)).  The new ACL completely replaces any previous
1968       ACL on the file.  The ACL must contain the full Unix permissions (eg.
1969       "u::rwx,g::rx,o::rx").
1970
1971       If you are specifying individual users or groups, then the mask field
1972       is also required (eg. "m::rwx"), followed by the "u:ID:..." and/or
1973       "g:ID:..." field(s).  A full ACL string might therefore look like this:
1974
1975        u::rwx,g::rwx,o::rwx,m::rwx,u:500:rwx,g:500:rwx
1976        \ Unix permissions / \mask/ \      ACL        /
1977
1978       You should use numeric UIDs and GIDs.  To map usernames and groupnames
1979       to the correct numeric ID in the context of the guest, use the Augeas
1980       functions (see "guestfs_aug_init").
1981
1982       This function returns 0 on success or -1 on error.
1983
1984       This function depends on the feature "acl".  See also
1985       "guestfs_feature_available".
1986
1987       (Added in 1.19.63)
1988
1989   guestfs_add_cdrom
1990        int
1991        guestfs_add_cdrom (guestfs_h *g,
1992                           const char *filename);
1993
1994       This function is deprecated.  In new code, use the
1995       "guestfs_add_drive_ro" call instead.
1996
1997       Deprecated functions will not be removed from the API, but the fact
1998       that they are deprecated indicates that there are problems with correct
1999       use of these functions.
2000
2001       This function adds a virtual CD-ROM disk image to the guest.
2002
2003       The image is added as read-only drive, so this function is equivalent
2004       of "guestfs_add_drive_ro".
2005
2006       This function returns 0 on success or -1 on error.
2007
2008       (Added in 0.3)
2009
2010   guestfs_add_domain
2011        int
2012        guestfs_add_domain (guestfs_h *g,
2013                            const char *dom,
2014                            ...);
2015
2016       You may supply a list of optional arguments to this call.  Use zero or
2017       more of the following pairs of parameters, and terminate the list with
2018       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
2019
2020        GUESTFS_ADD_DOMAIN_LIBVIRTURI, const char *libvirturi,
2021        GUESTFS_ADD_DOMAIN_READONLY, int readonly,
2022        GUESTFS_ADD_DOMAIN_IFACE, const char *iface,
2023        GUESTFS_ADD_DOMAIN_LIVE, int live,
2024        GUESTFS_ADD_DOMAIN_ALLOWUUID, int allowuuid,
2025        GUESTFS_ADD_DOMAIN_READONLYDISK, const char *readonlydisk,
2026        GUESTFS_ADD_DOMAIN_CACHEMODE, const char *cachemode,
2027        GUESTFS_ADD_DOMAIN_DISCARD, const char *discard,
2028        GUESTFS_ADD_DOMAIN_COPYONREAD, int copyonread,
2029
2030       This function adds the disk(s) attached to the named libvirt domain
2031       "dom".  It works by connecting to libvirt, requesting the domain and
2032       domain XML from libvirt, parsing it for disks, and calling
2033       "guestfs_add_drive_opts" on each one.
2034
2035       The number of disks added is returned.  This operation is atomic: if an
2036       error is returned, then no disks are added.
2037
2038       This function does some minimal checks to make sure the libvirt domain
2039       is not running (unless "readonly" is true).  In a future version we
2040       will try to acquire the libvirt lock on each disk.
2041
2042       Disks must be accessible locally.  This often means that adding disks
2043       from a remote libvirt connection (see https://libvirt.org/remote.html)
2044       will fail unless those disks are accessible via the same device path
2045       locally too.
2046
2047       The optional "libvirturi" parameter sets the libvirt URI (see
2048       https://libvirt.org/uri.html).  If this is not set then we connect to
2049       the default libvirt URI (or one set through an environment variable,
2050       see the libvirt documentation for full details).
2051
2052       The optional "live" flag controls whether this call will try to connect
2053       to a running virtual machine "guestfsd" process if it sees a suitable
2054       <channel> element in the libvirt XML definition.  The default (if the
2055       flag is omitted) is never to try.  See "ATTACHING TO RUNNING DAEMONS"
2056       for more information.
2057
2058       If the "allowuuid" flag is true (default is false) then a UUID may be
2059       passed instead of the domain name.  The "dom" string is treated as a
2060       UUID first and looked up, and if that lookup fails then we treat "dom"
2061       as a name as usual.
2062
2063       The optional "readonlydisk" parameter controls what we do for disks
2064       which are marked <readonly/> in the libvirt XML.  Possible values are:
2065
2066       readonlydisk = "error"
2067           If "readonly" is false:
2068
2069           The whole call is aborted with an error if any disk with the
2070           <readonly/> flag is found.
2071
2072           If "readonly" is true:
2073
2074           Disks with the <readonly/> flag are added read-only.
2075
2076       readonlydisk = "read"
2077           If "readonly" is false:
2078
2079           Disks with the <readonly/> flag are added read-only.  Other disks
2080           are added read/write.
2081
2082           If "readonly" is true:
2083
2084           Disks with the <readonly/> flag are added read-only.
2085
2086       readonlydisk = "write" (default)
2087           If "readonly" is false:
2088
2089           Disks with the <readonly/> flag are added read/write.
2090
2091           If "readonly" is true:
2092
2093           Disks with the <readonly/> flag are added read-only.
2094
2095       readonlydisk = "ignore"
2096           If "readonly" is true or false:
2097
2098           Disks with the <readonly/> flag are skipped.
2099
2100       If present, the value of "logical_block_size" attribute of <blockio/>
2101       tag in libvirt XML will be passed as "blocksize" parameter to
2102       "guestfs_add_drive_opts".
2103
2104       The other optional parameters are passed directly through to
2105       "guestfs_add_drive_opts".
2106
2107       On error this function returns -1.
2108
2109       (Added in 1.7.4)
2110
2111   guestfs_add_domain_va
2112        int
2113        guestfs_add_domain_va (guestfs_h *g,
2114                               const char *dom,
2115                               va_list args);
2116
2117       This is the "va_list variant" of "guestfs_add_domain".
2118
2119       See "CALLS WITH OPTIONAL ARGUMENTS".
2120
2121   guestfs_add_domain_argv
2122        int
2123        guestfs_add_domain_argv (guestfs_h *g,
2124                                 const char *dom,
2125                                 const struct guestfs_add_domain_argv *optargs);
2126
2127       This is the "argv variant" of "guestfs_add_domain".
2128
2129       See "CALLS WITH OPTIONAL ARGUMENTS".
2130
2131   guestfs_add_drive
2132        int
2133        guestfs_add_drive (guestfs_h *g,
2134                           const char *filename);
2135
2136       This function is provided for backwards compatibility with earlier
2137       versions of libguestfs.  It simply calls "guestfs_add_drive_opts" with
2138       no optional arguments.
2139
2140       (Added in 0.3)
2141
2142   guestfs_add_drive_opts
2143        int
2144        guestfs_add_drive_opts (guestfs_h *g,
2145                                const char *filename,
2146                                ...);
2147
2148       You may supply a list of optional arguments to this call.  Use zero or
2149       more of the following pairs of parameters, and terminate the list with
2150       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
2151
2152        GUESTFS_ADD_DRIVE_OPTS_READONLY, int readonly,
2153        GUESTFS_ADD_DRIVE_OPTS_FORMAT, const char *format,
2154        GUESTFS_ADD_DRIVE_OPTS_IFACE, const char *iface,
2155        GUESTFS_ADD_DRIVE_OPTS_NAME, const char *name,
2156        GUESTFS_ADD_DRIVE_OPTS_LABEL, const char *label,
2157        GUESTFS_ADD_DRIVE_OPTS_PROTOCOL, const char *protocol,
2158        GUESTFS_ADD_DRIVE_OPTS_SERVER, char *const *server,
2159        GUESTFS_ADD_DRIVE_OPTS_USERNAME, const char *username,
2160        GUESTFS_ADD_DRIVE_OPTS_SECRET, const char *secret,
2161        GUESTFS_ADD_DRIVE_OPTS_CACHEMODE, const char *cachemode,
2162        GUESTFS_ADD_DRIVE_OPTS_DISCARD, const char *discard,
2163        GUESTFS_ADD_DRIVE_OPTS_COPYONREAD, int copyonread,
2164        GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE, int blocksize,
2165
2166       This function adds a disk image called filename to the handle.
2167       filename may be a regular host file or a host device.
2168
2169       When this function is called before "guestfs_launch" (the usual case)
2170       then the first time you call this function, the disk appears in the API
2171       as /dev/sda, the second time as /dev/sdb, and so on.
2172
2173       In libguestfs ≥ 1.20 you can also call this function after launch (with
2174       some restrictions).  This is called "hotplugging".  When hotplugging,
2175       you must specify a "label" so that the new disk gets a predictable
2176       name.  For more information see "HOTPLUGGING".
2177
2178       You don't necessarily need to be root when using libguestfs.  However
2179       you obviously do need sufficient permissions to access the filename for
2180       whatever operations you want to perform (ie. read access if you just
2181       want to read the image or write access if you want to modify the
2182       image).
2183
2184       This call checks that filename exists.
2185
2186       filename may be the special string "/dev/null".  See "NULL DISKS".
2187
2188       The optional arguments are:
2189
2190       "readonly"
2191           If true then the image is treated as read-only.  Writes are still
2192           allowed, but they are stored in a temporary snapshot overlay which
2193           is discarded at the end.  The disk that you add is not modified.
2194
2195       "format"
2196           This forces the image format.  If you omit this (or use
2197           "guestfs_add_drive" or "guestfs_add_drive_ro") then the format is
2198           automatically detected.  Possible formats include "raw" and
2199           "qcow2".
2200
2201           Automatic detection of the format opens you up to a potential
2202           security hole when dealing with untrusted raw-format images.  See
2203           CVE-2010-3851 and RHBZ#642934.  Specifying the format closes this
2204           security hole.
2205
2206       "iface"
2207           This rarely-used option lets you emulate the behaviour of the
2208           deprecated "guestfs_add_drive_with_if" call (q.v.)
2209
2210       "name"
2211           The name the drive had in the original guest, e.g. /dev/sdb.  This
2212           is used as a hint to the guest inspection process if it is
2213           available.
2214
2215       "label"
2216           Give the disk a label.  The label should be a unique, short string
2217           using only ASCII characters "[a-zA-Z]".  As well as its usual name
2218           in the API (such as /dev/sda), the drive will also be named
2219           /dev/disk/guestfs/label.
2220
2221           See "DISK LABELS".
2222
2223       "protocol"
2224           The optional protocol argument can be used to select an alternate
2225           source protocol.
2226
2227           See also: "REMOTE STORAGE".
2228
2229           "protocol = "file""
2230               filename is interpreted as a local file or device.  This is the
2231               default if the optional protocol parameter is omitted.
2232
2233           "protocol = "ftp"|"ftps"|"http"|"https"|"tftp""
2234               Connect to a remote FTP, HTTP or TFTP server.  The "server"
2235               parameter must also be supplied - see below.
2236
2237               See also: "FTP, HTTP AND TFTP"
2238
2239           "protocol = "gluster""
2240               Connect to the GlusterFS server.  The "server" parameter must
2241               also be supplied - see below.
2242
2243               See also: "GLUSTER"
2244
2245           "protocol = "iscsi""
2246               Connect to the iSCSI server.  The "server" parameter must also
2247               be supplied - see below.  The "username" parameter may be
2248               supplied.  See below.  The "secret" parameter may be supplied.
2249               See below.
2250
2251               See also: "ISCSI".
2252
2253           "protocol = "nbd""
2254               Connect to the Network Block Device server.  The "server"
2255               parameter must also be supplied - see below.
2256
2257               See also: "NETWORK BLOCK DEVICE".
2258
2259           "protocol = "rbd""
2260               Connect to the Ceph (librbd/RBD) server.  The "server"
2261               parameter must also be supplied - see below.  The "username"
2262               parameter may be supplied.  See below.  The "secret" parameter
2263               may be supplied.  See below.
2264
2265               See also: "CEPH".
2266
2267           "protocol = "sheepdog""
2268               Connect to the Sheepdog server.  The "server" parameter may
2269               also be supplied - see below.
2270
2271               See also: "SHEEPDOG".
2272
2273           "protocol = "ssh""
2274               Connect to the Secure Shell (ssh) server.
2275
2276               The "server" parameter must be supplied.  The "username"
2277               parameter may be supplied.  See below.
2278
2279               See also: "SSH".
2280
2281       "server"
2282           For protocols which require access to a remote server, this is a
2283           list of server(s).
2284
2285            Protocol       Number of servers required
2286            --------       --------------------------
2287            file           List must be empty or param not used at all
2288            ftp|ftps|http|https|tftp  Exactly one
2289            gluster        Exactly one
2290            iscsi          Exactly one
2291            nbd            Exactly one
2292            rbd            Zero or more
2293            sheepdog       Zero or more
2294            ssh            Exactly one
2295
2296           Each list element is a string specifying a server.  The string must
2297           be in one of the following formats:
2298
2299            hostname
2300            hostname:port
2301            tcp:hostname
2302            tcp:hostname:port
2303            unix:/path/to/socket
2304
2305           If the port number is omitted, then the standard port number for
2306           the protocol is used (see /etc/services).
2307
2308       "username"
2309           For the "ftp", "ftps", "http", "https", "iscsi", "rbd", "ssh" and
2310           "tftp" protocols, this specifies the remote username.
2311
2312           If not given, then the local username is used for "ssh", and no
2313           authentication is attempted for ceph.  But note this sometimes may
2314           give unexpected results, for example if using the libvirt backend
2315           and if the libvirt backend is configured to start the qemu
2316           appliance as a special user such as "qemu.qemu".  If in doubt,
2317           specify the remote username you want.
2318
2319       "secret"
2320           For the "rbd" protocol only, this specifies the ‘secret’ to use
2321           when connecting to the remote device.  It must be base64 encoded.
2322
2323           If not given, then a secret matching the given username will be
2324           looked up in the default keychain locations, or if no username is
2325           given, then no authentication will be used.
2326
2327       "cachemode"
2328           Choose whether or not libguestfs will obey sync operations (safe
2329           but slow) or not (unsafe but fast).  The possible values for this
2330           string are:
2331
2332           "cachemode = "writeback""
2333               This is the default.
2334
2335               Write operations in the API do not return until a write(2) call
2336               has completed in the host [but note this does not imply that
2337               anything gets written to disk].
2338
2339               Sync operations in the API, including implicit syncs caused by
2340               filesystem journalling, will not return until an fdatasync(2)
2341               call has completed in the host, indicating that data has been
2342               committed to disk.
2343
2344           "cachemode = "unsafe""
2345               In this mode, there are no guarantees.  Libguestfs may cache
2346               anything and ignore sync requests.  This is suitable only for
2347               scratch or temporary disks.
2348
2349       "discard"
2350           Enable or disable discard (a.k.a. trim or unmap) support on this
2351           drive.  If enabled, operations such as "guestfs_fstrim" will be
2352           able to discard / make thin / punch holes in the underlying host
2353           file or device.
2354
2355           Possible discard settings are:
2356
2357           "discard = "disable""
2358               Disable discard support.  This is the default.
2359
2360           "discard = "enable""
2361               Enable discard support.  Fail if discard is not possible.
2362
2363           "discard = "besteffort""
2364               Enable discard support if possible, but don't fail if it is not
2365               supported.
2366
2367               Since not all backends and not all underlying systems support
2368               discard, this is a good choice if you want to use discard if
2369               possible, but don't mind if it doesn't work.
2370
2371       "copyonread"
2372           The boolean parameter "copyonread" enables copy-on-read support.
2373           This only affects disk formats which have backing files, and causes
2374           reads to be stored in the overlay layer, speeding up multiple reads
2375           of the same area of disk.
2376
2377           The default is false.
2378
2379       "blocksize"
2380           This parameter sets the sector size of the disk.  Possible values
2381           are 512 (the default if the parameter is omitted) or 4096.  Use
2382           4096 when handling an "Advanced Format" disk that uses 4K sector
2383           size (https://en.wikipedia.org/wiki/Advanced_Format).
2384
2385           Only a subset of the backends support this parameter (currently
2386           only the libvirt and direct backends do).
2387
2388       This function returns 0 on success or -1 on error.
2389
2390       (Added in 0.3)
2391
2392   guestfs_add_drive_opts_va
2393        int
2394        guestfs_add_drive_opts_va (guestfs_h *g,
2395                                   const char *filename,
2396                                   va_list args);
2397
2398       This is the "va_list variant" of "guestfs_add_drive_opts".
2399
2400       See "CALLS WITH OPTIONAL ARGUMENTS".
2401
2402   guestfs_add_drive_opts_argv
2403        int
2404        guestfs_add_drive_opts_argv (guestfs_h *g,
2405                                     const char *filename,
2406                                     const struct guestfs_add_drive_opts_argv *optargs);
2407
2408       This is the "argv variant" of "guestfs_add_drive_opts".
2409
2410       See "CALLS WITH OPTIONAL ARGUMENTS".
2411
2412   guestfs_add_drive_ro
2413        int
2414        guestfs_add_drive_ro (guestfs_h *g,
2415                              const char *filename);
2416
2417       This function is the equivalent of calling "guestfs_add_drive_opts"
2418       with the optional parameter "GUESTFS_ADD_DRIVE_OPTS_READONLY" set to 1,
2419       so the disk is added read-only, with the format being detected
2420       automatically.
2421
2422       This function returns 0 on success or -1 on error.
2423
2424       (Added in 1.0.38)
2425
2426   guestfs_add_drive_ro_with_if
2427        int
2428        guestfs_add_drive_ro_with_if (guestfs_h *g,
2429                                      const char *filename,
2430                                      const char *iface);
2431
2432       This function is deprecated.  In new code, use the "guestfs_add_drive"
2433       call instead.
2434
2435       Deprecated functions will not be removed from the API, but the fact
2436       that they are deprecated indicates that there are problems with correct
2437       use of these functions.
2438
2439       This is the same as "guestfs_add_drive_ro" but it allows you to specify
2440       the QEMU interface emulation to use at run time.
2441
2442       This function returns 0 on success or -1 on error.
2443
2444       (Added in 1.0.84)
2445
2446   guestfs_add_drive_scratch
2447        int
2448        guestfs_add_drive_scratch (guestfs_h *g,
2449                                   int64_t size,
2450                                   ...);
2451
2452       You may supply a list of optional arguments to this call.  Use zero or
2453       more of the following pairs of parameters, and terminate the list with
2454       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
2455
2456        GUESTFS_ADD_DRIVE_SCRATCH_NAME, const char *name,
2457        GUESTFS_ADD_DRIVE_SCRATCH_LABEL, const char *label,
2458        GUESTFS_ADD_DRIVE_SCRATCH_BLOCKSIZE, int blocksize,
2459
2460       This command adds a temporary scratch drive to the handle.  The "size"
2461       parameter is the virtual size (in bytes).  The scratch drive is blank
2462       initially (all reads return zeroes until you start writing to it).  The
2463       drive is deleted when the handle is closed.
2464
2465       The optional arguments "name", "label" and "blocksize" are passed
2466       through to "guestfs_add_drive_opts".
2467
2468       This function returns 0 on success or -1 on error.
2469
2470       (Added in 1.23.10)
2471
2472   guestfs_add_drive_scratch_va
2473        int
2474        guestfs_add_drive_scratch_va (guestfs_h *g,
2475                                      int64_t size,
2476                                      va_list args);
2477
2478       This is the "va_list variant" of "guestfs_add_drive_scratch".
2479
2480       See "CALLS WITH OPTIONAL ARGUMENTS".
2481
2482   guestfs_add_drive_scratch_argv
2483        int
2484        guestfs_add_drive_scratch_argv (guestfs_h *g,
2485                                        int64_t size,
2486                                        const struct guestfs_add_drive_scratch_argv *optargs);
2487
2488       This is the "argv variant" of "guestfs_add_drive_scratch".
2489
2490       See "CALLS WITH OPTIONAL ARGUMENTS".
2491
2492   guestfs_add_drive_with_if
2493        int
2494        guestfs_add_drive_with_if (guestfs_h *g,
2495                                   const char *filename,
2496                                   const char *iface);
2497
2498       This function is deprecated.  In new code, use the "guestfs_add_drive"
2499       call instead.
2500
2501       Deprecated functions will not be removed from the API, but the fact
2502       that they are deprecated indicates that there are problems with correct
2503       use of these functions.
2504
2505       This is the same as "guestfs_add_drive" but it allows you to specify
2506       the QEMU interface emulation to use at run time.
2507
2508       This function returns 0 on success or -1 on error.
2509
2510       (Added in 1.0.84)
2511
2512   guestfs_add_libvirt_dom
2513        int
2514        guestfs_add_libvirt_dom (guestfs_h *g,
2515                                 void * /* really virDomainPtr */ dom,
2516                                 ...);
2517
2518       You may supply a list of optional arguments to this call.  Use zero or
2519       more of the following pairs of parameters, and terminate the list with
2520       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
2521
2522        GUESTFS_ADD_LIBVIRT_DOM_READONLY, int readonly,
2523        GUESTFS_ADD_LIBVIRT_DOM_IFACE, const char *iface,
2524        GUESTFS_ADD_LIBVIRT_DOM_LIVE, int live,
2525        GUESTFS_ADD_LIBVIRT_DOM_READONLYDISK, const char *readonlydisk,
2526        GUESTFS_ADD_LIBVIRT_DOM_CACHEMODE, const char *cachemode,
2527        GUESTFS_ADD_LIBVIRT_DOM_DISCARD, const char *discard,
2528        GUESTFS_ADD_LIBVIRT_DOM_COPYONREAD, int copyonread,
2529
2530       This function adds the disk(s) attached to the libvirt domain "dom".
2531       It works by requesting the domain XML from libvirt, parsing it for
2532       disks, and calling "guestfs_add_drive_opts" on each one.
2533
2534       In the C API we declare "void *dom", but really it has type
2535       "virDomainPtr dom".  This is so we don't need <libvirt.h>.
2536
2537       The number of disks added is returned.  This operation is atomic: if an
2538       error is returned, then no disks are added.
2539
2540       This function does some minimal checks to make sure the libvirt domain
2541       is not running (unless "readonly" is true).  In a future version we
2542       will try to acquire the libvirt lock on each disk.
2543
2544       Disks must be accessible locally.  This often means that adding disks
2545       from a remote libvirt connection (see https://libvirt.org/remote.html)
2546       will fail unless those disks are accessible via the same device path
2547       locally too.
2548
2549       The optional "live" flag controls whether this call will try to connect
2550       to a running virtual machine "guestfsd" process if it sees a suitable
2551       <channel> element in the libvirt XML definition.  The default (if the
2552       flag is omitted) is never to try.  See "ATTACHING TO RUNNING DAEMONS"
2553       for more information.
2554
2555       The optional "readonlydisk" parameter controls what we do for disks
2556       which are marked <readonly/> in the libvirt XML.  See
2557       "guestfs_add_domain" for possible values.
2558
2559       If present, the value of "logical_block_size" attribute of <blockio/>
2560       tag in libvirt XML will be passed as "blocksize" parameter to
2561       "guestfs_add_drive_opts".
2562
2563       The other optional parameters are passed directly through to
2564       "guestfs_add_drive_opts".
2565
2566       On error this function returns -1.
2567
2568       (Added in 1.29.14)
2569
2570   guestfs_add_libvirt_dom_va
2571        int
2572        guestfs_add_libvirt_dom_va (guestfs_h *g,
2573                                    void * /* really virDomainPtr */ dom,
2574                                    va_list args);
2575
2576       This is the "va_list variant" of "guestfs_add_libvirt_dom".
2577
2578       See "CALLS WITH OPTIONAL ARGUMENTS".
2579
2580   guestfs_add_libvirt_dom_argv
2581        int
2582        guestfs_add_libvirt_dom_argv (guestfs_h *g,
2583                                      void * /* really virDomainPtr */ dom,
2584                                      const struct guestfs_add_libvirt_dom_argv *optargs);
2585
2586       This is the "argv variant" of "guestfs_add_libvirt_dom".
2587
2588       See "CALLS WITH OPTIONAL ARGUMENTS".
2589
2590   guestfs_aug_clear
2591        int
2592        guestfs_aug_clear (guestfs_h *g,
2593                           const char *augpath);
2594
2595       Set the value associated with "path" to "NULL".  This is the same as
2596       the augtool(1) "clear" command.
2597
2598       This function returns 0 on success or -1 on error.
2599
2600       (Added in 1.3.4)
2601
2602   guestfs_aug_close
2603        int
2604        guestfs_aug_close (guestfs_h *g);
2605
2606       Close the current Augeas handle and free up any resources used by it.
2607       After calling this, you have to call "guestfs_aug_init" again before
2608       you can use any other Augeas functions.
2609
2610       This function returns 0 on success or -1 on error.
2611
2612       (Added in 0.7)
2613
2614   guestfs_aug_defnode
2615        struct guestfs_int_bool *
2616        guestfs_aug_defnode (guestfs_h *g,
2617                             const char *name,
2618                             const char *expr,
2619                             const char *val);
2620
2621       Defines a variable "name" whose value is the result of evaluating
2622       "expr".
2623
2624       If "expr" evaluates to an empty nodeset, a node is created, equivalent
2625       to calling "guestfs_aug_set" "expr", "val".  "name" will be the nodeset
2626       containing that single node.
2627
2628       On success this returns a pair containing the number of nodes in the
2629       nodeset, and a boolean flag if a node was created.
2630
2631       This function returns a "struct guestfs_int_bool *", or NULL if there
2632       was an error.  The caller must call "guestfs_free_int_bool" after use.
2633
2634       (Added in 0.7)
2635
2636   guestfs_aug_defvar
2637        int
2638        guestfs_aug_defvar (guestfs_h *g,
2639                            const char *name,
2640                            const char *expr);
2641
2642       Defines an Augeas variable "name" whose value is the result of
2643       evaluating "expr".  If "expr" is NULL, then "name" is undefined.
2644
2645       On success this returns the number of nodes in "expr", or 0 if "expr"
2646       evaluates to something which is not a nodeset.
2647
2648       On error this function returns -1.
2649
2650       (Added in 0.7)
2651
2652   guestfs_aug_get
2653        char *
2654        guestfs_aug_get (guestfs_h *g,
2655                         const char *augpath);
2656
2657       Look up the value associated with "path".  If "path" matches exactly
2658       one node, the "value" is returned.
2659
2660       This function returns a string, or NULL on error.  The caller must free
2661       the returned string after use.
2662
2663       (Added in 0.7)
2664
2665   guestfs_aug_init
2666        int
2667        guestfs_aug_init (guestfs_h *g,
2668                          const char *root,
2669                          int flags);
2670
2671       Create a new Augeas handle for editing configuration files.  If there
2672       was any previous Augeas handle associated with this guestfs session,
2673       then it is closed.
2674
2675       You must call this before using any other "guestfs_aug_*" commands.
2676
2677       "root" is the filesystem root.  "root" must not be NULL, use / instead.
2678
2679       The flags are the same as the flags defined in <augeas.h>, the logical
2680       or of the following integers:
2681
2682       "AUG_SAVE_BACKUP" = 1
2683           Keep the original file with a ".augsave" extension.
2684
2685       "AUG_SAVE_NEWFILE" = 2
2686           Save changes into a file with extension ".augnew", and do not
2687           overwrite original.  Overrides "AUG_SAVE_BACKUP".
2688
2689       "AUG_TYPE_CHECK" = 4
2690           Typecheck lenses.
2691
2692           This option is only useful when debugging Augeas lenses.  Use of
2693           this option may require additional memory for the libguestfs
2694           appliance.  You may need to set the "LIBGUESTFS_MEMSIZE"
2695           environment variable or call "guestfs_set_memsize".
2696
2697       "AUG_NO_STDINC" = 8
2698           Do not use standard load path for modules.
2699
2700       "AUG_SAVE_NOOP" = 16
2701           Make save a no-op, just record what would have been changed.
2702
2703       "AUG_NO_LOAD" = 32
2704           Do not load the tree in "guestfs_aug_init".
2705
2706       To close the handle, you can call "guestfs_aug_close".
2707
2708       To find out more about Augeas, see http://augeas.net/.
2709
2710       This function returns 0 on success or -1 on error.
2711
2712       (Added in 0.7)
2713
2714   guestfs_aug_insert
2715        int
2716        guestfs_aug_insert (guestfs_h *g,
2717                            const char *augpath,
2718                            const char *label,
2719                            int before);
2720
2721       Create a new sibling "label" for "path", inserting it into the tree
2722       before or after "path" (depending on the boolean flag "before").
2723
2724       "path" must match exactly one existing node in the tree, and "label"
2725       must be a label, ie. not contain /, "*" or end with a bracketed index
2726       "[N]".
2727
2728       This function returns 0 on success or -1 on error.
2729
2730       (Added in 0.7)
2731
2732   guestfs_aug_label
2733        char *
2734        guestfs_aug_label (guestfs_h *g,
2735                           const char *augpath);
2736
2737       The label (name of the last element) of the Augeas path expression
2738       "augpath" is returned.  "augpath" must match exactly one node, else
2739       this function returns an error.
2740
2741       This function returns a string, or NULL on error.  The caller must free
2742       the returned string after use.
2743
2744       (Added in 1.23.14)
2745
2746   guestfs_aug_load
2747        int
2748        guestfs_aug_load (guestfs_h *g);
2749
2750       Load files into the tree.
2751
2752       See "aug_load" in the Augeas documentation for the full gory details.
2753
2754       This function returns 0 on success or -1 on error.
2755
2756       (Added in 0.7)
2757
2758   guestfs_aug_ls
2759        char **
2760        guestfs_aug_ls (guestfs_h *g,
2761                        const char *augpath);
2762
2763       This is just a shortcut for listing "guestfs_aug_match" "path/*" and
2764       sorting the resulting nodes into alphabetical order.
2765
2766       This function returns a NULL-terminated array of strings (like
2767       environ(3)), or NULL if there was an error.  The caller must free the
2768       strings and the array after use.
2769
2770       (Added in 0.8)
2771
2772   guestfs_aug_match
2773        char **
2774        guestfs_aug_match (guestfs_h *g,
2775                           const char *augpath);
2776
2777       Returns a list of paths which match the path expression "path".  The
2778       returned paths are sufficiently qualified so that they match exactly
2779       one node in the current tree.
2780
2781       This function returns a NULL-terminated array of strings (like
2782       environ(3)), or NULL if there was an error.  The caller must free the
2783       strings and the array after use.
2784
2785       (Added in 0.7)
2786
2787   guestfs_aug_mv
2788        int
2789        guestfs_aug_mv (guestfs_h *g,
2790                        const char *src,
2791                        const char *dest);
2792
2793       Move the node "src" to "dest".  "src" must match exactly one node.
2794       "dest" is overwritten if it exists.
2795
2796       This function returns 0 on success or -1 on error.
2797
2798       (Added in 0.7)
2799
2800   guestfs_aug_rm
2801        int
2802        guestfs_aug_rm (guestfs_h *g,
2803                        const char *augpath);
2804
2805       Remove "path" and all of its children.
2806
2807       On success this returns the number of entries which were removed.
2808
2809       On error this function returns -1.
2810
2811       (Added in 0.7)
2812
2813   guestfs_aug_save
2814        int
2815        guestfs_aug_save (guestfs_h *g);
2816
2817       This writes all pending changes to disk.
2818
2819       The flags which were passed to "guestfs_aug_init" affect exactly how
2820       files are saved.
2821
2822       This function returns 0 on success or -1 on error.
2823
2824       (Added in 0.7)
2825
2826   guestfs_aug_set
2827        int
2828        guestfs_aug_set (guestfs_h *g,
2829                         const char *augpath,
2830                         const char *val);
2831
2832       Set the value associated with "augpath" to "val".
2833
2834       In the Augeas API, it is possible to clear a node by setting the value
2835       to NULL.  Due to an oversight in the libguestfs API you cannot do that
2836       with this call.  Instead you must use the "guestfs_aug_clear" call.
2837
2838       This function returns 0 on success or -1 on error.
2839
2840       (Added in 0.7)
2841
2842   guestfs_aug_setm
2843        int
2844        guestfs_aug_setm (guestfs_h *g,
2845                          const char *base,
2846                          const char *sub,
2847                          const char *val);
2848
2849       Change multiple Augeas nodes in a single operation.  "base" is an
2850       expression matching multiple nodes.  "sub" is a path expression
2851       relative to "base".  All nodes matching "base" are found, and then for
2852       each node, "sub" is changed to "val".  "sub" may also be "NULL" in
2853       which case the "base" nodes are modified.
2854
2855       This returns the number of nodes modified.
2856
2857       On error this function returns -1.
2858
2859       (Added in 1.23.14)
2860
2861   guestfs_aug_transform
2862        int
2863        guestfs_aug_transform (guestfs_h *g,
2864                               const char *lens,
2865                               const char *file,
2866                               ...);
2867
2868       You may supply a list of optional arguments to this call.  Use zero or
2869       more of the following pairs of parameters, and terminate the list with
2870       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
2871
2872        GUESTFS_AUG_TRANSFORM_REMOVE, int remove,
2873
2874       Add an Augeas transformation for the specified "lens" so it can handle
2875       "file".
2876
2877       If "remove" is true ("false" by default), then the transformation is
2878       removed.
2879
2880       This function returns 0 on success or -1 on error.
2881
2882       (Added in 1.35.2)
2883
2884   guestfs_aug_transform_va
2885        int
2886        guestfs_aug_transform_va (guestfs_h *g,
2887                                  const char *lens,
2888                                  const char *file,
2889                                  va_list args);
2890
2891       This is the "va_list variant" of "guestfs_aug_transform".
2892
2893       See "CALLS WITH OPTIONAL ARGUMENTS".
2894
2895   guestfs_aug_transform_argv
2896        int
2897        guestfs_aug_transform_argv (guestfs_h *g,
2898                                    const char *lens,
2899                                    const char *file,
2900                                    const struct guestfs_aug_transform_argv *optargs);
2901
2902       This is the "argv variant" of "guestfs_aug_transform".
2903
2904       See "CALLS WITH OPTIONAL ARGUMENTS".
2905
2906   guestfs_available
2907        int
2908        guestfs_available (guestfs_h *g,
2909                           char *const *groups);
2910
2911       This command is used to check the availability of some groups of
2912       functionality in the appliance, which not all builds of the libguestfs
2913       appliance will be able to provide.
2914
2915       The libguestfs groups, and the functions that those groups correspond
2916       to, are listed in "AVAILABILITY".  You can also fetch this list at
2917       runtime by calling "guestfs_available_all_groups".
2918
2919       The argument "groups" is a list of group names, eg: "["inotify",
2920       "augeas"]" would check for the availability of the Linux inotify
2921       functions and Augeas (configuration file editing) functions.
2922
2923       The command returns no error if all requested groups are available.
2924
2925       It fails with an error if one or more of the requested groups is
2926       unavailable in the appliance.
2927
2928       If an unknown group name is included in the list of groups then an
2929       error is always returned.
2930
2931       Notes:
2932
2933       ·   "guestfs_feature_available" is the same as this call, but with a
2934           slightly simpler to use API: that call returns a boolean true/false
2935           instead of throwing an error.
2936
2937       ·   You must call "guestfs_launch" before calling this function.
2938
2939           The reason is because we don't know what groups are supported by
2940           the appliance/daemon until it is running and can be queried.
2941
2942       ·   If a group of functions is available, this does not necessarily
2943           mean that they will work.  You still have to check for errors when
2944           calling individual API functions even if they are available.
2945
2946       ·   It is usually the job of distro packagers to build complete
2947           functionality into the libguestfs appliance.  Upstream libguestfs,
2948           if built from source with all requirements satisfied, will support
2949           everything.
2950
2951       ·   This call was added in version 1.0.80.  In previous versions of
2952           libguestfs all you could do would be to speculatively execute a
2953           command to find out if the daemon implemented it.  See also
2954           "guestfs_version".
2955
2956       See also "guestfs_filesystem_available".
2957
2958       This function returns 0 on success or -1 on error.
2959
2960       (Added in 1.0.80)
2961
2962   guestfs_available_all_groups
2963        char **
2964        guestfs_available_all_groups (guestfs_h *g);
2965
2966       This command returns a list of all optional groups that this daemon
2967       knows about.  Note this returns both supported and unsupported groups.
2968       To find out which ones the daemon can actually support you have to call
2969       "guestfs_available" / "guestfs_feature_available" on each member of the
2970       returned list.
2971
2972       See also "guestfs_available", "guestfs_feature_available" and
2973       "AVAILABILITY".
2974
2975       This function returns a NULL-terminated array of strings (like
2976       environ(3)), or NULL if there was an error.  The caller must free the
2977       strings and the array after use.
2978
2979       (Added in 1.3.15)
2980
2981   guestfs_base64_in
2982        int
2983        guestfs_base64_in (guestfs_h *g,
2984                           const char *base64file,
2985                           const char *filename);
2986
2987       This command uploads base64-encoded data from "base64file" to filename.
2988
2989       This function returns 0 on success or -1 on error.
2990
2991       (Added in 1.3.5)
2992
2993   guestfs_base64_out
2994        int
2995        guestfs_base64_out (guestfs_h *g,
2996                            const char *filename,
2997                            const char *base64file);
2998
2999       This command downloads the contents of filename, writing it out to
3000       local file "base64file" encoded as base64.
3001
3002       This function returns 0 on success or -1 on error.
3003
3004       (Added in 1.3.5)
3005
3006   guestfs_blkdiscard
3007        int
3008        guestfs_blkdiscard (guestfs_h *g,
3009                            const char *device);
3010
3011       This discards all blocks on the block device "device", giving the free
3012       space back to the host.
3013
3014       This operation requires support in libguestfs, the host filesystem,
3015       qemu and the host kernel.  If this support isn't present it may give an
3016       error or even appear to run but do nothing.  You must also set the
3017       "discard" attribute on the underlying drive (see
3018       "guestfs_add_drive_opts").
3019
3020       This function returns 0 on success or -1 on error.
3021
3022       This function depends on the feature "blkdiscard".  See also
3023       "guestfs_feature_available".
3024
3025       (Added in 1.25.44)
3026
3027   guestfs_blkdiscardzeroes
3028        int
3029        guestfs_blkdiscardzeroes (guestfs_h *g,
3030                                  const char *device);
3031
3032       This call returns true if blocks on "device" that have been discarded
3033       by a call to "guestfs_blkdiscard" are returned as blocks of zero bytes
3034       when read the next time.
3035
3036       If it returns false, then it may be that discarded blocks are read as
3037       stale or random data.
3038
3039       This function returns a C truth value on success or -1 on error.
3040
3041       This function depends on the feature "blkdiscardzeroes".  See also
3042       "guestfs_feature_available".
3043
3044       (Added in 1.25.44)
3045
3046   guestfs_blkid
3047        char **
3048        guestfs_blkid (guestfs_h *g,
3049                       const char *device);
3050
3051       This command returns block device attributes for "device". The
3052       following fields are usually present in the returned hash. Other fields
3053       may also be present.
3054
3055       "UUID"
3056           The uuid of this device.
3057
3058       "LABEL"
3059           The label of this device.
3060
3061       "VERSION"
3062           The version of blkid command.
3063
3064       "TYPE"
3065           The filesystem type or RAID of this device.
3066
3067       "USAGE"
3068           The usage of this device, for example "filesystem" or "raid".
3069
3070       This function returns a NULL-terminated array of strings, or NULL if
3071       there was an error.  The array of strings will always have length
3072       "2n+1", where "n" keys and values alternate, followed by the trailing
3073       NULL entry.  The caller must free the strings and the array after use.
3074
3075       (Added in 1.15.9)
3076
3077   guestfs_blockdev_flushbufs
3078        int
3079        guestfs_blockdev_flushbufs (guestfs_h *g,
3080                                    const char *device);
3081
3082       This tells the kernel to flush internal buffers associated with
3083       "device".
3084
3085       This uses the blockdev(8) command.
3086
3087       This function returns 0 on success or -1 on error.
3088
3089       (Added in 1.9.3)
3090
3091   guestfs_blockdev_getbsz
3092        int
3093        guestfs_blockdev_getbsz (guestfs_h *g,
3094                                 const char *device);
3095
3096       This returns the block size of a device.
3097
3098       Note: this is different from both size in blocks and filesystem block
3099       size.  Also this setting is not really used by anything.  You should
3100       probably not use it for anything.  Filesystems have their own idea
3101       about what block size to choose.
3102
3103       This uses the blockdev(8) command.
3104
3105       On error this function returns -1.
3106
3107       (Added in 1.9.3)
3108
3109   guestfs_blockdev_getro
3110        int
3111        guestfs_blockdev_getro (guestfs_h *g,
3112                                const char *device);
3113
3114       Returns a boolean indicating if the block device is read-only (true if
3115       read-only, false if not).
3116
3117       This uses the blockdev(8) command.
3118
3119       This function returns a C truth value on success or -1 on error.
3120
3121       (Added in 1.9.3)
3122
3123   guestfs_blockdev_getsize64
3124        int64_t
3125        guestfs_blockdev_getsize64 (guestfs_h *g,
3126                                    const char *device);
3127
3128       This returns the size of the device in bytes.
3129
3130       See also "guestfs_blockdev_getsz".
3131
3132       This uses the blockdev(8) command.
3133
3134       On error this function returns -1.
3135
3136       (Added in 1.9.3)
3137
3138   guestfs_blockdev_getss
3139        int
3140        guestfs_blockdev_getss (guestfs_h *g,
3141                                const char *device);
3142
3143       This returns the size of sectors on a block device.  Usually 512, but
3144       can be larger for modern devices.
3145
3146       (Note, this is not the size in sectors, use "guestfs_blockdev_getsz"
3147       for that).
3148
3149       This uses the blockdev(8) command.
3150
3151       On error this function returns -1.
3152
3153       (Added in 1.9.3)
3154
3155   guestfs_blockdev_getsz
3156        int64_t
3157        guestfs_blockdev_getsz (guestfs_h *g,
3158                                const char *device);
3159
3160       This returns the size of the device in units of 512-byte sectors (even
3161       if the sectorsize isn't 512 bytes ... weird).
3162
3163       See also "guestfs_blockdev_getss" for the real sector size of the
3164       device, and "guestfs_blockdev_getsize64" for the more useful size in
3165       bytes.
3166
3167       This uses the blockdev(8) command.
3168
3169       On error this function returns -1.
3170
3171       (Added in 1.9.3)
3172
3173   guestfs_blockdev_rereadpt
3174        int
3175        guestfs_blockdev_rereadpt (guestfs_h *g,
3176                                   const char *device);
3177
3178       Reread the partition table on "device".
3179
3180       This uses the blockdev(8) command.
3181
3182       This function returns 0 on success or -1 on error.
3183
3184       (Added in 1.9.3)
3185
3186   guestfs_blockdev_setbsz
3187        int
3188        guestfs_blockdev_setbsz (guestfs_h *g,
3189                                 const char *device,
3190                                 int blocksize);
3191
3192       This function is deprecated.  There is no replacement.  Consult the API
3193       documentation in guestfs(3) for further information.
3194
3195       Deprecated functions will not be removed from the API, but the fact
3196       that they are deprecated indicates that there are problems with correct
3197       use of these functions.
3198
3199       This call does nothing and has never done anything because of a bug in
3200       blockdev.  Do not use it.
3201
3202       If you need to set the filesystem block size, use the "blocksize"
3203       option of "guestfs_mkfs".
3204
3205       This function returns 0 on success or -1 on error.
3206
3207       (Added in 1.9.3)
3208
3209   guestfs_blockdev_setra
3210        int
3211        guestfs_blockdev_setra (guestfs_h *g,
3212                                const char *device,
3213                                int sectors);
3214
3215       Set readahead (in 512-byte sectors) for the device.
3216
3217       This uses the blockdev(8) command.
3218
3219       This function returns 0 on success or -1 on error.
3220
3221       (Added in 1.29.10)
3222
3223   guestfs_blockdev_setro
3224        int
3225        guestfs_blockdev_setro (guestfs_h *g,
3226                                const char *device);
3227
3228       Sets the block device named "device" to read-only.
3229
3230       This uses the blockdev(8) command.
3231
3232       This function returns 0 on success or -1 on error.
3233
3234       (Added in 1.9.3)
3235
3236   guestfs_blockdev_setrw
3237        int
3238        guestfs_blockdev_setrw (guestfs_h *g,
3239                                const char *device);
3240
3241       Sets the block device named "device" to read-write.
3242
3243       This uses the blockdev(8) command.
3244
3245       This function returns 0 on success or -1 on error.
3246
3247       (Added in 1.9.3)
3248
3249   guestfs_btrfs_balance_cancel
3250        int
3251        guestfs_btrfs_balance_cancel (guestfs_h *g,
3252                                      const char *path);
3253
3254       Cancel a running balance on a btrfs filesystem.
3255
3256       This function returns 0 on success or -1 on error.
3257
3258       This function depends on the feature "btrfs".  See also
3259       "guestfs_feature_available".
3260
3261       (Added in 1.29.22)
3262
3263   guestfs_btrfs_balance_pause
3264        int
3265        guestfs_btrfs_balance_pause (guestfs_h *g,
3266                                     const char *path);
3267
3268       Pause a running balance on a btrfs filesystem.
3269
3270       This function returns 0 on success or -1 on error.
3271
3272       This function depends on the feature "btrfs".  See also
3273       "guestfs_feature_available".
3274
3275       (Added in 1.29.22)
3276
3277   guestfs_btrfs_balance_resume
3278        int
3279        guestfs_btrfs_balance_resume (guestfs_h *g,
3280                                      const char *path);
3281
3282       Resume a paused balance on a btrfs filesystem.
3283
3284       This function returns 0 on success or -1 on error.
3285
3286       This function depends on the feature "btrfs".  See also
3287       "guestfs_feature_available".
3288
3289       (Added in 1.29.22)
3290
3291   guestfs_btrfs_balance_status
3292        struct guestfs_btrfsbalance *
3293        guestfs_btrfs_balance_status (guestfs_h *g,
3294                                      const char *path);
3295
3296       Show the status of a running or paused balance on a btrfs filesystem.
3297
3298       This function returns a "struct guestfs_btrfsbalance *", or NULL if
3299       there was an error.  The caller must call "guestfs_free_btrfsbalance"
3300       after use.
3301
3302       This function depends on the feature "btrfs".  See also
3303       "guestfs_feature_available".
3304
3305       (Added in 1.29.26)
3306
3307   guestfs_btrfs_device_add
3308        int
3309        guestfs_btrfs_device_add (guestfs_h *g,
3310                                  char *const *devices,
3311                                  const char *fs);
3312
3313       Add the list of device(s) in "devices" to the btrfs filesystem mounted
3314       at "fs".  If "devices" is an empty list, this does nothing.
3315
3316       This function returns 0 on success or -1 on error.
3317
3318       This function depends on the feature "btrfs".  See also
3319       "guestfs_feature_available".
3320
3321       (Added in 1.17.35)
3322
3323   guestfs_btrfs_device_delete
3324        int
3325        guestfs_btrfs_device_delete (guestfs_h *g,
3326                                     char *const *devices,
3327                                     const char *fs);
3328
3329       Remove the "devices" from the btrfs filesystem mounted at "fs".  If
3330       "devices" is an empty list, this does nothing.
3331
3332       This function returns 0 on success or -1 on error.
3333
3334       This function depends on the feature "btrfs".  See also
3335       "guestfs_feature_available".
3336
3337       (Added in 1.17.35)
3338
3339   guestfs_btrfs_filesystem_balance
3340        int
3341        guestfs_btrfs_filesystem_balance (guestfs_h *g,
3342                                          const char *fs);
3343
3344       Balance the chunks in the btrfs filesystem mounted at "fs" across the
3345       underlying devices.
3346
3347       This function returns 0 on success or -1 on error.
3348
3349       This function depends on the feature "btrfs".  See also
3350       "guestfs_feature_available".
3351
3352       (Added in 1.17.35)
3353
3354   guestfs_btrfs_filesystem_defragment
3355        int
3356        guestfs_btrfs_filesystem_defragment (guestfs_h *g,
3357                                             const char *path,
3358                                             ...);
3359
3360       You may supply a list of optional arguments to this call.  Use zero or
3361       more of the following pairs of parameters, and terminate the list with
3362       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3363
3364        GUESTFS_BTRFS_FILESYSTEM_DEFRAGMENT_FLUSH, int flush,
3365        GUESTFS_BTRFS_FILESYSTEM_DEFRAGMENT_COMPRESS, const char *compress,
3366
3367       Defragment a file or directory on a btrfs filesystem. compress is one
3368       of zlib or lzo.
3369
3370       This function returns 0 on success or -1 on error.
3371
3372       This function depends on the feature "btrfs".  See also
3373       "guestfs_feature_available".
3374
3375       (Added in 1.29.22)
3376
3377   guestfs_btrfs_filesystem_defragment_va
3378        int
3379        guestfs_btrfs_filesystem_defragment_va (guestfs_h *g,
3380                                                const char *path,
3381                                                va_list args);
3382
3383       This is the "va_list variant" of "guestfs_btrfs_filesystem_defragment".
3384
3385       See "CALLS WITH OPTIONAL ARGUMENTS".
3386
3387   guestfs_btrfs_filesystem_defragment_argv
3388        int
3389        guestfs_btrfs_filesystem_defragment_argv (guestfs_h *g,
3390                                                  const char *path,
3391                                                  const struct guestfs_btrfs_filesystem_defragment_argv *optargs);
3392
3393       This is the "argv variant" of "guestfs_btrfs_filesystem_defragment".
3394
3395       See "CALLS WITH OPTIONAL ARGUMENTS".
3396
3397   guestfs_btrfs_filesystem_resize
3398        int
3399        guestfs_btrfs_filesystem_resize (guestfs_h *g,
3400                                         const char *mountpoint,
3401                                         ...);
3402
3403       You may supply a list of optional arguments to this call.  Use zero or
3404       more of the following pairs of parameters, and terminate the list with
3405       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3406
3407        GUESTFS_BTRFS_FILESYSTEM_RESIZE_SIZE, int64_t size,
3408
3409       This command resizes a btrfs filesystem.
3410
3411       Note that unlike other resize calls, the filesystem has to be mounted
3412       and the parameter is the mountpoint not the device (this is a
3413       requirement of btrfs itself).
3414
3415       The optional parameters are:
3416
3417       "size"
3418           The new size (in bytes) of the filesystem.  If omitted, the
3419           filesystem is resized to the maximum size.
3420
3421       See also btrfs(8).
3422
3423       This function returns 0 on success or -1 on error.
3424
3425       This function depends on the feature "btrfs".  See also
3426       "guestfs_feature_available".
3427
3428       (Added in 1.11.17)
3429
3430   guestfs_btrfs_filesystem_resize_va
3431        int
3432        guestfs_btrfs_filesystem_resize_va (guestfs_h *g,
3433                                            const char *mountpoint,
3434                                            va_list args);
3435
3436       This is the "va_list variant" of "guestfs_btrfs_filesystem_resize".
3437
3438       See "CALLS WITH OPTIONAL ARGUMENTS".
3439
3440   guestfs_btrfs_filesystem_resize_argv
3441        int
3442        guestfs_btrfs_filesystem_resize_argv (guestfs_h *g,
3443                                              const char *mountpoint,
3444                                              const struct guestfs_btrfs_filesystem_resize_argv *optargs);
3445
3446       This is the "argv variant" of "guestfs_btrfs_filesystem_resize".
3447
3448       See "CALLS WITH OPTIONAL ARGUMENTS".
3449
3450   guestfs_btrfs_filesystem_show
3451        char **
3452        guestfs_btrfs_filesystem_show (guestfs_h *g,
3453                                       const char *device);
3454
3455       Show all the devices where the filesystems in "device" is spanned over.
3456
3457       If not all the devices for the filesystems are present, then this
3458       function fails and the "errno" is set to "ENODEV".
3459
3460       This function returns a NULL-terminated array of strings (like
3461       environ(3)), or NULL if there was an error.  The caller must free the
3462       strings and the array after use.
3463
3464       This function depends on the feature "btrfs".  See also
3465       "guestfs_feature_available".
3466
3467       (Added in 1.33.29)
3468
3469   guestfs_btrfs_filesystem_sync
3470        int
3471        guestfs_btrfs_filesystem_sync (guestfs_h *g,
3472                                       const char *fs);
3473
3474       Force sync on the btrfs filesystem mounted at "fs".
3475
3476       This function returns 0 on success or -1 on error.
3477
3478       This function depends on the feature "btrfs".  See also
3479       "guestfs_feature_available".
3480
3481       (Added in 1.17.35)
3482
3483   guestfs_btrfs_fsck
3484        int
3485        guestfs_btrfs_fsck (guestfs_h *g,
3486                            const char *device,
3487                            ...);
3488
3489       You may supply a list of optional arguments to this call.  Use zero or
3490       more of the following pairs of parameters, and terminate the list with
3491       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3492
3493        GUESTFS_BTRFS_FSCK_SUPERBLOCK, int64_t superblock,
3494        GUESTFS_BTRFS_FSCK_REPAIR, int repair,
3495
3496       Used to check a btrfs filesystem, "device" is the device file where the
3497       filesystem is stored.
3498
3499       This function returns 0 on success or -1 on error.
3500
3501       This function depends on the feature "btrfs".  See also
3502       "guestfs_feature_available".
3503
3504       (Added in 1.17.43)
3505
3506   guestfs_btrfs_fsck_va
3507        int
3508        guestfs_btrfs_fsck_va (guestfs_h *g,
3509                               const char *device,
3510                               va_list args);
3511
3512       This is the "va_list variant" of "guestfs_btrfs_fsck".
3513
3514       See "CALLS WITH OPTIONAL ARGUMENTS".
3515
3516   guestfs_btrfs_fsck_argv
3517        int
3518        guestfs_btrfs_fsck_argv (guestfs_h *g,
3519                                 const char *device,
3520                                 const struct guestfs_btrfs_fsck_argv *optargs);
3521
3522       This is the "argv variant" of "guestfs_btrfs_fsck".
3523
3524       See "CALLS WITH OPTIONAL ARGUMENTS".
3525
3526   guestfs_btrfs_image
3527        int
3528        guestfs_btrfs_image (guestfs_h *g,
3529                             char *const *source,
3530                             const char *image,
3531                             ...);
3532
3533       You may supply a list of optional arguments to this call.  Use zero or
3534       more of the following pairs of parameters, and terminate the list with
3535       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3536
3537        GUESTFS_BTRFS_IMAGE_COMPRESSLEVEL, int compresslevel,
3538
3539       This is used to create an image of a btrfs filesystem.  All data will
3540       be zeroed, but metadata and the like is preserved.
3541
3542       This function returns 0 on success or -1 on error.
3543
3544       This function depends on the feature "btrfs".  See also
3545       "guestfs_feature_available".
3546
3547       (Added in 1.29.32)
3548
3549   guestfs_btrfs_image_va
3550        int
3551        guestfs_btrfs_image_va (guestfs_h *g,
3552                                char *const *source,
3553                                const char *image,
3554                                va_list args);
3555
3556       This is the "va_list variant" of "guestfs_btrfs_image".
3557
3558       See "CALLS WITH OPTIONAL ARGUMENTS".
3559
3560   guestfs_btrfs_image_argv
3561        int
3562        guestfs_btrfs_image_argv (guestfs_h *g,
3563                                  char *const *source,
3564                                  const char *image,
3565                                  const struct guestfs_btrfs_image_argv *optargs);
3566
3567       This is the "argv variant" of "guestfs_btrfs_image".
3568
3569       See "CALLS WITH OPTIONAL ARGUMENTS".
3570
3571   guestfs_btrfs_qgroup_assign
3572        int
3573        guestfs_btrfs_qgroup_assign (guestfs_h *g,
3574                                     const char *src,
3575                                     const char *dst,
3576                                     const char *path);
3577
3578       Add qgroup "src" to parent qgroup "dst". This command can group several
3579       qgroups into a parent qgroup to share common limit.
3580
3581       This function returns 0 on success or -1 on error.
3582
3583       This function depends on the feature "btrfs".  See also
3584       "guestfs_feature_available".
3585
3586       (Added in 1.29.17)
3587
3588   guestfs_btrfs_qgroup_create
3589        int
3590        guestfs_btrfs_qgroup_create (guestfs_h *g,
3591                                     const char *qgroupid,
3592                                     const char *subvolume);
3593
3594       Create a quota group (qgroup) for subvolume at "subvolume".
3595
3596       This function returns 0 on success or -1 on error.
3597
3598       This function depends on the feature "btrfs".  See also
3599       "guestfs_feature_available".
3600
3601       (Added in 1.29.17)
3602
3603   guestfs_btrfs_qgroup_destroy
3604        int
3605        guestfs_btrfs_qgroup_destroy (guestfs_h *g,
3606                                      const char *qgroupid,
3607                                      const char *subvolume);
3608
3609       Destroy a quota group.
3610
3611       This function returns 0 on success or -1 on error.
3612
3613       This function depends on the feature "btrfs".  See also
3614       "guestfs_feature_available".
3615
3616       (Added in 1.29.17)
3617
3618   guestfs_btrfs_qgroup_limit
3619        int
3620        guestfs_btrfs_qgroup_limit (guestfs_h *g,
3621                                    const char *subvolume,
3622                                    int64_t size);
3623
3624       Limit the size of the subvolume with path "subvolume".
3625
3626       This function returns 0 on success or -1 on error.
3627
3628       This function depends on the feature "btrfs".  See also
3629       "guestfs_feature_available".
3630
3631       (Added in 1.29.17)
3632
3633   guestfs_btrfs_qgroup_remove
3634        int
3635        guestfs_btrfs_qgroup_remove (guestfs_h *g,
3636                                     const char *src,
3637                                     const char *dst,
3638                                     const char *path);
3639
3640       Remove qgroup "src" from the parent qgroup "dst".
3641
3642       This function returns 0 on success or -1 on error.
3643
3644       This function depends on the feature "btrfs".  See also
3645       "guestfs_feature_available".
3646
3647       (Added in 1.29.17)
3648
3649   guestfs_btrfs_qgroup_show
3650        struct guestfs_btrfsqgroup_list *
3651        guestfs_btrfs_qgroup_show (guestfs_h *g,
3652                                   const char *path);
3653
3654       Show all subvolume quota groups in a btrfs filesystem, including their
3655       usages.
3656
3657       This function returns a "struct guestfs_btrfsqgroup_list *", or NULL if
3658       there was an error.  The caller must call
3659       "guestfs_free_btrfsqgroup_list" after use.
3660
3661       This function depends on the feature "btrfs".  See also
3662       "guestfs_feature_available".
3663
3664       (Added in 1.29.17)
3665
3666   guestfs_btrfs_quota_enable
3667        int
3668        guestfs_btrfs_quota_enable (guestfs_h *g,
3669                                    const char *fs,
3670                                    int enable);
3671
3672       Enable or disable subvolume quota support for filesystem which contains
3673       "path".
3674
3675       This function returns 0 on success or -1 on error.
3676
3677       This function depends on the feature "btrfs".  See also
3678       "guestfs_feature_available".
3679
3680       (Added in 1.29.17)
3681
3682   guestfs_btrfs_quota_rescan
3683        int
3684        guestfs_btrfs_quota_rescan (guestfs_h *g,
3685                                    const char *fs);
3686
3687       Trash all qgroup numbers and scan the metadata again with the current
3688       config.
3689
3690       This function returns 0 on success or -1 on error.
3691
3692       This function depends on the feature "btrfs".  See also
3693       "guestfs_feature_available".
3694
3695       (Added in 1.29.17)
3696
3697   guestfs_btrfs_replace
3698        int
3699        guestfs_btrfs_replace (guestfs_h *g,
3700                               const char *srcdev,
3701                               const char *targetdev,
3702                               const char *mntpoint);
3703
3704       Replace device of a btrfs filesystem. On a live filesystem, duplicate
3705       the data to the target device which is currently stored on the source
3706       device.  After completion of the operation, the source device is wiped
3707       out and removed from the filesystem.
3708
3709       The "targetdev" needs to be same size or larger than the "srcdev".
3710       Devices which are currently mounted are never allowed to be used as the
3711       "targetdev".
3712
3713       This function returns 0 on success or -1 on error.
3714
3715       This function depends on the feature "btrfs".  See also
3716       "guestfs_feature_available".
3717
3718       (Added in 1.29.48)
3719
3720   guestfs_btrfs_rescue_chunk_recover
3721        int
3722        guestfs_btrfs_rescue_chunk_recover (guestfs_h *g,
3723                                            const char *device);
3724
3725       Recover the chunk tree of btrfs filesystem by scanning the devices one
3726       by one.
3727
3728       This function returns 0 on success or -1 on error.
3729
3730       This function depends on the feature "btrfs".  See also
3731       "guestfs_feature_available".
3732
3733       (Added in 1.29.22)
3734
3735   guestfs_btrfs_rescue_super_recover
3736        int
3737        guestfs_btrfs_rescue_super_recover (guestfs_h *g,
3738                                            const char *device);
3739
3740       Recover bad superblocks from good copies.
3741
3742       This function returns 0 on success or -1 on error.
3743
3744       This function depends on the feature "btrfs".  See also
3745       "guestfs_feature_available".
3746
3747       (Added in 1.29.22)
3748
3749   guestfs_btrfs_scrub_cancel
3750        int
3751        guestfs_btrfs_scrub_cancel (guestfs_h *g,
3752                                    const char *path);
3753
3754       Cancel a running scrub on a btrfs filesystem.
3755
3756       This function returns 0 on success or -1 on error.
3757
3758       This function depends on the feature "btrfs".  See also
3759       "guestfs_feature_available".
3760
3761       (Added in 1.29.22)
3762
3763   guestfs_btrfs_scrub_resume
3764        int
3765        guestfs_btrfs_scrub_resume (guestfs_h *g,
3766                                    const char *path);
3767
3768       Resume a previously canceled or interrupted scrub on a btrfs
3769       filesystem.
3770
3771       This function returns 0 on success or -1 on error.
3772
3773       This function depends on the feature "btrfs".  See also
3774       "guestfs_feature_available".
3775
3776       (Added in 1.29.22)
3777
3778   guestfs_btrfs_scrub_start
3779        int
3780        guestfs_btrfs_scrub_start (guestfs_h *g,
3781                                   const char *path);
3782
3783       Reads all the data and metadata on the filesystem, and uses checksums
3784       and the duplicate copies from RAID storage to identify and repair any
3785       corrupt data.
3786
3787       This function returns 0 on success or -1 on error.
3788
3789       This function depends on the feature "btrfs".  See also
3790       "guestfs_feature_available".
3791
3792       (Added in 1.29.22)
3793
3794   guestfs_btrfs_scrub_status
3795        struct guestfs_btrfsscrub *
3796        guestfs_btrfs_scrub_status (guestfs_h *g,
3797                                    const char *path);
3798
3799       Show status of running or finished scrub on a btrfs filesystem.
3800
3801       This function returns a "struct guestfs_btrfsscrub *", or NULL if there
3802       was an error.  The caller must call "guestfs_free_btrfsscrub" after
3803       use.
3804
3805       This function depends on the feature "btrfs".  See also
3806       "guestfs_feature_available".
3807
3808       (Added in 1.29.26)
3809
3810   guestfs_btrfs_set_seeding
3811        int
3812        guestfs_btrfs_set_seeding (guestfs_h *g,
3813                                   const char *device,
3814                                   int seeding);
3815
3816       Enable or disable the seeding feature of a device that contains a btrfs
3817       filesystem.
3818
3819       This function returns 0 on success or -1 on error.
3820
3821       This function depends on the feature "btrfs".  See also
3822       "guestfs_feature_available".
3823
3824       (Added in 1.17.43)
3825
3826   guestfs_btrfs_subvolume_create
3827        int
3828        guestfs_btrfs_subvolume_create (guestfs_h *g,
3829                                        const char *dest);
3830
3831       This function is provided for backwards compatibility with earlier
3832       versions of libguestfs.  It simply calls
3833       "guestfs_btrfs_subvolume_create_opts" with no optional arguments.
3834
3835       (Added in 1.17.35)
3836
3837   guestfs_btrfs_subvolume_create_opts
3838        int
3839        guestfs_btrfs_subvolume_create_opts (guestfs_h *g,
3840                                             const char *dest,
3841                                             ...);
3842
3843       You may supply a list of optional arguments to this call.  Use zero or
3844       more of the following pairs of parameters, and terminate the list with
3845       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3846
3847        GUESTFS_BTRFS_SUBVOLUME_CREATE_OPTS_QGROUPID, const char *qgroupid,
3848
3849       Create a btrfs subvolume.  The "dest" argument is the destination
3850       directory and the name of the subvolume, in the form
3851       /path/to/dest/name.  The optional parameter "qgroupid" represents the
3852       qgroup which the newly created subvolume will be added to.
3853
3854       This function returns 0 on success or -1 on error.
3855
3856       This function depends on the feature "btrfs".  See also
3857       "guestfs_feature_available".
3858
3859       (Added in 1.17.35)
3860
3861   guestfs_btrfs_subvolume_create_opts_va
3862        int
3863        guestfs_btrfs_subvolume_create_opts_va (guestfs_h *g,
3864                                                const char *dest,
3865                                                va_list args);
3866
3867       This is the "va_list variant" of "guestfs_btrfs_subvolume_create_opts".
3868
3869       See "CALLS WITH OPTIONAL ARGUMENTS".
3870
3871   guestfs_btrfs_subvolume_create_opts_argv
3872        int
3873        guestfs_btrfs_subvolume_create_opts_argv (guestfs_h *g,
3874                                                  const char *dest,
3875                                                  const struct guestfs_btrfs_subvolume_create_opts_argv *optargs);
3876
3877       This is the "argv variant" of "guestfs_btrfs_subvolume_create_opts".
3878
3879       See "CALLS WITH OPTIONAL ARGUMENTS".
3880
3881   guestfs_btrfs_subvolume_delete
3882        int
3883        guestfs_btrfs_subvolume_delete (guestfs_h *g,
3884                                        const char *subvolume);
3885
3886       Delete the named btrfs subvolume or snapshot.
3887
3888       This function returns 0 on success or -1 on error.
3889
3890       This function depends on the feature "btrfs".  See also
3891       "guestfs_feature_available".
3892
3893       (Added in 1.17.35)
3894
3895   guestfs_btrfs_subvolume_get_default
3896        int64_t
3897        guestfs_btrfs_subvolume_get_default (guestfs_h *g,
3898                                             const char *fs);
3899
3900       Get the default subvolume or snapshot of a filesystem mounted at
3901       "mountpoint".
3902
3903       On error this function returns -1.
3904
3905       This function depends on the feature "btrfs".  See also
3906       "guestfs_feature_available".
3907
3908       (Added in 1.29.17)
3909
3910   guestfs_btrfs_subvolume_list
3911        struct guestfs_btrfssubvolume_list *
3912        guestfs_btrfs_subvolume_list (guestfs_h *g,
3913                                      const char *fs);
3914
3915       List the btrfs snapshots and subvolumes of the btrfs filesystem which
3916       is mounted at "fs".
3917
3918       This function returns a "struct guestfs_btrfssubvolume_list *", or NULL
3919       if there was an error.  The caller must call
3920       "guestfs_free_btrfssubvolume_list" after use.
3921
3922       This function depends on the feature "btrfs".  See also
3923       "guestfs_feature_available".
3924
3925       (Added in 1.17.35)
3926
3927   guestfs_btrfs_subvolume_set_default
3928        int
3929        guestfs_btrfs_subvolume_set_default (guestfs_h *g,
3930                                             int64_t id,
3931                                             const char *fs);
3932
3933       Set the subvolume of the btrfs filesystem "fs" which will be mounted by
3934       default.  See "guestfs_btrfs_subvolume_list" to get a list of
3935       subvolumes.
3936
3937       This function returns 0 on success or -1 on error.
3938
3939       This function depends on the feature "btrfs".  See also
3940       "guestfs_feature_available".
3941
3942       (Added in 1.17.35)
3943
3944   guestfs_btrfs_subvolume_show
3945        char **
3946        guestfs_btrfs_subvolume_show (guestfs_h *g,
3947                                      const char *subvolume);
3948
3949       Return detailed information of the subvolume.
3950
3951       This function returns a NULL-terminated array of strings, or NULL if
3952       there was an error.  The array of strings will always have length
3953       "2n+1", where "n" keys and values alternate, followed by the trailing
3954       NULL entry.  The caller must free the strings and the array after use.
3955
3956       This function depends on the feature "btrfs".  See also
3957       "guestfs_feature_available".
3958
3959       (Added in 1.29.17)
3960
3961   guestfs_btrfs_subvolume_snapshot
3962        int
3963        guestfs_btrfs_subvolume_snapshot (guestfs_h *g,
3964                                          const char *source,
3965                                          const char *dest);
3966
3967       This function is provided for backwards compatibility with earlier
3968       versions of libguestfs.  It simply calls
3969       "guestfs_btrfs_subvolume_snapshot_opts" with no optional arguments.
3970
3971       (Added in 1.17.35)
3972
3973   guestfs_btrfs_subvolume_snapshot_opts
3974        int
3975        guestfs_btrfs_subvolume_snapshot_opts (guestfs_h *g,
3976                                               const char *source,
3977                                               const char *dest,
3978                                               ...);
3979
3980       You may supply a list of optional arguments to this call.  Use zero or
3981       more of the following pairs of parameters, and terminate the list with
3982       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
3983
3984        GUESTFS_BTRFS_SUBVOLUME_SNAPSHOT_OPTS_RO, int ro,
3985        GUESTFS_BTRFS_SUBVOLUME_SNAPSHOT_OPTS_QGROUPID, const char *qgroupid,
3986
3987       Create a snapshot of the btrfs subvolume "source".  The "dest" argument
3988       is the destination directory and the name of the snapshot, in the form
3989       /path/to/dest/name. By default the newly created snapshot is writable,
3990       if the value of optional parameter "ro" is true, then a readonly
3991       snapshot is created. The optional parameter "qgroupid" represents the
3992       qgroup which the newly created snapshot will be added to.
3993
3994       This function returns 0 on success or -1 on error.
3995
3996       This function depends on the feature "btrfs".  See also
3997       "guestfs_feature_available".
3998
3999       (Added in 1.17.35)
4000
4001   guestfs_btrfs_subvolume_snapshot_opts_va
4002        int
4003        guestfs_btrfs_subvolume_snapshot_opts_va (guestfs_h *g,
4004                                                  const char *source,
4005                                                  const char *dest,
4006                                                  va_list args);
4007
4008       This is the "va_list variant" of
4009       "guestfs_btrfs_subvolume_snapshot_opts".
4010
4011       See "CALLS WITH OPTIONAL ARGUMENTS".
4012
4013   guestfs_btrfs_subvolume_snapshot_opts_argv
4014        int
4015        guestfs_btrfs_subvolume_snapshot_opts_argv (guestfs_h *g,
4016                                                    const char *source,
4017                                                    const char *dest,
4018                                                    const struct guestfs_btrfs_subvolume_snapshot_opts_argv *optargs);
4019
4020       This is the "argv variant" of "guestfs_btrfs_subvolume_snapshot_opts".
4021
4022       See "CALLS WITH OPTIONAL ARGUMENTS".
4023
4024   guestfs_btrfstune_enable_extended_inode_refs
4025        int
4026        guestfs_btrfstune_enable_extended_inode_refs (guestfs_h *g,
4027                                                      const char *device);
4028
4029       This will Enable extended inode refs.
4030
4031       This function returns 0 on success or -1 on error.
4032
4033       This function depends on the feature "btrfs".  See also
4034       "guestfs_feature_available".
4035
4036       (Added in 1.29.29)
4037
4038   guestfs_btrfstune_enable_skinny_metadata_extent_refs
4039        int
4040        guestfs_btrfstune_enable_skinny_metadata_extent_refs (guestfs_h *g,
4041                                                              const char *device);
4042
4043       This enable skinny metadata extent refs.
4044
4045       This function returns 0 on success or -1 on error.
4046
4047       This function depends on the feature "btrfs".  See also
4048       "guestfs_feature_available".
4049
4050       (Added in 1.29.29)
4051
4052   guestfs_btrfstune_seeding
4053        int
4054        guestfs_btrfstune_seeding (guestfs_h *g,
4055                                   const char *device,
4056                                   int seeding);
4057
4058       Enable seeding of a btrfs device, this will force a fs readonly so that
4059       you can use it to build other filesystems.
4060
4061       This function returns 0 on success or -1 on error.
4062
4063       This function depends on the feature "btrfs".  See also
4064       "guestfs_feature_available".
4065
4066       (Added in 1.29.29)
4067
4068   guestfs_c_pointer
4069        int64_t
4070        guestfs_c_pointer (guestfs_h *g);
4071
4072       In non-C language bindings, this allows you to retrieve the underlying
4073       C pointer to the handle (ie. "guestfs_h *").  The purpose of this is to
4074       allow other libraries to interwork with libguestfs.
4075
4076       On error this function returns -1.
4077
4078       (Added in 1.29.17)
4079
4080   guestfs_canonical_device_name
4081        char *
4082        guestfs_canonical_device_name (guestfs_h *g,
4083                                       const char *device);
4084
4085       This utility function is useful when displaying device names to the
4086       user.  It takes a number of irregular device names and returns them in
4087       a consistent format:
4088
4089       /dev/hdX
4090       /dev/vdX
4091           These are returned as /dev/sdX.  Note this works for device names
4092           and partition names.  This is approximately the reverse of the
4093           algorithm described in "BLOCK DEVICE NAMING".
4094
4095       /dev/mapper/VG-LV
4096       /dev/dm-N
4097           Converted to /dev/VG/LV form using "guestfs_lvm_canonical_lv_name".
4098
4099       Other strings are returned unmodified.
4100
4101       This function returns a string, or NULL on error.  The caller must free
4102       the returned string after use.
4103
4104       (Added in 1.19.7)
4105
4106   guestfs_cap_get_file
4107        char *
4108        guestfs_cap_get_file (guestfs_h *g,
4109                              const char *path);
4110
4111       This function returns the Linux capabilities attached to "path".  The
4112       capabilities set is returned in text form (see cap_to_text(3)).
4113
4114       If no capabilities are attached to a file, an empty string is returned.
4115
4116       This function returns a string, or NULL on error.  The caller must free
4117       the returned string after use.
4118
4119       This function depends on the feature "linuxcaps".  See also
4120       "guestfs_feature_available".
4121
4122       (Added in 1.19.63)
4123
4124   guestfs_cap_set_file
4125        int
4126        guestfs_cap_set_file (guestfs_h *g,
4127                              const char *path,
4128                              const char *cap);
4129
4130       This function sets the Linux capabilities attached to "path".  The
4131       capabilities set "cap" should be passed in text form (see
4132       cap_from_text(3)).
4133
4134       This function returns 0 on success or -1 on error.
4135
4136       This function depends on the feature "linuxcaps".  See also
4137       "guestfs_feature_available".
4138
4139       (Added in 1.19.63)
4140
4141   guestfs_case_sensitive_path
4142        char *
4143        guestfs_case_sensitive_path (guestfs_h *g,
4144                                     const char *path);
4145
4146       This can be used to resolve case insensitive paths on a filesystem
4147       which is case sensitive.  The use case is to resolve paths which you
4148       have read from Windows configuration files or the Windows Registry, to
4149       the true path.
4150
4151       The command handles a peculiarity of the Linux ntfs-3g filesystem
4152       driver (and probably others), which is that although the underlying
4153       filesystem is case-insensitive, the driver exports the filesystem to
4154       Linux as case-sensitive.
4155
4156       One consequence of this is that special directories such as C:\windows
4157       may appear as /WINDOWS or /windows (or other things) depending on the
4158       precise details of how they were created.  In Windows itself this would
4159       not be a problem.
4160
4161       Bug or feature?  You decide:
4162       https://www.tuxera.com/community/ntfs-3g-faq/#posixfilenames1
4163
4164       "guestfs_case_sensitive_path" attempts to resolve the true case of each
4165       element in the path. It will return a resolved path if either the full
4166       path or its parent directory exists. If the parent directory exists but
4167       the full path does not, the case of the parent directory will be
4168       correctly resolved, and the remainder appended unmodified. For example,
4169       if the file "/Windows/System32/netkvm.sys" exists:
4170
4171       "guestfs_case_sensitive_path" ("/windows/system32/netkvm.sys")
4172           "Windows/System32/netkvm.sys"
4173
4174       "guestfs_case_sensitive_path" ("/windows/system32/NoSuchFile")
4175           "Windows/System32/NoSuchFile"
4176
4177       "guestfs_case_sensitive_path" ("/windows/system33/netkvm.sys")
4178           ERROR
4179
4180       Note: Because of the above behaviour, "guestfs_case_sensitive_path"
4181       cannot be used to check for the existence of a file.
4182
4183       Note: This function does not handle drive names, backslashes etc.
4184
4185       See also "guestfs_realpath".
4186
4187       This function returns a string, or NULL on error.  The caller must free
4188       the returned string after use.
4189
4190       (Added in 1.0.75)
4191
4192   guestfs_cat
4193        char *
4194        guestfs_cat (guestfs_h *g,
4195                     const char *path);
4196
4197       Return the contents of the file named "path".
4198
4199       Because, in C, this function returns a "char *", there is no way to
4200       differentiate between a "\0" character in a file and end of string.  To
4201       handle binary files, use the "guestfs_read_file" or "guestfs_download"
4202       functions.
4203
4204       This function returns a string, or NULL on error.  The caller must free
4205       the returned string after use.
4206
4207       (Added in 0.4)
4208
4209   guestfs_checksum
4210        char *
4211        guestfs_checksum (guestfs_h *g,
4212                          const char *csumtype,
4213                          const char *path);
4214
4215       This call computes the MD5, SHAx or CRC checksum of the file named
4216       "path".
4217
4218       The type of checksum to compute is given by the "csumtype" parameter
4219       which must have one of the following values:
4220
4221       "crc"
4222           Compute the cyclic redundancy check (CRC) specified by POSIX for
4223           the "cksum" command.
4224
4225       "md5"
4226           Compute the MD5 hash (using the md5sum(1) program).
4227
4228       "sha1"
4229           Compute the SHA1 hash (using the sha1sum(1) program).
4230
4231       "sha224"
4232           Compute the SHA224 hash (using the sha224sum(1) program).
4233
4234       "sha256"
4235           Compute the SHA256 hash (using the sha256sum(1) program).
4236
4237       "sha384"
4238           Compute the SHA384 hash (using the sha384sum(1) program).
4239
4240       "sha512"
4241           Compute the SHA512 hash (using the sha512sum(1) program).
4242
4243       The checksum is returned as a printable string.
4244
4245       To get the checksum for a device, use "guestfs_checksum_device".
4246
4247       To get the checksums for many files, use "guestfs_checksums_out".
4248
4249       This function returns a string, or NULL on error.  The caller must free
4250       the returned string after use.
4251
4252       (Added in 1.0.2)
4253
4254   guestfs_checksum_device
4255        char *
4256        guestfs_checksum_device (guestfs_h *g,
4257                                 const char *csumtype,
4258                                 const char *device);
4259
4260       This call computes the MD5, SHAx or CRC checksum of the contents of the
4261       device named "device".  For the types of checksums supported see the
4262       "guestfs_checksum" command.
4263
4264       This function returns a string, or NULL on error.  The caller must free
4265       the returned string after use.
4266
4267       (Added in 1.3.2)
4268
4269   guestfs_checksums_out
4270        int
4271        guestfs_checksums_out (guestfs_h *g,
4272                               const char *csumtype,
4273                               const char *directory,
4274                               const char *sumsfile);
4275
4276       This command computes the checksums of all regular files in directory
4277       and then emits a list of those checksums to the local output file
4278       "sumsfile".
4279
4280       This can be used for verifying the integrity of a virtual machine.
4281       However to be properly secure you should pay attention to the output of
4282       the checksum command (it uses the ones from GNU coreutils).  In
4283       particular when the filename is not printable, coreutils uses a special
4284       backslash syntax.  For more information, see the GNU coreutils info
4285       file.
4286
4287       This function returns 0 on success or -1 on error.
4288
4289       (Added in 1.3.7)
4290
4291   guestfs_chmod
4292        int
4293        guestfs_chmod (guestfs_h *g,
4294                       int mode,
4295                       const char *path);
4296
4297       Change the mode (permissions) of "path" to "mode".  Only numeric modes
4298       are supported.
4299
4300       Note: When using this command from guestfish, "mode" by default would
4301       be decimal, unless you prefix it with 0 to get octal, ie. use 0700 not
4302       700.
4303
4304       The mode actually set is affected by the umask.
4305
4306       This function returns 0 on success or -1 on error.
4307
4308       (Added in 0.8)
4309
4310   guestfs_chown
4311        int
4312        guestfs_chown (guestfs_h *g,
4313                       int owner,
4314                       int group,
4315                       const char *path);
4316
4317       Change the file owner to "owner" and group to "group".
4318
4319       Only numeric uid and gid are supported.  If you want to use names, you
4320       will need to locate and parse the password file yourself (Augeas
4321       support makes this relatively easy).
4322
4323       This function returns 0 on success or -1 on error.
4324
4325       (Added in 0.8)
4326
4327   guestfs_clear_backend_setting
4328        int
4329        guestfs_clear_backend_setting (guestfs_h *g,
4330                                       const char *name);
4331
4332       If there is a backend setting string matching "name" or beginning with
4333       "name=", then that string is removed from the backend settings.
4334
4335       This call returns the number of strings which were removed (which may
4336       be 0, 1 or greater than 1).
4337
4338       See "BACKEND", "BACKEND SETTINGS".
4339
4340       On error this function returns -1.
4341
4342       (Added in 1.27.2)
4343
4344   guestfs_command
4345        char *
4346        guestfs_command (guestfs_h *g,
4347                         char *const *arguments);
4348
4349       This call runs a command from the guest filesystem.  The filesystem
4350       must be mounted, and must contain a compatible operating system (ie.
4351       something Linux, with the same or compatible processor architecture).
4352
4353       The single parameter is an argv-style list of arguments.  The first
4354       element is the name of the program to run.  Subsequent elements are
4355       parameters.  The list must be non-empty (ie. must contain a program
4356       name).  Note that the command runs directly, and is not invoked via the
4357       shell (see "guestfs_sh").
4358
4359       The return value is anything printed to stdout by the command.
4360
4361       If the command returns a non-zero exit status, then this function
4362       returns an error message.  The error message string is the content of
4363       stderr from the command.
4364
4365       The $PATH environment variable will contain at least /usr/bin and /bin.
4366       If you require a program from another location, you should provide the
4367       full path in the first parameter.
4368
4369       Shared libraries and data files required by the program must be
4370       available on filesystems which are mounted in the correct places.  It
4371       is the caller’s responsibility to ensure all filesystems that are
4372       needed are mounted at the right locations.
4373
4374       This function returns a string, or NULL on error.  The caller must free
4375       the returned string after use.
4376
4377       Because of the message protocol, there is a transfer limit of somewhere
4378       between 2MB and 4MB.  See "PROTOCOL LIMITS".
4379
4380       (Added in 1.9.1)
4381
4382   guestfs_command_lines
4383        char **
4384        guestfs_command_lines (guestfs_h *g,
4385                               char *const *arguments);
4386
4387       This is the same as "guestfs_command", but splits the result into a
4388       list of lines.
4389
4390       See also: "guestfs_sh_lines"
4391
4392       This function returns a NULL-terminated array of strings (like
4393       environ(3)), or NULL if there was an error.  The caller must free the
4394       strings and the array after use.
4395
4396       Because of the message protocol, there is a transfer limit of somewhere
4397       between 2MB and 4MB.  See "PROTOCOL LIMITS".
4398
4399       (Added in 1.9.1)
4400
4401   guestfs_compress_device_out
4402        int
4403        guestfs_compress_device_out (guestfs_h *g,
4404                                     const char *ctype,
4405                                     const char *device,
4406                                     const char *zdevice,
4407                                     ...);
4408
4409       You may supply a list of optional arguments to this call.  Use zero or
4410       more of the following pairs of parameters, and terminate the list with
4411       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4412
4413        GUESTFS_COMPRESS_DEVICE_OUT_LEVEL, int level,
4414
4415       This command compresses "device" and writes it out to the local file
4416       "zdevice".
4417
4418       The "ctype" and optional "level" parameters have the same meaning as in
4419       "guestfs_compress_out".
4420
4421       This function returns 0 on success or -1 on error.
4422
4423       (Added in 1.13.15)
4424
4425   guestfs_compress_device_out_va
4426        int
4427        guestfs_compress_device_out_va (guestfs_h *g,
4428                                        const char *ctype,
4429                                        const char *device,
4430                                        const char *zdevice,
4431                                        va_list args);
4432
4433       This is the "va_list variant" of "guestfs_compress_device_out".
4434
4435       See "CALLS WITH OPTIONAL ARGUMENTS".
4436
4437   guestfs_compress_device_out_argv
4438        int
4439        guestfs_compress_device_out_argv (guestfs_h *g,
4440                                          const char *ctype,
4441                                          const char *device,
4442                                          const char *zdevice,
4443                                          const struct guestfs_compress_device_out_argv *optargs);
4444
4445       This is the "argv variant" of "guestfs_compress_device_out".
4446
4447       See "CALLS WITH OPTIONAL ARGUMENTS".
4448
4449   guestfs_compress_out
4450        int
4451        guestfs_compress_out (guestfs_h *g,
4452                              const char *ctype,
4453                              const char *file,
4454                              const char *zfile,
4455                              ...);
4456
4457       You may supply a list of optional arguments to this call.  Use zero or
4458       more of the following pairs of parameters, and terminate the list with
4459       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4460
4461        GUESTFS_COMPRESS_OUT_LEVEL, int level,
4462
4463       This command compresses file and writes it out to the local file zfile.
4464
4465       The compression program used is controlled by the "ctype" parameter.
4466       Currently this includes: "compress", "gzip", "bzip2", "xz" or "lzop".
4467       Some compression types may not be supported by particular builds of
4468       libguestfs, in which case you will get an error containing the
4469       substring "not supported".
4470
4471       The optional "level" parameter controls compression level.  The meaning
4472       and default for this parameter depends on the compression program being
4473       used.
4474
4475       This function returns 0 on success or -1 on error.
4476
4477       (Added in 1.13.15)
4478
4479   guestfs_compress_out_va
4480        int
4481        guestfs_compress_out_va (guestfs_h *g,
4482                                 const char *ctype,
4483                                 const char *file,
4484                                 const char *zfile,
4485                                 va_list args);
4486
4487       This is the "va_list variant" of "guestfs_compress_out".
4488
4489       See "CALLS WITH OPTIONAL ARGUMENTS".
4490
4491   guestfs_compress_out_argv
4492        int
4493        guestfs_compress_out_argv (guestfs_h *g,
4494                                   const char *ctype,
4495                                   const char *file,
4496                                   const char *zfile,
4497                                   const struct guestfs_compress_out_argv *optargs);
4498
4499       This is the "argv variant" of "guestfs_compress_out".
4500
4501       See "CALLS WITH OPTIONAL ARGUMENTS".
4502
4503   guestfs_config
4504        int
4505        guestfs_config (guestfs_h *g,
4506                        const char *hvparam,
4507                        const char *hvvalue);
4508
4509       This can be used to add arbitrary hypervisor parameters of the form
4510       -param value.  Actually it’s not quite arbitrary - we prevent you from
4511       setting some parameters which would interfere with parameters that we
4512       use.
4513
4514       The first character of "hvparam" string must be a "-" (dash).
4515
4516       "hvvalue" can be NULL.
4517
4518       This function returns 0 on success or -1 on error.
4519
4520       (Added in 0.3)
4521
4522   guestfs_copy_attributes
4523        int
4524        guestfs_copy_attributes (guestfs_h *g,
4525                                 const char *src,
4526                                 const char *dest,
4527                                 ...);
4528
4529       You may supply a list of optional arguments to this call.  Use zero or
4530       more of the following pairs of parameters, and terminate the list with
4531       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4532
4533        GUESTFS_COPY_ATTRIBUTES_ALL, int all,
4534        GUESTFS_COPY_ATTRIBUTES_MODE, int mode,
4535        GUESTFS_COPY_ATTRIBUTES_XATTRIBUTES, int xattributes,
4536        GUESTFS_COPY_ATTRIBUTES_OWNERSHIP, int ownership,
4537
4538       Copy the attributes of a path (which can be a file or a directory) to
4539       another path.
4540
4541       By default no attribute is copied, so make sure to specify any (or
4542       "all" to copy everything).
4543
4544       The optional arguments specify which attributes can be copied:
4545
4546       "mode"
4547           Copy part of the file mode from "source" to "destination". Only the
4548           UNIX permissions and the sticky/setuid/setgid bits can be copied.
4549
4550       "xattributes"
4551           Copy the Linux extended attributes (xattrs) from "source" to
4552           "destination".  This flag does nothing if the linuxxattrs feature
4553           is not available (see "guestfs_feature_available").
4554
4555       "ownership"
4556           Copy the owner uid and the group gid of "source" to "destination".
4557
4558       "all"
4559           Copy all the attributes from "source" to "destination". Enabling it
4560           enables all the other flags, if they are not specified already.
4561
4562       This function returns 0 on success or -1 on error.
4563
4564       (Added in 1.25.21)
4565
4566   guestfs_copy_attributes_va
4567        int
4568        guestfs_copy_attributes_va (guestfs_h *g,
4569                                    const char *src,
4570                                    const char *dest,
4571                                    va_list args);
4572
4573       This is the "va_list variant" of "guestfs_copy_attributes".
4574
4575       See "CALLS WITH OPTIONAL ARGUMENTS".
4576
4577   guestfs_copy_attributes_argv
4578        int
4579        guestfs_copy_attributes_argv (guestfs_h *g,
4580                                      const char *src,
4581                                      const char *dest,
4582                                      const struct guestfs_copy_attributes_argv *optargs);
4583
4584       This is the "argv variant" of "guestfs_copy_attributes".
4585
4586       See "CALLS WITH OPTIONAL ARGUMENTS".
4587
4588   guestfs_copy_device_to_device
4589        int
4590        guestfs_copy_device_to_device (guestfs_h *g,
4591                                       const char *src,
4592                                       const char *dest,
4593                                       ...);
4594
4595       You may supply a list of optional arguments to this call.  Use zero or
4596       more of the following pairs of parameters, and terminate the list with
4597       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4598
4599        GUESTFS_COPY_DEVICE_TO_DEVICE_SRCOFFSET, int64_t srcoffset,
4600        GUESTFS_COPY_DEVICE_TO_DEVICE_DESTOFFSET, int64_t destoffset,
4601        GUESTFS_COPY_DEVICE_TO_DEVICE_SIZE, int64_t size,
4602        GUESTFS_COPY_DEVICE_TO_DEVICE_SPARSE, int sparse,
4603        GUESTFS_COPY_DEVICE_TO_DEVICE_APPEND, int append,
4604
4605       The four calls "guestfs_copy_device_to_device",
4606       "guestfs_copy_device_to_file", "guestfs_copy_file_to_device", and
4607       "guestfs_copy_file_to_file" let you copy from a source (device|file) to
4608       a destination (device|file).
4609
4610       Partial copies can be made since you can specify optionally the source
4611       offset, destination offset and size to copy.  These values are all
4612       specified in bytes.  If not given, the offsets both default to zero,
4613       and the size defaults to copying as much as possible until we hit the
4614       end of the source.
4615
4616       The source and destination may be the same object.  However overlapping
4617       regions may not be copied correctly.
4618
4619       If the destination is a file, it is created if required.  If the
4620       destination file is not large enough, it is extended.
4621
4622       If the destination is a file and the "append" flag is not set, then the
4623       destination file is truncated.  If the "append" flag is set, then the
4624       copy appends to the destination file.  The "append" flag currently
4625       cannot be set for devices.
4626
4627       If the "sparse" flag is true then the call avoids writing blocks that
4628       contain only zeroes, which can help in some situations where the
4629       backing disk is thin-provisioned.  Note that unless the target is
4630       already zeroed, using this option will result in incorrect copying.
4631
4632       This function returns 0 on success or -1 on error.
4633
4634       This long-running command can generate progress notification messages
4635       so that the caller can display a progress bar or indicator.  To receive
4636       these messages, the caller must register a progress event callback.
4637       See "GUESTFS_EVENT_PROGRESS".
4638
4639       (Added in 1.13.25)
4640
4641   guestfs_copy_device_to_device_va
4642        int
4643        guestfs_copy_device_to_device_va (guestfs_h *g,
4644                                          const char *src,
4645                                          const char *dest,
4646                                          va_list args);
4647
4648       This is the "va_list variant" of "guestfs_copy_device_to_device".
4649
4650       See "CALLS WITH OPTIONAL ARGUMENTS".
4651
4652   guestfs_copy_device_to_device_argv
4653        int
4654        guestfs_copy_device_to_device_argv (guestfs_h *g,
4655                                            const char *src,
4656                                            const char *dest,
4657                                            const struct guestfs_copy_device_to_device_argv *optargs);
4658
4659       This is the "argv variant" of "guestfs_copy_device_to_device".
4660
4661       See "CALLS WITH OPTIONAL ARGUMENTS".
4662
4663   guestfs_copy_device_to_file
4664        int
4665        guestfs_copy_device_to_file (guestfs_h *g,
4666                                     const char *src,
4667                                     const char *dest,
4668                                     ...);
4669
4670       You may supply a list of optional arguments to this call.  Use zero or
4671       more of the following pairs of parameters, and terminate the list with
4672       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4673
4674        GUESTFS_COPY_DEVICE_TO_FILE_SRCOFFSET, int64_t srcoffset,
4675        GUESTFS_COPY_DEVICE_TO_FILE_DESTOFFSET, int64_t destoffset,
4676        GUESTFS_COPY_DEVICE_TO_FILE_SIZE, int64_t size,
4677        GUESTFS_COPY_DEVICE_TO_FILE_SPARSE, int sparse,
4678        GUESTFS_COPY_DEVICE_TO_FILE_APPEND, int append,
4679
4680       See "guestfs_copy_device_to_device" for a general overview of this
4681       call.
4682
4683       This function returns 0 on success or -1 on error.
4684
4685       This long-running command can generate progress notification messages
4686       so that the caller can display a progress bar or indicator.  To receive
4687       these messages, the caller must register a progress event callback.
4688       See "GUESTFS_EVENT_PROGRESS".
4689
4690       (Added in 1.13.25)
4691
4692   guestfs_copy_device_to_file_va
4693        int
4694        guestfs_copy_device_to_file_va (guestfs_h *g,
4695                                        const char *src,
4696                                        const char *dest,
4697                                        va_list args);
4698
4699       This is the "va_list variant" of "guestfs_copy_device_to_file".
4700
4701       See "CALLS WITH OPTIONAL ARGUMENTS".
4702
4703   guestfs_copy_device_to_file_argv
4704        int
4705        guestfs_copy_device_to_file_argv (guestfs_h *g,
4706                                          const char *src,
4707                                          const char *dest,
4708                                          const struct guestfs_copy_device_to_file_argv *optargs);
4709
4710       This is the "argv variant" of "guestfs_copy_device_to_file".
4711
4712       See "CALLS WITH OPTIONAL ARGUMENTS".
4713
4714   guestfs_copy_file_to_device
4715        int
4716        guestfs_copy_file_to_device (guestfs_h *g,
4717                                     const char *src,
4718                                     const char *dest,
4719                                     ...);
4720
4721       You may supply a list of optional arguments to this call.  Use zero or
4722       more of the following pairs of parameters, and terminate the list with
4723       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4724
4725        GUESTFS_COPY_FILE_TO_DEVICE_SRCOFFSET, int64_t srcoffset,
4726        GUESTFS_COPY_FILE_TO_DEVICE_DESTOFFSET, int64_t destoffset,
4727        GUESTFS_COPY_FILE_TO_DEVICE_SIZE, int64_t size,
4728        GUESTFS_COPY_FILE_TO_DEVICE_SPARSE, int sparse,
4729        GUESTFS_COPY_FILE_TO_DEVICE_APPEND, int append,
4730
4731       See "guestfs_copy_device_to_device" for a general overview of this
4732       call.
4733
4734       This function returns 0 on success or -1 on error.
4735
4736       This long-running command can generate progress notification messages
4737       so that the caller can display a progress bar or indicator.  To receive
4738       these messages, the caller must register a progress event callback.
4739       See "GUESTFS_EVENT_PROGRESS".
4740
4741       (Added in 1.13.25)
4742
4743   guestfs_copy_file_to_device_va
4744        int
4745        guestfs_copy_file_to_device_va (guestfs_h *g,
4746                                        const char *src,
4747                                        const char *dest,
4748                                        va_list args);
4749
4750       This is the "va_list variant" of "guestfs_copy_file_to_device".
4751
4752       See "CALLS WITH OPTIONAL ARGUMENTS".
4753
4754   guestfs_copy_file_to_device_argv
4755        int
4756        guestfs_copy_file_to_device_argv (guestfs_h *g,
4757                                          const char *src,
4758                                          const char *dest,
4759                                          const struct guestfs_copy_file_to_device_argv *optargs);
4760
4761       This is the "argv variant" of "guestfs_copy_file_to_device".
4762
4763       See "CALLS WITH OPTIONAL ARGUMENTS".
4764
4765   guestfs_copy_file_to_file
4766        int
4767        guestfs_copy_file_to_file (guestfs_h *g,
4768                                   const char *src,
4769                                   const char *dest,
4770                                   ...);
4771
4772       You may supply a list of optional arguments to this call.  Use zero or
4773       more of the following pairs of parameters, and terminate the list with
4774       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4775
4776        GUESTFS_COPY_FILE_TO_FILE_SRCOFFSET, int64_t srcoffset,
4777        GUESTFS_COPY_FILE_TO_FILE_DESTOFFSET, int64_t destoffset,
4778        GUESTFS_COPY_FILE_TO_FILE_SIZE, int64_t size,
4779        GUESTFS_COPY_FILE_TO_FILE_SPARSE, int sparse,
4780        GUESTFS_COPY_FILE_TO_FILE_APPEND, int append,
4781
4782       See "guestfs_copy_device_to_device" for a general overview of this
4783       call.
4784
4785       This is not the function you want for copying files.  This is for
4786       copying blocks within existing files.  See "guestfs_cp", "guestfs_cp_a"
4787       and "guestfs_mv" for general file copying and moving functions.
4788
4789       This function returns 0 on success or -1 on error.
4790
4791       This long-running command can generate progress notification messages
4792       so that the caller can display a progress bar or indicator.  To receive
4793       these messages, the caller must register a progress event callback.
4794       See "GUESTFS_EVENT_PROGRESS".
4795
4796       (Added in 1.13.25)
4797
4798   guestfs_copy_file_to_file_va
4799        int
4800        guestfs_copy_file_to_file_va (guestfs_h *g,
4801                                      const char *src,
4802                                      const char *dest,
4803                                      va_list args);
4804
4805       This is the "va_list variant" of "guestfs_copy_file_to_file".
4806
4807       See "CALLS WITH OPTIONAL ARGUMENTS".
4808
4809   guestfs_copy_file_to_file_argv
4810        int
4811        guestfs_copy_file_to_file_argv (guestfs_h *g,
4812                                        const char *src,
4813                                        const char *dest,
4814                                        const struct guestfs_copy_file_to_file_argv *optargs);
4815
4816       This is the "argv variant" of "guestfs_copy_file_to_file".
4817
4818       See "CALLS WITH OPTIONAL ARGUMENTS".
4819
4820   guestfs_copy_in
4821        int
4822        guestfs_copy_in (guestfs_h *g,
4823                         const char *localpath,
4824                         const char *remotedir);
4825
4826       "guestfs_copy_in" copies local files or directories recursively into
4827       the disk image, placing them in the directory called "remotedir" (which
4828       must exist).
4829
4830       Wildcards cannot be used.
4831
4832       This function returns 0 on success or -1 on error.
4833
4834       (Added in 1.29.24)
4835
4836   guestfs_copy_out
4837        int
4838        guestfs_copy_out (guestfs_h *g,
4839                          const char *remotepath,
4840                          const char *localdir);
4841
4842       "guestfs_copy_out" copies remote files or directories recursively out
4843       of the disk image, placing them on the host disk in a local directory
4844       called "localdir" (which must exist).
4845
4846       To download to the current directory, use "." as in:
4847
4848        C<guestfs_copy_out> /home .
4849
4850       Wildcards cannot be used.
4851
4852       This function returns 0 on success or -1 on error.
4853
4854       (Added in 1.29.24)
4855
4856   guestfs_copy_size
4857        int
4858        guestfs_copy_size (guestfs_h *g,
4859                           const char *src,
4860                           const char *dest,
4861                           int64_t size);
4862
4863       This function is deprecated.  In new code, use the
4864       "guestfs_copy_device_to_device" call instead.
4865
4866       Deprecated functions will not be removed from the API, but the fact
4867       that they are deprecated indicates that there are problems with correct
4868       use of these functions.
4869
4870       This command copies exactly "size" bytes from one source device or file
4871       "src" to another destination device or file "dest".
4872
4873       Note this will fail if the source is too short or if the destination is
4874       not large enough.
4875
4876       This function returns 0 on success or -1 on error.
4877
4878       This long-running command can generate progress notification messages
4879       so that the caller can display a progress bar or indicator.  To receive
4880       these messages, the caller must register a progress event callback.
4881       See "GUESTFS_EVENT_PROGRESS".
4882
4883       (Added in 1.0.87)
4884
4885   guestfs_cp
4886        int
4887        guestfs_cp (guestfs_h *g,
4888                    const char *src,
4889                    const char *dest);
4890
4891       This copies a file from "src" to "dest" where "dest" is either a
4892       destination filename or destination directory.
4893
4894       This function returns 0 on success or -1 on error.
4895
4896       (Added in 1.0.18)
4897
4898   guestfs_cp_a
4899        int
4900        guestfs_cp_a (guestfs_h *g,
4901                      const char *src,
4902                      const char *dest);
4903
4904       This copies a file or directory from "src" to "dest" recursively using
4905       the "cp -a" command.
4906
4907       This function returns 0 on success or -1 on error.
4908
4909       (Added in 1.0.18)
4910
4911   guestfs_cp_r
4912        int
4913        guestfs_cp_r (guestfs_h *g,
4914                      const char *src,
4915                      const char *dest);
4916
4917       This copies a file or directory from "src" to "dest" recursively using
4918       the "cp -rP" command.
4919
4920       Most users should use "guestfs_cp_a" instead.  This command is useful
4921       when you don't want to preserve permissions, because the target
4922       filesystem does not support it (primarily when writing to DOS FAT
4923       filesystems).
4924
4925       This function returns 0 on success or -1 on error.
4926
4927       (Added in 1.21.38)
4928
4929   guestfs_cpio_out
4930        int
4931        guestfs_cpio_out (guestfs_h *g,
4932                          const char *directory,
4933                          const char *cpiofile,
4934                          ...);
4935
4936       You may supply a list of optional arguments to this call.  Use zero or
4937       more of the following pairs of parameters, and terminate the list with
4938       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
4939
4940        GUESTFS_CPIO_OUT_FORMAT, const char *format,
4941
4942       This command packs the contents of directory and downloads it to local
4943       file "cpiofile".
4944
4945       The optional "format" parameter can be used to select the format.  Only
4946       the following formats are currently permitted:
4947
4948       "newc"
4949           New (SVR4) portable format.  This format happens to be compatible
4950           with the cpio-like format used by the Linux kernel for initramfs.
4951
4952           This is the default format.
4953
4954       "crc"
4955           New (SVR4) portable format with a checksum.
4956
4957       This function returns 0 on success or -1 on error.
4958
4959       (Added in 1.27.9)
4960
4961   guestfs_cpio_out_va
4962        int
4963        guestfs_cpio_out_va (guestfs_h *g,
4964                             const char *directory,
4965                             const char *cpiofile,
4966                             va_list args);
4967
4968       This is the "va_list variant" of "guestfs_cpio_out".
4969
4970       See "CALLS WITH OPTIONAL ARGUMENTS".
4971
4972   guestfs_cpio_out_argv
4973        int
4974        guestfs_cpio_out_argv (guestfs_h *g,
4975                               const char *directory,
4976                               const char *cpiofile,
4977                               const struct guestfs_cpio_out_argv *optargs);
4978
4979       This is the "argv variant" of "guestfs_cpio_out".
4980
4981       See "CALLS WITH OPTIONAL ARGUMENTS".
4982
4983   guestfs_dd
4984        int
4985        guestfs_dd (guestfs_h *g,
4986                    const char *src,
4987                    const char *dest);
4988
4989       This function is deprecated.  In new code, use the
4990       "guestfs_copy_device_to_device" call instead.
4991
4992       Deprecated functions will not be removed from the API, but the fact
4993       that they are deprecated indicates that there are problems with correct
4994       use of these functions.
4995
4996       This command copies from one source device or file "src" to another
4997       destination device or file "dest".  Normally you would use this to copy
4998       to or from a device or partition, for example to duplicate a
4999       filesystem.
5000
5001       If the destination is a device, it must be as large or larger than the
5002       source file or device, otherwise the copy will fail.  This command
5003       cannot do partial copies (see "guestfs_copy_device_to_device").
5004
5005       This function returns 0 on success or -1 on error.
5006
5007       (Added in 1.0.80)
5008
5009   guestfs_device_index
5010        int
5011        guestfs_device_index (guestfs_h *g,
5012                              const char *device);
5013
5014       This function takes a device name (eg. "/dev/sdb") and returns the
5015       index of the device in the list of devices.
5016
5017       Index numbers start from 0.  The named device must exist, for example
5018       as a string returned from "guestfs_list_devices".
5019
5020       See also "guestfs_list_devices", "guestfs_part_to_dev".
5021
5022       On error this function returns -1.
5023
5024       (Added in 1.19.7)
5025
5026   guestfs_df
5027        char *
5028        guestfs_df (guestfs_h *g);
5029
5030       This command runs the df(1) command to report disk space used.
5031
5032       This command is mostly useful for interactive sessions.  It is not
5033       intended that you try to parse the output string.  Use
5034       "guestfs_statvfs" from programs.
5035
5036       This function returns a string, or NULL on error.  The caller must free
5037       the returned string after use.
5038
5039       (Added in 1.0.54)
5040
5041   guestfs_df_h
5042        char *
5043        guestfs_df_h (guestfs_h *g);
5044
5045       This command runs the "df -h" command to report disk space used in
5046       human-readable format.
5047
5048       This command is mostly useful for interactive sessions.  It is not
5049       intended that you try to parse the output string.  Use
5050       "guestfs_statvfs" from programs.
5051
5052       This function returns a string, or NULL on error.  The caller must free
5053       the returned string after use.
5054
5055       (Added in 1.0.54)
5056
5057   guestfs_disk_create
5058        int
5059        guestfs_disk_create (guestfs_h *g,
5060                             const char *filename,
5061                             const char *format,
5062                             int64_t size,
5063                             ...);
5064
5065       You may supply a list of optional arguments to this call.  Use zero or
5066       more of the following pairs of parameters, and terminate the list with
5067       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
5068
5069        GUESTFS_DISK_CREATE_BACKINGFILE, const char *backingfile,
5070        GUESTFS_DISK_CREATE_BACKINGFORMAT, const char *backingformat,
5071        GUESTFS_DISK_CREATE_PREALLOCATION, const char *preallocation,
5072        GUESTFS_DISK_CREATE_COMPAT, const char *compat,
5073        GUESTFS_DISK_CREATE_CLUSTERSIZE, int clustersize,
5074
5075       Create a blank disk image called filename (a host file) with format
5076       "format" (usually "raw" or "qcow2").  The size is "size" bytes.
5077
5078       If used with the optional "backingfile" parameter, then a snapshot is
5079       created on top of the backing file.  In this case, "size" must be
5080       passed as "-1".  The size of the snapshot is the same as the size of
5081       the backing file, which is discovered automatically.  You are
5082       encouraged to also pass "backingformat" to describe the format of
5083       "backingfile".
5084
5085       If filename refers to a block device, then the device is formatted.
5086       The "size" is ignored since block devices have an intrinsic size.
5087
5088       The other optional parameters are:
5089
5090       "preallocation"
5091           If format is "raw", then this can be either "off" (or "sparse") or
5092           "full" to create a sparse or fully allocated file respectively.
5093           The default is "off".
5094
5095           If format is "qcow2", then this can be "off" (or "sparse"),
5096           "metadata" or "full".  Preallocating metadata can be faster when
5097           doing lots of writes, but uses more space.  The default is "off".
5098
5099       "compat"
5100           "qcow2" only: Pass the string 1.1 to use the advanced qcow2 format
5101           supported by qemu ≥ 1.1.
5102
5103       "clustersize"
5104           "qcow2" only: Change the qcow2 cluster size.  The default is 65536
5105           (bytes) and this setting may be any power of two between 512 and
5106           2097152.
5107
5108       Note that this call does not add the new disk to the handle.  You may
5109       need to call "guestfs_add_drive_opts" separately.
5110
5111       This function returns 0 on success or -1 on error.
5112
5113       (Added in 1.25.31)
5114
5115   guestfs_disk_create_va
5116        int
5117        guestfs_disk_create_va (guestfs_h *g,
5118                                const char *filename,
5119                                const char *format,
5120                                int64_t size,
5121                                va_list args);
5122
5123       This is the "va_list variant" of "guestfs_disk_create".
5124
5125       See "CALLS WITH OPTIONAL ARGUMENTS".
5126
5127   guestfs_disk_create_argv
5128        int
5129        guestfs_disk_create_argv (guestfs_h *g,
5130                                  const char *filename,
5131                                  const char *format,
5132                                  int64_t size,
5133                                  const struct guestfs_disk_create_argv *optargs);
5134
5135       This is the "argv variant" of "guestfs_disk_create".
5136
5137       See "CALLS WITH OPTIONAL ARGUMENTS".
5138
5139   guestfs_disk_format
5140        char *
5141        guestfs_disk_format (guestfs_h *g,
5142                             const char *filename);
5143
5144       Detect and return the format of the disk image called filename.
5145       filename can also be a host device, etc.  If the format of the image
5146       could not be detected, then "unknown" is returned.
5147
5148       Note that detecting the disk format can be insecure under some
5149       circumstances.  See "CVE-2010-3851".
5150
5151       See also: "DISK IMAGE FORMATS"
5152
5153       This function returns a string, or NULL on error.  The caller must free
5154       the returned string after use.
5155
5156       (Added in 1.19.38)
5157
5158   guestfs_disk_has_backing_file
5159        int
5160        guestfs_disk_has_backing_file (guestfs_h *g,
5161                                       const char *filename);
5162
5163       Detect and return whether the disk image filename has a backing file.
5164
5165       Note that detecting disk features can be insecure under some
5166       circumstances.  See "CVE-2010-3851".
5167
5168       This function returns a C truth value on success or -1 on error.
5169
5170       (Added in 1.19.39)
5171
5172   guestfs_disk_virtual_size
5173        int64_t
5174        guestfs_disk_virtual_size (guestfs_h *g,
5175                                   const char *filename);
5176
5177       Detect and return the virtual size in bytes of the disk image called
5178       filename.
5179
5180       Note that detecting disk features can be insecure under some
5181       circumstances.  See "CVE-2010-3851".
5182
5183       On error this function returns -1.
5184
5185       (Added in 1.19.39)
5186
5187   guestfs_dmesg
5188        char *
5189        guestfs_dmesg (guestfs_h *g);
5190
5191       This returns the kernel messages (dmesg(1) output) from the guest
5192       kernel.  This is sometimes useful for extended debugging of problems.
5193
5194       Another way to get the same information is to enable verbose messages
5195       with "guestfs_set_verbose" or by setting the environment variable
5196       "LIBGUESTFS_DEBUG=1" before running the program.
5197
5198       This function returns a string, or NULL on error.  The caller must free
5199       the returned string after use.
5200
5201       (Added in 1.0.18)
5202
5203   guestfs_download
5204        int
5205        guestfs_download (guestfs_h *g,
5206                          const char *remotefilename,
5207                          const char *filename);
5208
5209       Download file remotefilename and save it as filename on the local
5210       machine.
5211
5212       filename can also be a named pipe.
5213
5214       See also "guestfs_upload", "guestfs_cat".
5215
5216       This function returns 0 on success or -1 on error.
5217
5218       This long-running command can generate progress notification messages
5219       so that the caller can display a progress bar or indicator.  To receive
5220       these messages, the caller must register a progress event callback.
5221       See "GUESTFS_EVENT_PROGRESS".
5222
5223       (Added in 1.0.2)
5224
5225   guestfs_download_blocks
5226        int
5227        guestfs_download_blocks (guestfs_h *g,
5228                                 const char *device,
5229                                 int64_t start,
5230                                 int64_t stop,
5231                                 const char *filename,
5232                                 ...);
5233
5234       You may supply a list of optional arguments to this call.  Use zero or
5235       more of the following pairs of parameters, and terminate the list with
5236       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
5237
5238        GUESTFS_DOWNLOAD_BLOCKS_UNALLOCATED, int unallocated,
5239
5240       Download the data units from start address to stop from the disk
5241       partition (eg. /dev/sda1) and save them as filename on the local
5242       machine.
5243
5244       The use of this API on sparse disk image formats such as QCOW, may
5245       result in large zero-filled files downloaded on the host.
5246
5247       The size of a data unit varies across filesystem implementations.  On
5248       NTFS filesystems data units are referred as clusters while on ExtX ones
5249       they are referred as fragments.
5250
5251       If the optional "unallocated" flag is true (default is false), only the
5252       unallocated blocks will be extracted.  This is useful to detect hidden
5253       data or to retrieve deleted files which data units have not been
5254       overwritten yet.
5255
5256       This function returns 0 on success or -1 on error.
5257
5258       This long-running command can generate progress notification messages
5259       so that the caller can display a progress bar or indicator.  To receive
5260       these messages, the caller must register a progress event callback.
5261       See "GUESTFS_EVENT_PROGRESS".
5262
5263       This function depends on the feature "sleuthkit".  See also
5264       "guestfs_feature_available".
5265
5266       (Added in 1.33.45)
5267
5268   guestfs_download_blocks_va
5269        int
5270        guestfs_download_blocks_va (guestfs_h *g,
5271                                    const char *device,
5272                                    int64_t start,
5273                                    int64_t stop,
5274                                    const char *filename,
5275                                    va_list args);
5276
5277       This is the "va_list variant" of "guestfs_download_blocks".
5278
5279       See "CALLS WITH OPTIONAL ARGUMENTS".
5280
5281   guestfs_download_blocks_argv
5282        int
5283        guestfs_download_blocks_argv (guestfs_h *g,
5284                                      const char *device,
5285                                      int64_t start,
5286                                      int64_t stop,
5287                                      const char *filename,
5288                                      const struct guestfs_download_blocks_argv *optargs);
5289
5290       This is the "argv variant" of "guestfs_download_blocks".
5291
5292       See "CALLS WITH OPTIONAL ARGUMENTS".
5293
5294   guestfs_download_inode
5295        int
5296        guestfs_download_inode (guestfs_h *g,
5297                                const char *device,
5298                                int64_t inode,
5299                                const char *filename);
5300
5301       Download a file given its inode from the disk partition (eg. /dev/sda1)
5302       and save it as filename on the local machine.
5303
5304       It is not required to mount the disk to run this command.
5305
5306       The command is capable of downloading deleted or inaccessible files.
5307
5308       This function returns 0 on success or -1 on error.
5309
5310       This long-running command can generate progress notification messages
5311       so that the caller can display a progress bar or indicator.  To receive
5312       these messages, the caller must register a progress event callback.
5313       See "GUESTFS_EVENT_PROGRESS".
5314
5315       This function depends on the feature "sleuthkit".  See also
5316       "guestfs_feature_available".
5317
5318       (Added in 1.33.14)
5319
5320   guestfs_download_offset
5321        int
5322        guestfs_download_offset (guestfs_h *g,
5323                                 const char *remotefilename,
5324                                 const char *filename,
5325                                 int64_t offset,
5326                                 int64_t size);
5327
5328       Download file remotefilename and save it as filename on the local
5329       machine.
5330
5331       remotefilename is read for "size" bytes starting at "offset" (this
5332       region must be within the file or device).
5333
5334       Note that there is no limit on the amount of data that can be
5335       downloaded with this call, unlike with "guestfs_pread", and this call
5336       always reads the full amount unless an error occurs.
5337
5338       See also "guestfs_download", "guestfs_pread".
5339
5340       This function returns 0 on success or -1 on error.
5341
5342       This long-running command can generate progress notification messages
5343       so that the caller can display a progress bar or indicator.  To receive
5344       these messages, the caller must register a progress event callback.
5345       See "GUESTFS_EVENT_PROGRESS".
5346
5347       (Added in 1.5.17)
5348
5349   guestfs_drop_caches
5350        int
5351        guestfs_drop_caches (guestfs_h *g,
5352                             int whattodrop);
5353
5354       This instructs the guest kernel to drop its page cache, and/or dentries
5355       and inode caches.  The parameter "whattodrop" tells the kernel what
5356       precisely to drop, see https://linux-mm.org/Drop_Caches
5357
5358       Setting "whattodrop" to 3 should drop everything.
5359
5360       This automatically calls sync(2) before the operation, so that the
5361       maximum guest memory is freed.
5362
5363       This function returns 0 on success or -1 on error.
5364
5365       (Added in 1.0.18)
5366
5367   guestfs_du
5368        int64_t
5369        guestfs_du (guestfs_h *g,
5370                    const char *path);
5371
5372       This command runs the "du -s" command to estimate file space usage for
5373       "path".
5374
5375       "path" can be a file or a directory.  If "path" is a directory then the
5376       estimate includes the contents of the directory and all subdirectories
5377       (recursively).
5378
5379       The result is the estimated size in kilobytes (ie. units of 1024
5380       bytes).
5381
5382       On error this function returns -1.
5383
5384       This long-running command can generate progress notification messages
5385       so that the caller can display a progress bar or indicator.  To receive
5386       these messages, the caller must register a progress event callback.
5387       See "GUESTFS_EVENT_PROGRESS".
5388
5389       (Added in 1.0.54)
5390
5391   guestfs_e2fsck
5392        int
5393        guestfs_e2fsck (guestfs_h *g,
5394                        const char *device,
5395                        ...);
5396
5397       You may supply a list of optional arguments to this call.  Use zero or
5398       more of the following pairs of parameters, and terminate the list with
5399       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
5400
5401        GUESTFS_E2FSCK_CORRECT, int correct,
5402        GUESTFS_E2FSCK_FORCEALL, int forceall,
5403
5404       This runs the ext2/ext3 filesystem checker on "device".  It can take
5405       the following optional arguments:
5406
5407       "correct"
5408           Automatically repair the file system. This option will cause e2fsck
5409           to automatically fix any filesystem problems that can be safely
5410           fixed without human intervention.
5411
5412           This option may not be specified at the same time as the "forceall"
5413           option.
5414
5415       "forceall"
5416           Assume an answer of ‘yes’ to all questions; allows e2fsck to be
5417           used non-interactively.
5418
5419           This option may not be specified at the same time as the "correct"
5420           option.
5421
5422       This function returns 0 on success or -1 on error.
5423
5424       (Added in 1.15.17)
5425
5426   guestfs_e2fsck_va
5427        int
5428        guestfs_e2fsck_va (guestfs_h *g,
5429                           const char *device,
5430                           va_list args);
5431
5432       This is the "va_list variant" of "guestfs_e2fsck".
5433
5434       See "CALLS WITH OPTIONAL ARGUMENTS".
5435
5436   guestfs_e2fsck_argv
5437        int
5438        guestfs_e2fsck_argv (guestfs_h *g,
5439                             const char *device,
5440                             const struct guestfs_e2fsck_argv *optargs);
5441
5442       This is the "argv variant" of "guestfs_e2fsck".
5443
5444       See "CALLS WITH OPTIONAL ARGUMENTS".
5445
5446   guestfs_e2fsck_f
5447        int
5448        guestfs_e2fsck_f (guestfs_h *g,
5449                          const char *device);
5450
5451       This function is deprecated.  In new code, use the "guestfs_e2fsck"
5452       call instead.
5453
5454       Deprecated functions will not be removed from the API, but the fact
5455       that they are deprecated indicates that there are problems with correct
5456       use of these functions.
5457
5458       This runs "e2fsck -p -f device", ie. runs the ext2/ext3 filesystem
5459       checker on "device", noninteractively (-p), even if the filesystem
5460       appears to be clean (-f).
5461
5462       This function returns 0 on success or -1 on error.
5463
5464       (Added in 1.0.29)
5465
5466   guestfs_echo_daemon
5467        char *
5468        guestfs_echo_daemon (guestfs_h *g,
5469                             char *const *words);
5470
5471       This command concatenates the list of "words" passed with single spaces
5472       between them and returns the resulting string.
5473
5474       You can use this command to test the connection through to the daemon.
5475
5476       See also "guestfs_ping_daemon".
5477
5478       This function returns a string, or NULL on error.  The caller must free
5479       the returned string after use.
5480
5481       (Added in 1.0.69)
5482
5483   guestfs_egrep
5484        char **
5485        guestfs_egrep (guestfs_h *g,
5486                       const char *regex,
5487                       const char *path);
5488
5489       This function is deprecated.  In new code, use the "guestfs_grep" call
5490       instead.
5491
5492       Deprecated functions will not be removed from the API, but the fact
5493       that they are deprecated indicates that there are problems with correct
5494       use of these functions.
5495
5496       This calls the external egrep(1) program and returns the matching
5497       lines.
5498
5499       This function returns a NULL-terminated array of strings (like
5500       environ(3)), or NULL if there was an error.  The caller must free the
5501       strings and the array after use.
5502
5503       Because of the message protocol, there is a transfer limit of somewhere
5504       between 2MB and 4MB.  See "PROTOCOL LIMITS".
5505
5506       (Added in 1.0.66)
5507
5508   guestfs_egrepi
5509        char **
5510        guestfs_egrepi (guestfs_h *g,
5511                        const char *regex,
5512                        const char *path);
5513
5514       This function is deprecated.  In new code, use the "guestfs_grep" call
5515       instead.
5516
5517       Deprecated functions will not be removed from the API, but the fact
5518       that they are deprecated indicates that there are problems with correct
5519       use of these functions.
5520
5521       This calls the external "egrep -i" program and returns the matching
5522       lines.
5523
5524       This function returns a NULL-terminated array of strings (like
5525       environ(3)), or NULL if there was an error.  The caller must free the
5526       strings and the array after use.
5527
5528       Because of the message protocol, there is a transfer limit of somewhere
5529       between 2MB and 4MB.  See "PROTOCOL LIMITS".
5530
5531       (Added in 1.0.66)
5532
5533   guestfs_equal
5534        int
5535        guestfs_equal (guestfs_h *g,
5536                       const char *file1,
5537                       const char *file2);
5538
5539       This compares the two files file1 and file2 and returns true if their
5540       content is exactly equal, or false otherwise.
5541
5542       The external cmp(1) program is used for the comparison.
5543
5544       This function returns a C truth value on success or -1 on error.
5545
5546       (Added in 1.0.18)
5547
5548   guestfs_exists
5549        int
5550        guestfs_exists (guestfs_h *g,
5551                        const char *path);
5552
5553       This returns "true" if and only if there is a file, directory (or
5554       anything) with the given "path" name.
5555
5556       See also "guestfs_is_file", "guestfs_is_dir", "guestfs_stat".
5557
5558       This function returns a C truth value on success or -1 on error.
5559
5560       (Added in 0.8)
5561
5562   guestfs_extlinux
5563        int
5564        guestfs_extlinux (guestfs_h *g,
5565                          const char *directory);
5566
5567       Install the SYSLINUX bootloader on the device mounted at directory.
5568       Unlike "guestfs_syslinux" which requires a FAT filesystem, this can be
5569       used on an ext2/3/4 or btrfs filesystem.
5570
5571       The directory parameter can be either a mountpoint, or a directory
5572       within the mountpoint.
5573
5574       You also have to mark the partition as "active"
5575       ("guestfs_part_set_bootable") and a Master Boot Record must be
5576       installed (eg. using "guestfs_pwrite_device") on the first sector of
5577       the whole disk.  The SYSLINUX package comes with some suitable Master
5578       Boot Records.  See the extlinux(1) man page for further information.
5579
5580       Additional configuration can be supplied to SYSLINUX by placing a file
5581       called extlinux.conf on the filesystem under directory.  For further
5582       information about the contents of this file, see extlinux(1).
5583
5584       See also "guestfs_syslinux".
5585
5586       This function returns 0 on success or -1 on error.
5587
5588       This function depends on the feature "extlinux".  See also
5589       "guestfs_feature_available".
5590
5591       (Added in 1.21.27)
5592
5593   guestfs_f2fs_expand
5594        int
5595        guestfs_f2fs_expand (guestfs_h *g,
5596                             const char *device);
5597
5598       This expands a f2fs filesystem to match the size of the underlying
5599       device.
5600
5601       This function returns 0 on success or -1 on error.
5602
5603       This function depends on the feature "f2fs".  See also
5604       "guestfs_feature_available".
5605
5606       (Added in 1.39.3)
5607
5608   guestfs_fallocate
5609        int
5610        guestfs_fallocate (guestfs_h *g,
5611                           const char *path,
5612                           int len);
5613
5614       This function is deprecated.  In new code, use the
5615       "guestfs_fallocate64" call instead.
5616
5617       Deprecated functions will not be removed from the API, but the fact
5618       that they are deprecated indicates that there are problems with correct
5619       use of these functions.
5620
5621       This command preallocates a file (containing zero bytes) named "path"
5622       of size "len" bytes.  If the file exists already, it is overwritten.
5623
5624       Do not confuse this with the guestfish-specific "alloc" command which
5625       allocates a file in the host and attaches it as a device.
5626
5627       This function returns 0 on success or -1 on error.
5628
5629       (Added in 1.0.66)
5630
5631   guestfs_fallocate64
5632        int
5633        guestfs_fallocate64 (guestfs_h *g,
5634                             const char *path,
5635                             int64_t len);
5636
5637       This command preallocates a file (containing zero bytes) named "path"
5638       of size "len" bytes.  If the file exists already, it is overwritten.
5639
5640       Note that this call allocates disk blocks for the file.  To create a
5641       sparse file use "guestfs_truncate_size" instead.
5642
5643       The deprecated call "guestfs_fallocate" does the same, but owing to an
5644       oversight it only allowed 30 bit lengths to be specified, effectively
5645       limiting the maximum size of files created through that call to 1GB.
5646
5647       Do not confuse this with the guestfish-specific "alloc" and "sparse"
5648       commands which create a file in the host and attach it as a device.
5649
5650       This function returns 0 on success or -1 on error.
5651
5652       (Added in 1.3.17)
5653
5654   guestfs_feature_available
5655        int
5656        guestfs_feature_available (guestfs_h *g,
5657                                   char *const *groups);
5658
5659       This is the same as "guestfs_available", but unlike that call it
5660       returns a simple true/false boolean result, instead of throwing an
5661       exception if a feature is not found.  For other documentation see
5662       "guestfs_available".
5663
5664       This function returns a C truth value on success or -1 on error.
5665
5666       (Added in 1.21.26)
5667
5668   guestfs_fgrep
5669        char **
5670        guestfs_fgrep (guestfs_h *g,
5671                       const char *pattern,
5672                       const char *path);
5673
5674       This function is deprecated.  In new code, use the "guestfs_grep" call
5675       instead.
5676
5677       Deprecated functions will not be removed from the API, but the fact
5678       that they are deprecated indicates that there are problems with correct
5679       use of these functions.
5680
5681       This calls the external fgrep(1) program and returns the matching
5682       lines.
5683
5684       This function returns a NULL-terminated array of strings (like
5685       environ(3)), or NULL if there was an error.  The caller must free the
5686       strings and the array after use.
5687
5688       Because of the message protocol, there is a transfer limit of somewhere
5689       between 2MB and 4MB.  See "PROTOCOL LIMITS".
5690
5691       (Added in 1.0.66)
5692
5693   guestfs_fgrepi
5694        char **
5695        guestfs_fgrepi (guestfs_h *g,
5696                        const char *pattern,
5697                        const char *path);
5698
5699       This function is deprecated.  In new code, use the "guestfs_grep" call
5700       instead.
5701
5702       Deprecated functions will not be removed from the API, but the fact
5703       that they are deprecated indicates that there are problems with correct
5704       use of these functions.
5705
5706       This calls the external "fgrep -i" program and returns the matching
5707       lines.
5708
5709       This function returns a NULL-terminated array of strings (like
5710       environ(3)), or NULL if there was an error.  The caller must free the
5711       strings and the array after use.
5712
5713       Because of the message protocol, there is a transfer limit of somewhere
5714       between 2MB and 4MB.  See "PROTOCOL LIMITS".
5715
5716       (Added in 1.0.66)
5717
5718   guestfs_file
5719        char *
5720        guestfs_file (guestfs_h *g,
5721                      const char *path);
5722
5723       This call uses the standard file(1) command to determine the type or
5724       contents of the file.
5725
5726       This call will also transparently look inside various types of
5727       compressed file.
5728
5729       The exact command which runs is "file -zb path".  Note in particular
5730       that the filename is not prepended to the output (the -b option).
5731
5732       The output depends on the output of the underlying file(1) command and
5733       it can change in future in ways beyond our control.  In other words,
5734       the output is not guaranteed by the ABI.
5735
5736       See also: file(1), "guestfs_vfs_type", "guestfs_lstat",
5737       "guestfs_is_file", "guestfs_is_blockdev" (etc), "guestfs_is_zero".
5738
5739       This function returns a string, or NULL on error.  The caller must free
5740       the returned string after use.
5741
5742       (Added in 1.9.1)
5743
5744   guestfs_file_architecture
5745        char *
5746        guestfs_file_architecture (guestfs_h *g,
5747                                   const char *filename);
5748
5749       This detects the architecture of the binary filename, and returns it if
5750       known.
5751
5752       Currently defined architectures are:
5753
5754       "aarch64"
5755           64 bit ARM.
5756
5757       "arm"
5758           32 bit ARM.
5759
5760       "i386"
5761           This string is returned for all 32 bit i386, i486, i586, i686
5762           binaries irrespective of the precise processor requirements of the
5763           binary.
5764
5765       "ia64"
5766           Intel Itanium.
5767
5768       "ppc"
5769           32 bit Power PC.
5770
5771       "ppc64"
5772           64 bit Power PC (big endian).
5773
5774       "ppc64le"
5775           64 bit Power PC (little endian).
5776
5777       "riscv32"
5778       "riscv64"
5779       "riscv128"
5780           RISC-V 32-, 64- or 128-bit variants.
5781
5782       "s390"
5783           31 bit IBM S/390.
5784
5785       "s390x"
5786           64 bit IBM S/390.
5787
5788       "sparc"
5789           32 bit SPARC.
5790
5791       "sparc64"
5792           64 bit SPARC V9 and above.
5793
5794       "x86_64"
5795           64 bit x86-64.
5796
5797       Libguestfs may return other architecture strings in future.
5798
5799       The function works on at least the following types of files:
5800
5801       ·   many types of Un*x and Linux binary
5802
5803       ·   many types of Un*x and Linux shared library
5804
5805       ·   Windows Win32 and Win64 binaries
5806
5807       ·   Windows Win32 and Win64 DLLs
5808
5809           Win32 binaries and DLLs return "i386".
5810
5811           Win64 binaries and DLLs return "x86_64".
5812
5813       ·   Linux kernel modules
5814
5815       ·   Linux new-style initrd images
5816
5817       ·   some non-x86 Linux vmlinuz kernels
5818
5819       What it can't do currently:
5820
5821       ·   static libraries (libfoo.a)
5822
5823       ·   Linux old-style initrd as compressed ext2 filesystem (RHEL 3)
5824
5825       ·   x86 Linux vmlinuz kernels
5826
5827           x86 vmlinuz images (bzImage format) consist of a mix of 16-, 32-
5828           and compressed code, and are horribly hard to unpack.  If you want
5829           to find the architecture of a kernel, use the architecture of the
5830           associated initrd or kernel module(s) instead.
5831
5832       This function returns a string, or NULL on error.  The caller must free
5833       the returned string after use.
5834
5835       (Added in 1.5.3)
5836
5837   guestfs_filesize
5838        int64_t
5839        guestfs_filesize (guestfs_h *g,
5840                          const char *file);
5841
5842       This command returns the size of file in bytes.
5843
5844       To get other stats about a file, use "guestfs_stat", "guestfs_lstat",
5845       "guestfs_is_dir", "guestfs_is_file" etc.  To get the size of block
5846       devices, use "guestfs_blockdev_getsize64".
5847
5848       On error this function returns -1.
5849
5850       (Added in 1.0.82)
5851
5852   guestfs_filesystem_available
5853        int
5854        guestfs_filesystem_available (guestfs_h *g,
5855                                      const char *filesystem);
5856
5857       Check whether libguestfs supports the named filesystem.  The argument
5858       "filesystem" is a filesystem name, such as "ext3".
5859
5860       You must call "guestfs_launch" before using this command.
5861
5862       This is mainly useful as a negative test.  If this returns true, it
5863       doesn't mean that a particular filesystem can be created or mounted,
5864       since filesystems can fail for other reasons such as it being a later
5865       version of the filesystem, or having incompatible features, or lacking
5866       the right mkfs.<fs> tool.
5867
5868       See also "guestfs_available", "guestfs_feature_available",
5869       "AVAILABILITY".
5870
5871       This function returns a C truth value on success or -1 on error.
5872
5873       (Added in 1.19.5)
5874
5875   guestfs_filesystem_walk
5876        struct guestfs_tsk_dirent_list *
5877        guestfs_filesystem_walk (guestfs_h *g,
5878                                 const char *device);
5879
5880       Walk through the internal structures of a disk partition (eg.
5881       /dev/sda1) in order to return a list of all the files and directories
5882       stored within.
5883
5884       It is not necessary to mount the disk partition to run this command.
5885
5886       All entries in the filesystem are returned. This function can list
5887       deleted or unaccessible files. The entries are not sorted.
5888
5889       The "tsk_dirent" structure contains the following fields.
5890
5891       "tsk_inode"
5892           Filesystem reference number of the node. It might be 0 if the node
5893           has been deleted.
5894
5895       "tsk_type"
5896           Basic file type information.  See below for a detailed list of
5897           values.
5898
5899       "tsk_size"
5900           File size in bytes. It might be "-1" if the node has been deleted.
5901
5902       "tsk_name"
5903           The file path relative to its directory.
5904
5905       "tsk_flags"
5906           Bitfield containing extra information regarding the entry.  It
5907           contains the logical OR of the following values:
5908
5909           0x0001
5910               If set to 1, the file is allocated and visible within the
5911               filesystem.  Otherwise, the file has been deleted.  Under
5912               certain circumstances, the function "download_inode" can be
5913               used to recover deleted files.
5914
5915           0x0002
5916               Filesystem such as NTFS and Ext2 or greater, separate the file
5917               name from the metadata structure.  The bit is set to 1 when the
5918               file name is in an unallocated state and the metadata structure
5919               is in an allocated one.  This generally implies the metadata
5920               has been reallocated to a new file.  Therefore, information
5921               such as file type, file size, timestamps, number of links and
5922               symlink target might not correspond with the ones of the
5923               original deleted entry.
5924
5925           0x0004
5926               The bit is set to 1 when the file is compressed using
5927               filesystem native compression support (NTFS). The API is not
5928               able to detect application level compression.
5929
5930       "tsk_atime_sec"
5931       "tsk_atime_nsec"
5932       "tsk_mtime_sec"
5933       "tsk_mtime_nsec"
5934       "tsk_ctime_sec"
5935       "tsk_ctime_nsec"
5936       "tsk_crtime_sec"
5937       "tsk_crtime_nsec"
5938           Respectively, access, modification, last status change and creation
5939           time in Unix format in seconds and nanoseconds.
5940
5941       "tsk_nlink"
5942           Number of file names pointing to this entry.
5943
5944       "tsk_link"
5945           If the entry is a symbolic link, this field will contain the path
5946           to the target file.
5947
5948       The "tsk_type" field will contain one of the following characters:
5949
5950       'b' Block special
5951
5952       'c' Char special
5953
5954       'd' Directory
5955
5956       'f' FIFO (named pipe)
5957
5958       'l' Symbolic link
5959
5960       'r' Regular file
5961
5962       's' Socket
5963
5964       'h' Shadow inode (Solaris)
5965
5966       'w' Whiteout inode (BSD)
5967
5968       'u' Unknown file type
5969
5970       This function returns a "struct guestfs_tsk_dirent_list *", or NULL if
5971       there was an error.  The caller must call
5972       "guestfs_free_tsk_dirent_list" after use.
5973
5974       This long-running command can generate progress notification messages
5975       so that the caller can display a progress bar or indicator.  To receive
5976       these messages, the caller must register a progress event callback.
5977       See "GUESTFS_EVENT_PROGRESS".
5978
5979       This function depends on the feature "libtsk".  See also
5980       "guestfs_feature_available".
5981
5982       (Added in 1.33.39)
5983
5984   guestfs_fill
5985        int
5986        guestfs_fill (guestfs_h *g,
5987                      int c,
5988                      int len,
5989                      const char *path);
5990
5991       This command creates a new file called "path".  The initial content of
5992       the file is "len" octets of "c", where "c" must be a number in the
5993       range "[0..255]".
5994
5995       To fill a file with zero bytes (sparsely), it is much more efficient to
5996       use "guestfs_truncate_size".  To create a file with a pattern of
5997       repeating bytes use "guestfs_fill_pattern".
5998
5999       This function returns 0 on success or -1 on error.
6000
6001       This long-running command can generate progress notification messages
6002       so that the caller can display a progress bar or indicator.  To receive
6003       these messages, the caller must register a progress event callback.
6004       See "GUESTFS_EVENT_PROGRESS".
6005
6006       (Added in 1.0.79)
6007
6008   guestfs_fill_dir
6009        int
6010        guestfs_fill_dir (guestfs_h *g,
6011                          const char *dir,
6012                          int nr);
6013
6014       This function, useful for testing filesystems, creates "nr" empty files
6015       in the directory "dir" with names 00000000 through "nr-1" (ie. each
6016       file name is 8 digits long padded with zeroes).
6017
6018       This function returns 0 on success or -1 on error.
6019
6020       (Added in 1.19.32)
6021
6022   guestfs_fill_pattern
6023        int
6024        guestfs_fill_pattern (guestfs_h *g,
6025                              const char *pattern,
6026                              int len,
6027                              const char *path);
6028
6029       This function is like "guestfs_fill" except that it creates a new file
6030       of length "len" containing the repeating pattern of bytes in "pattern".
6031       The pattern is truncated if necessary to ensure the length of the file
6032       is exactly "len" bytes.
6033
6034       This function returns 0 on success or -1 on error.
6035
6036       This long-running command can generate progress notification messages
6037       so that the caller can display a progress bar or indicator.  To receive
6038       these messages, the caller must register a progress event callback.
6039       See "GUESTFS_EVENT_PROGRESS".
6040
6041       (Added in 1.3.12)
6042
6043   guestfs_find
6044        char **
6045        guestfs_find (guestfs_h *g,
6046                      const char *directory);
6047
6048       This command lists out all files and directories, recursively, starting
6049       at directory.  It is essentially equivalent to running the shell
6050       command "find directory -print" but some post-processing happens on the
6051       output, described below.
6052
6053       This returns a list of strings without any prefix.  Thus if the
6054       directory structure was:
6055
6056        /tmp/a
6057        /tmp/b
6058        /tmp/c/d
6059
6060       then the returned list from "guestfs_find" /tmp would be 4 elements:
6061
6062        a
6063        b
6064        c
6065        c/d
6066
6067       If directory is not a directory, then this command returns an error.
6068
6069       The returned list is sorted.
6070
6071       This function returns a NULL-terminated array of strings (like
6072       environ(3)), or NULL if there was an error.  The caller must free the
6073       strings and the array after use.
6074
6075       (Added in 1.0.27)
6076
6077   guestfs_find0
6078        int
6079        guestfs_find0 (guestfs_h *g,
6080                       const char *directory,
6081                       const char *files);
6082
6083       This command lists out all files and directories, recursively, starting
6084       at directory, placing the resulting list in the external file called
6085       files.
6086
6087       This command works the same way as "guestfs_find" with the following
6088       exceptions:
6089
6090       ·   The resulting list is written to an external file.
6091
6092       ·   Items (filenames) in the result are separated by "\0" characters.
6093           See find(1) option -print0.
6094
6095       ·   The result list is not sorted.
6096
6097       This function returns 0 on success or -1 on error.
6098
6099       (Added in 1.0.74)
6100
6101   guestfs_find_inode
6102        struct guestfs_tsk_dirent_list *
6103        guestfs_find_inode (guestfs_h *g,
6104                            const char *device,
6105                            int64_t inode);
6106
6107       Searches all the entries associated with the given inode.
6108
6109       For each entry, a "tsk_dirent" structure is returned.  See
6110       "filesystem_walk" for more information about "tsk_dirent" structures.
6111
6112       This function returns a "struct guestfs_tsk_dirent_list *", or NULL if
6113       there was an error.  The caller must call
6114       "guestfs_free_tsk_dirent_list" after use.
6115
6116       This long-running command can generate progress notification messages
6117       so that the caller can display a progress bar or indicator.  To receive
6118       these messages, the caller must register a progress event callback.
6119       See "GUESTFS_EVENT_PROGRESS".
6120
6121       This function depends on the feature "libtsk".  See also
6122       "guestfs_feature_available".
6123
6124       (Added in 1.35.6)
6125
6126   guestfs_findfs_label
6127        char *
6128        guestfs_findfs_label (guestfs_h *g,
6129                              const char *label);
6130
6131       This command searches the filesystems and returns the one which has the
6132       given label.  An error is returned if no such filesystem can be found.
6133
6134       To find the label of a filesystem, use "guestfs_vfs_label".
6135
6136       This function returns a string, or NULL on error.  The caller must free
6137       the returned string after use.
6138
6139       (Added in 1.5.3)
6140
6141   guestfs_findfs_uuid
6142        char *
6143        guestfs_findfs_uuid (guestfs_h *g,
6144                             const char *uuid);
6145
6146       This command searches the filesystems and returns the one which has the
6147       given UUID.  An error is returned if no such filesystem can be found.
6148
6149       To find the UUID of a filesystem, use "guestfs_vfs_uuid".
6150
6151       This function returns a string, or NULL on error.  The caller must free
6152       the returned string after use.
6153
6154       (Added in 1.5.3)
6155
6156   guestfs_fsck
6157        int
6158        guestfs_fsck (guestfs_h *g,
6159                      const char *fstype,
6160                      const char *device);
6161
6162       This runs the filesystem checker (fsck) on "device" which should have
6163       filesystem type "fstype".
6164
6165       The returned integer is the status.  See fsck(8) for the list of status
6166       codes from "fsck".
6167
6168       Notes:
6169
6170       ·   Multiple status codes can be summed together.
6171
6172       ·   A non-zero return code can mean "success", for example if errors
6173           have been corrected on the filesystem.
6174
6175       ·   Checking or repairing NTFS volumes is not supported (by linux-
6176           ntfs).
6177
6178       This command is entirely equivalent to running "fsck -a -t fstype
6179       device".
6180
6181       On error this function returns -1.
6182
6183       (Added in 1.0.16)
6184
6185   guestfs_fstrim
6186        int
6187        guestfs_fstrim (guestfs_h *g,
6188                        const char *mountpoint,
6189                        ...);
6190
6191       You may supply a list of optional arguments to this call.  Use zero or
6192       more of the following pairs of parameters, and terminate the list with
6193       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
6194
6195        GUESTFS_FSTRIM_OFFSET, int64_t offset,
6196        GUESTFS_FSTRIM_LENGTH, int64_t length,
6197        GUESTFS_FSTRIM_MINIMUMFREEEXTENT, int64_t minimumfreeextent,
6198
6199       Trim the free space in the filesystem mounted on "mountpoint".  The
6200       filesystem must be mounted read-write.
6201
6202       The filesystem contents are not affected, but any free space in the
6203       filesystem is "trimmed", that is, given back to the host device, thus
6204       making disk images more sparse, allowing unused space in qcow2 files to
6205       be reused, etc.
6206
6207       This operation requires support in libguestfs, the mounted filesystem,
6208       the host filesystem, qemu and the host kernel.  If this support isn't
6209       present it may give an error or even appear to run but do nothing.
6210
6211       In the case where the kernel vfs driver does not support trimming, this
6212       call will fail with errno set to "ENOTSUP".  Currently this happens
6213       when trying to trim FAT filesystems.
6214
6215       See also "guestfs_zero_free_space".  That is a slightly different
6216       operation that turns free space in the filesystem into zeroes.  It is
6217       valid to call "guestfs_fstrim" either instead of, or after calling
6218       "guestfs_zero_free_space".
6219
6220       This function returns 0 on success or -1 on error.
6221
6222       This function depends on the feature "fstrim".  See also
6223       "guestfs_feature_available".
6224
6225       (Added in 1.19.6)
6226
6227   guestfs_fstrim_va
6228        int
6229        guestfs_fstrim_va (guestfs_h *g,
6230                           const char *mountpoint,
6231                           va_list args);
6232
6233       This is the "va_list variant" of "guestfs_fstrim".
6234
6235       See "CALLS WITH OPTIONAL ARGUMENTS".
6236
6237   guestfs_fstrim_argv
6238        int
6239        guestfs_fstrim_argv (guestfs_h *g,
6240                             const char *mountpoint,
6241                             const struct guestfs_fstrim_argv *optargs);
6242
6243       This is the "argv variant" of "guestfs_fstrim".
6244
6245       See "CALLS WITH OPTIONAL ARGUMENTS".
6246
6247   guestfs_get_append
6248        const char *
6249        guestfs_get_append (guestfs_h *g);
6250
6251       Return the additional kernel options which are added to the libguestfs
6252       appliance kernel command line.
6253
6254       If "NULL" then no options are added.
6255
6256       This function returns a string which may be NULL.  There is no way to
6257       return an error from this function.  The string is owned by the guest
6258       handle and must not be freed.
6259
6260       (Added in 1.0.26)
6261
6262   guestfs_get_attach_method
6263        char *
6264        guestfs_get_attach_method (guestfs_h *g);
6265
6266       This function is deprecated.  In new code, use the
6267       "guestfs_get_backend" call instead.
6268
6269       Deprecated functions will not be removed from the API, but the fact
6270       that they are deprecated indicates that there are problems with correct
6271       use of these functions.
6272
6273       Return the current backend.
6274
6275       See "guestfs_set_backend" and "BACKEND".
6276
6277       This function returns a string, or NULL on error.  The caller must free
6278       the returned string after use.
6279
6280       (Added in 1.9.8)
6281
6282   guestfs_get_autosync
6283        int
6284        guestfs_get_autosync (guestfs_h *g);
6285
6286       Get the autosync flag.
6287
6288       This function returns a C truth value on success or -1 on error.
6289
6290       (Added in 0.3)
6291
6292   guestfs_get_backend
6293        char *
6294        guestfs_get_backend (guestfs_h *g);
6295
6296       Return the current backend.
6297
6298       This handle property was previously called the "attach method".
6299
6300       See "guestfs_set_backend" and "BACKEND".
6301
6302       This function returns a string, or NULL on error.  The caller must free
6303       the returned string after use.
6304
6305       (Added in 1.21.26)
6306
6307   guestfs_get_backend_setting
6308        char *
6309        guestfs_get_backend_setting (guestfs_h *g,
6310                                     const char *name);
6311
6312       Find a backend setting string which is either "name" or begins with
6313       "name=".  If "name", this returns the string "1".  If "name=", this
6314       returns the part after the equals sign (which may be an empty string).
6315
6316       If no such setting is found, this function throws an error.  The errno
6317       (see "guestfs_last_errno") will be "ESRCH" in this case.
6318
6319       See "BACKEND", "BACKEND SETTINGS".
6320
6321       This function returns a string, or NULL on error.  The caller must free
6322       the returned string after use.
6323
6324       (Added in 1.27.2)
6325
6326   guestfs_get_backend_settings
6327        char **
6328        guestfs_get_backend_settings (guestfs_h *g);
6329
6330       Return the current backend settings.
6331
6332       This call returns all backend settings strings.  If you want to find a
6333       single backend setting, see "guestfs_get_backend_setting".
6334
6335       See "BACKEND", "BACKEND SETTINGS".
6336
6337       This function returns a NULL-terminated array of strings (like
6338       environ(3)), or NULL if there was an error.  The caller must free the
6339       strings and the array after use.
6340
6341       (Added in 1.25.24)
6342
6343   guestfs_get_cachedir
6344        char *
6345        guestfs_get_cachedir (guestfs_h *g);
6346
6347       Get the directory used by the handle to store the appliance cache.
6348
6349       This function returns a string, or NULL on error.  The caller must free
6350       the returned string after use.
6351
6352       (Added in 1.19.58)
6353
6354   guestfs_get_direct
6355        int
6356        guestfs_get_direct (guestfs_h *g);
6357
6358       This function is deprecated.  In new code, use the
6359       "guestfs_internal_get_console_socket" call instead.
6360
6361       Deprecated functions will not be removed from the API, but the fact
6362       that they are deprecated indicates that there are problems with correct
6363       use of these functions.
6364
6365       Return the direct appliance mode flag.
6366
6367       This function returns a C truth value on success or -1 on error.
6368
6369       (Added in 1.0.72)
6370
6371   guestfs_get_e2attrs
6372        char *
6373        guestfs_get_e2attrs (guestfs_h *g,
6374                             const char *file);
6375
6376       This returns the file attributes associated with file.
6377
6378       The attributes are a set of bits associated with each inode which
6379       affect the behaviour of the file.  The attributes are returned as a
6380       string of letters (described below).  The string may be empty,
6381       indicating that no file attributes are set for this file.
6382
6383       These attributes are only present when the file is located on an
6384       ext2/3/4 filesystem.  Using this call on other filesystem types will
6385       result in an error.
6386
6387       The characters (file attributes) in the returned string are currently:
6388
6389       'A' When the file is accessed, its atime is not modified.
6390
6391       'a' The file is append-only.
6392
6393       'c' The file is compressed on-disk.
6394
6395       'D' (Directories only.)  Changes to this directory are written
6396           synchronously to disk.
6397
6398       'd' The file is not a candidate for backup (see dump(8)).
6399
6400       'E' The file has compression errors.
6401
6402       'e' The file is using extents.
6403
6404       'h' The file is storing its blocks in units of the filesystem blocksize
6405           instead of sectors.
6406
6407       'I' (Directories only.)  The directory is using hashed trees.
6408
6409       'i' The file is immutable.  It cannot be modified, deleted or renamed.
6410           No link can be created to this file.
6411
6412       'j' The file is data-journaled.
6413
6414       's' When the file is deleted, all its blocks will be zeroed.
6415
6416       'S' Changes to this file are written synchronously to disk.
6417
6418       'T' (Directories only.)  This is a hint to the block allocator that
6419           subdirectories contained in this directory should be spread across
6420           blocks.  If not present, the block allocator will try to group
6421           subdirectories together.
6422
6423       't' For a file, this disables tail-merging.  (Not used by upstream
6424           implementations of ext2.)
6425
6426       'u' When the file is deleted, its blocks will be saved, allowing the
6427           file to be undeleted.
6428
6429       'X' The raw contents of the compressed file may be accessed.
6430
6431       'Z' The compressed file is dirty.
6432
6433       More file attributes may be added to this list later.  Not all file
6434       attributes may be set for all kinds of files.  For detailed
6435       information, consult the chattr(1) man page.
6436
6437       See also "guestfs_set_e2attrs".
6438
6439       Don't confuse these attributes with extended attributes (see
6440       "guestfs_getxattr").
6441
6442       This function returns a string, or NULL on error.  The caller must free
6443       the returned string after use.
6444
6445       (Added in 1.17.31)
6446
6447   guestfs_get_e2generation
6448        int64_t
6449        guestfs_get_e2generation (guestfs_h *g,
6450                                  const char *file);
6451
6452       This returns the ext2 file generation of a file.  The generation (which
6453       used to be called the "version") is a number associated with an inode.
6454       This is most commonly used by NFS servers.
6455
6456       The generation is only present when the file is located on an ext2/3/4
6457       filesystem.  Using this call on other filesystem types will result in
6458       an error.
6459
6460       See "guestfs_set_e2generation".
6461
6462       On error this function returns -1.
6463
6464       (Added in 1.17.31)
6465
6466   guestfs_get_e2label
6467        char *
6468        guestfs_get_e2label (guestfs_h *g,
6469                             const char *device);
6470
6471       This function is deprecated.  In new code, use the "guestfs_vfs_label"
6472       call instead.
6473
6474       Deprecated functions will not be removed from the API, but the fact
6475       that they are deprecated indicates that there are problems with correct
6476       use of these functions.
6477
6478       This returns the ext2/3/4 filesystem label of the filesystem on
6479       "device".
6480
6481       This function returns a string, or NULL on error.  The caller must free
6482       the returned string after use.
6483
6484       (Added in 1.0.15)
6485
6486   guestfs_get_e2uuid
6487        char *
6488        guestfs_get_e2uuid (guestfs_h *g,
6489                            const char *device);
6490
6491       This function is deprecated.  In new code, use the "guestfs_vfs_uuid"
6492       call instead.
6493
6494       Deprecated functions will not be removed from the API, but the fact
6495       that they are deprecated indicates that there are problems with correct
6496       use of these functions.
6497
6498       This returns the ext2/3/4 filesystem UUID of the filesystem on
6499       "device".
6500
6501       This function returns a string, or NULL on error.  The caller must free
6502       the returned string after use.
6503
6504       (Added in 1.0.15)
6505
6506   guestfs_get_hv
6507        char *
6508        guestfs_get_hv (guestfs_h *g);
6509
6510       Return the current hypervisor binary.
6511
6512       This is always non-NULL.  If it wasn't set already, then this will
6513       return the default qemu binary name.
6514
6515       This function returns a string, or NULL on error.  The caller must free
6516       the returned string after use.
6517
6518       (Added in 1.23.17)
6519
6520   guestfs_get_identifier
6521        const char *
6522        guestfs_get_identifier (guestfs_h *g);
6523
6524       Get the handle identifier.  See "guestfs_set_identifier".
6525
6526       This function returns a string, or NULL on error.  The string is owned
6527       by the guest handle and must not be freed.
6528
6529       (Added in 1.31.14)
6530
6531   guestfs_get_libvirt_requested_credential_challenge
6532        char *
6533        guestfs_get_libvirt_requested_credential_challenge (guestfs_h *g,
6534                                                            int index);
6535
6536       Get the challenge (provided by libvirt) for the "index"'th requested
6537       credential.  If libvirt did not provide a challenge, this returns the
6538       empty string "".
6539
6540       See "LIBVIRT AUTHENTICATION" for documentation and example code.
6541
6542       This function returns a string, or NULL on error.  The caller must free
6543       the returned string after use.
6544
6545       (Added in 1.19.52)
6546
6547   guestfs_get_libvirt_requested_credential_defresult
6548        char *
6549        guestfs_get_libvirt_requested_credential_defresult (guestfs_h *g,
6550                                                            int index);
6551
6552       Get the default result (provided by libvirt) for the "index"'th
6553       requested credential.  If libvirt did not provide a default result,
6554       this returns the empty string "".
6555
6556       See "LIBVIRT AUTHENTICATION" for documentation and example code.
6557
6558       This function returns a string, or NULL on error.  The caller must free
6559       the returned string after use.
6560
6561       (Added in 1.19.52)
6562
6563   guestfs_get_libvirt_requested_credential_prompt
6564        char *
6565        guestfs_get_libvirt_requested_credential_prompt (guestfs_h *g,
6566                                                         int index);
6567
6568       Get the prompt (provided by libvirt) for the "index"'th requested
6569       credential.  If libvirt did not provide a prompt, this returns the
6570       empty string "".
6571
6572       See "LIBVIRT AUTHENTICATION" for documentation and example code.
6573
6574       This function returns a string, or NULL on error.  The caller must free
6575       the returned string after use.
6576
6577       (Added in 1.19.52)
6578
6579   guestfs_get_libvirt_requested_credentials
6580        char **
6581        guestfs_get_libvirt_requested_credentials (guestfs_h *g);
6582
6583       This should only be called during the event callback for events of type
6584       "GUESTFS_EVENT_LIBVIRT_AUTH".
6585
6586       Return the list of credentials requested by libvirt.  Possible values
6587       are a subset of the strings provided when you called
6588       "guestfs_set_libvirt_supported_credentials".
6589
6590       See "LIBVIRT AUTHENTICATION" for documentation and example code.
6591
6592       This function returns a NULL-terminated array of strings (like
6593       environ(3)), or NULL if there was an error.  The caller must free the
6594       strings and the array after use.
6595
6596       (Added in 1.19.52)
6597
6598   guestfs_get_memsize
6599        int
6600        guestfs_get_memsize (guestfs_h *g);
6601
6602       This gets the memory size in megabytes allocated to the hypervisor.
6603
6604       If "guestfs_set_memsize" was not called on this handle, and if
6605       "LIBGUESTFS_MEMSIZE" was not set, then this returns the compiled-in
6606       default value for memsize.
6607
6608       For more information on the architecture of libguestfs, see guestfs(3).
6609
6610       On error this function returns -1.
6611
6612       (Added in 1.0.55)
6613
6614   guestfs_get_network
6615        int
6616        guestfs_get_network (guestfs_h *g);
6617
6618       This returns the enable network flag.
6619
6620       This function returns a C truth value on success or -1 on error.
6621
6622       (Added in 1.5.4)
6623
6624   guestfs_get_path
6625        const char *
6626        guestfs_get_path (guestfs_h *g);
6627
6628       Return the current search path.
6629
6630       This is always non-NULL.  If it wasn't set already, then this will
6631       return the default path.
6632
6633       This function returns a string, or NULL on error.  The string is owned
6634       by the guest handle and must not be freed.
6635
6636       (Added in 0.3)
6637
6638   guestfs_get_pgroup
6639        int
6640        guestfs_get_pgroup (guestfs_h *g);
6641
6642       This returns the process group flag.
6643
6644       This function returns a C truth value on success or -1 on error.
6645
6646       (Added in 1.11.18)
6647
6648   guestfs_get_pid
6649        int
6650        guestfs_get_pid (guestfs_h *g);
6651
6652       Return the process ID of the hypervisor.  If there is no hypervisor
6653       running, then this will return an error.
6654
6655       This is an internal call used for debugging and testing.
6656
6657       On error this function returns -1.
6658
6659       (Added in 1.0.56)
6660
6661   guestfs_get_program
6662        const char *
6663        guestfs_get_program (guestfs_h *g);
6664
6665       Get the program name.  See "guestfs_set_program".
6666
6667       This function returns a string, or NULL on error.  The string is owned
6668       by the guest handle and must not be freed.
6669
6670       (Added in 1.21.29)
6671
6672   guestfs_get_qemu
6673        const char *
6674        guestfs_get_qemu (guestfs_h *g);
6675
6676       This function is deprecated.  In new code, use the "guestfs_get_hv"
6677       call instead.
6678
6679       Deprecated functions will not be removed from the API, but the fact
6680       that they are deprecated indicates that there are problems with correct
6681       use of these functions.
6682
6683       Return the current hypervisor binary (usually qemu).
6684
6685       This is always non-NULL.  If it wasn't set already, then this will
6686       return the default qemu binary name.
6687
6688       This function returns a string, or NULL on error.  The string is owned
6689       by the guest handle and must not be freed.
6690
6691       (Added in 1.0.6)
6692
6693   guestfs_get_recovery_proc
6694        int
6695        guestfs_get_recovery_proc (guestfs_h *g);
6696
6697       Return the recovery process enabled flag.
6698
6699       This function returns a C truth value on success or -1 on error.
6700
6701       (Added in 1.0.77)
6702
6703   guestfs_get_selinux
6704        int
6705        guestfs_get_selinux (guestfs_h *g);
6706
6707       This function is deprecated.  In new code, use the
6708       "guestfs_selinux_relabel" call instead.
6709
6710       Deprecated functions will not be removed from the API, but the fact
6711       that they are deprecated indicates that there are problems with correct
6712       use of these functions.
6713
6714       This returns the current setting of the selinux flag which is passed to
6715       the appliance at boot time.  See "guestfs_set_selinux".
6716
6717       For more information on the architecture of libguestfs, see guestfs(3).
6718
6719       This function returns a C truth value on success or -1 on error.
6720
6721       (Added in 1.0.67)
6722
6723   guestfs_get_smp
6724        int
6725        guestfs_get_smp (guestfs_h *g);
6726
6727       This returns the number of virtual CPUs assigned to the appliance.
6728
6729       On error this function returns -1.
6730
6731       (Added in 1.13.15)
6732
6733   guestfs_get_sockdir
6734        char *
6735        guestfs_get_sockdir (guestfs_h *g);
6736
6737       Get the directory used by the handle to store temporary socket files.
6738
6739       This is different from "guestfs_get_tmpdir", as we need shorter paths
6740       for sockets (due to the limited buffers of filenames for UNIX sockets),
6741       and "guestfs_get_tmpdir" may be too long for them.
6742
6743       The environment variable "XDG_RUNTIME_DIR" controls the default value:
6744       If "XDG_RUNTIME_DIR" is set, then that is the default.  Else /tmp is
6745       the default.
6746
6747       This function returns a string, or NULL on error.  The caller must free
6748       the returned string after use.
6749
6750       (Added in 1.33.8)
6751
6752   guestfs_get_state
6753        int
6754        guestfs_get_state (guestfs_h *g);
6755
6756       This returns the current state as an opaque integer.  This is only
6757       useful for printing debug and internal error messages.
6758
6759       For more information on states, see guestfs(3).
6760
6761       On error this function returns -1.
6762
6763       (Added in 1.0.2)
6764
6765   guestfs_get_tmpdir
6766        char *
6767        guestfs_get_tmpdir (guestfs_h *g);
6768
6769       Get the directory used by the handle to store temporary files.
6770
6771       This function returns a string, or NULL on error.  The caller must free
6772       the returned string after use.
6773
6774       (Added in 1.19.58)
6775
6776   guestfs_get_trace
6777        int
6778        guestfs_get_trace (guestfs_h *g);
6779
6780       Return the command trace flag.
6781
6782       This function returns a C truth value on success or -1 on error.
6783
6784       (Added in 1.0.69)
6785
6786   guestfs_get_umask
6787        int
6788        guestfs_get_umask (guestfs_h *g);
6789
6790       Return the current umask.  By default the umask is 022 unless it has
6791       been set by calling "guestfs_umask".
6792
6793       On error this function returns -1.
6794
6795       (Added in 1.3.4)
6796
6797   guestfs_get_verbose
6798        int
6799        guestfs_get_verbose (guestfs_h *g);
6800
6801       This returns the verbose messages flag.
6802
6803       This function returns a C truth value on success or -1 on error.
6804
6805       (Added in 0.3)
6806
6807   guestfs_getcon
6808        char *
6809        guestfs_getcon (guestfs_h *g);
6810
6811       This function is deprecated.  In new code, use the
6812       "guestfs_selinux_relabel" call instead.
6813
6814       Deprecated functions will not be removed from the API, but the fact
6815       that they are deprecated indicates that there are problems with correct
6816       use of these functions.
6817
6818       This gets the SELinux security context of the daemon.
6819
6820       See the documentation about SELINUX in guestfs(3), and "guestfs_setcon"
6821
6822       This function returns a string, or NULL on error.  The caller must free
6823       the returned string after use.
6824
6825       This function depends on the feature "selinux".  See also
6826       "guestfs_feature_available".
6827
6828       (Added in 1.0.67)
6829
6830   guestfs_getxattr
6831        char *
6832        guestfs_getxattr (guestfs_h *g,
6833                          const char *path,
6834                          const char *name,
6835                          size_t *size_r);
6836
6837       Get a single extended attribute from file "path" named "name".  This
6838       call follows symlinks.  If you want to lookup an extended attribute for
6839       the symlink itself, use "guestfs_lgetxattr".
6840
6841       Normally it is better to get all extended attributes from a file in one
6842       go by calling "guestfs_getxattrs".  However some Linux filesystem
6843       implementations are buggy and do not provide a way to list out
6844       attributes.  For these filesystems (notably ntfs-3g) you have to know
6845       the names of the extended attributes you want in advance and call this
6846       function.
6847
6848       Extended attribute values are blobs of binary data.  If there is no
6849       extended attribute named "name", this returns an error.
6850
6851       See also: "guestfs_getxattrs", "guestfs_lgetxattr", attr(5).
6852
6853       This function returns a buffer, or NULL on error.  The size of the
6854       returned buffer is written to *size_r.  The caller must free the
6855       returned buffer after use.
6856
6857       This function depends on the feature "linuxxattrs".  See also
6858       "guestfs_feature_available".
6859
6860       (Added in 1.7.24)
6861
6862   guestfs_getxattrs
6863        struct guestfs_xattr_list *
6864        guestfs_getxattrs (guestfs_h *g,
6865                           const char *path);
6866
6867       This call lists the extended attributes of the file or directory
6868       "path".
6869
6870       At the system call level, this is a combination of the listxattr(2) and
6871       getxattr(2) calls.
6872
6873       See also: "guestfs_lgetxattrs", attr(5).
6874
6875       This function returns a "struct guestfs_xattr_list *", or NULL if there
6876       was an error.  The caller must call "guestfs_free_xattr_list" after
6877       use.
6878
6879       This function depends on the feature "linuxxattrs".  See also
6880       "guestfs_feature_available".
6881
6882       (Added in 1.0.59)
6883
6884   guestfs_glob_expand
6885        char **
6886        guestfs_glob_expand (guestfs_h *g,
6887                             const char *pattern);
6888
6889       This function is provided for backwards compatibility with earlier
6890       versions of libguestfs.  It simply calls "guestfs_glob_expand_opts"
6891       with no optional arguments.
6892
6893       (Added in 1.0.50)
6894
6895   guestfs_glob_expand_opts
6896        char **
6897        guestfs_glob_expand_opts (guestfs_h *g,
6898                                  const char *pattern,
6899                                  ...);
6900
6901       You may supply a list of optional arguments to this call.  Use zero or
6902       more of the following pairs of parameters, and terminate the list with
6903       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
6904
6905        GUESTFS_GLOB_EXPAND_OPTS_DIRECTORYSLASH, int directoryslash,
6906
6907       This command searches for all the pathnames matching "pattern"
6908       according to the wildcard expansion rules used by the shell.
6909
6910       If no paths match, then this returns an empty list (note: not an
6911       error).
6912
6913       It is just a wrapper around the C glob(3) function with flags
6914       "GLOB_MARK|GLOB_BRACE".  See that manual page for more details.
6915
6916       "directoryslash" controls whether use the "GLOB_MARK" flag for glob(3),
6917       and it defaults to true.  It can be explicitly set as off to return no
6918       trailing slashes in filenames of directories.
6919
6920       Notice that there is no equivalent command for expanding a device name
6921       (eg. /dev/sd*).  Use "guestfs_list_devices", "guestfs_list_partitions"
6922       etc functions instead.
6923
6924       This function returns a NULL-terminated array of strings (like
6925       environ(3)), or NULL if there was an error.  The caller must free the
6926       strings and the array after use.
6927
6928       (Added in 1.0.50)
6929
6930   guestfs_glob_expand_opts_va
6931        char **
6932        guestfs_glob_expand_opts_va (guestfs_h *g,
6933                                     const char *pattern,
6934                                     va_list args);
6935
6936       This is the "va_list variant" of "guestfs_glob_expand_opts".
6937
6938       See "CALLS WITH OPTIONAL ARGUMENTS".
6939
6940   guestfs_glob_expand_opts_argv
6941        char **
6942        guestfs_glob_expand_opts_argv (guestfs_h *g,
6943                                       const char *pattern,
6944                                       const struct guestfs_glob_expand_opts_argv *optargs);
6945
6946       This is the "argv variant" of "guestfs_glob_expand_opts".
6947
6948       See "CALLS WITH OPTIONAL ARGUMENTS".
6949
6950   guestfs_grep
6951        char **
6952        guestfs_grep (guestfs_h *g,
6953                      const char *regex,
6954                      const char *path);
6955
6956       This function is provided for backwards compatibility with earlier
6957       versions of libguestfs.  It simply calls "guestfs_grep_opts" with no
6958       optional arguments.
6959
6960       (Added in 1.0.66)
6961
6962   guestfs_grep_opts
6963        char **
6964        guestfs_grep_opts (guestfs_h *g,
6965                           const char *regex,
6966                           const char *path,
6967                           ...);
6968
6969       You may supply a list of optional arguments to this call.  Use zero or
6970       more of the following pairs of parameters, and terminate the list with
6971       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
6972
6973        GUESTFS_GREP_OPTS_EXTENDED, int extended,
6974        GUESTFS_GREP_OPTS_FIXED, int fixed,
6975        GUESTFS_GREP_OPTS_INSENSITIVE, int insensitive,
6976        GUESTFS_GREP_OPTS_COMPRESSED, int compressed,
6977
6978       This calls the external grep(1) program and returns the matching lines.
6979
6980       The optional flags are:
6981
6982       "extended"
6983           Use extended regular expressions.  This is the same as using the -E
6984           flag.
6985
6986       "fixed"
6987           Match fixed (don't use regular expressions).  This is the same as
6988           using the -F flag.
6989
6990       "insensitive"
6991           Match case-insensitive.  This is the same as using the -i flag.
6992
6993       "compressed"
6994           Use zgrep(1) instead of grep(1).  This allows the input to be
6995           compress- or gzip-compressed.
6996
6997       This function returns a NULL-terminated array of strings (like
6998       environ(3)), or NULL if there was an error.  The caller must free the
6999       strings and the array after use.
7000
7001       Because of the message protocol, there is a transfer limit of somewhere
7002       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7003
7004       (Added in 1.0.66)
7005
7006   guestfs_grep_opts_va
7007        char **
7008        guestfs_grep_opts_va (guestfs_h *g,
7009                              const char *regex,
7010                              const char *path,
7011                              va_list args);
7012
7013       This is the "va_list variant" of "guestfs_grep_opts".
7014
7015       See "CALLS WITH OPTIONAL ARGUMENTS".
7016
7017   guestfs_grep_opts_argv
7018        char **
7019        guestfs_grep_opts_argv (guestfs_h *g,
7020                                const char *regex,
7021                                const char *path,
7022                                const struct guestfs_grep_opts_argv *optargs);
7023
7024       This is the "argv variant" of "guestfs_grep_opts".
7025
7026       See "CALLS WITH OPTIONAL ARGUMENTS".
7027
7028   guestfs_grepi
7029        char **
7030        guestfs_grepi (guestfs_h *g,
7031                       const char *regex,
7032                       const char *path);
7033
7034       This function is deprecated.  In new code, use the "guestfs_grep" call
7035       instead.
7036
7037       Deprecated functions will not be removed from the API, but the fact
7038       that they are deprecated indicates that there are problems with correct
7039       use of these functions.
7040
7041       This calls the external "grep -i" program and returns the matching
7042       lines.
7043
7044       This function returns a NULL-terminated array of strings (like
7045       environ(3)), or NULL if there was an error.  The caller must free the
7046       strings and the array after use.
7047
7048       Because of the message protocol, there is a transfer limit of somewhere
7049       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7050
7051       (Added in 1.0.66)
7052
7053   guestfs_grub_install
7054        int
7055        guestfs_grub_install (guestfs_h *g,
7056                              const char *root,
7057                              const char *device);
7058
7059       This command installs GRUB 1 (the Grand Unified Bootloader) on
7060       "device", with the root directory being "root".
7061
7062       Notes:
7063
7064       ·   There is currently no way in the API to install grub2, which is
7065           used by most modern Linux guests.  It is possible to run the grub2
7066           command from the guest, although see the caveats in "RUNNING
7067           COMMANDS".
7068
7069       ·   This uses grub-install(8) from the host.  Unfortunately grub is not
7070           always compatible with itself, so this only works in rather narrow
7071           circumstances.  Careful testing with each guest version is
7072           advisable.
7073
7074       ·   If grub-install reports the error "No suitable drive was found in
7075           the generated device map."  it may be that you need to create a
7076           /boot/grub/device.map file first that contains the mapping between
7077           grub device names and Linux device names.  It is usually sufficient
7078           to create a file containing:
7079
7080            (hd0) /dev/vda
7081
7082           replacing /dev/vda with the name of the installation device.
7083
7084       This function returns 0 on success or -1 on error.
7085
7086       This function depends on the feature "grub".  See also
7087       "guestfs_feature_available".
7088
7089       (Added in 1.0.17)
7090
7091   guestfs_head
7092        char **
7093        guestfs_head (guestfs_h *g,
7094                      const char *path);
7095
7096       This command returns up to the first 10 lines of a file as a list of
7097       strings.
7098
7099       This function returns a NULL-terminated array of strings (like
7100       environ(3)), or NULL if there was an error.  The caller must free the
7101       strings and the array after use.
7102
7103       Because of the message protocol, there is a transfer limit of somewhere
7104       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7105
7106       (Added in 1.0.54)
7107
7108   guestfs_head_n
7109        char **
7110        guestfs_head_n (guestfs_h *g,
7111                        int nrlines,
7112                        const char *path);
7113
7114       If the parameter "nrlines" is a positive number, this returns the first
7115       "nrlines" lines of the file "path".
7116
7117       If the parameter "nrlines" is a negative number, this returns lines
7118       from the file "path", excluding the last "nrlines" lines.
7119
7120       If the parameter "nrlines" is zero, this returns an empty list.
7121
7122       This function returns a NULL-terminated array of strings (like
7123       environ(3)), or NULL if there was an error.  The caller must free the
7124       strings and the array after use.
7125
7126       Because of the message protocol, there is a transfer limit of somewhere
7127       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7128
7129       (Added in 1.0.54)
7130
7131   guestfs_hexdump
7132        char *
7133        guestfs_hexdump (guestfs_h *g,
7134                         const char *path);
7135
7136       This runs "hexdump -C" on the given "path".  The result is the human-
7137       readable, canonical hex dump of the file.
7138
7139       This function returns a string, or NULL on error.  The caller must free
7140       the returned string after use.
7141
7142       Because of the message protocol, there is a transfer limit of somewhere
7143       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7144
7145       (Added in 1.0.22)
7146
7147   guestfs_hivex_close
7148        int
7149        guestfs_hivex_close (guestfs_h *g);
7150
7151       Close the current hivex handle.
7152
7153       This is a wrapper around the hivex(3) call of the same name.
7154
7155       This function returns 0 on success or -1 on error.
7156
7157       This function depends on the feature "hivex".  See also
7158       "guestfs_feature_available".
7159
7160       (Added in 1.19.35)
7161
7162   guestfs_hivex_commit
7163        int
7164        guestfs_hivex_commit (guestfs_h *g,
7165                              const char *filename);
7166
7167       Commit (write) changes to the hive.
7168
7169       If the optional filename parameter is null, then the changes are
7170       written back to the same hive that was opened.  If this is not null
7171       then they are written to the alternate filename given and the original
7172       hive is left untouched.
7173
7174       This is a wrapper around the hivex(3) call of the same name.
7175
7176       This function returns 0 on success or -1 on error.
7177
7178       This function depends on the feature "hivex".  See also
7179       "guestfs_feature_available".
7180
7181       (Added in 1.19.35)
7182
7183   guestfs_hivex_node_add_child
7184        int64_t
7185        guestfs_hivex_node_add_child (guestfs_h *g,
7186                                      int64_t parent,
7187                                      const char *name);
7188
7189       Add a child node to "parent" named "name".
7190
7191       This is a wrapper around the hivex(3) call of the same name.
7192
7193       On error this function returns -1.
7194
7195       This function depends on the feature "hivex".  See also
7196       "guestfs_feature_available".
7197
7198       (Added in 1.19.35)
7199
7200   guestfs_hivex_node_children
7201        struct guestfs_hivex_node_list *
7202        guestfs_hivex_node_children (guestfs_h *g,
7203                                     int64_t nodeh);
7204
7205       Return the list of nodes which are subkeys of "nodeh".
7206
7207       This is a wrapper around the hivex(3) call of the same name.
7208
7209       This function returns a "struct guestfs_hivex_node_list *", or NULL if
7210       there was an error.  The caller must call
7211       "guestfs_free_hivex_node_list" after use.
7212
7213       This function depends on the feature "hivex".  See also
7214       "guestfs_feature_available".
7215
7216       (Added in 1.19.35)
7217
7218   guestfs_hivex_node_delete_child
7219        int
7220        guestfs_hivex_node_delete_child (guestfs_h *g,
7221                                         int64_t nodeh);
7222
7223       Delete "nodeh", recursively if necessary.
7224
7225       This is a wrapper around the hivex(3) call of the same name.
7226
7227       This function returns 0 on success or -1 on error.
7228
7229       This function depends on the feature "hivex".  See also
7230       "guestfs_feature_available".
7231
7232       (Added in 1.19.35)
7233
7234   guestfs_hivex_node_get_child
7235        int64_t
7236        guestfs_hivex_node_get_child (guestfs_h *g,
7237                                      int64_t nodeh,
7238                                      const char *name);
7239
7240       Return the child of "nodeh" with the name "name", if it exists.  This
7241       can return 0 meaning the name was not found.
7242
7243       This is a wrapper around the hivex(3) call of the same name.
7244
7245       On error this function returns -1.
7246
7247       This function depends on the feature "hivex".  See also
7248       "guestfs_feature_available".
7249
7250       (Added in 1.19.35)
7251
7252   guestfs_hivex_node_get_value
7253        int64_t
7254        guestfs_hivex_node_get_value (guestfs_h *g,
7255                                      int64_t nodeh,
7256                                      const char *key);
7257
7258       Return the value attached to "nodeh" which has the name "key", if it
7259       exists.  This can return 0 meaning the key was not found.
7260
7261       This is a wrapper around the hivex(3) call of the same name.
7262
7263       On error this function returns -1.
7264
7265       This function depends on the feature "hivex".  See also
7266       "guestfs_feature_available".
7267
7268       (Added in 1.19.35)
7269
7270   guestfs_hivex_node_name
7271        char *
7272        guestfs_hivex_node_name (guestfs_h *g,
7273                                 int64_t nodeh);
7274
7275       Return the name of "nodeh".
7276
7277       This is a wrapper around the hivex(3) call of the same name.
7278
7279       This function returns a string, or NULL on error.  The caller must free
7280       the returned string after use.
7281
7282       This function depends on the feature "hivex".  See also
7283       "guestfs_feature_available".
7284
7285       (Added in 1.19.35)
7286
7287   guestfs_hivex_node_parent
7288        int64_t
7289        guestfs_hivex_node_parent (guestfs_h *g,
7290                                   int64_t nodeh);
7291
7292       Return the parent node of "nodeh".
7293
7294       This is a wrapper around the hivex(3) call of the same name.
7295
7296       On error this function returns -1.
7297
7298       This function depends on the feature "hivex".  See also
7299       "guestfs_feature_available".
7300
7301       (Added in 1.19.35)
7302
7303   guestfs_hivex_node_set_value
7304        int
7305        guestfs_hivex_node_set_value (guestfs_h *g,
7306                                      int64_t nodeh,
7307                                      const char *key,
7308                                      int64_t t,
7309                                      const char *val,
7310                                      size_t val_size);
7311
7312       Set or replace a single value under the node "nodeh".  The "key" is the
7313       name, "t" is the type, and "val" is the data.
7314
7315       This is a wrapper around the hivex(3) call of the same name.
7316
7317       This function returns 0 on success or -1 on error.
7318
7319       This function depends on the feature "hivex".  See also
7320       "guestfs_feature_available".
7321
7322       (Added in 1.19.35)
7323
7324   guestfs_hivex_node_values
7325        struct guestfs_hivex_value_list *
7326        guestfs_hivex_node_values (guestfs_h *g,
7327                                   int64_t nodeh);
7328
7329       Return the array of (key, datatype, data) tuples attached to "nodeh".
7330
7331       This is a wrapper around the hivex(3) call of the same name.
7332
7333       This function returns a "struct guestfs_hivex_value_list *", or NULL if
7334       there was an error.  The caller must call
7335       "guestfs_free_hivex_value_list" after use.
7336
7337       This function depends on the feature "hivex".  See also
7338       "guestfs_feature_available".
7339
7340       (Added in 1.19.35)
7341
7342   guestfs_hivex_open
7343        int
7344        guestfs_hivex_open (guestfs_h *g,
7345                            const char *filename,
7346                            ...);
7347
7348       You may supply a list of optional arguments to this call.  Use zero or
7349       more of the following pairs of parameters, and terminate the list with
7350       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
7351
7352        GUESTFS_HIVEX_OPEN_VERBOSE, int verbose,
7353        GUESTFS_HIVEX_OPEN_DEBUG, int debug,
7354        GUESTFS_HIVEX_OPEN_WRITE, int write,
7355        GUESTFS_HIVEX_OPEN_UNSAFE, int unsafe,
7356
7357       Open the Windows Registry hive file named filename.  If there was any
7358       previous hivex handle associated with this guestfs session, then it is
7359       closed.
7360
7361       This is a wrapper around the hivex(3) call of the same name.
7362
7363       This function returns 0 on success or -1 on error.
7364
7365       This function depends on the feature "hivex".  See also
7366       "guestfs_feature_available".
7367
7368       (Added in 1.19.35)
7369
7370   guestfs_hivex_open_va
7371        int
7372        guestfs_hivex_open_va (guestfs_h *g,
7373                               const char *filename,
7374                               va_list args);
7375
7376       This is the "va_list variant" of "guestfs_hivex_open".
7377
7378       See "CALLS WITH OPTIONAL ARGUMENTS".
7379
7380   guestfs_hivex_open_argv
7381        int
7382        guestfs_hivex_open_argv (guestfs_h *g,
7383                                 const char *filename,
7384                                 const struct guestfs_hivex_open_argv *optargs);
7385
7386       This is the "argv variant" of "guestfs_hivex_open".
7387
7388       See "CALLS WITH OPTIONAL ARGUMENTS".
7389
7390   guestfs_hivex_root
7391        int64_t
7392        guestfs_hivex_root (guestfs_h *g);
7393
7394       Return the root node of the hive.
7395
7396       This is a wrapper around the hivex(3) call of the same name.
7397
7398       On error this function returns -1.
7399
7400       This function depends on the feature "hivex".  See also
7401       "guestfs_feature_available".
7402
7403       (Added in 1.19.35)
7404
7405   guestfs_hivex_value_key
7406        char *
7407        guestfs_hivex_value_key (guestfs_h *g,
7408                                 int64_t valueh);
7409
7410       Return the key (name) field of a (key, datatype, data) tuple.
7411
7412       This is a wrapper around the hivex(3) call of the same name.
7413
7414       This function returns a string, or NULL on error.  The caller must free
7415       the returned string after use.
7416
7417       This function depends on the feature "hivex".  See also
7418       "guestfs_feature_available".
7419
7420       (Added in 1.19.35)
7421
7422   guestfs_hivex_value_string
7423        char *
7424        guestfs_hivex_value_string (guestfs_h *g,
7425                                    int64_t valueh);
7426
7427       This calls "guestfs_hivex_value_value" (which returns the data field
7428       from a hivex value tuple).  It then assumes that the field is a
7429       UTF-16LE string and converts the result to UTF-8 (or if this is not
7430       possible, it returns an error).
7431
7432       This is useful for reading strings out of the Windows registry.
7433       However it is not foolproof because the registry is not strongly-typed
7434       and fields can contain arbitrary or unexpected data.
7435
7436       This function returns a string, or NULL on error.  The caller must free
7437       the returned string after use.
7438
7439       This function depends on the feature "hivex".  See also
7440       "guestfs_feature_available".
7441
7442       (Added in 1.37.22)
7443
7444   guestfs_hivex_value_type
7445        int64_t
7446        guestfs_hivex_value_type (guestfs_h *g,
7447                                  int64_t valueh);
7448
7449       Return the data type field from a (key, datatype, data) tuple.
7450
7451       This is a wrapper around the hivex(3) call of the same name.
7452
7453       On error this function returns -1.
7454
7455       This function depends on the feature "hivex".  See also
7456       "guestfs_feature_available".
7457
7458       (Added in 1.19.35)
7459
7460   guestfs_hivex_value_utf8
7461        char *
7462        guestfs_hivex_value_utf8 (guestfs_h *g,
7463                                  int64_t valueh);
7464
7465       This function is deprecated.  In new code, use the
7466       "guestfs_hivex_value_string" call instead.
7467
7468       Deprecated functions will not be removed from the API, but the fact
7469       that they are deprecated indicates that there are problems with correct
7470       use of these functions.
7471
7472       This calls "guestfs_hivex_value_value" (which returns the data field
7473       from a hivex value tuple).  It then assumes that the field is a
7474       UTF-16LE string and converts the result to UTF-8 (or if this is not
7475       possible, it returns an error).
7476
7477       This is useful for reading strings out of the Windows registry.
7478       However it is not foolproof because the registry is not strongly-typed
7479       and fields can contain arbitrary or unexpected data.
7480
7481       This function returns a string, or NULL on error.  The caller must free
7482       the returned string after use.
7483
7484       This function depends on the feature "hivex".  See also
7485       "guestfs_feature_available".
7486
7487       (Added in 1.19.35)
7488
7489   guestfs_hivex_value_value
7490        char *
7491        guestfs_hivex_value_value (guestfs_h *g,
7492                                   int64_t valueh,
7493                                   size_t *size_r);
7494
7495       Return the data field of a (key, datatype, data) tuple.
7496
7497       This is a wrapper around the hivex(3) call of the same name.
7498
7499       See also: "guestfs_hivex_value_utf8".
7500
7501       This function returns a buffer, or NULL on error.  The size of the
7502       returned buffer is written to *size_r.  The caller must free the
7503       returned buffer after use.
7504
7505       This function depends on the feature "hivex".  See also
7506       "guestfs_feature_available".
7507
7508       (Added in 1.19.35)
7509
7510   guestfs_initrd_cat
7511        char *
7512        guestfs_initrd_cat (guestfs_h *g,
7513                            const char *initrdpath,
7514                            const char *filename,
7515                            size_t *size_r);
7516
7517       This command unpacks the file filename from the initrd file called
7518       initrdpath.  The filename must be given without the initial /
7519       character.
7520
7521       For example, in guestfish you could use the following command to
7522       examine the boot script (usually called /init) contained in a Linux
7523       initrd or initramfs image:
7524
7525        initrd-cat /boot/initrd-<version>.img init
7526
7527       See also "guestfs_initrd_list".
7528
7529       This function returns a buffer, or NULL on error.  The size of the
7530       returned buffer is written to *size_r.  The caller must free the
7531       returned buffer after use.
7532
7533       Because of the message protocol, there is a transfer limit of somewhere
7534       between 2MB and 4MB.  See "PROTOCOL LIMITS".
7535
7536       (Added in 1.0.84)
7537
7538   guestfs_initrd_list
7539        char **
7540        guestfs_initrd_list (guestfs_h *g,
7541                             const char *path);
7542
7543       This command lists out files contained in an initrd.
7544
7545       The files are listed without any initial / character.  The files are
7546       listed in the order they appear (not necessarily alphabetical).
7547       Directory names are listed as separate items.
7548
7549       Old Linux kernels (2.4 and earlier) used a compressed ext2 filesystem
7550       as initrd.  We only support the newer initramfs format (compressed cpio
7551       files).
7552
7553       This function returns a NULL-terminated array of strings (like
7554       environ(3)), or NULL if there was an error.  The caller must free the
7555       strings and the array after use.
7556
7557       (Added in 1.0.54)
7558
7559   guestfs_inotify_add_watch
7560        int64_t
7561        guestfs_inotify_add_watch (guestfs_h *g,
7562                                   const char *path,
7563                                   int mask);
7564
7565       Watch "path" for the events listed in "mask".
7566
7567       Note that if "path" is a directory then events within that directory
7568       are watched, but this does not happen recursively (in subdirectories).
7569
7570       Note for non-C or non-Linux callers: the inotify events are defined by
7571       the Linux kernel ABI and are listed in /usr/include/sys/inotify.h.
7572
7573       On error this function returns -1.
7574
7575       This function depends on the feature "inotify".  See also
7576       "guestfs_feature_available".
7577
7578       (Added in 1.0.66)
7579
7580   guestfs_inotify_close
7581        int
7582        guestfs_inotify_close (guestfs_h *g);
7583
7584       This closes the inotify handle which was previously opened by
7585       inotify_init.  It removes all watches, throws away any pending events,
7586       and deallocates all resources.
7587
7588       This function returns 0 on success or -1 on error.
7589
7590       This function depends on the feature "inotify".  See also
7591       "guestfs_feature_available".
7592
7593       (Added in 1.0.66)
7594
7595   guestfs_inotify_files
7596        char **
7597        guestfs_inotify_files (guestfs_h *g);
7598
7599       This function is a helpful wrapper around "guestfs_inotify_read" which
7600       just returns a list of pathnames of objects that were touched.  The
7601       returned pathnames are sorted and deduplicated.
7602
7603       This function returns a NULL-terminated array of strings (like
7604       environ(3)), or NULL if there was an error.  The caller must free the
7605       strings and the array after use.
7606
7607       This function depends on the feature "inotify".  See also
7608       "guestfs_feature_available".
7609
7610       (Added in 1.0.66)
7611
7612   guestfs_inotify_init
7613        int
7614        guestfs_inotify_init (guestfs_h *g,
7615                              int maxevents);
7616
7617       This command creates a new inotify handle.  The inotify subsystem can
7618       be used to notify events which happen to objects in the guest
7619       filesystem.
7620
7621       "maxevents" is the maximum number of events which will be queued up
7622       between calls to "guestfs_inotify_read" or "guestfs_inotify_files".  If
7623       this is passed as 0, then the kernel (or previously set) default is
7624       used.  For Linux 2.6.29 the default was 16384 events.  Beyond this
7625       limit, the kernel throws away events, but records the fact that it
7626       threw them away by setting a flag "IN_Q_OVERFLOW" in the returned
7627       structure list (see "guestfs_inotify_read").
7628
7629       Before any events are generated, you have to add some watches to the
7630       internal watch list.  See: "guestfs_inotify_add_watch" and
7631       "guestfs_inotify_rm_watch".
7632
7633       Queued up events should be read periodically by calling
7634       "guestfs_inotify_read" (or "guestfs_inotify_files" which is just a
7635       helpful wrapper around "guestfs_inotify_read").  If you don't read the
7636       events out often enough then you risk the internal queue overflowing.
7637
7638       The handle should be closed after use by calling
7639       "guestfs_inotify_close".  This also removes any watches automatically.
7640
7641       See also inotify(7) for an overview of the inotify interface as exposed
7642       by the Linux kernel, which is roughly what we expose via libguestfs.
7643       Note that there is one global inotify handle per libguestfs instance.
7644
7645       This function returns 0 on success or -1 on error.
7646
7647       This function depends on the feature "inotify".  See also
7648       "guestfs_feature_available".
7649
7650       (Added in 1.0.66)
7651
7652   guestfs_inotify_read
7653        struct guestfs_inotify_event_list *
7654        guestfs_inotify_read (guestfs_h *g);
7655
7656       Return the complete queue of events that have happened since the
7657       previous read call.
7658
7659       If no events have happened, this returns an empty list.
7660
7661       Note: In order to make sure that all events have been read, you must
7662       call this function repeatedly until it returns an empty list.  The
7663       reason is that the call will read events up to the maximum appliance-
7664       to-host message size and leave remaining events in the queue.
7665
7666       This function returns a "struct guestfs_inotify_event_list *", or NULL
7667       if there was an error.  The caller must call
7668       "guestfs_free_inotify_event_list" after use.
7669
7670       This function depends on the feature "inotify".  See also
7671       "guestfs_feature_available".
7672
7673       (Added in 1.0.66)
7674
7675   guestfs_inotify_rm_watch
7676        int
7677        guestfs_inotify_rm_watch (guestfs_h *g,
7678                                  int wd);
7679
7680       Remove a previously defined inotify watch.  See
7681       "guestfs_inotify_add_watch".
7682
7683       This function returns 0 on success or -1 on error.
7684
7685       This function depends on the feature "inotify".  See also
7686       "guestfs_feature_available".
7687
7688       (Added in 1.0.66)
7689
7690   guestfs_inspect_get_arch
7691        char *
7692        guestfs_inspect_get_arch (guestfs_h *g,
7693                                  const char *root);
7694
7695       This returns the architecture of the inspected operating system.  The
7696       possible return values are listed under "guestfs_file_architecture".
7697
7698       If the architecture could not be determined, then the string "unknown"
7699       is returned.
7700
7701       Please read "INSPECTION" for more details.
7702
7703       This function returns a string, or NULL on error.  The caller must free
7704       the returned string after use.
7705
7706       (Added in 1.5.3)
7707
7708   guestfs_inspect_get_distro
7709        char *
7710        guestfs_inspect_get_distro (guestfs_h *g,
7711                                    const char *root);
7712
7713       This returns the distro (distribution) of the inspected operating
7714       system.
7715
7716       Currently defined distros are:
7717
7718       "alpinelinux"
7719           Alpine Linux.
7720
7721       "altlinux"
7722           ALT Linux.
7723
7724       "archlinux"
7725           Arch Linux.
7726
7727       "buildroot"
7728           Buildroot-derived distro, but not one we specifically recognize.
7729
7730       "centos"
7731           CentOS.
7732
7733       "cirros"
7734           Cirros.
7735
7736       "coreos"
7737           CoreOS.
7738
7739       "debian"
7740           Debian.
7741
7742       "fedora"
7743           Fedora.
7744
7745       "freebsd"
7746           FreeBSD.
7747
7748       "freedos"
7749           FreeDOS.
7750
7751       "frugalware"
7752           Frugalware.
7753
7754       "gentoo"
7755           Gentoo.
7756
7757       "kalilinux"
7758           Kali Linux.
7759
7760       "linuxmint"
7761           Linux Mint.
7762
7763       "mageia"
7764           Mageia.
7765
7766       "mandriva"
7767           Mandriva.
7768
7769       "meego"
7770           MeeGo.
7771
7772       "msdos"
7773           Microsoft DOS.
7774
7775       "neokylin"
7776           NeoKylin.
7777
7778       "netbsd"
7779           NetBSD.
7780
7781       "openbsd"
7782           OpenBSD.
7783
7784       "openmandriva"
7785           OpenMandriva Lx.
7786
7787       "opensuse"
7788           OpenSUSE.
7789
7790       "oraclelinux"
7791           Oracle Linux.
7792
7793       "pardus"
7794           Pardus.
7795
7796       "pldlinux"
7797           PLD Linux.
7798
7799       "redhat-based"
7800           Some Red Hat-derived distro.
7801
7802       "rhel"
7803           Red Hat Enterprise Linux.
7804
7805       "scientificlinux"
7806           Scientific Linux.
7807
7808       "slackware"
7809           Slackware.
7810
7811       "sles"
7812           SuSE Linux Enterprise Server or Desktop.
7813
7814       "suse-based"
7815           Some openSuSE-derived distro.
7816
7817       "ttylinux"
7818           ttylinux.
7819
7820       "ubuntu"
7821           Ubuntu.
7822
7823       "unknown"
7824           The distro could not be determined.
7825
7826       "voidlinux"
7827           Void Linux.
7828
7829       "windows"
7830           Windows does not have distributions.  This string is returned if
7831           the OS type is Windows.
7832
7833       Future versions of libguestfs may return other strings here.  The
7834       caller should be prepared to handle any string.
7835
7836       Please read "INSPECTION" for more details.
7837
7838       This function returns a string, or NULL on error.  The caller must free
7839       the returned string after use.
7840
7841       (Added in 1.5.3)
7842
7843   guestfs_inspect_get_drive_mappings
7844        char **
7845        guestfs_inspect_get_drive_mappings (guestfs_h *g,
7846                                            const char *root);
7847
7848       This call is useful for Windows which uses a primitive system of
7849       assigning drive letters (like C:\) to partitions.  This inspection API
7850       examines the Windows Registry to find out how disks/partitions are
7851       mapped to drive letters, and returns a hash table as in the example
7852       below:
7853
7854        C      =>     /dev/vda2
7855        E      =>     /dev/vdb1
7856        F      =>     /dev/vdc1
7857
7858       Note that keys are drive letters.  For Windows, the key is case
7859       insensitive and just contains the drive letter, without the customary
7860       colon separator character.
7861
7862       In future we may support other operating systems that also used drive
7863       letters, but the keys for those might not be case insensitive and might
7864       be longer than 1 character.  For example in OS-9, hard drives were
7865       named "h0", "h1" etc.
7866
7867       For Windows guests, currently only hard drive mappings are returned.
7868       Removable disks (eg. DVD-ROMs) are ignored.
7869
7870       For guests that do not use drive mappings, or if the drive mappings
7871       could not be determined, this returns an empty hash table.
7872
7873       Please read "INSPECTION" for more details.  See also
7874       "guestfs_inspect_get_mountpoints", "guestfs_inspect_get_filesystems".
7875
7876       This function returns a NULL-terminated array of strings, or NULL if
7877       there was an error.  The array of strings will always have length
7878       "2n+1", where "n" keys and values alternate, followed by the trailing
7879       NULL entry.  The caller must free the strings and the array after use.
7880
7881       (Added in 1.9.17)
7882
7883   guestfs_inspect_get_filesystems
7884        char **
7885        guestfs_inspect_get_filesystems (guestfs_h *g,
7886                                         const char *root);
7887
7888       This returns a list of all the filesystems that we think are associated
7889       with this operating system.  This includes the root filesystem, other
7890       ordinary filesystems, and non-mounted devices like swap partitions.
7891
7892       In the case of a multi-boot virtual machine, it is possible for a
7893       filesystem to be shared between operating systems.
7894
7895       Please read "INSPECTION" for more details.  See also
7896       "guestfs_inspect_get_mountpoints".
7897
7898       This function returns a NULL-terminated array of strings (like
7899       environ(3)), or NULL if there was an error.  The caller must free the
7900       strings and the array after use.
7901
7902       (Added in 1.5.3)
7903
7904   guestfs_inspect_get_format
7905        char *
7906        guestfs_inspect_get_format (guestfs_h *g,
7907                                    const char *root);
7908
7909       This function is deprecated.  There is no replacement.  Consult the API
7910       documentation in guestfs(3) for further information.
7911
7912       Deprecated functions will not be removed from the API, but the fact
7913       that they are deprecated indicates that there are problems with correct
7914       use of these functions.
7915
7916       Before libguestfs 1.38, there was some unreliable support for detecting
7917       installer CDs.  This API would return:
7918
7919       "installed"
7920           This is an installed operating system.
7921
7922       "installer"
7923           The disk image being inspected is not an installed operating
7924           system, but a bootable install disk, live CD, or similar.
7925
7926       "unknown"
7927           The format of this disk image is not known.
7928
7929       In libguestfs ≥ 1.38, this only returns "installed".  Use libosinfo
7930       directly to detect installer CDs.
7931
7932       Please read "INSPECTION" for more details.
7933
7934       This function returns a string, or NULL on error.  The caller must free
7935       the returned string after use.
7936
7937       (Added in 1.9.4)
7938
7939   guestfs_inspect_get_hostname
7940        char *
7941        guestfs_inspect_get_hostname (guestfs_h *g,
7942                                      const char *root);
7943
7944       This function returns the hostname of the operating system as found by
7945       inspection of the guest’s configuration files.
7946
7947       If the hostname could not be determined, then the string "unknown" is
7948       returned.
7949
7950       Please read "INSPECTION" for more details.
7951
7952       This function returns a string, or NULL on error.  The caller must free
7953       the returned string after use.
7954
7955       (Added in 1.7.9)
7956
7957   guestfs_inspect_get_icon
7958        char *
7959        guestfs_inspect_get_icon (guestfs_h *g,
7960                                  const char *root,
7961                                  size_t *size_r,
7962                                  ...);
7963
7964       You may supply a list of optional arguments to this call.  Use zero or
7965       more of the following pairs of parameters, and terminate the list with
7966       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
7967
7968        GUESTFS_INSPECT_GET_ICON_FAVICON, int favicon,
7969        GUESTFS_INSPECT_GET_ICON_HIGHQUALITY, int highquality,
7970
7971       This function returns an icon corresponding to the inspected operating
7972       system.  The icon is returned as a buffer containing a PNG image (re-
7973       encoded to PNG if necessary).
7974
7975       If it was not possible to get an icon this function returns a zero-
7976       length (non-NULL) buffer.  Callers must check for this case.
7977
7978       Libguestfs will start by looking for a file called /etc/favicon.png or
7979       C:\etc\favicon.png and if it has the correct format, the contents of
7980       this file will be returned.  You can disable favicons by passing the
7981       optional "favicon" boolean as false (default is true).
7982
7983       If finding the favicon fails, then we look in other places in the guest
7984       for a suitable icon.
7985
7986       If the optional "highquality" boolean is true then only high quality
7987       icons are returned, which means only icons of high resolution with an
7988       alpha channel.  The default (false) is to return any icon we can, even
7989       if it is of substandard quality.
7990
7991       Notes:
7992
7993       ·   Unlike most other inspection API calls, the guest’s disks must be
7994           mounted up before you call this, since it needs to read information
7995           from the guest filesystem during the call.
7996
7997       ·   Security: The icon data comes from the untrusted guest, and should
7998           be treated with caution.  PNG files have been known to contain
7999           exploits.  Ensure that libpng (or other relevant libraries) are
8000           fully up to date before trying to process or display the icon.
8001
8002       ·   The PNG image returned can be any size.  It might not be square.
8003           Libguestfs tries to return the largest, highest quality icon
8004           available.  The application must scale the icon to the required
8005           size.
8006
8007       ·   Extracting icons from Windows guests requires the external
8008           wrestool(1) program from the "icoutils" package, and several
8009           programs (bmptopnm(1), pnmtopng(1), pamcut(1)) from the "netpbm"
8010           package.  These must be installed separately.
8011
8012       ·   Operating system icons are usually trademarks.  Seek legal advice
8013           before using trademarks in applications.
8014
8015       This function returns a buffer, or NULL on error.  The size of the
8016       returned buffer is written to *size_r.  The caller must free the
8017       returned buffer after use.
8018
8019       (Added in 1.11.12)
8020
8021   guestfs_inspect_get_icon_va
8022        char *
8023        guestfs_inspect_get_icon_va (guestfs_h *g,
8024                                     const char *root,
8025                                     size_t *size_r,
8026                                     va_list args);
8027
8028       This is the "va_list variant" of "guestfs_inspect_get_icon".
8029
8030       See "CALLS WITH OPTIONAL ARGUMENTS".
8031
8032   guestfs_inspect_get_icon_argv
8033        char *
8034        guestfs_inspect_get_icon_argv (guestfs_h *g,
8035                                       const char *root,
8036                                       size_t *size_r,
8037                                       const struct guestfs_inspect_get_icon_argv *optargs);
8038
8039       This is the "argv variant" of "guestfs_inspect_get_icon".
8040
8041       See "CALLS WITH OPTIONAL ARGUMENTS".
8042
8043   guestfs_inspect_get_major_version
8044        int
8045        guestfs_inspect_get_major_version (guestfs_h *g,
8046                                           const char *root);
8047
8048       This returns the major version number of the inspected operating
8049       system.
8050
8051       Windows uses a consistent versioning scheme which is not reflected in
8052       the popular public names used by the operating system.  Notably the
8053       operating system known as "Windows 7" is really version 6.1 (ie. major
8054       = 6, minor = 1).  You can find out the real versions corresponding to
8055       releases of Windows by consulting Wikipedia or MSDN.
8056
8057       If the version could not be determined, then 0 is returned.
8058
8059       Please read "INSPECTION" for more details.
8060
8061       On error this function returns -1.
8062
8063       (Added in 1.5.3)
8064
8065   guestfs_inspect_get_minor_version
8066        int
8067        guestfs_inspect_get_minor_version (guestfs_h *g,
8068                                           const char *root);
8069
8070       This returns the minor version number of the inspected operating
8071       system.
8072
8073       If the version could not be determined, then 0 is returned.
8074
8075       Please read "INSPECTION" for more details.  See also
8076       "guestfs_inspect_get_major_version".
8077
8078       On error this function returns -1.
8079
8080       (Added in 1.5.3)
8081
8082   guestfs_inspect_get_mountpoints
8083        char **
8084        guestfs_inspect_get_mountpoints (guestfs_h *g,
8085                                         const char *root);
8086
8087       This returns a hash of where we think the filesystems associated with
8088       this operating system should be mounted.  Callers should note that this
8089       is at best an educated guess made by reading configuration files such
8090       as /etc/fstab.  In particular note that this may return filesystems
8091       which are non-existent or not mountable and callers should be prepared
8092       to handle or ignore failures if they try to mount them.
8093
8094       Each element in the returned hashtable has a key which is the path of
8095       the mountpoint (eg. /boot) and a value which is the filesystem that
8096       would be mounted there (eg. /dev/sda1).
8097
8098       Non-mounted devices such as swap devices are not returned in this list.
8099
8100       For operating systems like Windows which still use drive letters, this
8101       call will only return an entry for the first drive "mounted on" /.  For
8102       information about the mapping of drive letters to partitions, see
8103       "guestfs_inspect_get_drive_mappings".
8104
8105       Please read "INSPECTION" for more details.  See also
8106       "guestfs_inspect_get_filesystems".
8107
8108       This function returns a NULL-terminated array of strings, or NULL if
8109       there was an error.  The array of strings will always have length
8110       "2n+1", where "n" keys and values alternate, followed by the trailing
8111       NULL entry.  The caller must free the strings and the array after use.
8112
8113       (Added in 1.5.3)
8114
8115   guestfs_inspect_get_osinfo
8116        char *
8117        guestfs_inspect_get_osinfo (guestfs_h *g,
8118                                    const char *root);
8119
8120       This function returns a possible short ID for libosinfo corresponding
8121       to the guest.
8122
8123       Note: The returned ID is only a guess by libguestfs, and nothing
8124       ensures that it actually exists in osinfo-db.
8125
8126       If no ID could not be determined, then the string "unknown" is
8127       returned.
8128
8129       This function returns a string, or NULL on error.  The caller must free
8130       the returned string after use.
8131
8132       (Added in 1.39.1)
8133
8134   guestfs_inspect_get_package_format
8135        char *
8136        guestfs_inspect_get_package_format (guestfs_h *g,
8137                                            const char *root);
8138
8139       This function and "guestfs_inspect_get_package_management" return the
8140       package format and package management tool used by the inspected
8141       operating system.  For example for Fedora these functions would return
8142       "rpm" (package format), and "yum" or "dnf" (package management).
8143
8144       This returns the string "unknown" if we could not determine the package
8145       format or if the operating system does not have a real packaging system
8146       (eg. Windows).
8147
8148       Possible strings include: "rpm", "deb", "ebuild", "pisi", "pacman",
8149       "pkgsrc", "apk", "xbps".  Future versions of libguestfs may return
8150       other strings.
8151
8152       Please read "INSPECTION" for more details.
8153
8154       This function returns a string, or NULL on error.  The caller must free
8155       the returned string after use.
8156
8157       (Added in 1.7.5)
8158
8159   guestfs_inspect_get_package_management
8160        char *
8161        guestfs_inspect_get_package_management (guestfs_h *g,
8162                                                const char *root);
8163
8164       "guestfs_inspect_get_package_format" and this function return the
8165       package format and package management tool used by the inspected
8166       operating system.  For example for Fedora these functions would return
8167       "rpm" (package format), and "yum" or "dnf" (package management).
8168
8169       This returns the string "unknown" if we could not determine the package
8170       management tool or if the operating system does not have a real
8171       packaging system (eg. Windows).
8172
8173       Possible strings include: "yum", "dnf", "up2date", "apt" (for all
8174       Debian derivatives), "portage", "pisi", "pacman", "urpmi", "zypper",
8175       "apk", "xbps".  Future versions of libguestfs may return other strings.
8176
8177       Please read "INSPECTION" for more details.
8178
8179       This function returns a string, or NULL on error.  The caller must free
8180       the returned string after use.
8181
8182       (Added in 1.7.5)
8183
8184   guestfs_inspect_get_product_name
8185        char *
8186        guestfs_inspect_get_product_name (guestfs_h *g,
8187                                          const char *root);
8188
8189       This returns the product name of the inspected operating system.  The
8190       product name is generally some freeform string which can be displayed
8191       to the user, but should not be parsed by programs.
8192
8193       If the product name could not be determined, then the string "unknown"
8194       is returned.
8195
8196       Please read "INSPECTION" for more details.
8197
8198       This function returns a string, or NULL on error.  The caller must free
8199       the returned string after use.
8200
8201       (Added in 1.5.3)
8202
8203   guestfs_inspect_get_product_variant
8204        char *
8205        guestfs_inspect_get_product_variant (guestfs_h *g,
8206                                             const char *root);
8207
8208       This returns the product variant of the inspected operating system.
8209
8210       For Windows guests, this returns the contents of the Registry key
8211       "HKLM\Software\Microsoft\Windows NT\CurrentVersion" "InstallationType"
8212       which is usually a string such as "Client" or "Server" (other values
8213       are possible).  This can be used to distinguish consumer and enterprise
8214       versions of Windows that have the same version number (for example,
8215       Windows 7 and Windows 2008 Server are both version 6.1, but the former
8216       is "Client" and the latter is "Server").
8217
8218       For enterprise Linux guests, in future we intend this to return the
8219       product variant such as "Desktop", "Server" and so on.  But this is not
8220       implemented at present.
8221
8222       If the product variant could not be determined, then the string
8223       "unknown" is returned.
8224
8225       Please read "INSPECTION" for more details.  See also
8226       "guestfs_inspect_get_product_name",
8227       "guestfs_inspect_get_major_version".
8228
8229       This function returns a string, or NULL on error.  The caller must free
8230       the returned string after use.
8231
8232       (Added in 1.9.13)
8233
8234   guestfs_inspect_get_roots
8235        char **
8236        guestfs_inspect_get_roots (guestfs_h *g);
8237
8238       This function is a convenient way to get the list of root devices, as
8239       returned from a previous call to "guestfs_inspect_os", but without
8240       redoing the whole inspection process.
8241
8242       This returns an empty list if either no root devices were found or the
8243       caller has not called "guestfs_inspect_os".
8244
8245       Please read "INSPECTION" for more details.
8246
8247       This function returns a NULL-terminated array of strings (like
8248       environ(3)), or NULL if there was an error.  The caller must free the
8249       strings and the array after use.
8250
8251       (Added in 1.7.3)
8252
8253   guestfs_inspect_get_type
8254        char *
8255        guestfs_inspect_get_type (guestfs_h *g,
8256                                  const char *root);
8257
8258       This returns the type of the inspected operating system.  Currently
8259       defined types are:
8260
8261       "linux"
8262           Any Linux-based operating system.
8263
8264       "windows"
8265           Any Microsoft Windows operating system.
8266
8267       "freebsd"
8268           FreeBSD.
8269
8270       "netbsd"
8271           NetBSD.
8272
8273       "openbsd"
8274           OpenBSD.
8275
8276       "hurd"
8277           GNU/Hurd.
8278
8279       "dos"
8280           MS-DOS, FreeDOS and others.
8281
8282       "minix"
8283           MINIX.
8284
8285       "unknown"
8286           The operating system type could not be determined.
8287
8288       Future versions of libguestfs may return other strings here.  The
8289       caller should be prepared to handle any string.
8290
8291       Please read "INSPECTION" for more details.
8292
8293       This function returns a string, or NULL on error.  The caller must free
8294       the returned string after use.
8295
8296       (Added in 1.5.3)
8297
8298   guestfs_inspect_get_windows_current_control_set
8299        char *
8300        guestfs_inspect_get_windows_current_control_set (guestfs_h *g,
8301                                                         const char *root);
8302
8303       This returns the Windows CurrentControlSet of the inspected guest.  The
8304       CurrentControlSet is a registry key name such as "ControlSet001".
8305
8306       This call assumes that the guest is Windows and that the Registry could
8307       be examined by inspection.  If this is not the case then an error is
8308       returned.
8309
8310       Please read "INSPECTION" for more details.
8311
8312       This function returns a string, or NULL on error.  The caller must free
8313       the returned string after use.
8314
8315       (Added in 1.9.17)
8316
8317   guestfs_inspect_get_windows_software_hive
8318        char *
8319        guestfs_inspect_get_windows_software_hive (guestfs_h *g,
8320                                                   const char *root);
8321
8322       This returns the path to the hive (binary Windows Registry file)
8323       corresponding to HKLM\SOFTWARE.
8324
8325       This call assumes that the guest is Windows and that the guest has a
8326       software hive file with the right name.  If this is not the case then
8327       an error is returned.  This call does not check that the hive is a
8328       valid Windows Registry hive.
8329
8330       You can use "guestfs_hivex_open" to read or write to the hive.
8331
8332       Please read "INSPECTION" for more details.
8333
8334       This function returns a string, or NULL on error.  The caller must free
8335       the returned string after use.
8336
8337       (Added in 1.35.26)
8338
8339   guestfs_inspect_get_windows_system_hive
8340        char *
8341        guestfs_inspect_get_windows_system_hive (guestfs_h *g,
8342                                                 const char *root);
8343
8344       This returns the path to the hive (binary Windows Registry file)
8345       corresponding to HKLM\SYSTEM.
8346
8347       This call assumes that the guest is Windows and that the guest has a
8348       system hive file with the right name.  If this is not the case then an
8349       error is returned.  This call does not check that the hive is a valid
8350       Windows Registry hive.
8351
8352       You can use "guestfs_hivex_open" to read or write to the hive.
8353
8354       Please read "INSPECTION" for more details.
8355
8356       This function returns a string, or NULL on error.  The caller must free
8357       the returned string after use.
8358
8359       (Added in 1.35.26)
8360
8361   guestfs_inspect_get_windows_systemroot
8362        char *
8363        guestfs_inspect_get_windows_systemroot (guestfs_h *g,
8364                                                const char *root);
8365
8366       This returns the Windows systemroot of the inspected guest.  The
8367       systemroot is a directory path such as /WINDOWS.
8368
8369       This call assumes that the guest is Windows and that the systemroot
8370       could be determined by inspection.  If this is not the case then an
8371       error is returned.
8372
8373       Please read "INSPECTION" for more details.
8374
8375       This function returns a string, or NULL on error.  The caller must free
8376       the returned string after use.
8377
8378       (Added in 1.5.25)
8379
8380   guestfs_inspect_is_live
8381        int
8382        guestfs_inspect_is_live (guestfs_h *g,
8383                                 const char *root);
8384
8385       This function is deprecated.  There is no replacement.  Consult the API
8386       documentation in guestfs(3) for further information.
8387
8388       Deprecated functions will not be removed from the API, but the fact
8389       that they are deprecated indicates that there are problems with correct
8390       use of these functions.
8391
8392       This is deprecated and always returns "false".
8393
8394       Please read "INSPECTION" for more details.
8395
8396       This function returns a C truth value on success or -1 on error.
8397
8398       (Added in 1.9.4)
8399
8400   guestfs_inspect_is_multipart
8401        int
8402        guestfs_inspect_is_multipart (guestfs_h *g,
8403                                      const char *root);
8404
8405       This function is deprecated.  There is no replacement.  Consult the API
8406       documentation in guestfs(3) for further information.
8407
8408       Deprecated functions will not be removed from the API, but the fact
8409       that they are deprecated indicates that there are problems with correct
8410       use of these functions.
8411
8412       This is deprecated and always returns "false".
8413
8414       Please read "INSPECTION" for more details.
8415
8416       This function returns a C truth value on success or -1 on error.
8417
8418       (Added in 1.9.4)
8419
8420   guestfs_inspect_is_netinst
8421        int
8422        guestfs_inspect_is_netinst (guestfs_h *g,
8423                                    const char *root);
8424
8425       This function is deprecated.  There is no replacement.  Consult the API
8426       documentation in guestfs(3) for further information.
8427
8428       Deprecated functions will not be removed from the API, but the fact
8429       that they are deprecated indicates that there are problems with correct
8430       use of these functions.
8431
8432       This is deprecated and always returns "false".
8433
8434       Please read "INSPECTION" for more details.
8435
8436       This function returns a C truth value on success or -1 on error.
8437
8438       (Added in 1.9.4)
8439
8440   guestfs_inspect_list_applications
8441        struct guestfs_application_list *
8442        guestfs_inspect_list_applications (guestfs_h *g,
8443                                           const char *root);
8444
8445       This function is deprecated.  In new code, use the
8446       "guestfs_inspect_list_applications2" call instead.
8447
8448       Deprecated functions will not be removed from the API, but the fact
8449       that they are deprecated indicates that there are problems with correct
8450       use of these functions.
8451
8452       Return the list of applications installed in the operating system.
8453
8454       Note: This call works differently from other parts of the inspection
8455       API.  You have to call "guestfs_inspect_os", then
8456       "guestfs_inspect_get_mountpoints", then mount up the disks, before
8457       calling this.  Listing applications is a significantly more difficult
8458       operation which requires access to the full filesystem.  Also note that
8459       unlike the other "guestfs_inspect_get_*" calls which are just returning
8460       data cached in the libguestfs handle, this call actually reads parts of
8461       the mounted filesystems during the call.
8462
8463       This returns an empty list if the inspection code was not able to
8464       determine the list of applications.
8465
8466       The application structure contains the following fields:
8467
8468       "app_name"
8469           The name of the application.  For Linux guests, this is the package
8470           name.
8471
8472       "app_display_name"
8473           The display name of the application, sometimes localized to the
8474           install language of the guest operating system.
8475
8476           If unavailable this is returned as an empty string "".  Callers
8477           needing to display something can use "app_name" instead.
8478
8479       "app_epoch"
8480           For package managers which use epochs, this contains the epoch of
8481           the package (an integer).  If unavailable, this is returned as 0.
8482
8483       "app_version"
8484           The version string of the application or package.  If unavailable
8485           this is returned as an empty string "".
8486
8487       "app_release"
8488           The release string of the application or package, for package
8489           managers that use this.  If unavailable this is returned as an
8490           empty string "".
8491
8492       "app_install_path"
8493           The installation path of the application (on operating systems such
8494           as Windows which use installation paths).  This path is in the
8495           format used by the guest operating system, it is not a libguestfs
8496           path.
8497
8498           If unavailable this is returned as an empty string "".
8499
8500       "app_trans_path"
8501           The install path translated into a libguestfs path.  If unavailable
8502           this is returned as an empty string "".
8503
8504       "app_publisher"
8505           The name of the publisher of the application, for package managers
8506           that use this.  If unavailable this is returned as an empty string
8507           "".
8508
8509       "app_url"
8510           The URL (eg. upstream URL) of the application.  If unavailable this
8511           is returned as an empty string "".
8512
8513       "app_source_package"
8514           For packaging systems which support this, the name of the source
8515           package.  If unavailable this is returned as an empty string "".
8516
8517       "app_summary"
8518           A short (usually one line) description of the application or
8519           package.  If unavailable this is returned as an empty string "".
8520
8521       "app_description"
8522           A longer description of the application or package.  If unavailable
8523           this is returned as an empty string "".
8524
8525       Please read "INSPECTION" for more details.
8526
8527       This function returns a "struct guestfs_application_list *", or NULL if
8528       there was an error.  The caller must call
8529       "guestfs_free_application_list" after use.
8530
8531       (Added in 1.7.8)
8532
8533   guestfs_inspect_list_applications2
8534        struct guestfs_application2_list *
8535        guestfs_inspect_list_applications2 (guestfs_h *g,
8536                                            const char *root);
8537
8538       Return the list of applications installed in the operating system.
8539
8540       Note: This call works differently from other parts of the inspection
8541       API.  You have to call "guestfs_inspect_os", then
8542       "guestfs_inspect_get_mountpoints", then mount up the disks, before
8543       calling this.  Listing applications is a significantly more difficult
8544       operation which requires access to the full filesystem.  Also note that
8545       unlike the other "guestfs_inspect_get_*" calls which are just returning
8546       data cached in the libguestfs handle, this call actually reads parts of
8547       the mounted filesystems during the call.
8548
8549       This returns an empty list if the inspection code was not able to
8550       determine the list of applications.
8551
8552       The application structure contains the following fields:
8553
8554       "app2_name"
8555           The name of the application.  For Linux guests, this is the package
8556           name.
8557
8558       "app2_display_name"
8559           The display name of the application, sometimes localized to the
8560           install language of the guest operating system.
8561
8562           If unavailable this is returned as an empty string "".  Callers
8563           needing to display something can use "app2_name" instead.
8564
8565       "app2_epoch"
8566           For package managers which use epochs, this contains the epoch of
8567           the package (an integer).  If unavailable, this is returned as 0.
8568
8569       "app2_version"
8570           The version string of the application or package.  If unavailable
8571           this is returned as an empty string "".
8572
8573       "app2_release"
8574           The release string of the application or package, for package
8575           managers that use this.  If unavailable this is returned as an
8576           empty string "".
8577
8578       "app2_arch"
8579           The architecture string of the application or package, for package
8580           managers that use this.  If unavailable this is returned as an
8581           empty string "".
8582
8583       "app2_install_path"
8584           The installation path of the application (on operating systems such
8585           as Windows which use installation paths).  This path is in the
8586           format used by the guest operating system, it is not a libguestfs
8587           path.
8588
8589           If unavailable this is returned as an empty string "".
8590
8591       "app2_trans_path"
8592           The install path translated into a libguestfs path.  If unavailable
8593           this is returned as an empty string "".
8594
8595       "app2_publisher"
8596           The name of the publisher of the application, for package managers
8597           that use this.  If unavailable this is returned as an empty string
8598           "".
8599
8600       "app2_url"
8601           The URL (eg. upstream URL) of the application.  If unavailable this
8602           is returned as an empty string "".
8603
8604       "app2_source_package"
8605           For packaging systems which support this, the name of the source
8606           package.  If unavailable this is returned as an empty string "".
8607
8608       "app2_summary"
8609           A short (usually one line) description of the application or
8610           package.  If unavailable this is returned as an empty string "".
8611
8612       "app2_description"
8613           A longer description of the application or package.  If unavailable
8614           this is returned as an empty string "".
8615
8616       Please read "INSPECTION" for more details.
8617
8618       This function returns a "struct guestfs_application2_list *", or NULL
8619       if there was an error.  The caller must call
8620       "guestfs_free_application2_list" after use.
8621
8622       (Added in 1.19.56)
8623
8624   guestfs_inspect_os
8625        char **
8626        guestfs_inspect_os (guestfs_h *g);
8627
8628       This function uses other libguestfs functions and certain heuristics to
8629       inspect the disk(s) (usually disks belonging to a virtual machine),
8630       looking for operating systems.
8631
8632       The list returned is empty if no operating systems were found.
8633
8634       If one operating system was found, then this returns a list with a
8635       single element, which is the name of the root filesystem of this
8636       operating system.  It is also possible for this function to return a
8637       list containing more than one element, indicating a dual-boot or multi-
8638       boot virtual machine, with each element being the root filesystem of
8639       one of the operating systems.
8640
8641       You can pass the root string(s) returned to other
8642       "guestfs_inspect_get_*" functions in order to query further information
8643       about each operating system, such as the name and version.
8644
8645       This function uses other libguestfs features such as "guestfs_mount_ro"
8646       and "guestfs_umount_all" in order to mount and unmount filesystems and
8647       look at the contents.  This should be called with no disks currently
8648       mounted.  The function may also use Augeas, so any existing Augeas
8649       handle will be closed.
8650
8651       This function cannot decrypt encrypted disks.  The caller must do that
8652       first (supplying the necessary keys) if the disk is encrypted.
8653
8654       Please read "INSPECTION" for more details.
8655
8656       See also "guestfs_list_filesystems".
8657
8658       This function returns a NULL-terminated array of strings (like
8659       environ(3)), or NULL if there was an error.  The caller must free the
8660       strings and the array after use.
8661
8662       (Added in 1.5.3)
8663
8664   guestfs_is_blockdev
8665        int
8666        guestfs_is_blockdev (guestfs_h *g,
8667                             const char *path);
8668
8669       This function is provided for backwards compatibility with earlier
8670       versions of libguestfs.  It simply calls "guestfs_is_blockdev_opts"
8671       with no optional arguments.
8672
8673       (Added in 1.5.10)
8674
8675   guestfs_is_blockdev_opts
8676        int
8677        guestfs_is_blockdev_opts (guestfs_h *g,
8678                                  const char *path,
8679                                  ...);
8680
8681       You may supply a list of optional arguments to this call.  Use zero or
8682       more of the following pairs of parameters, and terminate the list with
8683       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
8684
8685        GUESTFS_IS_BLOCKDEV_OPTS_FOLLOWSYMLINKS, int followsymlinks,
8686
8687       This returns "true" if and only if there is a block device with the
8688       given "path" name.
8689
8690       If the optional flag "followsymlinks" is true, then a symlink (or chain
8691       of symlinks) that ends with a block device also causes the function to
8692       return true.
8693
8694       This call only looks at files within the guest filesystem.  Libguestfs
8695       partitions and block devices (eg. /dev/sda) cannot be used as the
8696       "path" parameter of this call.
8697
8698       See also "guestfs_stat".
8699
8700       This function returns a C truth value on success or -1 on error.
8701
8702       (Added in 1.5.10)
8703
8704   guestfs_is_blockdev_opts_va
8705        int
8706        guestfs_is_blockdev_opts_va (guestfs_h *g,
8707                                     const char *path,
8708                                     va_list args);
8709
8710       This is the "va_list variant" of "guestfs_is_blockdev_opts".
8711
8712       See "CALLS WITH OPTIONAL ARGUMENTS".
8713
8714   guestfs_is_blockdev_opts_argv
8715        int
8716        guestfs_is_blockdev_opts_argv (guestfs_h *g,
8717                                       const char *path,
8718                                       const struct guestfs_is_blockdev_opts_argv *optargs);
8719
8720       This is the "argv variant" of "guestfs_is_blockdev_opts".
8721
8722       See "CALLS WITH OPTIONAL ARGUMENTS".
8723
8724   guestfs_is_busy
8725        int
8726        guestfs_is_busy (guestfs_h *g);
8727
8728       This always returns false.  This function is deprecated with no
8729       replacement.  Do not use this function.
8730
8731       For more information on states, see guestfs(3).
8732
8733       This function returns a C truth value on success or -1 on error.
8734
8735       (Added in 1.0.2)
8736
8737   guestfs_is_chardev
8738        int
8739        guestfs_is_chardev (guestfs_h *g,
8740                            const char *path);
8741
8742       This function is provided for backwards compatibility with earlier
8743       versions of libguestfs.  It simply calls "guestfs_is_chardev_opts" with
8744       no optional arguments.
8745
8746       (Added in 1.5.10)
8747
8748   guestfs_is_chardev_opts
8749        int
8750        guestfs_is_chardev_opts (guestfs_h *g,
8751                                 const char *path,
8752                                 ...);
8753
8754       You may supply a list of optional arguments to this call.  Use zero or
8755       more of the following pairs of parameters, and terminate the list with
8756       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
8757
8758        GUESTFS_IS_CHARDEV_OPTS_FOLLOWSYMLINKS, int followsymlinks,
8759
8760       This returns "true" if and only if there is a character device with the
8761       given "path" name.
8762
8763       If the optional flag "followsymlinks" is true, then a symlink (or chain
8764       of symlinks) that ends with a chardev also causes the function to
8765       return true.
8766
8767       See also "guestfs_stat".
8768
8769       This function returns a C truth value on success or -1 on error.
8770
8771       (Added in 1.5.10)
8772
8773   guestfs_is_chardev_opts_va
8774        int
8775        guestfs_is_chardev_opts_va (guestfs_h *g,
8776                                    const char *path,
8777                                    va_list args);
8778
8779       This is the "va_list variant" of "guestfs_is_chardev_opts".
8780
8781       See "CALLS WITH OPTIONAL ARGUMENTS".
8782
8783   guestfs_is_chardev_opts_argv
8784        int
8785        guestfs_is_chardev_opts_argv (guestfs_h *g,
8786                                      const char *path,
8787                                      const struct guestfs_is_chardev_opts_argv *optargs);
8788
8789       This is the "argv variant" of "guestfs_is_chardev_opts".
8790
8791       See "CALLS WITH OPTIONAL ARGUMENTS".
8792
8793   guestfs_is_config
8794        int
8795        guestfs_is_config (guestfs_h *g);
8796
8797       This returns true iff this handle is being configured (in the "CONFIG"
8798       state).
8799
8800       For more information on states, see guestfs(3).
8801
8802       This function returns a C truth value on success or -1 on error.
8803
8804       (Added in 1.0.2)
8805
8806   guestfs_is_dir
8807        int
8808        guestfs_is_dir (guestfs_h *g,
8809                        const char *path);
8810
8811       This function is provided for backwards compatibility with earlier
8812       versions of libguestfs.  It simply calls "guestfs_is_dir_opts" with no
8813       optional arguments.
8814
8815       (Added in 0.8)
8816
8817   guestfs_is_dir_opts
8818        int
8819        guestfs_is_dir_opts (guestfs_h *g,
8820                             const char *path,
8821                             ...);
8822
8823       You may supply a list of optional arguments to this call.  Use zero or
8824       more of the following pairs of parameters, and terminate the list with
8825       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
8826
8827        GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, int followsymlinks,
8828
8829       This returns "true" if and only if there is a directory with the given
8830       "path" name.  Note that it returns false for other objects like files.
8831
8832       If the optional flag "followsymlinks" is true, then a symlink (or chain
8833       of symlinks) that ends with a directory also causes the function to
8834       return true.
8835
8836       See also "guestfs_stat".
8837
8838       This function returns a C truth value on success or -1 on error.
8839
8840       (Added in 0.8)
8841
8842   guestfs_is_dir_opts_va
8843        int
8844        guestfs_is_dir_opts_va (guestfs_h *g,
8845                                const char *path,
8846                                va_list args);
8847
8848       This is the "va_list variant" of "guestfs_is_dir_opts".
8849
8850       See "CALLS WITH OPTIONAL ARGUMENTS".
8851
8852   guestfs_is_dir_opts_argv
8853        int
8854        guestfs_is_dir_opts_argv (guestfs_h *g,
8855                                  const char *path,
8856                                  const struct guestfs_is_dir_opts_argv *optargs);
8857
8858       This is the "argv variant" of "guestfs_is_dir_opts".
8859
8860       See "CALLS WITH OPTIONAL ARGUMENTS".
8861
8862   guestfs_is_fifo
8863        int
8864        guestfs_is_fifo (guestfs_h *g,
8865                         const char *path);
8866
8867       This function is provided for backwards compatibility with earlier
8868       versions of libguestfs.  It simply calls "guestfs_is_fifo_opts" with no
8869       optional arguments.
8870
8871       (Added in 1.5.10)
8872
8873   guestfs_is_fifo_opts
8874        int
8875        guestfs_is_fifo_opts (guestfs_h *g,
8876                              const char *path,
8877                              ...);
8878
8879       You may supply a list of optional arguments to this call.  Use zero or
8880       more of the following pairs of parameters, and terminate the list with
8881       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
8882
8883        GUESTFS_IS_FIFO_OPTS_FOLLOWSYMLINKS, int followsymlinks,
8884
8885       This returns "true" if and only if there is a FIFO (named pipe) with
8886       the given "path" name.
8887
8888       If the optional flag "followsymlinks" is true, then a symlink (or chain
8889       of symlinks) that ends with a FIFO also causes the function to return
8890       true.
8891
8892       See also "guestfs_stat".
8893
8894       This function returns a C truth value on success or -1 on error.
8895
8896       (Added in 1.5.10)
8897
8898   guestfs_is_fifo_opts_va
8899        int
8900        guestfs_is_fifo_opts_va (guestfs_h *g,
8901                                 const char *path,
8902                                 va_list args);
8903
8904       This is the "va_list variant" of "guestfs_is_fifo_opts".
8905
8906       See "CALLS WITH OPTIONAL ARGUMENTS".
8907
8908   guestfs_is_fifo_opts_argv
8909        int
8910        guestfs_is_fifo_opts_argv (guestfs_h *g,
8911                                   const char *path,
8912                                   const struct guestfs_is_fifo_opts_argv *optargs);
8913
8914       This is the "argv variant" of "guestfs_is_fifo_opts".
8915
8916       See "CALLS WITH OPTIONAL ARGUMENTS".
8917
8918   guestfs_is_file
8919        int
8920        guestfs_is_file (guestfs_h *g,
8921                         const char *path);
8922
8923       This function is provided for backwards compatibility with earlier
8924       versions of libguestfs.  It simply calls "guestfs_is_file_opts" with no
8925       optional arguments.
8926
8927       (Added in 0.8)
8928
8929   guestfs_is_file_opts
8930        int
8931        guestfs_is_file_opts (guestfs_h *g,
8932                              const char *path,
8933                              ...);
8934
8935       You may supply a list of optional arguments to this call.  Use zero or
8936       more of the following pairs of parameters, and terminate the list with
8937       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
8938
8939        GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, int followsymlinks,
8940
8941       This returns "true" if and only if there is a regular file with the
8942       given "path" name.  Note that it returns false for other objects like
8943       directories.
8944
8945       If the optional flag "followsymlinks" is true, then a symlink (or chain
8946       of symlinks) that ends with a file also causes the function to return
8947       true.
8948
8949       See also "guestfs_stat".
8950
8951       This function returns a C truth value on success or -1 on error.
8952
8953       (Added in 0.8)
8954
8955   guestfs_is_file_opts_va
8956        int
8957        guestfs_is_file_opts_va (guestfs_h *g,
8958                                 const char *path,
8959                                 va_list args);
8960
8961       This is the "va_list variant" of "guestfs_is_file_opts".
8962
8963       See "CALLS WITH OPTIONAL ARGUMENTS".
8964
8965   guestfs_is_file_opts_argv
8966        int
8967        guestfs_is_file_opts_argv (guestfs_h *g,
8968                                   const char *path,
8969                                   const struct guestfs_is_file_opts_argv *optargs);
8970
8971       This is the "argv variant" of "guestfs_is_file_opts".
8972
8973       See "CALLS WITH OPTIONAL ARGUMENTS".
8974
8975   guestfs_is_launching
8976        int
8977        guestfs_is_launching (guestfs_h *g);
8978
8979       This returns true iff this handle is launching the subprocess (in the
8980       "LAUNCHING" state).
8981
8982       For more information on states, see guestfs(3).
8983
8984       This function returns a C truth value on success or -1 on error.
8985
8986       (Added in 1.0.2)
8987
8988   guestfs_is_lv
8989        int
8990        guestfs_is_lv (guestfs_h *g,
8991                       const char *mountable);
8992
8993       This command tests whether "mountable" is a logical volume, and returns
8994       true iff this is the case.
8995
8996       This function returns a C truth value on success or -1 on error.
8997
8998       (Added in 1.5.3)
8999
9000   guestfs_is_ready
9001        int
9002        guestfs_is_ready (guestfs_h *g);
9003
9004       This returns true iff this handle is ready to accept commands (in the
9005       "READY" state).
9006
9007       For more information on states, see guestfs(3).
9008
9009       This function returns a C truth value on success or -1 on error.
9010
9011       (Added in 1.0.2)
9012
9013   guestfs_is_socket
9014        int
9015        guestfs_is_socket (guestfs_h *g,
9016                           const char *path);
9017
9018       This function is provided for backwards compatibility with earlier
9019       versions of libguestfs.  It simply calls "guestfs_is_socket_opts" with
9020       no optional arguments.
9021
9022       (Added in 1.5.10)
9023
9024   guestfs_is_socket_opts
9025        int
9026        guestfs_is_socket_opts (guestfs_h *g,
9027                                const char *path,
9028                                ...);
9029
9030       You may supply a list of optional arguments to this call.  Use zero or
9031       more of the following pairs of parameters, and terminate the list with
9032       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
9033
9034        GUESTFS_IS_SOCKET_OPTS_FOLLOWSYMLINKS, int followsymlinks,
9035
9036       This returns "true" if and only if there is a Unix domain socket with
9037       the given "path" name.
9038
9039       If the optional flag "followsymlinks" is true, then a symlink (or chain
9040       of symlinks) that ends with a socket also causes the function to return
9041       true.
9042
9043       See also "guestfs_stat".
9044
9045       This function returns a C truth value on success or -1 on error.
9046
9047       (Added in 1.5.10)
9048
9049   guestfs_is_socket_opts_va
9050        int
9051        guestfs_is_socket_opts_va (guestfs_h *g,
9052                                   const char *path,
9053                                   va_list args);
9054
9055       This is the "va_list variant" of "guestfs_is_socket_opts".
9056
9057       See "CALLS WITH OPTIONAL ARGUMENTS".
9058
9059   guestfs_is_socket_opts_argv
9060        int
9061        guestfs_is_socket_opts_argv (guestfs_h *g,
9062                                     const char *path,
9063                                     const struct guestfs_is_socket_opts_argv *optargs);
9064
9065       This is the "argv variant" of "guestfs_is_socket_opts".
9066
9067       See "CALLS WITH OPTIONAL ARGUMENTS".
9068
9069   guestfs_is_symlink
9070        int
9071        guestfs_is_symlink (guestfs_h *g,
9072                            const char *path);
9073
9074       This returns "true" if and only if there is a symbolic link with the
9075       given "path" name.
9076
9077       See also "guestfs_stat".
9078
9079       This function returns a C truth value on success or -1 on error.
9080
9081       (Added in 1.5.10)
9082
9083   guestfs_is_whole_device
9084        int
9085        guestfs_is_whole_device (guestfs_h *g,
9086                                 const char *device);
9087
9088       This returns "true" if and only if "device" refers to a whole block
9089       device. That is, not a partition or a logical device.
9090
9091       This function returns a C truth value on success or -1 on error.
9092
9093       (Added in 1.21.9)
9094
9095   guestfs_is_zero
9096        int
9097        guestfs_is_zero (guestfs_h *g,
9098                         const char *path);
9099
9100       This returns true iff the file exists and the file is empty or it
9101       contains all zero bytes.
9102
9103       This function returns a C truth value on success or -1 on error.
9104
9105       (Added in 1.11.8)
9106
9107   guestfs_is_zero_device
9108        int
9109        guestfs_is_zero_device (guestfs_h *g,
9110                                const char *device);
9111
9112       This returns true iff the device exists and contains all zero bytes.
9113
9114       Note that for large devices this can take a long time to run.
9115
9116       This function returns a C truth value on success or -1 on error.
9117
9118       (Added in 1.11.8)
9119
9120   guestfs_isoinfo
9121        struct guestfs_isoinfo *
9122        guestfs_isoinfo (guestfs_h *g,
9123                         const char *isofile);
9124
9125       This is the same as "guestfs_isoinfo_device" except that it works for
9126       an ISO file located inside some other mounted filesystem.  Note that in
9127       the common case where you have added an ISO file as a libguestfs
9128       device, you would not call this.  Instead you would call
9129       "guestfs_isoinfo_device".
9130
9131       This function returns a "struct guestfs_isoinfo *", or NULL if there
9132       was an error.  The caller must call "guestfs_free_isoinfo" after use.
9133
9134       (Added in 1.17.19)
9135
9136   guestfs_isoinfo_device
9137        struct guestfs_isoinfo *
9138        guestfs_isoinfo_device (guestfs_h *g,
9139                                const char *device);
9140
9141       "device" is an ISO device.  This returns a struct of information read
9142       from the primary volume descriptor (the ISO equivalent of the
9143       superblock) of the device.
9144
9145       Usually it is more efficient to use the isoinfo(1) command with the -d
9146       option on the host to analyze ISO files, instead of going through
9147       libguestfs.
9148
9149       For information on the primary volume descriptor fields, see
9150       https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
9151
9152       This function returns a "struct guestfs_isoinfo *", or NULL if there
9153       was an error.  The caller must call "guestfs_free_isoinfo" after use.
9154
9155       (Added in 1.17.19)
9156
9157   guestfs_journal_close
9158        int
9159        guestfs_journal_close (guestfs_h *g);
9160
9161       Close the journal handle.
9162
9163       This function returns 0 on success or -1 on error.
9164
9165       This function depends on the feature "journal".  See also
9166       "guestfs_feature_available".
9167
9168       (Added in 1.23.11)
9169
9170   guestfs_journal_get
9171        struct guestfs_xattr_list *
9172        guestfs_journal_get (guestfs_h *g);
9173
9174       Read the current journal entry.  This returns all the fields in the
9175       journal as a set of "(attrname, attrval)" pairs.  The "attrname" is the
9176       field name (a string).
9177
9178       The "attrval" is the field value (a binary blob, often but not always a
9179       string).  Please note that "attrval" is a byte array, not a
9180       \0-terminated C string.
9181
9182       The length of data may be truncated to the data threshold (see:
9183       "guestfs_journal_set_data_threshold",
9184       "guestfs_journal_get_data_threshold").
9185
9186       If you set the data threshold to unlimited (0) then this call can read
9187       a journal entry of any size, ie. it is not limited by the libguestfs
9188       protocol.
9189
9190       This function returns a "struct guestfs_xattr_list *", or NULL if there
9191       was an error.  The caller must call "guestfs_free_xattr_list" after
9192       use.
9193
9194       This function depends on the feature "journal".  See also
9195       "guestfs_feature_available".
9196
9197       (Added in 1.23.11)
9198
9199   guestfs_journal_get_data_threshold
9200        int64_t
9201        guestfs_journal_get_data_threshold (guestfs_h *g);
9202
9203       Get the current data threshold for reading journal entries.  This is a
9204       hint to the journal that it may truncate data fields to this size when
9205       reading them (note also that it may not truncate them).  If this
9206       returns 0, then the threshold is unlimited.
9207
9208       See also "guestfs_journal_set_data_threshold".
9209
9210       On error this function returns -1.
9211
9212       This function depends on the feature "journal".  See also
9213       "guestfs_feature_available".
9214
9215       (Added in 1.23.11)
9216
9217   guestfs_journal_get_realtime_usec
9218        int64_t
9219        guestfs_journal_get_realtime_usec (guestfs_h *g);
9220
9221       Get the realtime (wallclock) timestamp of the current journal entry.
9222
9223       On error this function returns -1.
9224
9225       This function depends on the feature "journal".  See also
9226       "guestfs_feature_available".
9227
9228       (Added in 1.27.18)
9229
9230   guestfs_journal_next
9231        int
9232        guestfs_journal_next (guestfs_h *g);
9233
9234       Move to the next journal entry.  You have to call this at least once
9235       after opening the handle before you are able to read data.
9236
9237       The returned boolean tells you if there are any more journal records to
9238       read.  "true" means you can read the next record (eg. using
9239       "guestfs_journal_get"), and "false" means you have reached the end of
9240       the journal.
9241
9242       This function returns a C truth value on success or -1 on error.
9243
9244       This function depends on the feature "journal".  See also
9245       "guestfs_feature_available".
9246
9247       (Added in 1.23.11)
9248
9249   guestfs_journal_open
9250        int
9251        guestfs_journal_open (guestfs_h *g,
9252                              const char *directory);
9253
9254       Open the systemd journal located in directory.  Any previously opened
9255       journal handle is closed.
9256
9257       The contents of the journal can be read using "guestfs_journal_next"
9258       and "guestfs_journal_get".
9259
9260       After you have finished using the journal, you should close the handle
9261       by calling "guestfs_journal_close".
9262
9263       This function returns 0 on success or -1 on error.
9264
9265       This function depends on the feature "journal".  See also
9266       "guestfs_feature_available".
9267
9268       (Added in 1.23.11)
9269
9270   guestfs_journal_set_data_threshold
9271        int
9272        guestfs_journal_set_data_threshold (guestfs_h *g,
9273                                            int64_t threshold);
9274
9275       Set the data threshold for reading journal entries.  This is a hint to
9276       the journal that it may truncate data fields to this size when reading
9277       them (note also that it may not truncate them).  If you set this to 0,
9278       then the threshold is unlimited.
9279
9280       See also "guestfs_journal_get_data_threshold".
9281
9282       This function returns 0 on success or -1 on error.
9283
9284       This function depends on the feature "journal".  See also
9285       "guestfs_feature_available".
9286
9287       (Added in 1.23.11)
9288
9289   guestfs_journal_skip
9290        int64_t
9291        guestfs_journal_skip (guestfs_h *g,
9292                              int64_t skip);
9293
9294       Skip forwards ("skip ≥ 0") or backwards ("skip < 0") in the journal.
9295
9296       The number of entries actually skipped is returned (note "rskip ≥ 0").
9297       If this is not the same as the absolute value of the skip parameter
9298       ("|skip|") you passed in then it means you have reached the end or the
9299       start of the journal.
9300
9301       On error this function returns -1.
9302
9303       This function depends on the feature "journal".  See also
9304       "guestfs_feature_available".
9305
9306       (Added in 1.23.11)
9307
9308   guestfs_kill_subprocess
9309        int
9310        guestfs_kill_subprocess (guestfs_h *g);
9311
9312       This function is deprecated.  In new code, use the "guestfs_shutdown"
9313       call instead.
9314
9315       Deprecated functions will not be removed from the API, but the fact
9316       that they are deprecated indicates that there are problems with correct
9317       use of these functions.
9318
9319       This kills the hypervisor.
9320
9321       Do not call this.  See: "guestfs_shutdown" instead.
9322
9323       This function returns 0 on success or -1 on error.
9324
9325       (Added in 0.3)
9326
9327   guestfs_launch
9328        int
9329        guestfs_launch (guestfs_h *g);
9330
9331       You should call this after configuring the handle (eg. adding drives)
9332       but before performing any actions.
9333
9334       Do not call "guestfs_launch" twice on the same handle.  Although it
9335       will not give an error (for historical reasons), the precise behaviour
9336       when you do this is not well defined.  Handles are very cheap to
9337       create, so create a new one for each launch.
9338
9339       This function returns 0 on success or -1 on error.
9340
9341       This long-running command can generate progress notification messages
9342       so that the caller can display a progress bar or indicator.  To receive
9343       these messages, the caller must register a progress event callback.
9344       See "GUESTFS_EVENT_PROGRESS".
9345
9346       (Added in 0.3)
9347
9348   guestfs_lchown
9349        int
9350        guestfs_lchown (guestfs_h *g,
9351                        int owner,
9352                        int group,
9353                        const char *path);
9354
9355       Change the file owner to "owner" and group to "group".  This is like
9356       "guestfs_chown" but if "path" is a symlink then the link itself is
9357       changed, not the target.
9358
9359       Only numeric uid and gid are supported.  If you want to use names, you
9360       will need to locate and parse the password file yourself (Augeas
9361       support makes this relatively easy).
9362
9363       This function returns 0 on success or -1 on error.
9364
9365       (Added in 1.0.77)
9366
9367   guestfs_ldmtool_create_all
9368        int
9369        guestfs_ldmtool_create_all (guestfs_h *g);
9370
9371       This function scans all block devices looking for Windows dynamic disk
9372       volumes and partitions, and creates devices for any that were found.
9373
9374       Call "guestfs_list_ldm_volumes" and "guestfs_list_ldm_partitions" to
9375       return all devices.
9376
9377       Note that you don't normally need to call this explicitly, since it is
9378       done automatically at "guestfs_launch" time.  However you might want to
9379       call this function if you have hotplugged disks or have just created a
9380       Windows dynamic disk.
9381
9382       This function returns 0 on success or -1 on error.
9383
9384       This function depends on the feature "ldm".  See also
9385       "guestfs_feature_available".
9386
9387       (Added in 1.20.0)
9388
9389   guestfs_ldmtool_diskgroup_disks
9390        char **
9391        guestfs_ldmtool_diskgroup_disks (guestfs_h *g,
9392                                         const char *diskgroup);
9393
9394       Return the disks in a Windows dynamic disk group.  The "diskgroup"
9395       parameter should be the GUID of a disk group, one element from the list
9396       returned by "guestfs_ldmtool_scan".
9397
9398       This function returns a NULL-terminated array of strings (like
9399       environ(3)), or NULL if there was an error.  The caller must free the
9400       strings and the array after use.
9401
9402       This function depends on the feature "ldm".  See also
9403       "guestfs_feature_available".
9404
9405       (Added in 1.20.0)
9406
9407   guestfs_ldmtool_diskgroup_name
9408        char *
9409        guestfs_ldmtool_diskgroup_name (guestfs_h *g,
9410                                        const char *diskgroup);
9411
9412       Return the name of a Windows dynamic disk group.  The "diskgroup"
9413       parameter should be the GUID of a disk group, one element from the list
9414       returned by "guestfs_ldmtool_scan".
9415
9416       This function returns a string, or NULL on error.  The caller must free
9417       the returned string after use.
9418
9419       This function depends on the feature "ldm".  See also
9420       "guestfs_feature_available".
9421
9422       (Added in 1.20.0)
9423
9424   guestfs_ldmtool_diskgroup_volumes
9425        char **
9426        guestfs_ldmtool_diskgroup_volumes (guestfs_h *g,
9427                                           const char *diskgroup);
9428
9429       Return the volumes in a Windows dynamic disk group.  The "diskgroup"
9430       parameter should be the GUID of a disk group, one element from the list
9431       returned by "guestfs_ldmtool_scan".
9432
9433       This function returns a NULL-terminated array of strings (like
9434       environ(3)), or NULL if there was an error.  The caller must free the
9435       strings and the array after use.
9436
9437       This function depends on the feature "ldm".  See also
9438       "guestfs_feature_available".
9439
9440       (Added in 1.20.0)
9441
9442   guestfs_ldmtool_remove_all
9443        int
9444        guestfs_ldmtool_remove_all (guestfs_h *g);
9445
9446       This is essentially the opposite of "guestfs_ldmtool_create_all".  It
9447       removes the device mapper mappings for all Windows dynamic disk volumes
9448
9449       This function returns 0 on success or -1 on error.
9450
9451       This function depends on the feature "ldm".  See also
9452       "guestfs_feature_available".
9453
9454       (Added in 1.20.0)
9455
9456   guestfs_ldmtool_scan
9457        char **
9458        guestfs_ldmtool_scan (guestfs_h *g);
9459
9460       This function scans for Windows dynamic disks.  It returns a list of
9461       identifiers (GUIDs) for all disk groups that were found.  These
9462       identifiers can be passed to other "guestfs_ldmtool_*" functions.
9463
9464       This function scans all block devices.  To scan a subset of block
9465       devices, call "guestfs_ldmtool_scan_devices" instead.
9466
9467       This function returns a NULL-terminated array of strings (like
9468       environ(3)), or NULL if there was an error.  The caller must free the
9469       strings and the array after use.
9470
9471       This function depends on the feature "ldm".  See also
9472       "guestfs_feature_available".
9473
9474       (Added in 1.20.0)
9475
9476   guestfs_ldmtool_scan_devices
9477        char **
9478        guestfs_ldmtool_scan_devices (guestfs_h *g,
9479                                      char *const *devices);
9480
9481       This function scans for Windows dynamic disks.  It returns a list of
9482       identifiers (GUIDs) for all disk groups that were found.  These
9483       identifiers can be passed to other "guestfs_ldmtool_*" functions.
9484
9485       The parameter "devices" is a list of block devices which are scanned.
9486       If this list is empty, all block devices are scanned.
9487
9488       This function returns a NULL-terminated array of strings (like
9489       environ(3)), or NULL if there was an error.  The caller must free the
9490       strings and the array after use.
9491
9492       This function depends on the feature "ldm".  See also
9493       "guestfs_feature_available".
9494
9495       (Added in 1.20.0)
9496
9497   guestfs_ldmtool_volume_hint
9498        char *
9499        guestfs_ldmtool_volume_hint (guestfs_h *g,
9500                                     const char *diskgroup,
9501                                     const char *volume);
9502
9503       Return the hint field of the volume named "volume" in the disk group
9504       with GUID "diskgroup".  This may not be defined, in which case the
9505       empty string is returned.  The hint field is often, though not always,
9506       the name of a Windows drive, eg. "E:".
9507
9508       This function returns a string, or NULL on error.  The caller must free
9509       the returned string after use.
9510
9511       This function depends on the feature "ldm".  See also
9512       "guestfs_feature_available".
9513
9514       (Added in 1.20.0)
9515
9516   guestfs_ldmtool_volume_partitions
9517        char **
9518        guestfs_ldmtool_volume_partitions (guestfs_h *g,
9519                                           const char *diskgroup,
9520                                           const char *volume);
9521
9522       Return the list of partitions in the volume named "volume" in the disk
9523       group with GUID "diskgroup".
9524
9525       This function returns a NULL-terminated array of strings (like
9526       environ(3)), or NULL if there was an error.  The caller must free the
9527       strings and the array after use.
9528
9529       This function depends on the feature "ldm".  See also
9530       "guestfs_feature_available".
9531
9532       (Added in 1.20.0)
9533
9534   guestfs_ldmtool_volume_type
9535        char *
9536        guestfs_ldmtool_volume_type (guestfs_h *g,
9537                                     const char *diskgroup,
9538                                     const char *volume);
9539
9540       Return the type of the volume named "volume" in the disk group with
9541       GUID "diskgroup".
9542
9543       Possible volume types that can be returned here include: "simple",
9544       "spanned", "striped", "mirrored", "raid5".  Other types may also be
9545       returned.
9546
9547       This function returns a string, or NULL on error.  The caller must free
9548       the returned string after use.
9549
9550       This function depends on the feature "ldm".  See also
9551       "guestfs_feature_available".
9552
9553       (Added in 1.20.0)
9554
9555   guestfs_lgetxattr
9556        char *
9557        guestfs_lgetxattr (guestfs_h *g,
9558                           const char *path,
9559                           const char *name,
9560                           size_t *size_r);
9561
9562       Get a single extended attribute from file "path" named "name".  If
9563       "path" is a symlink, then this call returns an extended attribute from
9564       the symlink.
9565
9566       Normally it is better to get all extended attributes from a file in one
9567       go by calling "guestfs_getxattrs".  However some Linux filesystem
9568       implementations are buggy and do not provide a way to list out
9569       attributes.  For these filesystems (notably ntfs-3g) you have to know
9570       the names of the extended attributes you want in advance and call this
9571       function.
9572
9573       Extended attribute values are blobs of binary data.  If there is no
9574       extended attribute named "name", this returns an error.
9575
9576       See also: "guestfs_lgetxattrs", "guestfs_getxattr", attr(5).
9577
9578       This function returns a buffer, or NULL on error.  The size of the
9579       returned buffer is written to *size_r.  The caller must free the
9580       returned buffer after use.
9581
9582       This function depends on the feature "linuxxattrs".  See also
9583       "guestfs_feature_available".
9584
9585       (Added in 1.7.24)
9586
9587   guestfs_lgetxattrs
9588        struct guestfs_xattr_list *
9589        guestfs_lgetxattrs (guestfs_h *g,
9590                            const char *path);
9591
9592       This is the same as "guestfs_getxattrs", but if "path" is a symbolic
9593       link, then it returns the extended attributes of the link itself.
9594
9595       This function returns a "struct guestfs_xattr_list *", or NULL if there
9596       was an error.  The caller must call "guestfs_free_xattr_list" after
9597       use.
9598
9599       This function depends on the feature "linuxxattrs".  See also
9600       "guestfs_feature_available".
9601
9602       (Added in 1.0.59)
9603
9604   guestfs_list_9p
9605        char **
9606        guestfs_list_9p (guestfs_h *g);
9607
9608       List all 9p filesystems attached to the guest.  A list of mount tags is
9609       returned.
9610
9611       This function returns a NULL-terminated array of strings (like
9612       environ(3)), or NULL if there was an error.  The caller must free the
9613       strings and the array after use.
9614
9615       (Added in 1.11.12)
9616
9617   guestfs_list_devices
9618        char **
9619        guestfs_list_devices (guestfs_h *g);
9620
9621       List all the block devices.
9622
9623       The full block device names are returned, eg. /dev/sda.
9624
9625       See also "guestfs_list_filesystems".
9626
9627       This function returns a NULL-terminated array of strings (like
9628       environ(3)), or NULL if there was an error.  The caller must free the
9629       strings and the array after use.
9630
9631       (Added in 0.4)
9632
9633   guestfs_list_disk_labels
9634        char **
9635        guestfs_list_disk_labels (guestfs_h *g);
9636
9637       If you add drives using the optional "label" parameter of
9638       "guestfs_add_drive_opts", you can use this call to map between disk
9639       labels, and raw block device and partition names (like /dev/sda and
9640       /dev/sda1).
9641
9642       This returns a hashtable, where keys are the disk labels (without the
9643       /dev/disk/guestfs prefix), and the values are the full raw block device
9644       and partition names (eg. /dev/sda and /dev/sda1).
9645
9646       This function returns a NULL-terminated array of strings, or NULL if
9647       there was an error.  The array of strings will always have length
9648       "2n+1", where "n" keys and values alternate, followed by the trailing
9649       NULL entry.  The caller must free the strings and the array after use.
9650
9651       (Added in 1.19.49)
9652
9653   guestfs_list_dm_devices
9654        char **
9655        guestfs_list_dm_devices (guestfs_h *g);
9656
9657       List all device mapper devices.
9658
9659       The returned list contains /dev/mapper/* devices, eg. ones created by a
9660       previous call to "guestfs_luks_open".
9661
9662       Device mapper devices which correspond to logical volumes are not
9663       returned in this list.  Call "guestfs_lvs" if you want to list logical
9664       volumes.
9665
9666       This function returns a NULL-terminated array of strings (like
9667       environ(3)), or NULL if there was an error.  The caller must free the
9668       strings and the array after use.
9669
9670       (Added in 1.11.15)
9671
9672   guestfs_list_filesystems
9673        char **
9674        guestfs_list_filesystems (guestfs_h *g);
9675
9676       This inspection command looks for filesystems on partitions, block
9677       devices and logical volumes, returning a list of "mountables"
9678       containing filesystems and their type.
9679
9680       The return value is a hash, where the keys are the devices containing
9681       filesystems, and the values are the filesystem types.  For example:
9682
9683        "/dev/sda1" => "ntfs"
9684        "/dev/sda2" => "ext2"
9685        "/dev/vg_guest/lv_root" => "ext4"
9686        "/dev/vg_guest/lv_swap" => "swap"
9687
9688       The key is not necessarily a block device. It may also be an opaque
9689       ‘mountable’ string which can be passed to "guestfs_mount".
9690
9691       The value can have the special value "unknown", meaning the content of
9692       the device is undetermined or empty.  "swap" means a Linux swap
9693       partition.
9694
9695       In libguestfs ≤ 1.36 this command ran other libguestfs commands, which
9696       might have included "guestfs_mount" and "guestfs_umount", and therefore
9697       you had to use this soon after launch and only when nothing else was
9698       mounted.  This restriction is removed in libguestfs ≥ 1.38.
9699
9700       Not all of the filesystems returned will be mountable.  In particular,
9701       swap partitions are returned in the list.  Also this command does not
9702       check that each filesystem found is valid and mountable, and some
9703       filesystems might be mountable but require special options.
9704       Filesystems may not all belong to a single logical operating system
9705       (use "guestfs_inspect_os" to look for OSes).
9706
9707       This function returns a NULL-terminated array of strings, or NULL if
9708       there was an error.  The array of strings will always have length
9709       "2n+1", where "n" keys and values alternate, followed by the trailing
9710       NULL entry.  The caller must free the strings and the array after use.
9711
9712       (Added in 1.5.15)
9713
9714   guestfs_list_ldm_partitions
9715        char **
9716        guestfs_list_ldm_partitions (guestfs_h *g);
9717
9718       This function returns all Windows dynamic disk partitions that were
9719       found at launch time.  It returns a list of device names.
9720
9721       This function returns a NULL-terminated array of strings (like
9722       environ(3)), or NULL if there was an error.  The caller must free the
9723       strings and the array after use.
9724
9725       This function depends on the feature "ldm".  See also
9726       "guestfs_feature_available".
9727
9728       (Added in 1.20.0)
9729
9730   guestfs_list_ldm_volumes
9731        char **
9732        guestfs_list_ldm_volumes (guestfs_h *g);
9733
9734       This function returns all Windows dynamic disk volumes that were found
9735       at launch time.  It returns a list of device names.
9736
9737       This function returns a NULL-terminated array of strings (like
9738       environ(3)), or NULL if there was an error.  The caller must free the
9739       strings and the array after use.
9740
9741       This function depends on the feature "ldm".  See also
9742       "guestfs_feature_available".
9743
9744       (Added in 1.20.0)
9745
9746   guestfs_list_md_devices
9747        char **
9748        guestfs_list_md_devices (guestfs_h *g);
9749
9750       List all Linux md devices.
9751
9752       This function returns a NULL-terminated array of strings (like
9753       environ(3)), or NULL if there was an error.  The caller must free the
9754       strings and the array after use.
9755
9756       (Added in 1.15.4)
9757
9758   guestfs_list_partitions
9759        char **
9760        guestfs_list_partitions (guestfs_h *g);
9761
9762       List all the partitions detected on all block devices.
9763
9764       The full partition device names are returned, eg. /dev/sda1
9765
9766       This does not return logical volumes.  For that you will need to call
9767       "guestfs_lvs".
9768
9769       See also "guestfs_list_filesystems".
9770
9771       This function returns a NULL-terminated array of strings (like
9772       environ(3)), or NULL if there was an error.  The caller must free the
9773       strings and the array after use.
9774
9775       (Added in 0.4)
9776
9777   guestfs_ll
9778        char *
9779        guestfs_ll (guestfs_h *g,
9780                    const char *directory);
9781
9782       List the files in directory (relative to the root directory, there is
9783       no cwd) in the format of "ls -la".
9784
9785       This command is mostly useful for interactive sessions.  It is not
9786       intended that you try to parse the output string.
9787
9788       This function returns a string, or NULL on error.  The caller must free
9789       the returned string after use.
9790
9791       (Added in 0.4)
9792
9793   guestfs_llz
9794        char *
9795        guestfs_llz (guestfs_h *g,
9796                     const char *directory);
9797
9798       This function is deprecated.  In new code, use the "guestfs_lgetxattrs"
9799       call instead.
9800
9801       Deprecated functions will not be removed from the API, but the fact
9802       that they are deprecated indicates that there are problems with correct
9803       use of these functions.
9804
9805       List the files in directory in the format of "ls -laZ".
9806
9807       This command is mostly useful for interactive sessions.  It is not
9808       intended that you try to parse the output string.
9809
9810       This function returns a string, or NULL on error.  The caller must free
9811       the returned string after use.
9812
9813       (Added in 1.17.6)
9814
9815   guestfs_ln
9816        int
9817        guestfs_ln (guestfs_h *g,
9818                    const char *target,
9819                    const char *linkname);
9820
9821       This command creates a hard link.
9822
9823       This function returns 0 on success or -1 on error.
9824
9825       (Added in 1.0.66)
9826
9827   guestfs_ln_f
9828        int
9829        guestfs_ln_f (guestfs_h *g,
9830                      const char *target,
9831                      const char *linkname);
9832
9833       This command creates a hard link, removing the link "linkname" if it
9834       exists already.
9835
9836       This function returns 0 on success or -1 on error.
9837
9838       (Added in 1.0.66)
9839
9840   guestfs_ln_s
9841        int
9842        guestfs_ln_s (guestfs_h *g,
9843                      const char *target,
9844                      const char *linkname);
9845
9846       This command creates a symbolic link using the "ln -s" command.
9847
9848       This function returns 0 on success or -1 on error.
9849
9850       (Added in 1.0.66)
9851
9852   guestfs_ln_sf
9853        int
9854        guestfs_ln_sf (guestfs_h *g,
9855                       const char *target,
9856                       const char *linkname);
9857
9858       This command creates a symbolic link using the "ln -sf" command, The -f
9859       option removes the link ("linkname") if it exists already.
9860
9861       This function returns 0 on success or -1 on error.
9862
9863       (Added in 1.0.66)
9864
9865   guestfs_lremovexattr
9866        int
9867        guestfs_lremovexattr (guestfs_h *g,
9868                              const char *xattr,
9869                              const char *path);
9870
9871       This is the same as "guestfs_removexattr", but if "path" is a symbolic
9872       link, then it removes an extended attribute of the link itself.
9873
9874       This function returns 0 on success or -1 on error.
9875
9876       This function depends on the feature "linuxxattrs".  See also
9877       "guestfs_feature_available".
9878
9879       (Added in 1.0.59)
9880
9881   guestfs_ls
9882        char **
9883        guestfs_ls (guestfs_h *g,
9884                    const char *directory);
9885
9886       List the files in directory (relative to the root directory, there is
9887       no cwd).  The "." and ".." entries are not returned, but hidden files
9888       are shown.
9889
9890       This function returns a NULL-terminated array of strings (like
9891       environ(3)), or NULL if there was an error.  The caller must free the
9892       strings and the array after use.
9893
9894       (Added in 0.4)
9895
9896   guestfs_ls0
9897        int
9898        guestfs_ls0 (guestfs_h *g,
9899                     const char *dir,
9900                     const char *filenames);
9901
9902       This specialized command is used to get a listing of the filenames in
9903       the directory "dir".  The list of filenames is written to the local
9904       file filenames (on the host).
9905
9906       In the output file, the filenames are separated by "\0" characters.
9907
9908       "." and ".." are not returned.  The filenames are not sorted.
9909
9910       This function returns 0 on success or -1 on error.
9911
9912       (Added in 1.19.32)
9913
9914   guestfs_lsetxattr
9915        int
9916        guestfs_lsetxattr (guestfs_h *g,
9917                           const char *xattr,
9918                           const char *val,
9919                           int vallen,
9920                           const char *path);
9921
9922       This is the same as "guestfs_setxattr", but if "path" is a symbolic
9923       link, then it sets an extended attribute of the link itself.
9924
9925       This function returns 0 on success or -1 on error.
9926
9927       This function depends on the feature "linuxxattrs".  See also
9928       "guestfs_feature_available".
9929
9930       (Added in 1.0.59)
9931
9932   guestfs_lstat
9933        struct guestfs_stat *
9934        guestfs_lstat (guestfs_h *g,
9935                       const char *path);
9936
9937       This function is deprecated.  In new code, use the "guestfs_lstatns"
9938       call instead.
9939
9940       Deprecated functions will not be removed from the API, but the fact
9941       that they are deprecated indicates that there are problems with correct
9942       use of these functions.
9943
9944       Returns file information for the given "path".
9945
9946       This is the same as "guestfs_stat" except that if "path" is a symbolic
9947       link, then the link is stat-ed, not the file it refers to.
9948
9949       This is the same as the lstat(2) system call.
9950
9951       This function returns a "struct guestfs_stat *", or NULL if there was
9952       an error.  The caller must call "guestfs_free_stat" after use.
9953
9954       (Added in 1.9.2)
9955
9956   guestfs_lstatlist
9957        struct guestfs_stat_list *
9958        guestfs_lstatlist (guestfs_h *g,
9959                           const char *path,
9960                           char *const *names);
9961
9962       This function is deprecated.  In new code, use the
9963       "guestfs_lstatnslist" call instead.
9964
9965       Deprecated functions will not be removed from the API, but the fact
9966       that they are deprecated indicates that there are problems with correct
9967       use of these functions.
9968
9969       This call allows you to perform the "guestfs_lstat" operation on
9970       multiple files, where all files are in the directory "path".  "names"
9971       is the list of files from this directory.
9972
9973       On return you get a list of stat structs, with a one-to-one
9974       correspondence to the "names" list.  If any name did not exist or could
9975       not be lstat'd, then the "st_ino" field of that structure is set to
9976       "-1".
9977
9978       This call is intended for programs that want to efficiently list a
9979       directory contents without making many round-trips.  See also
9980       "guestfs_lxattrlist" for a similarly efficient call for getting
9981       extended attributes.
9982
9983       This function returns a "struct guestfs_stat_list *", or NULL if there
9984       was an error.  The caller must call "guestfs_free_stat_list" after use.
9985
9986       (Added in 1.0.77)
9987
9988   guestfs_lstatns
9989        struct guestfs_statns *
9990        guestfs_lstatns (guestfs_h *g,
9991                         const char *path);
9992
9993       Returns file information for the given "path".
9994
9995       This is the same as "guestfs_statns" except that if "path" is a
9996       symbolic link, then the link is stat-ed, not the file it refers to.
9997
9998       This is the same as the lstat(2) system call.
9999
10000       This function returns a "struct guestfs_statns *", or NULL if there was
10001       an error.  The caller must call "guestfs_free_statns" after use.
10002
10003       (Added in 1.27.53)
10004
10005   guestfs_lstatnslist
10006        struct guestfs_statns_list *
10007        guestfs_lstatnslist (guestfs_h *g,
10008                             const char *path,
10009                             char *const *names);
10010
10011       This call allows you to perform the "guestfs_lstatns" operation on
10012       multiple files, where all files are in the directory "path".  "names"
10013       is the list of files from this directory.
10014
10015       On return you get a list of stat structs, with a one-to-one
10016       correspondence to the "names" list.  If any name did not exist or could
10017       not be lstat'd, then the "st_ino" field of that structure is set to
10018       "-1".
10019
10020       This call is intended for programs that want to efficiently list a
10021       directory contents without making many round-trips.  See also
10022       "guestfs_lxattrlist" for a similarly efficient call for getting
10023       extended attributes.
10024
10025       This function returns a "struct guestfs_statns_list *", or NULL if
10026       there was an error.  The caller must call "guestfs_free_statns_list"
10027       after use.
10028
10029       (Added in 1.27.53)
10030
10031   guestfs_luks_add_key
10032        int
10033        guestfs_luks_add_key (guestfs_h *g,
10034                              const char *device,
10035                              const char *key,
10036                              const char *newkey,
10037                              int keyslot);
10038
10039       This command adds a new key on LUKS device "device".  "key" is any
10040       existing key, and is used to access the device.  "newkey" is the new
10041       key to add.  "keyslot" is the key slot that will be replaced.
10042
10043       Note that if "keyslot" already contains a key, then this command will
10044       fail.  You have to use "guestfs_luks_kill_slot" first to remove that
10045       key.
10046
10047       This function returns 0 on success or -1 on error.
10048
10049       This function takes a key or passphrase parameter which could contain
10050       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10051       information.
10052
10053       This function depends on the feature "luks".  See also
10054       "guestfs_feature_available".
10055
10056       (Added in 1.5.2)
10057
10058   guestfs_luks_close
10059        int
10060        guestfs_luks_close (guestfs_h *g,
10061                            const char *device);
10062
10063       This closes a LUKS device that was created earlier by
10064       "guestfs_luks_open" or "guestfs_luks_open_ro".  The "device" parameter
10065       must be the name of the LUKS mapping device (ie. /dev/mapper/mapname)
10066       and not the name of the underlying block device.
10067
10068       This function returns 0 on success or -1 on error.
10069
10070       This function depends on the feature "luks".  See also
10071       "guestfs_feature_available".
10072
10073       (Added in 1.5.1)
10074
10075   guestfs_luks_format
10076        int
10077        guestfs_luks_format (guestfs_h *g,
10078                             const char *device,
10079                             const char *key,
10080                             int keyslot);
10081
10082       This command erases existing data on "device" and formats the device as
10083       a LUKS encrypted device.  "key" is the initial key, which is added to
10084       key slot "keyslot".  (LUKS supports 8 key slots, numbered 0-7).
10085
10086       This function returns 0 on success or -1 on error.
10087
10088       This function takes a key or passphrase parameter which could contain
10089       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10090       information.
10091
10092       This function depends on the feature "luks".  See also
10093       "guestfs_feature_available".
10094
10095       (Added in 1.5.2)
10096
10097   guestfs_luks_format_cipher
10098        int
10099        guestfs_luks_format_cipher (guestfs_h *g,
10100                                    const char *device,
10101                                    const char *key,
10102                                    int keyslot,
10103                                    const char *cipher);
10104
10105       This command is the same as "guestfs_luks_format" but it also allows
10106       you to set the "cipher" used.
10107
10108       This function returns 0 on success or -1 on error.
10109
10110       This function takes a key or passphrase parameter which could contain
10111       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10112       information.
10113
10114       This function depends on the feature "luks".  See also
10115       "guestfs_feature_available".
10116
10117       (Added in 1.5.2)
10118
10119   guestfs_luks_kill_slot
10120        int
10121        guestfs_luks_kill_slot (guestfs_h *g,
10122                                const char *device,
10123                                const char *key,
10124                                int keyslot);
10125
10126       This command deletes the key in key slot "keyslot" from the encrypted
10127       LUKS device "device".  "key" must be one of the other keys.
10128
10129       This function returns 0 on success or -1 on error.
10130
10131       This function takes a key or passphrase parameter which could contain
10132       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10133       information.
10134
10135       This function depends on the feature "luks".  See also
10136       "guestfs_feature_available".
10137
10138       (Added in 1.5.2)
10139
10140   guestfs_luks_open
10141        int
10142        guestfs_luks_open (guestfs_h *g,
10143                           const char *device,
10144                           const char *key,
10145                           const char *mapname);
10146
10147       This command opens a block device which has been encrypted according to
10148       the Linux Unified Key Setup (LUKS) standard.
10149
10150       "device" is the encrypted block device or partition.
10151
10152       The caller must supply one of the keys associated with the LUKS block
10153       device, in the "key" parameter.
10154
10155       This creates a new block device called /dev/mapper/mapname.  Reads and
10156       writes to this block device are decrypted from and encrypted to the
10157       underlying "device" respectively.
10158
10159       If this block device contains LVM volume groups, then calling
10160       "guestfs_lvm_scan" with the "activate" parameter "true" will make them
10161       visible.
10162
10163       Use "guestfs_list_dm_devices" to list all device mapper devices.
10164
10165       This function returns 0 on success or -1 on error.
10166
10167       This function takes a key or passphrase parameter which could contain
10168       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10169       information.
10170
10171       This function depends on the feature "luks".  See also
10172       "guestfs_feature_available".
10173
10174       (Added in 1.5.1)
10175
10176   guestfs_luks_open_ro
10177        int
10178        guestfs_luks_open_ro (guestfs_h *g,
10179                              const char *device,
10180                              const char *key,
10181                              const char *mapname);
10182
10183       This is the same as "guestfs_luks_open" except that a read-only mapping
10184       is created.
10185
10186       This function returns 0 on success or -1 on error.
10187
10188       This function takes a key or passphrase parameter which could contain
10189       sensitive material.  Read the section "KEYS AND PASSPHRASES" for more
10190       information.
10191
10192       This function depends on the feature "luks".  See also
10193       "guestfs_feature_available".
10194
10195       (Added in 1.5.1)
10196
10197   guestfs_luks_uuid
10198        char *
10199        guestfs_luks_uuid (guestfs_h *g,
10200                           const char *device);
10201
10202       This returns the UUID of the LUKS device "device".
10203
10204       This function returns a string, or NULL on error.  The caller must free
10205       the returned string after use.
10206
10207       This function depends on the feature "luks".  See also
10208       "guestfs_feature_available".
10209
10210       (Added in 1.41.9)
10211
10212   guestfs_lvcreate
10213        int
10214        guestfs_lvcreate (guestfs_h *g,
10215                          const char *logvol,
10216                          const char *volgroup,
10217                          int mbytes);
10218
10219       This creates an LVM logical volume called "logvol" on the volume group
10220       "volgroup", with "size" megabytes.
10221
10222       This function returns 0 on success or -1 on error.
10223
10224       This function depends on the feature "lvm2".  See also
10225       "guestfs_feature_available".
10226
10227       (Added in 0.8)
10228
10229   guestfs_lvcreate_free
10230        int
10231        guestfs_lvcreate_free (guestfs_h *g,
10232                               const char *logvol,
10233                               const char *volgroup,
10234                               int percent);
10235
10236       Create an LVM logical volume called /dev/volgroup/logvol, using
10237       approximately "percent" % of the free space remaining in the volume
10238       group.  Most usefully, when "percent" is 100 this will create the
10239       largest possible LV.
10240
10241       This function returns 0 on success or -1 on error.
10242
10243       This function depends on the feature "lvm2".  See also
10244       "guestfs_feature_available".
10245
10246       (Added in 1.17.18)
10247
10248   guestfs_lvm_canonical_lv_name
10249        char *
10250        guestfs_lvm_canonical_lv_name (guestfs_h *g,
10251                                       const char *lvname);
10252
10253       This converts alternative naming schemes for LVs that you might find to
10254       the canonical name.  For example, /dev/mapper/VG-LV is converted to
10255       /dev/VG/LV.
10256
10257       This command returns an error if the "lvname" parameter does not refer
10258       to a logical volume.
10259
10260       See also "guestfs_is_lv", "guestfs_canonical_device_name".
10261
10262       This function returns a string, or NULL on error.  The caller must free
10263       the returned string after use.
10264
10265       (Added in 1.5.24)
10266
10267   guestfs_lvm_clear_filter
10268        int
10269        guestfs_lvm_clear_filter (guestfs_h *g);
10270
10271       This undoes the effect of "guestfs_lvm_set_filter".  LVM will be able
10272       to see every block device.
10273
10274       This command also clears the LVM cache and performs a volume group
10275       scan.
10276
10277       This function returns 0 on success or -1 on error.
10278
10279       (Added in 1.5.1)
10280
10281   guestfs_lvm_remove_all
10282        int
10283        guestfs_lvm_remove_all (guestfs_h *g);
10284
10285       This command removes all LVM logical volumes, volume groups and
10286       physical volumes.
10287
10288       This function returns 0 on success or -1 on error.
10289
10290       This function depends on the feature "lvm2".  See also
10291       "guestfs_feature_available".
10292
10293       (Added in 0.8)
10294
10295   guestfs_lvm_scan
10296        int
10297        guestfs_lvm_scan (guestfs_h *g,
10298                          int activate);
10299
10300       This scans all block devices and rebuilds the list of LVM physical
10301       volumes, volume groups and logical volumes.
10302
10303       If the "activate" parameter is "true" then newly found volume groups
10304       and logical volumes are activated, meaning the LV /dev/VG/LV devices
10305       become visible.
10306
10307       When a libguestfs handle is launched it scans for existing devices, so
10308       you do not normally need to use this API.  However it is useful when
10309       you have added a new device or deleted an existing device (such as when
10310       the "guestfs_luks_open" API is used).
10311
10312       This function returns 0 on success or -1 on error.
10313
10314       (Added in 1.39.8)
10315
10316   guestfs_lvm_set_filter
10317        int
10318        guestfs_lvm_set_filter (guestfs_h *g,
10319                                char *const *devices);
10320
10321       This sets the LVM device filter so that LVM will only be able to "see"
10322       the block devices in the list "devices", and will ignore all other
10323       attached block devices.
10324
10325       Where disk image(s) contain duplicate PVs or VGs, this command is
10326       useful to get LVM to ignore the duplicates, otherwise LVM can get
10327       confused.  Note also there are two types of duplication possible:
10328       either cloned PVs/VGs which have identical UUIDs; or VGs that are not
10329       cloned but just happen to have the same name.  In normal operation you
10330       cannot create this situation, but you can do it outside LVM, eg.  by
10331       cloning disk images or by bit twiddling inside the LVM metadata.
10332
10333       This command also clears the LVM cache and performs a volume group
10334       scan.
10335
10336       You can filter whole block devices or individual partitions.
10337
10338       You cannot use this if any VG is currently in use (eg.  contains a
10339       mounted filesystem), even if you are not filtering out that VG.
10340
10341       This function returns 0 on success or -1 on error.
10342
10343       This function depends on the feature "lvm2".  See also
10344       "guestfs_feature_available".
10345
10346       (Added in 1.5.1)
10347
10348   guestfs_lvremove
10349        int
10350        guestfs_lvremove (guestfs_h *g,
10351                          const char *device);
10352
10353       Remove an LVM logical volume "device", where "device" is the path to
10354       the LV, such as /dev/VG/LV.
10355
10356       You can also remove all LVs in a volume group by specifying the VG
10357       name, /dev/VG.
10358
10359       This function returns 0 on success or -1 on error.
10360
10361       This function depends on the feature "lvm2".  See also
10362       "guestfs_feature_available".
10363
10364       (Added in 1.0.13)
10365
10366   guestfs_lvrename
10367        int
10368        guestfs_lvrename (guestfs_h *g,
10369                          const char *logvol,
10370                          const char *newlogvol);
10371
10372       Rename a logical volume "logvol" with the new name "newlogvol".
10373
10374       This function returns 0 on success or -1 on error.
10375
10376       (Added in 1.0.83)
10377
10378   guestfs_lvresize
10379        int
10380        guestfs_lvresize (guestfs_h *g,
10381                          const char *device,
10382                          int mbytes);
10383
10384       This resizes (expands or shrinks) an existing LVM logical volume to
10385       "mbytes".  When reducing, data in the reduced part is lost.
10386
10387       This function returns 0 on success or -1 on error.
10388
10389       This function depends on the feature "lvm2".  See also
10390       "guestfs_feature_available".
10391
10392       (Added in 1.0.27)
10393
10394   guestfs_lvresize_free
10395        int
10396        guestfs_lvresize_free (guestfs_h *g,
10397                               const char *lv,
10398                               int percent);
10399
10400       This expands an existing logical volume "lv" so that it fills "pc" % of
10401       the remaining free space in the volume group.  Commonly you would call
10402       this with pc = 100 which expands the logical volume as much as
10403       possible, using all remaining free space in the volume group.
10404
10405       This function returns 0 on success or -1 on error.
10406
10407       This function depends on the feature "lvm2".  See also
10408       "guestfs_feature_available".
10409
10410       (Added in 1.3.3)
10411
10412   guestfs_lvs
10413        char **
10414        guestfs_lvs (guestfs_h *g);
10415
10416       List all the logical volumes detected.  This is the equivalent of the
10417       lvs(8) command.
10418
10419       This returns a list of the logical volume device names (eg.
10420       /dev/VolGroup00/LogVol00).
10421
10422       See also "guestfs_lvs_full", "guestfs_list_filesystems".
10423
10424       This function returns a NULL-terminated array of strings (like
10425       environ(3)), or NULL if there was an error.  The caller must free the
10426       strings and the array after use.
10427
10428       This function depends on the feature "lvm2".  See also
10429       "guestfs_feature_available".
10430
10431       (Added in 0.4)
10432
10433   guestfs_lvs_full
10434        struct guestfs_lvm_lv_list *
10435        guestfs_lvs_full (guestfs_h *g);
10436
10437       List all the logical volumes detected.  This is the equivalent of the
10438       lvs(8) command.  The "full" version includes all fields.
10439
10440       This function returns a "struct guestfs_lvm_lv_list *", or NULL if
10441       there was an error.  The caller must call "guestfs_free_lvm_lv_list"
10442       after use.
10443
10444       This function depends on the feature "lvm2".  See also
10445       "guestfs_feature_available".
10446
10447       (Added in 0.4)
10448
10449   guestfs_lvuuid
10450        char *
10451        guestfs_lvuuid (guestfs_h *g,
10452                        const char *device);
10453
10454       This command returns the UUID of the LVM LV "device".
10455
10456       This function returns a string, or NULL on error.  The caller must free
10457       the returned string after use.
10458
10459       (Added in 1.0.87)
10460
10461   guestfs_lxattrlist
10462        struct guestfs_xattr_list *
10463        guestfs_lxattrlist (guestfs_h *g,
10464                            const char *path,
10465                            char *const *names);
10466
10467       This call allows you to get the extended attributes of multiple files,
10468       where all files are in the directory "path".  "names" is the list of
10469       files from this directory.
10470
10471       On return you get a flat list of xattr structs which must be
10472       interpreted sequentially.  The first xattr struct always has a zero-
10473       length "attrname".  "attrval" in this struct is zero-length to indicate
10474       there was an error doing "guestfs_lgetxattr" for this file, or is a C
10475       string which is a decimal number (the number of following attributes
10476       for this file, which could be "0").  Then after the first xattr struct
10477       are the zero or more attributes for the first named file.  This repeats
10478       for the second and subsequent files.
10479
10480       This call is intended for programs that want to efficiently list a
10481       directory contents without making many round-trips.  See also
10482       "guestfs_lstatlist" for a similarly efficient call for getting standard
10483       stats.
10484
10485       This function returns a "struct guestfs_xattr_list *", or NULL if there
10486       was an error.  The caller must call "guestfs_free_xattr_list" after
10487       use.
10488
10489       This function depends on the feature "linuxxattrs".  See also
10490       "guestfs_feature_available".
10491
10492       (Added in 1.0.77)
10493
10494   guestfs_max_disks
10495        int
10496        guestfs_max_disks (guestfs_h *g);
10497
10498       Return the maximum number of disks that may be added to a handle (eg.
10499       by "guestfs_add_drive_opts" and similar calls).
10500
10501       This function was added in libguestfs 1.19.7.  In previous versions of
10502       libguestfs the limit was 25.
10503
10504       See "MAXIMUM NUMBER OF DISKS" for additional information on this topic.
10505
10506       On error this function returns -1.
10507
10508       (Added in 1.19.7)
10509
10510   guestfs_md_create
10511        int
10512        guestfs_md_create (guestfs_h *g,
10513                           const char *name,
10514                           char *const *devices,
10515                           ...);
10516
10517       You may supply a list of optional arguments to this call.  Use zero or
10518       more of the following pairs of parameters, and terminate the list with
10519       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
10520
10521        GUESTFS_MD_CREATE_MISSINGBITMAP, int64_t missingbitmap,
10522        GUESTFS_MD_CREATE_NRDEVICES, int nrdevices,
10523        GUESTFS_MD_CREATE_SPARE, int spare,
10524        GUESTFS_MD_CREATE_CHUNK, int64_t chunk,
10525        GUESTFS_MD_CREATE_LEVEL, const char *level,
10526
10527       Create a Linux md (RAID) device named "name" on the devices in the list
10528       "devices".
10529
10530       The optional parameters are:
10531
10532       "missingbitmap"
10533           A bitmap of missing devices.  If a bit is set it means that a
10534           missing device is added to the array.  The least significant bit
10535           corresponds to the first device in the array.
10536
10537           As examples:
10538
10539           If "devices = ["/dev/sda"]" and "missingbitmap = 0x1" then the
10540           resulting array would be "[<missing>, "/dev/sda"]".
10541
10542           If "devices = ["/dev/sda"]" and "missingbitmap = 0x2" then the
10543           resulting array would be "["/dev/sda", <missing>]".
10544
10545           This defaults to 0 (no missing devices).
10546
10547           The length of "devices" + the number of bits set in "missingbitmap"
10548           must equal "nrdevices" + "spare".
10549
10550       "nrdevices"
10551           The number of active RAID devices.
10552
10553           If not set, this defaults to the length of "devices" plus the
10554           number of bits set in "missingbitmap".
10555
10556       "spare"
10557           The number of spare devices.
10558
10559           If not set, this defaults to 0.
10560
10561       "chunk"
10562           The chunk size in bytes.
10563
10564       "level"
10565           The RAID level, which can be one of: "linear", "raid0", 0,
10566           "stripe", "raid1", 1, "mirror", "raid4", 4, "raid5", 5, "raid6", 6,
10567           "raid10", 10.  Some of these are synonymous, and more levels may be
10568           added in future.
10569
10570           If not set, this defaults to "raid1".
10571
10572       This function returns 0 on success or -1 on error.
10573
10574       This function depends on the feature "mdadm".  See also
10575       "guestfs_feature_available".
10576
10577       (Added in 1.15.6)
10578
10579   guestfs_md_create_va
10580        int
10581        guestfs_md_create_va (guestfs_h *g,
10582                              const char *name,
10583                              char *const *devices,
10584                              va_list args);
10585
10586       This is the "va_list variant" of "guestfs_md_create".
10587
10588       See "CALLS WITH OPTIONAL ARGUMENTS".
10589
10590   guestfs_md_create_argv
10591        int
10592        guestfs_md_create_argv (guestfs_h *g,
10593                                const char *name,
10594                                char *const *devices,
10595                                const struct guestfs_md_create_argv *optargs);
10596
10597       This is the "argv variant" of "guestfs_md_create".
10598
10599       See "CALLS WITH OPTIONAL ARGUMENTS".
10600
10601   guestfs_md_detail
10602        char **
10603        guestfs_md_detail (guestfs_h *g,
10604                           const char *md);
10605
10606       This command exposes the output of "mdadm -DY <md>".  The following
10607       fields are usually present in the returned hash.  Other fields may also
10608       be present.
10609
10610       "level"
10611           The raid level of the MD device.
10612
10613       "devices"
10614           The number of underlying devices in the MD device.
10615
10616       "metadata"
10617           The metadata version used.
10618
10619       "uuid"
10620           The UUID of the MD device.
10621
10622       "name"
10623           The name of the MD device.
10624
10625       This function returns a NULL-terminated array of strings, or NULL if
10626       there was an error.  The array of strings will always have length
10627       "2n+1", where "n" keys and values alternate, followed by the trailing
10628       NULL entry.  The caller must free the strings and the array after use.
10629
10630       This function depends on the feature "mdadm".  See also
10631       "guestfs_feature_available".
10632
10633       (Added in 1.15.6)
10634
10635   guestfs_md_stat
10636        struct guestfs_mdstat_list *
10637        guestfs_md_stat (guestfs_h *g,
10638                         const char *md);
10639
10640       This call returns a list of the underlying devices which make up the
10641       single software RAID array device "md".
10642
10643       To get a list of software RAID devices, call "guestfs_list_md_devices".
10644
10645       Each structure returned corresponds to one device along with additional
10646       status information:
10647
10648       "mdstat_device"
10649           The name of the underlying device.
10650
10651       "mdstat_index"
10652           The index of this device within the array.
10653
10654       "mdstat_flags"
10655           Flags associated with this device.  This is a string containing (in
10656           no specific order) zero or more of the following flags:
10657
10658           "W" write-mostly
10659
10660           "F" device is faulty
10661
10662           "S" device is a RAID spare
10663
10664           "R" replacement
10665
10666       This function returns a "struct guestfs_mdstat_list *", or NULL if
10667       there was an error.  The caller must call "guestfs_free_mdstat_list"
10668       after use.
10669
10670       This function depends on the feature "mdadm".  See also
10671       "guestfs_feature_available".
10672
10673       (Added in 1.17.21)
10674
10675   guestfs_md_stop
10676        int
10677        guestfs_md_stop (guestfs_h *g,
10678                         const char *md);
10679
10680       This command deactivates the MD array named "md".  The device is
10681       stopped, but it is not destroyed or zeroed.
10682
10683       This function returns 0 on success or -1 on error.
10684
10685       This function depends on the feature "mdadm".  See also
10686       "guestfs_feature_available".
10687
10688       (Added in 1.15.6)
10689
10690   guestfs_mkdir
10691        int
10692        guestfs_mkdir (guestfs_h *g,
10693                       const char *path);
10694
10695       Create a directory named "path".
10696
10697       This function returns 0 on success or -1 on error.
10698
10699       (Added in 0.8)
10700
10701   guestfs_mkdir_mode
10702        int
10703        guestfs_mkdir_mode (guestfs_h *g,
10704                            const char *path,
10705                            int mode);
10706
10707       This command creates a directory, setting the initial permissions of
10708       the directory to "mode".
10709
10710       For common Linux filesystems, the actual mode which is set will be
10711       "mode & ~umask & 01777".  Non-native-Linux filesystems may interpret
10712       the mode in other ways.
10713
10714       See also "guestfs_mkdir", "guestfs_umask"
10715
10716       This function returns 0 on success or -1 on error.
10717
10718       (Added in 1.0.77)
10719
10720   guestfs_mkdir_p
10721        int
10722        guestfs_mkdir_p (guestfs_h *g,
10723                         const char *path);
10724
10725       Create a directory named "path", creating any parent directories as
10726       necessary.  This is like the "mkdir -p" shell command.
10727
10728       This function returns 0 on success or -1 on error.
10729
10730       (Added in 0.8)
10731
10732   guestfs_mkdtemp
10733        char *
10734        guestfs_mkdtemp (guestfs_h *g,
10735                         const char *tmpl);
10736
10737       This command creates a temporary directory.  The "tmpl" parameter
10738       should be a full pathname for the temporary directory name with the
10739       final six characters being "XXXXXX".
10740
10741       For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
10742       one being suitable for Windows filesystems.
10743
10744       The name of the temporary directory that was created is returned.
10745
10746       The temporary directory is created with mode 0700 and is owned by root.
10747
10748       The caller is responsible for deleting the temporary directory and its
10749       contents after use.
10750
10751       See also: mkdtemp(3)
10752
10753       This function returns a string, or NULL on error.  The caller must free
10754       the returned string after use.
10755
10756       (Added in 1.0.54)
10757
10758   guestfs_mke2fs
10759        int
10760        guestfs_mke2fs (guestfs_h *g,
10761                        const char *device,
10762                        ...);
10763
10764       You may supply a list of optional arguments to this call.  Use zero or
10765       more of the following pairs of parameters, and terminate the list with
10766       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
10767
10768        GUESTFS_MKE2FS_BLOCKSCOUNT, int64_t blockscount,
10769        GUESTFS_MKE2FS_BLOCKSIZE, int64_t blocksize,
10770        GUESTFS_MKE2FS_FRAGSIZE, int64_t fragsize,
10771        GUESTFS_MKE2FS_BLOCKSPERGROUP, int64_t blockspergroup,
10772        GUESTFS_MKE2FS_NUMBEROFGROUPS, int64_t numberofgroups,
10773        GUESTFS_MKE2FS_BYTESPERINODE, int64_t bytesperinode,
10774        GUESTFS_MKE2FS_INODESIZE, int64_t inodesize,
10775        GUESTFS_MKE2FS_JOURNALSIZE, int64_t journalsize,
10776        GUESTFS_MKE2FS_NUMBEROFINODES, int64_t numberofinodes,
10777        GUESTFS_MKE2FS_STRIDESIZE, int64_t stridesize,
10778        GUESTFS_MKE2FS_STRIPEWIDTH, int64_t stripewidth,
10779        GUESTFS_MKE2FS_MAXONLINERESIZE, int64_t maxonlineresize,
10780        GUESTFS_MKE2FS_RESERVEDBLOCKSPERCENTAGE, int reservedblockspercentage,
10781        GUESTFS_MKE2FS_MMPUPDATEINTERVAL, int mmpupdateinterval,
10782        GUESTFS_MKE2FS_JOURNALDEVICE, const char *journaldevice,
10783        GUESTFS_MKE2FS_LABEL, const char *label,
10784        GUESTFS_MKE2FS_LASTMOUNTEDDIR, const char *lastmounteddir,
10785        GUESTFS_MKE2FS_CREATOROS, const char *creatoros,
10786        GUESTFS_MKE2FS_FSTYPE, const char *fstype,
10787        GUESTFS_MKE2FS_USAGETYPE, const char *usagetype,
10788        GUESTFS_MKE2FS_UUID, const char *uuid,
10789        GUESTFS_MKE2FS_FORCECREATE, int forcecreate,
10790        GUESTFS_MKE2FS_WRITESBANDGROUPONLY, int writesbandgrouponly,
10791        GUESTFS_MKE2FS_LAZYITABLEINIT, int lazyitableinit,
10792        GUESTFS_MKE2FS_LAZYJOURNALINIT, int lazyjournalinit,
10793        GUESTFS_MKE2FS_TESTFS, int testfs,
10794        GUESTFS_MKE2FS_DISCARD, int discard,
10795        GUESTFS_MKE2FS_QUOTATYPE, int quotatype,
10796        GUESTFS_MKE2FS_EXTENT, int extent,
10797        GUESTFS_MKE2FS_FILETYPE, int filetype,
10798        GUESTFS_MKE2FS_FLEXBG, int flexbg,
10799        GUESTFS_MKE2FS_HASJOURNAL, int hasjournal,
10800        GUESTFS_MKE2FS_JOURNALDEV, int journaldev,
10801        GUESTFS_MKE2FS_LARGEFILE, int largefile,
10802        GUESTFS_MKE2FS_QUOTA, int quota,
10803        GUESTFS_MKE2FS_RESIZEINODE, int resizeinode,
10804        GUESTFS_MKE2FS_SPARSESUPER, int sparsesuper,
10805        GUESTFS_MKE2FS_UNINITBG, int uninitbg,
10806
10807       "mke2fs" is used to create an ext2, ext3, or ext4 filesystem on
10808       "device".
10809
10810       The optional "blockscount" is the size of the filesystem in blocks.  If
10811       omitted it defaults to the size of "device".  Note if the filesystem is
10812       too small to contain a journal, "mke2fs" will silently create an ext2
10813       filesystem instead.
10814
10815       This function returns 0 on success or -1 on error.
10816
10817       (Added in 1.19.44)
10818
10819   guestfs_mke2fs_va
10820        int
10821        guestfs_mke2fs_va (guestfs_h *g,
10822                           const char *device,
10823                           va_list args);
10824
10825       This is the "va_list variant" of "guestfs_mke2fs".
10826
10827       See "CALLS WITH OPTIONAL ARGUMENTS".
10828
10829   guestfs_mke2fs_argv
10830        int
10831        guestfs_mke2fs_argv (guestfs_h *g,
10832                             const char *device,
10833                             const struct guestfs_mke2fs_argv *optargs);
10834
10835       This is the "argv variant" of "guestfs_mke2fs".
10836
10837       See "CALLS WITH OPTIONAL ARGUMENTS".
10838
10839   guestfs_mke2fs_J
10840        int
10841        guestfs_mke2fs_J (guestfs_h *g,
10842                          const char *fstype,
10843                          int blocksize,
10844                          const char *device,
10845                          const char *journal);
10846
10847       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10848       call instead.
10849
10850       Deprecated functions will not be removed from the API, but the fact
10851       that they are deprecated indicates that there are problems with correct
10852       use of these functions.
10853
10854       This creates an ext2/3/4 filesystem on "device" with an external
10855       journal on "journal".  It is equivalent to the command:
10856
10857        mke2fs -t fstype -b blocksize -J device=<journal> <device>
10858
10859       See also "guestfs_mke2journal".
10860
10861       This function returns 0 on success or -1 on error.
10862
10863       (Added in 1.0.68)
10864
10865   guestfs_mke2fs_JL
10866        int
10867        guestfs_mke2fs_JL (guestfs_h *g,
10868                           const char *fstype,
10869                           int blocksize,
10870                           const char *device,
10871                           const char *label);
10872
10873       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10874       call instead.
10875
10876       Deprecated functions will not be removed from the API, but the fact
10877       that they are deprecated indicates that there are problems with correct
10878       use of these functions.
10879
10880       This creates an ext2/3/4 filesystem on "device" with an external
10881       journal on the journal labeled "label".
10882
10883       See also "guestfs_mke2journal_L".
10884
10885       This function returns 0 on success or -1 on error.
10886
10887       (Added in 1.0.68)
10888
10889   guestfs_mke2fs_JU
10890        int
10891        guestfs_mke2fs_JU (guestfs_h *g,
10892                           const char *fstype,
10893                           int blocksize,
10894                           const char *device,
10895                           const char *uuid);
10896
10897       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10898       call instead.
10899
10900       Deprecated functions will not be removed from the API, but the fact
10901       that they are deprecated indicates that there are problems with correct
10902       use of these functions.
10903
10904       This creates an ext2/3/4 filesystem on "device" with an external
10905       journal on the journal with UUID "uuid".
10906
10907       See also "guestfs_mke2journal_U".
10908
10909       This function returns 0 on success or -1 on error.
10910
10911       This function depends on the feature "linuxfsuuid".  See also
10912       "guestfs_feature_available".
10913
10914       (Added in 1.0.68)
10915
10916   guestfs_mke2journal
10917        int
10918        guestfs_mke2journal (guestfs_h *g,
10919                             int blocksize,
10920                             const char *device);
10921
10922       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10923       call instead.
10924
10925       Deprecated functions will not be removed from the API, but the fact
10926       that they are deprecated indicates that there are problems with correct
10927       use of these functions.
10928
10929       This creates an ext2 external journal on "device".  It is equivalent to
10930       the command:
10931
10932        mke2fs -O journal_dev -b blocksize device
10933
10934       This function returns 0 on success or -1 on error.
10935
10936       (Added in 1.0.68)
10937
10938   guestfs_mke2journal_L
10939        int
10940        guestfs_mke2journal_L (guestfs_h *g,
10941                               int blocksize,
10942                               const char *label,
10943                               const char *device);
10944
10945       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10946       call instead.
10947
10948       Deprecated functions will not be removed from the API, but the fact
10949       that they are deprecated indicates that there are problems with correct
10950       use of these functions.
10951
10952       This creates an ext2 external journal on "device" with label "label".
10953
10954       This function returns 0 on success or -1 on error.
10955
10956       (Added in 1.0.68)
10957
10958   guestfs_mke2journal_U
10959        int
10960        guestfs_mke2journal_U (guestfs_h *g,
10961                               int blocksize,
10962                               const char *uuid,
10963                               const char *device);
10964
10965       This function is deprecated.  In new code, use the "guestfs_mke2fs"
10966       call instead.
10967
10968       Deprecated functions will not be removed from the API, but the fact
10969       that they are deprecated indicates that there are problems with correct
10970       use of these functions.
10971
10972       This creates an ext2 external journal on "device" with UUID "uuid".
10973
10974       This function returns 0 on success or -1 on error.
10975
10976       This function depends on the feature "linuxfsuuid".  See also
10977       "guestfs_feature_available".
10978
10979       (Added in 1.0.68)
10980
10981   guestfs_mkfifo
10982        int
10983        guestfs_mkfifo (guestfs_h *g,
10984                        int mode,
10985                        const char *path);
10986
10987       This call creates a FIFO (named pipe) called "path" with mode "mode".
10988       It is just a convenient wrapper around "guestfs_mknod".
10989
10990       Unlike with "guestfs_mknod", "mode" must contain only permissions bits.
10991
10992       The mode actually set is affected by the umask.
10993
10994       This function returns 0 on success or -1 on error.
10995
10996       This function depends on the feature "mknod".  See also
10997       "guestfs_feature_available".
10998
10999       (Added in 1.0.55)
11000
11001   guestfs_mkfs
11002        int
11003        guestfs_mkfs (guestfs_h *g,
11004                      const char *fstype,
11005                      const char *device);
11006
11007       This function is provided for backwards compatibility with earlier
11008       versions of libguestfs.  It simply calls "guestfs_mkfs_opts" with no
11009       optional arguments.
11010
11011       (Added in 0.8)
11012
11013   guestfs_mkfs_opts
11014        int
11015        guestfs_mkfs_opts (guestfs_h *g,
11016                           const char *fstype,
11017                           const char *device,
11018                           ...);
11019
11020       You may supply a list of optional arguments to this call.  Use zero or
11021       more of the following pairs of parameters, and terminate the list with
11022       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11023
11024        GUESTFS_MKFS_OPTS_BLOCKSIZE, int blocksize,
11025        GUESTFS_MKFS_OPTS_FEATURES, const char *features,
11026        GUESTFS_MKFS_OPTS_INODE, int inode,
11027        GUESTFS_MKFS_OPTS_SECTORSIZE, int sectorsize,
11028        GUESTFS_MKFS_OPTS_LABEL, const char *label,
11029
11030       This function creates a filesystem on "device".  The filesystem type is
11031       "fstype", for example "ext3".
11032
11033       The optional arguments are:
11034
11035       "blocksize"
11036           The filesystem block size.  Supported block sizes depend on the
11037           filesystem type, but typically they are 1024, 2048 or 4096 for
11038           Linux ext2/3 filesystems.
11039
11040           For VFAT and NTFS the "blocksize" parameter is treated as the
11041           requested cluster size.
11042
11043           For UFS block sizes, please see mkfs.ufs(8).
11044
11045       "features"
11046           This passes the -O parameter to the external mkfs program.
11047
11048           For certain filesystem types, this allows extra filesystem features
11049           to be selected.  See mke2fs(8) and mkfs.ufs(8) for more details.
11050
11051           You cannot use this optional parameter with the "gfs" or "gfs2"
11052           filesystem type.
11053
11054       "inode"
11055           This passes the -I parameter to the external mke2fs(8) program
11056           which sets the inode size (only for ext2/3/4 filesystems at
11057           present).
11058
11059       "sectorsize"
11060           This passes the -S parameter to external mkfs.ufs(8) program, which
11061           sets sector size for ufs filesystem.
11062
11063       This function returns 0 on success or -1 on error.
11064
11065       (Added in 0.8)
11066
11067   guestfs_mkfs_opts_va
11068        int
11069        guestfs_mkfs_opts_va (guestfs_h *g,
11070                              const char *fstype,
11071                              const char *device,
11072                              va_list args);
11073
11074       This is the "va_list variant" of "guestfs_mkfs_opts".
11075
11076       See "CALLS WITH OPTIONAL ARGUMENTS".
11077
11078   guestfs_mkfs_opts_argv
11079        int
11080        guestfs_mkfs_opts_argv (guestfs_h *g,
11081                                const char *fstype,
11082                                const char *device,
11083                                const struct guestfs_mkfs_opts_argv *optargs);
11084
11085       This is the "argv variant" of "guestfs_mkfs_opts".
11086
11087       See "CALLS WITH OPTIONAL ARGUMENTS".
11088
11089   guestfs_mkfs_b
11090        int
11091        guestfs_mkfs_b (guestfs_h *g,
11092                        const char *fstype,
11093                        int blocksize,
11094                        const char *device);
11095
11096       This function is deprecated.  In new code, use the "guestfs_mkfs" call
11097       instead.
11098
11099       Deprecated functions will not be removed from the API, but the fact
11100       that they are deprecated indicates that there are problems with correct
11101       use of these functions.
11102
11103       This call is similar to "guestfs_mkfs", but it allows you to control
11104       the block size of the resulting filesystem.  Supported block sizes
11105       depend on the filesystem type, but typically they are 1024, 2048 or
11106       4096 only.
11107
11108       For VFAT and NTFS the "blocksize" parameter is treated as the requested
11109       cluster size.
11110
11111       This function returns 0 on success or -1 on error.
11112
11113       (Added in 1.0.68)
11114
11115   guestfs_mkfs_btrfs
11116        int
11117        guestfs_mkfs_btrfs (guestfs_h *g,
11118                            char *const *devices,
11119                            ...);
11120
11121       You may supply a list of optional arguments to this call.  Use zero or
11122       more of the following pairs of parameters, and terminate the list with
11123       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11124
11125        GUESTFS_MKFS_BTRFS_ALLOCSTART, int64_t allocstart,
11126        GUESTFS_MKFS_BTRFS_BYTECOUNT, int64_t bytecount,
11127        GUESTFS_MKFS_BTRFS_DATATYPE, const char *datatype,
11128        GUESTFS_MKFS_BTRFS_LEAFSIZE, int leafsize,
11129        GUESTFS_MKFS_BTRFS_LABEL, const char *label,
11130        GUESTFS_MKFS_BTRFS_METADATA, const char *metadata,
11131        GUESTFS_MKFS_BTRFS_NODESIZE, int nodesize,
11132        GUESTFS_MKFS_BTRFS_SECTORSIZE, int sectorsize,
11133
11134       Create a btrfs filesystem, allowing all configurables to be set.  For
11135       more information on the optional arguments, see mkfs.btrfs(8).
11136
11137       Since btrfs filesystems can span multiple devices, this takes a non-
11138       empty list of devices.
11139
11140       To create general filesystems, use "guestfs_mkfs".
11141
11142       This function returns 0 on success or -1 on error.
11143
11144       This function depends on the feature "btrfs".  See also
11145       "guestfs_feature_available".
11146
11147       (Added in 1.17.25)
11148
11149   guestfs_mkfs_btrfs_va
11150        int
11151        guestfs_mkfs_btrfs_va (guestfs_h *g,
11152                               char *const *devices,
11153                               va_list args);
11154
11155       This is the "va_list variant" of "guestfs_mkfs_btrfs".
11156
11157       See "CALLS WITH OPTIONAL ARGUMENTS".
11158
11159   guestfs_mkfs_btrfs_argv
11160        int
11161        guestfs_mkfs_btrfs_argv (guestfs_h *g,
11162                                 char *const *devices,
11163                                 const struct guestfs_mkfs_btrfs_argv *optargs);
11164
11165       This is the "argv variant" of "guestfs_mkfs_btrfs".
11166
11167       See "CALLS WITH OPTIONAL ARGUMENTS".
11168
11169   guestfs_mklost_and_found
11170        int
11171        guestfs_mklost_and_found (guestfs_h *g,
11172                                  const char *mountpoint);
11173
11174       Make the "lost+found" directory, normally in the root directory of an
11175       ext2/3/4 filesystem.  "mountpoint" is the directory under which we try
11176       to create the "lost+found" directory.
11177
11178       This function returns 0 on success or -1 on error.
11179
11180       (Added in 1.19.56)
11181
11182   guestfs_mkmountpoint
11183        int
11184        guestfs_mkmountpoint (guestfs_h *g,
11185                              const char *exemptpath);
11186
11187       "guestfs_mkmountpoint" and "guestfs_rmmountpoint" are specialized calls
11188       that can be used to create extra mountpoints before mounting the first
11189       filesystem.
11190
11191       These calls are only necessary in some very limited circumstances,
11192       mainly the case where you want to mount a mix of unrelated and/or read-
11193       only filesystems together.
11194
11195       For example, live CDs often contain a "Russian doll" nest of
11196       filesystems, an ISO outer layer, with a squashfs image inside, with an
11197       ext2/3 image inside that.  You can unpack this as follows in guestfish:
11198
11199        add-ro Fedora-11-i686-Live.iso
11200        run
11201        mkmountpoint /cd
11202        mkmountpoint /sqsh
11203        mkmountpoint /ext3fs
11204        mount /dev/sda /cd
11205        mount-loop /cd/LiveOS/squashfs.img /sqsh
11206        mount-loop /sqsh/LiveOS/ext3fs.img /ext3fs
11207
11208       The inner filesystem is now unpacked under the /ext3fs mountpoint.
11209
11210       "guestfs_mkmountpoint" is not compatible with "guestfs_umount_all".
11211       You may get unexpected errors if you try to mix these calls.  It is
11212       safest to manually unmount filesystems and remove mountpoints after
11213       use.
11214
11215       "guestfs_umount_all" unmounts filesystems by sorting the paths longest
11216       first, so for this to work for manual mountpoints, you must ensure that
11217       the innermost mountpoints have the longest pathnames, as in the example
11218       code above.
11219
11220       For more details see https://bugzilla.redhat.com/show_bug.cgi?id=599503
11221
11222       Autosync [see "guestfs_set_autosync", this is set by default on
11223       handles] can cause "guestfs_umount_all" to be called when the handle is
11224       closed which can also trigger these issues.
11225
11226       This function returns 0 on success or -1 on error.
11227
11228       (Added in 1.0.62)
11229
11230   guestfs_mknod
11231        int
11232        guestfs_mknod (guestfs_h *g,
11233                       int mode,
11234                       int devmajor,
11235                       int devminor,
11236                       const char *path);
11237
11238       This call creates block or character special devices, or named pipes
11239       (FIFOs).
11240
11241       The "mode" parameter should be the mode, using the standard constants.
11242       "devmajor" and "devminor" are the device major and minor numbers, only
11243       used when creating block and character special devices.
11244
11245       Note that, just like mknod(2), the mode must be bitwise OR'd with
11246       S_IFBLK, S_IFCHR, S_IFIFO or S_IFSOCK (otherwise this call just creates
11247       a regular file).  These constants are available in the standard Linux
11248       header files, or you can use "guestfs_mknod_b", "guestfs_mknod_c" or
11249       "guestfs_mkfifo" which are wrappers around this command which bitwise
11250       OR in the appropriate constant for you.
11251
11252       The mode actually set is affected by the umask.
11253
11254       This function returns 0 on success or -1 on error.
11255
11256       This function depends on the feature "mknod".  See also
11257       "guestfs_feature_available".
11258
11259       (Added in 1.0.55)
11260
11261   guestfs_mknod_b
11262        int
11263        guestfs_mknod_b (guestfs_h *g,
11264                         int mode,
11265                         int devmajor,
11266                         int devminor,
11267                         const char *path);
11268
11269       This call creates a block device node called "path" with mode "mode"
11270       and device major/minor "devmajor" and "devminor".  It is just a
11271       convenient wrapper around "guestfs_mknod".
11272
11273       Unlike with "guestfs_mknod", "mode" must contain only permissions bits.
11274
11275       The mode actually set is affected by the umask.
11276
11277       This function returns 0 on success or -1 on error.
11278
11279       This function depends on the feature "mknod".  See also
11280       "guestfs_feature_available".
11281
11282       (Added in 1.0.55)
11283
11284   guestfs_mknod_c
11285        int
11286        guestfs_mknod_c (guestfs_h *g,
11287                         int mode,
11288                         int devmajor,
11289                         int devminor,
11290                         const char *path);
11291
11292       This call creates a char device node called "path" with mode "mode" and
11293       device major/minor "devmajor" and "devminor".  It is just a convenient
11294       wrapper around "guestfs_mknod".
11295
11296       Unlike with "guestfs_mknod", "mode" must contain only permissions bits.
11297
11298       The mode actually set is affected by the umask.
11299
11300       This function returns 0 on success or -1 on error.
11301
11302       This function depends on the feature "mknod".  See also
11303       "guestfs_feature_available".
11304
11305       (Added in 1.0.55)
11306
11307   guestfs_mksquashfs
11308        int
11309        guestfs_mksquashfs (guestfs_h *g,
11310                            const char *path,
11311                            const char *filename,
11312                            ...);
11313
11314       You may supply a list of optional arguments to this call.  Use zero or
11315       more of the following pairs of parameters, and terminate the list with
11316       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11317
11318        GUESTFS_MKSQUASHFS_COMPRESS, const char *compress,
11319        GUESTFS_MKSQUASHFS_EXCLUDES, char *const *excludes,
11320
11321       Create a squashfs filesystem for the specified "path".
11322
11323       The optional "compress" flag controls compression.  If not given, then
11324       the output compressed using "gzip".  Otherwise one of the following
11325       strings may be given to select the compression type of the squashfs:
11326       "gzip", "lzma", "lzo", "lz4", "xz".
11327
11328       The other optional arguments are:
11329
11330       "excludes"
11331           A list of wildcards.  Files are excluded if they match any of the
11332           wildcards.
11333
11334       Please note that this API may fail when used to compress directories
11335       with large files, such as the resulting squashfs will be over 3GB big.
11336
11337       This function returns 0 on success or -1 on error.
11338
11339       This function depends on the feature "squashfs".  See also
11340       "guestfs_feature_available".
11341
11342       (Added in 1.35.25)
11343
11344   guestfs_mksquashfs_va
11345        int
11346        guestfs_mksquashfs_va (guestfs_h *g,
11347                               const char *path,
11348                               const char *filename,
11349                               va_list args);
11350
11351       This is the "va_list variant" of "guestfs_mksquashfs".
11352
11353       See "CALLS WITH OPTIONAL ARGUMENTS".
11354
11355   guestfs_mksquashfs_argv
11356        int
11357        guestfs_mksquashfs_argv (guestfs_h *g,
11358                                 const char *path,
11359                                 const char *filename,
11360                                 const struct guestfs_mksquashfs_argv *optargs);
11361
11362       This is the "argv variant" of "guestfs_mksquashfs".
11363
11364       See "CALLS WITH OPTIONAL ARGUMENTS".
11365
11366   guestfs_mkswap
11367        int
11368        guestfs_mkswap (guestfs_h *g,
11369                        const char *device);
11370
11371       This function is provided for backwards compatibility with earlier
11372       versions of libguestfs.  It simply calls "guestfs_mkswap_opts" with no
11373       optional arguments.
11374
11375       (Added in 1.0.55)
11376
11377   guestfs_mkswap_opts
11378        int
11379        guestfs_mkswap_opts (guestfs_h *g,
11380                             const char *device,
11381                             ...);
11382
11383       You may supply a list of optional arguments to this call.  Use zero or
11384       more of the following pairs of parameters, and terminate the list with
11385       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11386
11387        GUESTFS_MKSWAP_OPTS_LABEL, const char *label,
11388        GUESTFS_MKSWAP_OPTS_UUID, const char *uuid,
11389
11390       Create a Linux swap partition on "device".
11391
11392       The option arguments "label" and "uuid" allow you to set the label
11393       and/or UUID of the new swap partition.
11394
11395       This function returns 0 on success or -1 on error.
11396
11397       (Added in 1.0.55)
11398
11399   guestfs_mkswap_opts_va
11400        int
11401        guestfs_mkswap_opts_va (guestfs_h *g,
11402                                const char *device,
11403                                va_list args);
11404
11405       This is the "va_list variant" of "guestfs_mkswap_opts".
11406
11407       See "CALLS WITH OPTIONAL ARGUMENTS".
11408
11409   guestfs_mkswap_opts_argv
11410        int
11411        guestfs_mkswap_opts_argv (guestfs_h *g,
11412                                  const char *device,
11413                                  const struct guestfs_mkswap_opts_argv *optargs);
11414
11415       This is the "argv variant" of "guestfs_mkswap_opts".
11416
11417       See "CALLS WITH OPTIONAL ARGUMENTS".
11418
11419   guestfs_mkswap_L
11420        int
11421        guestfs_mkswap_L (guestfs_h *g,
11422                          const char *label,
11423                          const char *device);
11424
11425       This function is deprecated.  In new code, use the "guestfs_mkswap"
11426       call instead.
11427
11428       Deprecated functions will not be removed from the API, but the fact
11429       that they are deprecated indicates that there are problems with correct
11430       use of these functions.
11431
11432       Create a swap partition on "device" with label "label".
11433
11434       Note that you cannot attach a swap label to a block device (eg.
11435       /dev/sda), just to a partition.  This appears to be a limitation of the
11436       kernel or swap tools.
11437
11438       This function returns 0 on success or -1 on error.
11439
11440       (Added in 1.0.55)
11441
11442   guestfs_mkswap_U
11443        int
11444        guestfs_mkswap_U (guestfs_h *g,
11445                          const char *uuid,
11446                          const char *device);
11447
11448       This function is deprecated.  In new code, use the "guestfs_mkswap"
11449       call instead.
11450
11451       Deprecated functions will not be removed from the API, but the fact
11452       that they are deprecated indicates that there are problems with correct
11453       use of these functions.
11454
11455       Create a swap partition on "device" with UUID "uuid".
11456
11457       This function returns 0 on success or -1 on error.
11458
11459       This function depends on the feature "linuxfsuuid".  See also
11460       "guestfs_feature_available".
11461
11462       (Added in 1.0.55)
11463
11464   guestfs_mkswap_file
11465        int
11466        guestfs_mkswap_file (guestfs_h *g,
11467                             const char *path);
11468
11469       Create a swap file.
11470
11471       This command just writes a swap file signature to an existing file.  To
11472       create the file itself, use something like "guestfs_fallocate".
11473
11474       This function returns 0 on success or -1 on error.
11475
11476       (Added in 1.0.66)
11477
11478   guestfs_mktemp
11479        char *
11480        guestfs_mktemp (guestfs_h *g,
11481                        const char *tmpl,
11482                        ...);
11483
11484       You may supply a list of optional arguments to this call.  Use zero or
11485       more of the following pairs of parameters, and terminate the list with
11486       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11487
11488        GUESTFS_MKTEMP_SUFFIX, const char *suffix,
11489
11490       This command creates a temporary file.  The "tmpl" parameter should be
11491       a full pathname for the temporary directory name with the final six
11492       characters being "XXXXXX".
11493
11494       For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second
11495       one being suitable for Windows filesystems.
11496
11497       The name of the temporary file that was created is returned.
11498
11499       The temporary file is created with mode 0600 and is owned by root.
11500
11501       The caller is responsible for deleting the temporary file after use.
11502
11503       If the optional "suffix" parameter is given, then the suffix (eg.
11504       ".txt") is appended to the temporary name.
11505
11506       See also: "guestfs_mkdtemp".
11507
11508       This function returns a string, or NULL on error.  The caller must free
11509       the returned string after use.
11510
11511       (Added in 1.19.53)
11512
11513   guestfs_mktemp_va
11514        char *
11515        guestfs_mktemp_va (guestfs_h *g,
11516                           const char *tmpl,
11517                           va_list args);
11518
11519       This is the "va_list variant" of "guestfs_mktemp".
11520
11521       See "CALLS WITH OPTIONAL ARGUMENTS".
11522
11523   guestfs_mktemp_argv
11524        char *
11525        guestfs_mktemp_argv (guestfs_h *g,
11526                             const char *tmpl,
11527                             const struct guestfs_mktemp_argv *optargs);
11528
11529       This is the "argv variant" of "guestfs_mktemp".
11530
11531       See "CALLS WITH OPTIONAL ARGUMENTS".
11532
11533   guestfs_modprobe
11534        int
11535        guestfs_modprobe (guestfs_h *g,
11536                          const char *modulename);
11537
11538       This loads a kernel module in the appliance.
11539
11540       This function returns 0 on success or -1 on error.
11541
11542       This function depends on the feature "linuxmodules".  See also
11543       "guestfs_feature_available".
11544
11545       (Added in 1.0.68)
11546
11547   guestfs_mount
11548        int
11549        guestfs_mount (guestfs_h *g,
11550                       const char *mountable,
11551                       const char *mountpoint);
11552
11553       Mount a guest disk at a position in the filesystem.  Block devices are
11554       named /dev/sda, /dev/sdb and so on, as they were added to the guest.
11555       If those block devices contain partitions, they will have the usual
11556       names (eg. /dev/sda1).  Also LVM /dev/VG/LV-style names can be used, or
11557       ‘mountable’ strings returned by "guestfs_list_filesystems" or
11558       "guestfs_inspect_get_mountpoints".
11559
11560       The rules are the same as for mount(2):  A filesystem must first be
11561       mounted on / before others can be mounted.  Other filesystems can only
11562       be mounted on directories which already exist.
11563
11564       The mounted filesystem is writable, if we have sufficient permissions
11565       on the underlying device.
11566
11567       Before libguestfs 1.13.16, this call implicitly added the options
11568       "sync" and "noatime".  The "sync" option greatly slowed writes and
11569       caused many problems for users.  If your program might need to work
11570       with older versions of libguestfs, use "guestfs_mount_options" instead
11571       (using an empty string for the first parameter if you don't want any
11572       options).
11573
11574       This function returns 0 on success or -1 on error.
11575
11576       (Added in 0.3)
11577
11578   guestfs_mount_9p
11579        int
11580        guestfs_mount_9p (guestfs_h *g,
11581                          const char *mounttag,
11582                          const char *mountpoint,
11583                          ...);
11584
11585       You may supply a list of optional arguments to this call.  Use zero or
11586       more of the following pairs of parameters, and terminate the list with
11587       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11588
11589        GUESTFS_MOUNT_9P_OPTIONS, const char *options,
11590
11591       Mount the virtio-9p filesystem with the tag "mounttag" on the directory
11592       "mountpoint".
11593
11594       If required, "trans=virtio" will be automatically added to the options.
11595       Any other options required can be passed in the optional "options"
11596       parameter.
11597
11598       This function returns 0 on success or -1 on error.
11599
11600       (Added in 1.11.12)
11601
11602   guestfs_mount_9p_va
11603        int
11604        guestfs_mount_9p_va (guestfs_h *g,
11605                             const char *mounttag,
11606                             const char *mountpoint,
11607                             va_list args);
11608
11609       This is the "va_list variant" of "guestfs_mount_9p".
11610
11611       See "CALLS WITH OPTIONAL ARGUMENTS".
11612
11613   guestfs_mount_9p_argv
11614        int
11615        guestfs_mount_9p_argv (guestfs_h *g,
11616                               const char *mounttag,
11617                               const char *mountpoint,
11618                               const struct guestfs_mount_9p_argv *optargs);
11619
11620       This is the "argv variant" of "guestfs_mount_9p".
11621
11622       See "CALLS WITH OPTIONAL ARGUMENTS".
11623
11624   guestfs_mount_local
11625        int
11626        guestfs_mount_local (guestfs_h *g,
11627                             const char *localmountpoint,
11628                             ...);
11629
11630       You may supply a list of optional arguments to this call.  Use zero or
11631       more of the following pairs of parameters, and terminate the list with
11632       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11633
11634        GUESTFS_MOUNT_LOCAL_READONLY, int readonly,
11635        GUESTFS_MOUNT_LOCAL_OPTIONS, const char *options,
11636        GUESTFS_MOUNT_LOCAL_CACHETIMEOUT, int cachetimeout,
11637        GUESTFS_MOUNT_LOCAL_DEBUGCALLS, int debugcalls,
11638
11639       This call exports the libguestfs-accessible filesystem to a local
11640       mountpoint (directory) called "localmountpoint".  Ordinary reads and
11641       writes to files and directories under "localmountpoint" are redirected
11642       through libguestfs.
11643
11644       If the optional "readonly" flag is set to true, then writes to the
11645       filesystem return error "EROFS".
11646
11647       "options" is a comma-separated list of mount options.  See
11648       guestmount(1) for some useful options.
11649
11650       "cachetimeout" sets the timeout (in seconds) for cached directory
11651       entries.  The default is 60 seconds.  See guestmount(1) for further
11652       information.
11653
11654       If "debugcalls" is set to true, then additional debugging information
11655       is generated for every FUSE call.
11656
11657       When "guestfs_mount_local" returns, the filesystem is ready, but is not
11658       processing requests (access to it will block).  You have to call
11659       "guestfs_mount_local_run" to run the main loop.
11660
11661       See "MOUNT LOCAL" for full documentation.
11662
11663       This function returns 0 on success or -1 on error.
11664
11665       (Added in 1.17.22)
11666
11667   guestfs_mount_local_va
11668        int
11669        guestfs_mount_local_va (guestfs_h *g,
11670                                const char *localmountpoint,
11671                                va_list args);
11672
11673       This is the "va_list variant" of "guestfs_mount_local".
11674
11675       See "CALLS WITH OPTIONAL ARGUMENTS".
11676
11677   guestfs_mount_local_argv
11678        int
11679        guestfs_mount_local_argv (guestfs_h *g,
11680                                  const char *localmountpoint,
11681                                  const struct guestfs_mount_local_argv *optargs);
11682
11683       This is the "argv variant" of "guestfs_mount_local".
11684
11685       See "CALLS WITH OPTIONAL ARGUMENTS".
11686
11687   guestfs_mount_local_run
11688        int
11689        guestfs_mount_local_run (guestfs_h *g);
11690
11691       Run the main loop which translates kernel calls to libguestfs calls.
11692
11693       This should only be called after "guestfs_mount_local" returns
11694       successfully.  The call will not return until the filesystem is
11695       unmounted.
11696
11697       Note you must not make concurrent libguestfs calls on the same handle
11698       from another thread.
11699
11700       You may call this from a different thread than the one which called
11701       "guestfs_mount_local", subject to the usual rules for threads and
11702       libguestfs (see "MULTIPLE HANDLES AND MULTIPLE THREADS").
11703
11704       See "MOUNT LOCAL" for full documentation.
11705
11706       This function returns 0 on success or -1 on error.
11707
11708       (Added in 1.17.22)
11709
11710   guestfs_mount_loop
11711        int
11712        guestfs_mount_loop (guestfs_h *g,
11713                            const char *file,
11714                            const char *mountpoint);
11715
11716       This command lets you mount file (a filesystem image in a file) on a
11717       mount point.  It is entirely equivalent to the command "mount -o loop
11718       file mountpoint".
11719
11720       This function returns 0 on success or -1 on error.
11721
11722       (Added in 1.0.54)
11723
11724   guestfs_mount_options
11725        int
11726        guestfs_mount_options (guestfs_h *g,
11727                               const char *options,
11728                               const char *mountable,
11729                               const char *mountpoint);
11730
11731       This is the same as the "guestfs_mount" command, but it allows you to
11732       set the mount options as for the mount(8) -o flag.
11733
11734       If the "options" parameter is an empty string, then no options are
11735       passed (all options default to whatever the filesystem uses).
11736
11737       This function returns 0 on success or -1 on error.
11738
11739       (Added in 1.0.10)
11740
11741   guestfs_mount_ro
11742        int
11743        guestfs_mount_ro (guestfs_h *g,
11744                          const char *mountable,
11745                          const char *mountpoint);
11746
11747       This is the same as the "guestfs_mount" command, but it mounts the
11748       filesystem with the read-only (-o ro) flag.
11749
11750       This function returns 0 on success or -1 on error.
11751
11752       (Added in 1.0.10)
11753
11754   guestfs_mount_vfs
11755        int
11756        guestfs_mount_vfs (guestfs_h *g,
11757                           const char *options,
11758                           const char *vfstype,
11759                           const char *mountable,
11760                           const char *mountpoint);
11761
11762       This is the same as the "guestfs_mount" command, but it allows you to
11763       set both the mount options and the vfstype as for the mount(8) -o and
11764       -t flags.
11765
11766       This function returns 0 on success or -1 on error.
11767
11768       (Added in 1.0.10)
11769
11770   guestfs_mountable_device
11771        char *
11772        guestfs_mountable_device (guestfs_h *g,
11773                                  const char *mountable);
11774
11775       Returns the device name of a mountable. In quite a lot of cases, the
11776       mountable is the device name.
11777
11778       However this doesn't apply for btrfs subvolumes, where the mountable is
11779       a combination of both the device name and the subvolume path (see also
11780       "guestfs_mountable_subvolume" to extract the subvolume path of the
11781       mountable if any).
11782
11783       This function returns a string, or NULL on error.  The caller must free
11784       the returned string after use.
11785
11786       (Added in 1.33.15)
11787
11788   guestfs_mountable_subvolume
11789        char *
11790        guestfs_mountable_subvolume (guestfs_h *g,
11791                                     const char *mountable);
11792
11793       Returns the subvolume path of a mountable. Btrfs subvolumes mountables
11794       are a combination of both the device name and the subvolume path (see
11795       also "guestfs_mountable_device" to extract the device of the
11796       mountable).
11797
11798       If the mountable does not represent a btrfs subvolume, then this
11799       function fails and the "errno" is set to "EINVAL".
11800
11801       This function returns a string, or NULL on error.  The caller must free
11802       the returned string after use.
11803
11804       (Added in 1.33.15)
11805
11806   guestfs_mountpoints
11807        char **
11808        guestfs_mountpoints (guestfs_h *g);
11809
11810       This call is similar to "guestfs_mounts".  That call returns a list of
11811       devices.  This one returns a hash table (map) of device name to
11812       directory where the device is mounted.
11813
11814       This function returns a NULL-terminated array of strings, or NULL if
11815       there was an error.  The array of strings will always have length
11816       "2n+1", where "n" keys and values alternate, followed by the trailing
11817       NULL entry.  The caller must free the strings and the array after use.
11818
11819       (Added in 1.0.62)
11820
11821   guestfs_mounts
11822        char **
11823        guestfs_mounts (guestfs_h *g);
11824
11825       This returns the list of currently mounted filesystems.  It returns the
11826       list of devices (eg. /dev/sda1, /dev/VG/LV).
11827
11828       Some internal mounts are not shown.
11829
11830       See also: "guestfs_mountpoints"
11831
11832       This function returns a NULL-terminated array of strings (like
11833       environ(3)), or NULL if there was an error.  The caller must free the
11834       strings and the array after use.
11835
11836       (Added in 0.8)
11837
11838   guestfs_mv
11839        int
11840        guestfs_mv (guestfs_h *g,
11841                    const char *src,
11842                    const char *dest);
11843
11844       This moves a file from "src" to "dest" where "dest" is either a
11845       destination filename or destination directory.
11846
11847       See also: "guestfs_rename".
11848
11849       This function returns 0 on success or -1 on error.
11850
11851       (Added in 1.0.18)
11852
11853   guestfs_nr_devices
11854        int
11855        guestfs_nr_devices (guestfs_h *g);
11856
11857       This returns the number of whole block devices that were added.  This
11858       is the same as the number of devices that would be returned if you
11859       called "guestfs_list_devices".
11860
11861       To find out the maximum number of devices that could be added, call
11862       "guestfs_max_disks".
11863
11864       On error this function returns -1.
11865
11866       (Added in 1.19.15)
11867
11868   guestfs_ntfs_3g_probe
11869        int
11870        guestfs_ntfs_3g_probe (guestfs_h *g,
11871                               int rw,
11872                               const char *device);
11873
11874       This command runs the ntfs-3g.probe(8) command which probes an NTFS
11875       "device" for mountability.  (Not all NTFS volumes can be mounted read-
11876       write, and some cannot be mounted at all).
11877
11878       "rw" is a boolean flag.  Set it to true if you want to test if the
11879       volume can be mounted read-write.  Set it to false if you want to test
11880       if the volume can be mounted read-only.
11881
11882       The return value is an integer which 0 if the operation would succeed,
11883       or some non-zero value documented in the ntfs-3g.probe(8) manual page.
11884
11885       On error this function returns -1.
11886
11887       This function depends on the feature "ntfs3g".  See also
11888       "guestfs_feature_available".
11889
11890       (Added in 1.0.43)
11891
11892   guestfs_ntfscat_i
11893        int
11894        guestfs_ntfscat_i (guestfs_h *g,
11895                           const char *device,
11896                           int64_t inode,
11897                           const char *filename);
11898
11899       Download a file given its inode from a NTFS filesystem and save it as
11900       filename on the local machine.
11901
11902       This allows to download some otherwise inaccessible files such as the
11903       ones within the $Extend folder.
11904
11905       The filesystem from which to extract the file must be unmounted,
11906       otherwise the call will fail.
11907
11908       This function returns 0 on success or -1 on error.
11909
11910       This long-running command can generate progress notification messages
11911       so that the caller can display a progress bar or indicator.  To receive
11912       these messages, the caller must register a progress event callback.
11913       See "GUESTFS_EVENT_PROGRESS".
11914
11915       (Added in 1.33.14)
11916
11917   guestfs_ntfsclone_in
11918        int
11919        guestfs_ntfsclone_in (guestfs_h *g,
11920                              const char *backupfile,
11921                              const char *device);
11922
11923       Restore the "backupfile" (from a previous call to
11924       "guestfs_ntfsclone_out") to "device", overwriting any existing contents
11925       of this device.
11926
11927       This function returns 0 on success or -1 on error.
11928
11929       This function depends on the feature "ntfs3g".  See also
11930       "guestfs_feature_available".
11931
11932       (Added in 1.17.9)
11933
11934   guestfs_ntfsclone_out
11935        int
11936        guestfs_ntfsclone_out (guestfs_h *g,
11937                               const char *device,
11938                               const char *backupfile,
11939                               ...);
11940
11941       You may supply a list of optional arguments to this call.  Use zero or
11942       more of the following pairs of parameters, and terminate the list with
11943       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
11944
11945        GUESTFS_NTFSCLONE_OUT_METADATAONLY, int metadataonly,
11946        GUESTFS_NTFSCLONE_OUT_RESCUE, int rescue,
11947        GUESTFS_NTFSCLONE_OUT_IGNOREFSCHECK, int ignorefscheck,
11948        GUESTFS_NTFSCLONE_OUT_PRESERVETIMESTAMPS, int preservetimestamps,
11949        GUESTFS_NTFSCLONE_OUT_FORCE, int force,
11950
11951       Stream the NTFS filesystem "device" to the local file "backupfile".
11952       The format used for the backup file is a special format used by the
11953       ntfsclone(8) tool.
11954
11955       If the optional "metadataonly" flag is true, then only the metadata is
11956       saved, losing all the user data (this is useful for diagnosing some
11957       filesystem problems).
11958
11959       The optional "rescue", "ignorefscheck", "preservetimestamps" and
11960       "force" flags have precise meanings detailed in the ntfsclone(8) man
11961       page.
11962
11963       Use "guestfs_ntfsclone_in" to restore the file back to a libguestfs
11964       device.
11965
11966       This function returns 0 on success or -1 on error.
11967
11968       This function depends on the feature "ntfs3g".  See also
11969       "guestfs_feature_available".
11970
11971       (Added in 1.17.9)
11972
11973   guestfs_ntfsclone_out_va
11974        int
11975        guestfs_ntfsclone_out_va (guestfs_h *g,
11976                                  const char *device,
11977                                  const char *backupfile,
11978                                  va_list args);
11979
11980       This is the "va_list variant" of "guestfs_ntfsclone_out".
11981
11982       See "CALLS WITH OPTIONAL ARGUMENTS".
11983
11984   guestfs_ntfsclone_out_argv
11985        int
11986        guestfs_ntfsclone_out_argv (guestfs_h *g,
11987                                    const char *device,
11988                                    const char *backupfile,
11989                                    const struct guestfs_ntfsclone_out_argv *optargs);
11990
11991       This is the "argv variant" of "guestfs_ntfsclone_out".
11992
11993       See "CALLS WITH OPTIONAL ARGUMENTS".
11994
11995   guestfs_ntfsfix
11996        int
11997        guestfs_ntfsfix (guestfs_h *g,
11998                         const char *device,
11999                         ...);
12000
12001       You may supply a list of optional arguments to this call.  Use zero or
12002       more of the following pairs of parameters, and terminate the list with
12003       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
12004
12005        GUESTFS_NTFSFIX_CLEARBADSECTORS, int clearbadsectors,
12006
12007       This command repairs some fundamental NTFS inconsistencies, resets the
12008       NTFS journal file, and schedules an NTFS consistency check for the
12009       first boot into Windows.
12010
12011       This is not an equivalent of Windows "chkdsk".  It does not scan the
12012       filesystem for inconsistencies.
12013
12014       The optional "clearbadsectors" flag clears the list of bad sectors.
12015       This is useful after cloning a disk with bad sectors to a new disk.
12016
12017       This function returns 0 on success or -1 on error.
12018
12019       This function depends on the feature "ntfs3g".  See also
12020       "guestfs_feature_available".
12021
12022       (Added in 1.17.9)
12023
12024   guestfs_ntfsfix_va
12025        int
12026        guestfs_ntfsfix_va (guestfs_h *g,
12027                            const char *device,
12028                            va_list args);
12029
12030       This is the "va_list variant" of "guestfs_ntfsfix".
12031
12032       See "CALLS WITH OPTIONAL ARGUMENTS".
12033
12034   guestfs_ntfsfix_argv
12035        int
12036        guestfs_ntfsfix_argv (guestfs_h *g,
12037                              const char *device,
12038                              const struct guestfs_ntfsfix_argv *optargs);
12039
12040       This is the "argv variant" of "guestfs_ntfsfix".
12041
12042       See "CALLS WITH OPTIONAL ARGUMENTS".
12043
12044   guestfs_ntfsresize
12045        int
12046        guestfs_ntfsresize (guestfs_h *g,
12047                            const char *device);
12048
12049       This function is provided for backwards compatibility with earlier
12050       versions of libguestfs.  It simply calls "guestfs_ntfsresize_opts" with
12051       no optional arguments.
12052
12053       (Added in 1.3.2)
12054
12055   guestfs_ntfsresize_opts
12056        int
12057        guestfs_ntfsresize_opts (guestfs_h *g,
12058                                 const char *device,
12059                                 ...);
12060
12061       You may supply a list of optional arguments to this call.  Use zero or
12062       more of the following pairs of parameters, and terminate the list with
12063       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
12064
12065        GUESTFS_NTFSRESIZE_OPTS_SIZE, int64_t size,
12066        GUESTFS_NTFSRESIZE_OPTS_FORCE, int force,
12067
12068       This command resizes an NTFS filesystem, expanding or shrinking it to
12069       the size of the underlying device.
12070
12071       The optional parameters are:
12072
12073       "size"
12074           The new size (in bytes) of the filesystem.  If omitted, the
12075           filesystem is resized to fit the container (eg. partition).
12076
12077       "force"
12078           If this option is true, then force the resize of the filesystem
12079           even if the filesystem is marked as requiring a consistency check.
12080
12081           After the resize operation, the filesystem is always marked as
12082           requiring a consistency check (for safety).  You have to boot into
12083           Windows to perform this check and clear this condition.  If you
12084           don't set the "force" option then it is not possible to call
12085           "guestfs_ntfsresize" multiple times on a single filesystem without
12086           booting into Windows between each resize.
12087
12088       See also ntfsresize(8).
12089
12090       This function returns 0 on success or -1 on error.
12091
12092       This function depends on the feature "ntfsprogs".  See also
12093       "guestfs_feature_available".
12094
12095       (Added in 1.3.2)
12096
12097   guestfs_ntfsresize_opts_va
12098        int
12099        guestfs_ntfsresize_opts_va (guestfs_h *g,
12100                                    const char *device,
12101                                    va_list args);
12102
12103       This is the "va_list variant" of "guestfs_ntfsresize_opts".
12104
12105       See "CALLS WITH OPTIONAL ARGUMENTS".
12106
12107   guestfs_ntfsresize_opts_argv
12108        int
12109        guestfs_ntfsresize_opts_argv (guestfs_h *g,
12110                                      const char *device,
12111                                      const struct guestfs_ntfsresize_opts_argv *optargs);
12112
12113       This is the "argv variant" of "guestfs_ntfsresize_opts".
12114
12115       See "CALLS WITH OPTIONAL ARGUMENTS".
12116
12117   guestfs_ntfsresize_size
12118        int
12119        guestfs_ntfsresize_size (guestfs_h *g,
12120                                 const char *device,
12121                                 int64_t size);
12122
12123       This function is deprecated.  In new code, use the "guestfs_ntfsresize"
12124       call instead.
12125
12126       Deprecated functions will not be removed from the API, but the fact
12127       that they are deprecated indicates that there are problems with correct
12128       use of these functions.
12129
12130       This command is the same as "guestfs_ntfsresize" except that it allows
12131       you to specify the new size (in bytes) explicitly.
12132
12133       This function returns 0 on success or -1 on error.
12134
12135       This function depends on the feature "ntfsprogs".  See also
12136       "guestfs_feature_available".
12137
12138       (Added in 1.3.14)
12139
12140   guestfs_parse_environment
12141        int
12142        guestfs_parse_environment (guestfs_h *g);
12143
12144       Parse the program’s environment and set flags in the handle
12145       accordingly.  For example if "LIBGUESTFS_DEBUG=1" then the ‘verbose’
12146       flag is set in the handle.
12147
12148       Most programs do not need to call this.  It is done implicitly when you
12149       call "guestfs_create".
12150
12151       See "ENVIRONMENT VARIABLES" for a list of environment variables that
12152       can affect libguestfs handles.  See also "guestfs_create_flags", and
12153       "guestfs_parse_environment_list".
12154
12155       This function returns 0 on success or -1 on error.
12156
12157       (Added in 1.19.53)
12158
12159   guestfs_parse_environment_list
12160        int
12161        guestfs_parse_environment_list (guestfs_h *g,
12162                                        char *const *environment);
12163
12164       Parse the list of strings in the argument "environment" and set flags
12165       in the handle accordingly.  For example if "LIBGUESTFS_DEBUG=1" is a
12166       string in the list, then the ‘verbose’ flag is set in the handle.
12167
12168       This is the same as "guestfs_parse_environment" except that it parses
12169       an explicit list of strings instead of the program's environment.
12170
12171       This function returns 0 on success or -1 on error.
12172
12173       (Added in 1.19.53)
12174
12175   guestfs_part_add
12176        int
12177        guestfs_part_add (guestfs_h *g,
12178                          const char *device,
12179                          const char *prlogex,
12180                          int64_t startsect,
12181                          int64_t endsect);
12182
12183       This command adds a partition to "device".  If there is no partition
12184       table on the device, call "guestfs_part_init" first.
12185
12186       The "prlogex" parameter is the type of partition.  Normally you should
12187       pass "p" or "primary" here, but MBR partition tables also support "l"
12188       (or "logical") and "e" (or "extended") partition types.
12189
12190       "startsect" and "endsect" are the start and end of the partition in
12191       sectors.  "endsect" may be negative, which means it counts backwards
12192       from the end of the disk ("-1" is the last sector).
12193
12194       Creating a partition which covers the whole disk is not so easy.  Use
12195       "guestfs_part_disk" to do that.
12196
12197       This function returns 0 on success or -1 on error.
12198
12199       (Added in 1.0.78)
12200
12201   guestfs_part_del
12202        int
12203        guestfs_part_del (guestfs_h *g,
12204                          const char *device,
12205                          int partnum);
12206
12207       This command deletes the partition numbered "partnum" on "device".
12208
12209       Note that in the case of MBR partitioning, deleting an extended
12210       partition also deletes any logical partitions it contains.
12211
12212       This function returns 0 on success or -1 on error.
12213
12214       (Added in 1.3.2)
12215
12216   guestfs_part_disk
12217        int
12218        guestfs_part_disk (guestfs_h *g,
12219                           const char *device,
12220                           const char *parttype);
12221
12222       This command is simply a combination of "guestfs_part_init" followed by
12223       "guestfs_part_add" to create a single primary partition covering the
12224       whole disk.
12225
12226       "parttype" is the partition table type, usually "mbr" or "gpt", but
12227       other possible values are described in "guestfs_part_init".
12228
12229       This function returns 0 on success or -1 on error.
12230
12231       (Added in 1.0.78)
12232
12233   guestfs_part_expand_gpt
12234        int
12235        guestfs_part_expand_gpt (guestfs_h *g,
12236                                 const char *device);
12237
12238       Move backup GPT data structures to the end of the disk.  This is useful
12239       in case of in-place image expand since disk space after backup GPT
12240       header is not usable.  This is equivalent to "sgdisk -e".
12241
12242       See also sgdisk(8).
12243
12244       This function returns 0 on success or -1 on error.
12245
12246       This function depends on the feature "gdisk".  See also
12247       "guestfs_feature_available".
12248
12249       (Added in 1.33.2)
12250
12251   guestfs_part_get_bootable
12252        int
12253        guestfs_part_get_bootable (guestfs_h *g,
12254                                   const char *device,
12255                                   int partnum);
12256
12257       This command returns true if the partition "partnum" on "device" has
12258       the bootable flag set.
12259
12260       See also "guestfs_part_set_bootable".
12261
12262       This function returns a C truth value on success or -1 on error.
12263
12264       (Added in 1.3.2)
12265
12266   guestfs_part_get_disk_guid
12267        char *
12268        guestfs_part_get_disk_guid (guestfs_h *g,
12269                                    const char *device);
12270
12271       Return the disk identifier (GUID) of a GPT-partitioned "device".
12272       Behaviour is undefined for other partition types.
12273
12274       This function returns a string, or NULL on error.  The caller must free
12275       the returned string after use.
12276
12277       This function depends on the feature "gdisk".  See also
12278       "guestfs_feature_available".
12279
12280       (Added in 1.33.2)
12281
12282   guestfs_part_get_gpt_attributes
12283        int64_t
12284        guestfs_part_get_gpt_attributes (guestfs_h *g,
12285                                         const char *device,
12286                                         int partnum);
12287
12288       Return the attribute flags of numbered GPT partition "partnum".  An
12289       error is returned for MBR partitions.
12290
12291       On error this function returns -1.
12292
12293       This function depends on the feature "gdisk".  See also
12294       "guestfs_feature_available".
12295
12296       (Added in 1.21.1)
12297
12298   guestfs_part_get_gpt_guid
12299        char *
12300        guestfs_part_get_gpt_guid (guestfs_h *g,
12301                                   const char *device,
12302                                   int partnum);
12303
12304       Return the GUID of numbered GPT partition "partnum".
12305
12306       This function returns a string, or NULL on error.  The caller must free
12307       the returned string after use.
12308
12309       This function depends on the feature "gdisk".  See also
12310       "guestfs_feature_available".
12311
12312       (Added in 1.29.25)
12313
12314   guestfs_part_get_gpt_type
12315        char *
12316        guestfs_part_get_gpt_type (guestfs_h *g,
12317                                   const char *device,
12318                                   int partnum);
12319
12320       Return the type GUID of numbered GPT partition "partnum". For MBR
12321       partitions, return an appropriate GUID corresponding to the MBR type.
12322       Behaviour is undefined for other partition types.
12323
12324       This function returns a string, or NULL on error.  The caller must free
12325       the returned string after use.
12326
12327       This function depends on the feature "gdisk".  See also
12328       "guestfs_feature_available".
12329
12330       (Added in 1.21.1)
12331
12332   guestfs_part_get_mbr_id
12333        int
12334        guestfs_part_get_mbr_id (guestfs_h *g,
12335                                 const char *device,
12336                                 int partnum);
12337
12338       Returns the MBR type byte (also known as the ID byte) from the numbered
12339       partition "partnum".
12340
12341       Note that only MBR (old DOS-style) partitions have type bytes.  You
12342       will get undefined results for other partition table types (see
12343       "guestfs_part_get_parttype").
12344
12345       On error this function returns -1.
12346
12347       (Added in 1.3.2)
12348
12349   guestfs_part_get_mbr_part_type
12350        char *
12351        guestfs_part_get_mbr_part_type (guestfs_h *g,
12352                                        const char *device,
12353                                        int partnum);
12354
12355       This returns the partition type of an MBR partition numbered "partnum"
12356       on device "device".
12357
12358       It returns "primary", "logical", or "extended".
12359
12360       This function returns a string, or NULL on error.  The caller must free
12361       the returned string after use.
12362
12363       (Added in 1.29.32)
12364
12365   guestfs_part_get_name
12366        char *
12367        guestfs_part_get_name (guestfs_h *g,
12368                               const char *device,
12369                               int partnum);
12370
12371       This gets the partition name on partition numbered "partnum" on device
12372       "device".  Note that partitions are numbered from 1.
12373
12374       The partition name can only be read on certain types of partition
12375       table.  This works on "gpt" but not on "mbr" partitions.
12376
12377       This function returns a string, or NULL on error.  The caller must free
12378       the returned string after use.
12379
12380       (Added in 1.25.33)
12381
12382   guestfs_part_get_parttype
12383        char *
12384        guestfs_part_get_parttype (guestfs_h *g,
12385                                   const char *device);
12386
12387       This command examines the partition table on "device" and returns the
12388       partition table type (format) being used.
12389
12390       Common return values include: "msdos" (a DOS/Windows style MBR
12391       partition table), "gpt" (a GPT/EFI-style partition table).  Other
12392       values are possible, although unusual.  See "guestfs_part_init" for a
12393       full list.
12394
12395       This function returns a string, or NULL on error.  The caller must free
12396       the returned string after use.
12397
12398       (Added in 1.0.78)
12399
12400   guestfs_part_init
12401        int
12402        guestfs_part_init (guestfs_h *g,
12403                           const char *device,
12404                           const char *parttype);
12405
12406       This creates an empty partition table on "device" of one of the
12407       partition types listed below.  Usually "parttype" should be either
12408       "msdos" or "gpt" (for large disks).
12409
12410       Initially there are no partitions.  Following this, you should call
12411       "guestfs_part_add" for each partition required.
12412
12413       Possible values for "parttype" are:
12414
12415       "efi"
12416       "gpt"
12417           Intel EFI / GPT partition table.
12418
12419           This is recommended for >= 2 TB partitions that will be accessed
12420           from Linux and Intel-based Mac OS X.  It also has limited backwards
12421           compatibility with the "mbr" format.
12422
12423       "mbr"
12424       "msdos"
12425           The standard PC "Master Boot Record" (MBR) format used by MS-DOS
12426           and Windows.  This partition type will only work for device sizes
12427           up to 2 TB.  For large disks we recommend using "gpt".
12428
12429       Other partition table types that may work but are not supported
12430       include:
12431
12432       "aix"
12433           AIX disk labels.
12434
12435       "amiga"
12436       "rdb"
12437           Amiga "Rigid Disk Block" format.
12438
12439       "bsd"
12440           BSD disk labels.
12441
12442       "dasd"
12443           DASD, used on IBM mainframes.
12444
12445       "dvh"
12446           MIPS/SGI volumes.
12447
12448       "mac"
12449           Old Mac partition format.  Modern Macs use "gpt".
12450
12451       "pc98"
12452           NEC PC-98 format, common in Japan apparently.
12453
12454       "sun"
12455           Sun disk labels.
12456
12457       This function returns 0 on success or -1 on error.
12458
12459       (Added in 1.0.78)
12460
12461   guestfs_part_list
12462        struct guestfs_partition_list *
12463        guestfs_part_list (guestfs_h *g,
12464                           const char *device);
12465
12466       This command parses the partition table on "device" and returns the
12467       list of partitions found.
12468
12469       The fields in the returned structure are:
12470
12471       "part_num"
12472           Partition number, counting from 1.
12473
12474       "part_start"
12475           Start of the partition in bytes.  To get sectors you have to divide
12476           by the device’s sector size, see "guestfs_blockdev_getss".
12477
12478       "part_end"
12479           End of the partition in bytes.
12480
12481       "part_size"
12482           Size of the partition in bytes.
12483
12484       This function returns a "struct guestfs_partition_list *", or NULL if
12485       there was an error.  The caller must call "guestfs_free_partition_list"
12486       after use.
12487
12488       (Added in 1.0.78)
12489
12490   guestfs_part_resize
12491        int
12492        guestfs_part_resize (guestfs_h *g,
12493                             const char *device,
12494                             int partnum,
12495                             int64_t endsect);
12496
12497       This command resizes the partition numbered "partnum" on "device" by
12498       moving the end position.
12499
12500       Note that this does not modify any filesystem present in the partition.
12501       If you wish to do this, you will need to use filesystem resizing
12502       commands like "guestfs_resize2fs".
12503
12504       When growing a partition you will want to grow the filesystem
12505       afterwards, but when shrinking, you need to shrink the filesystem
12506       before the partition.
12507
12508       This function returns 0 on success or -1 on error.
12509
12510       (Added in 1.37.20)
12511
12512   guestfs_part_set_bootable
12513        int
12514        guestfs_part_set_bootable (guestfs_h *g,
12515                                   const char *device,
12516                                   int partnum,
12517                                   int bootable);
12518
12519       This sets the bootable flag on partition numbered "partnum" on device
12520       "device".  Note that partitions are numbered from 1.
12521
12522       The bootable flag is used by some operating systems (notably Windows)
12523       to determine which partition to boot from.  It is by no means
12524       universally recognized.
12525
12526       This function returns 0 on success or -1 on error.
12527
12528       (Added in 1.0.78)
12529
12530   guestfs_part_set_disk_guid
12531        int
12532        guestfs_part_set_disk_guid (guestfs_h *g,
12533                                    const char *device,
12534                                    const char *guid);
12535
12536       Set the disk identifier (GUID) of a GPT-partitioned "device" to "guid".
12537       Return an error if the partition table of "device" isn't GPT, or if
12538       "guid" is not a valid GUID.
12539
12540       This function returns 0 on success or -1 on error.
12541
12542       This function depends on the feature "gdisk".  See also
12543       "guestfs_feature_available".
12544
12545       (Added in 1.33.2)
12546
12547   guestfs_part_set_disk_guid_random
12548        int
12549        guestfs_part_set_disk_guid_random (guestfs_h *g,
12550                                           const char *device);
12551
12552       Set the disk identifier (GUID) of a GPT-partitioned "device" to a
12553       randomly generated value.  Return an error if the partition table of
12554       "device" isn't GPT.
12555
12556       This function returns 0 on success or -1 on error.
12557
12558       This function depends on the feature "gdisk".  See also
12559       "guestfs_feature_available".
12560
12561       (Added in 1.33.2)
12562
12563   guestfs_part_set_gpt_attributes
12564        int
12565        guestfs_part_set_gpt_attributes (guestfs_h *g,
12566                                         const char *device,
12567                                         int partnum,
12568                                         int64_t attributes);
12569
12570       Set the attribute flags of numbered GPT partition "partnum" to
12571       "attributes". Return an error if the partition table of "device" isn't
12572       GPT.
12573
12574       See
12575       https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries
12576       for a useful list of partition attributes.
12577
12578       This function returns 0 on success or -1 on error.
12579
12580       This function depends on the feature "gdisk".  See also
12581       "guestfs_feature_available".
12582
12583       (Added in 1.21.1)
12584
12585   guestfs_part_set_gpt_guid
12586        int
12587        guestfs_part_set_gpt_guid (guestfs_h *g,
12588                                   const char *device,
12589                                   int partnum,
12590                                   const char *guid);
12591
12592       Set the GUID of numbered GPT partition "partnum" to "guid".  Return an
12593       error if the partition table of "device" isn't GPT, or if "guid" is not
12594       a valid GUID.
12595
12596       This function returns 0 on success or -1 on error.
12597
12598       This function depends on the feature "gdisk".  See also
12599       "guestfs_feature_available".
12600
12601       (Added in 1.29.25)
12602
12603   guestfs_part_set_gpt_type
12604        int
12605        guestfs_part_set_gpt_type (guestfs_h *g,
12606                                   const char *device,
12607                                   int partnum,
12608                                   const char *guid);
12609
12610       Set the type GUID of numbered GPT partition "partnum" to "guid". Return
12611       an error if the partition table of "device" isn't GPT, or if "guid" is
12612       not a valid GUID.
12613
12614       See
12615       https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
12616       for a useful list of type GUIDs.
12617
12618       This function returns 0 on success or -1 on error.
12619
12620       This function depends on the feature "gdisk".  See also
12621       "guestfs_feature_available".
12622
12623       (Added in 1.21.1)
12624
12625   guestfs_part_set_mbr_id
12626        int
12627        guestfs_part_set_mbr_id (guestfs_h *g,
12628                                 const char *device,
12629                                 int partnum,
12630                                 int idbyte);
12631
12632       Sets the MBR type byte (also known as the ID byte) of the numbered
12633       partition "partnum" to "idbyte".  Note that the type bytes quoted in
12634       most documentation are in fact hexadecimal numbers, but usually
12635       documented without any leading "0x" which might be confusing.
12636
12637       Note that only MBR (old DOS-style) partitions have type bytes.  You
12638       will get undefined results for other partition table types (see
12639       "guestfs_part_get_parttype").
12640
12641       This function returns 0 on success or -1 on error.
12642
12643       (Added in 1.3.2)
12644
12645   guestfs_part_set_name
12646        int
12647        guestfs_part_set_name (guestfs_h *g,
12648                               const char *device,
12649                               int partnum,
12650                               const char *name);
12651
12652       This sets the partition name on partition numbered "partnum" on device
12653       "device".  Note that partitions are numbered from 1.
12654
12655       The partition name can only be set on certain types of partition table.
12656       This works on "gpt" but not on "mbr" partitions.
12657
12658       This function returns 0 on success or -1 on error.
12659
12660       (Added in 1.0.78)
12661
12662   guestfs_part_to_dev
12663        char *
12664        guestfs_part_to_dev (guestfs_h *g,
12665                             const char *partition);
12666
12667       This function takes a partition name (eg. "/dev/sdb1") and removes the
12668       partition number, returning the device name (eg. "/dev/sdb").
12669
12670       The named partition must exist, for example as a string returned from
12671       "guestfs_list_partitions".
12672
12673       See also "guestfs_part_to_partnum", "guestfs_device_index".
12674
12675       This function returns a string, or NULL on error.  The caller must free
12676       the returned string after use.
12677
12678       (Added in 1.5.15)
12679
12680   guestfs_part_to_partnum
12681        int
12682        guestfs_part_to_partnum (guestfs_h *g,
12683                                 const char *partition);
12684
12685       This function takes a partition name (eg. "/dev/sdb1") and returns the
12686       partition number (eg. 1).
12687
12688       The named partition must exist, for example as a string returned from
12689       "guestfs_list_partitions".
12690
12691       See also "guestfs_part_to_dev".
12692
12693       On error this function returns -1.
12694
12695       (Added in 1.13.25)
12696
12697   guestfs_ping_daemon
12698        int
12699        guestfs_ping_daemon (guestfs_h *g);
12700
12701       This is a test probe into the guestfs daemon running inside the
12702       libguestfs appliance.  Calling this function checks that the daemon
12703       responds to the ping message, without affecting the daemon or attached
12704       block device(s) in any other way.
12705
12706       This function returns 0 on success or -1 on error.
12707
12708       (Added in 1.0.18)
12709
12710   guestfs_pread
12711        char *
12712        guestfs_pread (guestfs_h *g,
12713                       const char *path,
12714                       int count,
12715                       int64_t offset,
12716                       size_t *size_r);
12717
12718       This command lets you read part of a file.  It reads "count" bytes of
12719       the file, starting at "offset", from file "path".
12720
12721       This may read fewer bytes than requested.  For further details see the
12722       pread(2) system call.
12723
12724       See also "guestfs_pwrite", "guestfs_pread_device".
12725
12726       This function returns a buffer, or NULL on error.  The size of the
12727       returned buffer is written to *size_r.  The caller must free the
12728       returned buffer after use.
12729
12730       Because of the message protocol, there is a transfer limit of somewhere
12731       between 2MB and 4MB.  See "PROTOCOL LIMITS".
12732
12733       (Added in 1.0.77)
12734
12735   guestfs_pread_device
12736        char *
12737        guestfs_pread_device (guestfs_h *g,
12738                              const char *device,
12739                              int count,
12740                              int64_t offset,
12741                              size_t *size_r);
12742
12743       This command lets you read part of a block device.  It reads "count"
12744       bytes of "device", starting at "offset".
12745
12746       This may read fewer bytes than requested.  For further details see the
12747       pread(2) system call.
12748
12749       See also "guestfs_pread".
12750
12751       This function returns a buffer, or NULL on error.  The size of the
12752       returned buffer is written to *size_r.  The caller must free the
12753       returned buffer after use.
12754
12755       Because of the message protocol, there is a transfer limit of somewhere
12756       between 2MB and 4MB.  See "PROTOCOL LIMITS".
12757
12758       (Added in 1.5.21)
12759
12760   guestfs_pvchange_uuid
12761        int
12762        guestfs_pvchange_uuid (guestfs_h *g,
12763                               const char *device);
12764
12765       Generate a new random UUID for the physical volume "device".
12766
12767       This function returns 0 on success or -1 on error.
12768
12769       This function depends on the feature "lvm2".  See also
12770       "guestfs_feature_available".
12771
12772       (Added in 1.19.26)
12773
12774   guestfs_pvchange_uuid_all
12775        int
12776        guestfs_pvchange_uuid_all (guestfs_h *g);
12777
12778       Generate new random UUIDs for all physical volumes.
12779
12780       This function returns 0 on success or -1 on error.
12781
12782       This function depends on the feature "lvm2".  See also
12783       "guestfs_feature_available".
12784
12785       (Added in 1.19.26)
12786
12787   guestfs_pvcreate
12788        int
12789        guestfs_pvcreate (guestfs_h *g,
12790                          const char *device);
12791
12792       This creates an LVM physical volume on the named "device", where
12793       "device" should usually be a partition name such as /dev/sda1.
12794
12795       This function returns 0 on success or -1 on error.
12796
12797       This function depends on the feature "lvm2".  See also
12798       "guestfs_feature_available".
12799
12800       (Added in 0.8)
12801
12802   guestfs_pvremove
12803        int
12804        guestfs_pvremove (guestfs_h *g,
12805                          const char *device);
12806
12807       This wipes a physical volume "device" so that LVM will no longer
12808       recognise it.
12809
12810       The implementation uses the pvremove(8) command which refuses to wipe
12811       physical volumes that contain any volume groups, so you have to remove
12812       those first.
12813
12814       This function returns 0 on success or -1 on error.
12815
12816       This function depends on the feature "lvm2".  See also
12817       "guestfs_feature_available".
12818
12819       (Added in 1.0.13)
12820
12821   guestfs_pvresize
12822        int
12823        guestfs_pvresize (guestfs_h *g,
12824                          const char *device);
12825
12826       This resizes (expands or shrinks) an existing LVM physical volume to
12827       match the new size of the underlying device.
12828
12829       This function returns 0 on success or -1 on error.
12830
12831       This function depends on the feature "lvm2".  See also
12832       "guestfs_feature_available".
12833
12834       (Added in 1.0.26)
12835
12836   guestfs_pvresize_size
12837        int
12838        guestfs_pvresize_size (guestfs_h *g,
12839                               const char *device,
12840                               int64_t size);
12841
12842       This command is the same as "guestfs_pvresize" except that it allows
12843       you to specify the new size (in bytes) explicitly.
12844
12845       This function returns 0 on success or -1 on error.
12846
12847       This function depends on the feature "lvm2".  See also
12848       "guestfs_feature_available".
12849
12850       (Added in 1.3.14)
12851
12852   guestfs_pvs
12853        char **
12854        guestfs_pvs (guestfs_h *g);
12855
12856       List all the physical volumes detected.  This is the equivalent of the
12857       pvs(8) command.
12858
12859       This returns a list of just the device names that contain PVs (eg.
12860       /dev/sda2).
12861
12862       See also "guestfs_pvs_full".
12863
12864       This function returns a NULL-terminated array of strings (like
12865       environ(3)), or NULL if there was an error.  The caller must free the
12866       strings and the array after use.
12867
12868       This function depends on the feature "lvm2".  See also
12869       "guestfs_feature_available".
12870
12871       (Added in 0.4)
12872
12873   guestfs_pvs_full
12874        struct guestfs_lvm_pv_list *
12875        guestfs_pvs_full (guestfs_h *g);
12876
12877       List all the physical volumes detected.  This is the equivalent of the
12878       pvs(8) command.  The "full" version includes all fields.
12879
12880       This function returns a "struct guestfs_lvm_pv_list *", or NULL if
12881       there was an error.  The caller must call "guestfs_free_lvm_pv_list"
12882       after use.
12883
12884       This function depends on the feature "lvm2".  See also
12885       "guestfs_feature_available".
12886
12887       (Added in 0.4)
12888
12889   guestfs_pvuuid
12890        char *
12891        guestfs_pvuuid (guestfs_h *g,
12892                        const char *device);
12893
12894       This command returns the UUID of the LVM PV "device".
12895
12896       This function returns a string, or NULL on error.  The caller must free
12897       the returned string after use.
12898
12899       (Added in 1.0.87)
12900
12901   guestfs_pwrite
12902        int
12903        guestfs_pwrite (guestfs_h *g,
12904                        const char *path,
12905                        const char *content,
12906                        size_t content_size,
12907                        int64_t offset);
12908
12909       This command writes to part of a file.  It writes the data buffer
12910       "content" to the file "path" starting at offset "offset".
12911
12912       This command implements the pwrite(2) system call, and like that system
12913       call it may not write the full data requested.  The return value is the
12914       number of bytes that were actually written to the file.  This could
12915       even be 0, although short writes are unlikely for regular files in
12916       ordinary circumstances.
12917
12918       See also "guestfs_pread", "guestfs_pwrite_device".
12919
12920       On error this function returns -1.
12921
12922       Because of the message protocol, there is a transfer limit of somewhere
12923       between 2MB and 4MB.  See "PROTOCOL LIMITS".
12924
12925       (Added in 1.3.14)
12926
12927   guestfs_pwrite_device
12928        int
12929        guestfs_pwrite_device (guestfs_h *g,
12930                               const char *device,
12931                               const char *content,
12932                               size_t content_size,
12933                               int64_t offset);
12934
12935       This command writes to part of a device.  It writes the data buffer
12936       "content" to "device" starting at offset "offset".
12937
12938       This command implements the pwrite(2) system call, and like that system
12939       call it may not write the full data requested (although short writes to
12940       disk devices and partitions are probably impossible with standard Linux
12941       kernels).
12942
12943       See also "guestfs_pwrite".
12944
12945       On error this function returns -1.
12946
12947       Because of the message protocol, there is a transfer limit of somewhere
12948       between 2MB and 4MB.  See "PROTOCOL LIMITS".
12949
12950       (Added in 1.5.20)
12951
12952   guestfs_read_file
12953        char *
12954        guestfs_read_file (guestfs_h *g,
12955                           const char *path,
12956                           size_t *size_r);
12957
12958       This calls returns the contents of the file "path" as a buffer.
12959
12960       Unlike "guestfs_cat", this function can correctly handle files that
12961       contain embedded ASCII NUL characters.
12962
12963       This function returns a buffer, or NULL on error.  The size of the
12964       returned buffer is written to *size_r.  The caller must free the
12965       returned buffer after use.
12966
12967       (Added in 1.0.63)
12968
12969   guestfs_read_lines
12970        char **
12971        guestfs_read_lines (guestfs_h *g,
12972                            const char *path);
12973
12974       Return the contents of the file named "path".
12975
12976       The file contents are returned as a list of lines.  Trailing "LF" and
12977       "CRLF" character sequences are not returned.
12978
12979       Note that this function cannot correctly handle binary files
12980       (specifically, files containing "\0" character which is treated as end
12981       of string).  For those you need to use the "guestfs_read_file" function
12982       and split the buffer into lines yourself.
12983
12984       This function returns a NULL-terminated array of strings (like
12985       environ(3)), or NULL if there was an error.  The caller must free the
12986       strings and the array after use.
12987
12988       (Added in 0.7)
12989
12990   guestfs_readdir
12991        struct guestfs_dirent_list *
12992        guestfs_readdir (guestfs_h *g,
12993                         const char *dir);
12994
12995       This returns the list of directory entries in directory "dir".
12996
12997       All entries in the directory are returned, including "." and "..".  The
12998       entries are not sorted, but returned in the same order as the
12999       underlying filesystem.
13000
13001       Also this call returns basic file type information about each file.
13002       The "ftyp" field will contain one of the following characters:
13003
13004       'b' Block special
13005
13006       'c' Char special
13007
13008       'd' Directory
13009
13010       'f' FIFO (named pipe)
13011
13012       'l' Symbolic link
13013
13014       'r' Regular file
13015
13016       's' Socket
13017
13018       'u' Unknown file type
13019
13020       '?' The readdir(3) call returned a "d_type" field with an unexpected
13021           value
13022
13023       This function is primarily intended for use by programs.  To get a
13024       simple list of names, use "guestfs_ls".  To get a printable directory
13025       for human consumption, use "guestfs_ll".
13026
13027       This function returns a "struct guestfs_dirent_list *", or NULL if
13028       there was an error.  The caller must call "guestfs_free_dirent_list"
13029       after use.
13030
13031       Because of the message protocol, there is a transfer limit of somewhere
13032       between 2MB and 4MB.  See "PROTOCOL LIMITS".
13033
13034       (Added in 1.0.55)
13035
13036   guestfs_readlink
13037        char *
13038        guestfs_readlink (guestfs_h *g,
13039                          const char *path);
13040
13041       This command reads the target of a symbolic link.
13042
13043       This function returns a string, or NULL on error.  The caller must free
13044       the returned string after use.
13045
13046       (Added in 1.0.66)
13047
13048   guestfs_readlinklist
13049        char **
13050        guestfs_readlinklist (guestfs_h *g,
13051                              const char *path,
13052                              char *const *names);
13053
13054       This call allows you to do a "readlink" operation on multiple files,
13055       where all files are in the directory "path".  "names" is the list of
13056       files from this directory.
13057
13058       On return you get a list of strings, with a one-to-one correspondence
13059       to the "names" list.  Each string is the value of the symbolic link.
13060
13061       If the readlink(2) operation fails on any name, then the corresponding
13062       result string is the empty string "".  However the whole operation is
13063       completed even if there were readlink(2) errors, and so you can call
13064       this function with names where you don't know if they are symbolic
13065       links already (albeit slightly less efficient).
13066
13067       This call is intended for programs that want to efficiently list a
13068       directory contents without making many round-trips.
13069
13070       This function returns a NULL-terminated array of strings (like
13071       environ(3)), or NULL if there was an error.  The caller must free the
13072       strings and the array after use.
13073
13074       (Added in 1.0.77)
13075
13076   guestfs_realpath
13077        char *
13078        guestfs_realpath (guestfs_h *g,
13079                          const char *path);
13080
13081       Return the canonicalized absolute pathname of "path".  The returned
13082       path has no ".", ".." or symbolic link path elements.
13083
13084       This function returns a string, or NULL on error.  The caller must free
13085       the returned string after use.
13086
13087       (Added in 1.0.66)
13088
13089   guestfs_remount
13090        int
13091        guestfs_remount (guestfs_h *g,
13092                         const char *mountpoint,
13093                         ...);
13094
13095       You may supply a list of optional arguments to this call.  Use zero or
13096       more of the following pairs of parameters, and terminate the list with
13097       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13098
13099        GUESTFS_REMOUNT_RW, int rw,
13100
13101       This call allows you to change the "rw" (readonly/read-write) flag on
13102       an already mounted filesystem at "mountpoint", converting a readonly
13103       filesystem to be read-write, or vice-versa.
13104
13105       Note that at the moment you must supply the "optional" "rw" parameter.
13106       In future we may allow other flags to be adjusted.
13107
13108       This function returns 0 on success or -1 on error.
13109
13110       (Added in 1.23.2)
13111
13112   guestfs_remount_va
13113        int
13114        guestfs_remount_va (guestfs_h *g,
13115                            const char *mountpoint,
13116                            va_list args);
13117
13118       This is the "va_list variant" of "guestfs_remount".
13119
13120       See "CALLS WITH OPTIONAL ARGUMENTS".
13121
13122   guestfs_remount_argv
13123        int
13124        guestfs_remount_argv (guestfs_h *g,
13125                              const char *mountpoint,
13126                              const struct guestfs_remount_argv *optargs);
13127
13128       This is the "argv variant" of "guestfs_remount".
13129
13130       See "CALLS WITH OPTIONAL ARGUMENTS".
13131
13132   guestfs_remove_drive
13133        int
13134        guestfs_remove_drive (guestfs_h *g,
13135                              const char *label);
13136
13137       This function is conceptually the opposite of "guestfs_add_drive_opts".
13138       It removes the drive that was previously added with label "label".
13139
13140       Note that in order to remove drives, you have to add them with labels
13141       (see the optional "label" argument to "guestfs_add_drive_opts").  If
13142       you didn't use a label, then they cannot be removed.
13143
13144       You can call this function before or after launching the handle.  If
13145       called after launch, if the backend supports it, we try to hot unplug
13146       the drive: see "HOTPLUGGING".  The disk must not be in use (eg.
13147       mounted) when you do this.  We try to detect if the disk is in use and
13148       stop you from doing this.
13149
13150       This function returns 0 on success or -1 on error.
13151
13152       (Added in 1.19.49)
13153
13154   guestfs_removexattr
13155        int
13156        guestfs_removexattr (guestfs_h *g,
13157                             const char *xattr,
13158                             const char *path);
13159
13160       This call removes the extended attribute named "xattr" of the file
13161       "path".
13162
13163       See also: "guestfs_lremovexattr", attr(5).
13164
13165       This function returns 0 on success or -1 on error.
13166
13167       This function depends on the feature "linuxxattrs".  See also
13168       "guestfs_feature_available".
13169
13170       (Added in 1.0.59)
13171
13172   guestfs_rename
13173        int
13174        guestfs_rename (guestfs_h *g,
13175                        const char *oldpath,
13176                        const char *newpath);
13177
13178       Rename a file to a new place on the same filesystem.  This is the same
13179       as the Linux rename(2) system call.  In most cases you are better to
13180       use "guestfs_mv" instead.
13181
13182       This function returns 0 on success or -1 on error.
13183
13184       (Added in 1.21.5)
13185
13186   guestfs_resize2fs
13187        int
13188        guestfs_resize2fs (guestfs_h *g,
13189                           const char *device);
13190
13191       This resizes an ext2, ext3 or ext4 filesystem to match the size of the
13192       underlying device.
13193
13194       See also "RESIZE2FS ERRORS".
13195
13196       This function returns 0 on success or -1 on error.
13197
13198       (Added in 1.0.27)
13199
13200   guestfs_resize2fs_M
13201        int
13202        guestfs_resize2fs_M (guestfs_h *g,
13203                             const char *device);
13204
13205       This command is the same as "guestfs_resize2fs", but the filesystem is
13206       resized to its minimum size.  This works like the -M option to the
13207       resize2fs(8) command.
13208
13209       To get the resulting size of the filesystem you should call
13210       "guestfs_tune2fs_l" and read the "Block size" and "Block count" values.
13211       These two numbers, multiplied together, give the resulting size of the
13212       minimal filesystem in bytes.
13213
13214       See also "RESIZE2FS ERRORS".
13215
13216       This function returns 0 on success or -1 on error.
13217
13218       (Added in 1.9.4)
13219
13220   guestfs_resize2fs_size
13221        int
13222        guestfs_resize2fs_size (guestfs_h *g,
13223                                const char *device,
13224                                int64_t size);
13225
13226       This command is the same as "guestfs_resize2fs" except that it allows
13227       you to specify the new size (in bytes) explicitly.
13228
13229       See also "RESIZE2FS ERRORS".
13230
13231       This function returns 0 on success or -1 on error.
13232
13233       (Added in 1.3.14)
13234
13235   guestfs_rm
13236        int
13237        guestfs_rm (guestfs_h *g,
13238                    const char *path);
13239
13240       Remove the single file "path".
13241
13242       This function returns 0 on success or -1 on error.
13243
13244       (Added in 0.8)
13245
13246   guestfs_rm_f
13247        int
13248        guestfs_rm_f (guestfs_h *g,
13249                      const char *path);
13250
13251       Remove the file "path".
13252
13253       If the file doesn't exist, that error is ignored.  (Other errors, eg.
13254       I/O errors or bad paths, are not ignored)
13255
13256       This call cannot remove directories.  Use "guestfs_rmdir" to remove an
13257       empty directory, or "guestfs_rm_rf" to remove directories recursively.
13258
13259       This function returns 0 on success or -1 on error.
13260
13261       (Added in 1.19.42)
13262
13263   guestfs_rm_rf
13264        int
13265        guestfs_rm_rf (guestfs_h *g,
13266                       const char *path);
13267
13268       Remove the file or directory "path", recursively removing the contents
13269       if its a directory.  This is like the "rm -rf" shell command.
13270
13271       This function returns 0 on success or -1 on error.
13272
13273       (Added in 0.8)
13274
13275   guestfs_rmdir
13276        int
13277        guestfs_rmdir (guestfs_h *g,
13278                       const char *path);
13279
13280       Remove the single directory "path".
13281
13282       This function returns 0 on success or -1 on error.
13283
13284       (Added in 0.8)
13285
13286   guestfs_rmmountpoint
13287        int
13288        guestfs_rmmountpoint (guestfs_h *g,
13289                              const char *exemptpath);
13290
13291       This call removes a mountpoint that was previously created with
13292       "guestfs_mkmountpoint".  See "guestfs_mkmountpoint" for full details.
13293
13294       This function returns 0 on success or -1 on error.
13295
13296       (Added in 1.0.62)
13297
13298   guestfs_rsync
13299        int
13300        guestfs_rsync (guestfs_h *g,
13301                       const char *src,
13302                       const char *dest,
13303                       ...);
13304
13305       You may supply a list of optional arguments to this call.  Use zero or
13306       more of the following pairs of parameters, and terminate the list with
13307       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13308
13309        GUESTFS_RSYNC_ARCHIVE, int archive,
13310        GUESTFS_RSYNC_DELETEDEST, int deletedest,
13311
13312       This call may be used to copy or synchronize two directories under the
13313       same libguestfs handle.  This uses the rsync(1) program which uses a
13314       fast algorithm that avoids copying files unnecessarily.
13315
13316       "src" and "dest" are the source and destination directories.  Files are
13317       copied from "src" to "dest".
13318
13319       The optional arguments are:
13320
13321       "archive"
13322           Turns on archive mode.  This is the same as passing the --archive
13323           flag to "rsync".
13324
13325       "deletedest"
13326           Delete files at the destination that do not exist at the source.
13327
13328       This function returns 0 on success or -1 on error.
13329
13330       This function depends on the feature "rsync".  See also
13331       "guestfs_feature_available".
13332
13333       (Added in 1.19.29)
13334
13335   guestfs_rsync_va
13336        int
13337        guestfs_rsync_va (guestfs_h *g,
13338                          const char *src,
13339                          const char *dest,
13340                          va_list args);
13341
13342       This is the "va_list variant" of "guestfs_rsync".
13343
13344       See "CALLS WITH OPTIONAL ARGUMENTS".
13345
13346   guestfs_rsync_argv
13347        int
13348        guestfs_rsync_argv (guestfs_h *g,
13349                            const char *src,
13350                            const char *dest,
13351                            const struct guestfs_rsync_argv *optargs);
13352
13353       This is the "argv variant" of "guestfs_rsync".
13354
13355       See "CALLS WITH OPTIONAL ARGUMENTS".
13356
13357   guestfs_rsync_in
13358        int
13359        guestfs_rsync_in (guestfs_h *g,
13360                          const char *remote,
13361                          const char *dest,
13362                          ...);
13363
13364       You may supply a list of optional arguments to this call.  Use zero or
13365       more of the following pairs of parameters, and terminate the list with
13366       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13367
13368        GUESTFS_RSYNC_IN_ARCHIVE, int archive,
13369        GUESTFS_RSYNC_IN_DELETEDEST, int deletedest,
13370
13371       This call may be used to copy or synchronize the filesystem on the host
13372       or on a remote computer with the filesystem within libguestfs.  This
13373       uses the rsync(1) program which uses a fast algorithm that avoids
13374       copying files unnecessarily.
13375
13376       This call only works if the network is enabled.  See
13377       "guestfs_set_network" or the --network option to various tools like
13378       guestfish(1).
13379
13380       Files are copied from the remote server and directory specified by
13381       "remote" to the destination directory "dest".
13382
13383       The format of the remote server string is defined by rsync(1).  Note
13384       that there is no way to supply a password or passphrase so the target
13385       must be set up not to require one.
13386
13387       The optional arguments are the same as those of "guestfs_rsync".
13388
13389       This function returns 0 on success or -1 on error.
13390
13391       This function depends on the feature "rsync".  See also
13392       "guestfs_feature_available".
13393
13394       (Added in 1.19.29)
13395
13396   guestfs_rsync_in_va
13397        int
13398        guestfs_rsync_in_va (guestfs_h *g,
13399                             const char *remote,
13400                             const char *dest,
13401                             va_list args);
13402
13403       This is the "va_list variant" of "guestfs_rsync_in".
13404
13405       See "CALLS WITH OPTIONAL ARGUMENTS".
13406
13407   guestfs_rsync_in_argv
13408        int
13409        guestfs_rsync_in_argv (guestfs_h *g,
13410                               const char *remote,
13411                               const char *dest,
13412                               const struct guestfs_rsync_in_argv *optargs);
13413
13414       This is the "argv variant" of "guestfs_rsync_in".
13415
13416       See "CALLS WITH OPTIONAL ARGUMENTS".
13417
13418   guestfs_rsync_out
13419        int
13420        guestfs_rsync_out (guestfs_h *g,
13421                           const char *src,
13422                           const char *remote,
13423                           ...);
13424
13425       You may supply a list of optional arguments to this call.  Use zero or
13426       more of the following pairs of parameters, and terminate the list with
13427       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13428
13429        GUESTFS_RSYNC_OUT_ARCHIVE, int archive,
13430        GUESTFS_RSYNC_OUT_DELETEDEST, int deletedest,
13431
13432       This call may be used to copy or synchronize the filesystem within
13433       libguestfs with a filesystem on the host or on a remote computer.  This
13434       uses the rsync(1) program which uses a fast algorithm that avoids
13435       copying files unnecessarily.
13436
13437       This call only works if the network is enabled.  See
13438       "guestfs_set_network" or the --network option to various tools like
13439       guestfish(1).
13440
13441       Files are copied from the source directory "src" to the remote server
13442       and directory specified by "remote".
13443
13444       The format of the remote server string is defined by rsync(1).  Note
13445       that there is no way to supply a password or passphrase so the target
13446       must be set up not to require one.
13447
13448       The optional arguments are the same as those of "guestfs_rsync".
13449
13450       Globbing does not happen on the "src" parameter.  In programs which use
13451       the API directly you have to expand wildcards yourself (see
13452       "guestfs_glob_expand").  In guestfish you can use the "glob" command
13453       (see "glob" in guestfish(1)), for example:
13454
13455        ><fs> glob rsync-out /* rsync://remote/
13456
13457       This function returns 0 on success or -1 on error.
13458
13459       This function depends on the feature "rsync".  See also
13460       "guestfs_feature_available".
13461
13462       (Added in 1.19.29)
13463
13464   guestfs_rsync_out_va
13465        int
13466        guestfs_rsync_out_va (guestfs_h *g,
13467                              const char *src,
13468                              const char *remote,
13469                              va_list args);
13470
13471       This is the "va_list variant" of "guestfs_rsync_out".
13472
13473       See "CALLS WITH OPTIONAL ARGUMENTS".
13474
13475   guestfs_rsync_out_argv
13476        int
13477        guestfs_rsync_out_argv (guestfs_h *g,
13478                                const char *src,
13479                                const char *remote,
13480                                const struct guestfs_rsync_out_argv *optargs);
13481
13482       This is the "argv variant" of "guestfs_rsync_out".
13483
13484       See "CALLS WITH OPTIONAL ARGUMENTS".
13485
13486   guestfs_scrub_device
13487        int
13488        guestfs_scrub_device (guestfs_h *g,
13489                              const char *device);
13490
13491       This command writes patterns over "device" to make data retrieval more
13492       difficult.
13493
13494       It is an interface to the scrub(1) program.  See that manual page for
13495       more details.
13496
13497       This function returns 0 on success or -1 on error.
13498
13499       This function depends on the feature "scrub".  See also
13500       "guestfs_feature_available".
13501
13502       (Added in 1.0.52)
13503
13504   guestfs_scrub_file
13505        int
13506        guestfs_scrub_file (guestfs_h *g,
13507                            const char *file);
13508
13509       This command writes patterns over a file to make data retrieval more
13510       difficult.
13511
13512       The file is removed after scrubbing.
13513
13514       It is an interface to the scrub(1) program.  See that manual page for
13515       more details.
13516
13517       This function returns 0 on success or -1 on error.
13518
13519       This function depends on the feature "scrub".  See also
13520       "guestfs_feature_available".
13521
13522       (Added in 1.0.52)
13523
13524   guestfs_scrub_freespace
13525        int
13526        guestfs_scrub_freespace (guestfs_h *g,
13527                                 const char *dir);
13528
13529       This command creates the directory "dir" and then fills it with files
13530       until the filesystem is full, and scrubs the files as for
13531       "guestfs_scrub_file", and deletes them.  The intention is to scrub any
13532       free space on the partition containing "dir".
13533
13534       It is an interface to the scrub(1) program.  See that manual page for
13535       more details.
13536
13537       This function returns 0 on success or -1 on error.
13538
13539       This function depends on the feature "scrub".  See also
13540       "guestfs_feature_available".
13541
13542       (Added in 1.0.52)
13543
13544   guestfs_selinux_relabel
13545        int
13546        guestfs_selinux_relabel (guestfs_h *g,
13547                                 const char *specfile,
13548                                 const char *path,
13549                                 ...);
13550
13551       You may supply a list of optional arguments to this call.  Use zero or
13552       more of the following pairs of parameters, and terminate the list with
13553       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13554
13555        GUESTFS_SELINUX_RELABEL_FORCE, int force,
13556
13557       SELinux relabel parts of the filesystem.
13558
13559       The "specfile" parameter controls the policy spec file used.  You have
13560       to parse "/etc/selinux/config" to find the correct SELinux policy and
13561       then pass the spec file, usually: "/etc/selinux/" + selinuxtype +
13562       "/contexts/files/file_contexts".
13563
13564       The required "path" parameter is the top level directory where
13565       relabelling starts.  Normally you should pass "path" as "/" to relabel
13566       the whole guest filesystem.
13567
13568       The optional "force" boolean controls whether the context is reset for
13569       customizable files, and also whether the user, role and range parts of
13570       the file context is changed.
13571
13572       This function returns 0 on success or -1 on error.
13573
13574       This function depends on the feature "selinuxrelabel".  See also
13575       "guestfs_feature_available".
13576
13577       (Added in 1.33.43)
13578
13579   guestfs_selinux_relabel_va
13580        int
13581        guestfs_selinux_relabel_va (guestfs_h *g,
13582                                    const char *specfile,
13583                                    const char *path,
13584                                    va_list args);
13585
13586       This is the "va_list variant" of "guestfs_selinux_relabel".
13587
13588       See "CALLS WITH OPTIONAL ARGUMENTS".
13589
13590   guestfs_selinux_relabel_argv
13591        int
13592        guestfs_selinux_relabel_argv (guestfs_h *g,
13593                                      const char *specfile,
13594                                      const char *path,
13595                                      const struct guestfs_selinux_relabel_argv *optargs);
13596
13597       This is the "argv variant" of "guestfs_selinux_relabel".
13598
13599       See "CALLS WITH OPTIONAL ARGUMENTS".
13600
13601   guestfs_set_append
13602        int
13603        guestfs_set_append (guestfs_h *g,
13604                            const char *append);
13605
13606       This function is used to add additional options to the libguestfs
13607       appliance kernel command line.
13608
13609       The default is "NULL" unless overridden by setting "LIBGUESTFS_APPEND"
13610       environment variable.
13611
13612       Setting "append" to "NULL" means no additional options are passed
13613       (libguestfs always adds a few of its own).
13614
13615       This function returns 0 on success or -1 on error.
13616
13617       (Added in 1.0.26)
13618
13619   guestfs_set_attach_method
13620        int
13621        guestfs_set_attach_method (guestfs_h *g,
13622                                   const char *backend);
13623
13624       This function is deprecated.  In new code, use the
13625       "guestfs_set_backend" call instead.
13626
13627       Deprecated functions will not be removed from the API, but the fact
13628       that they are deprecated indicates that there are problems with correct
13629       use of these functions.
13630
13631       Set the method that libguestfs uses to connect to the backend guestfsd
13632       daemon.
13633
13634       See "BACKEND".
13635
13636       This function returns 0 on success or -1 on error.
13637
13638       (Added in 1.9.8)
13639
13640   guestfs_set_autosync
13641        int
13642        guestfs_set_autosync (guestfs_h *g,
13643                              int autosync);
13644
13645       If "autosync" is true, this enables autosync.  Libguestfs will make a
13646       best effort attempt to make filesystems consistent and synchronized
13647       when the handle is closed (also if the program exits without closing
13648       handles).
13649
13650       This is enabled by default (since libguestfs 1.5.24, previously it was
13651       disabled by default).
13652
13653       This function returns 0 on success or -1 on error.
13654
13655       (Added in 0.3)
13656
13657   guestfs_set_backend
13658        int
13659        guestfs_set_backend (guestfs_h *g,
13660                             const char *backend);
13661
13662       Set the method that libguestfs uses to connect to the backend guestfsd
13663       daemon.
13664
13665       This handle property was previously called the "attach method".
13666
13667       See "BACKEND".
13668
13669       This function returns 0 on success or -1 on error.
13670
13671       (Added in 1.21.26)
13672
13673   guestfs_set_backend_setting
13674        int
13675        guestfs_set_backend_setting (guestfs_h *g,
13676                                     const char *name,
13677                                     const char *val);
13678
13679       Append "name=value" to the backend settings string list.  However if a
13680       string already exists matching "name" or beginning with "name=", then
13681       that setting is replaced.
13682
13683       See "BACKEND", "BACKEND SETTINGS".
13684
13685       This function returns 0 on success or -1 on error.
13686
13687       (Added in 1.27.2)
13688
13689   guestfs_set_backend_settings
13690        int
13691        guestfs_set_backend_settings (guestfs_h *g,
13692                                      char *const *settings);
13693
13694       Set a list of zero or more settings which are passed through to the
13695       current backend.  Each setting is a string which is interpreted in a
13696       backend-specific way, or ignored if not understood by the backend.
13697
13698       The default value is an empty list, unless the environment variable
13699       "LIBGUESTFS_BACKEND_SETTINGS" was set when the handle was created.
13700       This environment variable contains a colon-separated list of settings.
13701
13702       This call replaces all backend settings.  If you want to replace a
13703       single backend setting, see "guestfs_set_backend_setting".  If you want
13704       to clear a single backend setting, see "guestfs_clear_backend_setting".
13705
13706       See "BACKEND", "BACKEND SETTINGS".
13707
13708       This function returns 0 on success or -1 on error.
13709
13710       (Added in 1.25.24)
13711
13712   guestfs_set_cachedir
13713        int
13714        guestfs_set_cachedir (guestfs_h *g,
13715                              const char *cachedir);
13716
13717       Set the directory used by the handle to store the appliance cache, when
13718       using a supermin appliance.  The appliance is cached and shared between
13719       all handles which have the same effective user ID.
13720
13721       The environment variables "LIBGUESTFS_CACHEDIR" and "TMPDIR" control
13722       the default value: If "LIBGUESTFS_CACHEDIR" is set, then that is the
13723       default.  Else if "TMPDIR" is set, then that is the default.  Else
13724       /var/tmp is the default.
13725
13726       This function returns 0 on success or -1 on error.
13727
13728       (Added in 1.19.58)
13729
13730   guestfs_set_direct
13731        int
13732        guestfs_set_direct (guestfs_h *g,
13733                            int direct);
13734
13735       This function is deprecated.  In new code, use the
13736       "guestfs_internal_get_console_socket" call instead.
13737
13738       Deprecated functions will not be removed from the API, but the fact
13739       that they are deprecated indicates that there are problems with correct
13740       use of these functions.
13741
13742       If the direct appliance mode flag is enabled, then stdin and stdout are
13743       passed directly through to the appliance once it is launched.
13744
13745       One consequence of this is that log messages aren't caught by the
13746       library and handled by "guestfs_set_log_message_callback", but go
13747       straight to stdout.
13748
13749       You probably don't want to use this unless you know what you are doing.
13750
13751       The default is disabled.
13752
13753       This function returns 0 on success or -1 on error.
13754
13755       (Added in 1.0.72)
13756
13757   guestfs_set_e2attrs
13758        int
13759        guestfs_set_e2attrs (guestfs_h *g,
13760                             const char *file,
13761                             const char *attrs,
13762                             ...);
13763
13764       You may supply a list of optional arguments to this call.  Use zero or
13765       more of the following pairs of parameters, and terminate the list with
13766       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
13767
13768        GUESTFS_SET_E2ATTRS_CLEAR, int clear,
13769
13770       This sets or clears the file attributes "attrs" associated with the
13771       inode file.
13772
13773       "attrs" is a string of characters representing file attributes.  See
13774       "guestfs_get_e2attrs" for a list of possible attributes.  Not all
13775       attributes can be changed.
13776
13777       If optional boolean "clear" is not present or false, then the "attrs"
13778       listed are set in the inode.
13779
13780       If "clear" is true, then the "attrs" listed are cleared in the inode.
13781
13782       In both cases, other attributes not present in the "attrs" string are
13783       left unchanged.
13784
13785       These attributes are only present when the file is located on an
13786       ext2/3/4 filesystem.  Using this call on other filesystem types will
13787       result in an error.
13788
13789       This function returns 0 on success or -1 on error.
13790
13791       (Added in 1.17.31)
13792
13793   guestfs_set_e2attrs_va
13794        int
13795        guestfs_set_e2attrs_va (guestfs_h *g,
13796                                const char *file,
13797                                const char *attrs,
13798                                va_list args);
13799
13800       This is the "va_list variant" of "guestfs_set_e2attrs".
13801
13802       See "CALLS WITH OPTIONAL ARGUMENTS".
13803
13804   guestfs_set_e2attrs_argv
13805        int
13806        guestfs_set_e2attrs_argv (guestfs_h *g,
13807                                  const char *file,
13808                                  const char *attrs,
13809                                  const struct guestfs_set_e2attrs_argv *optargs);
13810
13811       This is the "argv variant" of "guestfs_set_e2attrs".
13812
13813       See "CALLS WITH OPTIONAL ARGUMENTS".
13814
13815   guestfs_set_e2generation
13816        int
13817        guestfs_set_e2generation (guestfs_h *g,
13818                                  const char *file,
13819                                  int64_t generation);
13820
13821       This sets the ext2 file generation of a file.
13822
13823       See "guestfs_get_e2generation".
13824
13825       This function returns 0 on success or -1 on error.
13826
13827       (Added in 1.17.31)
13828
13829   guestfs_set_e2label
13830        int
13831        guestfs_set_e2label (guestfs_h *g,
13832                             const char *device,
13833                             const char *label);
13834
13835       This function is deprecated.  In new code, use the "guestfs_set_label"
13836       call instead.
13837
13838       Deprecated functions will not be removed from the API, but the fact
13839       that they are deprecated indicates that there are problems with correct
13840       use of these functions.
13841
13842       This sets the ext2/3/4 filesystem label of the filesystem on "device"
13843       to "label".  Filesystem labels are limited to 16 characters.
13844
13845       You can use either "guestfs_tune2fs_l" or "guestfs_get_e2label" to
13846       return the existing label on a filesystem.
13847
13848       This function returns 0 on success or -1 on error.
13849
13850       (Added in 1.0.15)
13851
13852   guestfs_set_e2uuid
13853        int
13854        guestfs_set_e2uuid (guestfs_h *g,
13855                            const char *device,
13856                            const char *uuid);
13857
13858       This function is deprecated.  In new code, use the "guestfs_set_uuid"
13859       call instead.
13860
13861       Deprecated functions will not be removed from the API, but the fact
13862       that they are deprecated indicates that there are problems with correct
13863       use of these functions.
13864
13865       This sets the ext2/3/4 filesystem UUID of the filesystem on "device" to
13866       "uuid".  The format of the UUID and alternatives such as "clear",
13867       "random" and "time" are described in the tune2fs(8) manpage.
13868
13869       You can use "guestfs_vfs_uuid" to return the existing UUID of a
13870       filesystem.
13871
13872       This function returns 0 on success or -1 on error.
13873
13874       (Added in 1.0.15)
13875
13876   guestfs_set_hv
13877        int
13878        guestfs_set_hv (guestfs_h *g,
13879                        const char *hv);
13880
13881       Set the hypervisor binary that we will use.  The hypervisor depends on
13882       the backend, but is usually the location of the qemu/KVM hypervisor.
13883       For the uml backend, it is the location of the "linux" or "vmlinux"
13884       binary.
13885
13886       The default is chosen when the library was compiled by the configure
13887       script.
13888
13889       You can also override this by setting the "LIBGUESTFS_HV" environment
13890       variable.
13891
13892       Note that you should call this function as early as possible after
13893       creating the handle.  This is because some pre-launch operations depend
13894       on testing qemu features (by running "qemu -help").  If the qemu binary
13895       changes, we don't retest features, and so you might see inconsistent
13896       results.  Using the environment variable "LIBGUESTFS_HV" is safest of
13897       all since that picks the qemu binary at the same time as the handle is
13898       created.
13899
13900       This function returns 0 on success or -1 on error.
13901
13902       (Added in 1.23.17)
13903
13904   guestfs_set_identifier
13905        int
13906        guestfs_set_identifier (guestfs_h *g,
13907                                const char *identifier);
13908
13909       This is an informative string which the caller may optionally set in
13910       the handle.  It is printed in various places, allowing the current
13911       handle to be identified in debugging output.
13912
13913       One important place is when tracing is enabled.  If the identifier
13914       string is not an empty string, then trace messages change from this:
13915
13916        libguestfs: trace: get_tmpdir
13917        libguestfs: trace: get_tmpdir = "/tmp"
13918
13919       to this:
13920
13921        libguestfs: trace: ID: get_tmpdir
13922        libguestfs: trace: ID: get_tmpdir = "/tmp"
13923
13924       where "ID" is the identifier string set by this call.
13925
13926       The identifier must only contain alphanumeric ASCII characters,
13927       underscore and minus sign.  The default is the empty string.
13928
13929       See also "guestfs_set_program", "guestfs_set_trace",
13930       "guestfs_get_identifier".
13931
13932       This function returns 0 on success or -1 on error.
13933
13934       (Added in 1.31.14)
13935
13936   guestfs_set_label
13937        int
13938        guestfs_set_label (guestfs_h *g,
13939                           const char *mountable,
13940                           const char *label);
13941
13942       Set the filesystem label on "mountable" to "label".
13943
13944       Only some filesystem types support labels, and libguestfs supports
13945       setting labels on only a subset of these.
13946
13947       ext2, ext3, ext4
13948           Labels are limited to 16 bytes.
13949
13950       NTFS
13951           Labels are limited to 128 unicode characters.
13952
13953       XFS The label is limited to 12 bytes.  The filesystem must not be
13954           mounted when trying to set the label.
13955
13956       btrfs
13957           The label is limited to 255 bytes and some characters are not
13958           allowed.  Setting the label on a btrfs subvolume will set the label
13959           on its parent filesystem.  The filesystem must not be mounted when
13960           trying to set the label.
13961
13962       fat The label is limited to 11 bytes.
13963
13964       swap
13965           The label is limited to 16 bytes.
13966
13967       If there is no support for changing the label for the type of the
13968       specified filesystem, set_label will fail and set errno as ENOTSUP.
13969
13970       To read the label on a filesystem, call "guestfs_vfs_label".
13971
13972       This function returns 0 on success or -1 on error.
13973
13974       (Added in 1.17.9)
13975
13976   guestfs_set_libvirt_requested_credential
13977        int
13978        guestfs_set_libvirt_requested_credential (guestfs_h *g,
13979                                                  int index,
13980                                                  const char *cred,
13981                                                  size_t cred_size);
13982
13983       After requesting the "index"'th credential from the user, call this
13984       function to pass the answer back to libvirt.
13985
13986       See "LIBVIRT AUTHENTICATION" for documentation and example code.
13987
13988       This function returns 0 on success or -1 on error.
13989
13990       (Added in 1.19.52)
13991
13992   guestfs_set_libvirt_supported_credentials
13993        int
13994        guestfs_set_libvirt_supported_credentials (guestfs_h *g,
13995                                                   char *const *creds);
13996
13997       Call this function before setting an event handler for
13998       "GUESTFS_EVENT_LIBVIRT_AUTH", to supply the list of credential types
13999       that the program knows how to process.
14000
14001       The "creds" list must be a non-empty list of strings.  Possible strings
14002       are:
14003
14004       "username"
14005       "authname"
14006       "language"
14007       "cnonce"
14008       "passphrase"
14009       "echoprompt"
14010       "noechoprompt"
14011       "realm"
14012       "external"
14013
14014       See libvirt documentation for the meaning of these credential types.
14015
14016       See "LIBVIRT AUTHENTICATION" for documentation and example code.
14017
14018       This function returns 0 on success or -1 on error.
14019
14020       (Added in 1.19.52)
14021
14022   guestfs_set_memsize
14023        int
14024        guestfs_set_memsize (guestfs_h *g,
14025                             int memsize);
14026
14027       This sets the memory size in megabytes allocated to the hypervisor.
14028       This only has any effect if called before "guestfs_launch".
14029
14030       You can also change this by setting the environment variable
14031       "LIBGUESTFS_MEMSIZE" before the handle is created.
14032
14033       For more information on the architecture of libguestfs, see guestfs(3).
14034
14035       This function returns 0 on success or -1 on error.
14036
14037       (Added in 1.0.55)
14038
14039   guestfs_set_network
14040        int
14041        guestfs_set_network (guestfs_h *g,
14042                             int network);
14043
14044       If "network" is true, then the network is enabled in the libguestfs
14045       appliance.  The default is false.
14046
14047       This affects whether commands are able to access the network (see
14048       "RUNNING COMMANDS").
14049
14050       You must call this before calling "guestfs_launch", otherwise it has no
14051       effect.
14052
14053       This function returns 0 on success or -1 on error.
14054
14055       (Added in 1.5.4)
14056
14057   guestfs_set_path
14058        int
14059        guestfs_set_path (guestfs_h *g,
14060                          const char *searchpath);
14061
14062       Set the path that libguestfs searches for kernel and initrd.img.
14063
14064       The default is "$libdir/guestfs" unless overridden by setting
14065       "LIBGUESTFS_PATH" environment variable.
14066
14067       Setting "path" to "NULL" restores the default path.
14068
14069       This function returns 0 on success or -1 on error.
14070
14071       (Added in 0.3)
14072
14073   guestfs_set_pgroup
14074        int
14075        guestfs_set_pgroup (guestfs_h *g,
14076                            int pgroup);
14077
14078       If "pgroup" is true, child processes are placed into their own process
14079       group.
14080
14081       The practical upshot of this is that signals like "SIGINT" (from users
14082       pressing "^C") won't be received by the child process.
14083
14084       The default for this flag is false, because usually you want "^C" to
14085       kill the subprocess.  Guestfish sets this flag to true when used
14086       interactively, so that "^C" can cancel long-running commands gracefully
14087       (see "guestfs_user_cancel").
14088
14089       This function returns 0 on success or -1 on error.
14090
14091       (Added in 1.11.18)
14092
14093   guestfs_set_program
14094        int
14095        guestfs_set_program (guestfs_h *g,
14096                             const char *program);
14097
14098       Set the program name.  This is an informative string which the main
14099       program may optionally set in the handle.
14100
14101       When the handle is created, the program name in the handle is set to
14102       the basename from "argv[0]".  The program name can never be "NULL".
14103
14104       This function returns 0 on success or -1 on error.
14105
14106       (Added in 1.21.29)
14107
14108   guestfs_set_qemu
14109        int
14110        guestfs_set_qemu (guestfs_h *g,
14111                          const char *hv);
14112
14113       This function is deprecated.  In new code, use the "guestfs_set_hv"
14114       call instead.
14115
14116       Deprecated functions will not be removed from the API, but the fact
14117       that they are deprecated indicates that there are problems with correct
14118       use of these functions.
14119
14120       Set the hypervisor binary (usually qemu) that we will use.
14121
14122       The default is chosen when the library was compiled by the configure
14123       script.
14124
14125       You can also override this by setting the "LIBGUESTFS_HV" environment
14126       variable.
14127
14128       Setting "hv" to "NULL" restores the default qemu binary.
14129
14130       Note that you should call this function as early as possible after
14131       creating the handle.  This is because some pre-launch operations depend
14132       on testing qemu features (by running "qemu -help").  If the qemu binary
14133       changes, we don't retest features, and so you might see inconsistent
14134       results.  Using the environment variable "LIBGUESTFS_HV" is safest of
14135       all since that picks the qemu binary at the same time as the handle is
14136       created.
14137
14138       This function returns 0 on success or -1 on error.
14139
14140       (Added in 1.0.6)
14141
14142   guestfs_set_recovery_proc
14143        int
14144        guestfs_set_recovery_proc (guestfs_h *g,
14145                                   int recoveryproc);
14146
14147       If this is called with the parameter "false" then "guestfs_launch" does
14148       not create a recovery process.  The purpose of the recovery process is
14149       to stop runaway hypervisor processes in the case where the main program
14150       aborts abruptly.
14151
14152       This only has any effect if called before "guestfs_launch", and the
14153       default is true.
14154
14155       About the only time when you would want to disable this is if the main
14156       process will fork itself into the background ("daemonize" itself).  In
14157       this case the recovery process thinks that the main program has
14158       disappeared and so kills the hypervisor, which is not very helpful.
14159
14160       This function returns 0 on success or -1 on error.
14161
14162       (Added in 1.0.77)
14163
14164   guestfs_set_selinux
14165        int
14166        guestfs_set_selinux (guestfs_h *g,
14167                             int selinux);
14168
14169       This function is deprecated.  In new code, use the
14170       "guestfs_selinux_relabel" call instead.
14171
14172       Deprecated functions will not be removed from the API, but the fact
14173       that they are deprecated indicates that there are problems with correct
14174       use of these functions.
14175
14176       This sets the selinux flag that is passed to the appliance at boot
14177       time.  The default is "selinux=0" (disabled).
14178
14179       Note that if SELinux is enabled, it is always in Permissive mode
14180       ("enforcing=0").
14181
14182       For more information on the architecture of libguestfs, see guestfs(3).
14183
14184       This function returns 0 on success or -1 on error.
14185
14186       (Added in 1.0.67)
14187
14188   guestfs_set_smp
14189        int
14190        guestfs_set_smp (guestfs_h *g,
14191                         int smp);
14192
14193       Change the number of virtual CPUs assigned to the appliance.  The
14194       default is 1.  Increasing this may improve performance, though often it
14195       has no effect.
14196
14197       This function must be called before "guestfs_launch".
14198
14199       This function returns 0 on success or -1 on error.
14200
14201       (Added in 1.13.15)
14202
14203   guestfs_set_tmpdir
14204        int
14205        guestfs_set_tmpdir (guestfs_h *g,
14206                            const char *tmpdir);
14207
14208       Set the directory used by the handle to store temporary files.
14209
14210       The environment variables "LIBGUESTFS_TMPDIR" and "TMPDIR" control the
14211       default value: If "LIBGUESTFS_TMPDIR" is set, then that is the default.
14212       Else if "TMPDIR" is set, then that is the default.  Else /tmp is the
14213       default.
14214
14215       This function returns 0 on success or -1 on error.
14216
14217       (Added in 1.19.58)
14218
14219   guestfs_set_trace
14220        int
14221        guestfs_set_trace (guestfs_h *g,
14222                           int trace);
14223
14224       If the command trace flag is set to 1, then libguestfs calls,
14225       parameters and return values are traced.
14226
14227       If you want to trace C API calls into libguestfs (and other libraries)
14228       then possibly a better way is to use the external ltrace(1) command.
14229
14230       Command traces are disabled unless the environment variable
14231       "LIBGUESTFS_TRACE" is defined and set to 1.
14232
14233       Trace messages are normally sent to "stderr", unless you register a
14234       callback to send them somewhere else (see
14235       "guestfs_set_event_callback").
14236
14237       This function returns 0 on success or -1 on error.
14238
14239       (Added in 1.0.69)
14240
14241   guestfs_set_uuid
14242        int
14243        guestfs_set_uuid (guestfs_h *g,
14244                          const char *device,
14245                          const char *uuid);
14246
14247       Set the filesystem UUID on "device" to "uuid".  If this fails and the
14248       errno is ENOTSUP, means that there is no support for changing the UUID
14249       for the type of the specified filesystem.
14250
14251       Only some filesystem types support setting UUIDs.
14252
14253       To read the UUID on a filesystem, call "guestfs_vfs_uuid".
14254
14255       This function returns 0 on success or -1 on error.
14256
14257       (Added in 1.23.10)
14258
14259   guestfs_set_uuid_random
14260        int
14261        guestfs_set_uuid_random (guestfs_h *g,
14262                                 const char *device);
14263
14264       Set the filesystem UUID on "device" to a random UUID.  If this fails
14265       and the errno is ENOTSUP, means that there is no support for changing
14266       the UUID for the type of the specified filesystem.
14267
14268       Only some filesystem types support setting UUIDs.
14269
14270       To read the UUID on a filesystem, call "guestfs_vfs_uuid".
14271
14272       This function returns 0 on success or -1 on error.
14273
14274       (Added in 1.29.50)
14275
14276   guestfs_set_verbose
14277        int
14278        guestfs_set_verbose (guestfs_h *g,
14279                             int verbose);
14280
14281       If "verbose" is true, this turns on verbose messages.
14282
14283       Verbose messages are disabled unless the environment variable
14284       "LIBGUESTFS_DEBUG" is defined and set to 1.
14285
14286       Verbose messages are normally sent to "stderr", unless you register a
14287       callback to send them somewhere else (see
14288       "guestfs_set_event_callback").
14289
14290       This function returns 0 on success or -1 on error.
14291
14292       (Added in 0.3)
14293
14294   guestfs_setcon
14295        int
14296        guestfs_setcon (guestfs_h *g,
14297                        const char *context);
14298
14299       This function is deprecated.  In new code, use the
14300       "guestfs_selinux_relabel" call instead.
14301
14302       Deprecated functions will not be removed from the API, but the fact
14303       that they are deprecated indicates that there are problems with correct
14304       use of these functions.
14305
14306       This sets the SELinux security context of the daemon to the string
14307       "context".
14308
14309       See the documentation about SELINUX in guestfs(3).
14310
14311       This function returns 0 on success or -1 on error.
14312
14313       This function depends on the feature "selinux".  See also
14314       "guestfs_feature_available".
14315
14316       (Added in 1.0.67)
14317
14318   guestfs_setxattr
14319        int
14320        guestfs_setxattr (guestfs_h *g,
14321                          const char *xattr,
14322                          const char *val,
14323                          int vallen,
14324                          const char *path);
14325
14326       This call sets the extended attribute named "xattr" of the file "path"
14327       to the value "val" (of length "vallen").  The value is arbitrary 8 bit
14328       data.
14329
14330       See also: "guestfs_lsetxattr", attr(5).
14331
14332       This function returns 0 on success or -1 on error.
14333
14334       This function depends on the feature "linuxxattrs".  See also
14335       "guestfs_feature_available".
14336
14337       (Added in 1.0.59)
14338
14339   guestfs_sfdisk
14340        int
14341        guestfs_sfdisk (guestfs_h *g,
14342                        const char *device,
14343                        int cyls,
14344                        int heads,
14345                        int sectors,
14346                        char *const *lines);
14347
14348       This function is deprecated.  In new code, use the "guestfs_part_add"
14349       call instead.
14350
14351       Deprecated functions will not be removed from the API, but the fact
14352       that they are deprecated indicates that there are problems with correct
14353       use of these functions.
14354
14355       This is a direct interface to the sfdisk(8) program for creating
14356       partitions on block devices.
14357
14358       "device" should be a block device, for example /dev/sda.
14359
14360       "cyls", "heads" and "sectors" are the number of cylinders, heads and
14361       sectors on the device, which are passed directly to sfdisk(8) as the
14362       -C, -H and -S parameters.  If you pass 0 for any of these, then the
14363       corresponding parameter is omitted.  Usually for ‘large’ disks, you can
14364       just pass 0 for these, but for small (floppy-sized) disks, sfdisk(8)
14365       (or rather, the kernel) cannot work out the right geometry and you will
14366       need to tell it.
14367
14368       "lines" is a list of lines that we feed to sfdisk(8).  For more
14369       information refer to the sfdisk(8) manpage.
14370
14371       To create a single partition occupying the whole disk, you would pass
14372       "lines" as a single element list, when the single element being the
14373       string "," (comma).
14374
14375       See also: "guestfs_sfdisk_l", "guestfs_sfdisk_N", "guestfs_part_init"
14376
14377       This function returns 0 on success or -1 on error.
14378
14379       (Added in 0.8)
14380
14381   guestfs_sfdiskM
14382        int
14383        guestfs_sfdiskM (guestfs_h *g,
14384                         const char *device,
14385                         char *const *lines);
14386
14387       This function is deprecated.  In new code, use the "guestfs_part_add"
14388       call instead.
14389
14390       Deprecated functions will not be removed from the API, but the fact
14391       that they are deprecated indicates that there are problems with correct
14392       use of these functions.
14393
14394       This is a simplified interface to the "guestfs_sfdisk" command, where
14395       partition sizes are specified in megabytes only (rounded to the nearest
14396       cylinder) and you don't need to specify the cyls, heads and sectors
14397       parameters which were rarely if ever used anyway.
14398
14399       See also: "guestfs_sfdisk", the sfdisk(8) manpage and
14400       "guestfs_part_disk"
14401
14402       This function returns 0 on success or -1 on error.
14403
14404       (Added in 1.0.55)
14405
14406   guestfs_sfdisk_N
14407        int
14408        guestfs_sfdisk_N (guestfs_h *g,
14409                          const char *device,
14410                          int partnum,
14411                          int cyls,
14412                          int heads,
14413                          int sectors,
14414                          const char *line);
14415
14416       This function is deprecated.  In new code, use the "guestfs_part_add"
14417       call instead.
14418
14419       Deprecated functions will not be removed from the API, but the fact
14420       that they are deprecated indicates that there are problems with correct
14421       use of these functions.
14422
14423       This runs sfdisk(8) option to modify just the single partition "n"
14424       (note: "n" counts from 1).
14425
14426       For other parameters, see "guestfs_sfdisk".  You should usually pass 0
14427       for the cyls/heads/sectors parameters.
14428
14429       See also: "guestfs_part_add"
14430
14431       This function returns 0 on success or -1 on error.
14432
14433       (Added in 1.0.26)
14434
14435   guestfs_sfdisk_disk_geometry
14436        char *
14437        guestfs_sfdisk_disk_geometry (guestfs_h *g,
14438                                      const char *device);
14439
14440       This displays the disk geometry of "device" read from the partition
14441       table.  Especially in the case where the underlying block device has
14442       been resized, this can be different from the kernel’s idea of the
14443       geometry (see "guestfs_sfdisk_kernel_geometry").
14444
14445       The result is in human-readable format, and not designed to be parsed.
14446
14447       This function returns a string, or NULL on error.  The caller must free
14448       the returned string after use.
14449
14450       (Added in 1.0.26)
14451
14452   guestfs_sfdisk_kernel_geometry
14453        char *
14454        guestfs_sfdisk_kernel_geometry (guestfs_h *g,
14455                                        const char *device);
14456
14457       This displays the kernel’s idea of the geometry of "device".
14458
14459       The result is in human-readable format, and not designed to be parsed.
14460
14461       This function returns a string, or NULL on error.  The caller must free
14462       the returned string after use.
14463
14464       (Added in 1.0.26)
14465
14466   guestfs_sfdisk_l
14467        char *
14468        guestfs_sfdisk_l (guestfs_h *g,
14469                          const char *device);
14470
14471       This function is deprecated.  In new code, use the "guestfs_part_list"
14472       call instead.
14473
14474       Deprecated functions will not be removed from the API, but the fact
14475       that they are deprecated indicates that there are problems with correct
14476       use of these functions.
14477
14478       This displays the partition table on "device", in the human-readable
14479       output of the sfdisk(8) command.  It is not intended to be parsed.
14480
14481       See also: "guestfs_part_list"
14482
14483       This function returns a string, or NULL on error.  The caller must free
14484       the returned string after use.
14485
14486       (Added in 1.0.26)
14487
14488   guestfs_sh
14489        char *
14490        guestfs_sh (guestfs_h *g,
14491                    const char *command);
14492
14493       This call runs a command from the guest filesystem via the guest’s
14494       /bin/sh.
14495
14496       This is like "guestfs_command", but passes the command to:
14497
14498        /bin/sh -c "command"
14499
14500       Depending on the guest’s shell, this usually results in wildcards being
14501       expanded, shell expressions being interpolated and so on.
14502
14503       All the provisos about "guestfs_command" apply to this call.
14504
14505       This function returns a string, or NULL on error.  The caller must free
14506       the returned string after use.
14507
14508       (Added in 1.0.50)
14509
14510   guestfs_sh_lines
14511        char **
14512        guestfs_sh_lines (guestfs_h *g,
14513                          const char *command);
14514
14515       This is the same as "guestfs_sh", but splits the result into a list of
14516       lines.
14517
14518       See also: "guestfs_command_lines"
14519
14520       This function returns a NULL-terminated array of strings (like
14521       environ(3)), or NULL if there was an error.  The caller must free the
14522       strings and the array after use.
14523
14524       (Added in 1.0.50)
14525
14526   guestfs_shutdown
14527        int
14528        guestfs_shutdown (guestfs_h *g);
14529
14530       This is the opposite of "guestfs_launch".  It performs an orderly
14531       shutdown of the backend process(es).  If the autosync flag is set
14532       (which is the default) then the disk image is synchronized.
14533
14534       If the subprocess exits with an error then this function will return an
14535       error, which should not be ignored (it may indicate that the disk image
14536       could not be written out properly).
14537
14538       It is safe to call this multiple times.  Extra calls are ignored.
14539
14540       This call does not close or free up the handle.  You still need to call
14541       "guestfs_close" afterwards.
14542
14543       "guestfs_close" will call this if you don't do it explicitly, but note
14544       that any errors are ignored in that case.
14545
14546       This function returns 0 on success or -1 on error.
14547
14548       (Added in 1.19.16)
14549
14550   guestfs_sleep
14551        int
14552        guestfs_sleep (guestfs_h *g,
14553                       int secs);
14554
14555       Sleep for "secs" seconds.
14556
14557       This function returns 0 on success or -1 on error.
14558
14559       (Added in 1.0.41)
14560
14561   guestfs_stat
14562        struct guestfs_stat *
14563        guestfs_stat (guestfs_h *g,
14564                      const char *path);
14565
14566       This function is deprecated.  In new code, use the "guestfs_statns"
14567       call instead.
14568
14569       Deprecated functions will not be removed from the API, but the fact
14570       that they are deprecated indicates that there are problems with correct
14571       use of these functions.
14572
14573       Returns file information for the given "path".
14574
14575       This is the same as the stat(2) system call.
14576
14577       This function returns a "struct guestfs_stat *", or NULL if there was
14578       an error.  The caller must call "guestfs_free_stat" after use.
14579
14580       (Added in 1.9.2)
14581
14582   guestfs_statns
14583        struct guestfs_statns *
14584        guestfs_statns (guestfs_h *g,
14585                        const char *path);
14586
14587       Returns file information for the given "path".
14588
14589       This is the same as the stat(2) system call.
14590
14591       This function returns a "struct guestfs_statns *", or NULL if there was
14592       an error.  The caller must call "guestfs_free_statns" after use.
14593
14594       (Added in 1.27.53)
14595
14596   guestfs_statvfs
14597        struct guestfs_statvfs *
14598        guestfs_statvfs (guestfs_h *g,
14599                         const char *path);
14600
14601       Returns file system statistics for any mounted file system.  "path"
14602       should be a file or directory in the mounted file system (typically it
14603       is the mount point itself, but it doesn't need to be).
14604
14605       This is the same as the statvfs(2) system call.
14606
14607       This function returns a "struct guestfs_statvfs *", or NULL if there
14608       was an error.  The caller must call "guestfs_free_statvfs" after use.
14609
14610       (Added in 1.9.2)
14611
14612   guestfs_strings
14613        char **
14614        guestfs_strings (guestfs_h *g,
14615                         const char *path);
14616
14617       This runs the strings(1) command on a file and returns the list of
14618       printable strings found.
14619
14620       The "strings" command has, in the past, had problems with parsing
14621       untrusted files.  These are mitigated in the current version of
14622       libguestfs, but see "CVE-2014-8484".
14623
14624       This function returns a NULL-terminated array of strings (like
14625       environ(3)), or NULL if there was an error.  The caller must free the
14626       strings and the array after use.
14627
14628       Because of the message protocol, there is a transfer limit of somewhere
14629       between 2MB and 4MB.  See "PROTOCOL LIMITS".
14630
14631       (Added in 1.0.22)
14632
14633   guestfs_strings_e
14634        char **
14635        guestfs_strings_e (guestfs_h *g,
14636                           const char *encoding,
14637                           const char *path);
14638
14639       This is like the "guestfs_strings" command, but allows you to specify
14640       the encoding of strings that are looked for in the source file "path".
14641
14642       Allowed encodings are:
14643
14644       s   Single 7-bit-byte characters like ASCII and the ASCII-compatible
14645           parts of ISO-8859-X (this is what "guestfs_strings" uses).
14646
14647       S   Single 8-bit-byte characters.
14648
14649       b   16-bit big endian strings such as those encoded in UTF-16BE or
14650           UCS-2BE.
14651
14652       l (lower case letter L)
14653           16-bit little endian such as UTF-16LE and UCS-2LE.  This is useful
14654           for examining binaries in Windows guests.
14655
14656       B   32-bit big endian such as UCS-4BE.
14657
14658       L   32-bit little endian such as UCS-4LE.
14659
14660       The returned strings are transcoded to UTF-8.
14661
14662       The "strings" command has, in the past, had problems with parsing
14663       untrusted files.  These are mitigated in the current version of
14664       libguestfs, but see "CVE-2014-8484".
14665
14666       This function returns a NULL-terminated array of strings (like
14667       environ(3)), or NULL if there was an error.  The caller must free the
14668       strings and the array after use.
14669
14670       Because of the message protocol, there is a transfer limit of somewhere
14671       between 2MB and 4MB.  See "PROTOCOL LIMITS".
14672
14673       (Added in 1.0.22)
14674
14675   guestfs_swapoff_device
14676        int
14677        guestfs_swapoff_device (guestfs_h *g,
14678                                const char *device);
14679
14680       This command disables the libguestfs appliance swap device or partition
14681       named "device".  See "guestfs_swapon_device".
14682
14683       This function returns 0 on success or -1 on error.
14684
14685       (Added in 1.0.66)
14686
14687   guestfs_swapoff_file
14688        int
14689        guestfs_swapoff_file (guestfs_h *g,
14690                              const char *file);
14691
14692       This command disables the libguestfs appliance swap on file.
14693
14694       This function returns 0 on success or -1 on error.
14695
14696       (Added in 1.0.66)
14697
14698   guestfs_swapoff_label
14699        int
14700        guestfs_swapoff_label (guestfs_h *g,
14701                               const char *label);
14702
14703       This command disables the libguestfs appliance swap on labeled swap
14704       partition.
14705
14706       This function returns 0 on success or -1 on error.
14707
14708       (Added in 1.0.66)
14709
14710   guestfs_swapoff_uuid
14711        int
14712        guestfs_swapoff_uuid (guestfs_h *g,
14713                              const char *uuid);
14714
14715       This command disables the libguestfs appliance swap partition with the
14716       given UUID.
14717
14718       This function returns 0 on success or -1 on error.
14719
14720       This function depends on the feature "linuxfsuuid".  See also
14721       "guestfs_feature_available".
14722
14723       (Added in 1.0.66)
14724
14725   guestfs_swapon_device
14726        int
14727        guestfs_swapon_device (guestfs_h *g,
14728                               const char *device);
14729
14730       This command enables the libguestfs appliance to use the swap device or
14731       partition named "device".  The increased memory is made available for
14732       all commands, for example those run using "guestfs_command" or
14733       "guestfs_sh".
14734
14735       Note that you should not swap to existing guest swap partitions unless
14736       you know what you are doing.  They may contain hibernation information,
14737       or other information that the guest doesn't want you to trash.  You
14738       also risk leaking information about the host to the guest this way.
14739       Instead, attach a new host device to the guest and swap on that.
14740
14741       This function returns 0 on success or -1 on error.
14742
14743       (Added in 1.0.66)
14744
14745   guestfs_swapon_file
14746        int
14747        guestfs_swapon_file (guestfs_h *g,
14748                             const char *file);
14749
14750       This command enables swap to a file.  See "guestfs_swapon_device" for
14751       other notes.
14752
14753       This function returns 0 on success or -1 on error.
14754
14755       (Added in 1.0.66)
14756
14757   guestfs_swapon_label
14758        int
14759        guestfs_swapon_label (guestfs_h *g,
14760                              const char *label);
14761
14762       This command enables swap to a labeled swap partition.  See
14763       "guestfs_swapon_device" for other notes.
14764
14765       This function returns 0 on success or -1 on error.
14766
14767       (Added in 1.0.66)
14768
14769   guestfs_swapon_uuid
14770        int
14771        guestfs_swapon_uuid (guestfs_h *g,
14772                             const char *uuid);
14773
14774       This command enables swap to a swap partition with the given UUID.  See
14775       "guestfs_swapon_device" for other notes.
14776
14777       This function returns 0 on success or -1 on error.
14778
14779       This function depends on the feature "linuxfsuuid".  See also
14780       "guestfs_feature_available".
14781
14782       (Added in 1.0.66)
14783
14784   guestfs_sync
14785        int
14786        guestfs_sync (guestfs_h *g);
14787
14788       This syncs the disk, so that any writes are flushed through to the
14789       underlying disk image.
14790
14791       You should always call this if you have modified a disk image, before
14792       closing the handle.
14793
14794       This function returns 0 on success or -1 on error.
14795
14796       (Added in 0.3)
14797
14798   guestfs_syslinux
14799        int
14800        guestfs_syslinux (guestfs_h *g,
14801                          const char *device,
14802                          ...);
14803
14804       You may supply a list of optional arguments to this call.  Use zero or
14805       more of the following pairs of parameters, and terminate the list with
14806       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
14807
14808        GUESTFS_SYSLINUX_DIRECTORY, const char *directory,
14809
14810       Install the SYSLINUX bootloader on "device".
14811
14812       The device parameter must be either a whole disk formatted as a FAT
14813       filesystem, or a partition formatted as a FAT filesystem.  In the
14814       latter case, the partition should be marked as "active"
14815       ("guestfs_part_set_bootable") and a Master Boot Record must be
14816       installed (eg. using "guestfs_pwrite_device") on the first sector of
14817       the whole disk.  The SYSLINUX package comes with some suitable Master
14818       Boot Records.  See the syslinux(1) man page for further information.
14819
14820       The optional arguments are:
14821
14822       directory
14823           Install SYSLINUX in the named subdirectory, instead of in the root
14824           directory of the FAT filesystem.
14825
14826       Additional configuration can be supplied to SYSLINUX by placing a file
14827       called syslinux.cfg on the FAT filesystem, either in the root
14828       directory, or under directory if that optional argument is being used.
14829       For further information about the contents of this file, see
14830       syslinux(1).
14831
14832       See also "guestfs_extlinux".
14833
14834       This function returns 0 on success or -1 on error.
14835
14836       This function depends on the feature "syslinux".  See also
14837       "guestfs_feature_available".
14838
14839       (Added in 1.21.27)
14840
14841   guestfs_syslinux_va
14842        int
14843        guestfs_syslinux_va (guestfs_h *g,
14844                             const char *device,
14845                             va_list args);
14846
14847       This is the "va_list variant" of "guestfs_syslinux".
14848
14849       See "CALLS WITH OPTIONAL ARGUMENTS".
14850
14851   guestfs_syslinux_argv
14852        int
14853        guestfs_syslinux_argv (guestfs_h *g,
14854                               const char *device,
14855                               const struct guestfs_syslinux_argv *optargs);
14856
14857       This is the "argv variant" of "guestfs_syslinux".
14858
14859       See "CALLS WITH OPTIONAL ARGUMENTS".
14860
14861   guestfs_tail
14862        char **
14863        guestfs_tail (guestfs_h *g,
14864                      const char *path);
14865
14866       This command returns up to the last 10 lines of a file as a list of
14867       strings.
14868
14869       This function returns a NULL-terminated array of strings (like
14870       environ(3)), or NULL if there was an error.  The caller must free the
14871       strings and the array after use.
14872
14873       Because of the message protocol, there is a transfer limit of somewhere
14874       between 2MB and 4MB.  See "PROTOCOL LIMITS".
14875
14876       (Added in 1.0.54)
14877
14878   guestfs_tail_n
14879        char **
14880        guestfs_tail_n (guestfs_h *g,
14881                        int nrlines,
14882                        const char *path);
14883
14884       If the parameter "nrlines" is a positive number, this returns the last
14885       "nrlines" lines of the file "path".
14886
14887       If the parameter "nrlines" is a negative number, this returns lines
14888       from the file "path", starting with the "-nrlines"'th line.
14889
14890       If the parameter "nrlines" is zero, this returns an empty list.
14891
14892       This function returns a NULL-terminated array of strings (like
14893       environ(3)), or NULL if there was an error.  The caller must free the
14894       strings and the array after use.
14895
14896       Because of the message protocol, there is a transfer limit of somewhere
14897       between 2MB and 4MB.  See "PROTOCOL LIMITS".
14898
14899       (Added in 1.0.54)
14900
14901   guestfs_tar_in
14902        int
14903        guestfs_tar_in (guestfs_h *g,
14904                        const char *tarfile,
14905                        const char *directory);
14906
14907       This function is provided for backwards compatibility with earlier
14908       versions of libguestfs.  It simply calls "guestfs_tar_in_opts" with no
14909       optional arguments.
14910
14911       (Added in 1.0.3)
14912
14913   guestfs_tar_in_opts
14914        int
14915        guestfs_tar_in_opts (guestfs_h *g,
14916                             const char *tarfile,
14917                             const char *directory,
14918                             ...);
14919
14920       You may supply a list of optional arguments to this call.  Use zero or
14921       more of the following pairs of parameters, and terminate the list with
14922       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
14923
14924        GUESTFS_TAR_IN_OPTS_COMPRESS, const char *compress,
14925        GUESTFS_TAR_IN_OPTS_XATTRS, int xattrs,
14926        GUESTFS_TAR_IN_OPTS_SELINUX, int selinux,
14927        GUESTFS_TAR_IN_OPTS_ACLS, int acls,
14928
14929       This command uploads and unpacks local file "tarfile" into directory.
14930
14931       The optional "compress" flag controls compression.  If not given, then
14932       the input should be an uncompressed tar file.  Otherwise one of the
14933       following strings may be given to select the compression type of the
14934       input file: "compress", "gzip", "bzip2", "xz", "lzop".  (Note that not
14935       all builds of libguestfs will support all of these compression types).
14936
14937       The other optional arguments are:
14938
14939       "xattrs"
14940           If set to true, extended attributes are restored from the tar file.
14941
14942       "selinux"
14943           If set to true, SELinux contexts are restored from the tar file.
14944
14945       "acls"
14946           If set to true, POSIX ACLs are restored from the tar file.
14947
14948       This function returns 0 on success or -1 on error.
14949
14950       (Added in 1.0.3)
14951
14952   guestfs_tar_in_opts_va
14953        int
14954        guestfs_tar_in_opts_va (guestfs_h *g,
14955                                const char *tarfile,
14956                                const char *directory,
14957                                va_list args);
14958
14959       This is the "va_list variant" of "guestfs_tar_in_opts".
14960
14961       See "CALLS WITH OPTIONAL ARGUMENTS".
14962
14963   guestfs_tar_in_opts_argv
14964        int
14965        guestfs_tar_in_opts_argv (guestfs_h *g,
14966                                  const char *tarfile,
14967                                  const char *directory,
14968                                  const struct guestfs_tar_in_opts_argv *optargs);
14969
14970       This is the "argv variant" of "guestfs_tar_in_opts".
14971
14972       See "CALLS WITH OPTIONAL ARGUMENTS".
14973
14974   guestfs_tar_out
14975        int
14976        guestfs_tar_out (guestfs_h *g,
14977                         const char *directory,
14978                         const char *tarfile);
14979
14980       This function is provided for backwards compatibility with earlier
14981       versions of libguestfs.  It simply calls "guestfs_tar_out_opts" with no
14982       optional arguments.
14983
14984       (Added in 1.0.3)
14985
14986   guestfs_tar_out_opts
14987        int
14988        guestfs_tar_out_opts (guestfs_h *g,
14989                              const char *directory,
14990                              const char *tarfile,
14991                              ...);
14992
14993       You may supply a list of optional arguments to this call.  Use zero or
14994       more of the following pairs of parameters, and terminate the list with
14995       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
14996
14997        GUESTFS_TAR_OUT_OPTS_COMPRESS, const char *compress,
14998        GUESTFS_TAR_OUT_OPTS_NUMERICOWNER, int numericowner,
14999        GUESTFS_TAR_OUT_OPTS_EXCLUDES, char *const *excludes,
15000        GUESTFS_TAR_OUT_OPTS_XATTRS, int xattrs,
15001        GUESTFS_TAR_OUT_OPTS_SELINUX, int selinux,
15002        GUESTFS_TAR_OUT_OPTS_ACLS, int acls,
15003
15004       This command packs the contents of directory and downloads it to local
15005       file "tarfile".
15006
15007       The optional "compress" flag controls compression.  If not given, then
15008       the output will be an uncompressed tar file.  Otherwise one of the
15009       following strings may be given to select the compression type of the
15010       output file: "compress", "gzip", "bzip2", "xz", "lzop".  (Note that not
15011       all builds of libguestfs will support all of these compression types).
15012
15013       The other optional arguments are:
15014
15015       "excludes"
15016           A list of wildcards.  Files are excluded if they match any of the
15017           wildcards.
15018
15019       "numericowner"
15020           If set to true, the output tar file will contain UID/GID numbers
15021           instead of user/group names.
15022
15023       "xattrs"
15024           If set to true, extended attributes are saved in the output tar.
15025
15026       "selinux"
15027           If set to true, SELinux contexts are saved in the output tar.
15028
15029       "acls"
15030           If set to true, POSIX ACLs are saved in the output tar.
15031
15032       This function returns 0 on success or -1 on error.
15033
15034       (Added in 1.0.3)
15035
15036   guestfs_tar_out_opts_va
15037        int
15038        guestfs_tar_out_opts_va (guestfs_h *g,
15039                                 const char *directory,
15040                                 const char *tarfile,
15041                                 va_list args);
15042
15043       This is the "va_list variant" of "guestfs_tar_out_opts".
15044
15045       See "CALLS WITH OPTIONAL ARGUMENTS".
15046
15047   guestfs_tar_out_opts_argv
15048        int
15049        guestfs_tar_out_opts_argv (guestfs_h *g,
15050                                   const char *directory,
15051                                   const char *tarfile,
15052                                   const struct guestfs_tar_out_opts_argv *optargs);
15053
15054       This is the "argv variant" of "guestfs_tar_out_opts".
15055
15056       See "CALLS WITH OPTIONAL ARGUMENTS".
15057
15058   guestfs_tgz_in
15059        int
15060        guestfs_tgz_in (guestfs_h *g,
15061                        const char *tarball,
15062                        const char *directory);
15063
15064       This function is deprecated.  In new code, use the "guestfs_tar_in"
15065       call instead.
15066
15067       Deprecated functions will not be removed from the API, but the fact
15068       that they are deprecated indicates that there are problems with correct
15069       use of these functions.
15070
15071       This command uploads and unpacks local file "tarball" (a gzip
15072       compressed tar file) into directory.
15073
15074       This function returns 0 on success or -1 on error.
15075
15076       (Added in 1.0.3)
15077
15078   guestfs_tgz_out
15079        int
15080        guestfs_tgz_out (guestfs_h *g,
15081                         const char *directory,
15082                         const char *tarball);
15083
15084       This function is deprecated.  In new code, use the "guestfs_tar_out"
15085       call instead.
15086
15087       Deprecated functions will not be removed from the API, but the fact
15088       that they are deprecated indicates that there are problems with correct
15089       use of these functions.
15090
15091       This command packs the contents of directory and downloads it to local
15092       file "tarball".
15093
15094       This function returns 0 on success or -1 on error.
15095
15096       (Added in 1.0.3)
15097
15098   guestfs_touch
15099        int
15100        guestfs_touch (guestfs_h *g,
15101                       const char *path);
15102
15103       Touch acts like the touch(1) command.  It can be used to update the
15104       timestamps on a file, or, if the file does not exist, to create a new
15105       zero-length file.
15106
15107       This command only works on regular files, and will fail on other file
15108       types such as directories, symbolic links, block special etc.
15109
15110       This function returns 0 on success or -1 on error.
15111
15112       (Added in 0.3)
15113
15114   guestfs_truncate
15115        int
15116        guestfs_truncate (guestfs_h *g,
15117                          const char *path);
15118
15119       This command truncates "path" to a zero-length file.  The file must
15120       exist already.
15121
15122       This function returns 0 on success or -1 on error.
15123
15124       (Added in 1.0.77)
15125
15126   guestfs_truncate_size
15127        int
15128        guestfs_truncate_size (guestfs_h *g,
15129                               const char *path,
15130                               int64_t size);
15131
15132       This command truncates "path" to size "size" bytes.  The file must
15133       exist already.
15134
15135       If the current file size is less than "size" then the file is extended
15136       to the required size with zero bytes.  This creates a sparse file (ie.
15137       disk blocks are not allocated for the file until you write to it).  To
15138       create a non-sparse file of zeroes, use "guestfs_fallocate64" instead.
15139
15140       This function returns 0 on success or -1 on error.
15141
15142       (Added in 1.0.77)
15143
15144   guestfs_tune2fs
15145        int
15146        guestfs_tune2fs (guestfs_h *g,
15147                         const char *device,
15148                         ...);
15149
15150       You may supply a list of optional arguments to this call.  Use zero or
15151       more of the following pairs of parameters, and terminate the list with
15152       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
15153
15154        GUESTFS_TUNE2FS_FORCE, int force,
15155        GUESTFS_TUNE2FS_MAXMOUNTCOUNT, int maxmountcount,
15156        GUESTFS_TUNE2FS_MOUNTCOUNT, int mountcount,
15157        GUESTFS_TUNE2FS_ERRORBEHAVIOR, const char *errorbehavior,
15158        GUESTFS_TUNE2FS_GROUP, int64_t group,
15159        GUESTFS_TUNE2FS_INTERVALBETWEENCHECKS, int intervalbetweenchecks,
15160        GUESTFS_TUNE2FS_RESERVEDBLOCKSPERCENTAGE, int reservedblockspercentage,
15161        GUESTFS_TUNE2FS_LASTMOUNTEDDIRECTORY, const char *lastmounteddirectory,
15162        GUESTFS_TUNE2FS_RESERVEDBLOCKSCOUNT, int64_t reservedblockscount,
15163        GUESTFS_TUNE2FS_USER, int64_t user,
15164
15165       This call allows you to adjust various filesystem parameters of an
15166       ext2/ext3/ext4 filesystem called "device".
15167
15168       The optional parameters are:
15169
15170       "force"
15171           Force tune2fs to complete the operation even in the face of errors.
15172           This is the same as the tune2fs(8) "-f" option.
15173
15174       "maxmountcount"
15175           Set the number of mounts after which the filesystem is checked by
15176           e2fsck(8).  If this is 0 then the number of mounts is disregarded.
15177           This is the same as the tune2fs(8) "-c" option.
15178
15179       "mountcount"
15180           Set the number of times the filesystem has been mounted.  This is
15181           the same as the tune2fs(8) "-C" option.
15182
15183       "errorbehavior"
15184           Change the behavior of the kernel code when errors are detected.
15185           Possible values currently are: "continue", "remount-ro", "panic".
15186           In practice these options don't really make any difference,
15187           particularly for write errors.
15188
15189           This is the same as the tune2fs(8) "-e" option.
15190
15191       "group"
15192           Set the group which can use reserved filesystem blocks.  This is
15193           the same as the tune2fs(8) "-g" option except that it can only be
15194           specified as a number.
15195
15196       "intervalbetweenchecks"
15197           Adjust the maximal time between two filesystem checks (in seconds).
15198           If the option is passed as 0 then time-dependent checking is
15199           disabled.
15200
15201           This is the same as the tune2fs(8) "-i" option.
15202
15203       "reservedblockspercentage"
15204           Set the percentage of the filesystem which may only be allocated by
15205           privileged processes.  This is the same as the tune2fs(8) "-m"
15206           option.
15207
15208       "lastmounteddirectory"
15209           Set the last mounted directory.  This is the same as the tune2fs(8)
15210           "-M" option.
15211
15212       "reservedblockscount" Set the number of reserved filesystem blocks.
15213       This is the same as the tune2fs(8) "-r" option.
15214       "user"
15215           Set the user who can use the reserved filesystem blocks.  This is
15216           the same as the tune2fs(8) "-u" option except that it can only be
15217           specified as a number.
15218
15219       To get the current values of filesystem parameters, see
15220       "guestfs_tune2fs_l".  For precise details of how tune2fs works, see the
15221       tune2fs(8) man page.
15222
15223       This function returns 0 on success or -1 on error.
15224
15225       (Added in 1.15.4)
15226
15227   guestfs_tune2fs_va
15228        int
15229        guestfs_tune2fs_va (guestfs_h *g,
15230                            const char *device,
15231                            va_list args);
15232
15233       This is the "va_list variant" of "guestfs_tune2fs".
15234
15235       See "CALLS WITH OPTIONAL ARGUMENTS".
15236
15237   guestfs_tune2fs_argv
15238        int
15239        guestfs_tune2fs_argv (guestfs_h *g,
15240                              const char *device,
15241                              const struct guestfs_tune2fs_argv *optargs);
15242
15243       This is the "argv variant" of "guestfs_tune2fs".
15244
15245       See "CALLS WITH OPTIONAL ARGUMENTS".
15246
15247   guestfs_tune2fs_l
15248        char **
15249        guestfs_tune2fs_l (guestfs_h *g,
15250                           const char *device);
15251
15252       This returns the contents of the ext2, ext3 or ext4 filesystem
15253       superblock on "device".
15254
15255       It is the same as running "tune2fs -l device".  See tune2fs(8) manpage
15256       for more details.  The list of fields returned isn't clearly defined,
15257       and depends on both the version of "tune2fs" that libguestfs was built
15258       against, and the filesystem itself.
15259
15260       This function returns a NULL-terminated array of strings, or NULL if
15261       there was an error.  The array of strings will always have length
15262       "2n+1", where "n" keys and values alternate, followed by the trailing
15263       NULL entry.  The caller must free the strings and the array after use.
15264
15265       (Added in 1.9.2)
15266
15267   guestfs_txz_in
15268        int
15269        guestfs_txz_in (guestfs_h *g,
15270                        const char *tarball,
15271                        const char *directory);
15272
15273       This function is deprecated.  In new code, use the "guestfs_tar_in"
15274       call instead.
15275
15276       Deprecated functions will not be removed from the API, but the fact
15277       that they are deprecated indicates that there are problems with correct
15278       use of these functions.
15279
15280       This command uploads and unpacks local file "tarball" (an xz compressed
15281       tar file) into directory.
15282
15283       This function returns 0 on success or -1 on error.
15284
15285       This function depends on the feature "xz".  See also
15286       "guestfs_feature_available".
15287
15288       (Added in 1.3.2)
15289
15290   guestfs_txz_out
15291        int
15292        guestfs_txz_out (guestfs_h *g,
15293                         const char *directory,
15294                         const char *tarball);
15295
15296       This function is deprecated.  In new code, use the "guestfs_tar_out"
15297       call instead.
15298
15299       Deprecated functions will not be removed from the API, but the fact
15300       that they are deprecated indicates that there are problems with correct
15301       use of these functions.
15302
15303       This command packs the contents of directory and downloads it to local
15304       file "tarball" (as an xz compressed tar archive).
15305
15306       This function returns 0 on success or -1 on error.
15307
15308       This function depends on the feature "xz".  See also
15309       "guestfs_feature_available".
15310
15311       (Added in 1.3.2)
15312
15313   guestfs_umask
15314        int
15315        guestfs_umask (guestfs_h *g,
15316                       int mask);
15317
15318       This function sets the mask used for creating new files and device
15319       nodes to "mask & 0777".
15320
15321       Typical umask values would be 022 which creates new files with
15322       permissions like "-rw-r--r--" or "-rwxr-xr-x", and 002 which creates
15323       new files with permissions like "-rw-rw-r--" or "-rwxrwxr-x".
15324
15325       The default umask is 022.  This is important because it means that
15326       directories and device nodes will be created with 0644 or 0755 mode
15327       even if you specify 0777.
15328
15329       See also "guestfs_get_umask", umask(2), "guestfs_mknod",
15330       "guestfs_mkdir".
15331
15332       This call returns the previous umask.
15333
15334       On error this function returns -1.
15335
15336       (Added in 1.0.55)
15337
15338   guestfs_umount
15339        int
15340        guestfs_umount (guestfs_h *g,
15341                        const char *pathordevice);
15342
15343       This function is provided for backwards compatibility with earlier
15344       versions of libguestfs.  It simply calls "guestfs_umount_opts" with no
15345       optional arguments.
15346
15347       (Added in 0.8)
15348
15349   guestfs_umount_opts
15350        int
15351        guestfs_umount_opts (guestfs_h *g,
15352                             const char *pathordevice,
15353                             ...);
15354
15355       You may supply a list of optional arguments to this call.  Use zero or
15356       more of the following pairs of parameters, and terminate the list with
15357       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
15358
15359        GUESTFS_UMOUNT_OPTS_FORCE, int force,
15360        GUESTFS_UMOUNT_OPTS_LAZYUNMOUNT, int lazyunmount,
15361
15362       This unmounts the given filesystem.  The filesystem may be specified
15363       either by its mountpoint (path) or the device which contains the
15364       filesystem.
15365
15366       This function returns 0 on success or -1 on error.
15367
15368       (Added in 0.8)
15369
15370   guestfs_umount_opts_va
15371        int
15372        guestfs_umount_opts_va (guestfs_h *g,
15373                                const char *pathordevice,
15374                                va_list args);
15375
15376       This is the "va_list variant" of "guestfs_umount_opts".
15377
15378       See "CALLS WITH OPTIONAL ARGUMENTS".
15379
15380   guestfs_umount_opts_argv
15381        int
15382        guestfs_umount_opts_argv (guestfs_h *g,
15383                                  const char *pathordevice,
15384                                  const struct guestfs_umount_opts_argv *optargs);
15385
15386       This is the "argv variant" of "guestfs_umount_opts".
15387
15388       See "CALLS WITH OPTIONAL ARGUMENTS".
15389
15390   guestfs_umount_all
15391        int
15392        guestfs_umount_all (guestfs_h *g);
15393
15394       This unmounts all mounted filesystems.
15395
15396       Some internal mounts are not unmounted by this call.
15397
15398       This function returns 0 on success or -1 on error.
15399
15400       (Added in 0.8)
15401
15402   guestfs_umount_local
15403        int
15404        guestfs_umount_local (guestfs_h *g,
15405                              ...);
15406
15407       You may supply a list of optional arguments to this call.  Use zero or
15408       more of the following pairs of parameters, and terminate the list with
15409       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
15410
15411        GUESTFS_UMOUNT_LOCAL_RETRY, int retry,
15412
15413       If libguestfs is exporting the filesystem on a local mountpoint, then
15414       this unmounts it.
15415
15416       See "MOUNT LOCAL" for full documentation.
15417
15418       This function returns 0 on success or -1 on error.
15419
15420       (Added in 1.17.22)
15421
15422   guestfs_umount_local_va
15423        int
15424        guestfs_umount_local_va (guestfs_h *g,
15425                                 va_list args);
15426
15427       This is the "va_list variant" of "guestfs_umount_local".
15428
15429       See "CALLS WITH OPTIONAL ARGUMENTS".
15430
15431   guestfs_umount_local_argv
15432        int
15433        guestfs_umount_local_argv (guestfs_h *g,
15434                                   const struct guestfs_umount_local_argv *optargs);
15435
15436       This is the "argv variant" of "guestfs_umount_local".
15437
15438       See "CALLS WITH OPTIONAL ARGUMENTS".
15439
15440   guestfs_upload
15441        int
15442        guestfs_upload (guestfs_h *g,
15443                        const char *filename,
15444                        const char *remotefilename);
15445
15446       Upload local file filename to remotefilename on the filesystem.
15447
15448       filename can also be a named pipe.
15449
15450       See also "guestfs_download".
15451
15452       This function returns 0 on success or -1 on error.
15453
15454       This long-running command can generate progress notification messages
15455       so that the caller can display a progress bar or indicator.  To receive
15456       these messages, the caller must register a progress event callback.
15457       See "GUESTFS_EVENT_PROGRESS".
15458
15459       (Added in 1.0.2)
15460
15461   guestfs_upload_offset
15462        int
15463        guestfs_upload_offset (guestfs_h *g,
15464                               const char *filename,
15465                               const char *remotefilename,
15466                               int64_t offset);
15467
15468       Upload local file filename to remotefilename on the filesystem.
15469
15470       remotefilename is overwritten starting at the byte "offset" specified.
15471       The intention is to overwrite parts of existing files or devices,
15472       although if a non-existent file is specified then it is created with a
15473       "hole" before "offset".  The size of the data written is implicit in
15474       the size of the source filename.
15475
15476       Note that there is no limit on the amount of data that can be uploaded
15477       with this call, unlike with "guestfs_pwrite", and this call always
15478       writes the full amount unless an error occurs.
15479
15480       See also "guestfs_upload", "guestfs_pwrite".
15481
15482       This function returns 0 on success or -1 on error.
15483
15484       This long-running command can generate progress notification messages
15485       so that the caller can display a progress bar or indicator.  To receive
15486       these messages, the caller must register a progress event callback.
15487       See "GUESTFS_EVENT_PROGRESS".
15488
15489       (Added in 1.5.17)
15490
15491   guestfs_user_cancel
15492        int
15493        guestfs_user_cancel (guestfs_h *g);
15494
15495       This function cancels the current upload or download operation.
15496
15497       Unlike most other libguestfs calls, this function is signal safe and
15498       thread safe.  You can call it from a signal handler or from another
15499       thread, without needing to do any locking.
15500
15501       The transfer that was in progress (if there is one) will stop shortly
15502       afterwards, and will return an error.  The errno (see
15503       "guestfs_last_errno") is set to "EINTR", so you can test for this to
15504       find out if the operation was cancelled or failed because of another
15505       error.
15506
15507       No cleanup is performed: for example, if a file was being uploaded then
15508       after cancellation there may be a partially uploaded file.  It is the
15509       caller’s responsibility to clean up if necessary.
15510
15511       There are two common places that you might call "guestfs_user_cancel":
15512
15513       In an interactive text-based program, you might call it from a "SIGINT"
15514       signal handler so that pressing "^C" cancels the current operation.
15515       (You also need to call "guestfs_set_pgroup" so that child processes
15516       don't receive the "^C" signal).
15517
15518       In a graphical program, when the main thread is displaying a progress
15519       bar with a cancel button, wire up the cancel button to call this
15520       function.
15521
15522       This function returns 0 on success or -1 on error.
15523
15524       (Added in 1.11.18)
15525
15526   guestfs_utimens
15527        int
15528        guestfs_utimens (guestfs_h *g,
15529                         const char *path,
15530                         int64_t atsecs,
15531                         int64_t atnsecs,
15532                         int64_t mtsecs,
15533                         int64_t mtnsecs);
15534
15535       This command sets the timestamps of a file with nanosecond precision.
15536
15537       "atsecs", "atnsecs" are the last access time (atime) in secs and
15538       nanoseconds from the epoch.
15539
15540       "mtsecs", "mtnsecs" are the last modification time (mtime) in secs and
15541       nanoseconds from the epoch.
15542
15543       If the *nsecs field contains the special value "-1" then the
15544       corresponding timestamp is set to the current time.  (The *secs field
15545       is ignored in this case).
15546
15547       If the *nsecs field contains the special value "-2" then the
15548       corresponding timestamp is left unchanged.  (The *secs field is ignored
15549       in this case).
15550
15551       This function returns 0 on success or -1 on error.
15552
15553       (Added in 1.0.77)
15554
15555   guestfs_utsname
15556        struct guestfs_utsname *
15557        guestfs_utsname (guestfs_h *g);
15558
15559       This returns the kernel version of the appliance, where this is
15560       available.  This information is only useful for debugging.  Nothing in
15561       the returned structure is defined by the API.
15562
15563       This function returns a "struct guestfs_utsname *", or NULL if there
15564       was an error.  The caller must call "guestfs_free_utsname" after use.
15565
15566       (Added in 1.19.27)
15567
15568   guestfs_version
15569        struct guestfs_version *
15570        guestfs_version (guestfs_h *g);
15571
15572       Return the libguestfs version number that the program is linked
15573       against.
15574
15575       Note that because of dynamic linking this is not necessarily the
15576       version of libguestfs that you compiled against.  You can compile the
15577       program, and then at runtime dynamically link against a completely
15578       different libguestfs.so library.
15579
15580       This call was added in version 1.0.58.  In previous versions of
15581       libguestfs there was no way to get the version number.  From C code you
15582       can use dynamic linker functions to find out if this symbol exists (if
15583       it doesn't, then it’s an earlier version).
15584
15585       The call returns a structure with four elements.  The first three
15586       ("major", "minor" and "release") are numbers and correspond to the
15587       usual version triplet.  The fourth element ("extra") is a string and is
15588       normally empty, but may be used for distro-specific information.
15589
15590       To construct the original version string:
15591       "$major.$minor.$release$extra"
15592
15593       See also: "LIBGUESTFS VERSION NUMBERS".
15594
15595       Note: Don't use this call to test for availability of features.  In
15596       enterprise distributions we backport features from later versions into
15597       earlier versions, making this an unreliable way to test for features.
15598       Use "guestfs_available" or "guestfs_feature_available" instead.
15599
15600       This function returns a "struct guestfs_version *", or NULL if there
15601       was an error.  The caller must call "guestfs_free_version" after use.
15602
15603       (Added in 1.0.58)
15604
15605   guestfs_vfs_label
15606        char *
15607        guestfs_vfs_label (guestfs_h *g,
15608                           const char *mountable);
15609
15610       This returns the label of the filesystem on "mountable".
15611
15612       If the filesystem is unlabeled, this returns the empty string.
15613
15614       To find a filesystem from the label, use "guestfs_findfs_label".
15615
15616       This function returns a string, or NULL on error.  The caller must free
15617       the returned string after use.
15618
15619       (Added in 1.3.18)
15620
15621   guestfs_vfs_minimum_size
15622        int64_t
15623        guestfs_vfs_minimum_size (guestfs_h *g,
15624                                  const char *mountable);
15625
15626       Get the minimum size of filesystem in bytes.  This is the minimum
15627       possible size for filesystem shrinking.
15628
15629       If getting minimum size of specified filesystem is not supported, this
15630       will fail and set errno as ENOTSUP.
15631
15632       See also ntfsresize(8), resize2fs(8), btrfs(8), xfs_info(8).
15633
15634       On error this function returns -1.
15635
15636       (Added in 1.31.18)
15637
15638   guestfs_vfs_type
15639        char *
15640        guestfs_vfs_type (guestfs_h *g,
15641                          const char *mountable);
15642
15643       This command gets the filesystem type corresponding to the filesystem
15644       on "mountable".
15645
15646       For most filesystems, the result is the name of the Linux VFS module
15647       which would be used to mount this filesystem if you mounted it without
15648       specifying the filesystem type.  For example a string such as "ext3" or
15649       "ntfs".
15650
15651       This function returns a string, or NULL on error.  The caller must free
15652       the returned string after use.
15653
15654       (Added in 1.0.75)
15655
15656   guestfs_vfs_uuid
15657        char *
15658        guestfs_vfs_uuid (guestfs_h *g,
15659                          const char *mountable);
15660
15661       This returns the filesystem UUID of the filesystem on "mountable".
15662
15663       If the filesystem does not have a UUID, this returns the empty string.
15664
15665       To find a filesystem from the UUID, use "guestfs_findfs_uuid".
15666
15667       This function returns a string, or NULL on error.  The caller must free
15668       the returned string after use.
15669
15670       (Added in 1.3.18)
15671
15672   guestfs_vg_activate
15673        int
15674        guestfs_vg_activate (guestfs_h *g,
15675                             int activate,
15676                             char *const *volgroups);
15677
15678       This command activates or (if "activate" is false) deactivates all
15679       logical volumes in the listed volume groups "volgroups".
15680
15681       This command is the same as running "vgchange -a y|n volgroups..."
15682
15683       Note that if "volgroups" is an empty list then all volume groups are
15684       activated or deactivated.
15685
15686       This function returns 0 on success or -1 on error.
15687
15688       This function depends on the feature "lvm2".  See also
15689       "guestfs_feature_available".
15690
15691       (Added in 1.0.26)
15692
15693   guestfs_vg_activate_all
15694        int
15695        guestfs_vg_activate_all (guestfs_h *g,
15696                                 int activate);
15697
15698       This command activates or (if "activate" is false) deactivates all
15699       logical volumes in all volume groups.
15700
15701       This command is the same as running "vgchange -a y|n"
15702
15703       This function returns 0 on success or -1 on error.
15704
15705       This function depends on the feature "lvm2".  See also
15706       "guestfs_feature_available".
15707
15708       (Added in 1.0.26)
15709
15710   guestfs_vgchange_uuid
15711        int
15712        guestfs_vgchange_uuid (guestfs_h *g,
15713                               const char *vg);
15714
15715       Generate a new random UUID for the volume group "vg".
15716
15717       This function returns 0 on success or -1 on error.
15718
15719       This function depends on the feature "lvm2".  See also
15720       "guestfs_feature_available".
15721
15722       (Added in 1.19.26)
15723
15724   guestfs_vgchange_uuid_all
15725        int
15726        guestfs_vgchange_uuid_all (guestfs_h *g);
15727
15728       Generate new random UUIDs for all volume groups.
15729
15730       This function returns 0 on success or -1 on error.
15731
15732       This function depends on the feature "lvm2".  See also
15733       "guestfs_feature_available".
15734
15735       (Added in 1.19.26)
15736
15737   guestfs_vgcreate
15738        int
15739        guestfs_vgcreate (guestfs_h *g,
15740                          const char *volgroup,
15741                          char *const *physvols);
15742
15743       This creates an LVM volume group called "volgroup" from the non-empty
15744       list of physical volumes "physvols".
15745
15746       This function returns 0 on success or -1 on error.
15747
15748       This function depends on the feature "lvm2".  See also
15749       "guestfs_feature_available".
15750
15751       (Added in 0.8)
15752
15753   guestfs_vglvuuids
15754        char **
15755        guestfs_vglvuuids (guestfs_h *g,
15756                           const char *vgname);
15757
15758       Given a VG called "vgname", this returns the UUIDs of all the logical
15759       volumes created in this volume group.
15760
15761       You can use this along with "guestfs_lvs" and "guestfs_lvuuid" calls to
15762       associate logical volumes and volume groups.
15763
15764       See also "guestfs_vgpvuuids".
15765
15766       This function returns a NULL-terminated array of strings (like
15767       environ(3)), or NULL if there was an error.  The caller must free the
15768       strings and the array after use.
15769
15770       (Added in 1.0.87)
15771
15772   guestfs_vgmeta
15773        char *
15774        guestfs_vgmeta (guestfs_h *g,
15775                        const char *vgname,
15776                        size_t *size_r);
15777
15778       "vgname" is an LVM volume group.  This command examines the volume
15779       group and returns its metadata.
15780
15781       Note that the metadata is an internal structure used by LVM, subject to
15782       change at any time, and is provided for information only.
15783
15784       This function returns a buffer, or NULL on error.  The size of the
15785       returned buffer is written to *size_r.  The caller must free the
15786       returned buffer after use.
15787
15788       This function depends on the feature "lvm2".  See also
15789       "guestfs_feature_available".
15790
15791       (Added in 1.17.20)
15792
15793   guestfs_vgpvuuids
15794        char **
15795        guestfs_vgpvuuids (guestfs_h *g,
15796                           const char *vgname);
15797
15798       Given a VG called "vgname", this returns the UUIDs of all the physical
15799       volumes that this volume group resides on.
15800
15801       You can use this along with "guestfs_pvs" and "guestfs_pvuuid" calls to
15802       associate physical volumes and volume groups.
15803
15804       See also "guestfs_vglvuuids".
15805
15806       This function returns a NULL-terminated array of strings (like
15807       environ(3)), or NULL if there was an error.  The caller must free the
15808       strings and the array after use.
15809
15810       (Added in 1.0.87)
15811
15812   guestfs_vgremove
15813        int
15814        guestfs_vgremove (guestfs_h *g,
15815                          const char *vgname);
15816
15817       Remove an LVM volume group "vgname", (for example "VG").
15818
15819       This also forcibly removes all logical volumes in the volume group (if
15820       any).
15821
15822       This function returns 0 on success or -1 on error.
15823
15824       This function depends on the feature "lvm2".  See also
15825       "guestfs_feature_available".
15826
15827       (Added in 1.0.13)
15828
15829   guestfs_vgrename
15830        int
15831        guestfs_vgrename (guestfs_h *g,
15832                          const char *volgroup,
15833                          const char *newvolgroup);
15834
15835       Rename a volume group "volgroup" with the new name "newvolgroup".
15836
15837       This function returns 0 on success or -1 on error.
15838
15839       (Added in 1.0.83)
15840
15841   guestfs_vgs
15842        char **
15843        guestfs_vgs (guestfs_h *g);
15844
15845       List all the volumes groups detected.  This is the equivalent of the
15846       vgs(8) command.
15847
15848       This returns a list of just the volume group names that were detected
15849       (eg. "VolGroup00").
15850
15851       See also "guestfs_vgs_full".
15852
15853       This function returns a NULL-terminated array of strings (like
15854       environ(3)), or NULL if there was an error.  The caller must free the
15855       strings and the array after use.
15856
15857       This function depends on the feature "lvm2".  See also
15858       "guestfs_feature_available".
15859
15860       (Added in 0.4)
15861
15862   guestfs_vgs_full
15863        struct guestfs_lvm_vg_list *
15864        guestfs_vgs_full (guestfs_h *g);
15865
15866       List all the volumes groups detected.  This is the equivalent of the
15867       vgs(8) command.  The "full" version includes all fields.
15868
15869       This function returns a "struct guestfs_lvm_vg_list *", or NULL if
15870       there was an error.  The caller must call "guestfs_free_lvm_vg_list"
15871       after use.
15872
15873       This function depends on the feature "lvm2".  See also
15874       "guestfs_feature_available".
15875
15876       (Added in 0.4)
15877
15878   guestfs_vgscan
15879        int
15880        guestfs_vgscan (guestfs_h *g);
15881
15882       This function is deprecated.  In new code, use the "guestfs_lvm_scan"
15883       call instead.
15884
15885       Deprecated functions will not be removed from the API, but the fact
15886       that they are deprecated indicates that there are problems with correct
15887       use of these functions.
15888
15889       This rescans all block devices and rebuilds the list of LVM physical
15890       volumes, volume groups and logical volumes.
15891
15892       This function returns 0 on success or -1 on error.
15893
15894       (Added in 1.3.2)
15895
15896   guestfs_vguuid
15897        char *
15898        guestfs_vguuid (guestfs_h *g,
15899                        const char *vgname);
15900
15901       This command returns the UUID of the LVM VG named "vgname".
15902
15903       This function returns a string, or NULL on error.  The caller must free
15904       the returned string after use.
15905
15906       (Added in 1.0.87)
15907
15908   guestfs_wait_ready
15909        int
15910        guestfs_wait_ready (guestfs_h *g);
15911
15912       This function is deprecated.  There is no replacement.  Consult the API
15913       documentation in guestfs(3) for further information.
15914
15915       Deprecated functions will not be removed from the API, but the fact
15916       that they are deprecated indicates that there are problems with correct
15917       use of these functions.
15918
15919       This function is a no op.
15920
15921       In versions of the API < 1.0.71 you had to call this function just
15922       after calling "guestfs_launch" to wait for the launch to complete.
15923       However this is no longer necessary because "guestfs_launch" now does
15924       the waiting.
15925
15926       If you see any calls to this function in code then you can just remove
15927       them, unless you want to retain compatibility with older versions of
15928       the API.
15929
15930       This function returns 0 on success or -1 on error.
15931
15932       (Added in 0.3)
15933
15934   guestfs_wc_c
15935        int
15936        guestfs_wc_c (guestfs_h *g,
15937                      const char *path);
15938
15939       This command counts the characters in a file, using the "wc -c"
15940       external command.
15941
15942       On error this function returns -1.
15943
15944       (Added in 1.0.54)
15945
15946   guestfs_wc_l
15947        int
15948        guestfs_wc_l (guestfs_h *g,
15949                      const char *path);
15950
15951       This command counts the lines in a file, using the "wc -l" external
15952       command.
15953
15954       On error this function returns -1.
15955
15956       (Added in 1.0.54)
15957
15958   guestfs_wc_w
15959        int
15960        guestfs_wc_w (guestfs_h *g,
15961                      const char *path);
15962
15963       This command counts the words in a file, using the "wc -w" external
15964       command.
15965
15966       On error this function returns -1.
15967
15968       (Added in 1.0.54)
15969
15970   guestfs_wipefs
15971        int
15972        guestfs_wipefs (guestfs_h *g,
15973                        const char *device);
15974
15975       This command erases filesystem or RAID signatures from the specified
15976       "device" to make the filesystem invisible to libblkid.
15977
15978       This does not erase the filesystem itself nor any other data from the
15979       "device".
15980
15981       Compare with "guestfs_zero" which zeroes the first few blocks of a
15982       device.
15983
15984       This function returns 0 on success or -1 on error.
15985
15986       This function depends on the feature "wipefs".  See also
15987       "guestfs_feature_available".
15988
15989       (Added in 1.17.6)
15990
15991   guestfs_write
15992        int
15993        guestfs_write (guestfs_h *g,
15994                       const char *path,
15995                       const char *content,
15996                       size_t content_size);
15997
15998       This call creates a file called "path".  The content of the file is the
15999       string "content" (which can contain any 8 bit data).
16000
16001       See also "guestfs_write_append".
16002
16003       This function returns 0 on success or -1 on error.
16004
16005       (Added in 1.3.14)
16006
16007   guestfs_write_append
16008        int
16009        guestfs_write_append (guestfs_h *g,
16010                              const char *path,
16011                              const char *content,
16012                              size_t content_size);
16013
16014       This call appends "content" to the end of file "path".  If "path" does
16015       not exist, then a new file is created.
16016
16017       See also "guestfs_write".
16018
16019       This function returns 0 on success or -1 on error.
16020
16021       (Added in 1.11.18)
16022
16023   guestfs_write_file
16024        int
16025        guestfs_write_file (guestfs_h *g,
16026                            const char *path,
16027                            const char *content,
16028                            int size);
16029
16030       This function is deprecated.  In new code, use the "guestfs_write" call
16031       instead.
16032
16033       Deprecated functions will not be removed from the API, but the fact
16034       that they are deprecated indicates that there are problems with correct
16035       use of these functions.
16036
16037       This call creates a file called "path".  The contents of the file is
16038       the string "content" (which can contain any 8 bit data), with length
16039       "size".
16040
16041       As a special case, if "size" is 0 then the length is calculated using
16042       "strlen" (so in this case the content cannot contain embedded ASCII
16043       NULs).
16044
16045       NB. Owing to a bug, writing content containing ASCII NUL characters
16046       does not work, even if the length is specified.
16047
16048       This function returns 0 on success or -1 on error.
16049
16050       Because of the message protocol, there is a transfer limit of somewhere
16051       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16052
16053       (Added in 0.8)
16054
16055   guestfs_xfs_admin
16056        int
16057        guestfs_xfs_admin (guestfs_h *g,
16058                           const char *device,
16059                           ...);
16060
16061       You may supply a list of optional arguments to this call.  Use zero or
16062       more of the following pairs of parameters, and terminate the list with
16063       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
16064
16065        GUESTFS_XFS_ADMIN_EXTUNWRITTEN, int extunwritten,
16066        GUESTFS_XFS_ADMIN_IMGFILE, int imgfile,
16067        GUESTFS_XFS_ADMIN_V2LOG, int v2log,
16068        GUESTFS_XFS_ADMIN_PROJID32BIT, int projid32bit,
16069        GUESTFS_XFS_ADMIN_LAZYCOUNTER, int lazycounter,
16070        GUESTFS_XFS_ADMIN_LABEL, const char *label,
16071        GUESTFS_XFS_ADMIN_UUID, const char *uuid,
16072
16073       Change the parameters of the XFS filesystem on "device".
16074
16075       Devices that are mounted cannot be modified.  Administrators must
16076       unmount filesystems before this call can modify parameters.
16077
16078       Some of the parameters of a mounted filesystem can be examined and
16079       modified using the "guestfs_xfs_info" and "guestfs_xfs_growfs" calls.
16080
16081       This function returns 0 on success or -1 on error.
16082
16083       This function depends on the feature "xfs".  See also
16084       "guestfs_feature_available".
16085
16086       (Added in 1.19.33)
16087
16088   guestfs_xfs_admin_va
16089        int
16090        guestfs_xfs_admin_va (guestfs_h *g,
16091                              const char *device,
16092                              va_list args);
16093
16094       This is the "va_list variant" of "guestfs_xfs_admin".
16095
16096       See "CALLS WITH OPTIONAL ARGUMENTS".
16097
16098   guestfs_xfs_admin_argv
16099        int
16100        guestfs_xfs_admin_argv (guestfs_h *g,
16101                                const char *device,
16102                                const struct guestfs_xfs_admin_argv *optargs);
16103
16104       This is the "argv variant" of "guestfs_xfs_admin".
16105
16106       See "CALLS WITH OPTIONAL ARGUMENTS".
16107
16108   guestfs_xfs_growfs
16109        int
16110        guestfs_xfs_growfs (guestfs_h *g,
16111                            const char *path,
16112                            ...);
16113
16114       You may supply a list of optional arguments to this call.  Use zero or
16115       more of the following pairs of parameters, and terminate the list with
16116       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
16117
16118        GUESTFS_XFS_GROWFS_DATASEC, int datasec,
16119        GUESTFS_XFS_GROWFS_LOGSEC, int logsec,
16120        GUESTFS_XFS_GROWFS_RTSEC, int rtsec,
16121        GUESTFS_XFS_GROWFS_DATASIZE, int64_t datasize,
16122        GUESTFS_XFS_GROWFS_LOGSIZE, int64_t logsize,
16123        GUESTFS_XFS_GROWFS_RTSIZE, int64_t rtsize,
16124        GUESTFS_XFS_GROWFS_RTEXTSIZE, int64_t rtextsize,
16125        GUESTFS_XFS_GROWFS_MAXPCT, int maxpct,
16126
16127       Grow the XFS filesystem mounted at "path".
16128
16129       The returned struct contains geometry information.  Missing fields are
16130       returned as "-1" (for numeric fields) or empty string.
16131
16132       This function returns 0 on success or -1 on error.
16133
16134       This function depends on the feature "xfs".  See also
16135       "guestfs_feature_available".
16136
16137       (Added in 1.19.28)
16138
16139   guestfs_xfs_growfs_va
16140        int
16141        guestfs_xfs_growfs_va (guestfs_h *g,
16142                               const char *path,
16143                               va_list args);
16144
16145       This is the "va_list variant" of "guestfs_xfs_growfs".
16146
16147       See "CALLS WITH OPTIONAL ARGUMENTS".
16148
16149   guestfs_xfs_growfs_argv
16150        int
16151        guestfs_xfs_growfs_argv (guestfs_h *g,
16152                                 const char *path,
16153                                 const struct guestfs_xfs_growfs_argv *optargs);
16154
16155       This is the "argv variant" of "guestfs_xfs_growfs".
16156
16157       See "CALLS WITH OPTIONAL ARGUMENTS".
16158
16159   guestfs_xfs_info
16160        struct guestfs_xfsinfo *
16161        guestfs_xfs_info (guestfs_h *g,
16162                          const char *pathordevice);
16163
16164       "pathordevice" is a mounted XFS filesystem or a device containing an
16165       XFS filesystem.  This command returns the geometry of the filesystem.
16166
16167       The returned struct contains geometry information.  Missing fields are
16168       returned as "-1" (for numeric fields) or empty string.
16169
16170       This function returns a "struct guestfs_xfsinfo *", or NULL if there
16171       was an error.  The caller must call "guestfs_free_xfsinfo" after use.
16172
16173       This function depends on the feature "xfs".  See also
16174       "guestfs_feature_available".
16175
16176       (Added in 1.19.21)
16177
16178   guestfs_xfs_repair
16179        int
16180        guestfs_xfs_repair (guestfs_h *g,
16181                            const char *device,
16182                            ...);
16183
16184       You may supply a list of optional arguments to this call.  Use zero or
16185       more of the following pairs of parameters, and terminate the list with
16186       "-1" on its own.  See "CALLS WITH OPTIONAL ARGUMENTS".
16187
16188        GUESTFS_XFS_REPAIR_FORCELOGZERO, int forcelogzero,
16189        GUESTFS_XFS_REPAIR_NOMODIFY, int nomodify,
16190        GUESTFS_XFS_REPAIR_NOPREFETCH, int noprefetch,
16191        GUESTFS_XFS_REPAIR_FORCEGEOMETRY, int forcegeometry,
16192        GUESTFS_XFS_REPAIR_MAXMEM, int64_t maxmem,
16193        GUESTFS_XFS_REPAIR_IHASHSIZE, int64_t ihashsize,
16194        GUESTFS_XFS_REPAIR_BHASHSIZE, int64_t bhashsize,
16195        GUESTFS_XFS_REPAIR_AGSTRIDE, int64_t agstride,
16196        GUESTFS_XFS_REPAIR_LOGDEV, const char *logdev,
16197        GUESTFS_XFS_REPAIR_RTDEV, const char *rtdev,
16198
16199       Repair corrupt or damaged XFS filesystem on "device".
16200
16201       The filesystem is specified using the "device" argument which should be
16202       the device name of the disk partition or volume containing the
16203       filesystem.  If given the name of a block device, "xfs_repair" will
16204       attempt to find the raw device associated with the specified block
16205       device and will use the raw device instead.
16206
16207       Regardless, the filesystem to be repaired must be unmounted, otherwise,
16208       the resulting filesystem may be inconsistent or corrupt.
16209
16210       The returned status indicates whether filesystem corruption was
16211       detected (returns 1) or was not detected (returns 0).
16212
16213       On error this function returns -1.
16214
16215       This function depends on the feature "xfs".  See also
16216       "guestfs_feature_available".
16217
16218       (Added in 1.19.36)
16219
16220   guestfs_xfs_repair_va
16221        int
16222        guestfs_xfs_repair_va (guestfs_h *g,
16223                               const char *device,
16224                               va_list args);
16225
16226       This is the "va_list variant" of "guestfs_xfs_repair".
16227
16228       See "CALLS WITH OPTIONAL ARGUMENTS".
16229
16230   guestfs_xfs_repair_argv
16231        int
16232        guestfs_xfs_repair_argv (guestfs_h *g,
16233                                 const char *device,
16234                                 const struct guestfs_xfs_repair_argv *optargs);
16235
16236       This is the "argv variant" of "guestfs_xfs_repair".
16237
16238       See "CALLS WITH OPTIONAL ARGUMENTS".
16239
16240   guestfs_yara_destroy
16241        int
16242        guestfs_yara_destroy (guestfs_h *g);
16243
16244       Destroy previously loaded Yara rules in order to free libguestfs
16245       resources.
16246
16247       This function returns 0 on success or -1 on error.
16248
16249       This function depends on the feature "libyara".  See also
16250       "guestfs_feature_available".
16251
16252       (Added in 1.37.13)
16253
16254   guestfs_yara_load
16255        int
16256        guestfs_yara_load (guestfs_h *g,
16257                           const char *filename);
16258
16259       Upload a set of Yara rules from local file filename.
16260
16261       Yara rules allow to categorize files based on textual or binary
16262       patterns within their content.  See "guestfs_yara_scan" to see how to
16263       scan files with the loaded rules.
16264
16265       Rules can be in binary format, as when compiled with yarac command, or
16266       in source code format. In the latter case, the rules will be first
16267       compiled and then loaded.
16268
16269       Rules in source code format cannot include external files. In such
16270       cases, it is recommended to compile them first.
16271
16272       Previously loaded rules will be destroyed.
16273
16274       This function returns 0 on success or -1 on error.
16275
16276       This long-running command can generate progress notification messages
16277       so that the caller can display a progress bar or indicator.  To receive
16278       these messages, the caller must register a progress event callback.
16279       See "GUESTFS_EVENT_PROGRESS".
16280
16281       This function depends on the feature "libyara".  See also
16282       "guestfs_feature_available".
16283
16284       (Added in 1.37.13)
16285
16286   guestfs_yara_scan
16287        struct guestfs_yara_detection_list *
16288        guestfs_yara_scan (guestfs_h *g,
16289                           const char *path);
16290
16291       Scan a file with the previously loaded Yara rules.
16292
16293       For each matching rule, a "yara_detection" structure is returned.
16294
16295       The "yara_detection" structure contains the following fields.
16296
16297       "yara_name"
16298           Path of the file matching a Yara rule.
16299
16300       "yara_rule"
16301           Identifier of the Yara rule which matched against the given file.
16302
16303       This function returns a "struct guestfs_yara_detection_list *", or NULL
16304       if there was an error.  The caller must call
16305       "guestfs_free_yara_detection_list" after use.
16306
16307       This long-running command can generate progress notification messages
16308       so that the caller can display a progress bar or indicator.  To receive
16309       these messages, the caller must register a progress event callback.
16310       See "GUESTFS_EVENT_PROGRESS".
16311
16312       This function depends on the feature "libyara".  See also
16313       "guestfs_feature_available".
16314
16315       (Added in 1.37.13)
16316
16317   guestfs_zegrep
16318        char **
16319        guestfs_zegrep (guestfs_h *g,
16320                        const char *regex,
16321                        const char *path);
16322
16323       This function is deprecated.  In new code, use the "guestfs_grep" call
16324       instead.
16325
16326       Deprecated functions will not be removed from the API, but the fact
16327       that they are deprecated indicates that there are problems with correct
16328       use of these functions.
16329
16330       This calls the external "zegrep" program and returns the matching
16331       lines.
16332
16333       This function returns a NULL-terminated array of strings (like
16334       environ(3)), or NULL if there was an error.  The caller must free the
16335       strings and the array after use.
16336
16337       Because of the message protocol, there is a transfer limit of somewhere
16338       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16339
16340       (Added in 1.0.66)
16341
16342   guestfs_zegrepi
16343        char **
16344        guestfs_zegrepi (guestfs_h *g,
16345                         const char *regex,
16346                         const char *path);
16347
16348       This function is deprecated.  In new code, use the "guestfs_grep" call
16349       instead.
16350
16351       Deprecated functions will not be removed from the API, but the fact
16352       that they are deprecated indicates that there are problems with correct
16353       use of these functions.
16354
16355       This calls the external "zegrep -i" program and returns the matching
16356       lines.
16357
16358       This function returns a NULL-terminated array of strings (like
16359       environ(3)), or NULL if there was an error.  The caller must free the
16360       strings and the array after use.
16361
16362       Because of the message protocol, there is a transfer limit of somewhere
16363       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16364
16365       (Added in 1.0.66)
16366
16367   guestfs_zero
16368        int
16369        guestfs_zero (guestfs_h *g,
16370                      const char *device);
16371
16372       This command writes zeroes over the first few blocks of "device".
16373
16374       How many blocks are zeroed isn't specified (but it’s not enough to
16375       securely wipe the device).  It should be sufficient to remove any
16376       partition tables, filesystem superblocks and so on.
16377
16378       If blocks are already zero, then this command avoids writing zeroes.
16379       This prevents the underlying device from becoming non-sparse or growing
16380       unnecessarily.
16381
16382       See also: "guestfs_zero_device", "guestfs_scrub_device",
16383       "guestfs_is_zero_device"
16384
16385       This function returns 0 on success or -1 on error.
16386
16387       This long-running command can generate progress notification messages
16388       so that the caller can display a progress bar or indicator.  To receive
16389       these messages, the caller must register a progress event callback.
16390       See "GUESTFS_EVENT_PROGRESS".
16391
16392       (Added in 1.0.16)
16393
16394   guestfs_zero_device
16395        int
16396        guestfs_zero_device (guestfs_h *g,
16397                             const char *device);
16398
16399       This command writes zeroes over the entire "device".  Compare with
16400       "guestfs_zero" which just zeroes the first few blocks of a device.
16401
16402       If blocks are already zero, then this command avoids writing zeroes.
16403       This prevents the underlying device from becoming non-sparse or growing
16404       unnecessarily.
16405
16406       This function returns 0 on success or -1 on error.
16407
16408       This long-running command can generate progress notification messages
16409       so that the caller can display a progress bar or indicator.  To receive
16410       these messages, the caller must register a progress event callback.
16411       See "GUESTFS_EVENT_PROGRESS".
16412
16413       (Added in 1.3.1)
16414
16415   guestfs_zero_free_space
16416        int
16417        guestfs_zero_free_space (guestfs_h *g,
16418                                 const char *directory);
16419
16420       Zero the free space in the filesystem mounted on directory.  The
16421       filesystem must be mounted read-write.
16422
16423       The filesystem contents are not affected, but any free space in the
16424       filesystem is freed.
16425
16426       Free space is not "trimmed".  You may want to call "guestfs_fstrim"
16427       either as an alternative to this, or after calling this, depending on
16428       your requirements.
16429
16430       This function returns 0 on success or -1 on error.
16431
16432       This long-running command can generate progress notification messages
16433       so that the caller can display a progress bar or indicator.  To receive
16434       these messages, the caller must register a progress event callback.
16435       See "GUESTFS_EVENT_PROGRESS".
16436
16437       (Added in 1.17.18)
16438
16439   guestfs_zerofree
16440        int
16441        guestfs_zerofree (guestfs_h *g,
16442                          const char *device);
16443
16444       This runs the zerofree program on "device".  This program claims to
16445       zero unused inodes and disk blocks on an ext2/3 filesystem, thus making
16446       it possible to compress the filesystem more effectively.
16447
16448       You should not run this program if the filesystem is mounted.
16449
16450       It is possible that using this program can damage the filesystem or
16451       data on the filesystem.
16452
16453       This function returns 0 on success or -1 on error.
16454
16455       This function depends on the feature "zerofree".  See also
16456       "guestfs_feature_available".
16457
16458       (Added in 1.0.26)
16459
16460   guestfs_zfgrep
16461        char **
16462        guestfs_zfgrep (guestfs_h *g,
16463                        const char *pattern,
16464                        const char *path);
16465
16466       This function is deprecated.  In new code, use the "guestfs_grep" call
16467       instead.
16468
16469       Deprecated functions will not be removed from the API, but the fact
16470       that they are deprecated indicates that there are problems with correct
16471       use of these functions.
16472
16473       This calls the external "zfgrep" program and returns the matching
16474       lines.
16475
16476       This function returns a NULL-terminated array of strings (like
16477       environ(3)), or NULL if there was an error.  The caller must free the
16478       strings and the array after use.
16479
16480       Because of the message protocol, there is a transfer limit of somewhere
16481       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16482
16483       (Added in 1.0.66)
16484
16485   guestfs_zfgrepi
16486        char **
16487        guestfs_zfgrepi (guestfs_h *g,
16488                         const char *pattern,
16489                         const char *path);
16490
16491       This function is deprecated.  In new code, use the "guestfs_grep" call
16492       instead.
16493
16494       Deprecated functions will not be removed from the API, but the fact
16495       that they are deprecated indicates that there are problems with correct
16496       use of these functions.
16497
16498       This calls the external "zfgrep -i" program and returns the matching
16499       lines.
16500
16501       This function returns a NULL-terminated array of strings (like
16502       environ(3)), or NULL if there was an error.  The caller must free the
16503       strings and the array after use.
16504
16505       Because of the message protocol, there is a transfer limit of somewhere
16506       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16507
16508       (Added in 1.0.66)
16509
16510   guestfs_zfile
16511        char *
16512        guestfs_zfile (guestfs_h *g,
16513                       const char *meth,
16514                       const char *path);
16515
16516       This function is deprecated.  In new code, use the "guestfs_file" call
16517       instead.
16518
16519       Deprecated functions will not be removed from the API, but the fact
16520       that they are deprecated indicates that there are problems with correct
16521       use of these functions.
16522
16523       This command runs file(1) after first decompressing "path" using
16524       "meth".
16525
16526       "meth" must be one of "gzip", "compress" or "bzip2".
16527
16528       Since 1.0.63, use "guestfs_file" instead which can now process
16529       compressed files.
16530
16531       This function returns a string, or NULL on error.  The caller must free
16532       the returned string after use.
16533
16534       (Added in 1.0.59)
16535
16536   guestfs_zgrep
16537        char **
16538        guestfs_zgrep (guestfs_h *g,
16539                       const char *regex,
16540                       const char *path);
16541
16542       This function is deprecated.  In new code, use the "guestfs_grep" call
16543       instead.
16544
16545       Deprecated functions will not be removed from the API, but the fact
16546       that they are deprecated indicates that there are problems with correct
16547       use of these functions.
16548
16549       This calls the external zgrep(1) program and returns the matching
16550       lines.
16551
16552       This function returns a NULL-terminated array of strings (like
16553       environ(3)), or NULL if there was an error.  The caller must free the
16554       strings and the array after use.
16555
16556       Because of the message protocol, there is a transfer limit of somewhere
16557       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16558
16559       (Added in 1.0.66)
16560
16561   guestfs_zgrepi
16562        char **
16563        guestfs_zgrepi (guestfs_h *g,
16564                        const char *regex,
16565                        const char *path);
16566
16567       This function is deprecated.  In new code, use the "guestfs_grep" call
16568       instead.
16569
16570       Deprecated functions will not be removed from the API, but the fact
16571       that they are deprecated indicates that there are problems with correct
16572       use of these functions.
16573
16574       This calls the external "zgrep -i" program and returns the matching
16575       lines.
16576
16577       This function returns a NULL-terminated array of strings (like
16578       environ(3)), or NULL if there was an error.  The caller must free the
16579       strings and the array after use.
16580
16581       Because of the message protocol, there is a transfer limit of somewhere
16582       between 2MB and 4MB.  See "PROTOCOL LIMITS".
16583
16584       (Added in 1.0.66)
16585

STRUCTURES

16587   guestfs_int_bool
16588        struct guestfs_int_bool {
16589          int32_t i;
16590          int32_t b;
16591        };
16592
16593        struct guestfs_int_bool_list {
16594          uint32_t len; /* Number of elements in list. */
16595          struct guestfs_int_bool *val; /* Elements. */
16596        };
16597
16598        int guestfs_compare_int_bool (const struct guestfs_int_bool *, const struct guestfs_int_bool *);
16599        int guestfs_compare_int_bool_list (const struct guestfs_int_bool_list *, const struct guestfs_int_bool_list *);
16600
16601        struct guestfs_int_bool *guestfs_copy_int_bool (const struct guestfs_int_bool *);
16602        struct guestfs_int_bool_list *guestfs_copy_int_bool_list (const struct guestfs_int_bool_list *);
16603
16604        void guestfs_free_int_bool (struct guestfs_int_bool *);
16605        void guestfs_free_int_bool_list (struct guestfs_int_bool_list *);
16606
16607   guestfs_lvm_pv
16608        struct guestfs_lvm_pv {
16609          char *pv_name;
16610          /* The next field is NOT nul-terminated, be careful when printing it: */
16611          char pv_uuid[32];
16612          char *pv_fmt;
16613          uint64_t pv_size;
16614          uint64_t dev_size;
16615          uint64_t pv_free;
16616          uint64_t pv_used;
16617          char *pv_attr;
16618          int64_t pv_pe_count;
16619          int64_t pv_pe_alloc_count;
16620          char *pv_tags;
16621          uint64_t pe_start;
16622          int64_t pv_mda_count;
16623          uint64_t pv_mda_free;
16624        };
16625
16626        struct guestfs_lvm_pv_list {
16627          uint32_t len; /* Number of elements in list. */
16628          struct guestfs_lvm_pv *val; /* Elements. */
16629        };
16630
16631        int guestfs_compare_lvm_pv (const struct guestfs_lvm_pv *, const struct guestfs_lvm_pv *);
16632        int guestfs_compare_lvm_pv_list (const struct guestfs_lvm_pv_list *, const struct guestfs_lvm_pv_list *);
16633
16634        struct guestfs_lvm_pv *guestfs_copy_lvm_pv (const struct guestfs_lvm_pv *);
16635        struct guestfs_lvm_pv_list *guestfs_copy_lvm_pv_list (const struct guestfs_lvm_pv_list *);
16636
16637        void guestfs_free_lvm_pv (struct guestfs_lvm_pv *);
16638        void guestfs_free_lvm_pv_list (struct guestfs_lvm_pv_list *);
16639
16640   guestfs_lvm_vg
16641        struct guestfs_lvm_vg {
16642          char *vg_name;
16643          /* The next field is NOT nul-terminated, be careful when printing it: */
16644          char vg_uuid[32];
16645          char *vg_fmt;
16646          char *vg_attr;
16647          uint64_t vg_size;
16648          uint64_t vg_free;
16649          char *vg_sysid;
16650          uint64_t vg_extent_size;
16651          int64_t vg_extent_count;
16652          int64_t vg_free_count;
16653          int64_t max_lv;
16654          int64_t max_pv;
16655          int64_t pv_count;
16656          int64_t lv_count;
16657          int64_t snap_count;
16658          int64_t vg_seqno;
16659          char *vg_tags;
16660          int64_t vg_mda_count;
16661          uint64_t vg_mda_free;
16662        };
16663
16664        struct guestfs_lvm_vg_list {
16665          uint32_t len; /* Number of elements in list. */
16666          struct guestfs_lvm_vg *val; /* Elements. */
16667        };
16668
16669        int guestfs_compare_lvm_vg (const struct guestfs_lvm_vg *, const struct guestfs_lvm_vg *);
16670        int guestfs_compare_lvm_vg_list (const struct guestfs_lvm_vg_list *, const struct guestfs_lvm_vg_list *);
16671
16672        struct guestfs_lvm_vg *guestfs_copy_lvm_vg (const struct guestfs_lvm_vg *);
16673        struct guestfs_lvm_vg_list *guestfs_copy_lvm_vg_list (const struct guestfs_lvm_vg_list *);
16674
16675        void guestfs_free_lvm_vg (struct guestfs_lvm_vg *);
16676        void guestfs_free_lvm_vg_list (struct guestfs_lvm_vg_list *);
16677
16678   guestfs_lvm_lv
16679        struct guestfs_lvm_lv {
16680          char *lv_name;
16681          /* The next field is NOT nul-terminated, be careful when printing it: */
16682          char lv_uuid[32];
16683          char *lv_attr;
16684          int64_t lv_major;
16685          int64_t lv_minor;
16686          int64_t lv_kernel_major;
16687          int64_t lv_kernel_minor;
16688          uint64_t lv_size;
16689          int64_t seg_count;
16690          char *origin;
16691          /* The next field is [0..100] or -1 meaning 'not present': */
16692          float snap_percent;
16693          /* The next field is [0..100] or -1 meaning 'not present': */
16694          float copy_percent;
16695          char *move_pv;
16696          char *lv_tags;
16697          char *mirror_log;
16698          char *modules;
16699        };
16700
16701        struct guestfs_lvm_lv_list {
16702          uint32_t len; /* Number of elements in list. */
16703          struct guestfs_lvm_lv *val; /* Elements. */
16704        };
16705
16706        int guestfs_compare_lvm_lv (const struct guestfs_lvm_lv *, const struct guestfs_lvm_lv *);
16707        int guestfs_compare_lvm_lv_list (const struct guestfs_lvm_lv_list *, const struct guestfs_lvm_lv_list *);
16708
16709        struct guestfs_lvm_lv *guestfs_copy_lvm_lv (const struct guestfs_lvm_lv *);
16710        struct guestfs_lvm_lv_list *guestfs_copy_lvm_lv_list (const struct guestfs_lvm_lv_list *);
16711
16712        void guestfs_free_lvm_lv (struct guestfs_lvm_lv *);
16713        void guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *);
16714
16715   guestfs_stat
16716        struct guestfs_stat {
16717          int64_t dev;
16718          int64_t ino;
16719          int64_t mode;
16720          int64_t nlink;
16721          int64_t uid;
16722          int64_t gid;
16723          int64_t rdev;
16724          int64_t size;
16725          int64_t blksize;
16726          int64_t blocks;
16727          int64_t atime;
16728          int64_t mtime;
16729          int64_t ctime;
16730        };
16731
16732        struct guestfs_stat_list {
16733          uint32_t len; /* Number of elements in list. */
16734          struct guestfs_stat *val; /* Elements. */
16735        };
16736
16737        int guestfs_compare_stat (const struct guestfs_stat *, const struct guestfs_stat *);
16738        int guestfs_compare_stat_list (const struct guestfs_stat_list *, const struct guestfs_stat_list *);
16739
16740        struct guestfs_stat *guestfs_copy_stat (const struct guestfs_stat *);
16741        struct guestfs_stat_list *guestfs_copy_stat_list (const struct guestfs_stat_list *);
16742
16743        void guestfs_free_stat (struct guestfs_stat *);
16744        void guestfs_free_stat_list (struct guestfs_stat_list *);
16745
16746   guestfs_statns
16747        struct guestfs_statns {
16748          int64_t st_dev;
16749          int64_t st_ino;
16750          int64_t st_mode;
16751          int64_t st_nlink;
16752          int64_t st_uid;
16753          int64_t st_gid;
16754          int64_t st_rdev;
16755          int64_t st_size;
16756          int64_t st_blksize;
16757          int64_t st_blocks;
16758          int64_t st_atime_sec;
16759          int64_t st_atime_nsec;
16760          int64_t st_mtime_sec;
16761          int64_t st_mtime_nsec;
16762          int64_t st_ctime_sec;
16763          int64_t st_ctime_nsec;
16764          int64_t st_spare1;
16765          int64_t st_spare2;
16766          int64_t st_spare3;
16767          int64_t st_spare4;
16768          int64_t st_spare5;
16769          int64_t st_spare6;
16770        };
16771
16772        struct guestfs_statns_list {
16773          uint32_t len; /* Number of elements in list. */
16774          struct guestfs_statns *val; /* Elements. */
16775        };
16776
16777        int guestfs_compare_statns (const struct guestfs_statns *, const struct guestfs_statns *);
16778        int guestfs_compare_statns_list (const struct guestfs_statns_list *, const struct guestfs_statns_list *);
16779
16780        struct guestfs_statns *guestfs_copy_statns (const struct guestfs_statns *);
16781        struct guestfs_statns_list *guestfs_copy_statns_list (const struct guestfs_statns_list *);
16782
16783        void guestfs_free_statns (struct guestfs_statns *);
16784        void guestfs_free_statns_list (struct guestfs_statns_list *);
16785
16786   guestfs_statvfs
16787        struct guestfs_statvfs {
16788          int64_t bsize;
16789          int64_t frsize;
16790          int64_t blocks;
16791          int64_t bfree;
16792          int64_t bavail;
16793          int64_t files;
16794          int64_t ffree;
16795          int64_t favail;
16796          int64_t fsid;
16797          int64_t flag;
16798          int64_t namemax;
16799        };
16800
16801        struct guestfs_statvfs_list {
16802          uint32_t len; /* Number of elements in list. */
16803          struct guestfs_statvfs *val; /* Elements. */
16804        };
16805
16806        int guestfs_compare_statvfs (const struct guestfs_statvfs *, const struct guestfs_statvfs *);
16807        int guestfs_compare_statvfs_list (const struct guestfs_statvfs_list *, const struct guestfs_statvfs_list *);
16808
16809        struct guestfs_statvfs *guestfs_copy_statvfs (const struct guestfs_statvfs *);
16810        struct guestfs_statvfs_list *guestfs_copy_statvfs_list (const struct guestfs_statvfs_list *);
16811
16812        void guestfs_free_statvfs (struct guestfs_statvfs *);
16813        void guestfs_free_statvfs_list (struct guestfs_statvfs_list *);
16814
16815   guestfs_dirent
16816        struct guestfs_dirent {
16817          int64_t ino;
16818          char ftyp;
16819          char *name;
16820        };
16821
16822        struct guestfs_dirent_list {
16823          uint32_t len; /* Number of elements in list. */
16824          struct guestfs_dirent *val; /* Elements. */
16825        };
16826
16827        int guestfs_compare_dirent (const struct guestfs_dirent *, const struct guestfs_dirent *);
16828        int guestfs_compare_dirent_list (const struct guestfs_dirent_list *, const struct guestfs_dirent_list *);
16829
16830        struct guestfs_dirent *guestfs_copy_dirent (const struct guestfs_dirent *);
16831        struct guestfs_dirent_list *guestfs_copy_dirent_list (const struct guestfs_dirent_list *);
16832
16833        void guestfs_free_dirent (struct guestfs_dirent *);
16834        void guestfs_free_dirent_list (struct guestfs_dirent_list *);
16835
16836   guestfs_version
16837        struct guestfs_version {
16838          int64_t major;
16839          int64_t minor;
16840          int64_t release;
16841          char *extra;
16842        };
16843
16844        struct guestfs_version_list {
16845          uint32_t len; /* Number of elements in list. */
16846          struct guestfs_version *val; /* Elements. */
16847        };
16848
16849        int guestfs_compare_version (const struct guestfs_version *, const struct guestfs_version *);
16850        int guestfs_compare_version_list (const struct guestfs_version_list *, const struct guestfs_version_list *);
16851
16852        struct guestfs_version *guestfs_copy_version (const struct guestfs_version *);
16853        struct guestfs_version_list *guestfs_copy_version_list (const struct guestfs_version_list *);
16854
16855        void guestfs_free_version (struct guestfs_version *);
16856        void guestfs_free_version_list (struct guestfs_version_list *);
16857
16858   guestfs_xattr
16859        struct guestfs_xattr {
16860          char *attrname;
16861          /* The next two fields describe a byte array. */
16862          uint32_t attrval_len;
16863          char *attrval;
16864        };
16865
16866        struct guestfs_xattr_list {
16867          uint32_t len; /* Number of elements in list. */
16868          struct guestfs_xattr *val; /* Elements. */
16869        };
16870
16871        int guestfs_compare_xattr (const struct guestfs_xattr *, const struct guestfs_xattr *);
16872        int guestfs_compare_xattr_list (const struct guestfs_xattr_list *, const struct guestfs_xattr_list *);
16873
16874        struct guestfs_xattr *guestfs_copy_xattr (const struct guestfs_xattr *);
16875        struct guestfs_xattr_list *guestfs_copy_xattr_list (const struct guestfs_xattr_list *);
16876
16877        void guestfs_free_xattr (struct guestfs_xattr *);
16878        void guestfs_free_xattr_list (struct guestfs_xattr_list *);
16879
16880   guestfs_inotify_event
16881        struct guestfs_inotify_event {
16882          int64_t in_wd;
16883          uint32_t in_mask;
16884          uint32_t in_cookie;
16885          char *in_name;
16886        };
16887
16888        struct guestfs_inotify_event_list {
16889          uint32_t len; /* Number of elements in list. */
16890          struct guestfs_inotify_event *val; /* Elements. */
16891        };
16892
16893        int guestfs_compare_inotify_event (const struct guestfs_inotify_event *, const struct guestfs_inotify_event *);
16894        int guestfs_compare_inotify_event_list (const struct guestfs_inotify_event_list *, const struct guestfs_inotify_event_list *);
16895
16896        struct guestfs_inotify_event *guestfs_copy_inotify_event (const struct guestfs_inotify_event *);
16897        struct guestfs_inotify_event_list *guestfs_copy_inotify_event_list (const struct guestfs_inotify_event_list *);
16898
16899        void guestfs_free_inotify_event (struct guestfs_inotify_event *);
16900        void guestfs_free_inotify_event_list (struct guestfs_inotify_event_list *);
16901
16902   guestfs_partition
16903        struct guestfs_partition {
16904          int32_t part_num;
16905          uint64_t part_start;
16906          uint64_t part_end;
16907          uint64_t part_size;
16908        };
16909
16910        struct guestfs_partition_list {
16911          uint32_t len; /* Number of elements in list. */
16912          struct guestfs_partition *val; /* Elements. */
16913        };
16914
16915        int guestfs_compare_partition (const struct guestfs_partition *, const struct guestfs_partition *);
16916        int guestfs_compare_partition_list (const struct guestfs_partition_list *, const struct guestfs_partition_list *);
16917
16918        struct guestfs_partition *guestfs_copy_partition (const struct guestfs_partition *);
16919        struct guestfs_partition_list *guestfs_copy_partition_list (const struct guestfs_partition_list *);
16920
16921        void guestfs_free_partition (struct guestfs_partition *);
16922        void guestfs_free_partition_list (struct guestfs_partition_list *);
16923
16924   guestfs_application
16925        struct guestfs_application {
16926          char *app_name;
16927          char *app_display_name;
16928          int32_t app_epoch;
16929          char *app_version;
16930          char *app_release;
16931          char *app_install_path;
16932          char *app_trans_path;
16933          char *app_publisher;
16934          char *app_url;
16935          char *app_source_package;
16936          char *app_summary;
16937          char *app_description;
16938        };
16939
16940        struct guestfs_application_list {
16941          uint32_t len; /* Number of elements in list. */
16942          struct guestfs_application *val; /* Elements. */
16943        };
16944
16945        int guestfs_compare_application (const struct guestfs_application *, const struct guestfs_application *);
16946        int guestfs_compare_application_list (const struct guestfs_application_list *, const struct guestfs_application_list *);
16947
16948        struct guestfs_application *guestfs_copy_application (const struct guestfs_application *);
16949        struct guestfs_application_list *guestfs_copy_application_list (const struct guestfs_application_list *);
16950
16951        void guestfs_free_application (struct guestfs_application *);
16952        void guestfs_free_application_list (struct guestfs_application_list *);
16953
16954   guestfs_application2
16955        struct guestfs_application2 {
16956          char *app2_name;
16957          char *app2_display_name;
16958          int32_t app2_epoch;
16959          char *app2_version;
16960          char *app2_release;
16961          char *app2_arch;
16962          char *app2_install_path;
16963          char *app2_trans_path;
16964          char *app2_publisher;
16965          char *app2_url;
16966          char *app2_source_package;
16967          char *app2_summary;
16968          char *app2_description;
16969          char *app2_spare1;
16970          char *app2_spare2;
16971          char *app2_spare3;
16972          char *app2_spare4;
16973        };
16974
16975        struct guestfs_application2_list {
16976          uint32_t len; /* Number of elements in list. */
16977          struct guestfs_application2 *val; /* Elements. */
16978        };
16979
16980        int guestfs_compare_application2 (const struct guestfs_application2 *, const struct guestfs_application2 *);
16981        int guestfs_compare_application2_list (const struct guestfs_application2_list *, const struct guestfs_application2_list *);
16982
16983        struct guestfs_application2 *guestfs_copy_application2 (const struct guestfs_application2 *);
16984        struct guestfs_application2_list *guestfs_copy_application2_list (const struct guestfs_application2_list *);
16985
16986        void guestfs_free_application2 (struct guestfs_application2 *);
16987        void guestfs_free_application2_list (struct guestfs_application2_list *);
16988
16989   guestfs_isoinfo
16990        struct guestfs_isoinfo {
16991          char *iso_system_id;
16992          char *iso_volume_id;
16993          uint32_t iso_volume_space_size;
16994          uint32_t iso_volume_set_size;
16995          uint32_t iso_volume_sequence_number;
16996          uint32_t iso_logical_block_size;
16997          char *iso_volume_set_id;
16998          char *iso_publisher_id;
16999          char *iso_data_preparer_id;
17000          char *iso_application_id;
17001          char *iso_copyright_file_id;
17002          char *iso_abstract_file_id;
17003          char *iso_bibliographic_file_id;
17004          int64_t iso_volume_creation_t;
17005          int64_t iso_volume_modification_t;
17006          int64_t iso_volume_expiration_t;
17007          int64_t iso_volume_effective_t;
17008        };
17009
17010        struct guestfs_isoinfo_list {
17011          uint32_t len; /* Number of elements in list. */
17012          struct guestfs_isoinfo *val; /* Elements. */
17013        };
17014
17015        int guestfs_compare_isoinfo (const struct guestfs_isoinfo *, const struct guestfs_isoinfo *);
17016        int guestfs_compare_isoinfo_list (const struct guestfs_isoinfo_list *, const struct guestfs_isoinfo_list *);
17017
17018        struct guestfs_isoinfo *guestfs_copy_isoinfo (const struct guestfs_isoinfo *);
17019        struct guestfs_isoinfo_list *guestfs_copy_isoinfo_list (const struct guestfs_isoinfo_list *);
17020
17021        void guestfs_free_isoinfo (struct guestfs_isoinfo *);
17022        void guestfs_free_isoinfo_list (struct guestfs_isoinfo_list *);
17023
17024   guestfs_mdstat
17025        struct guestfs_mdstat {
17026          char *mdstat_device;
17027          int32_t mdstat_index;
17028          char *mdstat_flags;
17029        };
17030
17031        struct guestfs_mdstat_list {
17032          uint32_t len; /* Number of elements in list. */
17033          struct guestfs_mdstat *val; /* Elements. */
17034        };
17035
17036        int guestfs_compare_mdstat (const struct guestfs_mdstat *, const struct guestfs_mdstat *);
17037        int guestfs_compare_mdstat_list (const struct guestfs_mdstat_list *, const struct guestfs_mdstat_list *);
17038
17039        struct guestfs_mdstat *guestfs_copy_mdstat (const struct guestfs_mdstat *);
17040        struct guestfs_mdstat_list *guestfs_copy_mdstat_list (const struct guestfs_mdstat_list *);
17041
17042        void guestfs_free_mdstat (struct guestfs_mdstat *);
17043        void guestfs_free_mdstat_list (struct guestfs_mdstat_list *);
17044
17045   guestfs_btrfssubvolume
17046        struct guestfs_btrfssubvolume {
17047          uint64_t btrfssubvolume_id;
17048          uint64_t btrfssubvolume_top_level_id;
17049          char *btrfssubvolume_path;
17050        };
17051
17052        struct guestfs_btrfssubvolume_list {
17053          uint32_t len; /* Number of elements in list. */
17054          struct guestfs_btrfssubvolume *val; /* Elements. */
17055        };
17056
17057        int guestfs_compare_btrfssubvolume (const struct guestfs_btrfssubvolume *, const struct guestfs_btrfssubvolume *);
17058        int guestfs_compare_btrfssubvolume_list (const struct guestfs_btrfssubvolume_list *, const struct guestfs_btrfssubvolume_list *);
17059
17060        struct guestfs_btrfssubvolume *guestfs_copy_btrfssubvolume (const struct guestfs_btrfssubvolume *);
17061        struct guestfs_btrfssubvolume_list *guestfs_copy_btrfssubvolume_list (const struct guestfs_btrfssubvolume_list *);
17062
17063        void guestfs_free_btrfssubvolume (struct guestfs_btrfssubvolume *);
17064        void guestfs_free_btrfssubvolume_list (struct guestfs_btrfssubvolume_list *);
17065
17066   guestfs_btrfsqgroup
17067        struct guestfs_btrfsqgroup {
17068          char *btrfsqgroup_id;
17069          uint64_t btrfsqgroup_rfer;
17070          uint64_t btrfsqgroup_excl;
17071        };
17072
17073        struct guestfs_btrfsqgroup_list {
17074          uint32_t len; /* Number of elements in list. */
17075          struct guestfs_btrfsqgroup *val; /* Elements. */
17076        };
17077
17078        int guestfs_compare_btrfsqgroup (const struct guestfs_btrfsqgroup *, const struct guestfs_btrfsqgroup *);
17079        int guestfs_compare_btrfsqgroup_list (const struct guestfs_btrfsqgroup_list *, const struct guestfs_btrfsqgroup_list *);
17080
17081        struct guestfs_btrfsqgroup *guestfs_copy_btrfsqgroup (const struct guestfs_btrfsqgroup *);
17082        struct guestfs_btrfsqgroup_list *guestfs_copy_btrfsqgroup_list (const struct guestfs_btrfsqgroup_list *);
17083
17084        void guestfs_free_btrfsqgroup (struct guestfs_btrfsqgroup *);
17085        void guestfs_free_btrfsqgroup_list (struct guestfs_btrfsqgroup_list *);
17086
17087   guestfs_btrfsbalance
17088        struct guestfs_btrfsbalance {
17089          char *btrfsbalance_status;
17090          uint64_t btrfsbalance_total;
17091          uint64_t btrfsbalance_balanced;
17092          uint64_t btrfsbalance_considered;
17093          uint64_t btrfsbalance_left;
17094        };
17095
17096        struct guestfs_btrfsbalance_list {
17097          uint32_t len; /* Number of elements in list. */
17098          struct guestfs_btrfsbalance *val; /* Elements. */
17099        };
17100
17101        int guestfs_compare_btrfsbalance (const struct guestfs_btrfsbalance *, const struct guestfs_btrfsbalance *);
17102        int guestfs_compare_btrfsbalance_list (const struct guestfs_btrfsbalance_list *, const struct guestfs_btrfsbalance_list *);
17103
17104        struct guestfs_btrfsbalance *guestfs_copy_btrfsbalance (const struct guestfs_btrfsbalance *);
17105        struct guestfs_btrfsbalance_list *guestfs_copy_btrfsbalance_list (const struct guestfs_btrfsbalance_list *);
17106
17107        void guestfs_free_btrfsbalance (struct guestfs_btrfsbalance *);
17108        void guestfs_free_btrfsbalance_list (struct guestfs_btrfsbalance_list *);
17109
17110   guestfs_btrfsscrub
17111        struct guestfs_btrfsscrub {
17112          uint64_t btrfsscrub_data_extents_scrubbed;
17113          uint64_t btrfsscrub_tree_extents_scrubbed;
17114          uint64_t btrfsscrub_data_bytes_scrubbed;
17115          uint64_t btrfsscrub_tree_bytes_scrubbed;
17116          uint64_t btrfsscrub_read_errors;
17117          uint64_t btrfsscrub_csum_errors;
17118          uint64_t btrfsscrub_verify_errors;
17119          uint64_t btrfsscrub_no_csum;
17120          uint64_t btrfsscrub_csum_discards;
17121          uint64_t btrfsscrub_super_errors;
17122          uint64_t btrfsscrub_malloc_errors;
17123          uint64_t btrfsscrub_uncorrectable_errors;
17124          uint64_t btrfsscrub_unverified_errors;
17125          uint64_t btrfsscrub_corrected_errors;
17126          uint64_t btrfsscrub_last_physical;
17127        };
17128
17129        struct guestfs_btrfsscrub_list {
17130          uint32_t len; /* Number of elements in list. */
17131          struct guestfs_btrfsscrub *val; /* Elements. */
17132        };
17133
17134        int guestfs_compare_btrfsscrub (const struct guestfs_btrfsscrub *, const struct guestfs_btrfsscrub *);
17135        int guestfs_compare_btrfsscrub_list (const struct guestfs_btrfsscrub_list *, const struct guestfs_btrfsscrub_list *);
17136
17137        struct guestfs_btrfsscrub *guestfs_copy_btrfsscrub (const struct guestfs_btrfsscrub *);
17138        struct guestfs_btrfsscrub_list *guestfs_copy_btrfsscrub_list (const struct guestfs_btrfsscrub_list *);
17139
17140        void guestfs_free_btrfsscrub (struct guestfs_btrfsscrub *);
17141        void guestfs_free_btrfsscrub_list (struct guestfs_btrfsscrub_list *);
17142
17143   guestfs_xfsinfo
17144        struct guestfs_xfsinfo {
17145          char *xfs_mntpoint;
17146          uint32_t xfs_inodesize;
17147          uint32_t xfs_agcount;
17148          uint32_t xfs_agsize;
17149          uint32_t xfs_sectsize;
17150          uint32_t xfs_attr;
17151          uint32_t xfs_blocksize;
17152          uint64_t xfs_datablocks;
17153          uint32_t xfs_imaxpct;
17154          uint32_t xfs_sunit;
17155          uint32_t xfs_swidth;
17156          uint32_t xfs_dirversion;
17157          uint32_t xfs_dirblocksize;
17158          uint32_t xfs_cimode;
17159          char *xfs_logname;
17160          uint32_t xfs_logblocksize;
17161          uint32_t xfs_logblocks;
17162          uint32_t xfs_logversion;
17163          uint32_t xfs_logsectsize;
17164          uint32_t xfs_logsunit;
17165          uint32_t xfs_lazycount;
17166          char *xfs_rtname;
17167          uint32_t xfs_rtextsize;
17168          uint64_t xfs_rtblocks;
17169          uint64_t xfs_rtextents;
17170        };
17171
17172        struct guestfs_xfsinfo_list {
17173          uint32_t len; /* Number of elements in list. */
17174          struct guestfs_xfsinfo *val; /* Elements. */
17175        };
17176
17177        int guestfs_compare_xfsinfo (const struct guestfs_xfsinfo *, const struct guestfs_xfsinfo *);
17178        int guestfs_compare_xfsinfo_list (const struct guestfs_xfsinfo_list *, const struct guestfs_xfsinfo_list *);
17179
17180        struct guestfs_xfsinfo *guestfs_copy_xfsinfo (const struct guestfs_xfsinfo *);
17181        struct guestfs_xfsinfo_list *guestfs_copy_xfsinfo_list (const struct guestfs_xfsinfo_list *);
17182
17183        void guestfs_free_xfsinfo (struct guestfs_xfsinfo *);
17184        void guestfs_free_xfsinfo_list (struct guestfs_xfsinfo_list *);
17185
17186   guestfs_utsname
17187        struct guestfs_utsname {
17188          char *uts_sysname;
17189          char *uts_release;
17190          char *uts_version;
17191          char *uts_machine;
17192        };
17193
17194        struct guestfs_utsname_list {
17195          uint32_t len; /* Number of elements in list. */
17196          struct guestfs_utsname *val; /* Elements. */
17197        };
17198
17199        int guestfs_compare_utsname (const struct guestfs_utsname *, const struct guestfs_utsname *);
17200        int guestfs_compare_utsname_list (const struct guestfs_utsname_list *, const struct guestfs_utsname_list *);
17201
17202        struct guestfs_utsname *guestfs_copy_utsname (const struct guestfs_utsname *);
17203        struct guestfs_utsname_list *guestfs_copy_utsname_list (const struct guestfs_utsname_list *);
17204
17205        void guestfs_free_utsname (struct guestfs_utsname *);
17206        void guestfs_free_utsname_list (struct guestfs_utsname_list *);
17207
17208   guestfs_hivex_node
17209        struct guestfs_hivex_node {
17210          int64_t hivex_node_h;
17211        };
17212
17213        struct guestfs_hivex_node_list {
17214          uint32_t len; /* Number of elements in list. */
17215          struct guestfs_hivex_node *val; /* Elements. */
17216        };
17217
17218        int guestfs_compare_hivex_node (const struct guestfs_hivex_node *, const struct guestfs_hivex_node *);
17219        int guestfs_compare_hivex_node_list (const struct guestfs_hivex_node_list *, const struct guestfs_hivex_node_list *);
17220
17221        struct guestfs_hivex_node *guestfs_copy_hivex_node (const struct guestfs_hivex_node *);
17222        struct guestfs_hivex_node_list *guestfs_copy_hivex_node_list (const struct guestfs_hivex_node_list *);
17223
17224        void guestfs_free_hivex_node (struct guestfs_hivex_node *);
17225        void guestfs_free_hivex_node_list (struct guestfs_hivex_node_list *);
17226
17227   guestfs_hivex_value
17228        struct guestfs_hivex_value {
17229          int64_t hivex_value_h;
17230        };
17231
17232        struct guestfs_hivex_value_list {
17233          uint32_t len; /* Number of elements in list. */
17234          struct guestfs_hivex_value *val; /* Elements. */
17235        };
17236
17237        int guestfs_compare_hivex_value (const struct guestfs_hivex_value *, const struct guestfs_hivex_value *);
17238        int guestfs_compare_hivex_value_list (const struct guestfs_hivex_value_list *, const struct guestfs_hivex_value_list *);
17239
17240        struct guestfs_hivex_value *guestfs_copy_hivex_value (const struct guestfs_hivex_value *);
17241        struct guestfs_hivex_value_list *guestfs_copy_hivex_value_list (const struct guestfs_hivex_value_list *);
17242
17243        void guestfs_free_hivex_value (struct guestfs_hivex_value *);
17244        void guestfs_free_hivex_value_list (struct guestfs_hivex_value_list *);
17245
17246   guestfs_internal_mountable
17247        struct guestfs_internal_mountable {
17248          int32_t im_type;
17249          char *im_device;
17250          char *im_volume;
17251        };
17252
17253        struct guestfs_internal_mountable_list {
17254          uint32_t len; /* Number of elements in list. */
17255          struct guestfs_internal_mountable *val; /* Elements. */
17256        };
17257
17258        int guestfs_compare_internal_mountable (const struct guestfs_internal_mountable *, const struct guestfs_internal_mountable *);
17259        int guestfs_compare_internal_mountable_list (const struct guestfs_internal_mountable_list *, const struct guestfs_internal_mountable_list *);
17260
17261        struct guestfs_internal_mountable *guestfs_copy_internal_mountable (const struct guestfs_internal_mountable *);
17262        struct guestfs_internal_mountable_list *guestfs_copy_internal_mountable_list (const struct guestfs_internal_mountable_list *);
17263
17264        void guestfs_free_internal_mountable (struct guestfs_internal_mountable *);
17265        void guestfs_free_internal_mountable_list (struct guestfs_internal_mountable_list *);
17266
17267   guestfs_tsk_dirent
17268        struct guestfs_tsk_dirent {
17269          uint64_t tsk_inode;
17270          char tsk_type;
17271          int64_t tsk_size;
17272          char *tsk_name;
17273          uint32_t tsk_flags;
17274          int64_t tsk_atime_sec;
17275          int64_t tsk_atime_nsec;
17276          int64_t tsk_mtime_sec;
17277          int64_t tsk_mtime_nsec;
17278          int64_t tsk_ctime_sec;
17279          int64_t tsk_ctime_nsec;
17280          int64_t tsk_crtime_sec;
17281          int64_t tsk_crtime_nsec;
17282          int64_t tsk_nlink;
17283          char *tsk_link;
17284          int64_t tsk_spare1;
17285        };
17286
17287        struct guestfs_tsk_dirent_list {
17288          uint32_t len; /* Number of elements in list. */
17289          struct guestfs_tsk_dirent *val; /* Elements. */
17290        };
17291
17292        int guestfs_compare_tsk_dirent (const struct guestfs_tsk_dirent *, const struct guestfs_tsk_dirent *);
17293        int guestfs_compare_tsk_dirent_list (const struct guestfs_tsk_dirent_list *, const struct guestfs_tsk_dirent_list *);
17294
17295        struct guestfs_tsk_dirent *guestfs_copy_tsk_dirent (const struct guestfs_tsk_dirent *);
17296        struct guestfs_tsk_dirent_list *guestfs_copy_tsk_dirent_list (const struct guestfs_tsk_dirent_list *);
17297
17298        void guestfs_free_tsk_dirent (struct guestfs_tsk_dirent *);
17299        void guestfs_free_tsk_dirent_list (struct guestfs_tsk_dirent_list *);
17300
17301   guestfs_yara_detection
17302        struct guestfs_yara_detection {
17303          char *yara_name;
17304          char *yara_rule;
17305        };
17306
17307        struct guestfs_yara_detection_list {
17308          uint32_t len; /* Number of elements in list. */
17309          struct guestfs_yara_detection *val; /* Elements. */
17310        };
17311
17312        int guestfs_compare_yara_detection (const struct guestfs_yara_detection *, const struct guestfs_yara_detection *);
17313        int guestfs_compare_yara_detection_list (const struct guestfs_yara_detection_list *, const struct guestfs_yara_detection_list *);
17314
17315        struct guestfs_yara_detection *guestfs_copy_yara_detection (const struct guestfs_yara_detection *);
17316        struct guestfs_yara_detection_list *guestfs_copy_yara_detection_list (const struct guestfs_yara_detection_list *);
17317
17318        void guestfs_free_yara_detection (struct guestfs_yara_detection *);
17319        void guestfs_free_yara_detection_list (struct guestfs_yara_detection_list *);
17320

AVAILABILITY

17322   GROUPS OF FUNCTIONALITY IN THE APPLIANCE
17323       Using "guestfs_available" you can test availability of the following
17324       groups of functions.  This test queries the appliance to see if the
17325       appliance you are currently using supports the functionality.
17326
17327       acl The following functions: "guestfs_acl_delete_def_file"
17328           "guestfs_acl_get_file" "guestfs_acl_set_file"
17329
17330       blkdiscard
17331           The following functions: "guestfs_blkdiscard"
17332
17333       blkdiscardzeroes
17334           The following functions: "guestfs_blkdiscardzeroes"
17335
17336       btrfs
17337           The following functions: "guestfs_btrfs_balance_cancel"
17338           "guestfs_btrfs_balance_pause" "guestfs_btrfs_balance_resume"
17339           "guestfs_btrfs_balance_status" "guestfs_btrfs_device_add"
17340           "guestfs_btrfs_device_delete" "guestfs_btrfs_filesystem_balance"
17341           "guestfs_btrfs_filesystem_defragment"
17342           "guestfs_btrfs_filesystem_resize" "guestfs_btrfs_filesystem_show"
17343           "guestfs_btrfs_filesystem_sync" "guestfs_btrfs_fsck"
17344           "guestfs_btrfs_image" "guestfs_btrfs_qgroup_assign"
17345           "guestfs_btrfs_qgroup_create" "guestfs_btrfs_qgroup_destroy"
17346           "guestfs_btrfs_qgroup_limit" "guestfs_btrfs_qgroup_remove"
17347           "guestfs_btrfs_qgroup_show" "guestfs_btrfs_quota_enable"
17348           "guestfs_btrfs_quota_rescan" "guestfs_btrfs_replace"
17349           "guestfs_btrfs_rescue_chunk_recover"
17350           "guestfs_btrfs_rescue_super_recover" "guestfs_btrfs_scrub_cancel"
17351           "guestfs_btrfs_scrub_resume" "guestfs_btrfs_scrub_start"
17352           "guestfs_btrfs_scrub_status" "guestfs_btrfs_set_seeding"
17353           "guestfs_btrfs_subvolume_create" "guestfs_btrfs_subvolume_delete"
17354           "guestfs_btrfs_subvolume_get_default"
17355           "guestfs_btrfs_subvolume_list"
17356           "guestfs_btrfs_subvolume_set_default"
17357           "guestfs_btrfs_subvolume_show" "guestfs_btrfs_subvolume_snapshot"
17358           "guestfs_btrfstune_enable_extended_inode_refs"
17359           "guestfs_btrfstune_enable_skinny_metadata_extent_refs"
17360           "guestfs_btrfstune_seeding" "guestfs_mkfs_btrfs"
17361
17362       extlinux
17363           The following functions: "guestfs_extlinux"
17364
17365       f2fs
17366           The following functions: "guestfs_f2fs_expand"
17367
17368       fstrim
17369           The following functions: "guestfs_fstrim"
17370
17371       gdisk
17372           The following functions: "guestfs_part_expand_gpt"
17373           "guestfs_part_get_disk_guid" "guestfs_part_get_gpt_attributes"
17374           "guestfs_part_get_gpt_guid" "guestfs_part_get_gpt_type"
17375           "guestfs_part_set_disk_guid" "guestfs_part_set_disk_guid_random"
17376           "guestfs_part_set_gpt_attributes" "guestfs_part_set_gpt_guid"
17377           "guestfs_part_set_gpt_type"
17378
17379       grub
17380           The following functions: "guestfs_grub_install"
17381
17382       hivex
17383           The following functions: "guestfs_hivex_close"
17384           "guestfs_hivex_commit" "guestfs_hivex_node_add_child"
17385           "guestfs_hivex_node_children" "guestfs_hivex_node_delete_child"
17386           "guestfs_hivex_node_get_child" "guestfs_hivex_node_get_value"
17387           "guestfs_hivex_node_name" "guestfs_hivex_node_parent"
17388           "guestfs_hivex_node_set_value" "guestfs_hivex_node_values"
17389           "guestfs_hivex_open" "guestfs_hivex_root" "guestfs_hivex_value_key"
17390           "guestfs_hivex_value_string" "guestfs_hivex_value_type"
17391           "guestfs_hivex_value_utf8" "guestfs_hivex_value_value"
17392
17393       inotify
17394           The following functions: "guestfs_inotify_add_watch"
17395           "guestfs_inotify_close" "guestfs_inotify_files"
17396           "guestfs_inotify_init" "guestfs_inotify_read"
17397           "guestfs_inotify_rm_watch"
17398
17399       journal
17400           The following functions: "guestfs_internal_journal_get"
17401           "guestfs_journal_close" "guestfs_journal_get_data_threshold"
17402           "guestfs_journal_get_realtime_usec" "guestfs_journal_next"
17403           "guestfs_journal_open" "guestfs_journal_set_data_threshold"
17404           "guestfs_journal_skip"
17405
17406       ldm The following functions: "guestfs_ldmtool_create_all"
17407           "guestfs_ldmtool_diskgroup_disks" "guestfs_ldmtool_diskgroup_name"
17408           "guestfs_ldmtool_diskgroup_volumes" "guestfs_ldmtool_remove_all"
17409           "guestfs_ldmtool_scan" "guestfs_ldmtool_scan_devices"
17410           "guestfs_ldmtool_volume_hint" "guestfs_ldmtool_volume_partitions"
17411           "guestfs_ldmtool_volume_type" "guestfs_list_ldm_partitions"
17412           "guestfs_list_ldm_volumes"
17413
17414       libtsk
17415           The following functions: "guestfs_internal_filesystem_walk"
17416           "guestfs_internal_find_inode"
17417
17418       libyara
17419           The following functions: "guestfs_internal_yara_scan"
17420           "guestfs_yara_destroy" "guestfs_yara_load"
17421
17422       linuxcaps
17423           The following functions: "guestfs_cap_get_file"
17424           "guestfs_cap_set_file"
17425
17426       linuxfsuuid
17427           The following functions: "guestfs_mke2fs_JU"
17428           "guestfs_mke2journal_U" "guestfs_mkswap_U" "guestfs_swapoff_uuid"
17429           "guestfs_swapon_uuid"
17430
17431       linuxmodules
17432           The following functions: "guestfs_modprobe"
17433
17434       linuxxattrs
17435           The following functions: "guestfs_getxattr" "guestfs_getxattrs"
17436           "guestfs_internal_lxattrlist" "guestfs_lgetxattr"
17437           "guestfs_lgetxattrs" "guestfs_lremovexattr" "guestfs_lsetxattr"
17438           "guestfs_removexattr" "guestfs_setxattr"
17439
17440       luks
17441           The following functions: "guestfs_luks_add_key"
17442           "guestfs_luks_close" "guestfs_luks_format"
17443           "guestfs_luks_format_cipher" "guestfs_luks_kill_slot"
17444           "guestfs_luks_open" "guestfs_luks_open_ro" "guestfs_luks_uuid"
17445
17446       lvm2
17447           The following functions: "guestfs_lvcreate" "guestfs_lvcreate_free"
17448           "guestfs_lvm_remove_all" "guestfs_lvm_set_filter"
17449           "guestfs_lvremove" "guestfs_lvresize" "guestfs_lvresize_free"
17450           "guestfs_lvs" "guestfs_lvs_full" "guestfs_pvchange_uuid"
17451           "guestfs_pvchange_uuid_all" "guestfs_pvcreate" "guestfs_pvremove"
17452           "guestfs_pvresize" "guestfs_pvresize_size" "guestfs_pvs"
17453           "guestfs_pvs_full" "guestfs_vg_activate" "guestfs_vg_activate_all"
17454           "guestfs_vgchange_uuid" "guestfs_vgchange_uuid_all"
17455           "guestfs_vgcreate" "guestfs_vgmeta" "guestfs_vgremove"
17456           "guestfs_vgs" "guestfs_vgs_full"
17457
17458       mdadm
17459           The following functions: "guestfs_md_create" "guestfs_md_detail"
17460           "guestfs_md_stat" "guestfs_md_stop"
17461
17462       mknod
17463           The following functions: "guestfs_mkfifo" "guestfs_mknod"
17464           "guestfs_mknod_b" "guestfs_mknod_c"
17465
17466       ntfs3g
17467           The following functions: "guestfs_ntfs_3g_probe"
17468           "guestfs_ntfsclone_in" "guestfs_ntfsclone_out" "guestfs_ntfsfix"
17469
17470       ntfsprogs
17471           The following functions: "guestfs_ntfsresize"
17472           "guestfs_ntfsresize_size"
17473
17474       rsync
17475           The following functions: "guestfs_rsync" "guestfs_rsync_in"
17476           "guestfs_rsync_out"
17477
17478       scrub
17479           The following functions: "guestfs_scrub_device"
17480           "guestfs_scrub_file" "guestfs_scrub_freespace"
17481
17482       selinux
17483           The following functions: "guestfs_getcon" "guestfs_setcon"
17484
17485       selinuxrelabel
17486           The following functions: "guestfs_selinux_relabel"
17487
17488       sleuthkit
17489           The following functions: "guestfs_download_blocks"
17490           "guestfs_download_inode"
17491
17492       squashfs
17493           The following functions: "guestfs_mksquashfs"
17494
17495       syslinux
17496           The following functions: "guestfs_syslinux"
17497
17498       wipefs
17499           The following functions: "guestfs_wipefs"
17500
17501       xfs The following functions: "guestfs_xfs_admin" "guestfs_xfs_growfs"
17502           "guestfs_xfs_info" "guestfs_xfs_repair"
17503
17504       xz  The following functions: "guestfs_txz_in" "guestfs_txz_out"
17505
17506       zerofree
17507           The following functions: "guestfs_zerofree"
17508
17509   FILESYSTEM AVAILABLE
17510       The "guestfs_filesystem_available" call tests whether a filesystem type
17511       is supported by the appliance kernel.
17512
17513       This is mainly useful as a negative test.  If this returns true, it
17514       doesn't mean that a particular filesystem can be mounted, since
17515       filesystems can fail for other reasons such as it being a later version
17516       of the filesystem, or having incompatible features.
17517
17518   GUESTFISH supported COMMAND
17519       In guestfish(3) there is a handy interactive command "supported" which
17520       prints out the available groups and whether they are supported by this
17521       build of libguestfs.  Note however that you have to do "run" first.
17522
17523   SINGLE CALLS AT COMPILE TIME
17524       Since version 1.5.8, "<guestfs.h>" defines symbols for each C API
17525       function, such as:
17526
17527        #define GUESTFS_HAVE_DD 1
17528
17529       if "guestfs_dd" is available.
17530
17531       Before version 1.5.8, if you needed to test whether a single libguestfs
17532       function is available at compile time, we recommended using build tools
17533       such as autoconf or cmake.  For example in autotools you could use:
17534
17535        AC_CHECK_LIB([guestfs],[guestfs_create])
17536        AC_CHECK_FUNCS([guestfs_dd])
17537
17538       which would result in "HAVE_GUESTFS_DD" being either defined or not
17539       defined in your program.
17540
17541   SINGLE CALLS AT RUN TIME
17542       Testing at compile time doesn't guarantee that a function really exists
17543       in the library.  The reason is that you might be dynamically linked
17544       against a previous libguestfs.so (dynamic library) which doesn't have
17545       the call.  This situation unfortunately results in a segmentation
17546       fault, which is a shortcoming of the C dynamic linking system itself.
17547
17548       You can use dlopen(3) to test if a function is available at run time,
17549       as in this example program (note that you still need the compile time
17550       check as well):
17551
17552        #include <stdio.h>
17553        #include <stdlib.h>
17554        #include <unistd.h>
17555        #include <dlfcn.h>
17556        #include <guestfs.h>
17557
17558        main ()
17559        {
17560        #ifdef GUESTFS_HAVE_DD
17561          void *dl;
17562          int has_function;
17563
17564          /* Test if the function guestfs_dd is really available. */
17565          dl = dlopen (NULL, RTLD_LAZY);
17566          if (!dl) {
17567            fprintf (stderr, "dlopen: %s\n", dlerror ());
17568            exit (EXIT_FAILURE);
17569          }
17570          has_function = dlsym (dl, "guestfs_dd") != NULL;
17571          dlclose (dl);
17572
17573          if (!has_function)
17574            printf ("this libguestfs.so does NOT have guestfs_dd function\n");
17575          else {
17576            printf ("this libguestfs.so has guestfs_dd function\n");
17577            /* Now it's safe to call
17578            guestfs_dd (g, "foo", "bar");
17579            */
17580          }
17581        #else
17582          printf ("guestfs_dd function was not found at compile time\n");
17583        #endif
17584         }
17585
17586       You may think the above is an awful lot of hassle, and it is.  There
17587       are other ways outside of the C linking system to ensure that this kind
17588       of incompatibility never arises, such as using package versioning:
17589
17590        Requires: libguestfs >= 1.0.80
17591

CALLS WITH OPTIONAL ARGUMENTS

17593       A recent feature of the API is the introduction of calls which take
17594       optional arguments.  In C these are declared 3 ways.  The main way is
17595       as a call which takes variable arguments (ie. "..."), as in this
17596       example:
17597
17598        int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);
17599
17600       Call this with a list of optional arguments, terminated by "-1".  So to
17601       call with no optional arguments specified:
17602
17603        guestfs_add_drive_opts (g, filename, -1);
17604
17605       With a single optional argument:
17606
17607        guestfs_add_drive_opts (g, filename,
17608                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "qcow2",
17609                                -1);
17610
17611       With two:
17612
17613        guestfs_add_drive_opts (g, filename,
17614                                GUESTFS_ADD_DRIVE_OPTS_FORMAT, "qcow2",
17615                                GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
17616                                -1);
17617
17618       and so forth.  Don’t forget the terminating "-1" otherwise Bad Things
17619       will happen!
17620
17621   USING va_list FOR OPTIONAL ARGUMENTS
17622       The second variant has the same name with the suffix "_va", which works
17623       the same way but takes a "va_list".  See the C manual for details.  For
17624       the example function, this is declared:
17625
17626        int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,
17627                                       va_list args);
17628
17629   CONSTRUCTING OPTIONAL ARGUMENTS
17630       The third variant is useful where you need to construct these calls.
17631       You pass in a structure where you fill in the optional fields.  The
17632       structure has a bitmask as the first element which you must set to
17633       indicate which fields you have filled in.  For our example function the
17634       structure and call are declared:
17635
17636        struct guestfs_add_drive_opts_argv {
17637          uint64_t bitmask;
17638          int readonly;
17639          const char *format;
17640          /* ... */
17641        };
17642        int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,
17643                     const struct guestfs_add_drive_opts_argv *optargs);
17644
17645       You could call it like this:
17646
17647        struct guestfs_add_drive_opts_argv optargs = {
17648          .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |
17649                     GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,
17650          .readonly = 1,
17651          .format = "qcow2"
17652        };
17653
17654        guestfs_add_drive_opts_argv (g, filename, &optargs);
17655
17656       Notes:
17657
17658       ·   The "_BITMASK" suffix on each option name when specifying the
17659           bitmask.
17660
17661       ·   You do not need to fill in all fields of the structure.
17662
17663       ·   There must be a one-to-one correspondence between fields of the
17664           structure that are filled in, and bits set in the bitmask.
17665
17666   OPTIONAL ARGUMENTS IN OTHER LANGUAGES
17667       In other languages, optional arguments are expressed in the way that is
17668       natural for that language.  We refer you to the language-specific
17669       documentation for more details on that.
17670
17671       For guestfish, see "OPTIONAL ARGUMENTS" in guestfish(1).
17672

EVENTS

17674   SETTING CALLBACKS TO HANDLE EVENTS
17675       Note: This section documents the generic event mechanism introduced in
17676       libguestfs 1.10, which you should use in new code if possible.  The old
17677       functions "guestfs_set_log_message_callback",
17678       "guestfs_set_subprocess_quit_callback",
17679       "guestfs_set_launch_done_callback", "guestfs_set_close_callback" and
17680       "guestfs_set_progress_callback" are no longer documented in this manual
17681       page.  Because of the ABI guarantee, the old functions continue to
17682       work.
17683
17684       Handles generate events when certain things happen, such as log
17685       messages being generated, progress messages during long-running
17686       operations, or the handle being closed.  The API calls described below
17687       let you register a callback to be called when events happen.  You can
17688       register multiple callbacks (for the same, different or overlapping
17689       sets of events), and individually remove callbacks.  If callbacks are
17690       not removed, then they remain in force until the handle is closed.
17691
17692       In the current implementation, events are only generated synchronously:
17693       that means that events (and hence callbacks) can only happen while you
17694       are in the middle of making another libguestfs call.  The callback is
17695       called in the same thread.
17696
17697       Events may contain a payload, usually nothing (void), an array of 64
17698       bit unsigned integers, or a message buffer.  Payloads are discussed
17699       later on.
17700
17701   CLASSES OF EVENTS
17702       GUESTFS_EVENT_CLOSE (payload type: void)
17703           The callback function will be called while the handle is being
17704           closed (synchronously from "guestfs_close").
17705
17706           Note that libguestfs installs an atexit(3) handler to try to clean
17707           up handles that are open when the program exits.  This means that
17708           this callback might be called indirectly from exit(3), which can
17709           cause unexpected problems in higher-level languages (eg. if your
17710           HLL interpreter has already been cleaned up by the time this is
17711           called, and if your callback then jumps into some HLL function).
17712
17713           If no callback is registered: the handle is closed without any
17714           callback being invoked.
17715
17716       GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)
17717           The callback function will be called when the child process quits,
17718           either asynchronously or if killed by "guestfs_kill_subprocess".
17719           (This corresponds to a transition from any state to the CONFIG
17720           state).
17721
17722           If no callback is registered: the event is ignored.
17723
17724       GUESTFS_EVENT_LAUNCH_DONE (payload type: void)
17725           The callback function will be called when the child process becomes
17726           ready first time after it has been launched.  (This corresponds to
17727           a transition from LAUNCHING to the READY state).
17728
17729           If no callback is registered: the event is ignored.
17730
17731       GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)
17732           Some long-running operations can generate progress messages.  If
17733           this callback is registered, then it will be called each time a
17734           progress message is generated (usually two seconds after the
17735           operation started, and three times per second thereafter until it
17736           completes, although the frequency may change in future versions).
17737
17738           The callback receives in the payload four unsigned 64 bit numbers
17739           which are (in order): "proc_nr", "serial", "position", "total".
17740
17741           The units of "total" are not defined, although for some operations
17742           "total" may relate in some way to the amount of data to be
17743           transferred (eg. in bytes or megabytes), and "position" may be the
17744           portion which has been transferred.
17745
17746           The only defined and stable parts of the API are:
17747
17748           ·   The callback can display to the user some type of progress bar
17749               or indicator which shows the ratio of "position":"total".
17750
17751           ·   0 <= "position" <= "total"
17752
17753           ·   If any progress notification is sent during a call, then a
17754               final progress notification is always sent when "position" =
17755               "total" (unless the call fails with an error).
17756
17757               This is to simplify caller code, so callers can easily set the
17758               progress indicator to "100%" at the end of the operation,
17759               without requiring special code to detect this case.
17760
17761           ·   For some calls we are unable to estimate the progress of the
17762               call, but we can still generate progress messages to indicate
17763               activity.  This is known as "pulse mode", and is directly
17764               supported by certain progress bar implementations (eg.
17765               GtkProgressBar).
17766
17767               For these calls, zero or more progress messages are generated
17768               with "position = 0" and "total = 1", followed by a final
17769               message with "position = total = 1".
17770
17771               As noted above, if the call fails with an error then the final
17772               message may not be generated.
17773
17774           The callback also receives the procedure number ("proc_nr") and
17775           serial number ("serial") of the call.  These are only useful for
17776           debugging protocol issues, and the callback can normally ignore
17777           them.  The callback may want to print these numbers in error
17778           messages or debugging messages.
17779
17780           If no callback is registered: progress messages are discarded.
17781
17782       GUESTFS_EVENT_APPLIANCE (payload type: message buffer)
17783           The callback function is called whenever a log message is generated
17784           by qemu, the appliance kernel, guestfsd (daemon), or utility
17785           programs.
17786
17787           If the verbose flag ("guestfs_set_verbose") is set before launch
17788           ("guestfs_launch") then additional debug messages are generated.
17789
17790           If no callback is registered: the messages are discarded unless the
17791           verbose flag is set in which case they are sent to stderr.  You can
17792           override the printing of verbose messages to stderr by setting up a
17793           callback.
17794
17795       GUESTFS_EVENT_LIBRARY (payload type: message buffer)
17796           The callback function is called whenever a log message is generated
17797           by the library part of libguestfs.
17798
17799           If the verbose flag ("guestfs_set_verbose") is set then additional
17800           debug messages are generated.
17801
17802           If no callback is registered: the messages are discarded unless the
17803           verbose flag is set in which case they are sent to stderr.  You can
17804           override the printing of verbose messages to stderr by setting up a
17805           callback.
17806
17807       GUESTFS_EVENT_WARNING (payload type: message buffer)
17808           The callback function is called whenever a warning message is
17809           generated by the library part of libguestfs.
17810
17811           If no callback is registered: the messages are printed to stderr.
17812           You can override the printing of warning messages to stderr by
17813           setting up a callback.
17814
17815       GUESTFS_EVENT_TRACE (payload type: message buffer)
17816           The callback function is called whenever a trace message is
17817           generated.  This only applies if the trace flag
17818           ("guestfs_set_trace") is set.
17819
17820           If no callback is registered: the messages are sent to stderr.  You
17821           can override the printing of trace messages to stderr by setting up
17822           a callback.
17823
17824       GUESTFS_EVENT_ENTER (payload type: function name)
17825           The callback function is called whenever a libguestfs function is
17826           entered.
17827
17828           The payload is a string which contains the name of the function
17829           that we are entering (not including "guestfs_" prefix).
17830
17831           Note that libguestfs functions can call themselves, so you may see
17832           many events from a single call.  A few libguestfs functions do not
17833           generate this event.
17834
17835           If no callback is registered: the event is ignored.
17836
17837       GUESTFS_EVENT_LIBVIRT_AUTH (payload type: libvirt URI)
17838           For any API function that opens a libvirt connection, this event
17839           may be generated to indicate that libvirt demands authentication
17840           information.  See "LIBVIRT AUTHENTICATION" below.
17841
17842           If no callback is registered: "virConnectAuthPtrDefault" is used
17843           (suitable for command-line programs only).
17844
17845   EVENT API
17846       guestfs_set_event_callback
17847
17848        int guestfs_set_event_callback (guestfs_h *g,
17849                                        guestfs_event_callback cb,
17850                                        uint64_t event_bitmask,
17851                                        int flags,
17852                                        void *opaque);
17853
17854       This function registers a callback ("cb") for all event classes in the
17855       "event_bitmask".
17856
17857       For example, to register for all log message events, you could call
17858       this function with the bitmask
17859       "GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_WARNING".
17860       To register a single callback for all possible classes of events, use
17861       "GUESTFS_EVENT_ALL".
17862
17863       "flags" should always be passed as 0.
17864
17865       "opaque" is an opaque pointer which is passed to the callback.  You can
17866       use it for any purpose.
17867
17868       The return value is the event handle (an integer) which you can use to
17869       delete the callback (see below).
17870
17871       If there is an error, this function returns "-1", and sets the error in
17872       the handle in the usual way (see "guestfs_last_error" etc.)
17873
17874       Callbacks remain in effect until they are deleted, or until the handle
17875       is closed.
17876
17877       In the case where multiple callbacks are registered for a particular
17878       event class, all of the callbacks are called.  The order in which
17879       multiple callbacks are called is not defined.
17880
17881       guestfs_delete_event_callback
17882
17883        void guestfs_delete_event_callback (guestfs_h *g, int event_handle);
17884
17885       Delete a callback that was previously registered.  "event_handle"
17886       should be the integer that was returned by a previous call to
17887       "guestfs_set_event_callback" on the same handle.
17888
17889       guestfs_event_to_string
17890
17891        char *guestfs_event_to_string (uint64_t event);
17892
17893       "event" is either a single event or a bitmask of events.  This returns
17894       a string representation (useful for debugging or printing events).
17895
17896       A single event is returned as the name in lower case, eg. "close".
17897
17898       A bitmask of several events is returned as a comma-separated list, eg.
17899       "close,progress".
17900
17901       If zero is passed, then the empty string "" is returned.
17902
17903       On success this returns a string.  On error it returns NULL and sets
17904       "errno".
17905
17906       The returned string must be freed by the caller.
17907
17908       guestfs_event_callback
17909
17910        typedef void (*guestfs_event_callback) (
17911                         guestfs_h *g,
17912                         void *opaque,
17913                         uint64_t event,
17914                         int event_handle,
17915                         int flags,
17916                         const char *buf, size_t buf_len,
17917                         const uint64_t *array, size_t array_len);
17918
17919       This is the type of the event callback function that you have to
17920       provide.
17921
17922       The basic parameters are: the handle ("g"), the opaque user pointer
17923       ("opaque"), the event class (eg. "GUESTFS_EVENT_PROGRESS"), the event
17924       handle, and "flags" which in the current API you should ignore.
17925
17926       The remaining parameters contain the event payload (if any).  Each
17927       event may contain a payload, which usually relates to the event class,
17928       but for future proofing your code should be written to handle any
17929       payload for any event class.
17930
17931       "buf" and "buf_len" contain a message buffer (if "buf_len == 0", then
17932       there is no message buffer).  Note that this message buffer can contain
17933       arbitrary 8 bit data, including NUL bytes.
17934
17935       "array" and "array_len" is an array of 64 bit unsigned integers.  At
17936       the moment this is only used for progress messages.
17937
17938   EXAMPLE: CAPTURING LOG MESSAGES
17939       A working program demonstrating this can be found in
17940       examples/debug-logging.c in the source of libguestfs.
17941
17942       One motivation for the generic event API was to allow GUI programs to
17943       capture debug and other messages.  In libguestfs ≤ 1.8 these were sent
17944       unconditionally to "stderr".
17945
17946       Events associated with log messages are: "GUESTFS_EVENT_LIBRARY",
17947       "GUESTFS_EVENT_APPLIANCE", "GUESTFS_EVENT_WARNING" and
17948       "GUESTFS_EVENT_TRACE".  (Note that error messages are not events; you
17949       must capture error messages separately).
17950
17951       Programs have to set up a callback to capture the classes of events of
17952       interest:
17953
17954        int eh =
17955          guestfs_set_event_callback
17956            (g, message_callback,
17957             GUESTFS_EVENT_LIBRARY | GUESTFS_EVENT_APPLIANCE |
17958             GUESTFS_EVENT_WARNING | GUESTFS_EVENT_TRACE,
17959             0, NULL) == -1)
17960        if (eh == -1) {
17961          // handle error in the usual way
17962        }
17963
17964       The callback can then direct messages to the appropriate place.  In
17965       this example, messages are directed to syslog:
17966
17967        static void
17968        message_callback (
17969                guestfs_h *g,
17970                void *opaque,
17971                uint64_t event,
17972                int event_handle,
17973                int flags,
17974                const char *buf, size_t buf_len,
17975                const uint64_t *array, size_t array_len)
17976        {
17977          const int priority = LOG_USER|LOG_INFO;
17978          if (buf_len > 0)
17979            syslog (priority, "event 0x%lx: %s", event, buf);
17980        }
17981
17982   LIBVIRT AUTHENTICATION
17983       Some libguestfs API calls can open libvirt connections.  Currently the
17984       only ones are "guestfs_add_domain"; and "guestfs_launch" if the libvirt
17985       backend has been selected.  Libvirt connections may require
17986       authentication, for example if they need to access a remote server or
17987       to access root services from non-root.  Libvirt authentication happens
17988       via a callback mechanism, see
17989       http://libvirt.org/guide/html/Application_Development_Guide-Connections.html
17990
17991       You may provide libvirt authentication data by registering a callback
17992       for events of type "GUESTFS_EVENT_LIBVIRT_AUTH".
17993
17994       If no such event is registered, then libguestfs uses a libvirt function
17995       that provides command-line prompts ("virConnectAuthPtrDefault").  This
17996       is only suitable for command-line libguestfs programs.
17997
17998       To provide authentication, first call
17999       "guestfs_set_libvirt_supported_credentials" with the list of
18000       credentials your program knows how to provide.  Second, register a
18001       callback for the "GUESTFS_EVENT_LIBVIRT_AUTH" event.  The event handler
18002       will be called when libvirt is requesting authentication information.
18003
18004       In the event handler, call "guestfs_get_libvirt_requested_credentials"
18005       to get a list of the credentials that libvirt is asking for.  You then
18006       need to ask (eg. the user) for each credential, and call
18007       "guestfs_set_libvirt_requested_credential" with the answer.  Note that
18008       for each credential, additional information may be available via the
18009       calls "guestfs_get_libvirt_requested_credential_prompt",
18010       "guestfs_get_libvirt_requested_credential_challenge" or
18011       "guestfs_get_libvirt_requested_credential_defresult".
18012
18013       The example program below should make this clearer.
18014
18015       There is also a more substantial working example program supplied with
18016       the libguestfs sources, called libvirt-auth.c.
18017
18018        main ()
18019        {
18020          guestfs_h *g;
18021          char *creds[] = { "authname", "passphrase", NULL };
18022          int r, eh;
18023
18024          g = guestfs_create ();
18025          if (!g) exit (EXIT_FAILURE);
18026
18027          /* Tell libvirt what credentials the program supports. */
18028          r = guestfs_set_libvirt_supported_credentials (g, creds);
18029          if (r == -1)
18030            exit (EXIT_FAILURE);
18031
18032          /* Set up the event handler. */
18033          eh = guestfs_set_event_callback (
18034              g, do_auth,
18035              GUESTFS_EVENT_LIBVIRT_AUTH, 0, NULL);
18036          if (eh == -1)
18037            exit (EXIT_FAILURE);
18038
18039          /* An example of a call that may ask for credentials. */
18040          r = guestfs_add_domain (
18041              g, "dom",
18042              GUESTFS_ADD_DOMAIN_LIBVIRTURI, "qemu:///system",
18043              -1);
18044          if (r == -1)
18045            exit (EXIT_FAILURE);
18046
18047          exit (EXIT_SUCCESS);
18048        }
18049
18050        static void
18051        do_auth (guestfs_h *g,
18052                 void *opaque,
18053                 uint64_t event,
18054                 int event_handle,
18055                 int flags,
18056                 const char *buf, size_t buf_len,
18057                 const uint64_t *array, size_t array_len)
18058        {
18059          char **creds;
18060          size_t i;
18061          char *prompt;
18062          char *reply;
18063          size_t replylen;
18064          int r;
18065
18066          // buf will be the libvirt URI.  buf_len may be ignored.
18067          printf ("Authentication required for libvirt conn '%s'\n",
18068                  buf);
18069
18070          // Ask libguestfs what credentials libvirt is demanding.
18071          creds = guestfs_get_libvirt_requested_credentials (g);
18072          if (creds == NULL)
18073            exit (EXIT_FAILURE);
18074
18075          // Now ask the user for answers.
18076          for (i = 0; creds[i] != NULL; ++i)
18077          {
18078            if (strcmp (creds[i], "authname") == 0 ||
18079                strcmp (creds[i], "passphrase") == 0)
18080            {
18081              prompt =
18082                guestfs_get_libvirt_requested_credential_prompt (g, i);
18083              if (prompt && strcmp (prompt, "") != 0)
18084                printf ("%s: ", prompt);
18085              free (prompt);
18086
18087              // Some code here to ask for the credential.
18088              // ...
18089              // Put the reply in 'reply', length 'replylen' (bytes).
18090
18091             r = guestfs_set_libvirt_requested_credential (g, i,
18092                 reply, replylen);
18093             if (r == -1)
18094               exit (EXIT_FAILURE);
18095            }
18096
18097            free (creds[i]);
18098          }
18099
18100          free (creds);
18101        }
18102

CANCELLING LONG TRANSFERS

18104       Some operations can be cancelled by the caller while they are in
18105       progress.  Currently only operations that involve uploading or
18106       downloading data can be cancelled (technically: operations that have
18107       "FileIn" or "FileOut" parameters in the generator).
18108
18109       To cancel the transfer, call "guestfs_user_cancel".  For more
18110       information, read the description of "guestfs_user_cancel".
18111

PRIVATE DATA AREA

18113       You can attach named pieces of private data to the libguestfs handle,
18114       fetch them by name, and walk over them, for the lifetime of the handle.
18115       This is called the private data area and is only available from the C
18116       API.
18117
18118       To attach a named piece of data, use the following call:
18119
18120        void guestfs_set_private (guestfs_h *g, const char *key, void *data);
18121
18122       "key" is the name to associate with this data, and "data" is an
18123       arbitrary pointer (which can be "NULL").  Any previous item with the
18124       same key is overwritten.
18125
18126       You can use any "key" string you want, but avoid keys beginning with an
18127       underscore character (libguestfs uses those for its own internal
18128       purposes, such as implementing language bindings).  It is recommended
18129       that you prefix the key with some unique string to avoid collisions
18130       with other users.
18131
18132       To retrieve the pointer, use:
18133
18134        void *guestfs_get_private (guestfs_h *g, const char *key);
18135
18136       This function returns "NULL" if either no data is found associated with
18137       "key", or if the user previously set the "key"’s "data" pointer to
18138       "NULL".
18139
18140       Libguestfs does not try to look at or interpret the "data" pointer in
18141       any way.  As far as libguestfs is concerned, it need not be a valid
18142       pointer at all.  In particular, libguestfs does not try to free the
18143       data when the handle is closed.  If the data must be freed, then the
18144       caller must either free it before calling "guestfs_close" or must set
18145       up a close callback to do it (see "GUESTFS_EVENT_CLOSE").
18146
18147       To walk over all entries, use these two functions:
18148
18149        void *guestfs_first_private (guestfs_h *g, const char **key_rtn);
18150
18151        void *guestfs_next_private (guestfs_h *g, const char **key_rtn);
18152
18153       "guestfs_first_private" returns the first key, pointer pair ("first"
18154       does not have any particular meaning -- keys are not returned in any
18155       defined order).  A pointer to the key is returned in *key_rtn and the
18156       corresponding data pointer is returned from the function.  "NULL" is
18157       returned if there are no keys stored in the handle.
18158
18159       "guestfs_next_private" returns the next key, pointer pair.  The return
18160       value of this function is "NULL" if there are no further entries to
18161       return.
18162
18163       Notes about walking over entries:
18164
18165       ·   You must not call "guestfs_set_private" while walking over the
18166           entries.
18167
18168       ·   The handle maintains an internal iterator which is reset when you
18169           call "guestfs_first_private".  This internal iterator is
18170           invalidated when you call "guestfs_set_private".
18171
18172       ·   If you have set the data pointer associated with a key to "NULL",
18173           ie:
18174
18175            guestfs_set_private (g, key, NULL);
18176
18177           then that "key" is not returned when walking.
18178
18179       ·   *key_rtn is only valid until the next call to
18180           "guestfs_first_private", "guestfs_next_private" or
18181           "guestfs_set_private".
18182
18183       The following example code shows how to print all keys and data
18184       pointers that are associated with the handle "g":
18185
18186        const char *key;
18187        void *data = guestfs_first_private (g, &key);
18188        while (data != NULL)
18189          {
18190            printf ("key = %s, data = %p\n", key, data);
18191            data = guestfs_next_private (g, &key);
18192          }
18193
18194       More commonly you are only interested in keys that begin with an
18195       application-specific prefix "foo_".  Modify the loop like so:
18196
18197        const char *key;
18198        void *data = guestfs_first_private (g, &key);
18199        while (data != NULL)
18200          {
18201            if (strncmp (key, "foo_", strlen ("foo_")) == 0)
18202              printf ("key = %s, data = %p\n", key, data);
18203            data = guestfs_next_private (g, &key);
18204          }
18205
18206       If you need to modify keys while walking, then you have to jump back to
18207       the beginning of the loop.  For example, to delete all keys prefixed
18208       with "foo_":
18209
18210         const char *key;
18211         void *data;
18212        again:
18213         data = guestfs_first_private (g, &key);
18214         while (data != NULL)
18215           {
18216             if (strncmp (key, "foo_", strlen ("foo_")) == 0)
18217               {
18218                 guestfs_set_private (g, key, NULL);
18219                 /* note that 'key' pointer is now invalid, and so is
18220                    the internal iterator */
18221                 goto again;
18222               }
18223             data = guestfs_next_private (g, &key);
18224           }
18225
18226       Note that the above loop is guaranteed to terminate because the keys
18227       are being deleted, but other manipulations of keys within the loop
18228       might not terminate unless you also maintain an indication of which
18229       keys have been visited.
18230

SYSTEMTAP

18232       The libguestfs C library can be probed using systemtap or DTrace.  This
18233       is true of any library, not just libguestfs.  However libguestfs also
18234       contains static markers to help in probing internal operations.
18235
18236       You can list all the static markers by doing:
18237
18238        stap -l 'process("/usr/lib*/libguestfs.so.0")
18239                     .provider("guestfs").mark("*")'
18240
18241       Note: These static markers are not part of the stable API and may
18242       change in future versions.
18243
18244   SYSTEMTAP SCRIPT EXAMPLE
18245       This script contains examples of displaying both the static markers and
18246       some ordinary C entry points:
18247
18248        global last;
18249
18250        function display_time () {
18251              now = gettimeofday_us ();
18252              delta = 0;
18253              if (last > 0)
18254                    delta = now - last;
18255              last = now;
18256
18257              printf ("%d (+%d):", now, delta);
18258        }
18259
18260        probe begin {
18261              last = 0;
18262              printf ("ready\n");
18263        }
18264
18265        /* Display all calls to static markers. */
18266        probe process("/usr/lib*/libguestfs.so.0")
18267                  .provider("guestfs").mark("*") ? {
18268              display_time();
18269              printf ("\t%s %s\n", $$name, $$parms);
18270        }
18271
18272        /* Display all calls to guestfs_mkfs* functions. */
18273        probe process("/usr/lib*/libguestfs.so.0")
18274                  .function("guestfs_mkfs*") ? {
18275              display_time();
18276              printf ("\t%s %s\n", probefunc(), $$parms);
18277        }
18278
18279       The script above can be saved to test.stap and run using the stap(1)
18280       program.  Note that you either have to be root, or you have to add
18281       yourself to several special stap groups.  Consult the systemtap
18282       documentation for more information.
18283
18284        # stap /tmp/test.stap
18285        ready
18286
18287       In another terminal, run a guestfish command such as this:
18288
18289        guestfish -N fs
18290
18291       In the first terminal, stap trace output similar to this is shown:
18292
18293        1318248056692655 (+0): launch_start
18294        1318248056692850 (+195):       launch_build_appliance_start
18295        1318248056818285 (+125435):    launch_build_appliance_end
18296        1318248056838059 (+19774):     launch_run_qemu
18297        1318248061071167 (+4233108):   launch_end
18298        1318248061280324 (+209157):    guestfs_mkfs g=0x1024ab0 fstype=0x46116f device=0x1024e60
18299

LIBGUESTFS VERSION NUMBERS

18301       Since April 2010, libguestfs has started to make separate development
18302       and stable releases, along with corresponding branches in our git
18303       repository.  These separate releases can be identified by version
18304       number:
18305
18306                        even numbers for stable: 1.2.x, 1.4.x, ...
18307              .-------- odd numbers for development: 1.3.x, 1.5.x, ...
18308              |
18309              v
18310        1  .  3  .  5
18311        ^           ^
18312        |           |
18313        |           `-------- sub-version
18314        |
18315        `------ always '1' because we don't change the ABI
18316
18317       Thus "1.3.5" is the 5th update to the development branch "1.3".
18318
18319       As time passes we cherry pick fixes from the development branch and
18320       backport those into the stable branch, the effect being that the stable
18321       branch should get more stable and less buggy over time.  So the stable
18322       releases are ideal for people who don't need new features but would
18323       just like the software to work.
18324
18325       Our criteria for backporting changes are:
18326
18327       ·   Documentation changes which don’t affect any code are backported
18328           unless the documentation refers to a future feature which is not in
18329           stable.
18330
18331       ·   Bug fixes which are not controversial, fix obvious problems, and
18332           have been well tested are backported.
18333
18334       ·   Simple rearrangements of code which shouldn't affect how it works
18335           get backported.  This is so that the code in the two branches
18336           doesn't get too far out of step, allowing us to backport future
18337           fixes more easily.
18338
18339       ·   We don’t backport new features, new APIs, new tools etc, except in
18340           one exceptional case: the new feature is required in order to
18341           implement an important bug fix.
18342
18343       A new stable branch starts when we think the new features in
18344       development are substantial and compelling enough over the current
18345       stable branch to warrant it.  When that happens we create new stable
18346       and development versions 1.N.0 and 1.(N+1).0 [N is even].  The new dot-
18347       oh release won't necessarily be so stable at this point, but by
18348       backporting fixes from development, that branch will stabilize over
18349       time.
18350

LIMITS

18352   PROTOCOL LIMITS
18353       Internally libguestfs uses a message-based protocol to pass API calls
18354       and their responses to and from a small "appliance" (see
18355       guestfs-internals(1) for plenty more detail about this).  The maximum
18356       message size used by the protocol is slightly less than 4 MB.  For some
18357       API calls you may need to be aware of this limit.  The API calls which
18358       may be affected are individually documented, with a link back to this
18359       section of the documentation.
18360
18361       In libguestfs < 1.19.32, several calls had to encode either their
18362       entire argument list or their entire return value (or sometimes both)
18363       in a single protocol message, and this gave them an arbitrary
18364       limitation on how much data they could handle.  For example,
18365       "guestfs_cat" could only download a file if it was less than around 4
18366       MB in size.  In later versions of libguestfs, some of these limits have
18367       been removed.  The APIs which were previously limited but are now
18368       unlimited (except perhaps by available memory) are listed below.  To
18369       find out if a specific API is subject to protocol limits, check for the
18370       warning in the API documentation which links to this section, and
18371       remember to check the version of the documentation that matches the
18372       version of libguestfs you are using.
18373
18374       "guestfs_cat", "guestfs_find", "guestfs_read_file",
18375       "guestfs_read_lines", "guestfs_write", "guestfs_write_append",
18376       "guestfs_lstatlist", "guestfs_lxattrlist", "guestfs_readlinklist",
18377       "guestfs_ls".
18378
18379       See also "UPLOADING" and "DOWNLOADING" for further information about
18380       copying large amounts of data into or out of a filesystem.
18381
18382   MAXIMUM NUMBER OF DISKS
18383       In libguestfs ≥ 1.19.7, you can query the maximum number of disks that
18384       may be added by calling "guestfs_max_disks".  In earlier versions of
18385       libguestfs (ie. where this call is not available) you should assume the
18386       maximum is 25.
18387
18388       The rest of this section covers implementation details, which could
18389       change in future.
18390
18391       When using virtio-scsi disks (the default if available in qemu) the
18392       current limit is 255 disks.  When using virtio-blk (the old default)
18393       the limit is around 27 disks, but may vary according to implementation
18394       details and whether the network is enabled.
18395
18396       Virtio-scsi as used by libguestfs is configured to use one target per
18397       disk, and 256 targets are available.
18398
18399       Virtio-blk consumes 1 virtual PCI slot per disk, and PCI is limited to
18400       31 slots, but some of these are used for other purposes.
18401
18402       One virtual disk is used by libguestfs internally.
18403
18404       Before libguestfs 1.19.7, disk names had to be a single character (eg.
18405       /dev/sda through /dev/sdz), and since one disk is reserved, that meant
18406       the limit was 25.  This has been fixed in more recent versions.
18407
18408       In libguestfs ≥ 1.20 it is possible to hot plug disks.  See
18409       "HOTPLUGGING".
18410
18411   MAXIMUM NUMBER OF PARTITIONS PER DISK
18412       Virtio limits the maximum number of partitions per disk to 15.
18413
18414       This is because it reserves 4 bits for the minor device number (thus
18415       /dev/vda, and /dev/vda1 through /dev/vda15).
18416
18417       If you attach a disk with more than 15 partitions, the extra partitions
18418       are ignored by libguestfs.
18419
18420   MAXIMUM SIZE OF A DISK
18421       Probably the limit is between 2**63-1 and 2**64-1 bytes.
18422
18423       We have tested block devices up to 1 exabyte (2**60 or
18424       1,152,921,504,606,846,976 bytes) using sparse files backed by an XFS
18425       host filesystem.
18426
18427       Although libguestfs probably does not impose any limit, the underlying
18428       host storage will.  If you store disk images on a host ext4 filesystem,
18429       then the maximum size will be limited by the maximum ext4 file size
18430       (currently 16 TB).  If you store disk images as host logical volumes
18431       then you are limited by the maximum size of an LV.
18432
18433       For the hugest disk image files, we recommend using XFS on the host for
18434       storage.
18435
18436   MAXIMUM SIZE OF A PARTITION
18437       The MBR (ie. classic MS-DOS) partitioning scheme uses 32 bit sector
18438       numbers.  Assuming a 512 byte sector size, this means that MBR cannot
18439       address a partition located beyond 2 TB on the disk.
18440
18441       It is recommended that you use GPT partitions on disks which are larger
18442       than this size.  GPT uses 64 bit sector numbers and so can address
18443       partitions which are theoretically larger than the largest disk we
18444       could support.
18445
18446   MAXIMUM SIZE OF A FILESYSTEM, FILES, DIRECTORIES
18447       This depends on the filesystem type.  libguestfs itself does not impose
18448       any known limit.  Consult Wikipedia or the filesystem documentation to
18449       find out what these limits are.
18450
18451   MAXIMUM UPLOAD AND DOWNLOAD
18452       The API functions "guestfs_upload", "guestfs_download",
18453       "guestfs_tar_in", "guestfs_tar_out" and the like allow unlimited sized
18454       uploads and downloads.
18455
18456   INSPECTION LIMITS
18457       The inspection code has several arbitrary limits on things like the
18458       size of Windows Registry hive it will read, and the length of product
18459       name.  These are intended to stop a malicious guest from consuming
18460       arbitrary amounts of memory and disk space on the host, and should not
18461       be reached in practice.  See the source code for more information.
18462

ADVANCED MACHINE READABLE OUTPUT

18464       Some of the tools support a --machine-readable option, which is
18465       generally used to make the output more machine friendly, for easier
18466       parsing for example.  By default, this output goes to stdout.
18467
18468       When using the --machine-readable option, the progress, information,
18469       warning, and error messages are also printed in JSON format for easier
18470       log tracking.  Thus, it is highly recommended to redirect the machine-
18471       readable output to a different stream.  The format of these JSON
18472       messages is like the following (actually printed within a single line,
18473       below it is indented for readability):
18474
18475        {
18476          "message": "Finishing off",
18477          "timestamp": "2019-03-22T14:46:49.067294446+01:00",
18478          "type": "message"
18479        }
18480
18481       "type" can be: "message" for progress messages, "info" for information
18482       messages, "warning" for warning messages, and "error" for error
18483       message.  "timestamp" is the RFC 3339 timestamp of the message.
18484
18485       In addition to that, a subset of these tools support an extra string
18486       passed to the --machine-readable option: this string specifies where
18487       the machine-readable output will go.
18488
18489       The possible values are:
18490
18491       fd:fd
18492           The output goes to the specified fd, which is a file descriptor
18493           already opened for writing.
18494
18495       file:filename
18496           The output goes to the specified filename.
18497
18498       stream:stdout
18499           The output goes to stdout.  This is basically the same as the
18500           default behaviour of --machine-readable with no parameter, although
18501           stdout as output is specified explicitly.
18502
18503       stream:stderr
18504           The output goes to stderr.
18505

ENVIRONMENT VARIABLES

18507       LIBGUESTFS_APPEND
18508           Pass additional options to the guest kernel.
18509
18510       LIBGUESTFS_ATTACH_METHOD
18511           This is the old way to set "LIBGUESTFS_BACKEND".
18512
18513       LIBGUESTFS_BACKEND
18514           Choose the default way to create the appliance.  See
18515           "guestfs_set_backend" and "BACKEND".
18516
18517       LIBGUESTFS_BACKEND_SETTINGS
18518           A colon-separated list of backend-specific settings.  See
18519           "BACKEND", "BACKEND SETTINGS".
18520
18521       LIBGUESTFS_CACHEDIR
18522           The location where libguestfs will cache its appliance, when using
18523           a supermin appliance.  The appliance is cached and shared between
18524           all handles which have the same effective user ID.
18525
18526           If "LIBGUESTFS_CACHEDIR" is not set, then "TMPDIR" is used.  If
18527           "TMPDIR" is not set, then /var/tmp is used.
18528
18529           See also "LIBGUESTFS_TMPDIR", "guestfs_set_cachedir".
18530
18531       LIBGUESTFS_DEBUG
18532           Set "LIBGUESTFS_DEBUG=1" to enable verbose messages.  This has the
18533           same effect as calling "guestfs_set_verbose (g, 1)".
18534
18535       LIBGUESTFS_HV
18536           Set the default hypervisor (usually qemu) binary that libguestfs
18537           uses.  If not set, then the qemu which was found at compile time by
18538           the configure script is used.
18539
18540           See also "QEMU WRAPPERS" above.
18541
18542       LIBGUESTFS_MEMSIZE
18543           Set the memory allocated to the qemu process, in megabytes.  For
18544           example:
18545
18546            LIBGUESTFS_MEMSIZE=700
18547
18548       LIBGUESTFS_PATH
18549           Set the path that libguestfs uses to search for a supermin
18550           appliance.  See the discussion of paths in section "PATH" above.
18551
18552       LIBGUESTFS_QEMU
18553           This is the old way to set "LIBGUESTFS_HV".
18554
18555       LIBGUESTFS_TMPDIR
18556           The location where libguestfs will store temporary files used by
18557           each handle.
18558
18559           If "LIBGUESTFS_TMPDIR" is not set, then "TMPDIR" is used.  If
18560           "TMPDIR" is not set, then /tmp is used.
18561
18562           See also "LIBGUESTFS_CACHEDIR", "guestfs_set_tmpdir".
18563
18564       LIBGUESTFS_TRACE
18565           Set "LIBGUESTFS_TRACE=1" to enable command traces.  This has the
18566           same effect as calling "guestfs_set_trace (g, 1)".
18567
18568       PATH
18569           Libguestfs may run some external programs, and relies on $PATH
18570           being set to a reasonable value.  If using the libvirt backend,
18571           libvirt will not work at all unless $PATH contains the path of
18572           qemu/KVM.  Note that PHP by default removes $PATH from the
18573           environment which tends to break everything.
18574
18575       SUPERMIN_KERNEL
18576       SUPERMIN_KERNEL_VERSION
18577       SUPERMIN_MODULES
18578           These three environment variables allow the kernel that libguestfs
18579           uses in the appliance to be selected.  If $SUPERMIN_KERNEL is not
18580           set, then the most recent host kernel is chosen.  For more
18581           information about kernel selection, see supermin(1).
18582
18583       TMPDIR
18584           See "LIBGUESTFS_CACHEDIR", "LIBGUESTFS_TMPDIR".
18585
18586       XDG_RUNTIME_DIR
18587           This directory represents a user-specific directory for storing
18588           non-essential runtime files.
18589
18590           If it is set, then is used to store temporary sockets.  Otherwise,
18591           /tmp is used.
18592
18593           See also "get-sockdir",
18594           http://www.freedesktop.org/wiki/Specifications/basedir-spec/.
18595

SEE ALSO

18597       Examples written in C: guestfs-examples(3).
18598
18599       Language bindings: guestfs-erlang(3), guestfs-gobject(3),
18600       guestfs-golang(3), guestfs-java(3), guestfs-lua(3), guestfs-ocaml(3),
18601       guestfs-perl(3), guestfs-python(3), guestfs-ruby(3).
18602
18603       Tools: guestfish(1), guestmount(1), virt-alignment-scan(1),
18604       virt-builder(1), virt-builder-repository(1), virt-cat(1),
18605       virt-copy-in(1), virt-copy-out(1), virt-customize(1), virt-df(1),
18606       virt-diff(1), virt-edit(1), virt-filesystems(1), virt-format(1),
18607       virt-inspector(1), virt-list-filesystems(1), virt-list-partitions(1),
18608       virt-log(1), virt-ls(1), virt-make-fs(1), virt-p2v(1), virt-rescue(1),
18609       virt-resize(1), virt-sparsify(1), virt-sysprep(1), virt-tail(1),
18610       virt-tar(1), virt-tar-in(1), virt-tar-out(1), virt-v2v(1),
18611       virt-win-reg(1).
18612
18613       Other libguestfs topics: guestfs-building(1), guestfs-faq(1),
18614       guestfs-hacking(1), guestfs-internals(1), guestfs-performance(1),
18615       guestfs-release-notes(1), guestfs-security(1), guestfs-testing(1),
18616       libguestfs-test-tool(1), libguestfs-make-fixed-appliance(1).
18617
18618       Related manual pages: supermin(1), qemu(1), hivex(3), stap(1),
18619       sd-journal(3).
18620
18621       Website: http://libguestfs.org/
18622
18623       Tools with a similar purpose: fdisk(8), parted(8), kpartx(8), lvm(8),
18624       disktype(1).
18625

AUTHORS

18627       Richard W.M. Jones ("rjones at redhat dot com")
18628
18630       Copyright (C) 2009-2020 Red Hat Inc.
18631

LICENSE

18633       This library is free software; you can redistribute it and/or modify it
18634       under the terms of the GNU Lesser General Public License as published
18635       by the Free Software Foundation; either version 2 of the License, or
18636       (at your option) any later version.
18637
18638       This library is distributed in the hope that it will be useful, but
18639       WITHOUT ANY WARRANTY; without even the implied warranty of
18640       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18641       Lesser General Public License for more details.
18642
18643       You should have received a copy of the GNU Lesser General Public
18644       License along with this library; if not, write to the Free Software
18645       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18646       02110-1301 USA
18647

BUGS

18649       To get a list of bugs against libguestfs, use this link:
18650       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
18651
18652       To report a new bug against libguestfs, use this link:
18653       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
18654
18655       When reporting a bug, please supply:
18656
18657       ·   The version of libguestfs.
18658
18659       ·   Where you got libguestfs (eg. which Linux distro, compiled from
18660           source, etc)
18661
18662       ·   Describe the bug accurately and give a way to reproduce it.
18663
18664       ·   Run libguestfs-test-tool(1) and paste the complete, unedited output
18665           into the bug report.
18666
18667
18668
18669libguestfs-1.42.0                 2020-03-09                        guestfs(3)
Impressum