.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Sys::Guestfs 3pm" .TH Sys::Guestfs 3pm 2024-11-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Sys::Guestfs \- Perl bindings for libguestfs .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Sys::Guestfs; \& \& my $g = Sys::Guestfs\->new (); \& $g\->add_drive_opts (\*(Aqguest.img\*(Aq, format => \*(Aqraw\*(Aq); \& $g\->launch (); \& $g\->mount (\*(Aq/dev/sda1\*(Aq, \*(Aq/\*(Aq); \& $g\->touch (\*(Aq/hello\*(Aq); \& $g\->shutdown (); \& $g\->close (); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" The \f(CW\*(C`Sys::Guestfs\*(C'\fR module provides a Perl XS binding to the libguestfs API for examining and modifying virtual machine disk images. .PP Amongst the things this is good for: making batch configuration changes to guests, getting disk used/free statistics (see also: virt-df), migrating between virtualization systems (see also: virt\-p2v), performing partial backups, performing partial guest clones, cloning guests and changing registry/UUID/hostname info, and much else besides. .PP Libguestfs uses Linux kernel and qemu code, and can access any type of guest filesystem that Linux and qemu can, including but not limited to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, qcow2, vmdk. .PP Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, what filesystem is in each LV, etc.). It can also run commands in the context of the guest. Also you can access filesystems over FUSE. .SH ERRORS .IX Header "ERRORS" All errors turn into calls to \f(CW\*(C`croak\*(C'\fR (see \fBCarp\fR\|(3)). .PP The error string from libguestfs is directly available from \&\f(CW$@\fR. Use the \f(CW\*(C`last_errno\*(C'\fR method if you want to get the errno. .SH METHODS .IX Header "METHODS" .ie n .IP "$g = Sys::Guestfs\->new ([environment => 0,] [close_on_exit => 0]);" 4 .el .IP "\f(CW$g\fR = Sys::Guestfs\->new ([environment => 0,] [close_on_exit => 0]);" 4 .IX Item "$g = Sys::Guestfs->new ([environment => 0,] [close_on_exit => 0]);" Create a new guestfs handle. .Sp If the optional argument \f(CW\*(C`environment\*(C'\fR is false, then the \f(CW\*(C`GUESTFS_CREATE_NO_ENVIRONMENT\*(C'\fR flag is set. .Sp If the optional argument \f(CW\*(C`close_on_exit\*(C'\fR is false, then the \f(CW\*(C`GUESTFS_CREATE_NO_CLOSE_ON_EXIT\*(C'\fR flag is set. .ie n .IP "$g\->close ();" 4 .el .IP "\f(CW$g\fR\->close ();" 4 .IX Item "$g->close ();" Explicitly close the guestfs handle. .Sp \&\fBNote:\fR You should not usually call this function. The handle will be closed implicitly when its reference count goes to zero (eg. when it goes out of scope or the program ends). This call is only required in some exceptional cases, such as where the program may contain cached references to the handle 'somewhere' and you really have to have the close happen right away. After calling \&\f(CW\*(C`close\*(C'\fR the program must not call any method (including \f(CW\*(C`close\*(C'\fR) on the handle (but the implicit call to \f(CW\*(C`DESTROY\*(C'\fR that happens when the final reference is cleaned up is OK). .ie n .IP $Sys::Guestfs::EVENT_CLOSE 4 .el .IP \f(CW$Sys::Guestfs::EVENT_CLOSE\fR 4 .IX Item "$Sys::Guestfs::EVENT_CLOSE" See "GUESTFS_EVENT_CLOSE" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_SUBPROCESS_QUIT 4 .el .IP \f(CW$Sys::Guestfs::EVENT_SUBPROCESS_QUIT\fR 4 .IX Item "$Sys::Guestfs::EVENT_SUBPROCESS_QUIT" See "GUESTFS_EVENT_SUBPROCESS_QUIT" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_LAUNCH_DONE 4 .el .IP \f(CW$Sys::Guestfs::EVENT_LAUNCH_DONE\fR 4 .IX Item "$Sys::Guestfs::EVENT_LAUNCH_DONE" See "GUESTFS_EVENT_LAUNCH_DONE" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_PROGRESS 4 .el .IP \f(CW$Sys::Guestfs::EVENT_PROGRESS\fR 4 .IX Item "$Sys::Guestfs::EVENT_PROGRESS" See "GUESTFS_EVENT_PROGRESS" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_APPLIANCE 4 .el .IP \f(CW$Sys::Guestfs::EVENT_APPLIANCE\fR 4 .IX Item "$Sys::Guestfs::EVENT_APPLIANCE" See "GUESTFS_EVENT_APPLIANCE" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_LIBRARY 4 .el .IP \f(CW$Sys::Guestfs::EVENT_LIBRARY\fR 4 .IX Item "$Sys::Guestfs::EVENT_LIBRARY" See "GUESTFS_EVENT_LIBRARY" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_TRACE 4 .el .IP \f(CW$Sys::Guestfs::EVENT_TRACE\fR 4 .IX Item "$Sys::Guestfs::EVENT_TRACE" See "GUESTFS_EVENT_TRACE" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_ENTER 4 .el .IP \f(CW$Sys::Guestfs::EVENT_ENTER\fR 4 .IX Item "$Sys::Guestfs::EVENT_ENTER" See "GUESTFS_EVENT_ENTER" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_LIBVIRT_AUTH 4 .el .IP \f(CW$Sys::Guestfs::EVENT_LIBVIRT_AUTH\fR 4 .IX Item "$Sys::Guestfs::EVENT_LIBVIRT_AUTH" See "GUESTFS_EVENT_LIBVIRT_AUTH" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_WARNING 4 .el .IP \f(CW$Sys::Guestfs::EVENT_WARNING\fR 4 .IX Item "$Sys::Guestfs::EVENT_WARNING" See "GUESTFS_EVENT_WARNING" in \fBguestfs\fR\|(3). .ie n .IP $Sys::Guestfs::EVENT_ALL 4 .el .IP \f(CW$Sys::Guestfs::EVENT_ALL\fR 4 .IX Item "$Sys::Guestfs::EVENT_ALL" See "GUESTFS_EVENT_ALL" in \fBguestfs\fR\|(3). .ie n .IP "$event_handle = $g\->set_event_callback (\e&cb, $event_bitmask);" 4 .el .IP "\f(CW$event_handle\fR = \f(CW$g\fR\->set_event_callback (\e&cb, \f(CW$event_bitmask\fR);" 4 .IX Item "$event_handle = $g->set_event_callback (&cb, $event_bitmask);" Register \f(CW\*(C`cb\*(C'\fR as a callback function for all of the events in \f(CW$event_bitmask\fR (one or more \f(CW\*(C`$Sys::Guestfs::EVENT_*\*(C'\fR flags logically or'd together). .Sp This function returns an event handle which can be used to delete the callback using \f(CW\*(C`delete_event_callback\*(C'\fR. .Sp The callback function receives 4 parameters: .Sp .Vb 1 \& &cb ($event, $event_handle, $buf, $array) .Ve .RS 4 .ie n .IP $event 4 .el .IP \f(CW$event\fR 4 .IX Item "$event" The event which happened (equal to one of \f(CW\*(C`$Sys::Guestfs::EVENT_*\*(C'\fR). .ie n .IP $event_handle 4 .el .IP \f(CW$event_handle\fR 4 .IX Item "$event_handle" The event handle. .ie n .IP $buf 4 .el .IP \f(CW$buf\fR 4 .IX Item "$buf" For some event types, this is a message buffer (ie. a string). .ie n .IP $array 4 .el .IP \f(CW$array\fR 4 .IX Item "$array" For some event types (notably progress events), this is an array of integers. .RE .RS 4 .Sp You should carefully read the documentation for "guestfs_set_event_callback" in \fBguestfs\fR\|(3) before using this function. .RE .ie n .IP "$g\->delete_event_callback ($event_handle);" 4 .el .IP "\f(CW$g\fR\->delete_event_callback ($event_handle);" 4 .IX Item "$g->delete_event_callback ($event_handle);" This removes the callback which was previously registered using \&\f(CW\*(C`set_event_callback\*(C'\fR. .ie n .IP "$str = Sys::Guestfs::event_to_string ($events);" 4 .el .IP "\f(CW$str\fR = Sys::Guestfs::event_to_string ($events);" 4 .IX Item "$str = Sys::Guestfs::event_to_string ($events);" \&\f(CW$events\fR is either a single event or a bitmask of events. This returns a printable string, useful for debugging. .Sp Note that this is a class function, not a method. .ie n .IP "$errnum = $g\->last_errno ();" 4 .el .IP "\f(CW$errnum\fR = \f(CW$g\fR\->last_errno ();" 4 .IX Item "$errnum = $g->last_errno ();" This returns the last error number (errno) that happened on the handle \f(CW$g\fR. .Sp If successful, an errno integer not equal to zero is returned. .Sp If no error number is available, this returns 0. See "guestfs_last_errno" in \fBguestfs\fR\|(3) for more details of why this can happen. .Sp You can use the standard Perl module \fBErrno\fR\|(3) to compare the numeric error returned from this call with symbolic errnos: .Sp .Vb 4 \& $g\->mkdir ("/foo"); \& if ($g\->last_errno() == Errno::EEXIST()) { \& # mkdir failed because the directory exists already. \& } .Ve .ie n .IP "$g\->acl_delete_def_file ($dir);" 4 .el .IP "\f(CW$g\fR\->acl_delete_def_file ($dir);" 4 .IX Item "$g->acl_delete_def_file ($dir);" This function deletes the default POSIX Access Control List (ACL) attached to directory \f(CW\*(C`dir\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`acl\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$acl = $g\->acl_get_file ($path, $acltype);" 4 .el .IP "\f(CW$acl\fR = \f(CW$g\fR\->acl_get_file ($path, \f(CW$acltype\fR);" 4 .IX Item "$acl = $g->acl_get_file ($path, $acltype);" This function returns the POSIX Access Control List (ACL) attached to \f(CW\*(C`path\*(C'\fR. The ACL is returned in "long text form" (see \fBacl\fR\|(5)). .Sp The \f(CW\*(C`acltype\*(C'\fR parameter may be: .RS 4 .ie n .IP """access""" 4 .el .IP \f(CWaccess\fR 4 .IX Item "access" Return the ordinary (access) ACL for any file, directory or other filesystem object. .ie n .IP """default""" 4 .el .IP \f(CWdefault\fR 4 .IX Item "default" Return the default ACL. Normally this only makes sense if \&\f(CW\*(C`path\*(C'\fR is a directory. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`acl\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->acl_set_file ($path, $acltype, $acl);" 4 .el .IP "\f(CW$g\fR\->acl_set_file ($path, \f(CW$acltype\fR, \f(CW$acl\fR);" 4 .IX Item "$g->acl_set_file ($path, $acltype, $acl);" This function sets the POSIX Access Control List (ACL) attached to \f(CW\*(C`path\*(C'\fR. .Sp The \f(CW\*(C`acltype\*(C'\fR parameter may be: .RS 4 .ie n .IP """access""" 4 .el .IP \f(CWaccess\fR 4 .IX Item "access" Set the ordinary (access) ACL for any file, directory or other filesystem object. .ie n .IP """default""" 4 .el .IP \f(CWdefault\fR 4 .IX Item "default" Set the default ACL. Normally this only makes sense if \&\f(CW\*(C`path\*(C'\fR is a directory. .RE .RS 4 .Sp The \f(CW\*(C`acl\*(C'\fR parameter is the new ACL in either "long text form" or "short text form" (see \fBacl\fR\|(5)). The new ACL completely replaces any previous ACL on the file. The ACL must contain the full Unix permissions (eg. \f(CW\*(C`u::rwx,g::rx,o::rx\*(C'\fR). .Sp If you are specifying individual users or groups, then the mask field is also required (eg. \f(CW\*(C`m::rwx\*(C'\fR), followed by the \&\f(CW\*(C`u:\fR\f(CIID\fR\f(CW:...\*(C'\fR and/or \f(CW\*(C`g:\fR\f(CIID\fR\f(CW:...\*(C'\fR field(s). A full ACL string might therefore look like this: .Sp .Vb 2 \& u::rwx,g::rwx,o::rwx,m::rwx,u:500:rwx,g:500:rwx \& \e Unix permissions / \emask/ \e ACL / .Ve .Sp You should use numeric UIDs and GIDs. To map usernames and groupnames to the correct numeric ID in the context of the guest, use the Augeas functions (see \f(CW\*(C`$g\->aug_init\*(C'\fR). .Sp This function depends on the feature \f(CW\*(C`acl\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->add_cdrom ($filename);" 4 .el .IP "\f(CW$g\fR\->add_cdrom ($filename);" 4 .IX Item "$g->add_cdrom ($filename);" This function adds a virtual CD-ROM disk image to the guest. .Sp The image is added as read-only drive, so this function is equivalent of \f(CW\*(C`$g\->add_drive_ro\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "add_drive_ro" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$nrdisks = $g\->add_domain ($dom [, libvirturi => $libvirturi] [, readonly => $readonly] [, iface => $iface] [, live => $live] [, allowuuid => $allowuuid] [, readonlydisk => $readonlydisk] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread]);" 4 .el .IP "\f(CW$nrdisks\fR = \f(CW$g\fR\->add_domain ($dom [, libvirturi => \f(CW$libvirturi\fR] [, readonly => \f(CW$readonly\fR] [, iface => \f(CW$iface\fR] [, live => \f(CW$live\fR] [, allowuuid => \f(CW$allowuuid\fR] [, readonlydisk => \f(CW$readonlydisk\fR] [, cachemode => \f(CW$cachemode\fR] [, discard => \f(CW$discard\fR] [, copyonread => \f(CW$copyonread\fR]);" 4 .IX Item "$nrdisks = $g->add_domain ($dom [, libvirturi => $libvirturi] [, readonly => $readonly] [, iface => $iface] [, live => $live] [, allowuuid => $allowuuid] [, readonlydisk => $readonlydisk] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread]);" This function adds the disk(s) attached to the named libvirt domain \f(CW\*(C`dom\*(C'\fR. It works by connecting to libvirt, requesting the domain and domain XML from libvirt, parsing it for disks, and calling \f(CW\*(C`$g\->add_drive_opts\*(C'\fR on each one. .Sp The number of disks added is returned. This operation is atomic: if an error is returned, then no disks are added. .Sp This function does some minimal checks to make sure the libvirt domain is not running (unless \f(CW\*(C`readonly\*(C'\fR is true). In a future version we will try to acquire the libvirt lock on each disk. .Sp Disks must be accessible locally. This often means that adding disks from a remote libvirt connection (see ) will fail unless those disks are accessible via the same device path locally too. .Sp The optional \f(CW\*(C`libvirturi\*(C'\fR parameter sets the libvirt URI (see ). If this is not set then we connect to the default libvirt URI (or one set through an environment variable, see the libvirt documentation for full details). .Sp The optional \f(CW\*(C`live\*(C'\fR flag is ignored in libguestfs ≥ 1.48. .Sp If the \f(CW\*(C`allowuuid\*(C'\fR flag is true (default is false) then a UUID \&\fImay\fR be passed instead of the domain name. The \f(CW\*(C`dom\*(C'\fR string is treated as a UUID first and looked up, and if that lookup fails then we treat \f(CW\*(C`dom\*(C'\fR as a name as usual. .Sp The optional \f(CW\*(C`readonlydisk\*(C'\fR parameter controls what we do for disks which are marked in the libvirt XML. Possible values are: .RS 4 .IP "readonlydisk = ""error""" 4 .IX Item "readonlydisk = ""error""" If \f(CW\*(C`readonly\*(C'\fR is false: .Sp The whole call is aborted with an error if any disk with the flag is found. .Sp If \f(CW\*(C`readonly\*(C'\fR is true: .Sp Disks with the flag are added read-only. .IP "readonlydisk = ""read""" 4 .IX Item "readonlydisk = ""read""" If \f(CW\*(C`readonly\*(C'\fR is false: .Sp Disks with the flag are added read-only. Other disks are added read/write. .Sp If \f(CW\*(C`readonly\*(C'\fR is true: .Sp Disks with the flag are added read-only. .IP "readonlydisk = ""write"" (default)" 4 .IX Item "readonlydisk = ""write"" (default)" If \f(CW\*(C`readonly\*(C'\fR is false: .Sp Disks with the flag are added read/write. .Sp If \f(CW\*(C`readonly\*(C'\fR is true: .Sp Disks with the flag are added read-only. .IP "readonlydisk = ""ignore""" 4 .IX Item "readonlydisk = ""ignore""" If \f(CW\*(C`readonly\*(C'\fR is true or false: .Sp Disks with the flag are skipped. .RE .RS 4 .Sp If present, the value of \f(CW\*(C`logical_block_size\*(C'\fR attribute of tag in libvirt XML will be passed as \f(CW\*(C`blocksize\*(C'\fR parameter to \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR. .Sp The other optional parameters are passed directly through to \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR. .RE .ie n .IP "$g\->add_drive ($filename [, readonly => $readonly] [, format => $format] [, iface => $iface] [, name => $name] [, label => $label] [, protocol => $protocol] [, server => $server] [, username => $username] [, secret => $secret] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread] [, blocksize => $blocksize]);" 4 .el .IP "\f(CW$g\fR\->add_drive ($filename [, readonly => \f(CW$readonly\fR] [, format => \f(CW$format\fR] [, iface => \f(CW$iface\fR] [, name => \f(CW$name\fR] [, label => \f(CW$label\fR] [, protocol => \f(CW$protocol\fR] [, server => \f(CW$server\fR] [, username => \f(CW$username\fR] [, secret => \f(CW$secret\fR] [, cachemode => \f(CW$cachemode\fR] [, discard => \f(CW$discard\fR] [, copyonread => \f(CW$copyonread\fR] [, blocksize => \f(CW$blocksize\fR]);" 4 .IX Item "$g->add_drive ($filename [, readonly => $readonly] [, format => $format] [, iface => $iface] [, name => $name] [, label => $label] [, protocol => $protocol] [, server => $server] [, username => $username] [, secret => $secret] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread] [, blocksize => $blocksize]);" This function adds a disk image called \fIfilename\fR to the handle. \&\fIfilename\fR may be a regular host file or a host device. .Sp When this function is called before \f(CW\*(C`$g\->launch\*(C'\fR (the usual case) then the first time you call this function, the disk appears in the API as \fI/dev/sda\fR, the second time as \fI/dev/sdb\fR, and so on. .Sp You don't necessarily need to be root when using libguestfs. However you obviously do need sufficient permissions to access the filename for whatever operations you want to perform (ie. read access if you just want to read the image or write access if you want to modify the image). .Sp This call checks that \fIfilename\fR exists. .Sp \&\fIfilename\fR may be the special string \f(CW"/dev/null"\fR. See "NULL DISKS" in \fBguestfs\fR\|(3). .Sp The optional arguments are: .RS 4 .ie n .IP """readonly""" 4 .el .IP \f(CWreadonly\fR 4 .IX Item "readonly" If true then the image is treated as read-only. Writes are still allowed, but they are stored in a temporary snapshot overlay which is discarded at the end. The disk that you add is not modified. .ie n .IP """format""" 4 .el .IP \f(CWformat\fR 4 .IX Item "format" This forces the image format. If you omit this (or use \f(CW\*(C`$g\->add_drive\*(C'\fR or \f(CW\*(C`$g\->add_drive_ro\*(C'\fR) then the format is automatically detected. Possible formats include \f(CW\*(C`raw\*(C'\fR and \f(CW\*(C`qcow2\*(C'\fR. .Sp Automatic detection of the format opens you up to a potential security hole when dealing with untrusted raw-format images. See CVE\-2010\-3851 and RHBZ#642934. Specifying the format closes this security hole. .ie n .IP """iface""" 4 .el .IP \f(CWiface\fR 4 .IX Item "iface" This rarely-used option lets you emulate the behaviour of the deprecated \f(CW\*(C`$g\->add_drive_with_if\*(C'\fR call (q.v.) .ie n .IP """name""" 4 .el .IP \f(CWname\fR 4 .IX Item "name" This field used to be passed as a hint for guest inspection, but it is no longer used. .ie n .IP """label""" 4 .el .IP \f(CWlabel\fR 4 .IX Item "label" Give the disk a label. The label should be a unique, short string using \fIonly\fR ASCII characters \f(CW\*(C`[a\-zA\-Z]\*(C'\fR. As well as its usual name in the API (such as \fI/dev/sda\fR), the drive will also be named \fI/dev/disk/guestfs/label\fR. .Sp See "DISK LABELS" in \fBguestfs\fR\|(3). .ie n .IP """protocol""" 4 .el .IP \f(CWprotocol\fR 4 .IX Item "protocol" The optional protocol argument can be used to select an alternate source protocol. .Sp See also: "REMOTE STORAGE" in \fBguestfs\fR\|(3). .RS 4 .ie n .IP """protocol = ""file""""" 4 .el .IP "\f(CWprotocol = ""file""\fR" 4 .IX Item "protocol = ""file""" \&\fIfilename\fR is interpreted as a local file or device. This is the default if the optional protocol parameter is omitted. .ie n .IP """protocol = ""ftp""|""ftps""|""http""|""https""""" 4 .el .IP "\f(CWprotocol = ""ftp""|""ftps""|""http""|""https""\fR" 4 .IX Item "protocol = ""ftp""|""ftps""|""http""|""https""" Connect to a remote FTP or HTTP server. The \f(CW\*(C`server\*(C'\fR parameter must also be supplied \- see below. .Sp See also: "FTP AND HTTP" in \fBguestfs\fR\|(3) .ie n .IP """protocol = ""iscsi""""" 4 .el .IP "\f(CWprotocol = ""iscsi""\fR" 4 .IX Item "protocol = ""iscsi""" Connect to the iSCSI server. The \f(CW\*(C`server\*(C'\fR parameter must also be supplied \- see below. The \f(CW\*(C`username\*(C'\fR parameter may be supplied. See below. The \f(CW\*(C`secret\*(C'\fR parameter may be supplied. See below. .Sp See also: "ISCSI" in \fBguestfs\fR\|(3). .ie n .IP """protocol = ""nbd""""" 4 .el .IP "\f(CWprotocol = ""nbd""\fR" 4 .IX Item "protocol = ""nbd""" Connect to the Network Block Device server. The \f(CW\*(C`server\*(C'\fR parameter must also be supplied \- see below. .Sp See also: "NETWORK BLOCK DEVICE" in \fBguestfs\fR\|(3). .ie n .IP """protocol = ""rbd""""" 4 .el .IP "\f(CWprotocol = ""rbd""\fR" 4 .IX Item "protocol = ""rbd""" Connect to the Ceph (librbd/RBD) server. The \f(CW\*(C`server\*(C'\fR parameter must also be supplied \- see below. The \f(CW\*(C`username\*(C'\fR parameter may be supplied. See below. The \f(CW\*(C`secret\*(C'\fR parameter may be supplied. See below. .Sp See also: "CEPH" in \fBguestfs\fR\|(3). .ie n .IP """protocol = ""ssh""""" 4 .el .IP "\f(CWprotocol = ""ssh""\fR" 4 .IX Item "protocol = ""ssh""" Connect to the Secure Shell (ssh) server. .Sp The \f(CW\*(C`server\*(C'\fR parameter must be supplied. The \f(CW\*(C`username\*(C'\fR parameter may be supplied. See below. .Sp See also: "SSH" in \fBguestfs\fR\|(3). .RE .RS 4 .RE .ie n .IP """server""" 4 .el .IP \f(CWserver\fR 4 .IX Item "server" For protocols which require access to a remote server, this is a list of server(s). .Sp .Vb 8 \& Protocol Number of servers required \& \-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& file List must be empty or param not used at all \& ftp|ftps|http|https Exactly one \& iscsi Exactly one \& nbd Exactly one \& rbd Zero or more \& ssh Exactly one .Ve .Sp Each list element is a string specifying a server. The string must be in one of the following formats: .Sp .Vb 5 \& hostname \& hostname:port \& tcp:hostname \& tcp:hostname:port \& unix:/path/to/socket .Ve .Sp If the port number is omitted, then the standard port number for the protocol is used (see \fI/etc/services\fR). .ie n .IP """username""" 4 .el .IP \f(CWusername\fR 4 .IX Item "username" For the \f(CW\*(C`ftp\*(C'\fR, \f(CW\*(C`ftps\*(C'\fR, \f(CW\*(C`http\*(C'\fR, \f(CW\*(C`https\*(C'\fR, \f(CW\*(C`iscsi\*(C'\fR, \f(CW\*(C`rbd\*(C'\fR and \f(CW\*(C`ssh\*(C'\fR protocols, this specifies the remote username. .Sp If not given, then the local username is used for \f(CW\*(C`ssh\*(C'\fR, and no authentication is attempted for ceph. But note this sometimes may give unexpected results, for example if using the libvirt backend and if the libvirt backend is configured to start the qemu appliance as a special user such as \f(CW\*(C`qemu.qemu\*(C'\fR. If in doubt, specify the remote username you want. .ie n .IP """secret""" 4 .el .IP \f(CWsecret\fR 4 .IX Item "secret" For the \f(CW\*(C`rbd\*(C'\fR protocol only, this specifies the ‘secret’ to use when connecting to the remote device. It must be base64 encoded. .Sp If not given, then a secret matching the given username will be looked up in the default keychain locations, or if no username is given, then no authentication will be used. .ie n .IP """cachemode""" 4 .el .IP \f(CWcachemode\fR 4 .IX Item "cachemode" Choose whether or not libguestfs will obey sync operations (safe but slow) or not (unsafe but fast). The possible values for this string are: .RS 4 .ie n .IP """cachemode = ""writeback""""" 4 .el .IP "\f(CWcachemode = ""writeback""\fR" 4 .IX Item "cachemode = ""writeback""" This is the default. .Sp Write operations in the API do not return until a \fBwrite\fR\|(2) call has completed in the host [but note this does not imply that anything gets written to disk]. .Sp Sync operations in the API, including implicit syncs caused by filesystem journalling, will not return until an \fBfdatasync\fR\|(2) call has completed in the host, indicating that data has been committed to disk. .ie n .IP """cachemode = ""unsafe""""" 4 .el .IP "\f(CWcachemode = ""unsafe""\fR" 4 .IX Item "cachemode = ""unsafe""" In this mode, there are no guarantees. Libguestfs may cache anything and ignore sync requests. This is suitable only for scratch or temporary disks. .RE .RS 4 .RE .ie n .IP """discard""" 4 .el .IP \f(CWdiscard\fR 4 .IX Item "discard" Enable or disable discard (a.k.a. trim or unmap) support on this drive. If enabled, operations such as \f(CW\*(C`$g\->fstrim\*(C'\fR will be able to discard / make thin / punch holes in the underlying host file or device. .Sp Possible discard settings are: .RS 4 .ie n .IP """discard = ""disable""""" 4 .el .IP "\f(CWdiscard = ""disable""\fR" 4 .IX Item "discard = ""disable""" Disable discard support. This is the default. .ie n .IP """discard = ""enable""""" 4 .el .IP "\f(CWdiscard = ""enable""\fR" 4 .IX Item "discard = ""enable""" Enable discard support. Fail if discard is not possible. .ie n .IP """discard = ""besteffort""""" 4 .el .IP "\f(CWdiscard = ""besteffort""\fR" 4 .IX Item "discard = ""besteffort""" Enable discard support if possible, but don't fail if it is not supported. .Sp Since not all backends and not all underlying systems support discard, this is a good choice if you want to use discard if possible, but don't mind if it doesn't work. .RE .RS 4 .RE .ie n .IP """copyonread""" 4 .el .IP \f(CWcopyonread\fR 4 .IX Item "copyonread" The boolean parameter \f(CW\*(C`copyonread\*(C'\fR enables copy-on-read support. This only affects disk formats which have backing files, and causes reads to be stored in the overlay layer, speeding up multiple reads of the same area of disk. .Sp The default is false. .ie n .IP """blocksize""" 4 .el .IP \f(CWblocksize\fR 4 .IX Item "blocksize" This parameter sets the sector size of the disk. Possible values are \&\f(CW512\fR (the default if the parameter is omitted) or \f(CW4096\fR. Use \&\f(CW4096\fR when handling an "Advanced Format" disk that uses 4K sector size (). .Sp Only a subset of the backends support this parameter (currently only the libvirt and direct backends do). .RE .RS 4 .RE .ie n .IP "$g\->add_drive_opts ($filename [, readonly => $readonly] [, format => $format] [, iface => $iface] [, name => $name] [, label => $label] [, protocol => $protocol] [, server => $server] [, username => $username] [, secret => $secret] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread] [, blocksize => $blocksize]);" 4 .el .IP "\f(CW$g\fR\->add_drive_opts ($filename [, readonly => \f(CW$readonly\fR] [, format => \f(CW$format\fR] [, iface => \f(CW$iface\fR] [, name => \f(CW$name\fR] [, label => \f(CW$label\fR] [, protocol => \f(CW$protocol\fR] [, server => \f(CW$server\fR] [, username => \f(CW$username\fR] [, secret => \f(CW$secret\fR] [, cachemode => \f(CW$cachemode\fR] [, discard => \f(CW$discard\fR] [, copyonread => \f(CW$copyonread\fR] [, blocksize => \f(CW$blocksize\fR]);" 4 .IX Item "$g->add_drive_opts ($filename [, readonly => $readonly] [, format => $format] [, iface => $iface] [, name => $name] [, label => $label] [, protocol => $protocol] [, server => $server] [, username => $username] [, secret => $secret] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread] [, blocksize => $blocksize]);" This is an alias of "add_drive". .ie n .IP "$g\->add_drive_ro ($filename);" 4 .el .IP "\f(CW$g\fR\->add_drive_ro ($filename);" 4 .IX Item "$g->add_drive_ro ($filename);" This function is the equivalent of calling \f(CW\*(C`$g\->add_drive_opts\*(C'\fR with the optional parameter \f(CW\*(C`GUESTFS_ADD_DRIVE_OPTS_READONLY\*(C'\fR set to 1, so the disk is added read-only, with the format being detected automatically. .ie n .IP "$g\->add_drive_ro_with_if ($filename, $iface);" 4 .el .IP "\f(CW$g\fR\->add_drive_ro_with_if ($filename, \f(CW$iface\fR);" 4 .IX Item "$g->add_drive_ro_with_if ($filename, $iface);" This is the same as \f(CW\*(C`$g\->add_drive_ro\*(C'\fR but it allows you to specify the QEMU interface emulation to use at run time. Both the direct and the libvirt backends ignore \f(CW\*(C`iface\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "add_drive" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->add_drive_scratch ($size [, name => $name] [, label => $label] [, blocksize => $blocksize]);" 4 .el .IP "\f(CW$g\fR\->add_drive_scratch ($size [, name => \f(CW$name\fR] [, label => \f(CW$label\fR] [, blocksize => \f(CW$blocksize\fR]);" 4 .IX Item "$g->add_drive_scratch ($size [, name => $name] [, label => $label] [, blocksize => $blocksize]);" This command adds a temporary scratch drive to the handle. The \&\f(CW\*(C`size\*(C'\fR parameter is the virtual size (in bytes). The scratch drive is blank initially (all reads return zeroes until you start writing to it). The drive is deleted when the handle is closed. .Sp The optional arguments \f(CW\*(C`name\*(C'\fR, \f(CW\*(C`label\*(C'\fR and \f(CW\*(C`blocksize\*(C'\fR are passed through to \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR. .ie n .IP "$g\->add_drive_with_if ($filename, $iface);" 4 .el .IP "\f(CW$g\fR\->add_drive_with_if ($filename, \f(CW$iface\fR);" 4 .IX Item "$g->add_drive_with_if ($filename, $iface);" This is the same as \f(CW\*(C`$g\->add_drive\*(C'\fR but it allows you to specify the QEMU interface emulation to use at run time. Both the direct and the libvirt backends ignore \f(CW\*(C`iface\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "add_drive" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$nrdisks = $g\->add_libvirt_dom ($dom [, readonly => $readonly] [, iface => $iface] [, live => $live] [, readonlydisk => $readonlydisk] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread]);" 4 .el .IP "\f(CW$nrdisks\fR = \f(CW$g\fR\->add_libvirt_dom ($dom [, readonly => \f(CW$readonly\fR] [, iface => \f(CW$iface\fR] [, live => \f(CW$live\fR] [, readonlydisk => \f(CW$readonlydisk\fR] [, cachemode => \f(CW$cachemode\fR] [, discard => \f(CW$discard\fR] [, copyonread => \f(CW$copyonread\fR]);" 4 .IX Item "$nrdisks = $g->add_libvirt_dom ($dom [, readonly => $readonly] [, iface => $iface] [, live => $live] [, readonlydisk => $readonlydisk] [, cachemode => $cachemode] [, discard => $discard] [, copyonread => $copyonread]);" This function adds the disk(s) attached to the libvirt domain \f(CW\*(C`dom\*(C'\fR. It works by requesting the domain XML from libvirt, parsing it for disks, and calling \f(CW\*(C`$g\->add_drive_opts\*(C'\fR on each one. .Sp In the C API we declare \f(CW\*(C`void *dom\*(C'\fR, but really it has type \&\f(CW\*(C`virDomainPtr dom\*(C'\fR. This is so we don't need . .Sp The number of disks added is returned. This operation is atomic: if an error is returned, then no disks are added. .Sp This function does some minimal checks to make sure the libvirt domain is not running (unless \f(CW\*(C`readonly\*(C'\fR is true). In a future version we will try to acquire the libvirt lock on each disk. .Sp Disks must be accessible locally. This often means that adding disks from a remote libvirt connection (see ) will fail unless those disks are accessible via the same device path locally too. .Sp The optional \f(CW\*(C`live\*(C'\fR flag is ignored in libguestfs ≥ 1.48. .Sp The optional \f(CW\*(C`readonlydisk\*(C'\fR parameter controls what we do for disks which are marked in the libvirt XML. See \f(CW\*(C`$g\->add_domain\*(C'\fR for possible values. .Sp If present, the value of \f(CW\*(C`logical_block_size\*(C'\fR attribute of tag in libvirt XML will be passed as \f(CW\*(C`blocksize\*(C'\fR parameter to \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR. .Sp The other optional parameters are passed directly through to \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR. .ie n .IP "$g\->aug_clear ($augpath);" 4 .el .IP "\f(CW$g\fR\->aug_clear ($augpath);" 4 .IX Item "$g->aug_clear ($augpath);" Set the value associated with \f(CW\*(C`path\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR. This is the same as the \fBaugtool\fR\|(1) \f(CW\*(C`clear\*(C'\fR command. .ie n .IP "$g\->aug_close ();" 4 .el .IP "\f(CW$g\fR\->aug_close ();" 4 .IX Item "$g->aug_close ();" Close the current Augeas handle and free up any resources used by it. After calling this, you have to call \&\f(CW\*(C`$g\->aug_init\*(C'\fR again before you can use any other Augeas functions. .ie n .IP "%nrnodescreated = $g\->aug_defnode ($name, $expr, $val);" 4 .el .IP "\f(CW%nrnodescreated\fR = \f(CW$g\fR\->aug_defnode ($name, \f(CW$expr\fR, \f(CW$val\fR);" 4 .IX Item "%nrnodescreated = $g->aug_defnode ($name, $expr, $val);" Defines a variable \f(CW\*(C`name\*(C'\fR whose value is the result of evaluating \f(CW\*(C`expr\*(C'\fR. .Sp If \f(CW\*(C`expr\*(C'\fR evaluates to an empty nodeset, a node is created, equivalent to calling \f(CW\*(C`$g\->aug_set\*(C'\fR \f(CW\*(C`expr\*(C'\fR, \f(CW\*(C`val\*(C'\fR. \&\f(CW\*(C`name\*(C'\fR will be the nodeset containing that single node. .Sp On success this returns a pair containing the number of nodes in the nodeset, and a boolean flag if a node was created. .ie n .IP "$nrnodes = $g\->aug_defvar ($name, $expr);" 4 .el .IP "\f(CW$nrnodes\fR = \f(CW$g\fR\->aug_defvar ($name, \f(CW$expr\fR);" 4 .IX Item "$nrnodes = $g->aug_defvar ($name, $expr);" Defines an Augeas variable \f(CW\*(C`name\*(C'\fR whose value is the result of evaluating \f(CW\*(C`expr\*(C'\fR. If \f(CW\*(C`expr\*(C'\fR is NULL, then \f(CW\*(C`name\*(C'\fR is undefined. .Sp On success this returns the number of nodes in \f(CW\*(C`expr\*(C'\fR, or \&\f(CW0\fR if \f(CW\*(C`expr\*(C'\fR evaluates to something which is not a nodeset. .ie n .IP "$val = $g\->aug_get ($augpath);" 4 .el .IP "\f(CW$val\fR = \f(CW$g\fR\->aug_get ($augpath);" 4 .IX Item "$val = $g->aug_get ($augpath);" Look up the value associated with \f(CW\*(C`path\*(C'\fR. If \f(CW\*(C`path\*(C'\fR matches exactly one node, the \f(CW\*(C`value\*(C'\fR is returned. .ie n .IP "$g\->aug_init ($root, $flags);" 4 .el .IP "\f(CW$g\fR\->aug_init ($root, \f(CW$flags\fR);" 4 .IX Item "$g->aug_init ($root, $flags);" Create a new Augeas handle for editing configuration files. If there was any previous Augeas handle associated with this guestfs session, then it is closed. .Sp You must call this before using any other \f(CW\*(C`$g\->aug_*\*(C'\fR commands. .Sp \&\f(CW\*(C`root\*(C'\fR is the filesystem root. \f(CW\*(C`root\*(C'\fR must not be NULL, use \fI/\fR instead. .Sp The flags are the same as the flags defined in , the logical \fIor\fR of the following integers: .RS 4 .ie n .IP """AUG_SAVE_BACKUP"" = 1" 4 .el .IP "\f(CWAUG_SAVE_BACKUP\fR = 1" 4 .IX Item "AUG_SAVE_BACKUP = 1" Keep the original file with a \f(CW\*(C`.augsave\*(C'\fR extension. .ie n .IP """AUG_SAVE_NEWFILE"" = 2" 4 .el .IP "\f(CWAUG_SAVE_NEWFILE\fR = 2" 4 .IX Item "AUG_SAVE_NEWFILE = 2" Save changes into a file with extension \f(CW\*(C`.augnew\*(C'\fR, and do not overwrite original. Overrides \f(CW\*(C`AUG_SAVE_BACKUP\*(C'\fR. .ie n .IP """AUG_TYPE_CHECK"" = 4" 4 .el .IP "\f(CWAUG_TYPE_CHECK\fR = 4" 4 .IX Item "AUG_TYPE_CHECK = 4" Typecheck lenses. .Sp This option is only useful when debugging Augeas lenses. Use of this option may require additional memory for the libguestfs appliance. You may need to set the \f(CW\*(C`LIBGUESTFS_MEMSIZE\*(C'\fR environment variable or call \f(CW\*(C`$g\->set_memsize\*(C'\fR. .ie n .IP """AUG_NO_STDINC"" = 8" 4 .el .IP "\f(CWAUG_NO_STDINC\fR = 8" 4 .IX Item "AUG_NO_STDINC = 8" Do not use standard load path for modules. .ie n .IP """AUG_SAVE_NOOP"" = 16" 4 .el .IP "\f(CWAUG_SAVE_NOOP\fR = 16" 4 .IX Item "AUG_SAVE_NOOP = 16" Make save a no-op, just record what would have been changed. .ie n .IP """AUG_NO_LOAD"" = 32" 4 .el .IP "\f(CWAUG_NO_LOAD\fR = 32" 4 .IX Item "AUG_NO_LOAD = 32" Do not load the tree in \f(CW\*(C`$g\->aug_init\*(C'\fR. .RE .RS 4 .Sp To close the handle, you can call \f(CW\*(C`$g\->aug_close\*(C'\fR. .Sp To find out more about Augeas, see . .RE .ie n .IP "$g\->aug_insert ($augpath, $label, $before);" 4 .el .IP "\f(CW$g\fR\->aug_insert ($augpath, \f(CW$label\fR, \f(CW$before\fR);" 4 .IX Item "$g->aug_insert ($augpath, $label, $before);" Create a new sibling \f(CW\*(C`label\*(C'\fR for \f(CW\*(C`path\*(C'\fR, inserting it into the tree before or after \f(CW\*(C`path\*(C'\fR (depending on the boolean flag \f(CW\*(C`before\*(C'\fR). .Sp \&\f(CW\*(C`path\*(C'\fR must match exactly one existing node in the tree, and \&\f(CW\*(C`label\*(C'\fR must be a label, ie. not contain \fI/\fR, \f(CW\*(C`*\*(C'\fR or end with a bracketed index \f(CW\*(C`[N]\*(C'\fR. .ie n .IP "$label = $g\->aug_label ($augpath);" 4 .el .IP "\f(CW$label\fR = \f(CW$g\fR\->aug_label ($augpath);" 4 .IX Item "$label = $g->aug_label ($augpath);" The label (name of the last element) of the Augeas path expression \&\f(CW\*(C`augpath\*(C'\fR is returned. \f(CW\*(C`augpath\*(C'\fR must match exactly one node, else this function returns an error. .ie n .IP "$g\->aug_load ();" 4 .el .IP "\f(CW$g\fR\->aug_load ();" 4 .IX Item "$g->aug_load ();" Load files into the tree. .Sp See \f(CW\*(C`aug_load\*(C'\fR in the Augeas documentation for the full gory details. .ie n .IP "@matches = $g\->aug_ls ($augpath);" 4 .el .IP "\f(CW@matches\fR = \f(CW$g\fR\->aug_ls ($augpath);" 4 .IX Item "@matches = $g->aug_ls ($augpath);" This is just a shortcut for listing \f(CW\*(C`$g\->aug_match\*(C'\fR \&\f(CW\*(C`path/*\*(C'\fR and sorting the resulting nodes into alphabetical order. .ie n .IP "@matches = $g\->aug_match ($augpath);" 4 .el .IP "\f(CW@matches\fR = \f(CW$g\fR\->aug_match ($augpath);" 4 .IX Item "@matches = $g->aug_match ($augpath);" Returns a list of paths which match the path expression \f(CW\*(C`path\*(C'\fR. The returned paths are sufficiently qualified so that they match exactly one node in the current tree. .ie n .IP "$g\->aug_mv ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->aug_mv ($src, \f(CW$dest\fR);" 4 .IX Item "$g->aug_mv ($src, $dest);" Move the node \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR. \f(CW\*(C`src\*(C'\fR must match exactly one node. \f(CW\*(C`dest\*(C'\fR is overwritten if it exists. .ie n .IP "$nrnodes = $g\->aug_rm ($augpath);" 4 .el .IP "\f(CW$nrnodes\fR = \f(CW$g\fR\->aug_rm ($augpath);" 4 .IX Item "$nrnodes = $g->aug_rm ($augpath);" Remove \f(CW\*(C`path\*(C'\fR and all of its children. .Sp On success this returns the number of entries which were removed. .ie n .IP "$g\->aug_save ();" 4 .el .IP "\f(CW$g\fR\->aug_save ();" 4 .IX Item "$g->aug_save ();" This writes all pending changes to disk. .Sp The flags which were passed to \f(CW\*(C`$g\->aug_init\*(C'\fR affect exactly how files are saved. .ie n .IP "$g\->aug_set ($augpath, $val);" 4 .el .IP "\f(CW$g\fR\->aug_set ($augpath, \f(CW$val\fR);" 4 .IX Item "$g->aug_set ($augpath, $val);" Set the value associated with \f(CW\*(C`augpath\*(C'\fR to \f(CW\*(C`val\*(C'\fR. .Sp In the Augeas API, it is possible to clear a node by setting the value to NULL. Due to an oversight in the libguestfs API you cannot do that with this call. Instead you must use the \&\f(CW\*(C`$g\->aug_clear\*(C'\fR call. .ie n .IP "$nodes = $g\->aug_setm ($base, $sub, $val);" 4 .el .IP "\f(CW$nodes\fR = \f(CW$g\fR\->aug_setm ($base, \f(CW$sub\fR, \f(CW$val\fR);" 4 .IX Item "$nodes = $g->aug_setm ($base, $sub, $val);" Change multiple Augeas nodes in a single operation. \f(CW\*(C`base\*(C'\fR is an expression matching multiple nodes. \f(CW\*(C`sub\*(C'\fR is a path expression relative to \f(CW\*(C`base\*(C'\fR. All nodes matching \f(CW\*(C`base\*(C'\fR are found, and then for each node, \f(CW\*(C`sub\*(C'\fR is changed to \f(CW\*(C`val\*(C'\fR. \f(CW\*(C`sub\*(C'\fR may also be \f(CW\*(C`NULL\*(C'\fR in which case the \f(CW\*(C`base\*(C'\fR nodes are modified. .Sp This returns the number of nodes modified. .ie n .IP "$g\->aug_transform ($lens, $file [, remove => $remove]);" 4 .el .IP "\f(CW$g\fR\->aug_transform ($lens, \f(CW$file\fR [, remove => \f(CW$remove\fR]);" 4 .IX Item "$g->aug_transform ($lens, $file [, remove => $remove]);" Add an Augeas transformation for the specified \f(CW\*(C`lens\*(C'\fR so it can handle \f(CW\*(C`file\*(C'\fR. .Sp If \f(CW\*(C`remove\*(C'\fR is true (\f(CW\*(C`false\*(C'\fR by default), then the transformation is removed. .ie n .IP "$g\->available (\e@groups);" 4 .el .IP "\f(CW$g\fR\->available (\e@groups);" 4 .IX Item "$g->available (@groups);" This command is used to check the availability of some groups of functionality in the appliance, which not all builds of the libguestfs appliance will be able to provide. .Sp The libguestfs groups, and the functions that those groups correspond to, are listed in "AVAILABILITY" in \fBguestfs\fR\|(3). You can also fetch this list at runtime by calling \&\f(CW\*(C`$g\->available_all_groups\*(C'\fR. .Sp The argument \f(CW\*(C`groups\*(C'\fR is a list of group names, eg: \&\f(CW\*(C`["inotify", "augeas"]\*(C'\fR would check for the availability of the Linux inotify functions and Augeas (configuration file editing) functions. .Sp The command returns no error if \fIall\fR requested groups are available. .Sp It fails with an error if one or more of the requested groups is unavailable in the appliance. .Sp If an unknown group name is included in the list of groups then an error is always returned. .Sp \&\fINotes:\fR .RS 4 .IP \(bu 4 \&\f(CW\*(C`$g\->feature_available\*(C'\fR is the same as this call, but with a slightly simpler to use API: that call returns a boolean true/false instead of throwing an error. .IP \(bu 4 You must call \f(CW\*(C`$g\->launch\*(C'\fR before calling this function. .Sp The reason is because we don't know what groups are supported by the appliance/daemon until it is running and can be queried. .IP \(bu 4 If a group of functions is available, this does not necessarily mean that they will work. You still have to check for errors when calling individual API functions even if they are available. .IP \(bu 4 It is usually the job of distro packagers to build complete functionality into the libguestfs appliance. Upstream libguestfs, if built from source with all requirements satisfied, will support everything. .IP \(bu 4 This call was added in version \f(CW1.0.80\fR. In previous versions of libguestfs all you could do would be to speculatively execute a command to find out if the daemon implemented it. See also \f(CW\*(C`$g\->version\*(C'\fR. .RE .RS 4 .Sp See also \f(CW\*(C`$g\->filesystem_available\*(C'\fR. .RE .ie n .IP "@groups = $g\->available_all_groups ();" 4 .el .IP "\f(CW@groups\fR = \f(CW$g\fR\->available_all_groups ();" 4 .IX Item "@groups = $g->available_all_groups ();" This command returns a list of all optional groups that this daemon knows about. Note this returns both supported and unsupported groups. To find out which ones the daemon can actually support you have to call \f(CW\*(C`$g\->available\*(C'\fR / \f(CW\*(C`$g\->feature_available\*(C'\fR on each member of the returned list. .Sp See also \f(CW\*(C`$g\->available\*(C'\fR, \f(CW\*(C`$g\->feature_available\*(C'\fR and "AVAILABILITY" in \fBguestfs\fR\|(3). .ie n .IP "$g\->base64_in ($base64file, $filename);" 4 .el .IP "\f(CW$g\fR\->base64_in ($base64file, \f(CW$filename\fR);" 4 .IX Item "$g->base64_in ($base64file, $filename);" This command uploads base64\-encoded data from \f(CW\*(C`base64file\*(C'\fR to \fIfilename\fR. .ie n .IP "$g\->base64_out ($filename, $base64file);" 4 .el .IP "\f(CW$g\fR\->base64_out ($filename, \f(CW$base64file\fR);" 4 .IX Item "$g->base64_out ($filename, $base64file);" This command downloads the contents of \fIfilename\fR, writing it out to local file \f(CW\*(C`base64file\*(C'\fR encoded as base64. .ie n .IP "$g\->blkdiscard ($device);" 4 .el .IP "\f(CW$g\fR\->blkdiscard ($device);" 4 .IX Item "$g->blkdiscard ($device);" This discards all blocks on the block device \f(CW\*(C`device\*(C'\fR, giving the free space back to the host. .Sp This operation requires support in libguestfs, the host filesystem, qemu and the host kernel. If this support isn't present it may give an error or even appear to run but do nothing. You must also set the \f(CW\*(C`discard\*(C'\fR attribute on the underlying drive (see \&\f(CW\*(C`$g\->add_drive_opts\*(C'\fR). .Sp This function depends on the feature \f(CW\*(C`blkdiscard\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$zeroes = $g\->blkdiscardzeroes ($device);" 4 .el .IP "\f(CW$zeroes\fR = \f(CW$g\fR\->blkdiscardzeroes ($device);" 4 .IX Item "$zeroes = $g->blkdiscardzeroes ($device);" This call returns true if blocks on \f(CW\*(C`device\*(C'\fR that have been discarded by a call to \f(CW\*(C`$g\->blkdiscard\*(C'\fR are returned as blocks of zero bytes when read the next time. .Sp If it returns false, then it may be that discarded blocks are read as stale or random data. .Sp This function depends on the feature \f(CW\*(C`blkdiscardzeroes\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%info = $g\->blkid ($device);" 4 .el .IP "\f(CW%info\fR = \f(CW$g\fR\->blkid ($device);" 4 .IX Item "%info = $g->blkid ($device);" This command returns block device attributes for \f(CW\*(C`device\*(C'\fR. The following fields are usually present in the returned hash. Other fields may also be present. .RS 4 .ie n .IP """UUID""" 4 .el .IP \f(CWUUID\fR 4 .IX Item "UUID" The uuid of this device. .ie n .IP """LABEL""" 4 .el .IP \f(CWLABEL\fR 4 .IX Item "LABEL" The label of this device. .ie n .IP """VERSION""" 4 .el .IP \f(CWVERSION\fR 4 .IX Item "VERSION" The version of blkid command. .ie n .IP """TYPE""" 4 .el .IP \f(CWTYPE\fR 4 .IX Item "TYPE" The filesystem type or RAID of this device. .ie n .IP """USAGE""" 4 .el .IP \f(CWUSAGE\fR 4 .IX Item "USAGE" The usage of this device, for example \f(CW\*(C`filesystem\*(C'\fR or \f(CW\*(C`raid\*(C'\fR. .RE .RS 4 .RE .ie n .IP "$g\->blockdev_flushbufs ($device);" 4 .el .IP "\f(CW$g\fR\->blockdev_flushbufs ($device);" 4 .IX Item "$g->blockdev_flushbufs ($device);" This tells the kernel to flush internal buffers associated with \f(CW\*(C`device\*(C'\fR. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$blocksize = $g\->blockdev_getbsz ($device);" 4 .el .IP "\f(CW$blocksize\fR = \f(CW$g\fR\->blockdev_getbsz ($device);" 4 .IX Item "$blocksize = $g->blockdev_getbsz ($device);" This returns the block size of a device. .Sp Note: this is different from both \fIsize in blocks\fR and \&\fIfilesystem block size\fR. Also this setting is not really used by anything. You should probably not use it for anything. Filesystems have their own idea about what block size to choose. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$ro = $g\->blockdev_getro ($device);" 4 .el .IP "\f(CW$ro\fR = \f(CW$g\fR\->blockdev_getro ($device);" 4 .IX Item "$ro = $g->blockdev_getro ($device);" Returns a boolean indicating if the block device is read-only (true if read-only, false if not). .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$sizeinbytes = $g\->blockdev_getsize64 ($device);" 4 .el .IP "\f(CW$sizeinbytes\fR = \f(CW$g\fR\->blockdev_getsize64 ($device);" 4 .IX Item "$sizeinbytes = $g->blockdev_getsize64 ($device);" This returns the size of the device in bytes. .Sp See also \f(CW\*(C`$g\->blockdev_getsz\*(C'\fR. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$sectorsize = $g\->blockdev_getss ($device);" 4 .el .IP "\f(CW$sectorsize\fR = \f(CW$g\fR\->blockdev_getss ($device);" 4 .IX Item "$sectorsize = $g->blockdev_getss ($device);" This returns the size of sectors on a block device. Usually 512, but can be larger for modern devices. .Sp (Note, this is not the size in sectors, use \f(CW\*(C`$g\->blockdev_getsz\*(C'\fR for that). .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$sizeinsectors = $g\->blockdev_getsz ($device);" 4 .el .IP "\f(CW$sizeinsectors\fR = \f(CW$g\fR\->blockdev_getsz ($device);" 4 .IX Item "$sizeinsectors = $g->blockdev_getsz ($device);" This returns the size of the device in units of 512\-byte sectors (even if the sectorsize isn't 512 bytes ... weird). .Sp See also \f(CW\*(C`$g\->blockdev_getss\*(C'\fR for the real sector size of the device, and \f(CW\*(C`$g\->blockdev_getsize64\*(C'\fR for the more useful \fIsize in bytes\fR. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$g\->blockdev_rereadpt ($device);" 4 .el .IP "\f(CW$g\fR\->blockdev_rereadpt ($device);" 4 .IX Item "$g->blockdev_rereadpt ($device);" Reread the partition table on \f(CW\*(C`device\*(C'\fR. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$g\->blockdev_setbsz ($device, $blocksize);" 4 .el .IP "\f(CW$g\fR\->blockdev_setbsz ($device, \f(CW$blocksize\fR);" 4 .IX Item "$g->blockdev_setbsz ($device, $blocksize);" This call does nothing and has never done anything because of a bug in blockdev. \fBDo not use it.\fR .Sp If you need to set the filesystem block size, use the \&\f(CW\*(C`blocksize\*(C'\fR option of \f(CW\*(C`$g\->mkfs\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->blockdev_setra ($device, $sectors);" 4 .el .IP "\f(CW$g\fR\->blockdev_setra ($device, \f(CW$sectors\fR);" 4 .IX Item "$g->blockdev_setra ($device, $sectors);" Set readahead (in 512\-byte sectors) for the device. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$g\->blockdev_setro ($device);" 4 .el .IP "\f(CW$g\fR\->blockdev_setro ($device);" 4 .IX Item "$g->blockdev_setro ($device);" Sets the block device named \f(CW\*(C`device\*(C'\fR to read-only. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$g\->blockdev_setrw ($device);" 4 .el .IP "\f(CW$g\fR\->blockdev_setrw ($device);" 4 .IX Item "$g->blockdev_setrw ($device);" Sets the block device named \f(CW\*(C`device\*(C'\fR to read-write. .Sp This uses the \fBblockdev\fR\|(8) command. .ie n .IP "$g\->btrfs_balance_cancel ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_balance_cancel ($path);" 4 .IX Item "$g->btrfs_balance_cancel ($path);" Cancel a running balance on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_balance_pause ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_balance_pause ($path);" 4 .IX Item "$g->btrfs_balance_pause ($path);" Pause a running balance on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_balance_resume ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_balance_resume ($path);" 4 .IX Item "$g->btrfs_balance_resume ($path);" Resume a paused balance on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%status = $g\->btrfs_balance_status ($path);" 4 .el .IP "\f(CW%status\fR = \f(CW$g\fR\->btrfs_balance_status ($path);" 4 .IX Item "%status = $g->btrfs_balance_status ($path);" Show the status of a running or paused balance on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_device_add (\e@devices, $fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_device_add (\e@devices, \f(CW$fs\fR);" 4 .IX Item "$g->btrfs_device_add (@devices, $fs);" Add the list of device(s) in \f(CW\*(C`devices\*(C'\fR to the btrfs filesystem mounted at \f(CW\*(C`fs\*(C'\fR. If \f(CW\*(C`devices\*(C'\fR is an empty list, this does nothing. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_device_delete (\e@devices, $fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_device_delete (\e@devices, \f(CW$fs\fR);" 4 .IX Item "$g->btrfs_device_delete (@devices, $fs);" Remove the \f(CW\*(C`devices\*(C'\fR from the btrfs filesystem mounted at \f(CW\*(C`fs\*(C'\fR. If \f(CW\*(C`devices\*(C'\fR is an empty list, this does nothing. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_filesystem_balance ($fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_filesystem_balance ($fs);" 4 .IX Item "$g->btrfs_filesystem_balance ($fs);" Balance the chunks in the btrfs filesystem mounted at \f(CW\*(C`fs\*(C'\fR across the underlying devices. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_filesystem_defragment ($path [, flush => $flush] [, compress => $compress]);" 4 .el .IP "\f(CW$g\fR\->btrfs_filesystem_defragment ($path [, flush => \f(CW$flush\fR] [, compress => \f(CW$compress\fR]);" 4 .IX Item "$g->btrfs_filesystem_defragment ($path [, flush => $flush] [, compress => $compress]);" Defragment a file or directory on a btrfs filesystem. compress is one of zlib or lzo. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_filesystem_resize ($mountpoint [, size => $size]);" 4 .el .IP "\f(CW$g\fR\->btrfs_filesystem_resize ($mountpoint [, size => \f(CW$size\fR]);" 4 .IX Item "$g->btrfs_filesystem_resize ($mountpoint [, size => $size]);" This command resizes a btrfs filesystem. .Sp Note that unlike other resize calls, the filesystem has to be mounted and the parameter is the mountpoint not the device (this is a requirement of btrfs itself). .Sp The optional parameters are: .RS 4 .ie n .IP """size""" 4 .el .IP \f(CWsize\fR 4 .IX Item "size" The new size (in bytes) of the filesystem. If omitted, the filesystem is resized to the maximum size. .RE .RS 4 .Sp See also \fBbtrfs\fR\|(8). .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "@devices = $g\->btrfs_filesystem_show ($device);" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->btrfs_filesystem_show ($device);" 4 .IX Item "@devices = $g->btrfs_filesystem_show ($device);" Show all the devices where the filesystems in \f(CW\*(C`device\*(C'\fR is spanned over. .Sp If not all the devices for the filesystems are present, then this function fails and the \f(CW\*(C`errno\*(C'\fR is set to \f(CW\*(C`ENODEV\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_filesystem_sync ($fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_filesystem_sync ($fs);" 4 .IX Item "$g->btrfs_filesystem_sync ($fs);" Force sync on the btrfs filesystem mounted at \f(CW\*(C`fs\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_fsck ($device [, superblock => $superblock] [, repair => $repair]);" 4 .el .IP "\f(CW$g\fR\->btrfs_fsck ($device [, superblock => \f(CW$superblock\fR] [, repair => \f(CW$repair\fR]);" 4 .IX Item "$g->btrfs_fsck ($device [, superblock => $superblock] [, repair => $repair]);" Used to check a btrfs filesystem, \f(CW\*(C`device\*(C'\fR is the device file where the filesystem is stored. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_image (\e@source, $image [, compresslevel => $compresslevel]);" 4 .el .IP "\f(CW$g\fR\->btrfs_image (\e@source, \f(CW$image\fR [, compresslevel => \f(CW$compresslevel\fR]);" 4 .IX Item "$g->btrfs_image (@source, $image [, compresslevel => $compresslevel]);" This is used to create an image of a btrfs filesystem. All data will be zeroed, but metadata and the like is preserved. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_qgroup_assign ($src, $dst, $path);" 4 .el .IP "\f(CW$g\fR\->btrfs_qgroup_assign ($src, \f(CW$dst\fR, \f(CW$path\fR);" 4 .IX Item "$g->btrfs_qgroup_assign ($src, $dst, $path);" Add qgroup \f(CW\*(C`src\*(C'\fR to parent qgroup \f(CW\*(C`dst\*(C'\fR. This command can group several qgroups into a parent qgroup to share common limit. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_qgroup_create ($qgroupid, $subvolume);" 4 .el .IP "\f(CW$g\fR\->btrfs_qgroup_create ($qgroupid, \f(CW$subvolume\fR);" 4 .IX Item "$g->btrfs_qgroup_create ($qgroupid, $subvolume);" Create a quota group (qgroup) for subvolume at \f(CW\*(C`subvolume\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_qgroup_destroy ($qgroupid, $subvolume);" 4 .el .IP "\f(CW$g\fR\->btrfs_qgroup_destroy ($qgroupid, \f(CW$subvolume\fR);" 4 .IX Item "$g->btrfs_qgroup_destroy ($qgroupid, $subvolume);" Destroy a quota group. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_qgroup_limit ($subvolume, $size);" 4 .el .IP "\f(CW$g\fR\->btrfs_qgroup_limit ($subvolume, \f(CW$size\fR);" 4 .IX Item "$g->btrfs_qgroup_limit ($subvolume, $size);" Limit the size of the subvolume with path \f(CW\*(C`subvolume\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_qgroup_remove ($src, $dst, $path);" 4 .el .IP "\f(CW$g\fR\->btrfs_qgroup_remove ($src, \f(CW$dst\fR, \f(CW$path\fR);" 4 .IX Item "$g->btrfs_qgroup_remove ($src, $dst, $path);" Remove qgroup \f(CW\*(C`src\*(C'\fR from the parent qgroup \f(CW\*(C`dst\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@qgroups = $g\->btrfs_qgroup_show ($path);" 4 .el .IP "\f(CW@qgroups\fR = \f(CW$g\fR\->btrfs_qgroup_show ($path);" 4 .IX Item "@qgroups = $g->btrfs_qgroup_show ($path);" Show all subvolume quota groups in a btrfs filesystem, including their usages. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_quota_enable ($fs, $enable);" 4 .el .IP "\f(CW$g\fR\->btrfs_quota_enable ($fs, \f(CW$enable\fR);" 4 .IX Item "$g->btrfs_quota_enable ($fs, $enable);" Enable or disable subvolume quota support for filesystem which contains \f(CW\*(C`path\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_quota_rescan ($fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_quota_rescan ($fs);" 4 .IX Item "$g->btrfs_quota_rescan ($fs);" Trash all qgroup numbers and scan the metadata again with the current config. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_replace ($srcdev, $targetdev, $mntpoint);" 4 .el .IP "\f(CW$g\fR\->btrfs_replace ($srcdev, \f(CW$targetdev\fR, \f(CW$mntpoint\fR);" 4 .IX Item "$g->btrfs_replace ($srcdev, $targetdev, $mntpoint);" Replace device of a btrfs filesystem. On a live filesystem, duplicate the data to the target device which is currently stored on the source device. After completion of the operation, the source device is wiped out and removed from the filesystem. .Sp The \f(CW\*(C`targetdev\*(C'\fR needs to be same size or larger than the \f(CW\*(C`srcdev\*(C'\fR. Devices which are currently mounted are never allowed to be used as the \f(CW\*(C`targetdev\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_rescue_chunk_recover ($device);" 4 .el .IP "\f(CW$g\fR\->btrfs_rescue_chunk_recover ($device);" 4 .IX Item "$g->btrfs_rescue_chunk_recover ($device);" Recover the chunk tree of btrfs filesystem by scanning the devices one by one. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_rescue_super_recover ($device);" 4 .el .IP "\f(CW$g\fR\->btrfs_rescue_super_recover ($device);" 4 .IX Item "$g->btrfs_rescue_super_recover ($device);" Recover bad superblocks from good copies. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_scrub_cancel ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_scrub_cancel ($path);" 4 .IX Item "$g->btrfs_scrub_cancel ($path);" Cancel a running scrub on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_scrub_resume ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_scrub_resume ($path);" 4 .IX Item "$g->btrfs_scrub_resume ($path);" Resume a previously canceled or interrupted scrub on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_scrub_start ($path);" 4 .el .IP "\f(CW$g\fR\->btrfs_scrub_start ($path);" 4 .IX Item "$g->btrfs_scrub_start ($path);" Reads all the data and metadata on the filesystem, and uses checksums and the duplicate copies from RAID storage to identify and repair any corrupt data. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%status = $g\->btrfs_scrub_status ($path);" 4 .el .IP "\f(CW%status\fR = \f(CW$g\fR\->btrfs_scrub_status ($path);" 4 .IX Item "%status = $g->btrfs_scrub_status ($path);" Show status of running or finished scrub on a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_set_seeding ($device, $seeding);" 4 .el .IP "\f(CW$g\fR\->btrfs_set_seeding ($device, \f(CW$seeding\fR);" 4 .IX Item "$g->btrfs_set_seeding ($device, $seeding);" Enable or disable the seeding feature of a device that contains a btrfs filesystem. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_subvolume_create ($dest [, qgroupid => $qgroupid]);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_create ($dest [, qgroupid => \f(CW$qgroupid\fR]);" 4 .IX Item "$g->btrfs_subvolume_create ($dest [, qgroupid => $qgroupid]);" Create a btrfs subvolume. The \f(CW\*(C`dest\*(C'\fR argument is the destination directory and the name of the subvolume, in the form \fI/path/to/dest/name\fR. The optional parameter \f(CW\*(C`qgroupid\*(C'\fR represents the qgroup which the newly created subvolume will be added to. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_subvolume_create_opts ($dest [, qgroupid => $qgroupid]);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_create_opts ($dest [, qgroupid => \f(CW$qgroupid\fR]);" 4 .IX Item "$g->btrfs_subvolume_create_opts ($dest [, qgroupid => $qgroupid]);" This is an alias of "btrfs_subvolume_create". .ie n .IP "$g\->btrfs_subvolume_delete ($subvolume);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_delete ($subvolume);" 4 .IX Item "$g->btrfs_subvolume_delete ($subvolume);" Delete the named btrfs subvolume or snapshot. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$id = $g\->btrfs_subvolume_get_default ($fs);" 4 .el .IP "\f(CW$id\fR = \f(CW$g\fR\->btrfs_subvolume_get_default ($fs);" 4 .IX Item "$id = $g->btrfs_subvolume_get_default ($fs);" Get the default subvolume or snapshot of a filesystem mounted at \f(CW\*(C`mountpoint\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@subvolumes = $g\->btrfs_subvolume_list ($fs);" 4 .el .IP "\f(CW@subvolumes\fR = \f(CW$g\fR\->btrfs_subvolume_list ($fs);" 4 .IX Item "@subvolumes = $g->btrfs_subvolume_list ($fs);" List the btrfs snapshots and subvolumes of the btrfs filesystem which is mounted at \f(CW\*(C`fs\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_subvolume_set_default ($id, $fs);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_set_default ($id, \f(CW$fs\fR);" 4 .IX Item "$g->btrfs_subvolume_set_default ($id, $fs);" Set the subvolume of the btrfs filesystem \f(CW\*(C`fs\*(C'\fR which will be mounted by default. See \f(CW\*(C`$g\->btrfs_subvolume_list\*(C'\fR to get a list of subvolumes. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%btrfssubvolumeinfo = $g\->btrfs_subvolume_show ($subvolume);" 4 .el .IP "\f(CW%btrfssubvolumeinfo\fR = \f(CW$g\fR\->btrfs_subvolume_show ($subvolume);" 4 .IX Item "%btrfssubvolumeinfo = $g->btrfs_subvolume_show ($subvolume);" Return detailed information of the subvolume. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_subvolume_snapshot ($source, $dest [, ro => $ro] [, qgroupid => $qgroupid]);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_snapshot ($source, \f(CW$dest\fR [, ro => \f(CW$ro\fR] [, qgroupid => \f(CW$qgroupid\fR]);" 4 .IX Item "$g->btrfs_subvolume_snapshot ($source, $dest [, ro => $ro] [, qgroupid => $qgroupid]);" Create a snapshot of the btrfs subvolume \f(CW\*(C`source\*(C'\fR. The \f(CW\*(C`dest\*(C'\fR argument is the destination directory and the name of the snapshot, in the form \fI/path/to/dest/name\fR. By default the newly created snapshot is writable, if the value of optional parameter \f(CW\*(C`ro\*(C'\fR is true, then a readonly snapshot is created. The optional parameter \f(CW\*(C`qgroupid\*(C'\fR represents the qgroup which the newly created snapshot will be added to. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfs_subvolume_snapshot_opts ($source, $dest [, ro => $ro] [, qgroupid => $qgroupid]);" 4 .el .IP "\f(CW$g\fR\->btrfs_subvolume_snapshot_opts ($source, \f(CW$dest\fR [, ro => \f(CW$ro\fR] [, qgroupid => \f(CW$qgroupid\fR]);" 4 .IX Item "$g->btrfs_subvolume_snapshot_opts ($source, $dest [, ro => $ro] [, qgroupid => $qgroupid]);" This is an alias of "btrfs_subvolume_snapshot". .ie n .IP "$g\->btrfstune_enable_extended_inode_refs ($device);" 4 .el .IP "\f(CW$g\fR\->btrfstune_enable_extended_inode_refs ($device);" 4 .IX Item "$g->btrfstune_enable_extended_inode_refs ($device);" This will Enable extended inode refs. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfstune_enable_skinny_metadata_extent_refs ($device);" 4 .el .IP "\f(CW$g\fR\->btrfstune_enable_skinny_metadata_extent_refs ($device);" 4 .IX Item "$g->btrfstune_enable_skinny_metadata_extent_refs ($device);" This enable skinny metadata extent refs. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->btrfstune_seeding ($device, $seeding);" 4 .el .IP "\f(CW$g\fR\->btrfstune_seeding ($device, \f(CW$seeding\fR);" 4 .IX Item "$g->btrfstune_seeding ($device, $seeding);" Enable seeding of a btrfs device, this will force a fs readonly so that you can use it to build other filesystems. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$ptr = $g\->c_pointer ();" 4 .el .IP "\f(CW$ptr\fR = \f(CW$g\fR\->c_pointer ();" 4 .IX Item "$ptr = $g->c_pointer ();" In non-C language bindings, this allows you to retrieve the underlying C pointer to the handle (ie. \f(CW\*(C`$g\->h *\*(C'\fR). The purpose of this is to allow other libraries to interwork with libguestfs. .ie n .IP "$canonical = $g\->canonical_device_name ($device);" 4 .el .IP "\f(CW$canonical\fR = \f(CW$g\fR\->canonical_device_name ($device);" 4 .IX Item "$canonical = $g->canonical_device_name ($device);" This utility function is useful when displaying device names to the user. It takes a number of irregular device names and returns them in a consistent format: .RS 4 .IP \fI/dev/hdX\fR 4 .IX Item "/dev/hdX" .PD 0 .IP \fI/dev/vdX\fR 4 .IX Item "/dev/vdX" .PD These are returned as \fI/dev/sdX\fR. Note this works for device names and partition names. This is approximately the reverse of the algorithm described in "BLOCK DEVICE NAMING" in \fBguestfs\fR\|(3). .IP \fI/dev/mapper/VG\-LV\fR 4 .IX Item "/dev/mapper/VG-LV" .PD 0 .IP \fI/dev/dm\-N\fR 4 .IX Item "/dev/dm-N" .PD Converted to \fI/dev/VG/LV\fR form using \f(CW\*(C`$g\->lvm_canonical_lv_name\*(C'\fR. .RE .RS 4 .Sp Other strings are returned unmodified. .RE .ie n .IP "$cap = $g\->cap_get_file ($path);" 4 .el .IP "\f(CW$cap\fR = \f(CW$g\fR\->cap_get_file ($path);" 4 .IX Item "$cap = $g->cap_get_file ($path);" This function returns the Linux capabilities attached to \f(CW\*(C`path\*(C'\fR. The capabilities set is returned in text form (see \fBcap_to_text\fR\|(3)). .Sp If no capabilities are attached to a file, an empty string is returned. .Sp This function depends on the feature \f(CW\*(C`linuxcaps\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->cap_set_file ($path, $cap);" 4 .el .IP "\f(CW$g\fR\->cap_set_file ($path, \f(CW$cap\fR);" 4 .IX Item "$g->cap_set_file ($path, $cap);" This function sets the Linux capabilities attached to \f(CW\*(C`path\*(C'\fR. The capabilities set \f(CW\*(C`cap\*(C'\fR should be passed in text form (see \fBcap_from_text\fR\|(3)). .Sp This function depends on the feature \f(CW\*(C`linuxcaps\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$rpath = $g\->case_sensitive_path ($path);" 4 .el .IP "\f(CW$rpath\fR = \f(CW$g\fR\->case_sensitive_path ($path);" 4 .IX Item "$rpath = $g->case_sensitive_path ($path);" This can be used to resolve case insensitive paths on a filesystem which is case sensitive. The use case is to resolve paths which you have read from Windows configuration files or the Windows Registry, to the true path. .Sp The command handles a peculiarity of the Linux ntfs\-3g filesystem driver (and probably others), which is that although the underlying filesystem is case-insensitive, the driver exports the filesystem to Linux as case-sensitive. .Sp One consequence of this is that special directories such as \fIC:\ewindows\fR may appear as \fI/WINDOWS\fR or \fI/windows\fR (or other things) depending on the precise details of how they were created. In Windows itself this would not be a problem. .Sp Bug or feature? You decide: .Sp \&\f(CW\*(C`$g\->case_sensitive_path\*(C'\fR attempts to resolve the true case of each element in the path. It will return a resolved path if either the full path or its parent directory exists. If the parent directory exists but the full path does not, the case of the parent directory will be correctly resolved, and the remainder appended unmodified. For example, if the file \f(CW"/Windows/System32/netkvm.sys"\fR exists: .RS 4 .ie n .IP """$g\->case_sensitive_path"" (""/windows/system32/netkvm.sys"")" 4 .el .IP "\f(CW$g\->case_sensitive_path\fR (""/windows/system32/netkvm.sys"")" 4 .IX Item "$g->case_sensitive_path (""/windows/system32/netkvm.sys"")" "Windows/System32/netkvm.sys" .ie n .IP """$g\->case_sensitive_path"" (""/windows/system32/NoSuchFile"")" 4 .el .IP "\f(CW$g\->case_sensitive_path\fR (""/windows/system32/NoSuchFile"")" 4 .IX Item "$g->case_sensitive_path (""/windows/system32/NoSuchFile"")" "Windows/System32/NoSuchFile" .ie n .IP """$g\->case_sensitive_path"" (""/windows/system33/netkvm.sys"")" 4 .el .IP "\f(CW$g\->case_sensitive_path\fR (""/windows/system33/netkvm.sys"")" 4 .IX Item "$g->case_sensitive_path (""/windows/system33/netkvm.sys"")" \&\fIERROR\fR .RE .RS 4 .Sp \&\fINote\fR: Because of the above behaviour, \f(CW\*(C`$g\->case_sensitive_path\*(C'\fR cannot be used to check for the existence of a file. .Sp \&\fINote\fR: This function does not handle drive names, backslashes etc. .Sp See also \f(CW\*(C`$g\->realpath\*(C'\fR. .RE .ie n .IP "$content = $g\->cat ($path);" 4 .el .IP "\f(CW$content\fR = \f(CW$g\fR\->cat ($path);" 4 .IX Item "$content = $g->cat ($path);" Return the contents of the file named \f(CW\*(C`path\*(C'\fR. .Sp Because, in C, this function returns a \f(CW\*(C`char *\*(C'\fR, there is no way to differentiate between a \f(CW\*(C`\e0\*(C'\fR character in a file and end of string. To handle binary files, use the \f(CW\*(C`$g\->read_file\*(C'\fR or \f(CW\*(C`$g\->download\*(C'\fR functions. .ie n .IP "$checksum = $g\->checksum ($csumtype, $path);" 4 .el .IP "\f(CW$checksum\fR = \f(CW$g\fR\->checksum ($csumtype, \f(CW$path\fR);" 4 .IX Item "$checksum = $g->checksum ($csumtype, $path);" This call computes the MD5, SHAx or CRC checksum of the file named \f(CW\*(C`path\*(C'\fR. .Sp The type of checksum to compute is given by the \f(CW\*(C`csumtype\*(C'\fR parameter which must have one of the following values: .RS 4 .ie n .IP """crc""" 4 .el .IP \f(CWcrc\fR 4 .IX Item "crc" Compute the cyclic redundancy check (CRC) specified by POSIX for the \f(CW\*(C`cksum\*(C'\fR command. .ie n .IP """gost""" 4 .el .IP \f(CWgost\fR 4 .IX Item "gost" .PD 0 .ie n .IP """gost12""" 4 .el .IP \f(CWgost12\fR 4 .IX Item "gost12" .PD Compute the checksum using GOST R34.11\-94 or GOST R34.11\-2012 message digest. .ie n .IP """md5""" 4 .el .IP \f(CWmd5\fR 4 .IX Item "md5" Compute the MD5 hash (using the \fBmd5sum\fR\|(1) program). .ie n .IP """sha1""" 4 .el .IP \f(CWsha1\fR 4 .IX Item "sha1" Compute the SHA1 hash (using the \fBsha1sum\fR\|(1) program). .ie n .IP """sha224""" 4 .el .IP \f(CWsha224\fR 4 .IX Item "sha224" Compute the SHA224 hash (using the \fBsha224sum\fR\|(1) program). .ie n .IP """sha256""" 4 .el .IP \f(CWsha256\fR 4 .IX Item "sha256" Compute the SHA256 hash (using the \fBsha256sum\fR\|(1) program). .ie n .IP """sha384""" 4 .el .IP \f(CWsha384\fR 4 .IX Item "sha384" Compute the SHA384 hash (using the \fBsha384sum\fR\|(1) program). .ie n .IP """sha512""" 4 .el .IP \f(CWsha512\fR 4 .IX Item "sha512" Compute the SHA512 hash (using the \fBsha512sum\fR\|(1) program). .RE .RS 4 .Sp The checksum is returned as a printable string. .Sp To get the checksum for a device, use \f(CW\*(C`$g\->checksum_device\*(C'\fR. .Sp To get the checksums for many files, use \f(CW\*(C`$g\->checksums_out\*(C'\fR. .RE .ie n .IP "$checksum = $g\->checksum_device ($csumtype, $device);" 4 .el .IP "\f(CW$checksum\fR = \f(CW$g\fR\->checksum_device ($csumtype, \f(CW$device\fR);" 4 .IX Item "$checksum = $g->checksum_device ($csumtype, $device);" This call computes the MD5, SHAx or CRC checksum of the contents of the device named \f(CW\*(C`device\*(C'\fR. For the types of checksums supported see the \f(CW\*(C`$g\->checksum\*(C'\fR command. .ie n .IP "$g\->checksums_out ($csumtype, $directory, $sumsfile);" 4 .el .IP "\f(CW$g\fR\->checksums_out ($csumtype, \f(CW$directory\fR, \f(CW$sumsfile\fR);" 4 .IX Item "$g->checksums_out ($csumtype, $directory, $sumsfile);" This command computes the checksums of all regular files in \&\fIdirectory\fR and then emits a list of those checksums to the local output file \f(CW\*(C`sumsfile\*(C'\fR. .Sp This can be used for verifying the integrity of a virtual machine. However to be properly secure you should pay attention to the output of the checksum command (it uses the ones from GNU coreutils). In particular when the filename is not printable, coreutils uses a special backslash syntax. For more information, see the GNU coreutils info file. .ie n .IP "$g\->chmod ($mode, $path);" 4 .el .IP "\f(CW$g\fR\->chmod ($mode, \f(CW$path\fR);" 4 .IX Item "$g->chmod ($mode, $path);" Change the mode (permissions) of \f(CW\*(C`path\*(C'\fR to \f(CW\*(C`mode\*(C'\fR. Only numeric modes are supported. .Sp \&\fINote\fR: When using this command from guestfish, \f(CW\*(C`mode\*(C'\fR by default would be decimal, unless you prefix it with \&\f(CW0\fR to get octal, ie. use \f(CW0700\fR not \f(CW700\fR. .Sp The mode actually set is affected by the umask. .ie n .IP "$g\->chown ($owner, $group, $path);" 4 .el .IP "\f(CW$g\fR\->chown ($owner, \f(CW$group\fR, \f(CW$path\fR);" 4 .IX Item "$g->chown ($owner, $group, $path);" Change the file owner to \f(CW\*(C`owner\*(C'\fR and group to \f(CW\*(C`group\*(C'\fR. .Sp Only numeric uid and gid are supported. If you want to use names, you will need to locate and parse the password file yourself (Augeas support makes this relatively easy). .ie n .IP "$count = $g\->clear_backend_setting ($name);" 4 .el .IP "\f(CW$count\fR = \f(CW$g\fR\->clear_backend_setting ($name);" 4 .IX Item "$count = $g->clear_backend_setting ($name);" If there is a backend setting string matching \f(CW"name"\fR or beginning with \f(CW"name="\fR, then that string is removed from the backend settings. .Sp This call returns the number of strings which were removed (which may be 0, 1 or greater than 1). .Sp See "BACKEND" in \fBguestfs\fR\|(3), "BACKEND SETTINGS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->clevis_luks_unlock ($device, $mapname);" 4 .el .IP "\f(CW$g\fR\->clevis_luks_unlock ($device, \f(CW$mapname\fR);" 4 .IX Item "$g->clevis_luks_unlock ($device, $mapname);" This command opens a block device that has been encrypted according to the Linux Unified Key Setup (LUKS) standard, using network-bound disk encryption (NBDE). .Sp \&\f(CW\*(C`device\*(C'\fR is the encrypted block device. .Sp The appliance will connect to the Tang servers noted in the tree of Clevis pins that is bound to a keyslot of the LUKS header. The Clevis pin tree may comprise \f(CW\*(C`sss\*(C'\fR (redudancy) pins as internal nodes (optionally), and \f(CW\*(C`tang\*(C'\fR pins as leaves. \f(CW\*(C`tpm2\*(C'\fR pins are not supported. The appliance unlocks the encrypted block device by combining responses from the Tang servers with metadata from the LUKS header; there is no \f(CW\*(C`key\*(C'\fR parameter. .Sp This command will fail if networking has not been enabled for the appliance. Refer to \f(CW\*(C`$g\->set_network\*(C'\fR. .Sp The command creates a new block device called \fI/dev/mapper/mapname\fR. Reads and writes to this block device are decrypted from and encrypted to the underlying \f(CW\*(C`device\*(C'\fR respectively. Close the decrypted block device with \f(CW\*(C`$g\->cryptsetup_close\*(C'\fR. .Sp \&\f(CW\*(C`mapname\*(C'\fR cannot be \f(CW"control"\fR because that name is reserved by device-mapper. .Sp If this block device contains LVM volume groups, then calling \&\f(CW\*(C`$g\->lvm_scan\*(C'\fR with the \f(CW\*(C`activate\*(C'\fR parameter \f(CW\*(C`true\*(C'\fR will make them visible. .Sp Use \f(CW\*(C`$g\->list_dm_devices\*(C'\fR to list all device mapper devices. .Sp This function depends on the feature \f(CW\*(C`clevisluks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$output = $g\->command (\e@arguments);" 4 .el .IP "\f(CW$output\fR = \f(CW$g\fR\->command (\e@arguments);" 4 .IX Item "$output = $g->command (@arguments);" This call runs a command from the guest filesystem. The filesystem must be mounted, and must contain a compatible operating system (ie. something Linux, with the same or compatible processor architecture). .Sp The single parameter is an argv-style list of arguments. The first element is the name of the program to run. Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). Note that the command runs directly, and is \fInot\fR invoked via the shell (see \f(CW\*(C`$g\->sh\*(C'\fR). .Sp The return value is anything printed to \fIstdout\fR by the command. .Sp If the command returns a non-zero exit status, then this function returns an error message. The error message string is the content of \fIstderr\fR from the command. .Sp The \f(CW$PATH\fR environment variable will contain at least \&\fI/usr/bin\fR and \fI/bin\fR. If you require a program from another location, you should provide the full path in the first parameter. .Sp Shared libraries and data files required by the program must be available on filesystems which are mounted in the correct places. It is the caller’s responsibility to ensure all filesystems that are needed are mounted at the right locations. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "@lines = $g\->command_lines (\e@arguments);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->command_lines (\e@arguments);" 4 .IX Item "@lines = $g->command_lines (@arguments);" This is the same as \f(CW\*(C`$g\->command\*(C'\fR, but splits the result into a list of lines. .Sp See also: \f(CW\*(C`$g\->sh_lines\*(C'\fR .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->compress_device_out ($ctype, $device, $zdevice [, level => $level]);" 4 .el .IP "\f(CW$g\fR\->compress_device_out ($ctype, \f(CW$device\fR, \f(CW$zdevice\fR [, level => \f(CW$level\fR]);" 4 .IX Item "$g->compress_device_out ($ctype, $device, $zdevice [, level => $level]);" This command compresses \f(CW\*(C`device\*(C'\fR and writes it out to the local file \f(CW\*(C`zdevice\*(C'\fR. .Sp The \f(CW\*(C`ctype\*(C'\fR and optional \f(CW\*(C`level\*(C'\fR parameters have the same meaning as in \f(CW\*(C`$g\->compress_out\*(C'\fR. .ie n .IP "$g\->compress_out ($ctype, $file, $zfile [, level => $level]);" 4 .el .IP "\f(CW$g\fR\->compress_out ($ctype, \f(CW$file\fR, \f(CW$zfile\fR [, level => \f(CW$level\fR]);" 4 .IX Item "$g->compress_out ($ctype, $file, $zfile [, level => $level]);" This command compresses \fIfile\fR and writes it out to the local file \fIzfile\fR. .Sp The compression program used is controlled by the \f(CW\*(C`ctype\*(C'\fR parameter. Currently this includes: \f(CW\*(C`compress\*(C'\fR, \f(CW\*(C`gzip\*(C'\fR, \f(CW\*(C`bzip2\*(C'\fR, \f(CW\*(C`xz\*(C'\fR or \f(CW\*(C`lzop\*(C'\fR. Some compression types may not be supported by particular builds of libguestfs, in which case you will get an error containing the substring "not supported". .Sp The optional \f(CW\*(C`level\*(C'\fR parameter controls compression level. The meaning and default for this parameter depends on the compression program being used. .ie n .IP "$g\->config ($hvparam, $hvvalue);" 4 .el .IP "\f(CW$g\fR\->config ($hvparam, \f(CW$hvvalue\fR);" 4 .IX Item "$g->config ($hvparam, $hvvalue);" This can be used to add arbitrary hypervisor parameters of the form \fI\-param value\fR. Actually it’s not quite arbitrary \- we prevent you from setting some parameters which would interfere with parameters that we use. .Sp The first character of \f(CW\*(C`hvparam\*(C'\fR string must be a \f(CW\*(C`\-\*(C'\fR (dash). .Sp \&\f(CW\*(C`hvvalue\*(C'\fR can be NULL. .ie n .IP "$g\->copy_attributes ($src, $dest [, all => $all] [, mode => $mode] [, xattributes => $xattributes] [, ownership => $ownership]);" 4 .el .IP "\f(CW$g\fR\->copy_attributes ($src, \f(CW$dest\fR [, all => \f(CW$all\fR] [, mode => \f(CW$mode\fR] [, xattributes => \f(CW$xattributes\fR] [, ownership => \f(CW$ownership\fR]);" 4 .IX Item "$g->copy_attributes ($src, $dest [, all => $all] [, mode => $mode] [, xattributes => $xattributes] [, ownership => $ownership]);" Copy the attributes of a path (which can be a file or a directory) to another path. .Sp By default \fBno\fR attribute is copied, so make sure to specify any (or \f(CW\*(C`all\*(C'\fR to copy everything). .Sp The optional arguments specify which attributes can be copied: .RS 4 .ie n .IP """mode""" 4 .el .IP \f(CWmode\fR 4 .IX Item "mode" Copy part of the file mode from \f(CW\*(C`source\*(C'\fR to \f(CW\*(C`destination\*(C'\fR. Only the UNIX permissions and the sticky/setuid/setgid bits can be copied. .ie n .IP """xattributes""" 4 .el .IP \f(CWxattributes\fR 4 .IX Item "xattributes" Copy the Linux extended attributes (xattrs) from \f(CW\*(C`source\*(C'\fR to \f(CW\*(C`destination\*(C'\fR. This flag does nothing if the \fIlinuxxattrs\fR feature is not available (see \f(CW\*(C`$g\->feature_available\*(C'\fR). .ie n .IP """ownership""" 4 .el .IP \f(CWownership\fR 4 .IX Item "ownership" Copy the owner uid and the group gid of \f(CW\*(C`source\*(C'\fR to \f(CW\*(C`destination\*(C'\fR. .ie n .IP """all""" 4 .el .IP \f(CWall\fR 4 .IX Item "all" Copy \fBall\fR the attributes from \f(CW\*(C`source\*(C'\fR to \f(CW\*(C`destination\*(C'\fR. Enabling it enables all the other flags, if they are not specified already. .RE .RS 4 .RE .ie n .IP "$g\->copy_device_to_device ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" 4 .el .IP "\f(CW$g\fR\->copy_device_to_device ($src, \f(CW$dest\fR [, srcoffset => \f(CW$srcoffset\fR] [, destoffset => \f(CW$destoffset\fR] [, size => \f(CW$size\fR] [, sparse => \f(CW$sparse\fR] [, append => \f(CW$append\fR]);" 4 .IX Item "$g->copy_device_to_device ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" The four calls \f(CW\*(C`$g\->copy_device_to_device\*(C'\fR, \&\f(CW\*(C`$g\->copy_device_to_file\*(C'\fR, \&\f(CW\*(C`$g\->copy_file_to_device\*(C'\fR, and \&\f(CW\*(C`$g\->copy_file_to_file\*(C'\fR let you copy from a source (device|file) to a destination (device|file). .Sp Partial copies can be made since you can specify optionally the source offset, destination offset and size to copy. These values are all specified in bytes. If not given, the offsets both default to zero, and the size defaults to copying as much as possible until we hit the end of the source. .Sp The source and destination may be the same object. However overlapping regions may not be copied correctly. .Sp If the destination is a file, it is created if required. If the destination file is not large enough, it is extended. .Sp If the destination is a file and the \f(CW\*(C`append\*(C'\fR flag is not set, then the destination file is truncated. If the \f(CW\*(C`append\*(C'\fR flag is set, then the copy appends to the destination file. The \f(CW\*(C`append\*(C'\fR flag currently cannot be set for devices. .Sp If the \f(CW\*(C`sparse\*(C'\fR flag is true then the call avoids writing blocks that contain only zeroes, which can help in some situations where the backing disk is thin-provisioned. Note that unless the target is already zeroed, using this option will result in incorrect copying. .ie n .IP "$g\->copy_device_to_file ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" 4 .el .IP "\f(CW$g\fR\->copy_device_to_file ($src, \f(CW$dest\fR [, srcoffset => \f(CW$srcoffset\fR] [, destoffset => \f(CW$destoffset\fR] [, size => \f(CW$size\fR] [, sparse => \f(CW$sparse\fR] [, append => \f(CW$append\fR]);" 4 .IX Item "$g->copy_device_to_file ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" See \f(CW\*(C`$g\->copy_device_to_device\*(C'\fR for a general overview of this call. .ie n .IP "$g\->copy_file_to_device ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" 4 .el .IP "\f(CW$g\fR\->copy_file_to_device ($src, \f(CW$dest\fR [, srcoffset => \f(CW$srcoffset\fR] [, destoffset => \f(CW$destoffset\fR] [, size => \f(CW$size\fR] [, sparse => \f(CW$sparse\fR] [, append => \f(CW$append\fR]);" 4 .IX Item "$g->copy_file_to_device ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" See \f(CW\*(C`$g\->copy_device_to_device\*(C'\fR for a general overview of this call. .ie n .IP "$g\->copy_file_to_file ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" 4 .el .IP "\f(CW$g\fR\->copy_file_to_file ($src, \f(CW$dest\fR [, srcoffset => \f(CW$srcoffset\fR] [, destoffset => \f(CW$destoffset\fR] [, size => \f(CW$size\fR] [, sparse => \f(CW$sparse\fR] [, append => \f(CW$append\fR]);" 4 .IX Item "$g->copy_file_to_file ($src, $dest [, srcoffset => $srcoffset] [, destoffset => $destoffset] [, size => $size] [, sparse => $sparse] [, append => $append]);" See \f(CW\*(C`$g\->copy_device_to_device\*(C'\fR for a general overview of this call. .Sp This is \fBnot\fR the function you want for copying files. This is for copying blocks within existing files. See \f(CW\*(C`$g\->cp\*(C'\fR, \&\f(CW\*(C`$g\->cp_a\*(C'\fR and \f(CW\*(C`$g\->mv\*(C'\fR for general file copying and moving functions. .ie n .IP "$g\->copy_in ($localpath, $remotedir);" 4 .el .IP "\f(CW$g\fR\->copy_in ($localpath, \f(CW$remotedir\fR);" 4 .IX Item "$g->copy_in ($localpath, $remotedir);" \&\f(CW\*(C`$g\->copy_in\*(C'\fR copies local files or directories recursively into the disk image, placing them in the directory called \f(CW\*(C`remotedir\*(C'\fR (which must exist). .Sp Wildcards cannot be used. .ie n .IP "$g\->copy_out ($remotepath, $localdir);" 4 .el .IP "\f(CW$g\fR\->copy_out ($remotepath, \f(CW$localdir\fR);" 4 .IX Item "$g->copy_out ($remotepath, $localdir);" \&\f(CW\*(C`$g\->copy_out\*(C'\fR copies remote files or directories recursively out of the disk image, placing them on the host disk in a local directory called \f(CW\*(C`localdir\*(C'\fR (which must exist). .Sp To download to the current directory, use \f(CW\*(C`.\*(C'\fR as in: .Sp .Vb 1 \& C<$g\-Ecopy_out> /home . .Ve .Sp Wildcards cannot be used. .ie n .IP "$g\->copy_size ($src, $dest, $size);" 4 .el .IP "\f(CW$g\fR\->copy_size ($src, \f(CW$dest\fR, \f(CW$size\fR);" 4 .IX Item "$g->copy_size ($src, $dest, $size);" This command copies exactly \f(CW\*(C`size\*(C'\fR bytes from one source device or file \f(CW\*(C`src\*(C'\fR to another destination device or file \f(CW\*(C`dest\*(C'\fR. .Sp Note this will fail if the source is too short or if the destination is not large enough. .Sp \&\fIThis function is deprecated.\fR In new code, use the "copy_device_to_device" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->cp ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->cp ($src, \f(CW$dest\fR);" 4 .IX Item "$g->cp ($src, $dest);" This copies a file from \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR where \f(CW\*(C`dest\*(C'\fR is either a destination filename or destination directory. .ie n .IP "$g\->cp_a ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->cp_a ($src, \f(CW$dest\fR);" 4 .IX Item "$g->cp_a ($src, $dest);" This copies a file or directory from \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR recursively using the \f(CW\*(C`cp \-a\*(C'\fR command. .ie n .IP "$g\->cp_r ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->cp_r ($src, \f(CW$dest\fR);" 4 .IX Item "$g->cp_r ($src, $dest);" This copies a file or directory from \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR recursively using the \f(CW\*(C`cp \-rP\*(C'\fR command. .Sp Most users should use \f(CW\*(C`$g\->cp_a\*(C'\fR instead. This command is useful when you don't want to preserve permissions, because the target filesystem does not support it (primarily when writing to DOS FAT filesystems). .ie n .IP "$g\->cpio_out ($directory, $cpiofile [, format => $format]);" 4 .el .IP "\f(CW$g\fR\->cpio_out ($directory, \f(CW$cpiofile\fR [, format => \f(CW$format\fR]);" 4 .IX Item "$g->cpio_out ($directory, $cpiofile [, format => $format]);" This command packs the contents of \fIdirectory\fR and downloads it to local file \f(CW\*(C`cpiofile\*(C'\fR. .Sp The optional \f(CW\*(C`format\*(C'\fR parameter can be used to select the format. Only the following formats are currently permitted: .RS 4 .ie n .IP """newc""" 4 .el .IP \f(CWnewc\fR 4 .IX Item "newc" New (SVR4) portable format. This format happens to be compatible with the cpio-like format used by the Linux kernel for initramfs. .Sp This is the default format. .ie n .IP """crc""" 4 .el .IP \f(CWcrc\fR 4 .IX Item "crc" New (SVR4) portable format with a checksum. .RE .RS 4 .RE .ie n .IP "$g\->cryptsetup_close ($device);" 4 .el .IP "\f(CW$g\fR\->cryptsetup_close ($device);" 4 .IX Item "$g->cryptsetup_close ($device);" This closes an encrypted device that was created earlier by \&\f(CW\*(C`$g\->cryptsetup_open\*(C'\fR. The \f(CW\*(C`device\*(C'\fR parameter must be the name of the mapping device (ie. \fI/dev/mapper/mapname\fR) and \fInot\fR the name of the underlying block device. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->cryptsetup_open ($device, $key, $mapname [, readonly => $readonly] [, crypttype => $crypttype] [, cipher => $cipher]);" 4 .el .IP "\f(CW$g\fR\->cryptsetup_open ($device, \f(CW$key\fR, \f(CW$mapname\fR [, readonly => \f(CW$readonly\fR] [, crypttype => \f(CW$crypttype\fR] [, cipher => \f(CW$cipher\fR]);" 4 .IX Item "$g->cryptsetup_open ($device, $key, $mapname [, readonly => $readonly] [, crypttype => $crypttype] [, cipher => $cipher]);" This command opens a block device which has been encrypted according to the Linux Unified Key Setup (LUKS) standard, Windows BitLocker, or some other types. .Sp \&\f(CW\*(C`device\*(C'\fR is the encrypted block device or partition. .Sp The caller must supply one of the keys associated with the encrypted block device, in the \f(CW\*(C`key\*(C'\fR parameter. .Sp This creates a new block device called \fI/dev/mapper/mapname\fR. Reads and writes to this block device are decrypted from and encrypted to the underlying \f(CW\*(C`device\*(C'\fR respectively. .Sp \&\f(CW\*(C`mapname\*(C'\fR cannot be \f(CW"control"\fR because that name is reserved by device-mapper. .Sp If the optional \f(CW\*(C`crypttype\*(C'\fR parameter is not present then libguestfs tries to guess the correct type (for example LUKS or BitLocker). However you can override this by specifying one of the following types: .RS 4 .ie n .IP """luks""" 4 .el .IP \f(CWluks\fR 4 .IX Item "luks" A Linux LUKS device. .ie n .IP """bitlk""" 4 .el .IP \f(CWbitlk\fR 4 .IX Item "bitlk" A Windows BitLocker device. .RE .RS 4 .Sp The optional \f(CW\*(C`readonly\*(C'\fR flag, if set to true, creates a read-only mapping. .Sp The optional \f(CW\*(C`cipher\*(C'\fR parameter allows specifying which cipher to use. .Sp If this block device contains LVM volume groups, then calling \f(CW\*(C`$g\->lvm_scan\*(C'\fR with the \f(CW\*(C`activate\*(C'\fR parameter \f(CW\*(C`true\*(C'\fR will make them visible. .Sp Use \f(CW\*(C`$g\->list_dm_devices\*(C'\fR to list all device mapper devices. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->dd ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->dd ($src, \f(CW$dest\fR);" 4 .IX Item "$g->dd ($src, $dest);" This command copies from one source device or file \f(CW\*(C`src\*(C'\fR to another destination device or file \f(CW\*(C`dest\*(C'\fR. Normally you would use this to copy to or from a device or partition, for example to duplicate a filesystem. .Sp If the destination is a device, it must be as large or larger than the source file or device, otherwise the copy will fail. This command cannot do partial copies (see \f(CW\*(C`$g\->copy_device_to_device\*(C'\fR). .Sp \&\fIThis function is deprecated.\fR In new code, use the "copy_device_to_device" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$index = $g\->device_index ($device);" 4 .el .IP "\f(CW$index\fR = \f(CW$g\fR\->device_index ($device);" 4 .IX Item "$index = $g->device_index ($device);" This function takes a device name (eg. "/dev/sdb") and returns the index of the device in the list of devices. .Sp Index numbers start from 0. The named device must exist, for example as a string returned from \f(CW\*(C`$g\->list_devices\*(C'\fR. .Sp See also \f(CW\*(C`$g\->list_devices\*(C'\fR, \f(CW\*(C`$g\->part_to_dev\*(C'\fR, \&\f(CW\*(C`$g\->device_name\*(C'\fR. .ie n .IP "$name = $g\->device_name ($index);" 4 .el .IP "\f(CW$name\fR = \f(CW$g\fR\->device_name ($index);" 4 .IX Item "$name = $g->device_name ($index);" This function takes a device index and returns the device name. For example index \f(CW0\fR will return the string \f(CW\*(C`/dev/sda\*(C'\fR. .Sp The drive index must have been added to the handle. .Sp See also \f(CW\*(C`$g\->list_devices\*(C'\fR, \f(CW\*(C`$g\->part_to_dev\*(C'\fR, \&\f(CW\*(C`$g\->device_index\*(C'\fR. .ie n .IP "$output = $g\->df ();" 4 .el .IP "\f(CW$output\fR = \f(CW$g\fR\->df ();" 4 .IX Item "$output = $g->df ();" This command runs the \fBdf\fR\|(1) command to report disk space used. .Sp This command is mostly useful for interactive sessions. It is \fInot\fR intended that you try to parse the output string. Use \f(CW\*(C`$g\->statvfs\*(C'\fR from programs. .ie n .IP "$output = $g\->df_h ();" 4 .el .IP "\f(CW$output\fR = \f(CW$g\fR\->df_h ();" 4 .IX Item "$output = $g->df_h ();" This command runs the \f(CW\*(C`df \-h\*(C'\fR command to report disk space used in human-readable format. .Sp This command is mostly useful for interactive sessions. It is \fInot\fR intended that you try to parse the output string. Use \f(CW\*(C`$g\->statvfs\*(C'\fR from programs. .ie n .IP "$g\->disk_create ($filename, $format, $size [, backingfile => $backingfile] [, backingformat => $backingformat] [, preallocation => $preallocation] [, compat => $compat] [, clustersize => $clustersize]);" 4 .el .IP "\f(CW$g\fR\->disk_create ($filename, \f(CW$format\fR, \f(CW$size\fR [, backingfile => \f(CW$backingfile\fR] [, backingformat => \f(CW$backingformat\fR] [, preallocation => \f(CW$preallocation\fR] [, compat => \f(CW$compat\fR] [, clustersize => \f(CW$clustersize\fR]);" 4 .IX Item "$g->disk_create ($filename, $format, $size [, backingfile => $backingfile] [, backingformat => $backingformat] [, preallocation => $preallocation] [, compat => $compat] [, clustersize => $clustersize]);" Create a blank disk image called \fIfilename\fR (a host file) with format \f(CW\*(C`format\*(C'\fR (usually \f(CW\*(C`raw\*(C'\fR or \f(CW\*(C`qcow2\*(C'\fR). The size is \f(CW\*(C`size\*(C'\fR bytes. .Sp If used with the optional \f(CW\*(C`backingfile\*(C'\fR parameter, then a snapshot is created on top of the backing file. In this case, \f(CW\*(C`size\*(C'\fR must be passed as \f(CW\-1\fR. The size of the snapshot is the same as the size of the backing file, which is discovered automatically. You are encouraged to also pass \f(CW\*(C`backingformat\*(C'\fR to describe the format of \f(CW\*(C`backingfile\*(C'\fR. .Sp If \fIfilename\fR refers to a block device, then the device is formatted. The \f(CW\*(C`size\*(C'\fR is ignored since block devices have an intrinsic size. .Sp The other optional parameters are: .RS 4 .ie n .IP """preallocation""" 4 .el .IP \f(CWpreallocation\fR 4 .IX Item "preallocation" If format is \f(CW\*(C`raw\*(C'\fR, then this can be either \f(CW\*(C`off\*(C'\fR (or \f(CW\*(C`sparse\*(C'\fR) or \f(CW\*(C`full\*(C'\fR to create a sparse or fully allocated file respectively. The default is \f(CW\*(C`off\*(C'\fR. .Sp If format is \f(CW\*(C`qcow2\*(C'\fR, then this can be \f(CW\*(C`off\*(C'\fR (or \f(CW\*(C`sparse\*(C'\fR), \&\f(CW\*(C`metadata\*(C'\fR or \f(CW\*(C`full\*(C'\fR. Preallocating metadata can be faster when doing lots of writes, but uses more space. The default is \f(CW\*(C`off\*(C'\fR. .ie n .IP """compat""" 4 .el .IP \f(CWcompat\fR 4 .IX Item "compat" \&\f(CW\*(C`qcow2\*(C'\fR only: Pass the string \f(CW1.1\fR to use the advanced qcow2 format supported by qemu ≥ 1.1. .ie n .IP """clustersize""" 4 .el .IP \f(CWclustersize\fR 4 .IX Item "clustersize" \&\f(CW\*(C`qcow2\*(C'\fR only: Change the qcow2 cluster size. The default is 65536 (bytes) and this setting may be any power of two between 512 and 2097152. .RE .RS 4 .Sp Note that this call does not add the new disk to the handle. You may need to call \f(CW\*(C`$g\->add_drive_opts\*(C'\fR separately. .RE .ie n .IP "$format = $g\->disk_format ($filename);" 4 .el .IP "\f(CW$format\fR = \f(CW$g\fR\->disk_format ($filename);" 4 .IX Item "$format = $g->disk_format ($filename);" Detect and return the format of the disk image called \fIfilename\fR. \&\fIfilename\fR can also be a host device, etc. If the format of the image could not be detected, then \f(CW"unknown"\fR is returned. .Sp Note that detecting the disk format can be insecure under some circumstances. See "CVE\-2010\-3851" in \fBguestfs\fR\|(3). .Sp See also: "DISK IMAGE FORMATS" in \fBguestfs\fR\|(3) .ie n .IP "$backingfile = $g\->disk_has_backing_file ($filename);" 4 .el .IP "\f(CW$backingfile\fR = \f(CW$g\fR\->disk_has_backing_file ($filename);" 4 .IX Item "$backingfile = $g->disk_has_backing_file ($filename);" Detect and return whether the disk image \fIfilename\fR has a backing file. .Sp Note that detecting disk features can be insecure under some circumstances. See "CVE\-2010\-3851" in \fBguestfs\fR\|(3). .ie n .IP "$size = $g\->disk_virtual_size ($filename);" 4 .el .IP "\f(CW$size\fR = \f(CW$g\fR\->disk_virtual_size ($filename);" 4 .IX Item "$size = $g->disk_virtual_size ($filename);" Detect and return the virtual size in bytes of the disk image called \fIfilename\fR. .Sp Note that detecting disk features can be insecure under some circumstances. See "CVE\-2010\-3851" in \fBguestfs\fR\|(3). .ie n .IP "$kmsgs = $g\->dmesg ();" 4 .el .IP "\f(CW$kmsgs\fR = \f(CW$g\fR\->dmesg ();" 4 .IX Item "$kmsgs = $g->dmesg ();" This returns the kernel messages (\fBdmesg\fR\|(1) output) from the guest kernel. This is sometimes useful for extended debugging of problems. .Sp Another way to get the same information is to enable verbose messages with \f(CW\*(C`$g\->set_verbose\*(C'\fR or by setting the environment variable \f(CW\*(C`LIBGUESTFS_DEBUG=1\*(C'\fR before running the program. .ie n .IP "$g\->download ($remotefilename, $filename);" 4 .el .IP "\f(CW$g\fR\->download ($remotefilename, \f(CW$filename\fR);" 4 .IX Item "$g->download ($remotefilename, $filename);" Download file \fIremotefilename\fR and save it as \fIfilename\fR on the local machine. .Sp \&\fIfilename\fR can also be a named pipe. .Sp See also \f(CW\*(C`$g\->upload\*(C'\fR, \f(CW\*(C`$g\->cat\*(C'\fR. .ie n .IP "$g\->download_blocks ($device, $start, $stop, $filename [, unallocated => $unallocated]);" 4 .el .IP "\f(CW$g\fR\->download_blocks ($device, \f(CW$start\fR, \f(CW$stop\fR, \f(CW$filename\fR [, unallocated => \f(CW$unallocated\fR]);" 4 .IX Item "$g->download_blocks ($device, $start, $stop, $filename [, unallocated => $unallocated]);" Download the data units from \fIstart\fR address to \fIstop\fR from the disk partition (eg. \fI/dev/sda1\fR) and save them as \fIfilename\fR on the local machine. .Sp The use of this API on sparse disk image formats such as QCOW, may result in large zero-filled files downloaded on the host. .Sp The size of a data unit varies across filesystem implementations. On NTFS filesystems data units are referred as clusters while on ExtX ones they are referred as fragments. .Sp If the optional \f(CW\*(C`unallocated\*(C'\fR flag is true (default is false), only the unallocated blocks will be extracted. This is useful to detect hidden data or to retrieve deleted files which data units have not been overwritten yet. .Sp This function depends on the feature \f(CW\*(C`sleuthkit\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->download_inode ($device, $inode, $filename);" 4 .el .IP "\f(CW$g\fR\->download_inode ($device, \f(CW$inode\fR, \f(CW$filename\fR);" 4 .IX Item "$g->download_inode ($device, $inode, $filename);" Download a file given its inode from the disk partition (eg. \fI/dev/sda1\fR) and save it as \fIfilename\fR on the local machine. .Sp It is not required to mount the disk to run this command. .Sp The command is capable of downloading deleted or inaccessible files. .Sp This function depends on the feature \f(CW\*(C`sleuthkit\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->download_offset ($remotefilename, $filename, $offset, $size);" 4 .el .IP "\f(CW$g\fR\->download_offset ($remotefilename, \f(CW$filename\fR, \f(CW$offset\fR, \f(CW$size\fR);" 4 .IX Item "$g->download_offset ($remotefilename, $filename, $offset, $size);" Download file \fIremotefilename\fR and save it as \fIfilename\fR on the local machine. .Sp \&\fIremotefilename\fR is read for \f(CW\*(C`size\*(C'\fR bytes starting at \f(CW\*(C`offset\*(C'\fR (this region must be within the file or device). .Sp Note that there is no limit on the amount of data that can be downloaded with this call, unlike with \f(CW\*(C`$g\->pread\*(C'\fR, and this call always reads the full amount unless an error occurs. .Sp See also \f(CW\*(C`$g\->download\*(C'\fR, \f(CW\*(C`$g\->pread\*(C'\fR. .ie n .IP "$g\->drop_caches ($whattodrop);" 4 .el .IP "\f(CW$g\fR\->drop_caches ($whattodrop);" 4 .IX Item "$g->drop_caches ($whattodrop);" This instructs the guest kernel to drop its page cache, and/or dentries and inode caches. The parameter \f(CW\*(C`whattodrop\*(C'\fR tells the kernel what precisely to drop, see .Sp Setting \f(CW\*(C`whattodrop\*(C'\fR to 3 should drop everything. .Sp This automatically calls \fBsync\fR\|(2) before the operation, so that the maximum guest memory is freed. .ie n .IP "$sizekb = $g\->du ($path);" 4 .el .IP "\f(CW$sizekb\fR = \f(CW$g\fR\->du ($path);" 4 .IX Item "$sizekb = $g->du ($path);" This command runs the \f(CW\*(C`du \-s\*(C'\fR command to estimate file space usage for \f(CW\*(C`path\*(C'\fR. .Sp \&\f(CW\*(C`path\*(C'\fR can be a file or a directory. If \f(CW\*(C`path\*(C'\fR is a directory then the estimate includes the contents of the directory and all subdirectories (recursively). .Sp The result is the estimated size in \fIkilobytes\fR (ie. units of 1024 bytes). .ie n .IP "$g\->e2fsck ($device [, correct => $correct] [, forceall => $forceall]);" 4 .el .IP "\f(CW$g\fR\->e2fsck ($device [, correct => \f(CW$correct\fR] [, forceall => \f(CW$forceall\fR]);" 4 .IX Item "$g->e2fsck ($device [, correct => $correct] [, forceall => $forceall]);" This runs the ext2/ext3 filesystem checker on \f(CW\*(C`device\*(C'\fR. It can take the following optional arguments: .RS 4 .ie n .IP """correct""" 4 .el .IP \f(CWcorrect\fR 4 .IX Item "correct" Automatically repair the file system. This option will cause e2fsck to automatically fix any filesystem problems that can be safely fixed without human intervention. .Sp This option may not be specified at the same time as the \f(CW\*(C`forceall\*(C'\fR option. .ie n .IP """forceall""" 4 .el .IP \f(CWforceall\fR 4 .IX Item "forceall" Assume an answer of ‘yes’ to all questions; allows e2fsck to be used non-interactively. .Sp This option may not be specified at the same time as the \f(CW\*(C`correct\*(C'\fR option. .RE .RS 4 .RE .ie n .IP "$g\->e2fsck_f ($device);" 4 .el .IP "\f(CW$g\fR\->e2fsck_f ($device);" 4 .IX Item "$g->e2fsck_f ($device);" This runs \f(CW\*(C`e2fsck \-p \-f device\*(C'\fR, ie. runs the ext2/ext3 filesystem checker on \f(CW\*(C`device\*(C'\fR, noninteractively (\fI\-p\fR), even if the filesystem appears to be clean (\fI\-f\fR). .Sp \&\fIThis function is deprecated.\fR In new code, use the "e2fsck" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$output = $g\->echo_daemon (\e@words);" 4 .el .IP "\f(CW$output\fR = \f(CW$g\fR\->echo_daemon (\e@words);" 4 .IX Item "$output = $g->echo_daemon (@words);" This command concatenates the list of \f(CW\*(C`words\*(C'\fR passed with single spaces between them and returns the resulting string. .Sp You can use this command to test the connection through to the daemon. .Sp See also \f(CW\*(C`$g\->ping_daemon\*(C'\fR. .ie n .IP "@lines = $g\->egrep ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->egrep ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->egrep ($regex, $path);" This calls the external \fBegrep\fR\|(1) program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->egrepi ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->egrepi ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->egrepi ($regex, $path);" This calls the external \f(CW\*(C`egrep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$equality = $g\->equal ($file1, $file2);" 4 .el .IP "\f(CW$equality\fR = \f(CW$g\fR\->equal ($file1, \f(CW$file2\fR);" 4 .IX Item "$equality = $g->equal ($file1, $file2);" This compares the two files \fIfile1\fR and \fIfile2\fR and returns true if their content is exactly equal, or false otherwise. .Sp The external \fBcmp\fR\|(1) program is used for the comparison. .ie n .IP "$existsflag = $g\->exists ($path);" 4 .el .IP "\f(CW$existsflag\fR = \f(CW$g\fR\->exists ($path);" 4 .IX Item "$existsflag = $g->exists ($path);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a file, directory (or anything) with the given \f(CW\*(C`path\*(C'\fR name. .Sp See also \f(CW\*(C`$g\->is_file\*(C'\fR, \f(CW\*(C`$g\->is_dir\*(C'\fR, \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$g\->extlinux ($directory);" 4 .el .IP "\f(CW$g\fR\->extlinux ($directory);" 4 .IX Item "$g->extlinux ($directory);" Install the SYSLINUX bootloader on the device mounted at \fIdirectory\fR. Unlike \f(CW\*(C`$g\->syslinux\*(C'\fR which requires a FAT filesystem, this can be used on an ext2/3/4 or btrfs filesystem. .Sp The \fIdirectory\fR parameter can be either a mountpoint, or a directory within the mountpoint. .Sp You also have to mark the partition as "active" (\f(CW\*(C`$g\->part_set_bootable\*(C'\fR) and a Master Boot Record must be installed (eg. using \f(CW\*(C`$g\->pwrite_device\*(C'\fR) on the first sector of the whole disk. The SYSLINUX package comes with some suitable Master Boot Records. See the \fBextlinux\fR\|(1) man page for further information. .Sp Additional configuration can be supplied to SYSLINUX by placing a file called \fIextlinux.conf\fR on the filesystem under \fIdirectory\fR. For further information about the contents of this file, see \fBextlinux\fR\|(1). .Sp See also \f(CW\*(C`$g\->syslinux\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`extlinux\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->f2fs_expand ($device);" 4 .el .IP "\f(CW$g\fR\->f2fs_expand ($device);" 4 .IX Item "$g->f2fs_expand ($device);" This expands a f2fs filesystem to match the size of the underlying device. .Sp This function depends on the feature \f(CW\*(C`f2fs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->fallocate ($path, $len);" 4 .el .IP "\f(CW$g\fR\->fallocate ($path, \f(CW$len\fR);" 4 .IX Item "$g->fallocate ($path, $len);" This command preallocates a file (containing zero bytes) named \&\f(CW\*(C`path\*(C'\fR of size \f(CW\*(C`len\*(C'\fR bytes. If the file exists already, it is overwritten. .Sp Do not confuse this with the guestfish-specific \&\f(CW\*(C`alloc\*(C'\fR command which allocates a file in the host and attaches it as a device. .Sp \&\fIThis function is deprecated.\fR In new code, use the "fallocate64" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->fallocate64 ($path, $len);" 4 .el .IP "\f(CW$g\fR\->fallocate64 ($path, \f(CW$len\fR);" 4 .IX Item "$g->fallocate64 ($path, $len);" This command preallocates a file (containing zero bytes) named \&\f(CW\*(C`path\*(C'\fR of size \f(CW\*(C`len\*(C'\fR bytes. If the file exists already, it is overwritten. .Sp Note that this call allocates disk blocks for the file. To create a sparse file use \f(CW\*(C`$g\->truncate_size\*(C'\fR instead. .Sp The deprecated call \f(CW\*(C`$g\->fallocate\*(C'\fR does the same, but owing to an oversight it only allowed 30 bit lengths to be specified, effectively limiting the maximum size of files created through that call to 1GB. .Sp Do not confuse this with the guestfish-specific \&\f(CW\*(C`alloc\*(C'\fR and \f(CW\*(C`sparse\*(C'\fR commands which create a file in the host and attach it as a device. .ie n .IP "$isavailable = $g\->feature_available (\e@groups);" 4 .el .IP "\f(CW$isavailable\fR = \f(CW$g\fR\->feature_available (\e@groups);" 4 .IX Item "$isavailable = $g->feature_available (@groups);" This is the same as \f(CW\*(C`$g\->available\*(C'\fR, but unlike that call it returns a simple true/false boolean result, instead of throwing an exception if a feature is not found. For other documentation see \f(CW\*(C`$g\->available\*(C'\fR. .ie n .IP "@lines = $g\->fgrep ($pattern, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->fgrep ($pattern, \f(CW$path\fR);" 4 .IX Item "@lines = $g->fgrep ($pattern, $path);" This calls the external \fBfgrep\fR\|(1) program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->fgrepi ($pattern, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->fgrepi ($pattern, \f(CW$path\fR);" 4 .IX Item "@lines = $g->fgrepi ($pattern, $path);" This calls the external \f(CW\*(C`fgrep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$description = $g\->file ($path);" 4 .el .IP "\f(CW$description\fR = \f(CW$g\fR\->file ($path);" 4 .IX Item "$description = $g->file ($path);" This call uses the standard \fBfile\fR\|(1) command to determine the type or contents of the file. .Sp This call will also transparently look inside various types of compressed file. .Sp The filename is not prepended to the output (like the file command \fI\-b\fR option). .Sp The output depends on the output of the underlying \fBfile\fR\|(1) command and it can change in future in ways beyond our control. In other words, the output is not guaranteed by the ABI. .Sp See also: \fBfile\fR\|(1), \f(CW\*(C`$g\->vfs_type\*(C'\fR, \f(CW\*(C`$g\->lstat\*(C'\fR, \&\f(CW\*(C`$g\->is_file\*(C'\fR, \f(CW\*(C`$g\->is_blockdev\*(C'\fR (etc), \f(CW\*(C`$g\->is_zero\*(C'\fR. .ie n .IP "$arch = $g\->file_architecture ($filename);" 4 .el .IP "\f(CW$arch\fR = \f(CW$g\fR\->file_architecture ($filename);" 4 .IX Item "$arch = $g->file_architecture ($filename);" This detects the architecture of the binary \fIfilename\fR, and returns it if known. .Sp Currently defined architectures are: .RS 4 .IP """aarch64""" 4 .IX Item """aarch64""" 64 bit ARM. .IP """arm""" 4 .IX Item """arm""" 32 bit ARM. .IP """i386""" 4 .IX Item """i386""" This string is returned for all 32 bit i386, i486, i586, i686 binaries irrespective of the precise processor requirements of the binary. .IP """ia64""" 4 .IX Item """ia64""" Intel Itanium. .IP """ppc""" 4 .IX Item """ppc""" 32 bit Power PC. .IP """ppc64""" 4 .IX Item """ppc64""" 64 bit Power PC (big endian). .IP """ppc64le""" 4 .IX Item """ppc64le""" 64 bit Power PC (little endian). .IP """loongarch64""" 4 .IX Item """loongarch64""" 64 bit LoongArch64 (little endian). .IP """riscv32""" 4 .IX Item """riscv32""" .PD 0 .IP """riscv64""" 4 .IX Item """riscv64""" .IP """riscv128""" 4 .IX Item """riscv128""" .PD RISC-V 32\-, 64\- or 128\-bit variants. .IP """s390""" 4 .IX Item """s390""" 31 bit IBM S/390. .IP """s390x""" 4 .IX Item """s390x""" 64 bit IBM S/390. .IP """sparc""" 4 .IX Item """sparc""" 32 bit SPARC. .IP """sparc64""" 4 .IX Item """sparc64""" 64 bit SPARC V9 and above. .IP """x86_64""" 4 .IX Item """x86_64""" 64 bit x86\-64. .RE .RS 4 .Sp Libguestfs may return other architecture strings in future. .Sp The function works on at least the following types of files: .IP \(bu 4 many types of Un*x and Linux binary .IP \(bu 4 many types of Un*x and Linux shared library .IP \(bu 4 Windows Win32 and Win64 binaries .IP \(bu 4 Windows Win32 and Win64 DLLs .Sp Win32 binaries and DLLs return \f(CW\*(C`i386\*(C'\fR. .Sp Win64 binaries and DLLs return \f(CW\*(C`x86_64\*(C'\fR. .IP \(bu 4 Linux kernel modules .IP \(bu 4 Linux new-style initrd images .IP \(bu 4 some non\-x86 Linux vmlinuz kernels .RE .RS 4 .Sp What it can't do currently: .IP \(bu 4 static libraries (libfoo.a) .IP \(bu 4 Linux old-style initrd as compressed ext2 filesystem (RHEL 3) .IP \(bu 4 x86 Linux vmlinuz kernels .Sp x86 vmlinuz images (bzImage format) consist of a mix of 16\-, 32\- and compressed code, and are horribly hard to unpack. If you want to find the architecture of a kernel, use the architecture of the associated initrd or kernel module(s) instead. .RE .RS 4 .RE .ie n .IP "$size = $g\->filesize ($file);" 4 .el .IP "\f(CW$size\fR = \f(CW$g\fR\->filesize ($file);" 4 .IX Item "$size = $g->filesize ($file);" This command returns the size of \fIfile\fR in bytes. .Sp To get other stats about a file, use \f(CW\*(C`$g\->stat\*(C'\fR, \f(CW\*(C`$g\->lstat\*(C'\fR, \&\f(CW\*(C`$g\->is_dir\*(C'\fR, \f(CW\*(C`$g\->is_file\*(C'\fR etc. To get the size of block devices, use \f(CW\*(C`$g\->blockdev_getsize64\*(C'\fR. .ie n .IP "$fsavail = $g\->filesystem_available ($filesystem);" 4 .el .IP "\f(CW$fsavail\fR = \f(CW$g\fR\->filesystem_available ($filesystem);" 4 .IX Item "$fsavail = $g->filesystem_available ($filesystem);" Check whether libguestfs supports the named filesystem. The argument \f(CW\*(C`filesystem\*(C'\fR is a filesystem name, such as \&\f(CW\*(C`ext3\*(C'\fR. .Sp You must call \f(CW\*(C`$g\->launch\*(C'\fR before using this command. .Sp This is mainly useful as a negative test. If this returns true, it doesn't mean that a particular filesystem can be created or mounted, since filesystems can fail for other reasons such as it being a later version of the filesystem, or having incompatible features, or lacking the right mkfs.<\fIfs\fR> tool. .Sp See also \f(CW\*(C`$g\->available\*(C'\fR, \f(CW\*(C`$g\->feature_available\*(C'\fR, "AVAILABILITY" in \fBguestfs\fR\|(3). .ie n .IP "@dirents = $g\->filesystem_walk ($device);" 4 .el .IP "\f(CW@dirents\fR = \f(CW$g\fR\->filesystem_walk ($device);" 4 .IX Item "@dirents = $g->filesystem_walk ($device);" Walk through the internal structures of a disk partition (eg. \fI/dev/sda1\fR) in order to return a list of all the files and directories stored within. .Sp It is not necessary to mount the disk partition to run this command. .Sp All entries in the filesystem are returned. This function can list deleted or unaccessible files. The entries are \fInot\fR sorted. .Sp The \f(CW\*(C`tsk_dirent\*(C'\fR structure contains the following fields. .RS 4 .ie n .IP """tsk_inode""" 4 .el .IP \f(CWtsk_inode\fR 4 .IX Item "tsk_inode" Filesystem reference number of the node. It might be \f(CW0\fR if the node has been deleted. .ie n .IP """tsk_type""" 4 .el .IP \f(CWtsk_type\fR 4 .IX Item "tsk_type" Basic file type information. See below for a detailed list of values. .ie n .IP """tsk_size""" 4 .el .IP \f(CWtsk_size\fR 4 .IX Item "tsk_size" File size in bytes. It might be \f(CW\-1\fR if the node has been deleted. .ie n .IP """tsk_name""" 4 .el .IP \f(CWtsk_name\fR 4 .IX Item "tsk_name" The file path relative to its directory. .ie n .IP """tsk_flags""" 4 .el .IP \f(CWtsk_flags\fR 4 .IX Item "tsk_flags" Bitfield containing extra information regarding the entry. It contains the logical OR of the following values: .RS 4 .IP 0x0001 4 .IX Item "0x0001" If set to \f(CW1\fR, the file is allocated and visible within the filesystem. Otherwise, the file has been deleted. Under certain circumstances, the function \f(CW\*(C`download_inode\*(C'\fR can be used to recover deleted files. .IP 0x0002 4 .IX Item "0x0002" Filesystem such as NTFS and Ext2 or greater, separate the file name from the metadata structure. The bit is set to \f(CW1\fR when the file name is in an unallocated state and the metadata structure is in an allocated one. This generally implies the metadata has been reallocated to a new file. Therefore, information such as file type, file size, timestamps, number of links and symlink target might not correspond with the ones of the original deleted entry. .IP 0x0004 4 .IX Item "0x0004" The bit is set to \f(CW1\fR when the file is compressed using filesystem native compression support (NTFS). The API is not able to detect application level compression. .RE .RS 4 .RE .ie n .IP """tsk_atime_sec""" 4 .el .IP \f(CWtsk_atime_sec\fR 4 .IX Item "tsk_atime_sec" .PD 0 .ie n .IP """tsk_atime_nsec""" 4 .el .IP \f(CWtsk_atime_nsec\fR 4 .IX Item "tsk_atime_nsec" .ie n .IP """tsk_mtime_sec""" 4 .el .IP \f(CWtsk_mtime_sec\fR 4 .IX Item "tsk_mtime_sec" .ie n .IP """tsk_mtime_nsec""" 4 .el .IP \f(CWtsk_mtime_nsec\fR 4 .IX Item "tsk_mtime_nsec" .ie n .IP """tsk_ctime_sec""" 4 .el .IP \f(CWtsk_ctime_sec\fR 4 .IX Item "tsk_ctime_sec" .ie n .IP """tsk_ctime_nsec""" 4 .el .IP \f(CWtsk_ctime_nsec\fR 4 .IX Item "tsk_ctime_nsec" .ie n .IP """tsk_crtime_sec""" 4 .el .IP \f(CWtsk_crtime_sec\fR 4 .IX Item "tsk_crtime_sec" .ie n .IP """tsk_crtime_nsec""" 4 .el .IP \f(CWtsk_crtime_nsec\fR 4 .IX Item "tsk_crtime_nsec" .PD Respectively, access, modification, last status change and creation time in Unix format in seconds and nanoseconds. .ie n .IP """tsk_nlink""" 4 .el .IP \f(CWtsk_nlink\fR 4 .IX Item "tsk_nlink" Number of file names pointing to this entry. .ie n .IP """tsk_link""" 4 .el .IP \f(CWtsk_link\fR 4 .IX Item "tsk_link" If the entry is a symbolic link, this field will contain the path to the target file. .RE .RS 4 .Sp The \f(CW\*(C`tsk_type\*(C'\fR field will contain one of the following characters: .IP 'b' 4 .IX Item "'b'" Block special .IP 'c' 4 .IX Item "'c'" Char special .IP 'd' 4 .IX Item "'d'" Directory .IP 'f' 4 .IX Item "'f'" FIFO (named pipe) .IP 'l' 4 .IX Item "'l'" Symbolic link .IP 'r' 4 .IX Item "'r'" Regular file .IP 's' 4 .IX Item "'s'" Socket .IP 'h' 4 .IX Item "'h'" Shadow inode (Solaris) .IP 'w' 4 .IX Item "'w'" Whiteout inode (BSD) .IP 'u' 4 .IX Item "'u'" Unknown file type .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`libtsk\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->fill ($c, $len, $path);" 4 .el .IP "\f(CW$g\fR\->fill ($c, \f(CW$len\fR, \f(CW$path\fR);" 4 .IX Item "$g->fill ($c, $len, $path);" This command creates a new file called \f(CW\*(C`path\*(C'\fR. The initial content of the file is \f(CW\*(C`len\*(C'\fR octets of \f(CW\*(C`c\*(C'\fR, where \f(CW\*(C`c\*(C'\fR must be a number in the range \f(CW\*(C`[0..255]\*(C'\fR. .Sp To fill a file with zero bytes (sparsely), it is much more efficient to use \f(CW\*(C`$g\->truncate_size\*(C'\fR. To create a file with a pattern of repeating bytes use \f(CW\*(C`$g\->fill_pattern\*(C'\fR. .ie n .IP "$g\->fill_dir ($dir, $nr);" 4 .el .IP "\f(CW$g\fR\->fill_dir ($dir, \f(CW$nr\fR);" 4 .IX Item "$g->fill_dir ($dir, $nr);" This function, useful for testing filesystems, creates \f(CW\*(C`nr\*(C'\fR empty files in the directory \f(CW\*(C`dir\*(C'\fR with names \f(CW00000000\fR through \f(CW\*(C`nr\-1\*(C'\fR (ie. each file name is 8 digits long padded with zeroes). .ie n .IP "$g\->fill_pattern ($pattern, $len, $path);" 4 .el .IP "\f(CW$g\fR\->fill_pattern ($pattern, \f(CW$len\fR, \f(CW$path\fR);" 4 .IX Item "$g->fill_pattern ($pattern, $len, $path);" This function is like \f(CW\*(C`$g\->fill\*(C'\fR except that it creates a new file of length \f(CW\*(C`len\*(C'\fR containing the repeating pattern of bytes in \f(CW\*(C`pattern\*(C'\fR. The pattern is truncated if necessary to ensure the length of the file is exactly \f(CW\*(C`len\*(C'\fR bytes. .ie n .IP "@names = $g\->find ($directory);" 4 .el .IP "\f(CW@names\fR = \f(CW$g\fR\->find ($directory);" 4 .IX Item "@names = $g->find ($directory);" This command lists out all files and directories, recursively, starting at \fIdirectory\fR. It is essentially equivalent to running the shell command \f(CW\*(C`find directory \-print\*(C'\fR but some post-processing happens on the output, described below. .Sp This returns a list of strings \fIwithout any prefix\fR. Thus if the directory structure was: .Sp .Vb 3 \& /tmp/a \& /tmp/b \& /tmp/c/d .Ve .Sp then the returned list from \f(CW\*(C`$g\->find\*(C'\fR \fI/tmp\fR would be 4 elements: .Sp .Vb 4 \& a \& b \& c \& c/d .Ve .Sp If \fIdirectory\fR is not a directory, then this command returns an error. .Sp The returned list is sorted. .ie n .IP "$g\->find0 ($directory, $files);" 4 .el .IP "\f(CW$g\fR\->find0 ($directory, \f(CW$files\fR);" 4 .IX Item "$g->find0 ($directory, $files);" This command lists out all files and directories, recursively, starting at \fIdirectory\fR, placing the resulting list in the external file called \fIfiles\fR. .Sp This command works the same way as \f(CW\*(C`$g\->find\*(C'\fR with the following exceptions: .RS 4 .IP \(bu 4 The resulting list is written to an external file. .IP \(bu 4 Items (filenames) in the result are separated by \f(CW\*(C`\e0\*(C'\fR characters. See \fBfind\fR\|(1) option \fI\-print0\fR. .IP \(bu 4 The result list is not sorted. .RE .RS 4 .RE .ie n .IP "@dirents = $g\->find_inode ($device, $inode);" 4 .el .IP "\f(CW@dirents\fR = \f(CW$g\fR\->find_inode ($device, \f(CW$inode\fR);" 4 .IX Item "@dirents = $g->find_inode ($device, $inode);" Searches all the entries associated with the given inode. .Sp For each entry, a \f(CW\*(C`tsk_dirent\*(C'\fR structure is returned. See \f(CW\*(C`filesystem_walk\*(C'\fR for more information about \f(CW\*(C`tsk_dirent\*(C'\fR structures. .Sp This function depends on the feature \f(CW\*(C`libtsk\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$device = $g\->findfs_label ($label);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->findfs_label ($label);" 4 .IX Item "$device = $g->findfs_label ($label);" This command searches the filesystems and returns the one which has the given label. An error is returned if no such filesystem can be found. .Sp To find the label of a filesystem, use \f(CW\*(C`$g\->vfs_label\*(C'\fR. .ie n .IP "$device = $g\->findfs_partlabel ($label);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->findfs_partlabel ($label);" 4 .IX Item "$device = $g->findfs_partlabel ($label);" This command searches the partitions and returns the one which has the given label. An error is returned if no such partition can be found. .Sp To find the label of a partition, use \f(CW\*(C`$g\->blkid\*(C'\fR (\f(CW\*(C`PART_ENTRY_NAME\*(C'\fR). .ie n .IP "$device = $g\->findfs_partuuid ($uuid);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->findfs_partuuid ($uuid);" 4 .IX Item "$device = $g->findfs_partuuid ($uuid);" This command searches the partitions and returns the one which has the given partition UUID. An error is returned if no such partition can be found. .Sp To find the UUID of a partition, use \f(CW\*(C`$g\->blkid\*(C'\fR (\f(CW\*(C`PART_ENTRY_UUID\*(C'\fR). .ie n .IP "$device = $g\->findfs_uuid ($uuid);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->findfs_uuid ($uuid);" 4 .IX Item "$device = $g->findfs_uuid ($uuid);" This command searches the filesystems and returns the one which has the given UUID. An error is returned if no such filesystem can be found. .Sp To find the UUID of a filesystem, use \f(CW\*(C`$g\->vfs_uuid\*(C'\fR. .ie n .IP "$status = $g\->fsck ($fstype, $device);" 4 .el .IP "\f(CW$status\fR = \f(CW$g\fR\->fsck ($fstype, \f(CW$device\fR);" 4 .IX Item "$status = $g->fsck ($fstype, $device);" This runs the filesystem checker (fsck) on \f(CW\*(C`device\*(C'\fR which should have filesystem type \f(CW\*(C`fstype\*(C'\fR. .Sp The returned integer is the status. See \fBfsck\fR\|(8) for the list of status codes from \f(CW\*(C`fsck\*(C'\fR. .Sp Notes: .RS 4 .IP \(bu 4 Multiple status codes can be summed together. .IP \(bu 4 A non-zero return code can mean "success", for example if errors have been corrected on the filesystem. .IP \(bu 4 Checking or repairing NTFS volumes is not supported (by linux-ntfs). .RE .RS 4 .Sp This command is entirely equivalent to running \f(CW\*(C`fsck \-a \-t fstype device\*(C'\fR. .RE .ie n .IP "$g\->fstrim ($mountpoint [, offset => $offset] [, length => $length] [, minimumfreeextent => $minimumfreeextent]);" 4 .el .IP "\f(CW$g\fR\->fstrim ($mountpoint [, offset => \f(CW$offset\fR] [, length => \f(CW$length\fR] [, minimumfreeextent => \f(CW$minimumfreeextent\fR]);" 4 .IX Item "$g->fstrim ($mountpoint [, offset => $offset] [, length => $length] [, minimumfreeextent => $minimumfreeextent]);" Trim the free space in the filesystem mounted on \f(CW\*(C`mountpoint\*(C'\fR. The filesystem must be mounted read-write. .Sp The filesystem contents are not affected, but any free space in the filesystem is "trimmed", that is, given back to the host device, thus making disk images more sparse, allowing unused space in qcow2 files to be reused, etc. .Sp This operation requires support in libguestfs, the mounted filesystem, the host filesystem, qemu and the host kernel. If this support isn't present it may give an error or even appear to run but do nothing. .Sp In the case where the kernel vfs driver does not support trimming, this call will fail with errno set to \f(CW\*(C`ENOTSUP\*(C'\fR. Currently this happens when trying to trim FAT filesystems. .Sp See also \f(CW\*(C`$g\->zero_free_space\*(C'\fR. That is a slightly different operation that turns free space in the filesystem into zeroes. It is valid to call \f(CW\*(C`$g\->fstrim\*(C'\fR either instead of, or after calling \f(CW\*(C`$g\->zero_free_space\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`fstrim\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$append = $g\->get_append ();" 4 .el .IP "\f(CW$append\fR = \f(CW$g\fR\->get_append ();" 4 .IX Item "$append = $g->get_append ();" Return the additional kernel options which are added to the libguestfs appliance kernel command line. .Sp If \f(CW\*(C`NULL\*(C'\fR then no options are added. .ie n .IP "$backend = $g\->get_attach_method ();" 4 .el .IP "\f(CW$backend\fR = \f(CW$g\fR\->get_attach_method ();" 4 .IX Item "$backend = $g->get_attach_method ();" Return the current backend. .Sp See \f(CW\*(C`$g\->set_backend\*(C'\fR and "BACKEND" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "get_backend" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$autosync = $g\->get_autosync ();" 4 .el .IP "\f(CW$autosync\fR = \f(CW$g\fR\->get_autosync ();" 4 .IX Item "$autosync = $g->get_autosync ();" Get the autosync flag. .ie n .IP "$backend = $g\->get_backend ();" 4 .el .IP "\f(CW$backend\fR = \f(CW$g\fR\->get_backend ();" 4 .IX Item "$backend = $g->get_backend ();" Return the current backend. .Sp This handle property was previously called the "attach method". .Sp See \f(CW\*(C`$g\->set_backend\*(C'\fR and "BACKEND" in \fBguestfs\fR\|(3). .ie n .IP "$val = $g\->get_backend_setting ($name);" 4 .el .IP "\f(CW$val\fR = \f(CW$g\fR\->get_backend_setting ($name);" 4 .IX Item "$val = $g->get_backend_setting ($name);" Find a backend setting string which is either \f(CW"name"\fR or begins with \f(CW"name="\fR. If \f(CW"name"\fR, this returns the string \f(CW"1"\fR. If \f(CW"name="\fR, this returns the part after the equals sign (which may be an empty string). .Sp If no such setting is found, this function throws an error. The errno (see \f(CW\*(C`$g\->last_errno\*(C'\fR) will be \f(CW\*(C`ESRCH\*(C'\fR in this case. .Sp See "BACKEND" in \fBguestfs\fR\|(3), "BACKEND SETTINGS" in \fBguestfs\fR\|(3). .ie n .IP "@settings = $g\->get_backend_settings ();" 4 .el .IP "\f(CW@settings\fR = \f(CW$g\fR\->get_backend_settings ();" 4 .IX Item "@settings = $g->get_backend_settings ();" Return the current backend settings. .Sp This call returns all backend settings strings. If you want to find a single backend setting, see \f(CW\*(C`$g\->get_backend_setting\*(C'\fR. .Sp See "BACKEND" in \fBguestfs\fR\|(3), "BACKEND SETTINGS" in \fBguestfs\fR\|(3). .ie n .IP "$cachedir = $g\->get_cachedir ();" 4 .el .IP "\f(CW$cachedir\fR = \f(CW$g\fR\->get_cachedir ();" 4 .IX Item "$cachedir = $g->get_cachedir ();" Get the directory used by the handle to store the appliance cache. .ie n .IP "$direct = $g\->get_direct ();" 4 .el .IP "\f(CW$direct\fR = \f(CW$g\fR\->get_direct ();" 4 .IX Item "$direct = $g->get_direct ();" Return the direct appliance mode flag. .Sp \&\fIThis function is deprecated.\fR In new code, use the "internal_get_console_socket" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$attrs = $g\->get_e2attrs ($file);" 4 .el .IP "\f(CW$attrs\fR = \f(CW$g\fR\->get_e2attrs ($file);" 4 .IX Item "$attrs = $g->get_e2attrs ($file);" This returns the file attributes associated with \fIfile\fR. .Sp The attributes are a set of bits associated with each inode which affect the behaviour of the file. The attributes are returned as a string of letters (described below). The string may be empty, indicating that no file attributes are set for this file. .Sp These attributes are only present when the file is located on an ext2/3/4 filesystem. Using this call on other filesystem types will result in an error. .Sp The characters (file attributes) in the returned string are currently: .RS 4 .IP 'A' 4 .IX Item "'A'" When the file is accessed, its atime is not modified. .IP 'a' 4 .IX Item "'a'" The file is append-only. .IP 'c' 4 .IX Item "'c'" The file is compressed on-disk. .IP 'D' 4 .IX Item "'D'" (Directories only.) Changes to this directory are written synchronously to disk. .IP 'd' 4 .IX Item "'d'" The file is not a candidate for backup (see \fBdump\fR\|(8)). .IP 'E' 4 .IX Item "'E'" The file has compression errors. .IP 'e' 4 .IX Item "'e'" The file is using extents. .IP 'h' 4 .IX Item "'h'" The file is storing its blocks in units of the filesystem blocksize instead of sectors. .IP 'I' 4 .IX Item "'I'" (Directories only.) The directory is using hashed trees. .IP 'i' 4 .IX Item "'i'" The file is immutable. It cannot be modified, deleted or renamed. No link can be created to this file. .IP 'j' 4 .IX Item "'j'" The file is data-journaled. .IP 's' 4 .IX Item "'s'" When the file is deleted, all its blocks will be zeroed. .IP 'S' 4 .IX Item "'S'" Changes to this file are written synchronously to disk. .IP 'T' 4 .IX Item "'T'" (Directories only.) This is a hint to the block allocator that subdirectories contained in this directory should be spread across blocks. If not present, the block allocator will try to group subdirectories together. .IP 't' 4 .IX Item "'t'" For a file, this disables tail-merging. (Not used by upstream implementations of ext2.) .IP 'u' 4 .IX Item "'u'" When the file is deleted, its blocks will be saved, allowing the file to be undeleted. .IP 'X' 4 .IX Item "'X'" The raw contents of the compressed file may be accessed. .IP 'Z' 4 .IX Item "'Z'" The compressed file is dirty. .RE .RS 4 .Sp More file attributes may be added to this list later. Not all file attributes may be set for all kinds of files. For detailed information, consult the \fBchattr\fR\|(1) man page. .Sp See also \f(CW\*(C`$g\->set_e2attrs\*(C'\fR. .Sp Don't confuse these attributes with extended attributes (see \f(CW\*(C`$g\->getxattr\*(C'\fR). .RE .ie n .IP "$generation = $g\->get_e2generation ($file);" 4 .el .IP "\f(CW$generation\fR = \f(CW$g\fR\->get_e2generation ($file);" 4 .IX Item "$generation = $g->get_e2generation ($file);" This returns the ext2 file generation of a file. The generation (which used to be called the "version") is a number associated with an inode. This is most commonly used by NFS servers. .Sp The generation is only present when the file is located on an ext2/3/4 filesystem. Using this call on other filesystem types will result in an error. .Sp See \f(CW\*(C`$g\->set_e2generation\*(C'\fR. .ie n .IP "$label = $g\->get_e2label ($device);" 4 .el .IP "\f(CW$label\fR = \f(CW$g\fR\->get_e2label ($device);" 4 .IX Item "$label = $g->get_e2label ($device);" This returns the ext2/3/4 filesystem label of the filesystem on \&\f(CW\*(C`device\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "vfs_label" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$uuid = $g\->get_e2uuid ($device);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->get_e2uuid ($device);" 4 .IX Item "$uuid = $g->get_e2uuid ($device);" This returns the ext2/3/4 filesystem UUID of the filesystem on \&\f(CW\*(C`device\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "vfs_uuid" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$hv = $g\->get_hv ();" 4 .el .IP "\f(CW$hv\fR = \f(CW$g\fR\->get_hv ();" 4 .IX Item "$hv = $g->get_hv ();" Return the current hypervisor binary. .Sp This is always non-NULL. If it wasn't set already, then this will return the default qemu binary name. .ie n .IP "$identifier = $g\->get_identifier ();" 4 .el .IP "\f(CW$identifier\fR = \f(CW$g\fR\->get_identifier ();" 4 .IX Item "$identifier = $g->get_identifier ();" Get the handle identifier. See \f(CW\*(C`$g\->set_identifier\*(C'\fR. .ie n .IP "$challenge = $g\->get_libvirt_requested_credential_challenge ($index);" 4 .el .IP "\f(CW$challenge\fR = \f(CW$g\fR\->get_libvirt_requested_credential_challenge ($index);" 4 .IX Item "$challenge = $g->get_libvirt_requested_credential_challenge ($index);" Get the challenge (provided by libvirt) for the \f(CW\*(C`index\*(C'\fR'th requested credential. If libvirt did not provide a challenge, this returns the empty string \f(CW""\fR. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .ie n .IP "$defresult = $g\->get_libvirt_requested_credential_defresult ($index);" 4 .el .IP "\f(CW$defresult\fR = \f(CW$g\fR\->get_libvirt_requested_credential_defresult ($index);" 4 .IX Item "$defresult = $g->get_libvirt_requested_credential_defresult ($index);" Get the default result (provided by libvirt) for the \f(CW\*(C`index\*(C'\fR'th requested credential. If libvirt did not provide a default result, this returns the empty string \f(CW""\fR. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .ie n .IP "$prompt = $g\->get_libvirt_requested_credential_prompt ($index);" 4 .el .IP "\f(CW$prompt\fR = \f(CW$g\fR\->get_libvirt_requested_credential_prompt ($index);" 4 .IX Item "$prompt = $g->get_libvirt_requested_credential_prompt ($index);" Get the prompt (provided by libvirt) for the \f(CW\*(C`index\*(C'\fR'th requested credential. If libvirt did not provide a prompt, this returns the empty string \f(CW""\fR. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .ie n .IP "@creds = $g\->get_libvirt_requested_credentials ();" 4 .el .IP "\f(CW@creds\fR = \f(CW$g\fR\->get_libvirt_requested_credentials ();" 4 .IX Item "@creds = $g->get_libvirt_requested_credentials ();" This should only be called during the event callback for events of type \f(CW\*(C`GUESTFS_EVENT_LIBVIRT_AUTH\*(C'\fR. .Sp Return the list of credentials requested by libvirt. Possible values are a subset of the strings provided when you called \&\f(CW\*(C`$g\->set_libvirt_supported_credentials\*(C'\fR. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .ie n .IP "$memsize = $g\->get_memsize ();" 4 .el .IP "\f(CW$memsize\fR = \f(CW$g\fR\->get_memsize ();" 4 .IX Item "$memsize = $g->get_memsize ();" This gets the memory size in megabytes allocated to the hypervisor. .Sp If \f(CW\*(C`$g\->set_memsize\*(C'\fR was not called on this handle, and if \f(CW\*(C`LIBGUESTFS_MEMSIZE\*(C'\fR was not set, then this returns the compiled-in default value for memsize. .Sp For more information on the architecture of libguestfs, see \fBguestfs\fR\|(3). .ie n .IP "$network = $g\->get_network ();" 4 .el .IP "\f(CW$network\fR = \f(CW$g\fR\->get_network ();" 4 .IX Item "$network = $g->get_network ();" This returns the enable network flag. .ie n .IP "$path = $g\->get_path ();" 4 .el .IP "\f(CW$path\fR = \f(CW$g\fR\->get_path ();" 4 .IX Item "$path = $g->get_path ();" Return the current search path. .Sp This is always non-NULL. If it wasn't set already, then this will return the default path. .ie n .IP "$pgroup = $g\->get_pgroup ();" 4 .el .IP "\f(CW$pgroup\fR = \f(CW$g\fR\->get_pgroup ();" 4 .IX Item "$pgroup = $g->get_pgroup ();" This returns the process group flag. .ie n .IP "$pid = $g\->get_pid ();" 4 .el .IP "\f(CW$pid\fR = \f(CW$g\fR\->get_pid ();" 4 .IX Item "$pid = $g->get_pid ();" Return the process ID of the hypervisor. If there is no hypervisor running, then this will return an error. .Sp This is an internal call used for debugging and testing. .ie n .IP "$program = $g\->get_program ();" 4 .el .IP "\f(CW$program\fR = \f(CW$g\fR\->get_program ();" 4 .IX Item "$program = $g->get_program ();" Get the program name. See \f(CW\*(C`$g\->set_program\*(C'\fR. .ie n .IP "$hv = $g\->get_qemu ();" 4 .el .IP "\f(CW$hv\fR = \f(CW$g\fR\->get_qemu ();" 4 .IX Item "$hv = $g->get_qemu ();" Return the current hypervisor binary (usually qemu). .Sp This is always non-NULL. If it wasn't set already, then this will return the default qemu binary name. .Sp \&\fIThis function is deprecated.\fR In new code, use the "get_hv" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$recoveryproc = $g\->get_recovery_proc ();" 4 .el .IP "\f(CW$recoveryproc\fR = \f(CW$g\fR\->get_recovery_proc ();" 4 .IX Item "$recoveryproc = $g->get_recovery_proc ();" Return the recovery process enabled flag. .ie n .IP "$selinux = $g\->get_selinux ();" 4 .el .IP "\f(CW$selinux\fR = \f(CW$g\fR\->get_selinux ();" 4 .IX Item "$selinux = $g->get_selinux ();" This returns the current setting of the selinux flag which is passed to the appliance at boot time. See \f(CW\*(C`$g\->set_selinux\*(C'\fR. .Sp For more information on the architecture of libguestfs, see \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "selinux_relabel" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$smp = $g\->get_smp ();" 4 .el .IP "\f(CW$smp\fR = \f(CW$g\fR\->get_smp ();" 4 .IX Item "$smp = $g->get_smp ();" This returns the number of virtual CPUs assigned to the appliance. .ie n .IP "$sockdir = $g\->get_sockdir ();" 4 .el .IP "\f(CW$sockdir\fR = \f(CW$g\fR\->get_sockdir ();" 4 .IX Item "$sockdir = $g->get_sockdir ();" Get the directory used by the handle to store temporary socket and PID files. .Sp This is different from \f(CW\*(C`$g\->get_tmpdir\*(C'\fR, as we need shorter paths for sockets (due to the limited buffers of filenames for UNIX sockets), and \f(CW\*(C`$g\->get_tmpdir\*(C'\fR may be too long for them. Furthermore, sockets and PID files must be accessible to such background services started by libguestfs that may not have permission to access the temporary directory returned by \f(CW\*(C`$g\->get_tmpdir\*(C'\fR. .Sp The environment variable \f(CW\*(C`XDG_RUNTIME_DIR\*(C'\fR controls the default value: If \f(CW\*(C`XDG_RUNTIME_DIR\*(C'\fR is set, then that is the default. Else \fI/tmp\fR is the default. .ie n .IP "$state = $g\->get_state ();" 4 .el .IP "\f(CW$state\fR = \f(CW$g\fR\->get_state ();" 4 .IX Item "$state = $g->get_state ();" This returns the current state as an opaque integer. This is only useful for printing debug and internal error messages. .Sp For more information on states, see \fBguestfs\fR\|(3). .ie n .IP "$tmpdir = $g\->get_tmpdir ();" 4 .el .IP "\f(CW$tmpdir\fR = \f(CW$g\fR\->get_tmpdir ();" 4 .IX Item "$tmpdir = $g->get_tmpdir ();" Get the directory used by the handle to store temporary files. .ie n .IP "$trace = $g\->get_trace ();" 4 .el .IP "\f(CW$trace\fR = \f(CW$g\fR\->get_trace ();" 4 .IX Item "$trace = $g->get_trace ();" Return the command trace flag. .ie n .IP "$mask = $g\->get_umask ();" 4 .el .IP "\f(CW$mask\fR = \f(CW$g\fR\->get_umask ();" 4 .IX Item "$mask = $g->get_umask ();" Return the current umask. By default the umask is \f(CW022\fR unless it has been set by calling \f(CW\*(C`$g\->umask\*(C'\fR. .ie n .IP "$verbose = $g\->get_verbose ();" 4 .el .IP "\f(CW$verbose\fR = \f(CW$g\fR\->get_verbose ();" 4 .IX Item "$verbose = $g->get_verbose ();" This returns the verbose messages flag. .ie n .IP "$context = $g\->getcon ();" 4 .el .IP "\f(CW$context\fR = \f(CW$g\fR\->getcon ();" 4 .IX Item "$context = $g->getcon ();" This gets the SELinux security context of the daemon. .Sp See the documentation about SELINUX in \fBguestfs\fR\|(3), and \f(CW\*(C`$g\->setcon\*(C'\fR .Sp This function depends on the feature \f(CW\*(C`selinux\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "selinux_relabel" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$xattr = $g\->getxattr ($path, $name);" 4 .el .IP "\f(CW$xattr\fR = \f(CW$g\fR\->getxattr ($path, \f(CW$name\fR);" 4 .IX Item "$xattr = $g->getxattr ($path, $name);" Get a single extended attribute from file \f(CW\*(C`path\*(C'\fR named \f(CW\*(C`name\*(C'\fR. This call follows symlinks. If you want to lookup an extended attribute for the symlink itself, use \f(CW\*(C`$g\->lgetxattr\*(C'\fR. .Sp Normally it is better to get all extended attributes from a file in one go by calling \f(CW\*(C`$g\->getxattrs\*(C'\fR. However some Linux filesystem implementations are buggy and do not provide a way to list out attributes. For these filesystems (notably ntfs\-3g) you have to know the names of the extended attributes you want in advance and call this function. .Sp Extended attribute values are blobs of binary data. If there is no extended attribute named \f(CW\*(C`name\*(C'\fR, this returns an error. .Sp See also: \f(CW\*(C`$g\->getxattrs\*(C'\fR, \f(CW\*(C`$g\->lgetxattr\*(C'\fR, \fBattr\fR\|(5). .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@xattrs = $g\->getxattrs ($path);" 4 .el .IP "\f(CW@xattrs\fR = \f(CW$g\fR\->getxattrs ($path);" 4 .IX Item "@xattrs = $g->getxattrs ($path);" This call lists the extended attributes of the file or directory \&\f(CW\*(C`path\*(C'\fR. .Sp At the system call level, this is a combination of the \&\fBlistxattr\fR\|(2) and \fBgetxattr\fR\|(2) calls. .Sp See also: \f(CW\*(C`$g\->lgetxattrs\*(C'\fR, \fBattr\fR\|(5). .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@paths = $g\->glob_expand ($pattern [, directoryslash => $directoryslash]);" 4 .el .IP "\f(CW@paths\fR = \f(CW$g\fR\->glob_expand ($pattern [, directoryslash => \f(CW$directoryslash\fR]);" 4 .IX Item "@paths = $g->glob_expand ($pattern [, directoryslash => $directoryslash]);" This command searches for all the pathnames matching \&\f(CW\*(C`pattern\*(C'\fR according to the wildcard expansion rules used by the shell. .Sp If no paths match, then this returns an empty list (note: not an error). .Sp It is just a wrapper around the C \fBglob\fR\|(3) function with flags \f(CW\*(C`GLOB_MARK|GLOB_BRACE\*(C'\fR. See that manual page for more details. .Sp \&\f(CW\*(C`directoryslash\*(C'\fR controls whether use the \f(CW\*(C`GLOB_MARK\*(C'\fR flag for \&\fBglob\fR\|(3), and it defaults to true. It can be explicitly set as off to return no trailing slashes in filenames of directories. .Sp Notice that there is no equivalent command for expanding a device name (eg. \fI/dev/sd*\fR). Use \f(CW\*(C`$g\->list_devices\*(C'\fR, \&\f(CW\*(C`$g\->list_partitions\*(C'\fR etc functions instead. .ie n .IP "@paths = $g\->glob_expand_opts ($pattern [, directoryslash => $directoryslash]);" 4 .el .IP "\f(CW@paths\fR = \f(CW$g\fR\->glob_expand_opts ($pattern [, directoryslash => \f(CW$directoryslash\fR]);" 4 .IX Item "@paths = $g->glob_expand_opts ($pattern [, directoryslash => $directoryslash]);" This is an alias of "glob_expand". .ie n .IP "@lines = $g\->grep ($regex, $path [, extended => $extended] [, fixed => $fixed] [, insensitive => $insensitive] [, compressed => $compressed]);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->grep ($regex, \f(CW$path\fR [, extended => \f(CW$extended\fR] [, fixed => \f(CW$fixed\fR] [, insensitive => \f(CW$insensitive\fR] [, compressed => \f(CW$compressed\fR]);" 4 .IX Item "@lines = $g->grep ($regex, $path [, extended => $extended] [, fixed => $fixed] [, insensitive => $insensitive] [, compressed => $compressed]);" This calls the external \fBgrep\fR\|(1) program and returns the matching lines. .Sp The optional flags are: .RS 4 .ie n .IP """extended""" 4 .el .IP \f(CWextended\fR 4 .IX Item "extended" Use extended regular expressions. This is the same as using the \fI\-E\fR flag. .ie n .IP """fixed""" 4 .el .IP \f(CWfixed\fR 4 .IX Item "fixed" Match fixed (don't use regular expressions). This is the same as using the \fI\-F\fR flag. .ie n .IP """insensitive""" 4 .el .IP \f(CWinsensitive\fR 4 .IX Item "insensitive" Match case-insensitive. This is the same as using the \fI\-i\fR flag. .ie n .IP """compressed""" 4 .el .IP \f(CWcompressed\fR 4 .IX Item "compressed" Use \fBzgrep\fR\|(1) instead of \fBgrep\fR\|(1). This allows the input to be compress\- or gzip-compressed. .RE .RS 4 .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .RE .ie n .IP "@lines = $g\->grep_opts ($regex, $path [, extended => $extended] [, fixed => $fixed] [, insensitive => $insensitive] [, compressed => $compressed]);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->grep_opts ($regex, \f(CW$path\fR [, extended => \f(CW$extended\fR] [, fixed => \f(CW$fixed\fR] [, insensitive => \f(CW$insensitive\fR] [, compressed => \f(CW$compressed\fR]);" 4 .IX Item "@lines = $g->grep_opts ($regex, $path [, extended => $extended] [, fixed => $fixed] [, insensitive => $insensitive] [, compressed => $compressed]);" This is an alias of "grep". .ie n .IP "@lines = $g\->grepi ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->grepi ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->grepi ($regex, $path);" This calls the external \f(CW\*(C`grep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->grub_install ($root, $device);" 4 .el .IP "\f(CW$g\fR\->grub_install ($root, \f(CW$device\fR);" 4 .IX Item "$g->grub_install ($root, $device);" This command installs GRUB 1 (the Grand Unified Bootloader) on \&\f(CW\*(C`device\*(C'\fR, with the root directory being \f(CW\*(C`root\*(C'\fR. .Sp Notes: .RS 4 .IP \(bu 4 There is currently no way in the API to install grub2, which is used by most modern Linux guests. It is possible to run the grub2 command from the guest, although see the caveats in "RUNNING COMMANDS" in \fBguestfs\fR\|(3). .IP \(bu 4 This uses \fBgrub\-install\fR\|(8) from the host. Unfortunately grub is not always compatible with itself, so this only works in rather narrow circumstances. Careful testing with each guest version is advisable. .IP \(bu 4 If grub-install reports the error "No suitable drive was found in the generated device map." it may be that you need to create a \fI/boot/grub/device.map\fR file first that contains the mapping between grub device names and Linux device names. It is usually sufficient to create a file containing: .Sp .Vb 1 \& (hd0) /dev/vda .Ve .Sp replacing \fI/dev/vda\fR with the name of the installation device. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`grub\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "@lines = $g\->head ($path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->head ($path);" 4 .IX Item "@lines = $g->head ($path);" This command returns up to the first 10 lines of a file as a list of strings. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "@lines = $g\->head_n ($nrlines, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->head_n ($nrlines, \f(CW$path\fR);" 4 .IX Item "@lines = $g->head_n ($nrlines, $path);" If the parameter \f(CW\*(C`nrlines\*(C'\fR is a positive number, this returns the first \&\f(CW\*(C`nrlines\*(C'\fR lines of the file \f(CW\*(C`path\*(C'\fR. .Sp If the parameter \f(CW\*(C`nrlines\*(C'\fR is a negative number, this returns lines from the file \f(CW\*(C`path\*(C'\fR, excluding the last \f(CW\*(C`nrlines\*(C'\fR lines. .Sp If the parameter \f(CW\*(C`nrlines\*(C'\fR is zero, this returns an empty list. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$dump = $g\->hexdump ($path);" 4 .el .IP "\f(CW$dump\fR = \f(CW$g\fR\->hexdump ($path);" 4 .IX Item "$dump = $g->hexdump ($path);" This runs \f(CW\*(C`hexdump \-C\*(C'\fR on the given \f(CW\*(C`path\*(C'\fR. The result is the human-readable, canonical hex dump of the file. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->hivex_close ();" 4 .el .IP "\f(CW$g\fR\->hivex_close ();" 4 .IX Item "$g->hivex_close ();" Close the current hivex handle. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->hivex_commit ($filename);" 4 .el .IP "\f(CW$g\fR\->hivex_commit ($filename);" 4 .IX Item "$g->hivex_commit ($filename);" Commit (write) changes to the hive. .Sp If the optional \fIfilename\fR parameter is null, then the changes are written back to the same hive that was opened. If this is not null then they are written to the alternate filename given and the original hive is left untouched. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$nodeh = $g\->hivex_node_add_child ($parent, $name);" 4 .el .IP "\f(CW$nodeh\fR = \f(CW$g\fR\->hivex_node_add_child ($parent, \f(CW$name\fR);" 4 .IX Item "$nodeh = $g->hivex_node_add_child ($parent, $name);" Add a child node to \f(CW\*(C`parent\*(C'\fR named \f(CW\*(C`name\*(C'\fR. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@nodehs = $g\->hivex_node_children ($nodeh);" 4 .el .IP "\f(CW@nodehs\fR = \f(CW$g\fR\->hivex_node_children ($nodeh);" 4 .IX Item "@nodehs = $g->hivex_node_children ($nodeh);" Return the list of nodes which are subkeys of \f(CW\*(C`nodeh\*(C'\fR. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->hivex_node_delete_child ($nodeh);" 4 .el .IP "\f(CW$g\fR\->hivex_node_delete_child ($nodeh);" 4 .IX Item "$g->hivex_node_delete_child ($nodeh);" Delete \f(CW\*(C`nodeh\*(C'\fR, recursively if necessary. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$child = $g\->hivex_node_get_child ($nodeh, $name);" 4 .el .IP "\f(CW$child\fR = \f(CW$g\fR\->hivex_node_get_child ($nodeh, \f(CW$name\fR);" 4 .IX Item "$child = $g->hivex_node_get_child ($nodeh, $name);" Return the child of \f(CW\*(C`nodeh\*(C'\fR with the name \f(CW\*(C`name\*(C'\fR, if it exists. This can return \f(CW0\fR meaning the name was not found. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$valueh = $g\->hivex_node_get_value ($nodeh, $key);" 4 .el .IP "\f(CW$valueh\fR = \f(CW$g\fR\->hivex_node_get_value ($nodeh, \f(CW$key\fR);" 4 .IX Item "$valueh = $g->hivex_node_get_value ($nodeh, $key);" Return the value attached to \f(CW\*(C`nodeh\*(C'\fR which has the name \f(CW\*(C`key\*(C'\fR, if it exists. This can return \f(CW0\fR meaning the key was not found. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$name = $g\->hivex_node_name ($nodeh);" 4 .el .IP "\f(CW$name\fR = \f(CW$g\fR\->hivex_node_name ($nodeh);" 4 .IX Item "$name = $g->hivex_node_name ($nodeh);" Return the name of \f(CW\*(C`nodeh\*(C'\fR. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$parent = $g\->hivex_node_parent ($nodeh);" 4 .el .IP "\f(CW$parent\fR = \f(CW$g\fR\->hivex_node_parent ($nodeh);" 4 .IX Item "$parent = $g->hivex_node_parent ($nodeh);" Return the parent node of \f(CW\*(C`nodeh\*(C'\fR. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->hivex_node_set_value ($nodeh, $key, $t, $val);" 4 .el .IP "\f(CW$g\fR\->hivex_node_set_value ($nodeh, \f(CW$key\fR, \f(CW$t\fR, \f(CW$val\fR);" 4 .IX Item "$g->hivex_node_set_value ($nodeh, $key, $t, $val);" Set or replace a single value under the node \f(CW\*(C`nodeh\*(C'\fR. The \&\f(CW\*(C`key\*(C'\fR is the name, \f(CW\*(C`t\*(C'\fR is the type, and \f(CW\*(C`val\*(C'\fR is the data. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@valuehs = $g\->hivex_node_values ($nodeh);" 4 .el .IP "\f(CW@valuehs\fR = \f(CW$g\fR\->hivex_node_values ($nodeh);" 4 .IX Item "@valuehs = $g->hivex_node_values ($nodeh);" Return the array of (key, datatype, data) tuples attached to \f(CW\*(C`nodeh\*(C'\fR. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->hivex_open ($filename [, verbose => $verbose] [, debug => $debug] [, write => $write] [, unsafe => $unsafe]);" 4 .el .IP "\f(CW$g\fR\->hivex_open ($filename [, verbose => \f(CW$verbose\fR] [, debug => \f(CW$debug\fR] [, write => \f(CW$write\fR] [, unsafe => \f(CW$unsafe\fR]);" 4 .IX Item "$g->hivex_open ($filename [, verbose => $verbose] [, debug => $debug] [, write => $write] [, unsafe => $unsafe]);" Open the Windows Registry hive file named \fIfilename\fR. If there was any previous hivex handle associated with this guestfs session, then it is closed. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$nodeh = $g\->hivex_root ();" 4 .el .IP "\f(CW$nodeh\fR = \f(CW$g\fR\->hivex_root ();" 4 .IX Item "$nodeh = $g->hivex_root ();" Return the root node of the hive. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$key = $g\->hivex_value_key ($valueh);" 4 .el .IP "\f(CW$key\fR = \f(CW$g\fR\->hivex_value_key ($valueh);" 4 .IX Item "$key = $g->hivex_value_key ($valueh);" Return the key (name) field of a (key, datatype, data) tuple. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$databuf = $g\->hivex_value_string ($valueh);" 4 .el .IP "\f(CW$databuf\fR = \f(CW$g\fR\->hivex_value_string ($valueh);" 4 .IX Item "$databuf = $g->hivex_value_string ($valueh);" This calls \f(CW\*(C`$g\->hivex_value_value\*(C'\fR (which returns the data field from a hivex value tuple). It then assumes that the field is a UTF\-16LE string and converts the result to UTF\-8 (or if this is not possible, it returns an error). .Sp This is useful for reading strings out of the Windows registry. However it is not foolproof because the registry is not strongly-typed and fields can contain arbitrary or unexpected data. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$datatype = $g\->hivex_value_type ($valueh);" 4 .el .IP "\f(CW$datatype\fR = \f(CW$g\fR\->hivex_value_type ($valueh);" 4 .IX Item "$datatype = $g->hivex_value_type ($valueh);" Return the data type field from a (key, datatype, data) tuple. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$databuf = $g\->hivex_value_utf8 ($valueh);" 4 .el .IP "\f(CW$databuf\fR = \f(CW$g\fR\->hivex_value_utf8 ($valueh);" 4 .IX Item "$databuf = $g->hivex_value_utf8 ($valueh);" This calls \f(CW\*(C`$g\->hivex_value_value\*(C'\fR (which returns the data field from a hivex value tuple). It then assumes that the field is a UTF\-16LE string and converts the result to UTF\-8 (or if this is not possible, it returns an error). .Sp This is useful for reading strings out of the Windows registry. However it is not foolproof because the registry is not strongly-typed and fields can contain arbitrary or unexpected data. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "hivex_value_string" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$databuf = $g\->hivex_value_value ($valueh);" 4 .el .IP "\f(CW$databuf\fR = \f(CW$g\fR\->hivex_value_value ($valueh);" 4 .IX Item "$databuf = $g->hivex_value_value ($valueh);" Return the data field of a (key, datatype, data) tuple. .Sp This is a wrapper around the \fBhivex\fR\|(3) call of the same name. .Sp See also: \f(CW\*(C`$g\->hivex_value_utf8\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`hivex\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$content = $g\->initrd_cat ($initrdpath, $filename);" 4 .el .IP "\f(CW$content\fR = \f(CW$g\fR\->initrd_cat ($initrdpath, \f(CW$filename\fR);" 4 .IX Item "$content = $g->initrd_cat ($initrdpath, $filename);" This command unpacks the file \fIfilename\fR from the initrd file called \fIinitrdpath\fR. The filename must be given \fIwithout\fR the initial \fI/\fR character. .Sp For example, in guestfish you could use the following command to examine the boot script (usually called \fI/init\fR) contained in a Linux initrd or initramfs image: .Sp .Vb 1 \& initrd\-cat /boot/initrd\-.img init .Ve .Sp See also \f(CW\*(C`$g\->initrd_list\*(C'\fR. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "@filenames = $g\->initrd_list ($path);" 4 .el .IP "\f(CW@filenames\fR = \f(CW$g\fR\->initrd_list ($path);" 4 .IX Item "@filenames = $g->initrd_list ($path);" This command lists out files contained in an initrd. .Sp The files are listed without any initial \fI/\fR character. The files are listed in the order they appear (not necessarily alphabetical). Directory names are listed as separate items. .Sp Old Linux kernels (2.4 and earlier) used a compressed ext2 filesystem as initrd. We \fIonly\fR support the newer initramfs format (compressed cpio files). .ie n .IP "$wd = $g\->inotify_add_watch ($path, $mask);" 4 .el .IP "\f(CW$wd\fR = \f(CW$g\fR\->inotify_add_watch ($path, \f(CW$mask\fR);" 4 .IX Item "$wd = $g->inotify_add_watch ($path, $mask);" Watch \f(CW\*(C`path\*(C'\fR for the events listed in \f(CW\*(C`mask\*(C'\fR. .Sp Note that if \f(CW\*(C`path\*(C'\fR is a directory then events within that directory are watched, but this does \fInot\fR happen recursively (in subdirectories). .Sp Note for non-C or non-Linux callers: the inotify events are defined by the Linux kernel ABI and are listed in \&\fI/usr/include/sys/inotify.h\fR. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->inotify_close ();" 4 .el .IP "\f(CW$g\fR\->inotify_close ();" 4 .IX Item "$g->inotify_close ();" This closes the inotify handle which was previously opened by inotify_init. It removes all watches, throws away any pending events, and deallocates all resources. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@paths = $g\->inotify_files ();" 4 .el .IP "\f(CW@paths\fR = \f(CW$g\fR\->inotify_files ();" 4 .IX Item "@paths = $g->inotify_files ();" This function is a helpful wrapper around \f(CW\*(C`$g\->inotify_read\*(C'\fR which just returns a list of pathnames of objects that were touched. The returned pathnames are sorted and deduplicated. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->inotify_init ($maxevents);" 4 .el .IP "\f(CW$g\fR\->inotify_init ($maxevents);" 4 .IX Item "$g->inotify_init ($maxevents);" This command creates a new inotify handle. The inotify subsystem can be used to notify events which happen to objects in the guest filesystem. .Sp \&\f(CW\*(C`maxevents\*(C'\fR is the maximum number of events which will be queued up between calls to \f(CW\*(C`$g\->inotify_read\*(C'\fR or \&\f(CW\*(C`$g\->inotify_files\*(C'\fR. If this is passed as \f(CW0\fR, then the kernel (or previously set) default is used. For Linux 2.6.29 the default was 16384 events. Beyond this limit, the kernel throws away events, but records the fact that it threw them away by setting a flag \&\f(CW\*(C`IN_Q_OVERFLOW\*(C'\fR in the returned structure list (see \&\f(CW\*(C`$g\->inotify_read\*(C'\fR). .Sp Before any events are generated, you have to add some watches to the internal watch list. See: \f(CW\*(C`$g\->inotify_add_watch\*(C'\fR and \&\f(CW\*(C`$g\->inotify_rm_watch\*(C'\fR. .Sp Queued up events should be read periodically by calling \&\f(CW\*(C`$g\->inotify_read\*(C'\fR (or \f(CW\*(C`$g\->inotify_files\*(C'\fR which is just a helpful wrapper around \f(CW\*(C`$g\->inotify_read\*(C'\fR). If you don't read the events out often enough then you risk the internal queue overflowing. .Sp The handle should be closed after use by calling \&\f(CW\*(C`$g\->inotify_close\*(C'\fR. This also removes any watches automatically. .Sp See also \fBinotify\fR\|(7) for an overview of the inotify interface as exposed by the Linux kernel, which is roughly what we expose via libguestfs. Note that there is one global inotify handle per libguestfs instance. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@events = $g\->inotify_read ();" 4 .el .IP "\f(CW@events\fR = \f(CW$g\fR\->inotify_read ();" 4 .IX Item "@events = $g->inotify_read ();" Return the complete queue of events that have happened since the previous read call. .Sp If no events have happened, this returns an empty list. .Sp \&\fINote\fR: In order to make sure that all events have been read, you must call this function repeatedly until it returns an empty list. The reason is that the call will read events up to the maximum appliance-to-host message size and leave remaining events in the queue. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->inotify_rm_watch ($wd);" 4 .el .IP "\f(CW$g\fR\->inotify_rm_watch ($wd);" 4 .IX Item "$g->inotify_rm_watch ($wd);" Remove a previously defined inotify watch. See \f(CW\*(C`$g\->inotify_add_watch\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`inotify\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$arch = $g\->inspect_get_arch ($root);" 4 .el .IP "\f(CW$arch\fR = \f(CW$g\fR\->inspect_get_arch ($root);" 4 .IX Item "$arch = $g->inspect_get_arch ($root);" This returns the architecture of the inspected operating system. The possible return values are listed under \&\f(CW\*(C`$g\->file_architecture\*(C'\fR. .Sp If the architecture could not be determined, then the string \f(CW\*(C`unknown\*(C'\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$buildid = $g\->inspect_get_build_id ($root);" 4 .el .IP "\f(CW$buildid\fR = \f(CW$g\fR\->inspect_get_build_id ($root);" 4 .IX Item "$buildid = $g->inspect_get_build_id ($root);" This returns the build ID of the system, or the string \&\f(CW"unknown"\fR if the system does not have a build ID. .Sp For Windows, this gets the build number. Although it is returned as a string, it is (so far) always a number. See for some possible values. .Sp For Linux, this returns the \f(CW\*(C`BUILD_ID\*(C'\fR string from \&\fI/etc/os\-release\fR, although this is not often used. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$distro = $g\->inspect_get_distro ($root);" 4 .el .IP "\f(CW$distro\fR = \f(CW$g\fR\->inspect_get_distro ($root);" 4 .IX Item "$distro = $g->inspect_get_distro ($root);" This returns the distro (distribution) of the inspected operating system. .Sp Currently defined distros are: .RS 4 .IP """alpinelinux""" 4 .IX Item """alpinelinux""" Alpine Linux. .IP """altlinux""" 4 .IX Item """altlinux""" ALT Linux. .IP """archlinux""" 4 .IX Item """archlinux""" Arch Linux. .IP """buildroot""" 4 .IX Item """buildroot""" Buildroot-derived distro, but not one we specifically recognize. .IP """centos""" 4 .IX Item """centos""" CentOS. .IP """circle""" 4 .IX Item """circle""" Circle Linux. .IP """cirros""" 4 .IX Item """cirros""" Cirros. .IP """coreos""" 4 .IX Item """coreos""" CoreOS. .IP """debian""" 4 .IX Item """debian""" Debian. .IP """fedora""" 4 .IX Item """fedora""" Fedora. .IP """freebsd""" 4 .IX Item """freebsd""" FreeBSD. .IP """freedos""" 4 .IX Item """freedos""" FreeDOS. .IP """frugalware""" 4 .IX Item """frugalware""" Frugalware. .IP """gentoo""" 4 .IX Item """gentoo""" Gentoo. .IP """kalilinux""" 4 .IX Item """kalilinux""" Kali Linux. .IP """kylin""" 4 .IX Item """kylin""" Kylin. .IP """linuxmint""" 4 .IX Item """linuxmint""" Linux Mint. .IP """mageia""" 4 .IX Item """mageia""" Mageia. .IP """mandriva""" 4 .IX Item """mandriva""" Mandriva. .IP """meego""" 4 .IX Item """meego""" MeeGo. .IP """msdos""" 4 .IX Item """msdos""" Microsoft DOS. .IP """neokylin""" 4 .IX Item """neokylin""" NeoKylin. .IP """netbsd""" 4 .IX Item """netbsd""" NetBSD. .IP """openbsd""" 4 .IX Item """openbsd""" OpenBSD. .IP """openeuler""" 4 .IX Item """openeuler""" openEuler. .IP """openmandriva""" 4 .IX Item """openmandriva""" OpenMandriva Lx. .IP """opensuse""" 4 .IX Item """opensuse""" OpenSUSE. .IP """oraclelinux""" 4 .IX Item """oraclelinux""" Oracle Linux. .IP """pardus""" 4 .IX Item """pardus""" Pardus. .IP """pldlinux""" 4 .IX Item """pldlinux""" PLD Linux. .IP """redhat-based""" 4 .IX Item """redhat-based""" Some Red Hat-derived distro. .IP """rhel""" 4 .IX Item """rhel""" Red Hat Enterprise Linux. .IP """rocky""" 4 .IX Item """rocky""" Rocky Linux. .IP """scientificlinux""" 4 .IX Item """scientificlinux""" Scientific Linux. .IP """slackware""" 4 .IX Item """slackware""" Slackware. .IP """sles""" 4 .IX Item """sles""" SuSE Linux Enterprise Server or Desktop. .IP """suse-based""" 4 .IX Item """suse-based""" Some openSuSE-derived distro. .IP """ttylinux""" 4 .IX Item """ttylinux""" ttylinux. .IP """ubuntu""" 4 .IX Item """ubuntu""" Ubuntu. .IP """unknown""" 4 .IX Item """unknown""" The distro could not be determined. .IP """voidlinux""" 4 .IX Item """voidlinux""" Void Linux. .IP """windows""" 4 .IX Item """windows""" Windows does not have distributions. This string is returned if the OS type is Windows. .RE .RS 4 .Sp Future versions of libguestfs may return other strings here. The caller should be prepared to handle any string. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .RE .ie n .IP "%drives = $g\->inspect_get_drive_mappings ($root);" 4 .el .IP "\f(CW%drives\fR = \f(CW$g\fR\->inspect_get_drive_mappings ($root);" 4 .IX Item "%drives = $g->inspect_get_drive_mappings ($root);" This call is useful for Windows which uses a primitive system of assigning drive letters (like \fIC:\e\fR) to partitions. This inspection API examines the Windows Registry to find out how disks/partitions are mapped to drive letters, and returns a hash table as in the example below: .Sp .Vb 3 \& C => /dev/vda2 \& E => /dev/vdb1 \& F => /dev/vdc1 .Ve .Sp Note that keys are drive letters. For Windows, the key is case insensitive and just contains the drive letter, without the customary colon separator character. .Sp In future we may support other operating systems that also used drive letters, but the keys for those might not be case insensitive and might be longer than 1 character. For example in OS\-9, hard drives were named \f(CW\*(C`h0\*(C'\fR, \f(CW\*(C`h1\*(C'\fR etc. .Sp For Windows guests, currently only hard drive mappings are returned. Removable disks (eg. DVD-ROMs) are ignored. .Sp For guests that do not use drive mappings, or if the drive mappings could not be determined, this returns an empty hash table. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. See also \f(CW\*(C`$g\->inspect_get_mountpoints\*(C'\fR, \&\f(CW\*(C`$g\->inspect_get_filesystems\*(C'\fR. .ie n .IP "@filesystems = $g\->inspect_get_filesystems ($root);" 4 .el .IP "\f(CW@filesystems\fR = \f(CW$g\fR\->inspect_get_filesystems ($root);" 4 .IX Item "@filesystems = $g->inspect_get_filesystems ($root);" This returns a list of all the filesystems that we think are associated with this operating system. This includes the root filesystem, other ordinary filesystems, and non-mounted devices like swap partitions. .Sp In the case of a multi-boot virtual machine, it is possible for a filesystem to be shared between operating systems. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. See also \f(CW\*(C`$g\->inspect_get_mountpoints\*(C'\fR. .ie n .IP "$format = $g\->inspect_get_format ($root);" 4 .el .IP "\f(CW$format\fR = \f(CW$g\fR\->inspect_get_format ($root);" 4 .IX Item "$format = $g->inspect_get_format ($root);" Before libguestfs 1.38, there was some unreliable support for detecting installer CDs. This API would return: .RS 4 .ie n .IP """installed""" 4 .el .IP \f(CWinstalled\fR 4 .IX Item "installed" This is an installed operating system. .ie n .IP """installer""" 4 .el .IP \f(CWinstaller\fR 4 .IX Item "installer" The disk image being inspected is not an installed operating system, but a \fIbootable\fR install disk, live CD, or similar. .ie n .IP """unknown""" 4 .el .IP \f(CWunknown\fR 4 .IX Item "unknown" The format of this disk image is not known. .RE .RS 4 .Sp In libguestfs ≥ 1.38, this only returns \f(CW\*(C`installed\*(C'\fR. Use libosinfo directly to detect installer CDs. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .RE .ie n .IP "$hostname = $g\->inspect_get_hostname ($root);" 4 .el .IP "\f(CW$hostname\fR = \f(CW$g\fR\->inspect_get_hostname ($root);" 4 .IX Item "$hostname = $g->inspect_get_hostname ($root);" This function returns the hostname of the operating system as found by inspection of the guest’s configuration files. .Sp If the hostname could not be determined, then the string \f(CW\*(C`unknown\*(C'\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$icon = $g\->inspect_get_icon ($root [, favicon => $favicon] [, highquality => $highquality]);" 4 .el .IP "\f(CW$icon\fR = \f(CW$g\fR\->inspect_get_icon ($root [, favicon => \f(CW$favicon\fR] [, highquality => \f(CW$highquality\fR]);" 4 .IX Item "$icon = $g->inspect_get_icon ($root [, favicon => $favicon] [, highquality => $highquality]);" This function returns an icon corresponding to the inspected operating system. The icon is returned as a buffer containing a PNG image (re-encoded to PNG if necessary). .Sp If it was not possible to get an icon this function returns a zero-length (non-NULL) buffer. \fICallers must check for this case\fR. .Sp Libguestfs will start by looking for a file called \&\fI/etc/favicon.png\fR or \fIC:\eetc\efavicon.png\fR and if it has the correct format, the contents of this file will be returned. You can disable favicons by passing the optional \f(CW\*(C`favicon\*(C'\fR boolean as false (default is true). .Sp If finding the favicon fails, then we look in other places in the guest for a suitable icon. .Sp If the optional \f(CW\*(C`highquality\*(C'\fR boolean is true then only high quality icons are returned, which means only icons of high resolution with an alpha channel. The default (false) is to return any icon we can, even if it is of substandard quality. .Sp Notes: .RS 4 .IP \(bu 4 Unlike most other inspection API calls, the guest’s disks must be mounted up before you call this, since it needs to read information from the guest filesystem during the call. .IP \(bu 4 \&\fBSecurity:\fR The icon data comes from the untrusted guest, and should be treated with caution. PNG files have been known to contain exploits. Ensure that libpng (or other relevant libraries) are fully up to date before trying to process or display the icon. .IP \(bu 4 The PNG image returned can be any size. It might not be square. Libguestfs tries to return the largest, highest quality icon available. The application must scale the icon to the required size. .IP \(bu 4 Extracting icons from Windows guests requires the external \&\fBwrestool\fR\|(1) program from the \f(CW\*(C`icoutils\*(C'\fR package, and several programs (\fBbmptopnm\fR\|(1), \fBpnmtopng\fR\|(1), \fBpamcut\fR\|(1)) from the \f(CW\*(C`netpbm\*(C'\fR package. These must be installed separately. .IP \(bu 4 Operating system icons are usually trademarks. Seek legal advice before using trademarks in applications. .RE .RS 4 .RE .ie n .IP "$major = $g\->inspect_get_major_version ($root);" 4 .el .IP "\f(CW$major\fR = \f(CW$g\fR\->inspect_get_major_version ($root);" 4 .IX Item "$major = $g->inspect_get_major_version ($root);" This returns the major version number of the inspected operating system. .Sp Windows uses a consistent versioning scheme which is \fInot\fR reflected in the popular public names used by the operating system. Notably the operating system known as "Windows 7" is really version 6.1 (ie. major = 6, minor = 1). You can find out the real versions corresponding to releases of Windows by consulting Wikipedia or MSDN. .Sp If the version could not be determined, then \f(CW0\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$minor = $g\->inspect_get_minor_version ($root);" 4 .el .IP "\f(CW$minor\fR = \f(CW$g\fR\->inspect_get_minor_version ($root);" 4 .IX Item "$minor = $g->inspect_get_minor_version ($root);" This returns the minor version number of the inspected operating system. .Sp If the version could not be determined, then \f(CW0\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. See also \f(CW\*(C`$g\->inspect_get_major_version\*(C'\fR. .ie n .IP "%mountpoints = $g\->inspect_get_mountpoints ($root);" 4 .el .IP "\f(CW%mountpoints\fR = \f(CW$g\fR\->inspect_get_mountpoints ($root);" 4 .IX Item "%mountpoints = $g->inspect_get_mountpoints ($root);" This returns a hash of where we think the filesystems associated with this operating system should be mounted. Callers should note that this is at best an educated guess made by reading configuration files such as \fI/etc/fstab\fR. \&\fIIn particular note\fR that this may return filesystems which are non-existent or not mountable and callers should be prepared to handle or ignore failures if they try to mount them. .Sp Each element in the returned hashtable has a key which is the path of the mountpoint (eg. \fI/boot\fR) and a value which is the filesystem that would be mounted there (eg. \fI/dev/sda1\fR). .Sp Non-mounted devices such as swap devices are \fInot\fR returned in this list. .Sp For operating systems like Windows which still use drive letters, this call will only return an entry for the first drive "mounted on" \fI/\fR. For information about the mapping of drive letters to partitions, see \&\f(CW\*(C`$g\->inspect_get_drive_mappings\*(C'\fR. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. See also \f(CW\*(C`$g\->inspect_get_filesystems\*(C'\fR. .ie n .IP "$id = $g\->inspect_get_osinfo ($root);" 4 .el .IP "\f(CW$id\fR = \f(CW$g\fR\->inspect_get_osinfo ($root);" 4 .IX Item "$id = $g->inspect_get_osinfo ($root);" This function returns a possible short ID for libosinfo corresponding to the guest. .Sp \&\fINote:\fR The returned ID is only a guess by libguestfs, and nothing ensures that it actually exists in osinfo-db. .Sp If no ID could not be determined, then the string \f(CW\*(C`unknown\*(C'\fR is returned. .ie n .IP "$packageformat = $g\->inspect_get_package_format ($root);" 4 .el .IP "\f(CW$packageformat\fR = \f(CW$g\fR\->inspect_get_package_format ($root);" 4 .IX Item "$packageformat = $g->inspect_get_package_format ($root);" This function and \f(CW\*(C`$g\->inspect_get_package_management\*(C'\fR return the package format and package management tool used by the inspected operating system. For example for Fedora these functions would return \f(CW\*(C`rpm\*(C'\fR (package format), and \&\f(CW\*(C`yum\*(C'\fR or \f(CW\*(C`dnf\*(C'\fR (package management). .Sp This returns the string \f(CW\*(C`unknown\*(C'\fR if we could not determine the package format \fIor\fR if the operating system does not have a real packaging system (eg. Windows). .Sp Possible strings include: \&\f(CW\*(C`rpm\*(C'\fR, \f(CW\*(C`deb\*(C'\fR, \f(CW\*(C`ebuild\*(C'\fR, \f(CW\*(C`pisi\*(C'\fR, \f(CW\*(C`pacman\*(C'\fR, \f(CW\*(C`pkgsrc\*(C'\fR, \f(CW\*(C`apk\*(C'\fR, \&\f(CW\*(C`xbps\*(C'\fR. Future versions of libguestfs may return other strings. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$packagemanagement = $g\->inspect_get_package_management ($root);" 4 .el .IP "\f(CW$packagemanagement\fR = \f(CW$g\fR\->inspect_get_package_management ($root);" 4 .IX Item "$packagemanagement = $g->inspect_get_package_management ($root);" \&\f(CW\*(C`$g\->inspect_get_package_format\*(C'\fR and this function return the package format and package management tool used by the inspected operating system. For example for Fedora these functions would return \f(CW\*(C`rpm\*(C'\fR (package format), and \&\f(CW\*(C`yum\*(C'\fR or \f(CW\*(C`dnf\*(C'\fR (package management). .Sp This returns the string \f(CW\*(C`unknown\*(C'\fR if we could not determine the package management tool \fIor\fR if the operating system does not have a real packaging system (eg. Windows). .Sp Possible strings include: \f(CW\*(C`yum\*(C'\fR, \f(CW\*(C`dnf\*(C'\fR, \f(CW\*(C`up2date\*(C'\fR, \&\f(CW\*(C`apt\*(C'\fR (for all Debian derivatives), \&\f(CW\*(C`portage\*(C'\fR, \f(CW\*(C`pisi\*(C'\fR, \f(CW\*(C`pacman\*(C'\fR, \f(CW\*(C`urpmi\*(C'\fR, \f(CW\*(C`zypper\*(C'\fR, \f(CW\*(C`apk\*(C'\fR, \f(CW\*(C`xbps\*(C'\fR. Future versions of libguestfs may return other strings. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$product = $g\->inspect_get_product_name ($root);" 4 .el .IP "\f(CW$product\fR = \f(CW$g\fR\->inspect_get_product_name ($root);" 4 .IX Item "$product = $g->inspect_get_product_name ($root);" This returns the product name of the inspected operating system. The product name is generally some freeform string which can be displayed to the user, but should not be parsed by programs. .Sp If the product name could not be determined, then the string \f(CW\*(C`unknown\*(C'\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$variant = $g\->inspect_get_product_variant ($root);" 4 .el .IP "\f(CW$variant\fR = \f(CW$g\fR\->inspect_get_product_variant ($root);" 4 .IX Item "$variant = $g->inspect_get_product_variant ($root);" This returns the product variant of the inspected operating system. .Sp For Windows guests, this returns the contents of the Registry key \&\f(CW\*(C`HKLM\eSoftware\eMicrosoft\eWindows NT\eCurrentVersion\*(C'\fR \&\f(CW\*(C`InstallationType\*(C'\fR which is usually a string such as \&\f(CW\*(C`Client\*(C'\fR or \f(CW\*(C`Server\*(C'\fR (other values are possible). This can be used to distinguish consumer and enterprise versions of Windows that have the same version number (for example, Windows 7 and Windows 2008 Server are both version 6.1, but the former is \f(CW\*(C`Client\*(C'\fR and the latter is \f(CW\*(C`Server\*(C'\fR). .Sp For enterprise Linux guests, in future we intend this to return the product variant such as \f(CW\*(C`Desktop\*(C'\fR, \f(CW\*(C`Server\*(C'\fR and so on. But this is not implemented at present. .Sp If the product variant could not be determined, then the string \f(CW\*(C`unknown\*(C'\fR is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. See also \f(CW\*(C`$g\->inspect_get_product_name\*(C'\fR, \&\f(CW\*(C`$g\->inspect_get_major_version\*(C'\fR. .ie n .IP "@roots = $g\->inspect_get_roots ();" 4 .el .IP "\f(CW@roots\fR = \f(CW$g\fR\->inspect_get_roots ();" 4 .IX Item "@roots = $g->inspect_get_roots ();" This function is a convenient way to get the list of root devices, as returned from a previous call to \f(CW\*(C`$g\->inspect_os\*(C'\fR, but without redoing the whole inspection process. .Sp This returns an empty list if either no root devices were found or the caller has not called \f(CW\*(C`$g\->inspect_os\*(C'\fR. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$name = $g\->inspect_get_type ($root);" 4 .el .IP "\f(CW$name\fR = \f(CW$g\fR\->inspect_get_type ($root);" 4 .IX Item "$name = $g->inspect_get_type ($root);" This returns the type of the inspected operating system. Currently defined types are: .RS 4 .IP """linux""" 4 .IX Item """linux""" Any Linux-based operating system. .IP """windows""" 4 .IX Item """windows""" Any Microsoft Windows operating system. .IP """freebsd""" 4 .IX Item """freebsd""" FreeBSD. .IP """netbsd""" 4 .IX Item """netbsd""" NetBSD. .IP """openbsd""" 4 .IX Item """openbsd""" OpenBSD. .IP """hurd""" 4 .IX Item """hurd""" GNU/Hurd. .IP """dos""" 4 .IX Item """dos""" MS-DOS, FreeDOS and others. .IP """minix""" 4 .IX Item """minix""" MINIX. .IP """unknown""" 4 .IX Item """unknown""" The operating system type could not be determined. .RE .RS 4 .Sp Future versions of libguestfs may return other strings here. The caller should be prepared to handle any string. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .RE .ie n .IP "$controlset = $g\->inspect_get_windows_current_control_set ($root);" 4 .el .IP "\f(CW$controlset\fR = \f(CW$g\fR\->inspect_get_windows_current_control_set ($root);" 4 .IX Item "$controlset = $g->inspect_get_windows_current_control_set ($root);" This returns the Windows CurrentControlSet of the inspected guest. The CurrentControlSet is a registry key name such as \f(CW\*(C`ControlSet001\*(C'\fR. .Sp This call assumes that the guest is Windows and that the Registry could be examined by inspection. If this is not the case then an error is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$path = $g\->inspect_get_windows_software_hive ($root);" 4 .el .IP "\f(CW$path\fR = \f(CW$g\fR\->inspect_get_windows_software_hive ($root);" 4 .IX Item "$path = $g->inspect_get_windows_software_hive ($root);" This returns the path to the hive (binary Windows Registry file) corresponding to HKLM\eSOFTWARE. .Sp This call assumes that the guest is Windows and that the guest has a software hive file with the right name. If this is not the case then an error is returned. This call does not check that the hive is a valid Windows Registry hive. .Sp You can use \f(CW\*(C`$g\->hivex_open\*(C'\fR to read or write to the hive. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$path = $g\->inspect_get_windows_system_hive ($root);" 4 .el .IP "\f(CW$path\fR = \f(CW$g\fR\->inspect_get_windows_system_hive ($root);" 4 .IX Item "$path = $g->inspect_get_windows_system_hive ($root);" This returns the path to the hive (binary Windows Registry file) corresponding to HKLM\eSYSTEM. .Sp This call assumes that the guest is Windows and that the guest has a system hive file with the right name. If this is not the case then an error is returned. This call does not check that the hive is a valid Windows Registry hive. .Sp You can use \f(CW\*(C`$g\->hivex_open\*(C'\fR to read or write to the hive. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$systemroot = $g\->inspect_get_windows_systemroot ($root);" 4 .el .IP "\f(CW$systemroot\fR = \f(CW$g\fR\->inspect_get_windows_systemroot ($root);" 4 .IX Item "$systemroot = $g->inspect_get_windows_systemroot ($root);" This returns the Windows systemroot of the inspected guest. The systemroot is a directory path such as \fI/WINDOWS\fR. .Sp This call assumes that the guest is Windows and that the systemroot could be determined by inspection. If this is not the case then an error is returned. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .ie n .IP "$live = $g\->inspect_is_live ($root);" 4 .el .IP "\f(CW$live\fR = \f(CW$g\fR\->inspect_is_live ($root);" 4 .IX Item "$live = $g->inspect_is_live ($root);" This is deprecated and always returns \f(CW\*(C`false\*(C'\fR. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$multipart = $g\->inspect_is_multipart ($root);" 4 .el .IP "\f(CW$multipart\fR = \f(CW$g\fR\->inspect_is_multipart ($root);" 4 .IX Item "$multipart = $g->inspect_is_multipart ($root);" This is deprecated and always returns \f(CW\*(C`false\*(C'\fR. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$netinst = $g\->inspect_is_netinst ($root);" 4 .el .IP "\f(CW$netinst\fR = \f(CW$g\fR\->inspect_is_netinst ($root);" 4 .IX Item "$netinst = $g->inspect_is_netinst ($root);" This is deprecated and always returns \f(CW\*(C`false\*(C'\fR. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@applications = $g\->inspect_list_applications ($root);" 4 .el .IP "\f(CW@applications\fR = \f(CW$g\fR\->inspect_list_applications ($root);" 4 .IX Item "@applications = $g->inspect_list_applications ($root);" Return the list of applications installed in the operating system. .Sp \&\fINote:\fR This call works differently from other parts of the inspection API. You have to call \f(CW\*(C`$g\->inspect_os\*(C'\fR, then \&\f(CW\*(C`$g\->inspect_get_mountpoints\*(C'\fR, then mount up the disks, before calling this. Listing applications is a significantly more difficult operation which requires access to the full filesystem. Also note that unlike the other \&\f(CW\*(C`$g\->inspect_get_*\*(C'\fR calls which are just returning data cached in the libguestfs handle, this call actually reads parts of the mounted filesystems during the call. .Sp This returns an empty list if the inspection code was not able to determine the list of applications. .Sp The application structure contains the following fields: .RS 4 .ie n .IP """app_name""" 4 .el .IP \f(CWapp_name\fR 4 .IX Item "app_name" The name of the application. For Linux guests, this is the package name. .ie n .IP """app_display_name""" 4 .el .IP \f(CWapp_display_name\fR 4 .IX Item "app_display_name" The display name of the application, sometimes localized to the install language of the guest operating system. .Sp If unavailable this is returned as an empty string \f(CW""\fR. Callers needing to display something can use \f(CW\*(C`app_name\*(C'\fR instead. .ie n .IP """app_epoch""" 4 .el .IP \f(CWapp_epoch\fR 4 .IX Item "app_epoch" For package managers which use epochs, this contains the epoch of the package (an integer). If unavailable, this is returned as \f(CW0\fR. .ie n .IP """app_version""" 4 .el .IP \f(CWapp_version\fR 4 .IX Item "app_version" The version string of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_release""" 4 .el .IP \f(CWapp_release\fR 4 .IX Item "app_release" The release string of the application or package, for package managers that use this. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_install_path""" 4 .el .IP \f(CWapp_install_path\fR 4 .IX Item "app_install_path" The installation path of the application (on operating systems such as Windows which use installation paths). This path is in the format used by the guest operating system, it is not a libguestfs path. .Sp If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_trans_path""" 4 .el .IP \f(CWapp_trans_path\fR 4 .IX Item "app_trans_path" The install path translated into a libguestfs path. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_publisher""" 4 .el .IP \f(CWapp_publisher\fR 4 .IX Item "app_publisher" The name of the publisher of the application, for package managers that use this. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_url""" 4 .el .IP \f(CWapp_url\fR 4 .IX Item "app_url" The URL (eg. upstream URL) of the application. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_source_package""" 4 .el .IP \f(CWapp_source_package\fR 4 .IX Item "app_source_package" For packaging systems which support this, the name of the source package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_summary""" 4 .el .IP \f(CWapp_summary\fR 4 .IX Item "app_summary" A short (usually one line) description of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app_description""" 4 .el .IP \f(CWapp_description\fR 4 .IX Item "app_description" A longer description of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .RE .RS 4 .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp \&\fIThis function is deprecated.\fR In new code, use the "inspect_list_applications2" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .RE .ie n .IP "@applications2 = $g\->inspect_list_applications2 ($root);" 4 .el .IP "\f(CW@applications2\fR = \f(CW$g\fR\->inspect_list_applications2 ($root);" 4 .IX Item "@applications2 = $g->inspect_list_applications2 ($root);" Return the list of applications installed in the operating system. .Sp \&\fINote:\fR This call works differently from other parts of the inspection API. You have to call \f(CW\*(C`$g\->inspect_os\*(C'\fR, then \&\f(CW\*(C`$g\->inspect_get_mountpoints\*(C'\fR, then mount up the disks, before calling this. Listing applications is a significantly more difficult operation which requires access to the full filesystem. Also note that unlike the other \&\f(CW\*(C`$g\->inspect_get_*\*(C'\fR calls which are just returning data cached in the libguestfs handle, this call actually reads parts of the mounted filesystems during the call. .Sp This returns an empty list if the inspection code was not able to determine the list of applications. .Sp The application structure contains the following fields: .RS 4 .ie n .IP """app2_name""" 4 .el .IP \f(CWapp2_name\fR 4 .IX Item "app2_name" The name of the application. For Linux guests, this is the package name. .ie n .IP """app2_display_name""" 4 .el .IP \f(CWapp2_display_name\fR 4 .IX Item "app2_display_name" The display name of the application, sometimes localized to the install language of the guest operating system. .Sp If unavailable this is returned as an empty string \f(CW""\fR. Callers needing to display something can use \f(CW\*(C`app2_name\*(C'\fR instead. .ie n .IP """app2_epoch""" 4 .el .IP \f(CWapp2_epoch\fR 4 .IX Item "app2_epoch" For package managers which use epochs, this contains the epoch of the package (an integer). If unavailable, this is returned as \f(CW0\fR. .ie n .IP """app2_version""" 4 .el .IP \f(CWapp2_version\fR 4 .IX Item "app2_version" The version string of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_release""" 4 .el .IP \f(CWapp2_release\fR 4 .IX Item "app2_release" The release string of the application or package, for package managers that use this. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_arch""" 4 .el .IP \f(CWapp2_arch\fR 4 .IX Item "app2_arch" The architecture string of the application or package, for package managers that use this. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_install_path""" 4 .el .IP \f(CWapp2_install_path\fR 4 .IX Item "app2_install_path" The installation path of the application (on operating systems such as Windows which use installation paths). This path is in the format used by the guest operating system, it is not a libguestfs path. .Sp If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_trans_path""" 4 .el .IP \f(CWapp2_trans_path\fR 4 .IX Item "app2_trans_path" The install path translated into a libguestfs path. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_publisher""" 4 .el .IP \f(CWapp2_publisher\fR 4 .IX Item "app2_publisher" The name of the publisher of the application, for package managers that use this. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_url""" 4 .el .IP \f(CWapp2_url\fR 4 .IX Item "app2_url" The URL (eg. upstream URL) of the application. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_source_package""" 4 .el .IP \f(CWapp2_source_package\fR 4 .IX Item "app2_source_package" For packaging systems which support this, the name of the source package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_summary""" 4 .el .IP \f(CWapp2_summary\fR 4 .IX Item "app2_summary" A short (usually one line) description of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .ie n .IP """app2_description""" 4 .el .IP \f(CWapp2_description\fR 4 .IX Item "app2_description" A longer description of the application or package. If unavailable this is returned as an empty string \f(CW""\fR. .RE .RS 4 .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .RE .ie n .IP "@roots = $g\->inspect_os ();" 4 .el .IP "\f(CW@roots\fR = \f(CW$g\fR\->inspect_os ();" 4 .IX Item "@roots = $g->inspect_os ();" This function uses other libguestfs functions and certain heuristics to inspect the disk(s) (usually disks belonging to a virtual machine), looking for operating systems. .Sp The list returned is empty if no operating systems were found. .Sp If one operating system was found, then this returns a list with a single element, which is the name of the root filesystem of this operating system. It is also possible for this function to return a list containing more than one element, indicating a dual-boot or multi-boot virtual machine, with each element being the root filesystem of one of the operating systems. .Sp You can pass the root string(s) returned to other \&\f(CW\*(C`$g\->inspect_get_*\*(C'\fR functions in order to query further information about each operating system, such as the name and version. .Sp This function uses other libguestfs features such as \&\f(CW\*(C`$g\->mount_ro\*(C'\fR and \f(CW\*(C`$g\->umount_all\*(C'\fR in order to mount and unmount filesystems and look at the contents. This should be called with no disks currently mounted. The function may also use Augeas, so any existing Augeas handle will be closed. .Sp This function cannot decrypt encrypted disks. The caller must do that first (supplying the necessary keys) if the disk is encrypted. .Sp Please read "INSPECTION" in \fBguestfs\fR\|(3) for more details. .Sp See also \f(CW\*(C`$g\->list_filesystems\*(C'\fR. .ie n .IP "$flag = $g\->is_blockdev ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_blockdev ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_blockdev ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a block device with the given \f(CW\*(C`path\*(C'\fR name. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a block device also causes the function to return true. .Sp This call only looks at files within the guest filesystem. Libguestfs partitions and block devices (eg. \fI/dev/sda\fR) cannot be used as the \&\f(CW\*(C`path\*(C'\fR parameter of this call. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$flag = $g\->is_blockdev_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_blockdev_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_blockdev_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_blockdev". .ie n .IP "$busy = $g\->is_busy ();" 4 .el .IP "\f(CW$busy\fR = \f(CW$g\fR\->is_busy ();" 4 .IX Item "$busy = $g->is_busy ();" This always returns false. This function is deprecated with no replacement. Do not use this function. .Sp For more information on states, see \fBguestfs\fR\|(3). .ie n .IP "$flag = $g\->is_chardev ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_chardev ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_chardev ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a character device with the given \f(CW\*(C`path\*(C'\fR name. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a chardev also causes the function to return true. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$flag = $g\->is_chardev_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_chardev_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_chardev_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_chardev". .ie n .IP "$config = $g\->is_config ();" 4 .el .IP "\f(CW$config\fR = \f(CW$g\fR\->is_config ();" 4 .IX Item "$config = $g->is_config ();" This returns true iff this handle is being configured (in the \f(CW\*(C`CONFIG\*(C'\fR state). .Sp For more information on states, see \fBguestfs\fR\|(3). .ie n .IP "$dirflag = $g\->is_dir ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$dirflag\fR = \f(CW$g\fR\->is_dir ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$dirflag = $g->is_dir ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a directory with the given \f(CW\*(C`path\*(C'\fR name. Note that it returns false for other objects like files. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a directory also causes the function to return true. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$dirflag = $g\->is_dir_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$dirflag\fR = \f(CW$g\fR\->is_dir_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$dirflag = $g->is_dir_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_dir". .ie n .IP "$flag = $g\->is_fifo ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_fifo ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_fifo ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a FIFO (named pipe) with the given \f(CW\*(C`path\*(C'\fR name. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a FIFO also causes the function to return true. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$flag = $g\->is_fifo_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_fifo_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_fifo_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_fifo". .ie n .IP "$fileflag = $g\->is_file ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$fileflag\fR = \f(CW$g\fR\->is_file ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$fileflag = $g->is_file ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a regular file with the given \f(CW\*(C`path\*(C'\fR name. Note that it returns false for other objects like directories. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a file also causes the function to return true. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$fileflag = $g\->is_file_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$fileflag\fR = \f(CW$g\fR\->is_file_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$fileflag = $g->is_file_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_file". .ie n .IP "$launching = $g\->is_launching ();" 4 .el .IP "\f(CW$launching\fR = \f(CW$g\fR\->is_launching ();" 4 .IX Item "$launching = $g->is_launching ();" This returns true iff this handle is launching the subprocess (in the \f(CW\*(C`LAUNCHING\*(C'\fR state). .Sp For more information on states, see \fBguestfs\fR\|(3). .ie n .IP "$lvflag = $g\->is_lv ($mountable);" 4 .el .IP "\f(CW$lvflag\fR = \f(CW$g\fR\->is_lv ($mountable);" 4 .IX Item "$lvflag = $g->is_lv ($mountable);" This command tests whether \f(CW\*(C`mountable\*(C'\fR is a logical volume, and returns true iff this is the case. .ie n .IP "$ready = $g\->is_ready ();" 4 .el .IP "\f(CW$ready\fR = \f(CW$g\fR\->is_ready ();" 4 .IX Item "$ready = $g->is_ready ();" This returns true iff this handle is ready to accept commands (in the \f(CW\*(C`READY\*(C'\fR state). .Sp For more information on states, see \fBguestfs\fR\|(3). .ie n .IP "$flag = $g\->is_socket ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_socket ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_socket ($path [, followsymlinks => $followsymlinks]);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a Unix domain socket with the given \f(CW\*(C`path\*(C'\fR name. .Sp If the optional flag \f(CW\*(C`followsymlinks\*(C'\fR is true, then a symlink (or chain of symlinks) that ends with a socket also causes the function to return true. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$flag = $g\->is_socket_opts ($path [, followsymlinks => $followsymlinks]);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_socket_opts ($path [, followsymlinks => \f(CW$followsymlinks\fR]);" 4 .IX Item "$flag = $g->is_socket_opts ($path [, followsymlinks => $followsymlinks]);" This is an alias of "is_socket". .ie n .IP "$flag = $g\->is_symlink ($path);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_symlink ($path);" 4 .IX Item "$flag = $g->is_symlink ($path);" This returns \f(CW\*(C`true\*(C'\fR if and only if there is a symbolic link with the given \f(CW\*(C`path\*(C'\fR name. .Sp See also \f(CW\*(C`$g\->stat\*(C'\fR. .ie n .IP "$flag = $g\->is_whole_device ($device);" 4 .el .IP "\f(CW$flag\fR = \f(CW$g\fR\->is_whole_device ($device);" 4 .IX Item "$flag = $g->is_whole_device ($device);" This returns \f(CW\*(C`true\*(C'\fR if and only if \f(CW\*(C`device\*(C'\fR refers to a whole block device. That is, not a partition or a logical device. .ie n .IP "$zeroflag = $g\->is_zero ($path);" 4 .el .IP "\f(CW$zeroflag\fR = \f(CW$g\fR\->is_zero ($path);" 4 .IX Item "$zeroflag = $g->is_zero ($path);" This returns true iff the file exists and the file is empty or it contains all zero bytes. .ie n .IP "$zeroflag = $g\->is_zero_device ($device);" 4 .el .IP "\f(CW$zeroflag\fR = \f(CW$g\fR\->is_zero_device ($device);" 4 .IX Item "$zeroflag = $g->is_zero_device ($device);" This returns true iff the device exists and contains all zero bytes. .Sp Note that for large devices this can take a long time to run. .ie n .IP "%isodata = $g\->isoinfo ($isofile);" 4 .el .IP "\f(CW%isodata\fR = \f(CW$g\fR\->isoinfo ($isofile);" 4 .IX Item "%isodata = $g->isoinfo ($isofile);" This is the same as \f(CW\*(C`$g\->isoinfo_device\*(C'\fR except that it works for an ISO file located inside some other mounted filesystem. Note that in the common case where you have added an ISO file as a libguestfs device, you would \fInot\fR call this. Instead you would call \f(CW\*(C`$g\->isoinfo_device\*(C'\fR. .ie n .IP "%isodata = $g\->isoinfo_device ($device);" 4 .el .IP "\f(CW%isodata\fR = \f(CW$g\fR\->isoinfo_device ($device);" 4 .IX Item "%isodata = $g->isoinfo_device ($device);" \&\f(CW\*(C`device\*(C'\fR is an ISO device. This returns a struct of information read from the primary volume descriptor (the ISO equivalent of the superblock) of the device. .Sp Usually it is more efficient to use the \fBisoinfo\fR\|(1) command with the \fI\-d\fR option on the host to analyze ISO files, instead of going through libguestfs. .Sp For information on the primary volume descriptor fields, see .ie n .IP "$g\->journal_close ();" 4 .el .IP "\f(CW$g\fR\->journal_close ();" 4 .IX Item "$g->journal_close ();" Close the journal handle. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@fields = $g\->journal_get ();" 4 .el .IP "\f(CW@fields\fR = \f(CW$g\fR\->journal_get ();" 4 .IX Item "@fields = $g->journal_get ();" Read the current journal entry. This returns all the fields in the journal as a set of \f(CW\*(C`(attrname, attrval)\*(C'\fR pairs. The \&\f(CW\*(C`attrname\*(C'\fR is the field name (a string). .Sp The \f(CW\*(C`attrval\*(C'\fR is the field value (a binary blob, often but not always a string). Please note that \f(CW\*(C`attrval\*(C'\fR is a byte array, \fInot\fR a \e0\-terminated C string. .Sp The length of data may be truncated to the data threshold (see: \f(CW\*(C`$g\->journal_set_data_threshold\*(C'\fR, \&\f(CW\*(C`$g\->journal_get_data_threshold\*(C'\fR). .Sp If you set the data threshold to unlimited (\f(CW0\fR) then this call can read a journal entry of any size, ie. it is not limited by the libguestfs protocol. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$threshold = $g\->journal_get_data_threshold ();" 4 .el .IP "\f(CW$threshold\fR = \f(CW$g\fR\->journal_get_data_threshold ();" 4 .IX Item "$threshold = $g->journal_get_data_threshold ();" Get the current data threshold for reading journal entries. This is a hint to the journal that it may truncate data fields to this size when reading them (note also that it may not truncate them). If this returns \f(CW0\fR, then the threshold is unlimited. .Sp See also \f(CW\*(C`$g\->journal_set_data_threshold\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$usec = $g\->journal_get_realtime_usec ();" 4 .el .IP "\f(CW$usec\fR = \f(CW$g\fR\->journal_get_realtime_usec ();" 4 .IX Item "$usec = $g->journal_get_realtime_usec ();" Get the realtime (wallclock) timestamp of the current journal entry. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$more = $g\->journal_next ();" 4 .el .IP "\f(CW$more\fR = \f(CW$g\fR\->journal_next ();" 4 .IX Item "$more = $g->journal_next ();" Move to the next journal entry. You have to call this at least once after opening the handle before you are able to read data. .Sp The returned boolean tells you if there are any more journal records to read. \f(CW\*(C`true\*(C'\fR means you can read the next record (eg. using \f(CW\*(C`$g\->journal_get\*(C'\fR), and \f(CW\*(C`false\*(C'\fR means you have reached the end of the journal. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->journal_open ($directory);" 4 .el .IP "\f(CW$g\fR\->journal_open ($directory);" 4 .IX Item "$g->journal_open ($directory);" Open the systemd journal located in \fIdirectory\fR. Any previously opened journal handle is closed. .Sp The contents of the journal can be read using \f(CW\*(C`$g\->journal_next\*(C'\fR and \f(CW\*(C`$g\->journal_get\*(C'\fR. .Sp After you have finished using the journal, you should close the handle by calling \f(CW\*(C`$g\->journal_close\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->journal_set_data_threshold ($threshold);" 4 .el .IP "\f(CW$g\fR\->journal_set_data_threshold ($threshold);" 4 .IX Item "$g->journal_set_data_threshold ($threshold);" Set the data threshold for reading journal entries. This is a hint to the journal that it may truncate data fields to this size when reading them (note also that it may not truncate them). If you set this to \f(CW0\fR, then the threshold is unlimited. .Sp See also \f(CW\*(C`$g\->journal_get_data_threshold\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$rskip = $g\->journal_skip ($skip);" 4 .el .IP "\f(CW$rskip\fR = \f(CW$g\fR\->journal_skip ($skip);" 4 .IX Item "$rskip = $g->journal_skip ($skip);" Skip forwards (\f(CW\*(C`skip ≥ 0\*(C'\fR) or backwards (\f(CW\*(C`skip < 0\*(C'\fR) in the journal. .Sp The number of entries actually skipped is returned (note \f(CW\*(C`rskip\ ≥\ 0\*(C'\fR). If this is not the same as the absolute value of the skip parameter (\f(CW\*(C`|skip|\*(C'\fR) you passed in then it means you have reached the end or the start of the journal. .Sp This function depends on the feature \f(CW\*(C`journal\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->kill_subprocess ();" 4 .el .IP "\f(CW$g\fR\->kill_subprocess ();" 4 .IX Item "$g->kill_subprocess ();" This kills the hypervisor. .Sp Do not call this. See: \f(CW\*(C`$g\->shutdown\*(C'\fR instead. .Sp \&\fIThis function is deprecated.\fR In new code, use the "shutdown" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->launch ();" 4 .el .IP "\f(CW$g\fR\->launch ();" 4 .IX Item "$g->launch ();" You should call this after configuring the handle (eg. adding drives) but before performing any actions. .Sp Do not call \f(CW\*(C`$g\->launch\*(C'\fR twice on the same handle. Although it will not give an error (for historical reasons), the precise behaviour when you do this is not well defined. Handles are very cheap to create, so create a new one for each launch. .ie n .IP "$g\->lchown ($owner, $group, $path);" 4 .el .IP "\f(CW$g\fR\->lchown ($owner, \f(CW$group\fR, \f(CW$path\fR);" 4 .IX Item "$g->lchown ($owner, $group, $path);" Change the file owner to \f(CW\*(C`owner\*(C'\fR and group to \f(CW\*(C`group\*(C'\fR. This is like \f(CW\*(C`$g\->chown\*(C'\fR but if \f(CW\*(C`path\*(C'\fR is a symlink then the link itself is changed, not the target. .Sp Only numeric uid and gid are supported. If you want to use names, you will need to locate and parse the password file yourself (Augeas support makes this relatively easy). .ie n .IP "$g\->ldmtool_create_all ();" 4 .el .IP "\f(CW$g\fR\->ldmtool_create_all ();" 4 .IX Item "$g->ldmtool_create_all ();" This function scans all block devices looking for Windows dynamic disk volumes and partitions, and creates devices for any that were found. .Sp Call \f(CW\*(C`$g\->list_ldm_volumes\*(C'\fR and \f(CW\*(C`$g\->list_ldm_partitions\*(C'\fR to return all devices. .Sp Note that you \fBdon't\fR normally need to call this explicitly, since it is done automatically at \f(CW\*(C`$g\->launch\*(C'\fR time. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@disks = $g\->ldmtool_diskgroup_disks ($diskgroup);" 4 .el .IP "\f(CW@disks\fR = \f(CW$g\fR\->ldmtool_diskgroup_disks ($diskgroup);" 4 .IX Item "@disks = $g->ldmtool_diskgroup_disks ($diskgroup);" Return the disks in a Windows dynamic disk group. The \f(CW\*(C`diskgroup\*(C'\fR parameter should be the GUID of a disk group, one element from the list returned by \f(CW\*(C`$g\->ldmtool_scan\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$name = $g\->ldmtool_diskgroup_name ($diskgroup);" 4 .el .IP "\f(CW$name\fR = \f(CW$g\fR\->ldmtool_diskgroup_name ($diskgroup);" 4 .IX Item "$name = $g->ldmtool_diskgroup_name ($diskgroup);" Return the name of a Windows dynamic disk group. The \f(CW\*(C`diskgroup\*(C'\fR parameter should be the GUID of a disk group, one element from the list returned by \f(CW\*(C`$g\->ldmtool_scan\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@volumes = $g\->ldmtool_diskgroup_volumes ($diskgroup);" 4 .el .IP "\f(CW@volumes\fR = \f(CW$g\fR\->ldmtool_diskgroup_volumes ($diskgroup);" 4 .IX Item "@volumes = $g->ldmtool_diskgroup_volumes ($diskgroup);" Return the volumes in a Windows dynamic disk group. The \f(CW\*(C`diskgroup\*(C'\fR parameter should be the GUID of a disk group, one element from the list returned by \f(CW\*(C`$g\->ldmtool_scan\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->ldmtool_remove_all ();" 4 .el .IP "\f(CW$g\fR\->ldmtool_remove_all ();" 4 .IX Item "$g->ldmtool_remove_all ();" This is essentially the opposite of \f(CW\*(C`$g\->ldmtool_create_all\*(C'\fR. It removes the device mapper mappings for all Windows dynamic disk volumes .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@guids = $g\->ldmtool_scan ();" 4 .el .IP "\f(CW@guids\fR = \f(CW$g\fR\->ldmtool_scan ();" 4 .IX Item "@guids = $g->ldmtool_scan ();" This function scans for Windows dynamic disks. It returns a list of identifiers (GUIDs) for all disk groups that were found. These identifiers can be passed to other \f(CW\*(C`$g\->ldmtool_*\*(C'\fR functions. .Sp This function scans all block devices. To scan a subset of block devices, call \f(CW\*(C`$g\->ldmtool_scan_devices\*(C'\fR instead. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@guids = $g\->ldmtool_scan_devices (\e@devices);" 4 .el .IP "\f(CW@guids\fR = \f(CW$g\fR\->ldmtool_scan_devices (\e@devices);" 4 .IX Item "@guids = $g->ldmtool_scan_devices (@devices);" This function scans for Windows dynamic disks. It returns a list of identifiers (GUIDs) for all disk groups that were found. These identifiers can be passed to other \f(CW\*(C`$g\->ldmtool_*\*(C'\fR functions. .Sp The parameter \f(CW\*(C`devices\*(C'\fR is a list of block devices which are scanned. If this list is empty, all block devices are scanned. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$hint = $g\->ldmtool_volume_hint ($diskgroup, $volume);" 4 .el .IP "\f(CW$hint\fR = \f(CW$g\fR\->ldmtool_volume_hint ($diskgroup, \f(CW$volume\fR);" 4 .IX Item "$hint = $g->ldmtool_volume_hint ($diskgroup, $volume);" Return the hint field of the volume named \f(CW\*(C`volume\*(C'\fR in the disk group with GUID \f(CW\*(C`diskgroup\*(C'\fR. This may not be defined, in which case the empty string is returned. The hint field is often, though not always, the name of a Windows drive, eg. \f(CW\*(C`E:\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@partitions = $g\->ldmtool_volume_partitions ($diskgroup, $volume);" 4 .el .IP "\f(CW@partitions\fR = \f(CW$g\fR\->ldmtool_volume_partitions ($diskgroup, \f(CW$volume\fR);" 4 .IX Item "@partitions = $g->ldmtool_volume_partitions ($diskgroup, $volume);" Return the list of partitions in the volume named \f(CW\*(C`volume\*(C'\fR in the disk group with GUID \f(CW\*(C`diskgroup\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$voltype = $g\->ldmtool_volume_type ($diskgroup, $volume);" 4 .el .IP "\f(CW$voltype\fR = \f(CW$g\fR\->ldmtool_volume_type ($diskgroup, \f(CW$volume\fR);" 4 .IX Item "$voltype = $g->ldmtool_volume_type ($diskgroup, $volume);" Return the type of the volume named \f(CW\*(C`volume\*(C'\fR in the disk group with GUID \f(CW\*(C`diskgroup\*(C'\fR. .Sp Possible volume types that can be returned here include: \&\f(CW\*(C`simple\*(C'\fR, \f(CW\*(C`spanned\*(C'\fR, \f(CW\*(C`striped\*(C'\fR, \f(CW\*(C`mirrored\*(C'\fR, \f(CW\*(C`raid5\*(C'\fR. Other types may also be returned. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$xattr = $g\->lgetxattr ($path, $name);" 4 .el .IP "\f(CW$xattr\fR = \f(CW$g\fR\->lgetxattr ($path, \f(CW$name\fR);" 4 .IX Item "$xattr = $g->lgetxattr ($path, $name);" Get a single extended attribute from file \f(CW\*(C`path\*(C'\fR named \f(CW\*(C`name\*(C'\fR. If \f(CW\*(C`path\*(C'\fR is a symlink, then this call returns an extended attribute from the symlink. .Sp Normally it is better to get all extended attributes from a file in one go by calling \f(CW\*(C`$g\->getxattrs\*(C'\fR. However some Linux filesystem implementations are buggy and do not provide a way to list out attributes. For these filesystems (notably ntfs\-3g) you have to know the names of the extended attributes you want in advance and call this function. .Sp Extended attribute values are blobs of binary data. If there is no extended attribute named \f(CW\*(C`name\*(C'\fR, this returns an error. .Sp See also: \f(CW\*(C`$g\->lgetxattrs\*(C'\fR, \f(CW\*(C`$g\->getxattr\*(C'\fR, \fBattr\fR\|(5). .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@xattrs = $g\->lgetxattrs ($path);" 4 .el .IP "\f(CW@xattrs\fR = \f(CW$g\fR\->lgetxattrs ($path);" 4 .IX Item "@xattrs = $g->lgetxattrs ($path);" This is the same as \f(CW\*(C`$g\->getxattrs\*(C'\fR, but if \f(CW\*(C`path\*(C'\fR is a symbolic link, then it returns the extended attributes of the link itself. .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@mounttags = $g\->list_9p ();" 4 .el .IP "\f(CW@mounttags\fR = \f(CW$g\fR\->list_9p ();" 4 .IX Item "@mounttags = $g->list_9p ();" This call does nothing and returns an error. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@devices = $g\->list_devices ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->list_devices ();" 4 .IX Item "@devices = $g->list_devices ();" List all the block devices. .Sp The full block device names are returned, eg. \fI/dev/sda\fR. .Sp See also \f(CW\*(C`$g\->list_filesystems\*(C'\fR. .ie n .IP "%labels = $g\->list_disk_labels ();" 4 .el .IP "\f(CW%labels\fR = \f(CW$g\fR\->list_disk_labels ();" 4 .IX Item "%labels = $g->list_disk_labels ();" If you add drives using the optional \f(CW\*(C`label\*(C'\fR parameter of \f(CW\*(C`$g\->add_drive_opts\*(C'\fR, you can use this call to map between disk labels, and raw block device and partition names (like \fI/dev/sda\fR and \fI/dev/sda1\fR). .Sp This returns a hashtable, where keys are the disk labels (\fIwithout\fR the \fI/dev/disk/guestfs\fR prefix), and the values are the full raw block device and partition names (eg. \fI/dev/sda\fR and \fI/dev/sda1\fR). .ie n .IP "@devices = $g\->list_dm_devices ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->list_dm_devices ();" 4 .IX Item "@devices = $g->list_dm_devices ();" List all device mapper devices. .Sp The returned list contains \fI/dev/mapper/*\fR devices, eg. ones created by a previous call to \f(CW\*(C`$g\->luks_open\*(C'\fR. .Sp Device mapper devices which correspond to logical volumes are \fInot\fR returned in this list. Call \f(CW\*(C`$g\->lvs\*(C'\fR if you want to list logical volumes. .ie n .IP "%fses = $g\->list_filesystems ();" 4 .el .IP "\f(CW%fses\fR = \f(CW$g\fR\->list_filesystems ();" 4 .IX Item "%fses = $g->list_filesystems ();" This inspection command looks for filesystems on partitions, block devices and logical volumes, returning a list of \f(CW\*(C`mountables\*(C'\fR containing filesystems and their type. .Sp The return value is a hash, where the keys are the devices containing filesystems, and the values are the filesystem types. For example: .Sp .Vb 4 \& "/dev/sda1" => "ntfs" \& "/dev/sda2" => "ext2" \& "/dev/vg_guest/lv_root" => "ext4" \& "/dev/vg_guest/lv_swap" => "swap" .Ve .Sp The key is not necessarily a block device. It may also be an opaque ‘mountable’ string which can be passed to \f(CW\*(C`$g\->mount\*(C'\fR. .Sp The value can have the special value "unknown", meaning the content of the device is undetermined or empty. "swap" means a Linux swap partition. .Sp In libguestfs ≤ 1.36 this command ran other libguestfs commands, which might have included \f(CW\*(C`$g\->mount\*(C'\fR and \f(CW\*(C`$g\->umount\*(C'\fR, and therefore you had to use this soon after launch and only when nothing else was mounted. This restriction is removed in libguestfs ≥ 1.38. .Sp Not all of the filesystems returned will be mountable. In particular, swap partitions are returned in the list. Also this command does not check that each filesystem found is valid and mountable, and some filesystems might be mountable but require special options. Filesystems may not all belong to a single logical operating system (use \f(CW\*(C`$g\->inspect_os\*(C'\fR to look for OSes). .ie n .IP "@devices = $g\->list_ldm_partitions ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->list_ldm_partitions ();" 4 .IX Item "@devices = $g->list_ldm_partitions ();" This function returns all Windows dynamic disk partitions that were found at launch time. It returns a list of device names. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@devices = $g\->list_ldm_volumes ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->list_ldm_volumes ();" 4 .IX Item "@devices = $g->list_ldm_volumes ();" This function returns all Windows dynamic disk volumes that were found at launch time. It returns a list of device names. .Sp This function depends on the feature \f(CW\*(C`ldm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@devices = $g\->list_md_devices ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->list_md_devices ();" 4 .IX Item "@devices = $g->list_md_devices ();" List all Linux md devices. .ie n .IP "@partitions = $g\->list_partitions ();" 4 .el .IP "\f(CW@partitions\fR = \f(CW$g\fR\->list_partitions ();" 4 .IX Item "@partitions = $g->list_partitions ();" List all the partitions detected on all block devices. .Sp The full partition device names are returned, eg. \fI/dev/sda1\fR .Sp This does not return logical volumes. For that you will need to call \f(CW\*(C`$g\->lvs\*(C'\fR. .Sp See also \f(CW\*(C`$g\->list_filesystems\*(C'\fR. .ie n .IP "$listing = $g\->ll ($directory);" 4 .el .IP "\f(CW$listing\fR = \f(CW$g\fR\->ll ($directory);" 4 .IX Item "$listing = $g->ll ($directory);" List the files in \fIdirectory\fR (relative to the root directory, there is no cwd) in the format of \f(CW\*(C`ls \-la\*(C'\fR. .Sp This command is mostly useful for interactive sessions. It is \fInot\fR intended that you try to parse the output string. .ie n .IP "$listing = $g\->llz ($directory);" 4 .el .IP "\f(CW$listing\fR = \f(CW$g\fR\->llz ($directory);" 4 .IX Item "$listing = $g->llz ($directory);" List the files in \fIdirectory\fR in the format of \f(CW\*(C`ls \-laZ\*(C'\fR. .Sp This command is mostly useful for interactive sessions. It is \fInot\fR intended that you try to parse the output string. .Sp \&\fIThis function is deprecated.\fR In new code, use the "lgetxattrs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->ln ($target, $linkname);" 4 .el .IP "\f(CW$g\fR\->ln ($target, \f(CW$linkname\fR);" 4 .IX Item "$g->ln ($target, $linkname);" This command creates a hard link. .ie n .IP "$g\->ln_f ($target, $linkname);" 4 .el .IP "\f(CW$g\fR\->ln_f ($target, \f(CW$linkname\fR);" 4 .IX Item "$g->ln_f ($target, $linkname);" This command creates a hard link, removing the link \f(CW\*(C`linkname\*(C'\fR if it exists already. .ie n .IP "$g\->ln_s ($target, $linkname);" 4 .el .IP "\f(CW$g\fR\->ln_s ($target, \f(CW$linkname\fR);" 4 .IX Item "$g->ln_s ($target, $linkname);" This command creates a symbolic link using the \f(CW\*(C`ln \-s\*(C'\fR command. .ie n .IP "$g\->ln_sf ($target, $linkname);" 4 .el .IP "\f(CW$g\fR\->ln_sf ($target, \f(CW$linkname\fR);" 4 .IX Item "$g->ln_sf ($target, $linkname);" This command creates a symbolic link using the \f(CW\*(C`ln \-sf\*(C'\fR command, The \fI\-f\fR option removes the link (\f(CW\*(C`linkname\*(C'\fR) if it exists already. .ie n .IP "$g\->lremovexattr ($xattr, $path);" 4 .el .IP "\f(CW$g\fR\->lremovexattr ($xattr, \f(CW$path\fR);" 4 .IX Item "$g->lremovexattr ($xattr, $path);" This is the same as \f(CW\*(C`$g\->removexattr\*(C'\fR, but if \f(CW\*(C`path\*(C'\fR is a symbolic link, then it removes an extended attribute of the link itself. .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@listing = $g\->ls ($directory);" 4 .el .IP "\f(CW@listing\fR = \f(CW$g\fR\->ls ($directory);" 4 .IX Item "@listing = $g->ls ($directory);" List the files in \fIdirectory\fR (relative to the root directory, there is no cwd). The \f(CW\*(C`.\*(C'\fR and \f(CW\*(C`..\*(C'\fR entries are not returned, but hidden files are shown. .ie n .IP "$g\->ls0 ($dir, $filenames);" 4 .el .IP "\f(CW$g\fR\->ls0 ($dir, \f(CW$filenames\fR);" 4 .IX Item "$g->ls0 ($dir, $filenames);" This specialized command is used to get a listing of the filenames in the directory \f(CW\*(C`dir\*(C'\fR. The list of filenames is written to the local file \fIfilenames\fR (on the host). .Sp In the output file, the filenames are separated by \f(CW\*(C`\e0\*(C'\fR characters. .Sp \&\f(CW\*(C`.\*(C'\fR and \f(CW\*(C`..\*(C'\fR are not returned. The filenames are not sorted. .ie n .IP "$g\->lsetxattr ($xattr, $val, $vallen, $path);" 4 .el .IP "\f(CW$g\fR\->lsetxattr ($xattr, \f(CW$val\fR, \f(CW$vallen\fR, \f(CW$path\fR);" 4 .IX Item "$g->lsetxattr ($xattr, $val, $vallen, $path);" This is the same as \f(CW\*(C`$g\->setxattr\*(C'\fR, but if \f(CW\*(C`path\*(C'\fR is a symbolic link, then it sets an extended attribute of the link itself. .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%statbuf = $g\->lstat ($path);" 4 .el .IP "\f(CW%statbuf\fR = \f(CW$g\fR\->lstat ($path);" 4 .IX Item "%statbuf = $g->lstat ($path);" Returns file information for the given \f(CW\*(C`path\*(C'\fR. .Sp This is the same as \f(CW\*(C`$g\->stat\*(C'\fR except that if \f(CW\*(C`path\*(C'\fR is a symbolic link, then the link is stat-ed, not the file it refers to. .Sp This is the same as the \fBlstat\fR\|(2) system call. .Sp \&\fIThis function is deprecated.\fR In new code, use the "lstatns" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@statbufs = $g\->lstatlist ($path, \e@names);" 4 .el .IP "\f(CW@statbufs\fR = \f(CW$g\fR\->lstatlist ($path, \e@names);" 4 .IX Item "@statbufs = $g->lstatlist ($path, @names);" This call allows you to perform the \f(CW\*(C`$g\->lstat\*(C'\fR operation on multiple files, where all files are in the directory \f(CW\*(C`path\*(C'\fR. \&\f(CW\*(C`names\*(C'\fR is the list of files from this directory. .Sp On return you get a list of stat structs, with a one-to-one correspondence to the \f(CW\*(C`names\*(C'\fR list. If any name did not exist or could not be lstat'd, then the \f(CW\*(C`st_ino\*(C'\fR field of that structure is set to \f(CW\-1\fR. .Sp This call is intended for programs that want to efficiently list a directory contents without making many round-trips. See also \f(CW\*(C`$g\->lxattrlist\*(C'\fR for a similarly efficient call for getting extended attributes. .Sp \&\fIThis function is deprecated.\fR In new code, use the "lstatnslist" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "%statbuf = $g\->lstatns ($path);" 4 .el .IP "\f(CW%statbuf\fR = \f(CW$g\fR\->lstatns ($path);" 4 .IX Item "%statbuf = $g->lstatns ($path);" Returns file information for the given \f(CW\*(C`path\*(C'\fR. .Sp This is the same as \f(CW\*(C`$g\->statns\*(C'\fR except that if \f(CW\*(C`path\*(C'\fR is a symbolic link, then the link is stat-ed, not the file it refers to. .Sp This is the same as the \fBlstat\fR\|(2) system call. .ie n .IP "@statbufs = $g\->lstatnslist ($path, \e@names);" 4 .el .IP "\f(CW@statbufs\fR = \f(CW$g\fR\->lstatnslist ($path, \e@names);" 4 .IX Item "@statbufs = $g->lstatnslist ($path, @names);" This call allows you to perform the \f(CW\*(C`$g\->lstatns\*(C'\fR operation on multiple files, where all files are in the directory \f(CW\*(C`path\*(C'\fR. \&\f(CW\*(C`names\*(C'\fR is the list of files from this directory. .Sp On return you get a list of stat structs, with a one-to-one correspondence to the \f(CW\*(C`names\*(C'\fR list. If any name did not exist or could not be lstat'd, then the \f(CW\*(C`st_ino\*(C'\fR field of that structure is set to \f(CW\-1\fR. .Sp This call is intended for programs that want to efficiently list a directory contents without making many round-trips. See also \f(CW\*(C`$g\->lxattrlist\*(C'\fR for a similarly efficient call for getting extended attributes. .ie n .IP "$g\->luks_add_key ($device, $key, $newkey, $keyslot);" 4 .el .IP "\f(CW$g\fR\->luks_add_key ($device, \f(CW$key\fR, \f(CW$newkey\fR, \f(CW$keyslot\fR);" 4 .IX Item "$g->luks_add_key ($device, $key, $newkey, $keyslot);" This command adds a new key on LUKS device \f(CW\*(C`device\*(C'\fR. \&\f(CW\*(C`key\*(C'\fR is any existing key, and is used to access the device. \&\f(CW\*(C`newkey\*(C'\fR is the new key to add. \f(CW\*(C`keyslot\*(C'\fR is the key slot that will be replaced. .Sp Note that if \f(CW\*(C`keyslot\*(C'\fR already contains a key, then this command will fail. You have to use \f(CW\*(C`$g\->luks_kill_slot\*(C'\fR first to remove that key. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->luks_close ($device);" 4 .el .IP "\f(CW$g\fR\->luks_close ($device);" 4 .IX Item "$g->luks_close ($device);" This closes a LUKS device that was created earlier by \&\f(CW\*(C`$g\->luks_open\*(C'\fR or \f(CW\*(C`$g\->luks_open_ro\*(C'\fR. The \&\f(CW\*(C`device\*(C'\fR parameter must be the name of the LUKS mapping device (ie. \fI/dev/mapper/mapname\fR) and \fInot\fR the name of the underlying block device. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "cryptsetup_close" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->luks_format ($device, $key, $keyslot);" 4 .el .IP "\f(CW$g\fR\->luks_format ($device, \f(CW$key\fR, \f(CW$keyslot\fR);" 4 .IX Item "$g->luks_format ($device, $key, $keyslot);" This command erases existing data on \f(CW\*(C`device\*(C'\fR and formats the device as a LUKS encrypted device. \f(CW\*(C`key\*(C'\fR is the initial key, which is added to key slot \f(CW\*(C`keyslot\*(C'\fR. (LUKS supports 8 key slots, numbered 0\-7). .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->luks_format_cipher ($device, $key, $keyslot, $cipher);" 4 .el .IP "\f(CW$g\fR\->luks_format_cipher ($device, \f(CW$key\fR, \f(CW$keyslot\fR, \f(CW$cipher\fR);" 4 .IX Item "$g->luks_format_cipher ($device, $key, $keyslot, $cipher);" This command is the same as \f(CW\*(C`$g\->luks_format\*(C'\fR but it also allows you to set the \f(CW\*(C`cipher\*(C'\fR used. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->luks_kill_slot ($device, $key, $keyslot);" 4 .el .IP "\f(CW$g\fR\->luks_kill_slot ($device, \f(CW$key\fR, \f(CW$keyslot\fR);" 4 .IX Item "$g->luks_kill_slot ($device, $key, $keyslot);" This command deletes the key in key slot \f(CW\*(C`keyslot\*(C'\fR from the encrypted LUKS device \f(CW\*(C`device\*(C'\fR. \f(CW\*(C`key\*(C'\fR must be one of the \&\fIother\fR keys. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->luks_open ($device, $key, $mapname);" 4 .el .IP "\f(CW$g\fR\->luks_open ($device, \f(CW$key\fR, \f(CW$mapname\fR);" 4 .IX Item "$g->luks_open ($device, $key, $mapname);" This command opens a block device which has been encrypted according to the Linux Unified Key Setup (LUKS) standard. .Sp \&\f(CW\*(C`device\*(C'\fR is the encrypted block device or partition. .Sp The caller must supply one of the keys associated with the LUKS block device, in the \f(CW\*(C`key\*(C'\fR parameter. .Sp This creates a new block device called \fI/dev/mapper/mapname\fR. Reads and writes to this block device are decrypted from and encrypted to the underlying \f(CW\*(C`device\*(C'\fR respectively. .Sp If this block device contains LVM volume groups, then calling \f(CW\*(C`$g\->lvm_scan\*(C'\fR with the \f(CW\*(C`activate\*(C'\fR parameter \f(CW\*(C`true\*(C'\fR will make them visible. .Sp Use \f(CW\*(C`$g\->list_dm_devices\*(C'\fR to list all device mapper devices. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "cryptsetup_open" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->luks_open_ro ($device, $key, $mapname);" 4 .el .IP "\f(CW$g\fR\->luks_open_ro ($device, \f(CW$key\fR, \f(CW$mapname\fR);" 4 .IX Item "$g->luks_open_ro ($device, $key, $mapname);" This is the same as \f(CW\*(C`$g\->luks_open\*(C'\fR except that a read-only mapping is created. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "cryptsetup_open" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$uuid = $g\->luks_uuid ($device);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->luks_uuid ($device);" 4 .IX Item "$uuid = $g->luks_uuid ($device);" This returns the UUID of the LUKS device \f(CW\*(C`device\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`luks\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvcreate ($logvol, $volgroup, $mbytes);" 4 .el .IP "\f(CW$g\fR\->lvcreate ($logvol, \f(CW$volgroup\fR, \f(CW$mbytes\fR);" 4 .IX Item "$g->lvcreate ($logvol, $volgroup, $mbytes);" This creates an LVM logical volume called \f(CW\*(C`logvol\*(C'\fR on the volume group \f(CW\*(C`volgroup\*(C'\fR, with \f(CW\*(C`size\*(C'\fR megabytes. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvcreate_free ($logvol, $volgroup, $percent);" 4 .el .IP "\f(CW$g\fR\->lvcreate_free ($logvol, \f(CW$volgroup\fR, \f(CW$percent\fR);" 4 .IX Item "$g->lvcreate_free ($logvol, $volgroup, $percent);" Create an LVM logical volume called \fI/dev/volgroup/logvol\fR, using approximately \f(CW\*(C`percent\*(C'\fR % of the free space remaining in the volume group. Most usefully, when \f(CW\*(C`percent\*(C'\fR is \f(CW100\fR this will create the largest possible LV. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$lv = $g\->lvm_canonical_lv_name ($lvname);" 4 .el .IP "\f(CW$lv\fR = \f(CW$g\fR\->lvm_canonical_lv_name ($lvname);" 4 .IX Item "$lv = $g->lvm_canonical_lv_name ($lvname);" This converts alternative naming schemes for LVs that you might find to the canonical name. For example, \fI/dev/mapper/VG\-LV\fR is converted to \fI/dev/VG/LV\fR. .Sp This command returns an error if the \f(CW\*(C`lvname\*(C'\fR parameter does not refer to a logical volume. In this case errno will be set to \f(CW\*(C`EINVAL\*(C'\fR. .Sp See also \f(CW\*(C`$g\->is_lv\*(C'\fR, \f(CW\*(C`$g\->canonical_device_name\*(C'\fR. .ie n .IP "$g\->lvm_clear_filter ();" 4 .el .IP "\f(CW$g\fR\->lvm_clear_filter ();" 4 .IX Item "$g->lvm_clear_filter ();" This undoes the effect of \f(CW\*(C`$g\->lvm_set_filter\*(C'\fR. LVM will be able to see every block device. .Sp This command also clears the LVM cache and performs a volume group scan. .ie n .IP "$g\->lvm_remove_all ();" 4 .el .IP "\f(CW$g\fR\->lvm_remove_all ();" 4 .IX Item "$g->lvm_remove_all ();" This command removes all LVM logical volumes, volume groups and physical volumes. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvm_scan ($activate);" 4 .el .IP "\f(CW$g\fR\->lvm_scan ($activate);" 4 .IX Item "$g->lvm_scan ($activate);" This scans all block devices and rebuilds the list of LVM physical volumes, volume groups and logical volumes. .Sp If the \f(CW\*(C`activate\*(C'\fR parameter is \f(CW\*(C`true\*(C'\fR then newly found volume groups and logical volumes are activated, meaning the LV \fI/dev/VG/LV\fR devices become visible. .Sp When a libguestfs handle is launched it scans for existing devices, so you do not normally need to use this API. However it is useful when you have added a new device or deleted an existing device (such as when the \f(CW\*(C`$g\->luks_open\*(C'\fR API is used). .ie n .IP "$g\->lvm_set_filter (\e@devices);" 4 .el .IP "\f(CW$g\fR\->lvm_set_filter (\e@devices);" 4 .IX Item "$g->lvm_set_filter (@devices);" This sets the LVM device filter so that LVM will only be able to "see" the block devices in the list \f(CW\*(C`devices\*(C'\fR, and will ignore all other attached block devices. .Sp Where disk image(s) contain duplicate PVs or VGs, this command is useful to get LVM to ignore the duplicates, otherwise LVM can get confused. Note also there are two types of duplication possible: either cloned PVs/VGs which have identical UUIDs; or VGs that are not cloned but just happen to have the same name. In normal operation you cannot create this situation, but you can do it outside LVM, eg. by cloning disk images or by bit twiddling inside the LVM metadata. .Sp This command also clears the LVM cache and performs a volume group scan. .Sp You can filter whole block devices or individual partitions. .Sp You cannot use this if any VG is currently in use (eg. contains a mounted filesystem), even if you are not filtering out that VG. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvremove ($device);" 4 .el .IP "\f(CW$g\fR\->lvremove ($device);" 4 .IX Item "$g->lvremove ($device);" Remove an LVM logical volume \f(CW\*(C`device\*(C'\fR, where \f(CW\*(C`device\*(C'\fR is the path to the LV, such as \fI/dev/VG/LV\fR. .Sp You can also remove all LVs in a volume group by specifying the VG name, \fI/dev/VG\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvrename ($logvol, $newlogvol);" 4 .el .IP "\f(CW$g\fR\->lvrename ($logvol, \f(CW$newlogvol\fR);" 4 .IX Item "$g->lvrename ($logvol, $newlogvol);" Rename a logical volume \f(CW\*(C`logvol\*(C'\fR with the new name \f(CW\*(C`newlogvol\*(C'\fR. .ie n .IP "$g\->lvresize ($device, $mbytes);" 4 .el .IP "\f(CW$g\fR\->lvresize ($device, \f(CW$mbytes\fR);" 4 .IX Item "$g->lvresize ($device, $mbytes);" This resizes (expands or shrinks) an existing LVM logical volume to \f(CW\*(C`mbytes\*(C'\fR. When reducing, data in the reduced part is lost. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->lvresize_free ($lv, $percent);" 4 .el .IP "\f(CW$g\fR\->lvresize_free ($lv, \f(CW$percent\fR);" 4 .IX Item "$g->lvresize_free ($lv, $percent);" This expands an existing logical volume \f(CW\*(C`lv\*(C'\fR so that it fills \&\f(CW\*(C`pc\*(C'\fR % of the remaining free space in the volume group. Commonly you would call this with pc = 100 which expands the logical volume as much as possible, using all remaining free space in the volume group. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@logvols = $g\->lvs ();" 4 .el .IP "\f(CW@logvols\fR = \f(CW$g\fR\->lvs ();" 4 .IX Item "@logvols = $g->lvs ();" List all the logical volumes detected. This is the equivalent of the \fBlvs\fR\|(8) command. .Sp This returns a list of the logical volume device names (eg. \fI/dev/VolGroup00/LogVol00\fR). .Sp See also \f(CW\*(C`$g\->lvs_full\*(C'\fR, \f(CW\*(C`$g\->list_filesystems\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@logvols = $g\->lvs_full ();" 4 .el .IP "\f(CW@logvols\fR = \f(CW$g\fR\->lvs_full ();" 4 .IX Item "@logvols = $g->lvs_full ();" List all the logical volumes detected. This is the equivalent of the \fBlvs\fR\|(8) command. The "full" version includes all fields. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$uuid = $g\->lvuuid ($device);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->lvuuid ($device);" 4 .IX Item "$uuid = $g->lvuuid ($device);" This command returns the UUID of the LVM LV \f(CW\*(C`device\*(C'\fR. .ie n .IP "@xattrs = $g\->lxattrlist ($path, \e@names);" 4 .el .IP "\f(CW@xattrs\fR = \f(CW$g\fR\->lxattrlist ($path, \e@names);" 4 .IX Item "@xattrs = $g->lxattrlist ($path, @names);" This call allows you to get the extended attributes of multiple files, where all files are in the directory \f(CW\*(C`path\*(C'\fR. \&\f(CW\*(C`names\*(C'\fR is the list of files from this directory. .Sp On return you get a flat list of xattr structs which must be interpreted sequentially. The first xattr struct always has a zero-length \&\f(CW\*(C`attrname\*(C'\fR. \f(CW\*(C`attrval\*(C'\fR in this struct is zero-length to indicate there was an error doing \f(CW\*(C`$g\->lgetxattr\*(C'\fR for this file, \fIor\fR is a C string which is a decimal number (the number of following attributes for this file, which could be \f(CW"0"\fR). Then after the first xattr struct are the zero or more attributes for the first named file. This repeats for the second and subsequent files. .Sp This call is intended for programs that want to efficiently list a directory contents without making many round-trips. See also \f(CW\*(C`$g\->lstatlist\*(C'\fR for a similarly efficient call for getting standard stats. .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$disks = $g\->max_disks ();" 4 .el .IP "\f(CW$disks\fR = \f(CW$g\fR\->max_disks ();" 4 .IX Item "$disks = $g->max_disks ();" Return the maximum number of disks that may be added to a handle (eg. by \f(CW\*(C`$g\->add_drive_opts\*(C'\fR and similar calls). .Sp This function was added in libguestfs 1.19.7. In previous versions of libguestfs the limit was 25. .Sp See "MAXIMUM NUMBER OF DISKS" in \fBguestfs\fR\|(3) for additional information on this topic. .ie n .IP "$g\->md_create ($name, \e@devices [, missingbitmap => $missingbitmap] [, nrdevices => $nrdevices] [, spare => $spare] [, chunk => $chunk] [, level => $level]);" 4 .el .IP "\f(CW$g\fR\->md_create ($name, \e@devices [, missingbitmap => \f(CW$missingbitmap\fR] [, nrdevices => \f(CW$nrdevices\fR] [, spare => \f(CW$spare\fR] [, chunk => \f(CW$chunk\fR] [, level => \f(CW$level\fR]);" 4 .IX Item "$g->md_create ($name, @devices [, missingbitmap => $missingbitmap] [, nrdevices => $nrdevices] [, spare => $spare] [, chunk => $chunk] [, level => $level]);" Create a Linux md (RAID) device named \f(CW\*(C`name\*(C'\fR on the devices in the list \f(CW\*(C`devices\*(C'\fR. .Sp The optional parameters are: .RS 4 .ie n .IP """missingbitmap""" 4 .el .IP \f(CWmissingbitmap\fR 4 .IX Item "missingbitmap" A bitmap of missing devices. If a bit is set it means that a missing device is added to the array. The least significant bit corresponds to the first device in the array. .Sp As examples: .Sp If \f(CW\*(C`devices = ["/dev/sda"]\*(C'\fR and \f(CW\*(C`missingbitmap = 0x1\*(C'\fR then the resulting array would be \f(CW\*(C`[, "/dev/sda"]\*(C'\fR. .Sp If \f(CW\*(C`devices = ["/dev/sda"]\*(C'\fR and \f(CW\*(C`missingbitmap = 0x2\*(C'\fR then the resulting array would be \f(CW\*(C`["/dev/sda", ]\*(C'\fR. .Sp This defaults to \f(CW0\fR (no missing devices). .Sp The length of \f(CW\*(C`devices\*(C'\fR + the number of bits set in \&\f(CW\*(C`missingbitmap\*(C'\fR must equal \f(CW\*(C`nrdevices\*(C'\fR + \f(CW\*(C`spare\*(C'\fR. .ie n .IP """nrdevices""" 4 .el .IP \f(CWnrdevices\fR 4 .IX Item "nrdevices" The number of active RAID devices. .Sp If not set, this defaults to the length of \f(CW\*(C`devices\*(C'\fR plus the number of bits set in \f(CW\*(C`missingbitmap\*(C'\fR. .ie n .IP """spare""" 4 .el .IP \f(CWspare\fR 4 .IX Item "spare" The number of spare devices. .Sp If not set, this defaults to \f(CW0\fR. .ie n .IP """chunk""" 4 .el .IP \f(CWchunk\fR 4 .IX Item "chunk" The chunk size in bytes. .Sp The \f(CW\*(C`chunk\*(C'\fR parameter does not make sense, and should not be specified, when \f(CW\*(C`level\*(C'\fR is \f(CW\*(C`raid1\*(C'\fR (which is the default; see below). .ie n .IP """level""" 4 .el .IP \f(CWlevel\fR 4 .IX Item "level" The RAID level, which can be one of: \&\f(CW\*(C`linear\*(C'\fR, \f(CW\*(C`raid0\*(C'\fR, \f(CW0\fR, \f(CW\*(C`stripe\*(C'\fR, \f(CW\*(C`raid1\*(C'\fR, \f(CW1\fR, \f(CW\*(C`mirror\*(C'\fR, \&\f(CW\*(C`raid4\*(C'\fR, \f(CW4\fR, \f(CW\*(C`raid5\*(C'\fR, \f(CW5\fR, \f(CW\*(C`raid6\*(C'\fR, \f(CW6\fR, \f(CW\*(C`raid10\*(C'\fR, \f(CW10\fR. Some of these are synonymous, and more levels may be added in future. .Sp If not set, this defaults to \f(CW\*(C`raid1\*(C'\fR. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`mdadm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "%info = $g\->md_detail ($md);" 4 .el .IP "\f(CW%info\fR = \f(CW$g\fR\->md_detail ($md);" 4 .IX Item "%info = $g->md_detail ($md);" This command exposes the output of \f(CW\*(C`mdadm \-DY \*(C'\fR. The following fields are usually present in the returned hash. Other fields may also be present. .RS 4 .ie n .IP """level""" 4 .el .IP \f(CWlevel\fR 4 .IX Item "level" The raid level of the MD device. .ie n .IP """devices""" 4 .el .IP \f(CWdevices\fR 4 .IX Item "devices" The number of underlying devices in the MD device. .ie n .IP """metadata""" 4 .el .IP \f(CWmetadata\fR 4 .IX Item "metadata" The metadata version used. .ie n .IP """uuid""" 4 .el .IP \f(CWuuid\fR 4 .IX Item "uuid" The UUID of the MD device. .ie n .IP """name""" 4 .el .IP \f(CWname\fR 4 .IX Item "name" The name of the MD device. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`mdadm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "@devices = $g\->md_stat ($md);" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->md_stat ($md);" 4 .IX Item "@devices = $g->md_stat ($md);" This call returns a list of the underlying devices which make up the single software RAID array device \f(CW\*(C`md\*(C'\fR. .Sp To get a list of software RAID devices, call \f(CW\*(C`$g\->list_md_devices\*(C'\fR. .Sp Each structure returned corresponds to one device along with additional status information: .RS 4 .ie n .IP """mdstat_device""" 4 .el .IP \f(CWmdstat_device\fR 4 .IX Item "mdstat_device" The name of the underlying device. .ie n .IP """mdstat_index""" 4 .el .IP \f(CWmdstat_index\fR 4 .IX Item "mdstat_index" The index of this device within the array. .ie n .IP """mdstat_flags""" 4 .el .IP \f(CWmdstat_flags\fR 4 .IX Item "mdstat_flags" Flags associated with this device. This is a string containing (in no specific order) zero or more of the following flags: .RS 4 .ie n .IP """W""" 4 .el .IP \f(CWW\fR 4 .IX Item "W" write-mostly .ie n .IP """F""" 4 .el .IP \f(CWF\fR 4 .IX Item "F" device is faulty .ie n .IP """S""" 4 .el .IP \f(CWS\fR 4 .IX Item "S" device is a RAID spare .ie n .IP """R""" 4 .el .IP \f(CWR\fR 4 .IX Item "R" replacement .RE .RS 4 .RE .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`mdadm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->md_stop ($md);" 4 .el .IP "\f(CW$g\fR\->md_stop ($md);" 4 .IX Item "$g->md_stop ($md);" This command deactivates the MD array named \f(CW\*(C`md\*(C'\fR. The device is stopped, but it is not destroyed or zeroed. .Sp This function depends on the feature \f(CW\*(C`mdadm\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mkdir ($path);" 4 .el .IP "\f(CW$g\fR\->mkdir ($path);" 4 .IX Item "$g->mkdir ($path);" Create a directory named \f(CW\*(C`path\*(C'\fR. .ie n .IP "$g\->mkdir_mode ($path, $mode);" 4 .el .IP "\f(CW$g\fR\->mkdir_mode ($path, \f(CW$mode\fR);" 4 .IX Item "$g->mkdir_mode ($path, $mode);" This command creates a directory, setting the initial permissions of the directory to \f(CW\*(C`mode\*(C'\fR. .Sp For common Linux filesystems, the actual mode which is set will be \f(CW\*(C`mode & ~umask & 01777\*(C'\fR. Non-native-Linux filesystems may interpret the mode in other ways. .Sp See also \f(CW\*(C`$g\->mkdir\*(C'\fR, \f(CW\*(C`$g\->umask\*(C'\fR .ie n .IP "$g\->mkdir_p ($path);" 4 .el .IP "\f(CW$g\fR\->mkdir_p ($path);" 4 .IX Item "$g->mkdir_p ($path);" Create a directory named \f(CW\*(C`path\*(C'\fR, creating any parent directories as necessary. This is like the \f(CW\*(C`mkdir \-p\*(C'\fR shell command. .ie n .IP "$dir = $g\->mkdtemp ($tmpl);" 4 .el .IP "\f(CW$dir\fR = \f(CW$g\fR\->mkdtemp ($tmpl);" 4 .IX Item "$dir = $g->mkdtemp ($tmpl);" This command creates a temporary directory. The \&\f(CW\*(C`tmpl\*(C'\fR parameter should be a full pathname for the temporary directory name with the final six characters being "XXXXXX". .Sp For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second one being suitable for Windows filesystems. .Sp The name of the temporary directory that was created is returned. .Sp The temporary directory is created with mode 0700 and is owned by root. .Sp The caller is responsible for deleting the temporary directory and its contents after use. .Sp See also: \fBmkdtemp\fR\|(3) .ie n .IP "$g\->mke2fs ($device [, blockscount => $blockscount] [, blocksize => $blocksize] [, fragsize => $fragsize] [, blockspergroup => $blockspergroup] [, numberofgroups => $numberofgroups] [, bytesperinode => $bytesperinode] [, inodesize => $inodesize] [, journalsize => $journalsize] [, numberofinodes => $numberofinodes] [, stridesize => $stridesize] [, stripewidth => $stripewidth] [, maxonlineresize => $maxonlineresize] [, reservedblockspercentage => $reservedblockspercentage] [, mmpupdateinterval => $mmpupdateinterval] [, journaldevice => $journaldevice] [, label => $label] [, lastmounteddir => $lastmounteddir] [, creatoros => $creatoros] [, fstype => $fstype] [, usagetype => $usagetype] [, uuid => $uuid] [, forcecreate => $forcecreate] [, writesbandgrouponly => $writesbandgrouponly] [, lazyitableinit => $lazyitableinit] [, lazyjournalinit => $lazyjournalinit] [, testfs => $testfs] [, discard => $discard] [, quotatype => $quotatype] [, extent => $extent] [, filetype => $filetype] [, flexbg => $flexbg] [, hasjournal => $hasjournal] [, journaldev => $journaldev] [, largefile => $largefile] [, quota => $quota] [, resizeinode => $resizeinode] [, sparsesuper => $sparsesuper] [, uninitbg => $uninitbg]);" 4 .el .IP "\f(CW$g\fR\->mke2fs ($device [, blockscount => \f(CW$blockscount\fR] [, blocksize => \f(CW$blocksize\fR] [, fragsize => \f(CW$fragsize\fR] [, blockspergroup => \f(CW$blockspergroup\fR] [, numberofgroups => \f(CW$numberofgroups\fR] [, bytesperinode => \f(CW$bytesperinode\fR] [, inodesize => \f(CW$inodesize\fR] [, journalsize => \f(CW$journalsize\fR] [, numberofinodes => \f(CW$numberofinodes\fR] [, stridesize => \f(CW$stridesize\fR] [, stripewidth => \f(CW$stripewidth\fR] [, maxonlineresize => \f(CW$maxonlineresize\fR] [, reservedblockspercentage => \f(CW$reservedblockspercentage\fR] [, mmpupdateinterval => \f(CW$mmpupdateinterval\fR] [, journaldevice => \f(CW$journaldevice\fR] [, label => \f(CW$label\fR] [, lastmounteddir => \f(CW$lastmounteddir\fR] [, creatoros => \f(CW$creatoros\fR] [, fstype => \f(CW$fstype\fR] [, usagetype => \f(CW$usagetype\fR] [, uuid => \f(CW$uuid\fR] [, forcecreate => \f(CW$forcecreate\fR] [, writesbandgrouponly => \f(CW$writesbandgrouponly\fR] [, lazyitableinit => \f(CW$lazyitableinit\fR] [, lazyjournalinit => \f(CW$lazyjournalinit\fR] [, testfs => \f(CW$testfs\fR] [, discard => \f(CW$discard\fR] [, quotatype => \f(CW$quotatype\fR] [, extent => \f(CW$extent\fR] [, filetype => \f(CW$filetype\fR] [, flexbg => \f(CW$flexbg\fR] [, hasjournal => \f(CW$hasjournal\fR] [, journaldev => \f(CW$journaldev\fR] [, largefile => \f(CW$largefile\fR] [, quota => \f(CW$quota\fR] [, resizeinode => \f(CW$resizeinode\fR] [, sparsesuper => \f(CW$sparsesuper\fR] [, uninitbg => \f(CW$uninitbg\fR]);" 4 .IX Item "$g->mke2fs ($device [, blockscount => $blockscount] [, blocksize => $blocksize] [, fragsize => $fragsize] [, blockspergroup => $blockspergroup] [, numberofgroups => $numberofgroups] [, bytesperinode => $bytesperinode] [, inodesize => $inodesize] [, journalsize => $journalsize] [, numberofinodes => $numberofinodes] [, stridesize => $stridesize] [, stripewidth => $stripewidth] [, maxonlineresize => $maxonlineresize] [, reservedblockspercentage => $reservedblockspercentage] [, mmpupdateinterval => $mmpupdateinterval] [, journaldevice => $journaldevice] [, label => $label] [, lastmounteddir => $lastmounteddir] [, creatoros => $creatoros] [, fstype => $fstype] [, usagetype => $usagetype] [, uuid => $uuid] [, forcecreate => $forcecreate] [, writesbandgrouponly => $writesbandgrouponly] [, lazyitableinit => $lazyitableinit] [, lazyjournalinit => $lazyjournalinit] [, testfs => $testfs] [, discard => $discard] [, quotatype => $quotatype] [, extent => $extent] [, filetype => $filetype] [, flexbg => $flexbg] [, hasjournal => $hasjournal] [, journaldev => $journaldev] [, largefile => $largefile] [, quota => $quota] [, resizeinode => $resizeinode] [, sparsesuper => $sparsesuper] [, uninitbg => $uninitbg]);" \&\f(CW\*(C`mke2fs\*(C'\fR is used to create an ext2, ext3, or ext4 filesystem on \f(CW\*(C`device\*(C'\fR. .Sp The optional \f(CW\*(C`blockscount\*(C'\fR is the size of the filesystem in blocks. If omitted it defaults to the size of \f(CW\*(C`device\*(C'\fR. Note if the filesystem is too small to contain a journal, \f(CW\*(C`mke2fs\*(C'\fR will silently create an ext2 filesystem instead. .ie n .IP "$g\->mke2fs_J ($fstype, $blocksize, $device, $journal);" 4 .el .IP "\f(CW$g\fR\->mke2fs_J ($fstype, \f(CW$blocksize\fR, \f(CW$device\fR, \f(CW$journal\fR);" 4 .IX Item "$g->mke2fs_J ($fstype, $blocksize, $device, $journal);" This creates an ext2/3/4 filesystem on \f(CW\*(C`device\*(C'\fR with an external journal on \f(CW\*(C`journal\*(C'\fR. It is equivalent to the command: .Sp .Vb 1 \& mke2fs \-t fstype \-b blocksize \-J device= .Ve .Sp See also \f(CW\*(C`$g\->mke2journal\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mke2fs_JL ($fstype, $blocksize, $device, $label);" 4 .el .IP "\f(CW$g\fR\->mke2fs_JL ($fstype, \f(CW$blocksize\fR, \f(CW$device\fR, \f(CW$label\fR);" 4 .IX Item "$g->mke2fs_JL ($fstype, $blocksize, $device, $label);" This creates an ext2/3/4 filesystem on \f(CW\*(C`device\*(C'\fR with an external journal on the journal labeled \f(CW\*(C`label\*(C'\fR. .Sp See also \f(CW\*(C`$g\->mke2journal_L\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mke2fs_JU ($fstype, $blocksize, $device, $uuid);" 4 .el .IP "\f(CW$g\fR\->mke2fs_JU ($fstype, \f(CW$blocksize\fR, \f(CW$device\fR, \f(CW$uuid\fR);" 4 .IX Item "$g->mke2fs_JU ($fstype, $blocksize, $device, $uuid);" This creates an ext2/3/4 filesystem on \f(CW\*(C`device\*(C'\fR with an external journal on the journal with UUID \f(CW\*(C`uuid\*(C'\fR. .Sp See also \f(CW\*(C`$g\->mke2journal_U\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`linuxfsuuid\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mke2journal ($blocksize, $device);" 4 .el .IP "\f(CW$g\fR\->mke2journal ($blocksize, \f(CW$device\fR);" 4 .IX Item "$g->mke2journal ($blocksize, $device);" This creates an ext2 external journal on \f(CW\*(C`device\*(C'\fR. It is equivalent to the command: .Sp .Vb 1 \& mke2fs \-O journal_dev \-b blocksize device .Ve .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mke2journal_L ($blocksize, $label, $device);" 4 .el .IP "\f(CW$g\fR\->mke2journal_L ($blocksize, \f(CW$label\fR, \f(CW$device\fR);" 4 .IX Item "$g->mke2journal_L ($blocksize, $label, $device);" This creates an ext2 external journal on \f(CW\*(C`device\*(C'\fR with label \f(CW\*(C`label\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mke2journal_U ($blocksize, $uuid, $device);" 4 .el .IP "\f(CW$g\fR\->mke2journal_U ($blocksize, \f(CW$uuid\fR, \f(CW$device\fR);" 4 .IX Item "$g->mke2journal_U ($blocksize, $uuid, $device);" This creates an ext2 external journal on \f(CW\*(C`device\*(C'\fR with UUID \f(CW\*(C`uuid\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`linuxfsuuid\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mke2fs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mkfifo ($mode, $path);" 4 .el .IP "\f(CW$g\fR\->mkfifo ($mode, \f(CW$path\fR);" 4 .IX Item "$g->mkfifo ($mode, $path);" This call creates a FIFO (named pipe) called \f(CW\*(C`path\*(C'\fR with mode \f(CW\*(C`mode\*(C'\fR. It is just a convenient wrapper around \&\f(CW\*(C`$g\->mknod\*(C'\fR. .Sp Unlike with \f(CW\*(C`$g\->mknod\*(C'\fR, \f(CW\*(C`mode\*(C'\fR \fBmust\fR contain only permissions bits. .Sp The mode actually set is affected by the umask. .Sp This function depends on the feature \f(CW\*(C`mknod\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mkfs ($fstype, $device [, blocksize => $blocksize] [, features => $features] [, inode => $inode] [, sectorsize => $sectorsize] [, label => $label]);" 4 .el .IP "\f(CW$g\fR\->mkfs ($fstype, \f(CW$device\fR [, blocksize => \f(CW$blocksize\fR] [, features => \f(CW$features\fR] [, inode => \f(CW$inode\fR] [, sectorsize => \f(CW$sectorsize\fR] [, label => \f(CW$label\fR]);" 4 .IX Item "$g->mkfs ($fstype, $device [, blocksize => $blocksize] [, features => $features] [, inode => $inode] [, sectorsize => $sectorsize] [, label => $label]);" This function creates a filesystem on \f(CW\*(C`device\*(C'\fR. The filesystem type is \f(CW\*(C`fstype\*(C'\fR, for example \f(CW\*(C`ext3\*(C'\fR. .Sp The optional arguments are: .RS 4 .ie n .IP """blocksize""" 4 .el .IP \f(CWblocksize\fR 4 .IX Item "blocksize" The filesystem block size. Supported block sizes depend on the filesystem type, but typically they are \f(CW1024\fR, \f(CW2048\fR or \f(CW4096\fR for Linux ext2/3 filesystems. .Sp For VFAT and NTFS the \f(CW\*(C`blocksize\*(C'\fR parameter is treated as the requested cluster size. .Sp For UFS block sizes, please see \fBmkfs.ufs\fR\|(8). .ie n .IP """features""" 4 .el .IP \f(CWfeatures\fR 4 .IX Item "features" This passes the \fI\-O\fR parameter to the external mkfs program. .Sp For certain filesystem types, this allows extra filesystem features to be selected. See \fBmke2fs\fR\|(8) and \fBmkfs.ufs\fR\|(8) for more details. .Sp You cannot use this optional parameter with the \f(CW\*(C`gfs\*(C'\fR or \&\f(CW\*(C`gfs2\*(C'\fR filesystem type. .ie n .IP """inode""" 4 .el .IP \f(CWinode\fR 4 .IX Item "inode" This passes the \fI\-I\fR parameter to the external \fBmke2fs\fR\|(8) program which sets the inode size (only for ext2/3/4 filesystems at present). .ie n .IP """sectorsize""" 4 .el .IP \f(CWsectorsize\fR 4 .IX Item "sectorsize" This passes the \fI\-S\fR parameter to external \fBmkfs.ufs\fR\|(8) program, which sets sector size for ufs filesystem. .RE .RS 4 .RE .ie n .IP "$g\->mkfs_opts ($fstype, $device [, blocksize => $blocksize] [, features => $features] [, inode => $inode] [, sectorsize => $sectorsize] [, label => $label]);" 4 .el .IP "\f(CW$g\fR\->mkfs_opts ($fstype, \f(CW$device\fR [, blocksize => \f(CW$blocksize\fR] [, features => \f(CW$features\fR] [, inode => \f(CW$inode\fR] [, sectorsize => \f(CW$sectorsize\fR] [, label => \f(CW$label\fR]);" 4 .IX Item "$g->mkfs_opts ($fstype, $device [, blocksize => $blocksize] [, features => $features] [, inode => $inode] [, sectorsize => $sectorsize] [, label => $label]);" This is an alias of "mkfs". .ie n .IP "$g\->mkfs_b ($fstype, $blocksize, $device);" 4 .el .IP "\f(CW$g\fR\->mkfs_b ($fstype, \f(CW$blocksize\fR, \f(CW$device\fR);" 4 .IX Item "$g->mkfs_b ($fstype, $blocksize, $device);" This call is similar to \f(CW\*(C`$g\->mkfs\*(C'\fR, but it allows you to control the block size of the resulting filesystem. Supported block sizes depend on the filesystem type, but typically they are \f(CW1024\fR, \f(CW2048\fR or \f(CW4096\fR only. .Sp For VFAT and NTFS the \f(CW\*(C`blocksize\*(C'\fR parameter is treated as the requested cluster size. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mkfs" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mkfs_btrfs (\e@devices [, allocstart => $allocstart] [, bytecount => $bytecount] [, datatype => $datatype] [, leafsize => $leafsize] [, label => $label] [, metadata => $metadata] [, nodesize => $nodesize] [, sectorsize => $sectorsize]);" 4 .el .IP "\f(CW$g\fR\->mkfs_btrfs (\e@devices [, allocstart => \f(CW$allocstart\fR] [, bytecount => \f(CW$bytecount\fR] [, datatype => \f(CW$datatype\fR] [, leafsize => \f(CW$leafsize\fR] [, label => \f(CW$label\fR] [, metadata => \f(CW$metadata\fR] [, nodesize => \f(CW$nodesize\fR] [, sectorsize => \f(CW$sectorsize\fR]);" 4 .IX Item "$g->mkfs_btrfs (@devices [, allocstart => $allocstart] [, bytecount => $bytecount] [, datatype => $datatype] [, leafsize => $leafsize] [, label => $label] [, metadata => $metadata] [, nodesize => $nodesize] [, sectorsize => $sectorsize]);" Create a btrfs filesystem, allowing all configurables to be set. For more information on the optional arguments, see \fBmkfs.btrfs\fR\|(8). .Sp Since btrfs filesystems can span multiple devices, this takes a non-empty list of devices. .Sp To create general filesystems, use \f(CW\*(C`$g\->mkfs\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`btrfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mklost_and_found ($mountpoint);" 4 .el .IP "\f(CW$g\fR\->mklost_and_found ($mountpoint);" 4 .IX Item "$g->mklost_and_found ($mountpoint);" Make the \f(CW\*(C`lost+found\*(C'\fR directory, normally in the root directory of an ext2/3/4 filesystem. \f(CW\*(C`mountpoint\*(C'\fR is the directory under which we try to create the \f(CW\*(C`lost+found\*(C'\fR directory. .ie n .IP "$g\->mkmountpoint ($exemptpath);" 4 .el .IP "\f(CW$g\fR\->mkmountpoint ($exemptpath);" 4 .IX Item "$g->mkmountpoint ($exemptpath);" \&\f(CW\*(C`$g\->mkmountpoint\*(C'\fR and \f(CW\*(C`$g\->rmmountpoint\*(C'\fR are specialized calls that can be used to create extra mountpoints before mounting the first filesystem. .Sp These calls are \fIonly\fR necessary in some very limited circumstances, mainly the case where you want to mount a mix of unrelated and/or read-only filesystems together. .Sp For example, live CDs often contain a "Russian doll" nest of filesystems, an ISO outer layer, with a squashfs image inside, with an ext2/3 image inside that. You can unpack this as follows in guestfish: .Sp .Vb 8 \& add\-ro Fedora\-11\-i686\-Live.iso \& run \& mkmountpoint /cd \& mkmountpoint /sqsh \& mkmountpoint /ext3fs \& mount /dev/sda /cd \& mount\-loop /cd/LiveOS/squashfs.img /sqsh \& mount\-loop /sqsh/LiveOS/ext3fs.img /ext3fs .Ve .Sp The inner filesystem is now unpacked under the /ext3fs mountpoint. .Sp \&\f(CW\*(C`$g\->mkmountpoint\*(C'\fR is not compatible with \f(CW\*(C`$g\->umount_all\*(C'\fR. You may get unexpected errors if you try to mix these calls. It is safest to manually unmount filesystems and remove mountpoints after use. .Sp \&\f(CW\*(C`$g\->umount_all\*(C'\fR unmounts filesystems by sorting the paths longest first, so for this to work for manual mountpoints, you must ensure that the innermost mountpoints have the longest pathnames, as in the example code above. .Sp For more details see .Sp Autosync [see \f(CW\*(C`$g\->set_autosync\*(C'\fR, this is set by default on handles] can cause \f(CW\*(C`$g\->umount_all\*(C'\fR to be called when the handle is closed which can also trigger these issues. .ie n .IP "$g\->mknod ($mode, $devmajor, $devminor, $path);" 4 .el .IP "\f(CW$g\fR\->mknod ($mode, \f(CW$devmajor\fR, \f(CW$devminor\fR, \f(CW$path\fR);" 4 .IX Item "$g->mknod ($mode, $devmajor, $devminor, $path);" This call creates block or character special devices, or named pipes (FIFOs). .Sp The \f(CW\*(C`mode\*(C'\fR parameter should be the mode, using the standard constants. \f(CW\*(C`devmajor\*(C'\fR and \f(CW\*(C`devminor\*(C'\fR are the device major and minor numbers, only used when creating block and character special devices. .Sp Note that, just like \fBmknod\fR\|(2), the mode must be bitwise OR'd with S_IFBLK, S_IFCHR, S_IFIFO or S_IFSOCK (otherwise this call just creates a regular file). These constants are available in the standard Linux header files, or you can use \&\f(CW\*(C`$g\->mknod_b\*(C'\fR, \f(CW\*(C`$g\->mknod_c\*(C'\fR or \f(CW\*(C`$g\->mkfifo\*(C'\fR which are wrappers around this command which bitwise OR in the appropriate constant for you. .Sp The mode actually set is affected by the umask. .Sp This function depends on the feature \f(CW\*(C`mknod\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mknod_b ($mode, $devmajor, $devminor, $path);" 4 .el .IP "\f(CW$g\fR\->mknod_b ($mode, \f(CW$devmajor\fR, \f(CW$devminor\fR, \f(CW$path\fR);" 4 .IX Item "$g->mknod_b ($mode, $devmajor, $devminor, $path);" This call creates a block device node called \f(CW\*(C`path\*(C'\fR with mode \f(CW\*(C`mode\*(C'\fR and device major/minor \f(CW\*(C`devmajor\*(C'\fR and \f(CW\*(C`devminor\*(C'\fR. It is just a convenient wrapper around \f(CW\*(C`$g\->mknod\*(C'\fR. .Sp Unlike with \f(CW\*(C`$g\->mknod\*(C'\fR, \f(CW\*(C`mode\*(C'\fR \fBmust\fR contain only permissions bits. .Sp The mode actually set is affected by the umask. .Sp This function depends on the feature \f(CW\*(C`mknod\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mknod_c ($mode, $devmajor, $devminor, $path);" 4 .el .IP "\f(CW$g\fR\->mknod_c ($mode, \f(CW$devmajor\fR, \f(CW$devminor\fR, \f(CW$path\fR);" 4 .IX Item "$g->mknod_c ($mode, $devmajor, $devminor, $path);" This call creates a char device node called \f(CW\*(C`path\*(C'\fR with mode \f(CW\*(C`mode\*(C'\fR and device major/minor \f(CW\*(C`devmajor\*(C'\fR and \f(CW\*(C`devminor\*(C'\fR. It is just a convenient wrapper around \f(CW\*(C`$g\->mknod\*(C'\fR. .Sp Unlike with \f(CW\*(C`$g\->mknod\*(C'\fR, \f(CW\*(C`mode\*(C'\fR \fBmust\fR contain only permissions bits. .Sp The mode actually set is affected by the umask. .Sp This function depends on the feature \f(CW\*(C`mknod\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mksquashfs ($path, $filename [, compress => $compress] [, excludes => $excludes]);" 4 .el .IP "\f(CW$g\fR\->mksquashfs ($path, \f(CW$filename\fR [, compress => \f(CW$compress\fR] [, excludes => \f(CW$excludes\fR]);" 4 .IX Item "$g->mksquashfs ($path, $filename [, compress => $compress] [, excludes => $excludes]);" Create a squashfs filesystem for the specified \f(CW\*(C`path\*(C'\fR. .Sp The optional \f(CW\*(C`compress\*(C'\fR flag controls compression. If not given, then the output compressed using \f(CW\*(C`gzip\*(C'\fR. Otherwise one of the following strings may be given to select the compression type of the squashfs: \f(CW\*(C`gzip\*(C'\fR, \f(CW\*(C`lzma\*(C'\fR, \f(CW\*(C`lzo\*(C'\fR, \f(CW\*(C`lz4\*(C'\fR, \f(CW\*(C`xz\*(C'\fR. .Sp The other optional arguments are: .RS 4 .ie n .IP """excludes""" 4 .el .IP \f(CWexcludes\fR 4 .IX Item "excludes" A list of wildcards. Files are excluded if they match any of the wildcards. .RE .RS 4 .Sp Please note that this API may fail when used to compress directories with large files, such as the resulting squashfs will be over 3GB big. .Sp This function depends on the feature \f(CW\*(C`squashfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->mkswap ($device [, label => $label] [, uuid => $uuid]);" 4 .el .IP "\f(CW$g\fR\->mkswap ($device [, label => \f(CW$label\fR] [, uuid => \f(CW$uuid\fR]);" 4 .IX Item "$g->mkswap ($device [, label => $label] [, uuid => $uuid]);" Create a Linux swap partition on \f(CW\*(C`device\*(C'\fR. .Sp The option arguments \f(CW\*(C`label\*(C'\fR and \f(CW\*(C`uuid\*(C'\fR allow you to set the label and/or UUID of the new swap partition. .ie n .IP "$g\->mkswap_opts ($device [, label => $label] [, uuid => $uuid]);" 4 .el .IP "\f(CW$g\fR\->mkswap_opts ($device [, label => \f(CW$label\fR] [, uuid => \f(CW$uuid\fR]);" 4 .IX Item "$g->mkswap_opts ($device [, label => $label] [, uuid => $uuid]);" This is an alias of "mkswap". .ie n .IP "$g\->mkswap_L ($label, $device);" 4 .el .IP "\f(CW$g\fR\->mkswap_L ($label, \f(CW$device\fR);" 4 .IX Item "$g->mkswap_L ($label, $device);" Create a swap partition on \f(CW\*(C`device\*(C'\fR with label \f(CW\*(C`label\*(C'\fR. .Sp Note that you cannot attach a swap label to a block device (eg. \fI/dev/sda\fR), just to a partition. This appears to be a limitation of the kernel or swap tools. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mkswap" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mkswap_U ($uuid, $device);" 4 .el .IP "\f(CW$g\fR\->mkswap_U ($uuid, \f(CW$device\fR);" 4 .IX Item "$g->mkswap_U ($uuid, $device);" Create a swap partition on \f(CW\*(C`device\*(C'\fR with UUID \f(CW\*(C`uuid\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`linuxfsuuid\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "mkswap" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mkswap_file ($path);" 4 .el .IP "\f(CW$g\fR\->mkswap_file ($path);" 4 .IX Item "$g->mkswap_file ($path);" Create a swap file. .Sp This command just writes a swap file signature to an existing file. To create the file itself, use something like \f(CW\*(C`$g\->fallocate\*(C'\fR. .ie n .IP "$path = $g\->mktemp ($tmpl [, suffix => $suffix]);" 4 .el .IP "\f(CW$path\fR = \f(CW$g\fR\->mktemp ($tmpl [, suffix => \f(CW$suffix\fR]);" 4 .IX Item "$path = $g->mktemp ($tmpl [, suffix => $suffix]);" This command creates a temporary file. The \&\f(CW\*(C`tmpl\*(C'\fR parameter should be a full pathname for the temporary directory name with the final six characters being "XXXXXX". .Sp For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX", the second one being suitable for Windows filesystems. .Sp The name of the temporary file that was created is returned. .Sp The temporary file is created with mode 0600 and is owned by root. .Sp The caller is responsible for deleting the temporary file after use. .Sp If the optional \f(CW\*(C`suffix\*(C'\fR parameter is given, then the suffix (eg. \f(CW\*(C`.txt\*(C'\fR) is appended to the temporary name. .Sp See also: \f(CW\*(C`$g\->mkdtemp\*(C'\fR. .ie n .IP "$g\->modprobe ($modulename);" 4 .el .IP "\f(CW$g\fR\->modprobe ($modulename);" 4 .IX Item "$g->modprobe ($modulename);" This loads a kernel module in the appliance. .Sp This function depends on the feature \f(CW\*(C`linuxmodules\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->mount ($mountable, $mountpoint);" 4 .el .IP "\f(CW$g\fR\->mount ($mountable, \f(CW$mountpoint\fR);" 4 .IX Item "$g->mount ($mountable, $mountpoint);" Mount a guest disk at a position in the filesystem. Block devices are named \fI/dev/sda\fR, \fI/dev/sdb\fR and so on, as they were added to the guest. If those block devices contain partitions, they will have the usual names (eg. \fI/dev/sda1\fR). Also LVM \fI/dev/VG/LV\fR\-style names can be used, or ‘mountable’ strings returned by \&\f(CW\*(C`$g\->list_filesystems\*(C'\fR or \f(CW\*(C`$g\->inspect_get_mountpoints\*(C'\fR. .Sp The rules are the same as for \fBmount\fR\|(2): A filesystem must first be mounted on \fI/\fR before others can be mounted. Other filesystems can only be mounted on directories which already exist. .Sp The mounted filesystem is writable, if we have sufficient permissions on the underlying device. .Sp Before libguestfs 1.13.16, this call implicitly added the options \&\f(CW\*(C`sync\*(C'\fR and \f(CW\*(C`noatime\*(C'\fR. The \f(CW\*(C`sync\*(C'\fR option greatly slowed writes and caused many problems for users. If your program might need to work with older versions of libguestfs, use \&\f(CW\*(C`$g\->mount_options\*(C'\fR instead (using an empty string for the first parameter if you don't want any options). .ie n .IP "$g\->mount_9p ($mounttag, $mountpoint [, options => $options]);" 4 .el .IP "\f(CW$g\fR\->mount_9p ($mounttag, \f(CW$mountpoint\fR [, options => \f(CW$options\fR]);" 4 .IX Item "$g->mount_9p ($mounttag, $mountpoint [, options => $options]);" This call does nothing and returns an error. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->mount_local ($localmountpoint [, readonly => $readonly] [, options => $options] [, cachetimeout => $cachetimeout] [, debugcalls => $debugcalls]);" 4 .el .IP "\f(CW$g\fR\->mount_local ($localmountpoint [, readonly => \f(CW$readonly\fR] [, options => \f(CW$options\fR] [, cachetimeout => \f(CW$cachetimeout\fR] [, debugcalls => \f(CW$debugcalls\fR]);" 4 .IX Item "$g->mount_local ($localmountpoint [, readonly => $readonly] [, options => $options] [, cachetimeout => $cachetimeout] [, debugcalls => $debugcalls]);" This call exports the libguestfs-accessible filesystem to a local mountpoint (directory) called \f(CW\*(C`localmountpoint\*(C'\fR. Ordinary reads and writes to files and directories under \&\f(CW\*(C`localmountpoint\*(C'\fR are redirected through libguestfs. .Sp If the optional \f(CW\*(C`readonly\*(C'\fR flag is set to true, then writes to the filesystem return error \f(CW\*(C`EROFS\*(C'\fR. .Sp \&\f(CW\*(C`options\*(C'\fR is a comma-separated list of mount options. See \fBguestmount\fR\|(1) for some useful options. .Sp \&\f(CW\*(C`cachetimeout\*(C'\fR sets the timeout (in seconds) for cached directory entries. The default is 60 seconds. See \fBguestmount\fR\|(1) for further information. .Sp If \f(CW\*(C`debugcalls\*(C'\fR is set to true, then additional debugging information is generated for every FUSE call. .Sp When \f(CW\*(C`$g\->mount_local\*(C'\fR returns, the filesystem is ready, but is not processing requests (access to it will block). You have to call \f(CW\*(C`$g\->mount_local_run\*(C'\fR to run the main loop. .Sp See "MOUNT LOCAL" in \fBguestfs\fR\|(3) for full documentation. .ie n .IP "$g\->mount_local_run ();" 4 .el .IP "\f(CW$g\fR\->mount_local_run ();" 4 .IX Item "$g->mount_local_run ();" Run the main loop which translates kernel calls to libguestfs calls. .Sp This should only be called after \f(CW\*(C`$g\->mount_local\*(C'\fR returns successfully. The call will not return until the filesystem is unmounted. .Sp \&\fBNote\fR you must \fInot\fR make concurrent libguestfs calls on the same handle from another thread. .Sp You may call this from a different thread than the one which called \f(CW\*(C`$g\->mount_local\*(C'\fR, subject to the usual rules for threads and libguestfs (see "MULTIPLE HANDLES AND MULTIPLE THREADS" in \fBguestfs\fR\|(3)). .Sp See "MOUNT LOCAL" in \fBguestfs\fR\|(3) for full documentation. .ie n .IP "$g\->mount_loop ($file, $mountpoint);" 4 .el .IP "\f(CW$g\fR\->mount_loop ($file, \f(CW$mountpoint\fR);" 4 .IX Item "$g->mount_loop ($file, $mountpoint);" This command lets you mount \fIfile\fR (a filesystem image in a file) on a mount point. It is entirely equivalent to the command \f(CW\*(C`mount \-o loop file mountpoint\*(C'\fR. .ie n .IP "$g\->mount_options ($options, $mountable, $mountpoint);" 4 .el .IP "\f(CW$g\fR\->mount_options ($options, \f(CW$mountable\fR, \f(CW$mountpoint\fR);" 4 .IX Item "$g->mount_options ($options, $mountable, $mountpoint);" This is the same as the \f(CW\*(C`$g\->mount\*(C'\fR command, but it allows you to set the mount options as for the \&\fBmount\fR\|(8) \fI\-o\fR flag. .Sp If the \f(CW\*(C`options\*(C'\fR parameter is an empty string, then no options are passed (all options default to whatever the filesystem uses). .ie n .IP "$g\->mount_ro ($mountable, $mountpoint);" 4 .el .IP "\f(CW$g\fR\->mount_ro ($mountable, \f(CW$mountpoint\fR);" 4 .IX Item "$g->mount_ro ($mountable, $mountpoint);" This is the same as the \f(CW\*(C`$g\->mount\*(C'\fR command, but it mounts the filesystem with the read-only (\fI\-o ro\fR) flag. .ie n .IP "$g\->mount_vfs ($options, $vfstype, $mountable, $mountpoint);" 4 .el .IP "\f(CW$g\fR\->mount_vfs ($options, \f(CW$vfstype\fR, \f(CW$mountable\fR, \f(CW$mountpoint\fR);" 4 .IX Item "$g->mount_vfs ($options, $vfstype, $mountable, $mountpoint);" This is the same as the \f(CW\*(C`$g\->mount\*(C'\fR command, but it allows you to set both the mount options and the vfstype as for the \fBmount\fR\|(8) \fI\-o\fR and \fI\-t\fR flags. .ie n .IP "$device = $g\->mountable_device ($mountable);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->mountable_device ($mountable);" 4 .IX Item "$device = $g->mountable_device ($mountable);" Returns the device name of a mountable. In quite a lot of cases, the mountable is the device name. .Sp However this doesn't apply for btrfs subvolumes, where the mountable is a combination of both the device name and the subvolume path (see also \f(CW\*(C`$g\->mountable_subvolume\*(C'\fR to extract the subvolume path of the mountable if any). .ie n .IP "$subvolume = $g\->mountable_subvolume ($mountable);" 4 .el .IP "\f(CW$subvolume\fR = \f(CW$g\fR\->mountable_subvolume ($mountable);" 4 .IX Item "$subvolume = $g->mountable_subvolume ($mountable);" Returns the subvolume path of a mountable. Btrfs subvolumes mountables are a combination of both the device name and the subvolume path (see also \f(CW\*(C`$g\->mountable_device\*(C'\fR to extract the device of the mountable). .Sp If the mountable does not represent a btrfs subvolume, then this function fails and the \f(CW\*(C`errno\*(C'\fR is set to \f(CW\*(C`EINVAL\*(C'\fR. .ie n .IP "%mps = $g\->mountpoints ();" 4 .el .IP "\f(CW%mps\fR = \f(CW$g\fR\->mountpoints ();" 4 .IX Item "%mps = $g->mountpoints ();" This call is similar to \f(CW\*(C`$g\->mounts\*(C'\fR. That call returns a list of devices. This one returns a hash table (map) of device name to directory where the device is mounted. .ie n .IP "@devices = $g\->mounts ();" 4 .el .IP "\f(CW@devices\fR = \f(CW$g\fR\->mounts ();" 4 .IX Item "@devices = $g->mounts ();" This returns the list of currently mounted filesystems. It returns the list of devices (eg. \fI/dev/sda1\fR, \fI/dev/VG/LV\fR). .Sp Some internal mounts are not shown. .Sp See also: \f(CW\*(C`$g\->mountpoints\*(C'\fR .ie n .IP "$g\->mv ($src, $dest);" 4 .el .IP "\f(CW$g\fR\->mv ($src, \f(CW$dest\fR);" 4 .IX Item "$g->mv ($src, $dest);" This moves a file from \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR where \f(CW\*(C`dest\*(C'\fR is either a destination filename or destination directory. .Sp See also: \f(CW\*(C`$g\->rename\*(C'\fR. .ie n .IP "$nrdisks = $g\->nr_devices ();" 4 .el .IP "\f(CW$nrdisks\fR = \f(CW$g\fR\->nr_devices ();" 4 .IX Item "$nrdisks = $g->nr_devices ();" This returns the number of whole block devices that were added. This is the same as the number of devices that would be returned if you called \f(CW\*(C`$g\->list_devices\*(C'\fR. .Sp To find out the maximum number of devices that could be added, call \f(CW\*(C`$g\->max_disks\*(C'\fR. .ie n .IP "$status = $g\->ntfs_3g_probe ($rw, $device);" 4 .el .IP "\f(CW$status\fR = \f(CW$g\fR\->ntfs_3g_probe ($rw, \f(CW$device\fR);" 4 .IX Item "$status = $g->ntfs_3g_probe ($rw, $device);" This command runs the \fBntfs\-3g.probe\fR\|(8) command which probes an NTFS \f(CW\*(C`device\*(C'\fR for mountability. (Not all NTFS volumes can be mounted read-write, and some cannot be mounted at all). .Sp \&\f(CW\*(C`rw\*(C'\fR is a boolean flag. Set it to true if you want to test if the volume can be mounted read-write. Set it to false if you want to test if the volume can be mounted read-only. .Sp The return value is an integer which \f(CW0\fR if the operation would succeed, or some non-zero value documented in the \&\fBntfs\-3g.probe\fR\|(8) manual page. .Sp This function depends on the feature \f(CW\*(C`ntfs3g\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->ntfscat_i ($device, $inode, $filename);" 4 .el .IP "\f(CW$g\fR\->ntfscat_i ($device, \f(CW$inode\fR, \f(CW$filename\fR);" 4 .IX Item "$g->ntfscat_i ($device, $inode, $filename);" Download a file given its inode from a NTFS filesystem and save it as \&\fIfilename\fR on the local machine. .Sp This allows to download some otherwise inaccessible files such as the ones within the \f(CW$Extend\fR folder. .Sp The filesystem from which to extract the file must be unmounted, otherwise the call will fail. .ie n .IP "$g\->ntfsclone_in ($backupfile, $device);" 4 .el .IP "\f(CW$g\fR\->ntfsclone_in ($backupfile, \f(CW$device\fR);" 4 .IX Item "$g->ntfsclone_in ($backupfile, $device);" Restore the \f(CW\*(C`backupfile\*(C'\fR (from a previous call to \&\f(CW\*(C`$g\->ntfsclone_out\*(C'\fR) to \f(CW\*(C`device\*(C'\fR, overwriting any existing contents of this device. .Sp This function depends on the feature \f(CW\*(C`ntfs3g\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->ntfsclone_out ($device, $backupfile [, metadataonly => $metadataonly] [, rescue => $rescue] [, ignorefscheck => $ignorefscheck] [, preservetimestamps => $preservetimestamps] [, force => $force]);" 4 .el .IP "\f(CW$g\fR\->ntfsclone_out ($device, \f(CW$backupfile\fR [, metadataonly => \f(CW$metadataonly\fR] [, rescue => \f(CW$rescue\fR] [, ignorefscheck => \f(CW$ignorefscheck\fR] [, preservetimestamps => \f(CW$preservetimestamps\fR] [, force => \f(CW$force\fR]);" 4 .IX Item "$g->ntfsclone_out ($device, $backupfile [, metadataonly => $metadataonly] [, rescue => $rescue] [, ignorefscheck => $ignorefscheck] [, preservetimestamps => $preservetimestamps] [, force => $force]);" Stream the NTFS filesystem \f(CW\*(C`device\*(C'\fR to the local file \&\f(CW\*(C`backupfile\*(C'\fR. The format used for the backup file is a special format used by the \fBntfsclone\fR\|(8) tool. .Sp If the optional \f(CW\*(C`metadataonly\*(C'\fR flag is true, then \fIonly\fR the metadata is saved, losing all the user data (this is useful for diagnosing some filesystem problems). .Sp The optional \f(CW\*(C`rescue\*(C'\fR, \f(CW\*(C`ignorefscheck\*(C'\fR, \f(CW\*(C`preservetimestamps\*(C'\fR and \f(CW\*(C`force\*(C'\fR flags have precise meanings detailed in the \&\fBntfsclone\fR\|(8) man page. .Sp Use \f(CW\*(C`$g\->ntfsclone_in\*(C'\fR to restore the file back to a libguestfs device. .Sp This function depends on the feature \f(CW\*(C`ntfs3g\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->ntfsfix ($device [, clearbadsectors => $clearbadsectors]);" 4 .el .IP "\f(CW$g\fR\->ntfsfix ($device [, clearbadsectors => \f(CW$clearbadsectors\fR]);" 4 .IX Item "$g->ntfsfix ($device [, clearbadsectors => $clearbadsectors]);" This command repairs some fundamental NTFS inconsistencies, resets the NTFS journal file, and schedules an NTFS consistency check for the first boot into Windows. .Sp This is \fInot\fR an equivalent of Windows \f(CW\*(C`chkdsk\*(C'\fR. It does \fInot\fR scan the filesystem for inconsistencies. .Sp The optional \f(CW\*(C`clearbadsectors\*(C'\fR flag clears the list of bad sectors. This is useful after cloning a disk with bad sectors to a new disk. .Sp This function depends on the feature \f(CW\*(C`ntfs3g\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->ntfsresize ($device [, size => $size] [, force => $force]);" 4 .el .IP "\f(CW$g\fR\->ntfsresize ($device [, size => \f(CW$size\fR] [, force => \f(CW$force\fR]);" 4 .IX Item "$g->ntfsresize ($device [, size => $size] [, force => $force]);" This command resizes an NTFS filesystem, expanding or shrinking it to the size of the underlying device. .Sp The optional parameters are: .RS 4 .ie n .IP """size""" 4 .el .IP \f(CWsize\fR 4 .IX Item "size" The new size (in bytes) of the filesystem. If omitted, the filesystem is resized to fit the container (eg. partition). .ie n .IP """force""" 4 .el .IP \f(CWforce\fR 4 .IX Item "force" If this option is true, then force the resize of the filesystem even if the filesystem is marked as requiring a consistency check. .Sp After the resize operation, the filesystem is always marked as requiring a consistency check (for safety). You have to boot into Windows to perform this check and clear this condition. If you \fIdon't\fR set the \f(CW\*(C`force\*(C'\fR option then it is not possible to call \f(CW\*(C`$g\->ntfsresize\*(C'\fR multiple times on a single filesystem without booting into Windows between each resize. .RE .RS 4 .Sp See also \fBntfsresize\fR\|(8). .Sp This function depends on the feature \f(CW\*(C`ntfsprogs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->ntfsresize_opts ($device [, size => $size] [, force => $force]);" 4 .el .IP "\f(CW$g\fR\->ntfsresize_opts ($device [, size => \f(CW$size\fR] [, force => \f(CW$force\fR]);" 4 .IX Item "$g->ntfsresize_opts ($device [, size => $size] [, force => $force]);" This is an alias of "ntfsresize". .ie n .IP "$g\->ntfsresize_size ($device, $size);" 4 .el .IP "\f(CW$g\fR\->ntfsresize_size ($device, \f(CW$size\fR);" 4 .IX Item "$g->ntfsresize_size ($device, $size);" This command is the same as \f(CW\*(C`$g\->ntfsresize\*(C'\fR except that it allows you to specify the new size (in bytes) explicitly. .Sp This function depends on the feature \f(CW\*(C`ntfsprogs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "ntfsresize" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->parse_environment ();" 4 .el .IP "\f(CW$g\fR\->parse_environment ();" 4 .IX Item "$g->parse_environment ();" Parse the program’s environment and set flags in the handle accordingly. For example if \f(CW\*(C`LIBGUESTFS_DEBUG=1\*(C'\fR then the ‘verbose’ flag is set in the handle. .Sp \&\fIMost programs do not need to call this\fR. It is done implicitly when you call \f(CW\*(C`$g\->create\*(C'\fR. .Sp See "ENVIRONMENT VARIABLES" in \fBguestfs\fR\|(3) for a list of environment variables that can affect libguestfs handles. See also "guestfs_create_flags" in \fBguestfs\fR\|(3), and \&\f(CW\*(C`$g\->parse_environment_list\*(C'\fR. .ie n .IP "$g\->parse_environment_list (\e@environment);" 4 .el .IP "\f(CW$g\fR\->parse_environment_list (\e@environment);" 4 .IX Item "$g->parse_environment_list (@environment);" Parse the list of strings in the argument \f(CW\*(C`environment\*(C'\fR and set flags in the handle accordingly. For example if \f(CW\*(C`LIBGUESTFS_DEBUG=1\*(C'\fR is a string in the list, then the ‘verbose’ flag is set in the handle. .Sp This is the same as \f(CW\*(C`$g\->parse_environment\*(C'\fR except that it parses an explicit list of strings instead of the program's environment. .ie n .IP "$g\->part_add ($device, $prlogex, $startsect, $endsect);" 4 .el .IP "\f(CW$g\fR\->part_add ($device, \f(CW$prlogex\fR, \f(CW$startsect\fR, \f(CW$endsect\fR);" 4 .IX Item "$g->part_add ($device, $prlogex, $startsect, $endsect);" This command adds a partition to \f(CW\*(C`device\*(C'\fR. If there is no partition table on the device, call \f(CW\*(C`$g\->part_init\*(C'\fR first. .Sp The \f(CW\*(C`prlogex\*(C'\fR parameter is the type of partition. Normally you should pass \f(CW\*(C`p\*(C'\fR or \f(CW\*(C`primary\*(C'\fR here, but MBR partition tables also support \f(CW\*(C`l\*(C'\fR (or \f(CW\*(C`logical\*(C'\fR) and \f(CW\*(C`e\*(C'\fR (or \f(CW\*(C`extended\*(C'\fR) partition types. .Sp \&\f(CW\*(C`startsect\*(C'\fR and \f(CW\*(C`endsect\*(C'\fR are the start and end of the partition in \fIsectors\fR. \f(CW\*(C`endsect\*(C'\fR may be negative, which means it counts backwards from the end of the disk (\f(CW\-1\fR is the last sector). .Sp Creating a partition which covers the whole disk is not so easy. Use \f(CW\*(C`$g\->part_disk\*(C'\fR to do that. .ie n .IP "$g\->part_del ($device, $partnum);" 4 .el .IP "\f(CW$g\fR\->part_del ($device, \f(CW$partnum\fR);" 4 .IX Item "$g->part_del ($device, $partnum);" This command deletes the partition numbered \f(CW\*(C`partnum\*(C'\fR on \f(CW\*(C`device\*(C'\fR. .Sp Note that in the case of MBR partitioning, deleting an extended partition also deletes any logical partitions it contains. .ie n .IP "$g\->part_disk ($device, $parttype);" 4 .el .IP "\f(CW$g\fR\->part_disk ($device, \f(CW$parttype\fR);" 4 .IX Item "$g->part_disk ($device, $parttype);" This command is simply a combination of \f(CW\*(C`$g\->part_init\*(C'\fR followed by \f(CW\*(C`$g\->part_add\*(C'\fR to create a single primary partition covering the whole disk. .Sp \&\f(CW\*(C`parttype\*(C'\fR is the partition table type, usually \f(CW\*(C`mbr\*(C'\fR or \f(CW\*(C`gpt\*(C'\fR, but other possible values are described in \f(CW\*(C`$g\->part_init\*(C'\fR. .ie n .IP "$g\->part_expand_gpt ($device);" 4 .el .IP "\f(CW$g\fR\->part_expand_gpt ($device);" 4 .IX Item "$g->part_expand_gpt ($device);" Move backup GPT data structures to the end of the disk. This is useful in case of in-place image expand since disk space after backup GPT header is not usable. This is equivalent to \f(CW\*(C`sgdisk \-e\*(C'\fR. .Sp See also \fBsgdisk\fR\|(8). .Sp This function depends on the feature \f(CW\*(C`gdisk\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$bootable = $g\->part_get_bootable ($device, $partnum);" 4 .el .IP "\f(CW$bootable\fR = \f(CW$g\fR\->part_get_bootable ($device, \f(CW$partnum\fR);" 4 .IX Item "$bootable = $g->part_get_bootable ($device, $partnum);" This command returns true if the partition \f(CW\*(C`partnum\*(C'\fR on \&\f(CW\*(C`device\*(C'\fR has the bootable flag set. .Sp See also \f(CW\*(C`$g\->part_set_bootable\*(C'\fR. .ie n .IP "$guid = $g\->part_get_disk_guid ($device);" 4 .el .IP "\f(CW$guid\fR = \f(CW$g\fR\->part_get_disk_guid ($device);" 4 .IX Item "$guid = $g->part_get_disk_guid ($device);" Return the disk identifier (GUID) of a GPT-partitioned \f(CW\*(C`device\*(C'\fR. Behaviour is undefined for other partition types. .ie n .IP "$attributes = $g\->part_get_gpt_attributes ($device, $partnum);" 4 .el .IP "\f(CW$attributes\fR = \f(CW$g\fR\->part_get_gpt_attributes ($device, \f(CW$partnum\fR);" 4 .IX Item "$attributes = $g->part_get_gpt_attributes ($device, $partnum);" Return the attribute flags of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR. An error is returned for MBR partitions. .ie n .IP "$guid = $g\->part_get_gpt_guid ($device, $partnum);" 4 .el .IP "\f(CW$guid\fR = \f(CW$g\fR\->part_get_gpt_guid ($device, \f(CW$partnum\fR);" 4 .IX Item "$guid = $g->part_get_gpt_guid ($device, $partnum);" Return the GUID of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR. .ie n .IP "$guid = $g\->part_get_gpt_type ($device, $partnum);" 4 .el .IP "\f(CW$guid\fR = \f(CW$g\fR\->part_get_gpt_type ($device, \f(CW$partnum\fR);" 4 .IX Item "$guid = $g->part_get_gpt_type ($device, $partnum);" Return the type GUID of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR. .ie n .IP "$idbyte = $g\->part_get_mbr_id ($device, $partnum);" 4 .el .IP "\f(CW$idbyte\fR = \f(CW$g\fR\->part_get_mbr_id ($device, \f(CW$partnum\fR);" 4 .IX Item "$idbyte = $g->part_get_mbr_id ($device, $partnum);" Returns the MBR type byte (also known as the ID byte) from the numbered partition \f(CW\*(C`partnum\*(C'\fR. .Sp Note that only MBR (old DOS-style) partitions have type bytes. You will get undefined results for other partition table types (see \f(CW\*(C`$g\->part_get_parttype\*(C'\fR). .ie n .IP "$partitiontype = $g\->part_get_mbr_part_type ($device, $partnum);" 4 .el .IP "\f(CW$partitiontype\fR = \f(CW$g\fR\->part_get_mbr_part_type ($device, \f(CW$partnum\fR);" 4 .IX Item "$partitiontype = $g->part_get_mbr_part_type ($device, $partnum);" This returns the partition type of an MBR partition numbered \f(CW\*(C`partnum\*(C'\fR on device \f(CW\*(C`device\*(C'\fR. .Sp It returns \f(CW\*(C`primary\*(C'\fR, \f(CW\*(C`logical\*(C'\fR, or \f(CW\*(C`extended\*(C'\fR. .ie n .IP "$name = $g\->part_get_name ($device, $partnum);" 4 .el .IP "\f(CW$name\fR = \f(CW$g\fR\->part_get_name ($device, \f(CW$partnum\fR);" 4 .IX Item "$name = $g->part_get_name ($device, $partnum);" This gets the partition name on partition numbered \f(CW\*(C`partnum\*(C'\fR on device \f(CW\*(C`device\*(C'\fR. Note that partitions are numbered from 1. .Sp The partition name can only be read on certain types of partition table. This works on \f(CW\*(C`gpt\*(C'\fR but not on \f(CW\*(C`mbr\*(C'\fR partitions. .ie n .IP "$parttype = $g\->part_get_parttype ($device);" 4 .el .IP "\f(CW$parttype\fR = \f(CW$g\fR\->part_get_parttype ($device);" 4 .IX Item "$parttype = $g->part_get_parttype ($device);" This command examines the partition table on \f(CW\*(C`device\*(C'\fR and returns the partition table type (format) being used. .Sp Common return values include: \f(CW\*(C`msdos\*(C'\fR (a DOS/Windows style MBR partition table), \f(CW\*(C`gpt\*(C'\fR (a GPT/EFI\-style partition table). Other values are possible, although unusual. See \f(CW\*(C`$g\->part_init\*(C'\fR for a full list. .ie n .IP "$g\->part_init ($device, $parttype);" 4 .el .IP "\f(CW$g\fR\->part_init ($device, \f(CW$parttype\fR);" 4 .IX Item "$g->part_init ($device, $parttype);" This creates an empty partition table on \f(CW\*(C`device\*(C'\fR of one of the partition types listed below. Usually \f(CW\*(C`parttype\*(C'\fR should be either \f(CW\*(C`msdos\*(C'\fR or \f(CW\*(C`gpt\*(C'\fR (for large disks). .Sp Initially there are no partitions. Following this, you should call \f(CW\*(C`$g\->part_add\*(C'\fR for each partition required. .Sp Possible values for \f(CW\*(C`parttype\*(C'\fR are: .RS 4 .ie n .IP """efi""" 4 .el .IP \f(CWefi\fR 4 .IX Item "efi" .PD 0 .ie n .IP """gpt""" 4 .el .IP \f(CWgpt\fR 4 .IX Item "gpt" .PD Intel EFI / GPT partition table. .Sp This is recommended for >= 2 TB partitions that will be accessed from Linux and Intel-based Mac OS X. It also has limited backwards compatibility with the \f(CW\*(C`mbr\*(C'\fR format. .ie n .IP """mbr""" 4 .el .IP \f(CWmbr\fR 4 .IX Item "mbr" .PD 0 .ie n .IP """msdos""" 4 .el .IP \f(CWmsdos\fR 4 .IX Item "msdos" .PD The standard PC "Master Boot Record" (MBR) format used by MS-DOS and Windows. This partition type will \fBonly\fR work for device sizes up to 2 TB. For large disks we recommend using \f(CW\*(C`gpt\*(C'\fR. .RE .RS 4 .Sp Other partition table types that may work but are not supported include: .ie n .IP """aix""" 4 .el .IP \f(CWaix\fR 4 .IX Item "aix" AIX disk labels. .ie n .IP """amiga""" 4 .el .IP \f(CWamiga\fR 4 .IX Item "amiga" .PD 0 .ie n .IP """rdb""" 4 .el .IP \f(CWrdb\fR 4 .IX Item "rdb" .PD Amiga "Rigid Disk Block" format. .ie n .IP """bsd""" 4 .el .IP \f(CWbsd\fR 4 .IX Item "bsd" BSD disk labels. .ie n .IP """dasd""" 4 .el .IP \f(CWdasd\fR 4 .IX Item "dasd" DASD, used on IBM mainframes. .ie n .IP """dvh""" 4 .el .IP \f(CWdvh\fR 4 .IX Item "dvh" MIPS/SGI volumes. .ie n .IP """mac""" 4 .el .IP \f(CWmac\fR 4 .IX Item "mac" Old Mac partition format. Modern Macs use \f(CW\*(C`gpt\*(C'\fR. .ie n .IP """pc98""" 4 .el .IP \f(CWpc98\fR 4 .IX Item "pc98" NEC PC\-98 format, common in Japan apparently. .ie n .IP """sun""" 4 .el .IP \f(CWsun\fR 4 .IX Item "sun" Sun disk labels. .RE .RS 4 .RE .ie n .IP "@partitions = $g\->part_list ($device);" 4 .el .IP "\f(CW@partitions\fR = \f(CW$g\fR\->part_list ($device);" 4 .IX Item "@partitions = $g->part_list ($device);" This command parses the partition table on \f(CW\*(C`device\*(C'\fR and returns the list of partitions found. .Sp The fields in the returned structure are: .RS 4 .ie n .IP """part_num""" 4 .el .IP \f(CWpart_num\fR 4 .IX Item "part_num" Partition number, counting from 1. .ie n .IP """part_start""" 4 .el .IP \f(CWpart_start\fR 4 .IX Item "part_start" Start of the partition \fIin bytes\fR. To get sectors you have to divide by the device’s sector size, see \f(CW\*(C`$g\->blockdev_getss\*(C'\fR. .ie n .IP """part_end""" 4 .el .IP \f(CWpart_end\fR 4 .IX Item "part_end" End of the partition in bytes. .ie n .IP """part_size""" 4 .el .IP \f(CWpart_size\fR 4 .IX Item "part_size" Size of the partition in bytes. .RE .RS 4 .RE .ie n .IP "$g\->part_resize ($device, $partnum, $endsect);" 4 .el .IP "\f(CW$g\fR\->part_resize ($device, \f(CW$partnum\fR, \f(CW$endsect\fR);" 4 .IX Item "$g->part_resize ($device, $partnum, $endsect);" This command resizes the partition numbered \f(CW\*(C`partnum\*(C'\fR on \f(CW\*(C`device\*(C'\fR by moving the end position. .Sp Note that this does not modify any filesystem present in the partition. If you wish to do this, you will need to use filesystem resizing commands like \f(CW\*(C`$g\->resize2fs\*(C'\fR. .Sp When growing a partition you will want to grow the filesystem afterwards, but when shrinking, you need to shrink the filesystem before the partition. .ie n .IP "$g\->part_set_bootable ($device, $partnum, $bootable);" 4 .el .IP "\f(CW$g\fR\->part_set_bootable ($device, \f(CW$partnum\fR, \f(CW$bootable\fR);" 4 .IX Item "$g->part_set_bootable ($device, $partnum, $bootable);" This sets the bootable flag on partition numbered \f(CW\*(C`partnum\*(C'\fR on device \f(CW\*(C`device\*(C'\fR. Note that partitions are numbered from 1. .Sp The bootable flag is used by some operating systems (notably Windows) to determine which partition to boot from. It is by no means universally recognized. .ie n .IP "$g\->part_set_disk_guid ($device, $guid);" 4 .el .IP "\f(CW$g\fR\->part_set_disk_guid ($device, \f(CW$guid\fR);" 4 .IX Item "$g->part_set_disk_guid ($device, $guid);" Set the disk identifier (GUID) of a GPT-partitioned \f(CW\*(C`device\*(C'\fR to \f(CW\*(C`guid\*(C'\fR. Return an error if the partition table of \f(CW\*(C`device\*(C'\fR isn't GPT, or if \f(CW\*(C`guid\*(C'\fR is not a valid GUID. .ie n .IP "$g\->part_set_disk_guid_random ($device);" 4 .el .IP "\f(CW$g\fR\->part_set_disk_guid_random ($device);" 4 .IX Item "$g->part_set_disk_guid_random ($device);" Set the disk identifier (GUID) of a GPT-partitioned \f(CW\*(C`device\*(C'\fR to a randomly generated value. Return an error if the partition table of \f(CW\*(C`device\*(C'\fR isn't GPT. .ie n .IP "$g\->part_set_gpt_attributes ($device, $partnum, $attributes);" 4 .el .IP "\f(CW$g\fR\->part_set_gpt_attributes ($device, \f(CW$partnum\fR, \f(CW$attributes\fR);" 4 .IX Item "$g->part_set_gpt_attributes ($device, $partnum, $attributes);" Set the attribute flags of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR to \f(CW\*(C`attributes\*(C'\fR. Return an error if the partition table of \f(CW\*(C`device\*(C'\fR isn't GPT. .Sp See for a useful list of partition attributes. .ie n .IP "$g\->part_set_gpt_guid ($device, $partnum, $guid);" 4 .el .IP "\f(CW$g\fR\->part_set_gpt_guid ($device, \f(CW$partnum\fR, \f(CW$guid\fR);" 4 .IX Item "$g->part_set_gpt_guid ($device, $partnum, $guid);" Set the GUID of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR to \f(CW\*(C`guid\*(C'\fR. Return an error if the partition table of \f(CW\*(C`device\*(C'\fR isn't GPT, or if \f(CW\*(C`guid\*(C'\fR is not a valid GUID. .ie n .IP "$g\->part_set_gpt_type ($device, $partnum, $guid);" 4 .el .IP "\f(CW$g\fR\->part_set_gpt_type ($device, \f(CW$partnum\fR, \f(CW$guid\fR);" 4 .IX Item "$g->part_set_gpt_type ($device, $partnum, $guid);" Set the type GUID of numbered GPT partition \f(CW\*(C`partnum\*(C'\fR to \f(CW\*(C`guid\*(C'\fR. Return an error if the partition table of \f(CW\*(C`device\*(C'\fR isn't GPT, or if \f(CW\*(C`guid\*(C'\fR is not a valid GUID. .Sp See for a useful list of type GUIDs. .ie n .IP "$g\->part_set_mbr_id ($device, $partnum, $idbyte);" 4 .el .IP "\f(CW$g\fR\->part_set_mbr_id ($device, \f(CW$partnum\fR, \f(CW$idbyte\fR);" 4 .IX Item "$g->part_set_mbr_id ($device, $partnum, $idbyte);" Sets the MBR type byte (also known as the ID byte) of the numbered partition \f(CW\*(C`partnum\*(C'\fR to \f(CW\*(C`idbyte\*(C'\fR. Note that the type bytes quoted in most documentation are in fact hexadecimal numbers, but usually documented without any leading "0x" which might be confusing. .Sp Note that only MBR (old DOS-style) partitions have type bytes. You will get undefined results for other partition table types (see \f(CW\*(C`$g\->part_get_parttype\*(C'\fR). .ie n .IP "$g\->part_set_name ($device, $partnum, $name);" 4 .el .IP "\f(CW$g\fR\->part_set_name ($device, \f(CW$partnum\fR, \f(CW$name\fR);" 4 .IX Item "$g->part_set_name ($device, $partnum, $name);" This sets the partition name on partition numbered \f(CW\*(C`partnum\*(C'\fR on device \f(CW\*(C`device\*(C'\fR. Note that partitions are numbered from 1. .Sp The partition name can only be set on certain types of partition table. This works on \f(CW\*(C`gpt\*(C'\fR but not on \f(CW\*(C`mbr\*(C'\fR partitions. .ie n .IP "$device = $g\->part_to_dev ($partition);" 4 .el .IP "\f(CW$device\fR = \f(CW$g\fR\->part_to_dev ($partition);" 4 .IX Item "$device = $g->part_to_dev ($partition);" This function takes a partition name (eg. "/dev/sdb1") and removes the partition number, returning the device name (eg. "/dev/sdb"). .Sp The named partition must exist, for example as a string returned from \f(CW\*(C`$g\->list_partitions\*(C'\fR. .Sp See also \f(CW\*(C`$g\->part_to_partnum\*(C'\fR, \f(CW\*(C`$g\->device_index\*(C'\fR. .ie n .IP "$partnum = $g\->part_to_partnum ($partition);" 4 .el .IP "\f(CW$partnum\fR = \f(CW$g\fR\->part_to_partnum ($partition);" 4 .IX Item "$partnum = $g->part_to_partnum ($partition);" This function takes a partition name (eg. "/dev/sdb1") and returns the partition number (eg. \f(CW1\fR). .Sp The named partition must exist, for example as a string returned from \f(CW\*(C`$g\->list_partitions\*(C'\fR. .Sp See also \f(CW\*(C`$g\->part_to_dev\*(C'\fR. .ie n .IP "$g\->ping_daemon ();" 4 .el .IP "\f(CW$g\fR\->ping_daemon ();" 4 .IX Item "$g->ping_daemon ();" This is a test probe into the guestfs daemon running inside the libguestfs appliance. Calling this function checks that the daemon responds to the ping message, without affecting the daemon or attached block device(s) in any other way. .ie n .IP "$content = $g\->pread ($path, $count, $offset);" 4 .el .IP "\f(CW$content\fR = \f(CW$g\fR\->pread ($path, \f(CW$count\fR, \f(CW$offset\fR);" 4 .IX Item "$content = $g->pread ($path, $count, $offset);" This command lets you read part of a file. It reads \f(CW\*(C`count\*(C'\fR bytes of the file, starting at \f(CW\*(C`offset\*(C'\fR, from file \f(CW\*(C`path\*(C'\fR. .Sp This may read fewer bytes than requested. For further details see the \fBpread\fR\|(2) system call. .Sp See also \f(CW\*(C`$g\->pwrite\*(C'\fR, \f(CW\*(C`$g\->pread_device\*(C'\fR. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$content = $g\->pread_device ($device, $count, $offset);" 4 .el .IP "\f(CW$content\fR = \f(CW$g\fR\->pread_device ($device, \f(CW$count\fR, \f(CW$offset\fR);" 4 .IX Item "$content = $g->pread_device ($device, $count, $offset);" This command lets you read part of a block device. It reads \f(CW\*(C`count\*(C'\fR bytes of \f(CW\*(C`device\*(C'\fR, starting at \f(CW\*(C`offset\*(C'\fR. .Sp This may read fewer bytes than requested. For further details see the \fBpread\fR\|(2) system call. .Sp See also \f(CW\*(C`$g\->pread\*(C'\fR. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->pvchange_uuid ($device);" 4 .el .IP "\f(CW$g\fR\->pvchange_uuid ($device);" 4 .IX Item "$g->pvchange_uuid ($device);" Generate a new random UUID for the physical volume \f(CW\*(C`device\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->pvchange_uuid_all ();" 4 .el .IP "\f(CW$g\fR\->pvchange_uuid_all ();" 4 .IX Item "$g->pvchange_uuid_all ();" Generate new random UUIDs for all physical volumes. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->pvcreate ($device);" 4 .el .IP "\f(CW$g\fR\->pvcreate ($device);" 4 .IX Item "$g->pvcreate ($device);" This creates an LVM physical volume on the named \f(CW\*(C`device\*(C'\fR, where \f(CW\*(C`device\*(C'\fR should usually be a partition name such as \fI/dev/sda1\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->pvremove ($device);" 4 .el .IP "\f(CW$g\fR\->pvremove ($device);" 4 .IX Item "$g->pvremove ($device);" This wipes a physical volume \f(CW\*(C`device\*(C'\fR so that LVM will no longer recognise it. .Sp The implementation uses the \fBpvremove\fR\|(8) command which refuses to wipe physical volumes that contain any volume groups, so you have to remove those first. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->pvresize ($device);" 4 .el .IP "\f(CW$g\fR\->pvresize ($device);" 4 .IX Item "$g->pvresize ($device);" This resizes (expands or shrinks) an existing LVM physical volume to match the new size of the underlying device. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->pvresize_size ($device, $size);" 4 .el .IP "\f(CW$g\fR\->pvresize_size ($device, \f(CW$size\fR);" 4 .IX Item "$g->pvresize_size ($device, $size);" This command is the same as \f(CW\*(C`$g\->pvresize\*(C'\fR except that it allows you to specify the new size (in bytes) explicitly. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@physvols = $g\->pvs ();" 4 .el .IP "\f(CW@physvols\fR = \f(CW$g\fR\->pvs ();" 4 .IX Item "@physvols = $g->pvs ();" List all the physical volumes detected. This is the equivalent of the \fBpvs\fR\|(8) command. .Sp This returns a list of just the device names that contain PVs (eg. \fI/dev/sda2\fR). .Sp See also \f(CW\*(C`$g\->pvs_full\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@physvols = $g\->pvs_full ();" 4 .el .IP "\f(CW@physvols\fR = \f(CW$g\fR\->pvs_full ();" 4 .IX Item "@physvols = $g->pvs_full ();" List all the physical volumes detected. This is the equivalent of the \fBpvs\fR\|(8) command. The "full" version includes all fields. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$uuid = $g\->pvuuid ($device);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->pvuuid ($device);" 4 .IX Item "$uuid = $g->pvuuid ($device);" This command returns the UUID of the LVM PV \f(CW\*(C`device\*(C'\fR. .ie n .IP "$nbytes = $g\->pwrite ($path, $content, $offset);" 4 .el .IP "\f(CW$nbytes\fR = \f(CW$g\fR\->pwrite ($path, \f(CW$content\fR, \f(CW$offset\fR);" 4 .IX Item "$nbytes = $g->pwrite ($path, $content, $offset);" This command writes to part of a file. It writes the data buffer \f(CW\*(C`content\*(C'\fR to the file \f(CW\*(C`path\*(C'\fR starting at offset \f(CW\*(C`offset\*(C'\fR. .Sp This command implements the \fBpwrite\fR\|(2) system call, and like that system call it may not write the full data requested. The return value is the number of bytes that were actually written to the file. This could even be 0, although short writes are unlikely for regular files in ordinary circumstances. .Sp See also \f(CW\*(C`$g\->pread\*(C'\fR, \f(CW\*(C`$g\->pwrite_device\*(C'\fR. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$nbytes = $g\->pwrite_device ($device, $content, $offset);" 4 .el .IP "\f(CW$nbytes\fR = \f(CW$g\fR\->pwrite_device ($device, \f(CW$content\fR, \f(CW$offset\fR);" 4 .IX Item "$nbytes = $g->pwrite_device ($device, $content, $offset);" This command writes to part of a device. It writes the data buffer \f(CW\*(C`content\*(C'\fR to \f(CW\*(C`device\*(C'\fR starting at offset \f(CW\*(C`offset\*(C'\fR. .Sp This command implements the \fBpwrite\fR\|(2) system call, and like that system call it may not write the full data requested (although short writes to disk devices and partitions are probably impossible with standard Linux kernels). .Sp See also \f(CW\*(C`$g\->pwrite\*(C'\fR. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$content = $g\->read_file ($path);" 4 .el .IP "\f(CW$content\fR = \f(CW$g\fR\->read_file ($path);" 4 .IX Item "$content = $g->read_file ($path);" This calls returns the contents of the file \f(CW\*(C`path\*(C'\fR as a buffer. .Sp Unlike \f(CW\*(C`$g\->cat\*(C'\fR, this function can correctly handle files that contain embedded ASCII NUL characters. .ie n .IP "@lines = $g\->read_lines ($path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->read_lines ($path);" 4 .IX Item "@lines = $g->read_lines ($path);" Return the contents of the file named \f(CW\*(C`path\*(C'\fR. .Sp The file contents are returned as a list of lines. Trailing \&\f(CW\*(C`LF\*(C'\fR and \f(CW\*(C`CRLF\*(C'\fR character sequences are \fInot\fR returned. .Sp Note that this function cannot correctly handle binary files (specifically, files containing \f(CW\*(C`\e0\*(C'\fR character which is treated as end of string). For those you need to use the \f(CW\*(C`$g\->read_file\*(C'\fR function and split the buffer into lines yourself. .ie n .IP "@entries = $g\->readdir ($dir);" 4 .el .IP "\f(CW@entries\fR = \f(CW$g\fR\->readdir ($dir);" 4 .IX Item "@entries = $g->readdir ($dir);" This returns the list of directory entries in directory \f(CW\*(C`dir\*(C'\fR. .Sp All entries in the directory are returned, including \f(CW\*(C`.\*(C'\fR and \&\f(CW\*(C`..\*(C'\fR. The entries are \fInot\fR sorted, but returned in the same order as the underlying filesystem. .Sp Also this call returns basic file type information about each file. The \f(CW\*(C`ftyp\*(C'\fR field will contain one of the following characters: .RS 4 .IP 'b' 4 .IX Item "'b'" Block special .IP 'c' 4 .IX Item "'c'" Char special .IP 'd' 4 .IX Item "'d'" Directory .IP 'f' 4 .IX Item "'f'" FIFO (named pipe) .IP 'l' 4 .IX Item "'l'" Symbolic link .IP 'r' 4 .IX Item "'r'" Regular file .IP 's' 4 .IX Item "'s'" Socket .IP 'u' 4 .IX Item "'u'" Unknown file type .IP '?' 4 The \fBreaddir\fR\|(3) call returned a \f(CW\*(C`d_type\*(C'\fR field with an unexpected value .RE .RS 4 .Sp This function is primarily intended for use by programs. To get a simple list of names, use \f(CW\*(C`$g\->ls\*(C'\fR. To get a printable directory for human consumption, use \f(CW\*(C`$g\->ll\*(C'\fR. .RE .ie n .IP "$link = $g\->readlink ($path);" 4 .el .IP "\f(CW$link\fR = \f(CW$g\fR\->readlink ($path);" 4 .IX Item "$link = $g->readlink ($path);" This command reads the target of a symbolic link. .ie n .IP "@links = $g\->readlinklist ($path, \e@names);" 4 .el .IP "\f(CW@links\fR = \f(CW$g\fR\->readlinklist ($path, \e@names);" 4 .IX Item "@links = $g->readlinklist ($path, @names);" This call allows you to do a \f(CW\*(C`readlink\*(C'\fR operation on multiple files, where all files are in the directory \f(CW\*(C`path\*(C'\fR. \&\f(CW\*(C`names\*(C'\fR is the list of files from this directory. .Sp On return you get a list of strings, with a one-to-one correspondence to the \f(CW\*(C`names\*(C'\fR list. Each string is the value of the symbolic link. .Sp If the \fBreadlink\fR\|(2) operation fails on any name, then the corresponding result string is the empty string \f(CW""\fR. However the whole operation is completed even if there were \fBreadlink\fR\|(2) errors, and so you can call this function with names where you don't know if they are symbolic links already (albeit slightly less efficient). .Sp This call is intended for programs that want to efficiently list a directory contents without making many round-trips. .ie n .IP "$rpath = $g\->realpath ($path);" 4 .el .IP "\f(CW$rpath\fR = \f(CW$g\fR\->realpath ($path);" 4 .IX Item "$rpath = $g->realpath ($path);" Return the canonicalized absolute pathname of \f(CW\*(C`path\*(C'\fR. The returned path has no \f(CW\*(C`.\*(C'\fR, \f(CW\*(C`..\*(C'\fR or symbolic link path elements. .ie n .IP "$g\->remount ($mountpoint [, rw => $rw]);" 4 .el .IP "\f(CW$g\fR\->remount ($mountpoint [, rw => \f(CW$rw\fR]);" 4 .IX Item "$g->remount ($mountpoint [, rw => $rw]);" This call allows you to change the \f(CW\*(C`rw\*(C'\fR (readonly/read\-write) flag on an already mounted filesystem at \f(CW\*(C`mountpoint\*(C'\fR, converting a readonly filesystem to be read-write, or vice-versa. .Sp Note that at the moment you must supply the "optional" \f(CW\*(C`rw\*(C'\fR parameter. In future we may allow other flags to be adjusted. .ie n .IP "$g\->remove_drive ($label);" 4 .el .IP "\f(CW$g\fR\->remove_drive ($label);" 4 .IX Item "$g->remove_drive ($label);" This call does nothing and returns an error. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->removexattr ($xattr, $path);" 4 .el .IP "\f(CW$g\fR\->removexattr ($xattr, \f(CW$path\fR);" 4 .IX Item "$g->removexattr ($xattr, $path);" This call removes the extended attribute named \f(CW\*(C`xattr\*(C'\fR of the file \f(CW\*(C`path\*(C'\fR. .Sp See also: \f(CW\*(C`$g\->lremovexattr\*(C'\fR, \fBattr\fR\|(5). .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->rename ($oldpath, $newpath);" 4 .el .IP "\f(CW$g\fR\->rename ($oldpath, \f(CW$newpath\fR);" 4 .IX Item "$g->rename ($oldpath, $newpath);" Rename a file to a new place on the same filesystem. This is the same as the Linux \fBrename\fR\|(2) system call. In most cases you are better to use \f(CW\*(C`$g\->mv\*(C'\fR instead. .ie n .IP "$g\->resize2fs ($device);" 4 .el .IP "\f(CW$g\fR\->resize2fs ($device);" 4 .IX Item "$g->resize2fs ($device);" This resizes an ext2, ext3 or ext4 filesystem to match the size of the underlying device. .Sp See also "RESIZE2FS ERRORS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->resize2fs_M ($device);" 4 .el .IP "\f(CW$g\fR\->resize2fs_M ($device);" 4 .IX Item "$g->resize2fs_M ($device);" This command is the same as \f(CW\*(C`$g\->resize2fs\*(C'\fR, but the filesystem is resized to its minimum size. This works like the \fI\-M\fR option to the \fBresize2fs\fR\|(8) command. .Sp To get the resulting size of the filesystem you should call \&\f(CW\*(C`$g\->tune2fs_l\*(C'\fR and read the \f(CW\*(C`Block size\*(C'\fR and \f(CW\*(C`Block count\*(C'\fR values. These two numbers, multiplied together, give the resulting size of the minimal filesystem in bytes. .Sp See also "RESIZE2FS ERRORS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->resize2fs_size ($device, $size);" 4 .el .IP "\f(CW$g\fR\->resize2fs_size ($device, \f(CW$size\fR);" 4 .IX Item "$g->resize2fs_size ($device, $size);" This command is the same as \f(CW\*(C`$g\->resize2fs\*(C'\fR except that it allows you to specify the new size (in bytes) explicitly. .Sp See also "RESIZE2FS ERRORS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->rm ($path);" 4 .el .IP "\f(CW$g\fR\->rm ($path);" 4 .IX Item "$g->rm ($path);" Remove the single file \f(CW\*(C`path\*(C'\fR. .ie n .IP "$g\->rm_f ($path);" 4 .el .IP "\f(CW$g\fR\->rm_f ($path);" 4 .IX Item "$g->rm_f ($path);" Remove the file \f(CW\*(C`path\*(C'\fR. .Sp If the file doesn't exist, that error is ignored. (Other errors, eg. I/O errors or bad paths, are not ignored) .Sp This call cannot remove directories. Use \f(CW\*(C`$g\->rmdir\*(C'\fR to remove an empty directory, or \f(CW\*(C`$g\->rm_rf\*(C'\fR to remove directories recursively. .ie n .IP "$g\->rm_rf ($path);" 4 .el .IP "\f(CW$g\fR\->rm_rf ($path);" 4 .IX Item "$g->rm_rf ($path);" Remove the file or directory \f(CW\*(C`path\*(C'\fR, recursively removing the contents if its a directory. This is like the \f(CW\*(C`rm \-rf\*(C'\fR shell command. .ie n .IP "$g\->rmdir ($path);" 4 .el .IP "\f(CW$g\fR\->rmdir ($path);" 4 .IX Item "$g->rmdir ($path);" Remove the single directory \f(CW\*(C`path\*(C'\fR. .ie n .IP "$g\->rmmountpoint ($exemptpath);" 4 .el .IP "\f(CW$g\fR\->rmmountpoint ($exemptpath);" 4 .IX Item "$g->rmmountpoint ($exemptpath);" This call removes a mountpoint that was previously created with \f(CW\*(C`$g\->mkmountpoint\*(C'\fR. See \f(CW\*(C`$g\->mkmountpoint\*(C'\fR for full details. .ie n .IP "$g\->rsync ($src, $dest [, archive => $archive] [, deletedest => $deletedest]);" 4 .el .IP "\f(CW$g\fR\->rsync ($src, \f(CW$dest\fR [, archive => \f(CW$archive\fR] [, deletedest => \f(CW$deletedest\fR]);" 4 .IX Item "$g->rsync ($src, $dest [, archive => $archive] [, deletedest => $deletedest]);" This call may be used to copy or synchronize two directories under the same libguestfs handle. This uses the \fBrsync\fR\|(1) program which uses a fast algorithm that avoids copying files unnecessarily. .Sp \&\f(CW\*(C`src\*(C'\fR and \f(CW\*(C`dest\*(C'\fR are the source and destination directories. Files are copied from \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dest\*(C'\fR. .Sp The optional arguments are: .RS 4 .ie n .IP """archive""" 4 .el .IP \f(CWarchive\fR 4 .IX Item "archive" Turns on archive mode. This is the same as passing the \&\fI\-\-archive\fR flag to \f(CW\*(C`rsync\*(C'\fR. .ie n .IP """deletedest""" 4 .el .IP \f(CWdeletedest\fR 4 .IX Item "deletedest" Delete files at the destination that do not exist at the source. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`rsync\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "$g\->rsync_in ($remote, $dest [, archive => $archive] [, deletedest => $deletedest]);" 4 .el .IP "\f(CW$g\fR\->rsync_in ($remote, \f(CW$dest\fR [, archive => \f(CW$archive\fR] [, deletedest => \f(CW$deletedest\fR]);" 4 .IX Item "$g->rsync_in ($remote, $dest [, archive => $archive] [, deletedest => $deletedest]);" This call may be used to copy or synchronize the filesystem on the host or on a remote computer with the filesystem within libguestfs. This uses the \fBrsync\fR\|(1) program which uses a fast algorithm that avoids copying files unnecessarily. .Sp This call only works if the network is enabled. See \&\f(CW\*(C`$g\->set_network\*(C'\fR or the \fI\-\-network\fR option to various tools like \fBguestfish\fR\|(1). .Sp Files are copied from the remote server and directory specified by \f(CW\*(C`remote\*(C'\fR to the destination directory \f(CW\*(C`dest\*(C'\fR. .Sp The format of the remote server string is defined by \fBrsync\fR\|(1). Note that there is no way to supply a password or passphrase so the target must be set up not to require one. .Sp The optional arguments are the same as those of \f(CW\*(C`$g\->rsync\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`rsync\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->rsync_out ($src, $remote [, archive => $archive] [, deletedest => $deletedest]);" 4 .el .IP "\f(CW$g\fR\->rsync_out ($src, \f(CW$remote\fR [, archive => \f(CW$archive\fR] [, deletedest => \f(CW$deletedest\fR]);" 4 .IX Item "$g->rsync_out ($src, $remote [, archive => $archive] [, deletedest => $deletedest]);" This call may be used to copy or synchronize the filesystem within libguestfs with a filesystem on the host or on a remote computer. This uses the \fBrsync\fR\|(1) program which uses a fast algorithm that avoids copying files unnecessarily. .Sp This call only works if the network is enabled. See \&\f(CW\*(C`$g\->set_network\*(C'\fR or the \fI\-\-network\fR option to various tools like \fBguestfish\fR\|(1). .Sp Files are copied from the source directory \f(CW\*(C`src\*(C'\fR to the remote server and directory specified by \f(CW\*(C`remote\*(C'\fR. .Sp The format of the remote server string is defined by \fBrsync\fR\|(1). Note that there is no way to supply a password or passphrase so the target must be set up not to require one. .Sp The optional arguments are the same as those of \f(CW\*(C`$g\->rsync\*(C'\fR. .Sp Globbing does not happen on the \f(CW\*(C`src\*(C'\fR parameter. In programs which use the API directly you have to expand wildcards yourself (see \f(CW\*(C`$g\->glob_expand\*(C'\fR). In guestfish you can use the \f(CW\*(C`glob\*(C'\fR command (see "glob" in \fBguestfish\fR\|(1)), for example: .Sp .Vb 1 \& > glob rsync\-out /* rsync://remote/ .Ve .Sp This function depends on the feature \f(CW\*(C`rsync\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->scrub_device ($device);" 4 .el .IP "\f(CW$g\fR\->scrub_device ($device);" 4 .IX Item "$g->scrub_device ($device);" This command writes patterns over \f(CW\*(C`device\*(C'\fR to make data retrieval more difficult. .Sp It is an interface to the \fBscrub\fR\|(1) program. See that manual page for more details. .Sp This function depends on the feature \f(CW\*(C`scrub\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->scrub_file ($file);" 4 .el .IP "\f(CW$g\fR\->scrub_file ($file);" 4 .IX Item "$g->scrub_file ($file);" This command writes patterns over a file to make data retrieval more difficult. .Sp The file is \fIremoved\fR after scrubbing. .Sp It is an interface to the \fBscrub\fR\|(1) program. See that manual page for more details. .Sp This function depends on the feature \f(CW\*(C`scrub\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->scrub_freespace ($dir);" 4 .el .IP "\f(CW$g\fR\->scrub_freespace ($dir);" 4 .IX Item "$g->scrub_freespace ($dir);" This command creates the directory \f(CW\*(C`dir\*(C'\fR and then fills it with files until the filesystem is full, and scrubs the files as for \f(CW\*(C`$g\->scrub_file\*(C'\fR, and deletes them. The intention is to scrub any free space on the partition containing \f(CW\*(C`dir\*(C'\fR. .Sp It is an interface to the \fBscrub\fR\|(1) program. See that manual page for more details. .Sp This function depends on the feature \f(CW\*(C`scrub\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->selinux_relabel ($specfile, $path [, force => $force]);" 4 .el .IP "\f(CW$g\fR\->selinux_relabel ($specfile, \f(CW$path\fR [, force => \f(CW$force\fR]);" 4 .IX Item "$g->selinux_relabel ($specfile, $path [, force => $force]);" SELinux relabel parts of the filesystem. .Sp The \f(CW\*(C`specfile\*(C'\fR parameter controls the policy spec file used. You have to parse \f(CW\*(C`/etc/selinux/config\*(C'\fR to find the correct SELinux policy and then pass the spec file, usually: \&\f(CW\*(C`/etc/selinux/\*(C'\fR + \fIselinuxtype\fR + \f(CW\*(C`/contexts/files/file_contexts\*(C'\fR. .Sp The required \f(CW\*(C`path\*(C'\fR parameter is the top level directory where relabelling starts. Normally you should pass \f(CW\*(C`path\*(C'\fR as \f(CW\*(C`/\*(C'\fR to relabel the whole guest filesystem. .Sp The optional \f(CW\*(C`force\*(C'\fR boolean controls whether the context is reset for customizable files, and also whether the user, role and range parts of the file context is changed. .Sp This function depends on the feature \f(CW\*(C`selinuxrelabel\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->set_append ($append);" 4 .el .IP "\f(CW$g\fR\->set_append ($append);" 4 .IX Item "$g->set_append ($append);" This function is used to add additional options to the libguestfs appliance kernel command line. .Sp The default is \f(CW\*(C`NULL\*(C'\fR unless overridden by setting \&\f(CW\*(C`LIBGUESTFS_APPEND\*(C'\fR environment variable. .Sp Setting \f(CW\*(C`append\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR means \fIno\fR additional options are passed (libguestfs always adds a few of its own). .ie n .IP "$g\->set_attach_method ($backend);" 4 .el .IP "\f(CW$g\fR\->set_attach_method ($backend);" 4 .IX Item "$g->set_attach_method ($backend);" Set the method that libguestfs uses to connect to the backend guestfsd daemon. .Sp See "BACKEND" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "set_backend" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_autosync ($autosync);" 4 .el .IP "\f(CW$g\fR\->set_autosync ($autosync);" 4 .IX Item "$g->set_autosync ($autosync);" If \f(CW\*(C`autosync\*(C'\fR is true, this enables autosync. Libguestfs will make a best effort attempt to make filesystems consistent and synchronized when the handle is closed (also if the program exits without closing handles). .Sp This is enabled by default (since libguestfs 1.5.24, previously it was disabled by default). .ie n .IP "$g\->set_backend ($backend);" 4 .el .IP "\f(CW$g\fR\->set_backend ($backend);" 4 .IX Item "$g->set_backend ($backend);" Set the method that libguestfs uses to connect to the backend guestfsd daemon. .Sp This handle property was previously called the "attach method". .Sp See "BACKEND" in \fBguestfs\fR\|(3). .ie n .IP "$g\->set_backend_setting ($name, $val);" 4 .el .IP "\f(CW$g\fR\->set_backend_setting ($name, \f(CW$val\fR);" 4 .IX Item "$g->set_backend_setting ($name, $val);" Append \f(CW"name=value"\fR to the backend settings string list. However if a string already exists matching \f(CW"name"\fR or beginning with \f(CW"name="\fR, then that setting is replaced. .Sp See "BACKEND" in \fBguestfs\fR\|(3), "BACKEND SETTINGS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->set_backend_settings (\e@settings);" 4 .el .IP "\f(CW$g\fR\->set_backend_settings (\e@settings);" 4 .IX Item "$g->set_backend_settings (@settings);" Set a list of zero or more settings which are passed through to the current backend. Each setting is a string which is interpreted in a backend-specific way, or ignored if not understood by the backend. .Sp The default value is an empty list, unless the environment variable \f(CW\*(C`LIBGUESTFS_BACKEND_SETTINGS\*(C'\fR was set when the handle was created. This environment variable contains a colon-separated list of settings. .Sp This call replaces all backend settings. If you want to replace a single backend setting, see \f(CW\*(C`$g\->set_backend_setting\*(C'\fR. If you want to clear a single backend setting, see \&\f(CW\*(C`$g\->clear_backend_setting\*(C'\fR. .Sp See "BACKEND" in \fBguestfs\fR\|(3), "BACKEND SETTINGS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->set_cachedir ($cachedir);" 4 .el .IP "\f(CW$g\fR\->set_cachedir ($cachedir);" 4 .IX Item "$g->set_cachedir ($cachedir);" Set the directory used by the handle to store the appliance cache, when using a supermin appliance. The appliance is cached and shared between all handles which have the same effective user ID. .Sp The environment variables \f(CW\*(C`LIBGUESTFS_CACHEDIR\*(C'\fR and \f(CW\*(C`TMPDIR\*(C'\fR control the default value: If \f(CW\*(C`LIBGUESTFS_CACHEDIR\*(C'\fR is set, then that is the default. Else if \f(CW\*(C`TMPDIR\*(C'\fR is set, then that is the default. Else \fI/var/tmp\fR is the default. .ie n .IP "$g\->set_direct ($direct);" 4 .el .IP "\f(CW$g\fR\->set_direct ($direct);" 4 .IX Item "$g->set_direct ($direct);" If the direct appliance mode flag is enabled, then stdin and stdout are passed directly through to the appliance once it is launched. .Sp One consequence of this is that log messages aren't caught by the library and handled by \f(CW\*(C`$g\->set_log_message_callback\*(C'\fR, but go straight to stdout. .Sp You probably don't want to use this unless you know what you are doing. .Sp The default is disabled. .Sp \&\fIThis function is deprecated.\fR In new code, use the "internal_get_console_socket" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_e2attrs ($file, $attrs [, clear => $clear]);" 4 .el .IP "\f(CW$g\fR\->set_e2attrs ($file, \f(CW$attrs\fR [, clear => \f(CW$clear\fR]);" 4 .IX Item "$g->set_e2attrs ($file, $attrs [, clear => $clear]);" This sets or clears the file attributes \f(CW\*(C`attrs\*(C'\fR associated with the inode \fIfile\fR. .Sp \&\f(CW\*(C`attrs\*(C'\fR is a string of characters representing file attributes. See \f(CW\*(C`$g\->get_e2attrs\*(C'\fR for a list of possible attributes. Not all attributes can be changed. .Sp If optional boolean \f(CW\*(C`clear\*(C'\fR is not present or false, then the \f(CW\*(C`attrs\*(C'\fR listed are set in the inode. .Sp If \f(CW\*(C`clear\*(C'\fR is true, then the \f(CW\*(C`attrs\*(C'\fR listed are cleared in the inode. .Sp In both cases, other attributes not present in the \f(CW\*(C`attrs\*(C'\fR string are left unchanged. .Sp These attributes are only present when the file is located on an ext2/3/4 filesystem. Using this call on other filesystem types will result in an error. .ie n .IP "$g\->set_e2generation ($file, $generation);" 4 .el .IP "\f(CW$g\fR\->set_e2generation ($file, \f(CW$generation\fR);" 4 .IX Item "$g->set_e2generation ($file, $generation);" This sets the ext2 file generation of a file. .Sp See \f(CW\*(C`$g\->get_e2generation\*(C'\fR. .ie n .IP "$g\->set_e2label ($device, $label);" 4 .el .IP "\f(CW$g\fR\->set_e2label ($device, \f(CW$label\fR);" 4 .IX Item "$g->set_e2label ($device, $label);" This sets the ext2/3/4 filesystem label of the filesystem on \&\f(CW\*(C`device\*(C'\fR to \f(CW\*(C`label\*(C'\fR. Filesystem labels are limited to 16 characters. .Sp You can use either \f(CW\*(C`$g\->tune2fs_l\*(C'\fR or \f(CW\*(C`$g\->get_e2label\*(C'\fR to return the existing label on a filesystem. .Sp \&\fIThis function is deprecated.\fR In new code, use the "set_label" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_e2uuid ($device, $uuid);" 4 .el .IP "\f(CW$g\fR\->set_e2uuid ($device, \f(CW$uuid\fR);" 4 .IX Item "$g->set_e2uuid ($device, $uuid);" This sets the ext2/3/4 filesystem UUID of the filesystem on \&\f(CW\*(C`device\*(C'\fR to \f(CW\*(C`uuid\*(C'\fR. The format of the UUID and alternatives such as \f(CW\*(C`clear\*(C'\fR, \f(CW\*(C`random\*(C'\fR and \f(CW\*(C`time\*(C'\fR are described in the \&\fBtune2fs\fR\|(8) manpage. .Sp You can use \f(CW\*(C`$g\->vfs_uuid\*(C'\fR to return the existing UUID of a filesystem. .Sp \&\fIThis function is deprecated.\fR In new code, use the "set_uuid" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_hv ($hv);" 4 .el .IP "\f(CW$g\fR\->set_hv ($hv);" 4 .IX Item "$g->set_hv ($hv);" Set the hypervisor binary that we will use. The hypervisor depends on the backend, but is usually the location of the qemu/KVM hypervisor. .Sp The default is chosen when the library was compiled by the configure script. .Sp You can also override this by setting the \f(CW\*(C`LIBGUESTFS_HV\*(C'\fR environment variable. .Sp Note that you should call this function as early as possible after creating the handle. This is because some pre-launch operations depend on testing qemu features (by running \f(CW\*(C`qemu \-help\*(C'\fR). If the qemu binary changes, we don't retest features, and so you might see inconsistent results. Using the environment variable \f(CW\*(C`LIBGUESTFS_HV\*(C'\fR is safest of all since that picks the qemu binary at the same time as the handle is created. .ie n .IP "$g\->set_identifier ($identifier);" 4 .el .IP "\f(CW$g\fR\->set_identifier ($identifier);" 4 .IX Item "$g->set_identifier ($identifier);" This is an informative string which the caller may optionally set in the handle. It is printed in various places, allowing the current handle to be identified in debugging output. .Sp One important place is when tracing is enabled. If the identifier string is not an empty string, then trace messages change from this: .Sp .Vb 2 \& libguestfs: trace: get_tmpdir \& libguestfs: trace: get_tmpdir = "/tmp" .Ve .Sp to this: .Sp .Vb 2 \& libguestfs: trace: ID: get_tmpdir \& libguestfs: trace: ID: get_tmpdir = "/tmp" .Ve .Sp where \f(CW\*(C`ID\*(C'\fR is the identifier string set by this call. .Sp The identifier must only contain alphanumeric ASCII characters, underscore and minus sign. The default is the empty string. .Sp See also \f(CW\*(C`$g\->set_program\*(C'\fR, \f(CW\*(C`$g\->set_trace\*(C'\fR, \&\f(CW\*(C`$g\->get_identifier\*(C'\fR. .ie n .IP "$g\->set_label ($mountable, $label);" 4 .el .IP "\f(CW$g\fR\->set_label ($mountable, \f(CW$label\fR);" 4 .IX Item "$g->set_label ($mountable, $label);" Set the filesystem label on \f(CW\*(C`mountable\*(C'\fR to \f(CW\*(C`label\*(C'\fR. .Sp Only some filesystem types support labels, and libguestfs supports setting labels on only a subset of these. .RS 4 .IP "ext2, ext3, ext4" 4 .IX Item "ext2, ext3, ext4" Labels are limited to 16 bytes. .IP NTFS 4 .IX Item "NTFS" Labels are limited to 128 unicode characters. .IP XFS 4 .IX Item "XFS" The label is limited to 12 bytes. The filesystem must not be mounted when trying to set the label. .IP btrfs 4 .IX Item "btrfs" The label is limited to 255 bytes and some characters are not allowed. Setting the label on a btrfs subvolume will set the label on its parent filesystem. The filesystem must not be mounted when trying to set the label. .IP fat 4 .IX Item "fat" The label is limited to 11 bytes. .IP swap 4 .IX Item "swap" The label is limited to 16 bytes. .RE .RS 4 .Sp If there is no support for changing the label for the type of the specified filesystem, set_label will fail and set errno as ENOTSUP. .Sp To read the label on a filesystem, call \f(CW\*(C`$g\->vfs_label\*(C'\fR. .RE .ie n .IP "$g\->set_libvirt_requested_credential ($index, $cred);" 4 .el .IP "\f(CW$g\fR\->set_libvirt_requested_credential ($index, \f(CW$cred\fR);" 4 .IX Item "$g->set_libvirt_requested_credential ($index, $cred);" After requesting the \f(CW\*(C`index\*(C'\fR'th credential from the user, call this function to pass the answer back to libvirt. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .ie n .IP "$g\->set_libvirt_supported_credentials (\e@creds);" 4 .el .IP "\f(CW$g\fR\->set_libvirt_supported_credentials (\e@creds);" 4 .IX Item "$g->set_libvirt_supported_credentials (@creds);" Call this function before setting an event handler for \&\f(CW\*(C`GUESTFS_EVENT_LIBVIRT_AUTH\*(C'\fR, to supply the list of credential types that the program knows how to process. .Sp The \f(CW\*(C`creds\*(C'\fR list must be a non-empty list of strings. Possible strings are: .RS 4 .ie n .IP """username""" 4 .el .IP \f(CWusername\fR 4 .IX Item "username" .PD 0 .ie n .IP """authname""" 4 .el .IP \f(CWauthname\fR 4 .IX Item "authname" .ie n .IP """language""" 4 .el .IP \f(CWlanguage\fR 4 .IX Item "language" .ie n .IP """cnonce""" 4 .el .IP \f(CWcnonce\fR 4 .IX Item "cnonce" .ie n .IP """passphrase""" 4 .el .IP \f(CWpassphrase\fR 4 .IX Item "passphrase" .ie n .IP """echoprompt""" 4 .el .IP \f(CWechoprompt\fR 4 .IX Item "echoprompt" .ie n .IP """noechoprompt""" 4 .el .IP \f(CWnoechoprompt\fR 4 .IX Item "noechoprompt" .ie n .IP """realm""" 4 .el .IP \f(CWrealm\fR 4 .IX Item "realm" .ie n .IP """external""" 4 .el .IP \f(CWexternal\fR 4 .IX Item "external" .RE .RS 4 .PD .Sp See libvirt documentation for the meaning of these credential types. .Sp See "LIBVIRT AUTHENTICATION" in \fBguestfs\fR\|(3) for documentation and example code. .RE .ie n .IP "$g\->set_memsize ($memsize);" 4 .el .IP "\f(CW$g\fR\->set_memsize ($memsize);" 4 .IX Item "$g->set_memsize ($memsize);" This sets the memory size in megabytes allocated to the hypervisor. This only has any effect if called before \&\f(CW\*(C`$g\->launch\*(C'\fR. .Sp You can also change this by setting the environment variable \f(CW\*(C`LIBGUESTFS_MEMSIZE\*(C'\fR before the handle is created. .Sp For more information on the architecture of libguestfs, see \fBguestfs\fR\|(3). .ie n .IP "$g\->set_network ($network);" 4 .el .IP "\f(CW$g\fR\->set_network ($network);" 4 .IX Item "$g->set_network ($network);" If \f(CW\*(C`network\*(C'\fR is true, then the network is enabled in the libguestfs appliance. The default is false. .Sp This affects whether commands are able to access the network (see "RUNNING COMMANDS" in \fBguestfs\fR\|(3)). .Sp You must call this before calling \f(CW\*(C`$g\->launch\*(C'\fR, otherwise it has no effect. .ie n .IP "$g\->set_path ($searchpath);" 4 .el .IP "\f(CW$g\fR\->set_path ($searchpath);" 4 .IX Item "$g->set_path ($searchpath);" Set the path that libguestfs searches for kernel and initrd.img. .Sp The default is \f(CW\*(C`$libdir/guestfs\*(C'\fR unless overridden by setting \&\f(CW\*(C`LIBGUESTFS_PATH\*(C'\fR environment variable. .Sp Setting \f(CW\*(C`path\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR restores the default path. .ie n .IP "$g\->set_pgroup ($pgroup);" 4 .el .IP "\f(CW$g\fR\->set_pgroup ($pgroup);" 4 .IX Item "$g->set_pgroup ($pgroup);" If \f(CW\*(C`pgroup\*(C'\fR is true, child processes are placed into their own process group. .Sp The practical upshot of this is that signals like \f(CW\*(C`SIGINT\*(C'\fR (from users pressing \f(CW\*(C`^C\*(C'\fR) won't be received by the child process. .Sp The default for this flag is false, because usually you want \&\f(CW\*(C`^C\*(C'\fR to kill the subprocess. Guestfish sets this flag to true when used interactively, so that \f(CW\*(C`^C\*(C'\fR can cancel long-running commands gracefully (see \f(CW\*(C`$g\->user_cancel\*(C'\fR). .ie n .IP "$g\->set_program ($program);" 4 .el .IP "\f(CW$g\fR\->set_program ($program);" 4 .IX Item "$g->set_program ($program);" Set the program name. This is an informative string which the main program may optionally set in the handle. .Sp When the handle is created, the program name in the handle is set to the basename from \f(CW\*(C`argv[0]\*(C'\fR. The program name can never be \f(CW\*(C`NULL\*(C'\fR. .ie n .IP "$g\->set_qemu ($hv);" 4 .el .IP "\f(CW$g\fR\->set_qemu ($hv);" 4 .IX Item "$g->set_qemu ($hv);" Set the hypervisor binary (usually qemu) that we will use. .Sp The default is chosen when the library was compiled by the configure script. .Sp You can also override this by setting the \f(CW\*(C`LIBGUESTFS_HV\*(C'\fR environment variable. .Sp Setting \f(CW\*(C`hv\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR restores the default qemu binary. .Sp Note that you should call this function as early as possible after creating the handle. This is because some pre-launch operations depend on testing qemu features (by running \f(CW\*(C`qemu \-help\*(C'\fR). If the qemu binary changes, we don't retest features, and so you might see inconsistent results. Using the environment variable \f(CW\*(C`LIBGUESTFS_HV\*(C'\fR is safest of all since that picks the qemu binary at the same time as the handle is created. .Sp \&\fIThis function is deprecated.\fR In new code, use the "set_hv" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_recovery_proc ($recoveryproc);" 4 .el .IP "\f(CW$g\fR\->set_recovery_proc ($recoveryproc);" 4 .IX Item "$g->set_recovery_proc ($recoveryproc);" If this is called with the parameter \f(CW\*(C`false\*(C'\fR then \&\f(CW\*(C`$g\->launch\*(C'\fR does not create a recovery process. The purpose of the recovery process is to stop runaway hypervisor processes in the case where the main program aborts abruptly. .Sp This only has any effect if called before \f(CW\*(C`$g\->launch\*(C'\fR, and the default is true. .Sp About the only time when you would want to disable this is if the main process will fork itself into the background ("daemonize" itself). In this case the recovery process thinks that the main program has disappeared and so kills the hypervisor, which is not very helpful. .ie n .IP "$g\->set_selinux ($selinux);" 4 .el .IP "\f(CW$g\fR\->set_selinux ($selinux);" 4 .IX Item "$g->set_selinux ($selinux);" This sets the selinux flag that is passed to the appliance at boot time. The default is \f(CW\*(C`selinux=0\*(C'\fR (disabled). .Sp Note that if SELinux is enabled, it is always in Permissive mode (\f(CW\*(C`enforcing=0\*(C'\fR). .Sp For more information on the architecture of libguestfs, see \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "selinux_relabel" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->set_smp ($smp);" 4 .el .IP "\f(CW$g\fR\->set_smp ($smp);" 4 .IX Item "$g->set_smp ($smp);" Change the number of virtual CPUs assigned to the appliance. The default is \f(CW1\fR. Increasing this may improve performance, though often it has no effect. .Sp This function must be called before \f(CW\*(C`$g\->launch\*(C'\fR. .ie n .IP "$g\->set_tmpdir ($tmpdir);" 4 .el .IP "\f(CW$g\fR\->set_tmpdir ($tmpdir);" 4 .IX Item "$g->set_tmpdir ($tmpdir);" Set the directory used by the handle to store temporary files. .Sp The environment variables \f(CW\*(C`LIBGUESTFS_TMPDIR\*(C'\fR and \f(CW\*(C`TMPDIR\*(C'\fR control the default value: If \f(CW\*(C`LIBGUESTFS_TMPDIR\*(C'\fR is set, then that is the default. Else if \f(CW\*(C`TMPDIR\*(C'\fR is set, then that is the default. Else \fI/tmp\fR is the default. .ie n .IP "$g\->set_trace ($trace);" 4 .el .IP "\f(CW$g\fR\->set_trace ($trace);" 4 .IX Item "$g->set_trace ($trace);" If the command trace flag is set to 1, then libguestfs calls, parameters and return values are traced. .Sp If you want to trace C API calls into libguestfs (and other libraries) then possibly a better way is to use the external \fBltrace\fR\|(1) command. .Sp Command traces are disabled unless the environment variable \&\f(CW\*(C`LIBGUESTFS_TRACE\*(C'\fR is defined and set to \f(CW1\fR. .Sp Trace messages are normally sent to \f(CW\*(C`stderr\*(C'\fR, unless you register a callback to send them somewhere else (see \&\f(CW\*(C`$g\->set_event_callback\*(C'\fR). .ie n .IP "$g\->set_uuid ($device, $uuid);" 4 .el .IP "\f(CW$g\fR\->set_uuid ($device, \f(CW$uuid\fR);" 4 .IX Item "$g->set_uuid ($device, $uuid);" Set the filesystem UUID on \f(CW\*(C`device\*(C'\fR to \f(CW\*(C`uuid\*(C'\fR. If this fails and the errno is ENOTSUP, means that there is no support for changing the UUID for the type of the specified filesystem. .Sp Only some filesystem types support setting UUIDs. .Sp To read the UUID on a filesystem, call \f(CW\*(C`$g\->vfs_uuid\*(C'\fR. .ie n .IP "$g\->set_uuid_random ($device);" 4 .el .IP "\f(CW$g\fR\->set_uuid_random ($device);" 4 .IX Item "$g->set_uuid_random ($device);" Set the filesystem UUID on \f(CW\*(C`device\*(C'\fR to a random UUID. If this fails and the errno is ENOTSUP, means that there is no support for changing the UUID for the type of the specified filesystem. .Sp Only some filesystem types support setting UUIDs. .Sp To read the UUID on a filesystem, call \f(CW\*(C`$g\->vfs_uuid\*(C'\fR. .ie n .IP "$g\->set_verbose ($verbose);" 4 .el .IP "\f(CW$g\fR\->set_verbose ($verbose);" 4 .IX Item "$g->set_verbose ($verbose);" If \f(CW\*(C`verbose\*(C'\fR is true, this turns on verbose messages. .Sp Verbose messages are disabled unless the environment variable \&\f(CW\*(C`LIBGUESTFS_DEBUG\*(C'\fR is defined and set to \f(CW1\fR. .Sp Verbose messages are normally sent to \f(CW\*(C`stderr\*(C'\fR, unless you register a callback to send them somewhere else (see \&\f(CW\*(C`$g\->set_event_callback\*(C'\fR). .ie n .IP "$g\->setcon ($context);" 4 .el .IP "\f(CW$g\fR\->setcon ($context);" 4 .IX Item "$g->setcon ($context);" This sets the SELinux security context of the daemon to the string \f(CW\*(C`context\*(C'\fR. .Sp See the documentation about SELINUX in \fBguestfs\fR\|(3). .Sp This function depends on the feature \f(CW\*(C`selinux\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "selinux_relabel" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->setxattr ($xattr, $val, $vallen, $path);" 4 .el .IP "\f(CW$g\fR\->setxattr ($xattr, \f(CW$val\fR, \f(CW$vallen\fR, \f(CW$path\fR);" 4 .IX Item "$g->setxattr ($xattr, $val, $vallen, $path);" This call sets the extended attribute named \f(CW\*(C`xattr\*(C'\fR of the file \f(CW\*(C`path\*(C'\fR to the value \f(CW\*(C`val\*(C'\fR (of length \f(CW\*(C`vallen\*(C'\fR). The value is arbitrary 8 bit data. .Sp See also: \f(CW\*(C`$g\->lsetxattr\*(C'\fR, \fBattr\fR\|(5). .Sp This function depends on the feature \f(CW\*(C`linuxxattrs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->sfdisk ($device, $cyls, $heads, $sectors, \e@lines);" 4 .el .IP "\f(CW$g\fR\->sfdisk ($device, \f(CW$cyls\fR, \f(CW$heads\fR, \f(CW$sectors\fR, \e@lines);" 4 .IX Item "$g->sfdisk ($device, $cyls, $heads, $sectors, @lines);" This is a direct interface to the \fBsfdisk\fR\|(8) program for creating partitions on block devices. .Sp \&\f(CW\*(C`device\*(C'\fR should be a block device, for example \fI/dev/sda\fR. .Sp \&\f(CW\*(C`cyls\*(C'\fR, \f(CW\*(C`heads\*(C'\fR and \f(CW\*(C`sectors\*(C'\fR are the number of cylinders, heads and sectors on the device, which are passed directly to \fBsfdisk\fR\|(8) as the \fI\-C\fR, \fI\-H\fR and \fI\-S\fR parameters. If you pass \f(CW0\fR for any of these, then the corresponding parameter is omitted. Usually for ‘large’ disks, you can just pass \f(CW0\fR for these, but for small (floppy-sized) disks, \fBsfdisk\fR\|(8) (or rather, the kernel) cannot work out the right geometry and you will need to tell it. .Sp \&\f(CW\*(C`lines\*(C'\fR is a list of lines that we feed to \fBsfdisk\fR\|(8). For more information refer to the \fBsfdisk\fR\|(8) manpage. .Sp To create a single partition occupying the whole disk, you would pass \f(CW\*(C`lines\*(C'\fR as a single element list, when the single element being the string \f(CW\*(C`,\*(C'\fR (comma). .Sp See also: \f(CW\*(C`$g\->sfdisk_l\*(C'\fR, \f(CW\*(C`$g\->sfdisk_N\*(C'\fR, \&\f(CW\*(C`$g\->part_init\*(C'\fR .Sp \&\fIThis function is deprecated.\fR In new code, use the "part_add" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->sfdiskM ($device, \e@lines);" 4 .el .IP "\f(CW$g\fR\->sfdiskM ($device, \e@lines);" 4 .IX Item "$g->sfdiskM ($device, @lines);" This is a simplified interface to the \f(CW\*(C`$g\->sfdisk\*(C'\fR command, where partition sizes are specified in megabytes only (rounded to the nearest cylinder) and you don't need to specify the cyls, heads and sectors parameters which were rarely if ever used anyway. .Sp See also: \f(CW\*(C`$g\->sfdisk\*(C'\fR, the \fBsfdisk\fR\|(8) manpage and \f(CW\*(C`$g\->part_disk\*(C'\fR .Sp \&\fIThis function is deprecated.\fR In new code, use the "part_add" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->sfdisk_N ($device, $partnum, $cyls, $heads, $sectors, $line);" 4 .el .IP "\f(CW$g\fR\->sfdisk_N ($device, \f(CW$partnum\fR, \f(CW$cyls\fR, \f(CW$heads\fR, \f(CW$sectors\fR, \f(CW$line\fR);" 4 .IX Item "$g->sfdisk_N ($device, $partnum, $cyls, $heads, $sectors, $line);" This runs \fBsfdisk\fR\|(8) option to modify just the single partition \f(CW\*(C`n\*(C'\fR (note: \f(CW\*(C`n\*(C'\fR counts from 1). .Sp For other parameters, see \f(CW\*(C`$g\->sfdisk\*(C'\fR. You should usually pass \f(CW0\fR for the cyls/heads/sectors parameters. .Sp See also: \f(CW\*(C`$g\->part_add\*(C'\fR .Sp \&\fIThis function is deprecated.\fR In new code, use the "part_add" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$partitions = $g\->sfdisk_disk_geometry ($device);" 4 .el .IP "\f(CW$partitions\fR = \f(CW$g\fR\->sfdisk_disk_geometry ($device);" 4 .IX Item "$partitions = $g->sfdisk_disk_geometry ($device);" This displays the disk geometry of \f(CW\*(C`device\*(C'\fR read from the partition table. Especially in the case where the underlying block device has been resized, this can be different from the kernel’s idea of the geometry (see \f(CW\*(C`$g\->sfdisk_kernel_geometry\*(C'\fR). .Sp The result is in human-readable format, and not designed to be parsed. .ie n .IP "$partitions = $g\->sfdisk_kernel_geometry ($device);" 4 .el .IP "\f(CW$partitions\fR = \f(CW$g\fR\->sfdisk_kernel_geometry ($device);" 4 .IX Item "$partitions = $g->sfdisk_kernel_geometry ($device);" This displays the kernel’s idea of the geometry of \f(CW\*(C`device\*(C'\fR. .Sp The result is in human-readable format, and not designed to be parsed. .ie n .IP "$partitions = $g\->sfdisk_l ($device);" 4 .el .IP "\f(CW$partitions\fR = \f(CW$g\fR\->sfdisk_l ($device);" 4 .IX Item "$partitions = $g->sfdisk_l ($device);" This displays the partition table on \f(CW\*(C`device\*(C'\fR, in the human-readable output of the \fBsfdisk\fR\|(8) command. It is not intended to be parsed. .Sp See also: \f(CW\*(C`$g\->part_list\*(C'\fR .Sp \&\fIThis function is deprecated.\fR In new code, use the "part_list" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$output = $g\->sh ($command);" 4 .el .IP "\f(CW$output\fR = \f(CW$g\fR\->sh ($command);" 4 .IX Item "$output = $g->sh ($command);" This call runs a command from the guest filesystem via the guest’s \fI/bin/sh\fR. .Sp This is like \f(CW\*(C`$g\->command\*(C'\fR, but passes the command to: .Sp .Vb 1 \& /bin/sh \-c "command" .Ve .Sp Depending on the guest’s shell, this usually results in wildcards being expanded, shell expressions being interpolated and so on. .Sp All the provisos about \f(CW\*(C`$g\->command\*(C'\fR apply to this call. .ie n .IP "@lines = $g\->sh_lines ($command);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->sh_lines ($command);" 4 .IX Item "@lines = $g->sh_lines ($command);" This is the same as \f(CW\*(C`$g\->sh\*(C'\fR, but splits the result into a list of lines. .Sp See also: \f(CW\*(C`$g\->command_lines\*(C'\fR .ie n .IP "$g\->shutdown ();" 4 .el .IP "\f(CW$g\fR\->shutdown ();" 4 .IX Item "$g->shutdown ();" This is the opposite of \f(CW\*(C`$g\->launch\*(C'\fR. It performs an orderly shutdown of the backend process(es). If the autosync flag is set (which is the default) then the disk image is synchronized. .Sp If the subprocess exits with an error then this function will return an error, which should \fInot\fR be ignored (it may indicate that the disk image could not be written out properly). .Sp It is safe to call this multiple times. Extra calls are ignored. .Sp This call does \fInot\fR close or free up the handle. You still need to call \f(CW\*(C`$g\->close\*(C'\fR afterwards. .Sp \&\f(CW\*(C`$g\->close\*(C'\fR will call this if you don't do it explicitly, but note that any errors are ignored in that case. .ie n .IP "$g\->sleep ($secs);" 4 .el .IP "\f(CW$g\fR\->sleep ($secs);" 4 .IX Item "$g->sleep ($secs);" Sleep for \f(CW\*(C`secs\*(C'\fR seconds. .ie n .IP "%statbuf = $g\->stat ($path);" 4 .el .IP "\f(CW%statbuf\fR = \f(CW$g\fR\->stat ($path);" 4 .IX Item "%statbuf = $g->stat ($path);" Returns file information for the given \f(CW\*(C`path\*(C'\fR. .Sp This is the same as the \fBstat\fR\|(2) system call. .Sp \&\fIThis function is deprecated.\fR In new code, use the "statns" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "%statbuf = $g\->statns ($path);" 4 .el .IP "\f(CW%statbuf\fR = \f(CW$g\fR\->statns ($path);" 4 .IX Item "%statbuf = $g->statns ($path);" Returns file information for the given \f(CW\*(C`path\*(C'\fR. .Sp This is the same as the \fBstat\fR\|(2) system call. .ie n .IP "%statbuf = $g\->statvfs ($path);" 4 .el .IP "\f(CW%statbuf\fR = \f(CW$g\fR\->statvfs ($path);" 4 .IX Item "%statbuf = $g->statvfs ($path);" Returns file system statistics for any mounted file system. \&\f(CW\*(C`path\*(C'\fR should be a file or directory in the mounted file system (typically it is the mount point itself, but it doesn't need to be). .Sp This is the same as the \fBstatvfs\fR\|(2) system call. .ie n .IP "@stringsout = $g\->strings ($path);" 4 .el .IP "\f(CW@stringsout\fR = \f(CW$g\fR\->strings ($path);" 4 .IX Item "@stringsout = $g->strings ($path);" This runs the \fBstrings\fR\|(1) command on a file and returns the list of printable strings found. .Sp The \f(CW\*(C`strings\*(C'\fR command has, in the past, had problems with parsing untrusted files. These are mitigated in the current version of libguestfs, but see "CVE\-2014\-8484" in \fBguestfs\fR\|(3). .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "@stringsout = $g\->strings_e ($encoding, $path);" 4 .el .IP "\f(CW@stringsout\fR = \f(CW$g\fR\->strings_e ($encoding, \f(CW$path\fR);" 4 .IX Item "@stringsout = $g->strings_e ($encoding, $path);" This is like the \f(CW\*(C`$g\->strings\*(C'\fR command, but allows you to specify the encoding of strings that are looked for in the source file \f(CW\*(C`path\*(C'\fR. .Sp Allowed encodings are: .RS 4 .IP s 4 .IX Item "s" Single 7\-bit\-byte characters like ASCII and the ASCII-compatible parts of ISO\-8859\-X (this is what \f(CW\*(C`$g\->strings\*(C'\fR uses). .IP S 4 .IX Item "S" Single 8\-bit\-byte characters. .IP b 4 .IX Item "b" 16\-bit big endian strings such as those encoded in UTF\-16BE or UCS\-2BE. .IP "l (lower case letter L)" 4 .IX Item "l (lower case letter L)" 16\-bit little endian such as UTF\-16LE and UCS\-2LE. This is useful for examining binaries in Windows guests. .IP B 4 .IX Item "B" 32\-bit big endian such as UCS\-4BE. .IP L 4 .IX Item "L" 32\-bit little endian such as UCS\-4LE. .RE .RS 4 .Sp The returned strings are transcoded to UTF\-8. .Sp The \f(CW\*(C`strings\*(C'\fR command has, in the past, had problems with parsing untrusted files. These are mitigated in the current version of libguestfs, but see "CVE\-2014\-8484" in \fBguestfs\fR\|(3). .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .RE .ie n .IP "$g\->swapoff_device ($device);" 4 .el .IP "\f(CW$g\fR\->swapoff_device ($device);" 4 .IX Item "$g->swapoff_device ($device);" This command disables the libguestfs appliance swap device or partition named \f(CW\*(C`device\*(C'\fR. See \f(CW\*(C`$g\->swapon_device\*(C'\fR. .ie n .IP "$g\->swapoff_file ($file);" 4 .el .IP "\f(CW$g\fR\->swapoff_file ($file);" 4 .IX Item "$g->swapoff_file ($file);" This command disables the libguestfs appliance swap on file. .ie n .IP "$g\->swapoff_label ($label);" 4 .el .IP "\f(CW$g\fR\->swapoff_label ($label);" 4 .IX Item "$g->swapoff_label ($label);" This command disables the libguestfs appliance swap on labeled swap partition. .ie n .IP "$g\->swapoff_uuid ($uuid);" 4 .el .IP "\f(CW$g\fR\->swapoff_uuid ($uuid);" 4 .IX Item "$g->swapoff_uuid ($uuid);" This command disables the libguestfs appliance swap partition with the given UUID. .Sp This function depends on the feature \f(CW\*(C`linuxfsuuid\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->swapon_device ($device);" 4 .el .IP "\f(CW$g\fR\->swapon_device ($device);" 4 .IX Item "$g->swapon_device ($device);" This command enables the libguestfs appliance to use the swap device or partition named \f(CW\*(C`device\*(C'\fR. The increased memory is made available for all commands, for example those run using \f(CW\*(C`$g\->command\*(C'\fR or \f(CW\*(C`$g\->sh\*(C'\fR. .Sp Note that you should not swap to existing guest swap partitions unless you know what you are doing. They may contain hibernation information, or other information that the guest doesn't want you to trash. You also risk leaking information about the host to the guest this way. Instead, attach a new host device to the guest and swap on that. .ie n .IP "$g\->swapon_file ($file);" 4 .el .IP "\f(CW$g\fR\->swapon_file ($file);" 4 .IX Item "$g->swapon_file ($file);" This command enables swap to a file. See \f(CW\*(C`$g\->swapon_device\*(C'\fR for other notes. .ie n .IP "$g\->swapon_label ($label);" 4 .el .IP "\f(CW$g\fR\->swapon_label ($label);" 4 .IX Item "$g->swapon_label ($label);" This command enables swap to a labeled swap partition. See \f(CW\*(C`$g\->swapon_device\*(C'\fR for other notes. .ie n .IP "$g\->swapon_uuid ($uuid);" 4 .el .IP "\f(CW$g\fR\->swapon_uuid ($uuid);" 4 .IX Item "$g->swapon_uuid ($uuid);" This command enables swap to a swap partition with the given UUID. See \f(CW\*(C`$g\->swapon_device\*(C'\fR for other notes. .Sp This function depends on the feature \f(CW\*(C`linuxfsuuid\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->sync ();" 4 .el .IP "\f(CW$g\fR\->sync ();" 4 .IX Item "$g->sync ();" This syncs the disk, so that any writes are flushed through to the underlying disk image. .Sp You should always call this if you have modified a disk image, before closing the handle. .ie n .IP "$g\->syslinux ($device [, directory => $directory]);" 4 .el .IP "\f(CW$g\fR\->syslinux ($device [, directory => \f(CW$directory\fR]);" 4 .IX Item "$g->syslinux ($device [, directory => $directory]);" Install the SYSLINUX bootloader on \f(CW\*(C`device\*(C'\fR. .Sp The device parameter must be either a whole disk formatted as a FAT filesystem, or a partition formatted as a FAT filesystem. In the latter case, the partition should be marked as "active" (\f(CW\*(C`$g\->part_set_bootable\*(C'\fR) and a Master Boot Record must be installed (eg. using \f(CW\*(C`$g\->pwrite_device\*(C'\fR) on the first sector of the whole disk. The SYSLINUX package comes with some suitable Master Boot Records. See the \fBsyslinux\fR\|(1) man page for further information. .Sp The optional arguments are: .RS 4 .IP \fIdirectory\fR 4 .IX Item "directory" Install SYSLINUX in the named subdirectory, instead of in the root directory of the FAT filesystem. .RE .RS 4 .Sp Additional configuration can be supplied to SYSLINUX by placing a file called \fIsyslinux.cfg\fR on the FAT filesystem, either in the root directory, or under \fIdirectory\fR if that optional argument is being used. For further information about the contents of this file, see \fBsyslinux\fR\|(1). .Sp See also \f(CW\*(C`$g\->extlinux\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`syslinux\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "@lines = $g\->tail ($path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->tail ($path);" 4 .IX Item "@lines = $g->tail ($path);" This command returns up to the last 10 lines of a file as a list of strings. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "@lines = $g\->tail_n ($nrlines, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->tail_n ($nrlines, \f(CW$path\fR);" 4 .IX Item "@lines = $g->tail_n ($nrlines, $path);" If the parameter \f(CW\*(C`nrlines\*(C'\fR is a positive number, this returns the last \&\f(CW\*(C`nrlines\*(C'\fR lines of the file \f(CW\*(C`path\*(C'\fR. .Sp If the parameter \f(CW\*(C`nrlines\*(C'\fR is a negative number, this returns lines from the file \f(CW\*(C`path\*(C'\fR, starting with the \f(CW\*(C`\-nrlines\*(C'\fR'th line. .Sp If the parameter \f(CW\*(C`nrlines\*(C'\fR is zero, this returns an empty list. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .ie n .IP "$g\->tar_in ($tarfile, $directory [, compress => $compress] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" 4 .el .IP "\f(CW$g\fR\->tar_in ($tarfile, \f(CW$directory\fR [, compress => \f(CW$compress\fR] [, xattrs => \f(CW$xattrs\fR] [, selinux => \f(CW$selinux\fR] [, acls => \f(CW$acls\fR]);" 4 .IX Item "$g->tar_in ($tarfile, $directory [, compress => $compress] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" This command uploads and unpacks local file \f(CW\*(C`tarfile\*(C'\fR into \fIdirectory\fR. .Sp The optional \f(CW\*(C`compress\*(C'\fR flag controls compression. If not given, then the input should be an uncompressed tar file. Otherwise one of the following strings may be given to select the compression type of the input file: \f(CW\*(C`compress\*(C'\fR, \f(CW\*(C`gzip\*(C'\fR, \f(CW\*(C`bzip2\*(C'\fR, \f(CW\*(C`xz\*(C'\fR, \f(CW\*(C`lzop\*(C'\fR, \&\f(CW\*(C`lzma\*(C'\fR, \f(CW\*(C`zstd\*(C'\fR. (Note that not all builds of libguestfs will support all of these compression types). .Sp The other optional arguments are: .RS 4 .ie n .IP """xattrs""" 4 .el .IP \f(CWxattrs\fR 4 .IX Item "xattrs" If set to true, extended attributes are restored from the tar file. .ie n .IP """selinux""" 4 .el .IP \f(CWselinux\fR 4 .IX Item "selinux" If set to true, SELinux contexts are restored from the tar file. .ie n .IP """acls""" 4 .el .IP \f(CWacls\fR 4 .IX Item "acls" If set to true, POSIX ACLs are restored from the tar file. .RE .RS 4 .RE .ie n .IP "$g\->tar_in_opts ($tarfile, $directory [, compress => $compress] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" 4 .el .IP "\f(CW$g\fR\->tar_in_opts ($tarfile, \f(CW$directory\fR [, compress => \f(CW$compress\fR] [, xattrs => \f(CW$xattrs\fR] [, selinux => \f(CW$selinux\fR] [, acls => \f(CW$acls\fR]);" 4 .IX Item "$g->tar_in_opts ($tarfile, $directory [, compress => $compress] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" This is an alias of "tar_in". .ie n .IP "$g\->tar_out ($directory, $tarfile [, compress => $compress] [, numericowner => $numericowner] [, excludes => $excludes] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" 4 .el .IP "\f(CW$g\fR\->tar_out ($directory, \f(CW$tarfile\fR [, compress => \f(CW$compress\fR] [, numericowner => \f(CW$numericowner\fR] [, excludes => \f(CW$excludes\fR] [, xattrs => \f(CW$xattrs\fR] [, selinux => \f(CW$selinux\fR] [, acls => \f(CW$acls\fR]);" 4 .IX Item "$g->tar_out ($directory, $tarfile [, compress => $compress] [, numericowner => $numericowner] [, excludes => $excludes] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" This command packs the contents of \fIdirectory\fR and downloads it to local file \f(CW\*(C`tarfile\*(C'\fR. .Sp The optional \f(CW\*(C`compress\*(C'\fR flag controls compression. If not given, then the output will be an uncompressed tar file. Otherwise one of the following strings may be given to select the compression type of the output file: \f(CW\*(C`compress\*(C'\fR, \f(CW\*(C`gzip\*(C'\fR, \f(CW\*(C`bzip2\*(C'\fR, \f(CW\*(C`xz\*(C'\fR, \f(CW\*(C`lzop\*(C'\fR, \&\f(CW\*(C`lzma\*(C'\fR, \f(CW\*(C`zstd\*(C'\fR. (Note that not all builds of libguestfs will support all of these compression types). .Sp The other optional arguments are: .RS 4 .ie n .IP """excludes""" 4 .el .IP \f(CWexcludes\fR 4 .IX Item "excludes" A list of wildcards. Files are excluded if they match any of the wildcards. .ie n .IP """numericowner""" 4 .el .IP \f(CWnumericowner\fR 4 .IX Item "numericowner" If set to true, the output tar file will contain UID/GID numbers instead of user/group names. .ie n .IP """xattrs""" 4 .el .IP \f(CWxattrs\fR 4 .IX Item "xattrs" If set to true, extended attributes are saved in the output tar. .ie n .IP """selinux""" 4 .el .IP \f(CWselinux\fR 4 .IX Item "selinux" If set to true, SELinux contexts are saved in the output tar. .ie n .IP """acls""" 4 .el .IP \f(CWacls\fR 4 .IX Item "acls" If set to true, POSIX ACLs are saved in the output tar. .RE .RS 4 .RE .ie n .IP "$g\->tar_out_opts ($directory, $tarfile [, compress => $compress] [, numericowner => $numericowner] [, excludes => $excludes] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" 4 .el .IP "\f(CW$g\fR\->tar_out_opts ($directory, \f(CW$tarfile\fR [, compress => \f(CW$compress\fR] [, numericowner => \f(CW$numericowner\fR] [, excludes => \f(CW$excludes\fR] [, xattrs => \f(CW$xattrs\fR] [, selinux => \f(CW$selinux\fR] [, acls => \f(CW$acls\fR]);" 4 .IX Item "$g->tar_out_opts ($directory, $tarfile [, compress => $compress] [, numericowner => $numericowner] [, excludes => $excludes] [, xattrs => $xattrs] [, selinux => $selinux] [, acls => $acls]);" This is an alias of "tar_out". .ie n .IP "$g\->tgz_in ($tarball, $directory);" 4 .el .IP "\f(CW$g\fR\->tgz_in ($tarball, \f(CW$directory\fR);" 4 .IX Item "$g->tgz_in ($tarball, $directory);" This command uploads and unpacks local file \f(CW\*(C`tarball\*(C'\fR (a \&\fIgzip compressed\fR tar file) into \fIdirectory\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "tar_in" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->tgz_out ($directory, $tarball);" 4 .el .IP "\f(CW$g\fR\->tgz_out ($directory, \f(CW$tarball\fR);" 4 .IX Item "$g->tgz_out ($directory, $tarball);" This command packs the contents of \fIdirectory\fR and downloads it to local file \f(CW\*(C`tarball\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "tar_out" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->touch ($path);" 4 .el .IP "\f(CW$g\fR\->touch ($path);" 4 .IX Item "$g->touch ($path);" Touch acts like the \fBtouch\fR\|(1) command. It can be used to update the timestamps on a file, or, if the file does not exist, to create a new zero-length file. .Sp This command only works on regular files, and will fail on other file types such as directories, symbolic links, block special etc. .ie n .IP "$g\->truncate ($path);" 4 .el .IP "\f(CW$g\fR\->truncate ($path);" 4 .IX Item "$g->truncate ($path);" This command truncates \f(CW\*(C`path\*(C'\fR to a zero-length file. The file must exist already. .ie n .IP "$g\->truncate_size ($path, $size);" 4 .el .IP "\f(CW$g\fR\->truncate_size ($path, \f(CW$size\fR);" 4 .IX Item "$g->truncate_size ($path, $size);" This command truncates \f(CW\*(C`path\*(C'\fR to size \f(CW\*(C`size\*(C'\fR bytes. The file must exist already. .Sp If the current file size is less than \f(CW\*(C`size\*(C'\fR then the file is extended to the required size with zero bytes. This creates a sparse file (ie. disk blocks are not allocated for the file until you write to it). To create a non-sparse file of zeroes, use \f(CW\*(C`$g\->fallocate64\*(C'\fR instead. .ie n .IP "$g\->tune2fs ($device [, force => $force] [, maxmountcount => $maxmountcount] [, mountcount => $mountcount] [, errorbehavior => $errorbehavior] [, group => $group] [, intervalbetweenchecks => $intervalbetweenchecks] [, reservedblockspercentage => $reservedblockspercentage] [, lastmounteddirectory => $lastmounteddirectory] [, reservedblockscount => $reservedblockscount] [, user => $user]);" 4 .el .IP "\f(CW$g\fR\->tune2fs ($device [, force => \f(CW$force\fR] [, maxmountcount => \f(CW$maxmountcount\fR] [, mountcount => \f(CW$mountcount\fR] [, errorbehavior => \f(CW$errorbehavior\fR] [, group => \f(CW$group\fR] [, intervalbetweenchecks => \f(CW$intervalbetweenchecks\fR] [, reservedblockspercentage => \f(CW$reservedblockspercentage\fR] [, lastmounteddirectory => \f(CW$lastmounteddirectory\fR] [, reservedblockscount => \f(CW$reservedblockscount\fR] [, user => \f(CW$user\fR]);" 4 .IX Item "$g->tune2fs ($device [, force => $force] [, maxmountcount => $maxmountcount] [, mountcount => $mountcount] [, errorbehavior => $errorbehavior] [, group => $group] [, intervalbetweenchecks => $intervalbetweenchecks] [, reservedblockspercentage => $reservedblockspercentage] [, lastmounteddirectory => $lastmounteddirectory] [, reservedblockscount => $reservedblockscount] [, user => $user]);" This call allows you to adjust various filesystem parameters of an ext2/ext3/ext4 filesystem called \f(CW\*(C`device\*(C'\fR. .Sp The optional parameters are: .RS 4 .ie n .IP """force""" 4 .el .IP \f(CWforce\fR 4 .IX Item "force" Force tune2fs to complete the operation even in the face of errors. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-f\*(C'\fR option. .ie n .IP """maxmountcount""" 4 .el .IP \f(CWmaxmountcount\fR 4 .IX Item "maxmountcount" Set the number of mounts after which the filesystem is checked by \fBe2fsck\fR\|(8). If this is \f(CW0\fR then the number of mounts is disregarded. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-c\*(C'\fR option. .ie n .IP """mountcount""" 4 .el .IP \f(CWmountcount\fR 4 .IX Item "mountcount" Set the number of times the filesystem has been mounted. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-C\*(C'\fR option. .ie n .IP """errorbehavior""" 4 .el .IP \f(CWerrorbehavior\fR 4 .IX Item "errorbehavior" Change the behavior of the kernel code when errors are detected. Possible values currently are: \f(CW\*(C`continue\*(C'\fR, \f(CW\*(C`remount\-ro\*(C'\fR, \f(CW\*(C`panic\*(C'\fR. In practice these options don't really make any difference, particularly for write errors. .Sp This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-e\*(C'\fR option. .ie n .IP """group""" 4 .el .IP \f(CWgroup\fR 4 .IX Item "group" Set the group which can use reserved filesystem blocks. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-g\*(C'\fR option except that it can only be specified as a number. .ie n .IP """intervalbetweenchecks""" 4 .el .IP \f(CWintervalbetweenchecks\fR 4 .IX Item "intervalbetweenchecks" Adjust the maximal time between two filesystem checks (in seconds). If the option is passed as \f(CW0\fR then time-dependent checking is disabled. .Sp This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-i\*(C'\fR option. .ie n .IP """reservedblockspercentage""" 4 .el .IP \f(CWreservedblockspercentage\fR 4 .IX Item "reservedblockspercentage" Set the percentage of the filesystem which may only be allocated by privileged processes. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-m\*(C'\fR option. .ie n .IP """lastmounteddirectory""" 4 .el .IP \f(CWlastmounteddirectory\fR 4 .IX Item "lastmounteddirectory" Set the last mounted directory. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-M\*(C'\fR option. .ie n .IP """reservedblockscount"" Set the number of reserved filesystem blocks. This is the same as the \fBtune2fs\fR\|(8) ""\-r"" option." 4 .el .IP "\f(CWreservedblockscount\fR Set the number of reserved filesystem blocks. This is the same as the \fBtune2fs\fR\|(8) \f(CW\-r\fR option." 4 .IX Item "reservedblockscount Set the number of reserved filesystem blocks. This is the same as the tune2fs -r option." .PD 0 .ie n .IP """user""" 4 .el .IP \f(CWuser\fR 4 .IX Item "user" .PD Set the user who can use the reserved filesystem blocks. This is the same as the \fBtune2fs\fR\|(8) \f(CW\*(C`\-u\*(C'\fR option except that it can only be specified as a number. .RE .RS 4 .Sp To get the current values of filesystem parameters, see \&\f(CW\*(C`$g\->tune2fs_l\*(C'\fR. For precise details of how tune2fs works, see the \fBtune2fs\fR\|(8) man page. .RE .ie n .IP "%superblock = $g\->tune2fs_l ($device);" 4 .el .IP "\f(CW%superblock\fR = \f(CW$g\fR\->tune2fs_l ($device);" 4 .IX Item "%superblock = $g->tune2fs_l ($device);" This returns the contents of the ext2, ext3 or ext4 filesystem superblock on \f(CW\*(C`device\*(C'\fR. .Sp It is the same as running \f(CW\*(C`tune2fs \-l device\*(C'\fR. See \fBtune2fs\fR\|(8) manpage for more details. The list of fields returned isn't clearly defined, and depends on both the version of \f(CW\*(C`tune2fs\*(C'\fR that libguestfs was built against, and the filesystem itself. .ie n .IP "$g\->txz_in ($tarball, $directory);" 4 .el .IP "\f(CW$g\fR\->txz_in ($tarball, \f(CW$directory\fR);" 4 .IX Item "$g->txz_in ($tarball, $directory);" This command uploads and unpacks local file \f(CW\*(C`tarball\*(C'\fR (an \&\fIxz compressed\fR tar file) into \fIdirectory\fR. .Sp This function depends on the feature \f(CW\*(C`xz\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "tar_in" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->txz_out ($directory, $tarball);" 4 .el .IP "\f(CW$g\fR\->txz_out ($directory, \f(CW$tarball\fR);" 4 .IX Item "$g->txz_out ($directory, $tarball);" This command packs the contents of \fIdirectory\fR and downloads it to local file \f(CW\*(C`tarball\*(C'\fR (as an xz compressed tar archive). .Sp This function depends on the feature \f(CW\*(C`xz\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .Sp \&\fIThis function is deprecated.\fR In new code, use the "tar_out" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$oldmask = $g\->umask ($mask);" 4 .el .IP "\f(CW$oldmask\fR = \f(CW$g\fR\->umask ($mask);" 4 .IX Item "$oldmask = $g->umask ($mask);" This function sets the mask used for creating new files and device nodes to \f(CW\*(C`mask & 0777\*(C'\fR. .Sp Typical umask values would be \f(CW022\fR which creates new files with permissions like "\-rw\-r\-\-r\-\-" or "\-rwxr\-xr\-x", and \&\f(CW002\fR which creates new files with permissions like "\-rw\-rw\-r\-\-" or "\-rwxrwxr\-x". .Sp The default umask is \f(CW022\fR. This is important because it means that directories and device nodes will be created with \&\f(CW0644\fR or \f(CW0755\fR mode even if you specify \f(CW0777\fR. .Sp See also \f(CW\*(C`$g\->get_umask\*(C'\fR, \&\fBumask\fR\|(2), \f(CW\*(C`$g\->mknod\*(C'\fR, \f(CW\*(C`$g\->mkdir\*(C'\fR. .Sp This call returns the previous umask. .ie n .IP "$g\->umount ($pathordevice [, force => $force] [, lazyunmount => $lazyunmount]);" 4 .el .IP "\f(CW$g\fR\->umount ($pathordevice [, force => \f(CW$force\fR] [, lazyunmount => \f(CW$lazyunmount\fR]);" 4 .IX Item "$g->umount ($pathordevice [, force => $force] [, lazyunmount => $lazyunmount]);" This unmounts the given filesystem. The filesystem may be specified either by its mountpoint (path) or the device which contains the filesystem. .ie n .IP "$g\->umount_opts ($pathordevice [, force => $force] [, lazyunmount => $lazyunmount]);" 4 .el .IP "\f(CW$g\fR\->umount_opts ($pathordevice [, force => \f(CW$force\fR] [, lazyunmount => \f(CW$lazyunmount\fR]);" 4 .IX Item "$g->umount_opts ($pathordevice [, force => $force] [, lazyunmount => $lazyunmount]);" This is an alias of "umount". .ie n .IP "$g\->umount_all ();" 4 .el .IP "\f(CW$g\fR\->umount_all ();" 4 .IX Item "$g->umount_all ();" This unmounts all mounted filesystems. .Sp Some internal mounts are not unmounted by this call. .ie n .IP "$g\->umount_local ([retry => $retry]);" 4 .el .IP "\f(CW$g\fR\->umount_local ([retry => \f(CW$retry\fR]);" 4 .IX Item "$g->umount_local ([retry => $retry]);" If libguestfs is exporting the filesystem on a local mountpoint, then this unmounts it. .Sp See "MOUNT LOCAL" in \fBguestfs\fR\|(3) for full documentation. .ie n .IP "$g\->upload ($filename, $remotefilename);" 4 .el .IP "\f(CW$g\fR\->upload ($filename, \f(CW$remotefilename\fR);" 4 .IX Item "$g->upload ($filename, $remotefilename);" Upload local file \fIfilename\fR to \fIremotefilename\fR on the filesystem. .Sp \&\fIfilename\fR can also be a named pipe. .Sp See also \f(CW\*(C`$g\->download\*(C'\fR. .ie n .IP "$g\->upload_offset ($filename, $remotefilename, $offset);" 4 .el .IP "\f(CW$g\fR\->upload_offset ($filename, \f(CW$remotefilename\fR, \f(CW$offset\fR);" 4 .IX Item "$g->upload_offset ($filename, $remotefilename, $offset);" Upload local file \fIfilename\fR to \fIremotefilename\fR on the filesystem. .Sp \&\fIremotefilename\fR is overwritten starting at the byte \f(CW\*(C`offset\*(C'\fR specified. The intention is to overwrite parts of existing files or devices, although if a non-existent file is specified then it is created with a "hole" before \f(CW\*(C`offset\*(C'\fR. The size of the data written is implicit in the size of the source \fIfilename\fR. .Sp Note that there is no limit on the amount of data that can be uploaded with this call, unlike with \f(CW\*(C`$g\->pwrite\*(C'\fR, and this call always writes the full amount unless an error occurs. .Sp See also \f(CW\*(C`$g\->upload\*(C'\fR, \f(CW\*(C`$g\->pwrite\*(C'\fR. .ie n .IP "$g\->user_cancel ();" 4 .el .IP "\f(CW$g\fR\->user_cancel ();" 4 .IX Item "$g->user_cancel ();" This function cancels the current upload or download operation. .Sp Unlike most other libguestfs calls, this function is signal safe and thread safe. You can call it from a signal handler or from another thread, without needing to do any locking. .Sp The transfer that was in progress (if there is one) will stop shortly afterwards, and will return an error. The errno (see "guestfs_last_errno") is set to \f(CW\*(C`EINTR\*(C'\fR, so you can test for this to find out if the operation was cancelled or failed because of another error. .Sp No cleanup is performed: for example, if a file was being uploaded then after cancellation there may be a partially uploaded file. It is the caller’s responsibility to clean up if necessary. .Sp There are two common places that you might call \f(CW\*(C`$g\->user_cancel\*(C'\fR: .Sp In an interactive text-based program, you might call it from a \&\f(CW\*(C`SIGINT\*(C'\fR signal handler so that pressing \f(CW\*(C`^C\*(C'\fR cancels the current operation. (You also need to call \f(CW\*(C`$g\->set_pgroup\*(C'\fR so that child processes don't receive the \f(CW\*(C`^C\*(C'\fR signal). .Sp In a graphical program, when the main thread is displaying a progress bar with a cancel button, wire up the cancel button to call this function. .ie n .IP "$g\->utimens ($path, $atsecs, $atnsecs, $mtsecs, $mtnsecs);" 4 .el .IP "\f(CW$g\fR\->utimens ($path, \f(CW$atsecs\fR, \f(CW$atnsecs\fR, \f(CW$mtsecs\fR, \f(CW$mtnsecs\fR);" 4 .IX Item "$g->utimens ($path, $atsecs, $atnsecs, $mtsecs, $mtnsecs);" This command sets the timestamps of a file with nanosecond precision. .Sp \&\f(CW\*(C`atsecs\*(C'\fR, \f(CW\*(C`atnsecs\*(C'\fR are the last access time (atime) in secs and nanoseconds from the epoch. .Sp \&\f(CW\*(C`mtsecs\*(C'\fR, \f(CW\*(C`mtnsecs\*(C'\fR are the last modification time (mtime) in secs and nanoseconds from the epoch. .Sp If the \f(CW*nsecs\fR field contains the special value \f(CW\-1\fR then the corresponding timestamp is set to the current time. (The \&\f(CW*secs\fR field is ignored in this case). .Sp If the \f(CW*nsecs\fR field contains the special value \f(CW\-2\fR then the corresponding timestamp is left unchanged. (The \&\f(CW*secs\fR field is ignored in this case). .ie n .IP "%uts = $g\->utsname ();" 4 .el .IP "\f(CW%uts\fR = \f(CW$g\fR\->utsname ();" 4 .IX Item "%uts = $g->utsname ();" This returns the kernel version of the appliance, where this is available. This information is only useful for debugging. Nothing in the returned structure is defined by the API. .ie n .IP "%version = $g\->version ();" 4 .el .IP "\f(CW%version\fR = \f(CW$g\fR\->version ();" 4 .IX Item "%version = $g->version ();" Return the libguestfs version number that the program is linked against. .Sp Note that because of dynamic linking this is not necessarily the version of libguestfs that you compiled against. You can compile the program, and then at runtime dynamically link against a completely different \fIlibguestfs.so\fR library. .Sp This call was added in version \f(CW1.0.58\fR. In previous versions of libguestfs there was no way to get the version number. From C code you can use dynamic linker functions to find out if this symbol exists (if it doesn't, then it’s an earlier version). .Sp The call returns a structure with four elements. The first three (\f(CW\*(C`major\*(C'\fR, \f(CW\*(C`minor\*(C'\fR and \f(CW\*(C`release\*(C'\fR) are numbers and correspond to the usual version triplet. The fourth element (\f(CW\*(C`extra\*(C'\fR) is a string and is normally empty, but may be used for distro-specific information. .Sp To construct the original version string: \&\f(CW\*(C`$major.$minor.$release$extra\*(C'\fR .Sp See also: "LIBGUESTFS VERSION NUMBERS" in \fBguestfs\fR\|(3). .Sp \&\fINote:\fR Don't use this call to test for availability of features. In enterprise distributions we backport features from later versions into earlier versions, making this an unreliable way to test for features. Use \f(CW\*(C`$g\->available\*(C'\fR or \f(CW\*(C`$g\->feature_available\*(C'\fR instead. .ie n .IP "$label = $g\->vfs_label ($mountable);" 4 .el .IP "\f(CW$label\fR = \f(CW$g\fR\->vfs_label ($mountable);" 4 .IX Item "$label = $g->vfs_label ($mountable);" This returns the label of the filesystem on \f(CW\*(C`mountable\*(C'\fR. .Sp If the filesystem is unlabeled, this returns the empty string. .Sp To find a filesystem from the label, use \f(CW\*(C`$g\->findfs_label\*(C'\fR. .ie n .IP "$sizeinbytes = $g\->vfs_minimum_size ($mountable);" 4 .el .IP "\f(CW$sizeinbytes\fR = \f(CW$g\fR\->vfs_minimum_size ($mountable);" 4 .IX Item "$sizeinbytes = $g->vfs_minimum_size ($mountable);" Get the minimum size of filesystem in bytes. This is the minimum possible size for filesystem shrinking. .Sp If getting minimum size of specified filesystem is not supported, this will fail and set errno as ENOTSUP. .Sp See also \fBntfsresize\fR\|(8), \fBresize2fs\fR\|(8), \fBbtrfs\fR\|(8), \fBxfs_info\fR\|(8). .ie n .IP "$fstype = $g\->vfs_type ($mountable);" 4 .el .IP "\f(CW$fstype\fR = \f(CW$g\fR\->vfs_type ($mountable);" 4 .IX Item "$fstype = $g->vfs_type ($mountable);" This command gets the filesystem type corresponding to the filesystem on \f(CW\*(C`mountable\*(C'\fR. .Sp For most filesystems, the result is the name of the Linux VFS module which would be used to mount this filesystem if you mounted it without specifying the filesystem type. For example a string such as \f(CW\*(C`ext3\*(C'\fR or \f(CW\*(C`ntfs\*(C'\fR. .ie n .IP "$uuid = $g\->vfs_uuid ($mountable);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->vfs_uuid ($mountable);" 4 .IX Item "$uuid = $g->vfs_uuid ($mountable);" This returns the filesystem UUID of the filesystem on \f(CW\*(C`mountable\*(C'\fR. .Sp If the filesystem does not have a UUID, this returns the empty string. .Sp To find a filesystem from the UUID, use \f(CW\*(C`$g\->findfs_uuid\*(C'\fR. .ie n .IP "$g\->vg_activate ($activate, \e@volgroups);" 4 .el .IP "\f(CW$g\fR\->vg_activate ($activate, \e@volgroups);" 4 .IX Item "$g->vg_activate ($activate, @volgroups);" This command activates or (if \f(CW\*(C`activate\*(C'\fR is false) deactivates all logical volumes in the listed volume groups \f(CW\*(C`volgroups\*(C'\fR. .Sp This command is the same as running \f(CW\*(C`vgchange \-a y|n volgroups...\*(C'\fR .Sp Note that if \f(CW\*(C`volgroups\*(C'\fR is an empty list then \fBall\fR volume groups are activated or deactivated. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vg_activate_all ($activate);" 4 .el .IP "\f(CW$g\fR\->vg_activate_all ($activate);" 4 .IX Item "$g->vg_activate_all ($activate);" This command activates or (if \f(CW\*(C`activate\*(C'\fR is false) deactivates all logical volumes in all volume groups. .Sp This command is the same as running \f(CW\*(C`vgchange \-a y|n\*(C'\fR .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vgchange_uuid ($vg);" 4 .el .IP "\f(CW$g\fR\->vgchange_uuid ($vg);" 4 .IX Item "$g->vgchange_uuid ($vg);" Generate a new random UUID for the volume group \f(CW\*(C`vg\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vgchange_uuid_all ();" 4 .el .IP "\f(CW$g\fR\->vgchange_uuid_all ();" 4 .IX Item "$g->vgchange_uuid_all ();" Generate new random UUIDs for all volume groups. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vgcreate ($volgroup, \e@physvols);" 4 .el .IP "\f(CW$g\fR\->vgcreate ($volgroup, \e@physvols);" 4 .IX Item "$g->vgcreate ($volgroup, @physvols);" This creates an LVM volume group called \f(CW\*(C`volgroup\*(C'\fR from the non-empty list of physical volumes \f(CW\*(C`physvols\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@uuids = $g\->vglvuuids ($vgname);" 4 .el .IP "\f(CW@uuids\fR = \f(CW$g\fR\->vglvuuids ($vgname);" 4 .IX Item "@uuids = $g->vglvuuids ($vgname);" Given a VG called \f(CW\*(C`vgname\*(C'\fR, this returns the UUIDs of all the logical volumes created in this volume group. .Sp You can use this along with \f(CW\*(C`$g\->lvs\*(C'\fR and \f(CW\*(C`$g\->lvuuid\*(C'\fR calls to associate logical volumes and volume groups. .Sp See also \f(CW\*(C`$g\->vgpvuuids\*(C'\fR. .ie n .IP "$metadata = $g\->vgmeta ($vgname);" 4 .el .IP "\f(CW$metadata\fR = \f(CW$g\fR\->vgmeta ($vgname);" 4 .IX Item "$metadata = $g->vgmeta ($vgname);" \&\f(CW\*(C`vgname\*(C'\fR is an LVM volume group. This command examines the volume group and returns its metadata. .Sp Note that the metadata is an internal structure used by LVM, subject to change at any time, and is provided for information only. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@uuids = $g\->vgpvuuids ($vgname);" 4 .el .IP "\f(CW@uuids\fR = \f(CW$g\fR\->vgpvuuids ($vgname);" 4 .IX Item "@uuids = $g->vgpvuuids ($vgname);" Given a VG called \f(CW\*(C`vgname\*(C'\fR, this returns the UUIDs of all the physical volumes that this volume group resides on. .Sp You can use this along with \f(CW\*(C`$g\->pvs\*(C'\fR and \f(CW\*(C`$g\->pvuuid\*(C'\fR calls to associate physical volumes and volume groups. .Sp See also \f(CW\*(C`$g\->vglvuuids\*(C'\fR. .ie n .IP "$g\->vgremove ($vgname);" 4 .el .IP "\f(CW$g\fR\->vgremove ($vgname);" 4 .IX Item "$g->vgremove ($vgname);" Remove an LVM volume group \f(CW\*(C`vgname\*(C'\fR, (for example \f(CW\*(C`VG\*(C'\fR). .Sp This also forcibly removes all logical volumes in the volume group (if any). .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vgrename ($volgroup, $newvolgroup);" 4 .el .IP "\f(CW$g\fR\->vgrename ($volgroup, \f(CW$newvolgroup\fR);" 4 .IX Item "$g->vgrename ($volgroup, $newvolgroup);" Rename a volume group \f(CW\*(C`volgroup\*(C'\fR with the new name \f(CW\*(C`newvolgroup\*(C'\fR. .ie n .IP "@volgroups = $g\->vgs ();" 4 .el .IP "\f(CW@volgroups\fR = \f(CW$g\fR\->vgs ();" 4 .IX Item "@volgroups = $g->vgs ();" List all the volumes groups detected. This is the equivalent of the \fBvgs\fR\|(8) command. .Sp This returns a list of just the volume group names that were detected (eg. \f(CW\*(C`VolGroup00\*(C'\fR). .Sp See also \f(CW\*(C`$g\->vgs_full\*(C'\fR. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@volgroups = $g\->vgs_full ();" 4 .el .IP "\f(CW@volgroups\fR = \f(CW$g\fR\->vgs_full ();" 4 .IX Item "@volgroups = $g->vgs_full ();" List all the volumes groups detected. This is the equivalent of the \fBvgs\fR\|(8) command. The "full" version includes all fields. .Sp This function depends on the feature \f(CW\*(C`lvm2\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->vgscan ();" 4 .el .IP "\f(CW$g\fR\->vgscan ();" 4 .IX Item "$g->vgscan ();" This rescans all block devices and rebuilds the list of LVM physical volumes, volume groups and logical volumes. .Sp \&\fIThis function is deprecated.\fR In new code, use the "lvm_scan" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$uuid = $g\->vguuid ($vgname);" 4 .el .IP "\f(CW$uuid\fR = \f(CW$g\fR\->vguuid ($vgname);" 4 .IX Item "$uuid = $g->vguuid ($vgname);" This command returns the UUID of the LVM VG named \f(CW\*(C`vgname\*(C'\fR. .ie n .IP "$g\->wait_ready ();" 4 .el .IP "\f(CW$g\fR\->wait_ready ();" 4 .IX Item "$g->wait_ready ();" This function is a no op. .Sp In versions of the API < 1.0.71 you had to call this function just after calling \f(CW\*(C`$g\->launch\*(C'\fR to wait for the launch to complete. However this is no longer necessary because \&\f(CW\*(C`$g\->launch\*(C'\fR now does the waiting. .Sp If you see any calls to this function in code then you can just remove them, unless you want to retain compatibility with older versions of the API. .Sp \&\fIThis function is deprecated.\fR There is no replacement. Consult the API documentation in \&\fBguestfs\fR\|(3) for further information. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$chars = $g\->wc_c ($path);" 4 .el .IP "\f(CW$chars\fR = \f(CW$g\fR\->wc_c ($path);" 4 .IX Item "$chars = $g->wc_c ($path);" This command counts the characters in a file, using the \&\f(CW\*(C`wc \-c\*(C'\fR external command. .ie n .IP "$lines = $g\->wc_l ($path);" 4 .el .IP "\f(CW$lines\fR = \f(CW$g\fR\->wc_l ($path);" 4 .IX Item "$lines = $g->wc_l ($path);" This command counts the lines in a file, using the \&\f(CW\*(C`wc \-l\*(C'\fR external command. .ie n .IP "$words = $g\->wc_w ($path);" 4 .el .IP "\f(CW$words\fR = \f(CW$g\fR\->wc_w ($path);" 4 .IX Item "$words = $g->wc_w ($path);" This command counts the words in a file, using the \&\f(CW\*(C`wc \-w\*(C'\fR external command. .ie n .IP "$g\->wipefs ($device);" 4 .el .IP "\f(CW$g\fR\->wipefs ($device);" 4 .IX Item "$g->wipefs ($device);" This command erases filesystem or RAID signatures from the specified \f(CW\*(C`device\*(C'\fR to make the filesystem invisible to libblkid. .Sp This does not erase the filesystem itself nor any other data from the \&\f(CW\*(C`device\*(C'\fR. .Sp Compare with \f(CW\*(C`$g\->zero\*(C'\fR which zeroes the first few blocks of a device. .Sp This function depends on the feature \f(CW\*(C`wipefs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->write ($path, $content);" 4 .el .IP "\f(CW$g\fR\->write ($path, \f(CW$content\fR);" 4 .IX Item "$g->write ($path, $content);" This call creates a file called \f(CW\*(C`path\*(C'\fR. The content of the file is the string \f(CW\*(C`content\*(C'\fR (which can contain any 8 bit data). .Sp See also \f(CW\*(C`$g\->write_append\*(C'\fR. .ie n .IP "$g\->write_append ($path, $content);" 4 .el .IP "\f(CW$g\fR\->write_append ($path, \f(CW$content\fR);" 4 .IX Item "$g->write_append ($path, $content);" This call appends \f(CW\*(C`content\*(C'\fR to the end of file \f(CW\*(C`path\*(C'\fR. If \&\f(CW\*(C`path\*(C'\fR does not exist, then a new file is created. .Sp See also \f(CW\*(C`$g\->write\*(C'\fR. .ie n .IP "$g\->write_file ($path, $content, $size);" 4 .el .IP "\f(CW$g\fR\->write_file ($path, \f(CW$content\fR, \f(CW$size\fR);" 4 .IX Item "$g->write_file ($path, $content, $size);" This call creates a file called \f(CW\*(C`path\*(C'\fR. The contents of the file is the string \f(CW\*(C`content\*(C'\fR (which can contain any 8 bit data), with length \f(CW\*(C`size\*(C'\fR. .Sp As a special case, if \f(CW\*(C`size\*(C'\fR is \f(CW0\fR then the length is calculated using \f(CW\*(C`strlen\*(C'\fR (so in this case the content cannot contain embedded ASCII NULs). .Sp \&\fINB.\fR Owing to a bug, writing content containing ASCII NUL characters does \fInot\fR work, even if the length is specified. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "write" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->xfs_admin ($device [, extunwritten => $extunwritten] [, imgfile => $imgfile] [, v2log => $v2log] [, projid32bit => $projid32bit] [, lazycounter => $lazycounter] [, label => $label] [, uuid => $uuid]);" 4 .el .IP "\f(CW$g\fR\->xfs_admin ($device [, extunwritten => \f(CW$extunwritten\fR] [, imgfile => \f(CW$imgfile\fR] [, v2log => \f(CW$v2log\fR] [, projid32bit => \f(CW$projid32bit\fR] [, lazycounter => \f(CW$lazycounter\fR] [, label => \f(CW$label\fR] [, uuid => \f(CW$uuid\fR]);" 4 .IX Item "$g->xfs_admin ($device [, extunwritten => $extunwritten] [, imgfile => $imgfile] [, v2log => $v2log] [, projid32bit => $projid32bit] [, lazycounter => $lazycounter] [, label => $label] [, uuid => $uuid]);" Change the parameters of the XFS filesystem on \f(CW\*(C`device\*(C'\fR. .Sp Devices that are mounted cannot be modified. Administrators must unmount filesystems before this call can modify parameters. .Sp Some of the parameters of a mounted filesystem can be examined and modified using the \f(CW\*(C`$g\->xfs_info\*(C'\fR and \&\f(CW\*(C`$g\->xfs_growfs\*(C'\fR calls. .Sp Beginning with XFS version 5, it is no longer possible to modify the lazy-counters setting (ie. \f(CW\*(C`lazycounter\*(C'\fR parameter has no effect). .Sp This function depends on the feature \f(CW\*(C`xfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->xfs_growfs ($path [, datasec => $datasec] [, logsec => $logsec] [, rtsec => $rtsec] [, datasize => $datasize] [, logsize => $logsize] [, rtsize => $rtsize] [, rtextsize => $rtextsize] [, maxpct => $maxpct]);" 4 .el .IP "\f(CW$g\fR\->xfs_growfs ($path [, datasec => \f(CW$datasec\fR] [, logsec => \f(CW$logsec\fR] [, rtsec => \f(CW$rtsec\fR] [, datasize => \f(CW$datasize\fR] [, logsize => \f(CW$logsize\fR] [, rtsize => \f(CW$rtsize\fR] [, rtextsize => \f(CW$rtextsize\fR] [, maxpct => \f(CW$maxpct\fR]);" 4 .IX Item "$g->xfs_growfs ($path [, datasec => $datasec] [, logsec => $logsec] [, rtsec => $rtsec] [, datasize => $datasize] [, logsize => $logsize] [, rtsize => $rtsize] [, rtextsize => $rtextsize] [, maxpct => $maxpct]);" Grow the XFS filesystem mounted at \f(CW\*(C`path\*(C'\fR. .Sp The returned struct contains geometry information. Missing fields are returned as \f(CW\-1\fR (for numeric fields) or empty string. .Sp This function depends on the feature \f(CW\*(C`xfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "%info = $g\->xfs_info ($pathordevice);" 4 .el .IP "\f(CW%info\fR = \f(CW$g\fR\->xfs_info ($pathordevice);" 4 .IX Item "%info = $g->xfs_info ($pathordevice);" \&\f(CW\*(C`pathordevice\*(C'\fR is a mounted XFS filesystem or a device containing an XFS filesystem. This command returns the geometry of the filesystem. .Sp The returned struct contains geometry information. Missing fields are returned as \f(CW\-1\fR (for numeric fields) or empty string. .Sp This function depends on the feature \f(CW\*(C`xfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$status = $g\->xfs_repair ($device [, forcelogzero => $forcelogzero] [, nomodify => $nomodify] [, noprefetch => $noprefetch] [, forcegeometry => $forcegeometry] [, maxmem => $maxmem] [, ihashsize => $ihashsize] [, bhashsize => $bhashsize] [, agstride => $agstride] [, logdev => $logdev] [, rtdev => $rtdev]);" 4 .el .IP "\f(CW$status\fR = \f(CW$g\fR\->xfs_repair ($device [, forcelogzero => \f(CW$forcelogzero\fR] [, nomodify => \f(CW$nomodify\fR] [, noprefetch => \f(CW$noprefetch\fR] [, forcegeometry => \f(CW$forcegeometry\fR] [, maxmem => \f(CW$maxmem\fR] [, ihashsize => \f(CW$ihashsize\fR] [, bhashsize => \f(CW$bhashsize\fR] [, agstride => \f(CW$agstride\fR] [, logdev => \f(CW$logdev\fR] [, rtdev => \f(CW$rtdev\fR]);" 4 .IX Item "$status = $g->xfs_repair ($device [, forcelogzero => $forcelogzero] [, nomodify => $nomodify] [, noprefetch => $noprefetch] [, forcegeometry => $forcegeometry] [, maxmem => $maxmem] [, ihashsize => $ihashsize] [, bhashsize => $bhashsize] [, agstride => $agstride] [, logdev => $logdev] [, rtdev => $rtdev]);" Repair corrupt or damaged XFS filesystem on \f(CW\*(C`device\*(C'\fR. .Sp The filesystem is specified using the \f(CW\*(C`device\*(C'\fR argument which should be the device name of the disk partition or volume containing the filesystem. If given the name of a block device, \f(CW\*(C`xfs_repair\*(C'\fR will attempt to find the raw device associated with the specified block device and will use the raw device instead. .Sp Regardless, the filesystem to be repaired must be unmounted, otherwise, the resulting filesystem may be inconsistent or corrupt. .Sp The returned status indicates whether filesystem corruption was detected (returns \f(CW1\fR) or was not detected (returns \f(CW0\fR). .Sp This function depends on the feature \f(CW\*(C`xfs\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->yara_destroy ();" 4 .el .IP "\f(CW$g\fR\->yara_destroy ();" 4 .IX Item "$g->yara_destroy ();" Destroy previously loaded Yara rules in order to free libguestfs resources. .Sp This function depends on the feature \f(CW\*(C`libyara\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "$g\->yara_load ($filename);" 4 .el .IP "\f(CW$g\fR\->yara_load ($filename);" 4 .IX Item "$g->yara_load ($filename);" Upload a set of Yara rules from local file \fIfilename\fR. .Sp Yara rules allow to categorize files based on textual or binary patterns within their content. See \f(CW\*(C`$g\->yara_scan\*(C'\fR to see how to scan files with the loaded rules. .Sp Rules can be in binary format, as when compiled with yarac command, or in source code format. In the latter case, the rules will be first compiled and then loaded. .Sp Rules in source code format cannot include external files. In such cases, it is recommended to compile them first. .Sp Previously loaded rules will be destroyed. .Sp This function depends on the feature \f(CW\*(C`libyara\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@detections = $g\->yara_scan ($path);" 4 .el .IP "\f(CW@detections\fR = \f(CW$g\fR\->yara_scan ($path);" 4 .IX Item "@detections = $g->yara_scan ($path);" Scan a file with the previously loaded Yara rules. .Sp For each matching rule, a \f(CW\*(C`yara_detection\*(C'\fR structure is returned. .Sp The \f(CW\*(C`yara_detection\*(C'\fR structure contains the following fields. .RS 4 .ie n .IP """yara_name""" 4 .el .IP \f(CWyara_name\fR 4 .IX Item "yara_name" Path of the file matching a Yara rule. .ie n .IP """yara_rule""" 4 .el .IP \f(CWyara_rule\fR 4 .IX Item "yara_rule" Identifier of the Yara rule which matched against the given file. .RE .RS 4 .Sp This function depends on the feature \f(CW\*(C`libyara\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .RE .ie n .IP "@lines = $g\->zegrep ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zegrep ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zegrep ($regex, $path);" This calls the external \f(CW\*(C`zegrep\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->zegrepi ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zegrepi ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zegrepi ($regex, $path);" This calls the external \f(CW\*(C`zegrep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$g\->zero ($device);" 4 .el .IP "\f(CW$g\fR\->zero ($device);" 4 .IX Item "$g->zero ($device);" This command writes zeroes over the first few blocks of \f(CW\*(C`device\*(C'\fR. .Sp How many blocks are zeroed isn't specified (but it’s \fInot\fR enough to securely wipe the device). It should be sufficient to remove any partition tables, filesystem superblocks and so on. .Sp If blocks are already zero, then this command avoids writing zeroes. This prevents the underlying device from becoming non-sparse or growing unnecessarily. .Sp See also: \f(CW\*(C`$g\->zero_device\*(C'\fR, \f(CW\*(C`$g\->scrub_device\*(C'\fR, \&\f(CW\*(C`$g\->is_zero_device\*(C'\fR .ie n .IP "$g\->zero_device ($device);" 4 .el .IP "\f(CW$g\fR\->zero_device ($device);" 4 .IX Item "$g->zero_device ($device);" This command writes zeroes over the entire \f(CW\*(C`device\*(C'\fR. Compare with \f(CW\*(C`$g\->zero\*(C'\fR which just zeroes the first few blocks of a device. .Sp If blocks are already zero, then this command avoids writing zeroes. This prevents the underlying device from becoming non-sparse or growing unnecessarily. .ie n .IP "$g\->zero_free_space ($directory);" 4 .el .IP "\f(CW$g\fR\->zero_free_space ($directory);" 4 .IX Item "$g->zero_free_space ($directory);" Zero the free space in the filesystem mounted on \fIdirectory\fR. The filesystem must be mounted read-write. .Sp The filesystem contents are not affected, but any free space in the filesystem is freed. .Sp Free space is not "trimmed". You may want to call \&\f(CW\*(C`$g\->fstrim\*(C'\fR either as an alternative to this, or after calling this, depending on your requirements. .ie n .IP "$g\->zerofree ($device);" 4 .el .IP "\f(CW$g\fR\->zerofree ($device);" 4 .IX Item "$g->zerofree ($device);" This runs the \fIzerofree\fR program on \f(CW\*(C`device\*(C'\fR. This program claims to zero unused inodes and disk blocks on an ext2/3 filesystem, thus making it possible to compress the filesystem more effectively. .Sp You should \fBnot\fR run this program if the filesystem is mounted. .Sp It is possible that using this program can damage the filesystem or data on the filesystem. .Sp This function depends on the feature \f(CW\*(C`zerofree\*(C'\fR. See also \&\f(CW\*(C`$g\->feature\-available\*(C'\fR. .ie n .IP "@lines = $g\->zfgrep ($pattern, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zfgrep ($pattern, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zfgrep ($pattern, $path);" This calls the external \f(CW\*(C`zfgrep\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->zfgrepi ($pattern, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zfgrepi ($pattern, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zfgrepi ($pattern, $path);" This calls the external \f(CW\*(C`zfgrep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "$description = $g\->zfile ($meth, $path);" 4 .el .IP "\f(CW$description\fR = \f(CW$g\fR\->zfile ($meth, \f(CW$path\fR);" 4 .IX Item "$description = $g->zfile ($meth, $path);" This command runs \fBfile\fR\|(1) after first decompressing \f(CW\*(C`path\*(C'\fR using \f(CW\*(C`meth\*(C'\fR. .Sp \&\f(CW\*(C`meth\*(C'\fR must be one of \f(CW\*(C`gzip\*(C'\fR, \f(CW\*(C`compress\*(C'\fR or \f(CW\*(C`bzip2\*(C'\fR. .Sp Since 1.0.63, use \f(CW\*(C`$g\->file\*(C'\fR instead which can now process compressed files. .Sp \&\fIThis function is deprecated.\fR In new code, use the "file" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->zgrep ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zgrep ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zgrep ($regex, $path);" This calls the external \fBzgrep\fR\|(1) program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .ie n .IP "@lines = $g\->zgrepi ($regex, $path);" 4 .el .IP "\f(CW@lines\fR = \f(CW$g\fR\->zgrepi ($regex, \f(CW$path\fR);" 4 .IX Item "@lines = $g->zgrepi ($regex, $path);" This calls the external \f(CW\*(C`zgrep \-i\*(C'\fR program and returns the matching lines. .Sp Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. See "PROTOCOL LIMITS" in \fBguestfs\fR\|(3). .Sp \&\fIThis function is deprecated.\fR In new code, use the "grep" call instead. .Sp Deprecated functions will not be removed from the API, but the fact that they are deprecated indicates that there are problems with correct use of these functions. .SH AVAILABILITY .IX Header "AVAILABILITY" From time to time we add new libguestfs APIs. Also some libguestfs APIs won't be available in all builds of libguestfs (the Fedora build is full-featured, but other builds may disable features). How do you test whether the APIs that your Perl program needs are available in the version of \f(CW\*(C`Sys::Guestfs\*(C'\fR that you are using? .PP To test if a particular function is available in the \f(CW\*(C`Sys::Guestfs\*(C'\fR class, use the ordinary Perl UNIVERSAL method \f(CWcan(METHOD)\fR (see \fBperlobj\fR\|(1)). For example: .PP .Vb 4 \& use Sys::Guestfs; \& if (defined (Sys::Guestfs\->can ("set_verbose"))) { \& print "\e$g\->set_verbose is available\en"; \& } .Ve .PP To test if particular features are supported by the current build, use the "feature_available" method like the example below. Note that the appliance must be launched first. .PP .Vb 1 \& $g\->feature_available ( ["augeas"] ); .Ve .PP For further discussion on this topic, refer to "AVAILABILITY" in \fBguestfs\fR\|(3). .SH "STORING DATA IN THE HANDLE" .IX Header "STORING DATA IN THE HANDLE" The handle returned from "new" is a hash reference. The hash normally contains some elements: .PP .Vb 4 \& { \& _g => [private data used by libguestfs], \& _flags => [flags provided when creating the handle] \& } .Ve .PP Callers can add other elements to this hash to store data for their own purposes. The data lasts for the lifetime of the handle. .PP Any fields whose names begin with an underscore are reserved for private use by libguestfs. We may add more in future. .PP It is recommended that callers prefix the name of their field(s) with some unique string, to avoid conflicts with other users. .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright (C) 2009\-2023 Red Hat Inc. .SH LICENSE .IX Header "LICENSE" Please see the file COPYING.LIB for the full license. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBguestfs\fR\|(3), \&\fBguestfish\fR\|(1), .