Generated code for mknod, mkfifo, mknod_b, mknod_c, umask.
[libguestfs.git] / guestfish-actions.pod
index 9b07c40..8ced2e1 100644 (file)
@@ -26,7 +26,7 @@ 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).
 
-This is equivalent to the qemu parameter C<-drive file=filename>.
+This is equivalent to the qemu parameter C<-drive file=filename,cache=off>.
 
 Note that this call checks for the existence of C<filename>.  This
 stops you from specifying other types of drive which are supported
@@ -401,7 +401,9 @@ or compatible processor architecture).
 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).
+non-empty (ie. must contain a program name).  Note that
+the command runs directly, and is I<not> invoked via
+the shell (see C<sh>).
 
 The return value is anything printed to I<stdout> by
 the command.
@@ -432,6 +434,8 @@ FTP.
 This is the same as C<command>, but splits the
 result into a list of lines.
 
+See also: C<sh-lines>
+
 Because of the message protocol, there is a transfer limit 
 of somewhere between 2MB and 4MB.  To transfer large files you should use
 FTP.
@@ -475,6 +479,27 @@ There is no comprehensive help for this command.  You have
 to look at the file C<daemon/debug.c> in the libguestfs source
 to find out what you can do.
 
+=head2 df
+
+ df
+
+This command runs the C<df> command to report disk space used.
+
+This command is mostly useful for interactive sessions.  It
+is I<not> intended that you try to parse the output string.
+Use C<statvfs> from programs.
+
+=head2 df-h
+
+ df-h
+
+This command runs the C<df -h> command to report disk space used
+in human-readable format.
+
+This command is mostly useful for interactive sessions.  It
+is I<not> intended that you try to parse the output string.
+Use C<statvfs> from programs.
+
 =head2 dmesg
 
  dmesg
@@ -515,6 +540,20 @@ Setting C<whattodrop> to 3 should drop everything.
 This automatically calls L<sync(2)> before the operation,
 so that the maximum guest memory is freed.
 
+=head2 du
+
+ du path
+
+This command runs the C<du -s> command to estimate file space
+usage for C<path>.
+
+C<path> can be a file or a directory.  If C<path> is a directory
+then the estimate includes the contents of the directory and all
+subdirectories (recursively).
+
+The result is the estimated size in I<kilobytes>
+(ie. units of 1024 bytes).
+
 =head2 e2fsck-f
 
  e2fsck-f device
@@ -646,6 +685,20 @@ C<device>.
 This returns the ext2/3/4 filesystem UUID of the filesystem on
 C<device>.
 
+=head2 get-memsize
+
+ get-memsize
+
+This gets the memory size in megabytes allocated to the
+qemu subprocess.
+
+If C<set-memsize> was not called
+on this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,
+then this returns the compiled-in default value for memsize.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
 =head2 get-path
 
  get-path
@@ -679,6 +732,21 @@ For more information on states, see L<guestfs(3)>.
 
 This returns the verbose messages flag.
 
+=head2 glob-expand
+
+ glob-expand pattern
+
+This command searches for all the pathnames matching
+C<pattern> according to the wildcard expansion rules
+used by the shell.
+
+If no paths match, then this returns an empty list
+(note: not an error).
+
+It is just a wrapper around the C L<glob(3)> function
+with flags C<GLOB_MARK|GLOB_BRACE>.
+See that manual page for more details.
+
 =head2 grub-install
 
  grub-install root device
@@ -686,6 +754,33 @@ This returns the verbose messages flag.
 This command installs GRUB (the Grand Unified Bootloader) on
 C<device>, with the root directory being C<root>.
 
+=head2 head
+
+ head path
+
+This command returns up to the first 10 lines of a file as
+a list of strings.
+
+Because of the message protocol, there is a transfer limit 
+of somewhere between 2MB and 4MB.  To transfer large files you should use
+FTP.
+
+=head2 head-n
+
+ head-n nrlines path
+
+If the parameter C<nrlines> is a positive number, this returns the first
+C<nrlines> lines of the file C<path>.
+
+If the parameter C<nrlines> is a negative number, this returns lines
+from the file C<path>, excluding the last C<nrlines> lines.
+
+If the parameter C<nrlines> is zero, this returns an empty list.
+
+Because of the message protocol, there is a transfer limit 
+of somewhere between 2MB and 4MB.  To transfer large files you should use
+FTP.
+
 =head2 hexdump
 
  hexdump path
@@ -697,6 +792,20 @@ Because of the message protocol, there is a transfer limit
 of somewhere between 2MB and 4MB.  To transfer large files you should use
 FTP.
 
+=head2 initrd-list
+
+ initrd-list path
+
+This command lists out files contained in an initrd.
+
+The files are listed without any initial C</> character.  The
+files are listed in the order they appear (not necessarily
+alphabetical).  Directory names are listed as separate items.
+
+Old Linux kernels (2.4 and earlier) used a compressed ext2
+filesystem as initrd.  We I<only> support the newer initramfs
+format (compressed cpio files).
+
 =head2 is-busy
 
  is-busy
@@ -888,6 +997,37 @@ Create a directory named C<path>.
 Create a directory named C<path>, creating any parent directories
 as necessary.  This is like the C<mkdir -p> shell command.
 
+=head2 mkdtemp
+
+ mkdtemp template
+
+This command creates a temporary directory.  The
+C<template> parameter should be a full pathname for the
+temporary directory name with the final six characters being
+"XXXXXX".
+
+For example: "/tmp/myprogXXXXXX" or "/Temp/myprogXXXXXX",
+the second one being suitable for Windows filesystems.
+
+The name of the temporary directory that was created
+is returned.
+
+The temporary directory is created with mode 0700
+and is owned by root.
+
+The caller is responsible for deleting the temporary
+directory and its contents after use.
+
+See also: L<mkdtemp(3)>
+
+=head2 mkfifo
+
+ mkfifo mode path
+
+This call creates a FIFO (named pipe) called C<path> with
+mode C<mode>.  It is just a convenient wrapper around
+C<mknod>.
+
 =head2 mkfs
 
  mkfs fstype device
@@ -896,6 +1036,52 @@ This creates a filesystem on C<device> (usually a partition
 or LVM logical volume).  The filesystem type is C<fstype>, for
 example C<ext3>.
 
+=head2 mknod
+
+ mknod mode devmajor devminor path
+
+This call creates block or character special devices, or
+named pipes (FIFOs).
+
+The C<mode> parameter should be the mode, using the standard
+constants.  C<devmajor> and C<devminor> are the
+device major and minor numbers, only used when creating block
+and character special devices.
+
+=head2 mknod-b
+
+ mknod-b mode devmajor devminor path
+
+This call creates a block device node called C<path> with
+mode C<mode> and device major/minor C<devmajor> and C<devminor>.
+It is just a convenient wrapper around C<mknod>.
+
+=head2 mknod-c
+
+ mknod-c mode devmajor devminor path
+
+This call creates a char device node called C<path> with
+mode C<mode> and device major/minor C<devmajor> and C<devminor>.
+It is just a convenient wrapper around C<mknod>.
+
+=head2 mkswap
+
+ mkswap device
+
+Create a swap partition on C<device>.
+
+=head2 mkswap-L
+
+ mkswap-L label device
+
+Create a swap partition on C<device> with label C<label>.
+
+=head2 mkswap-U
+
+ mkswap-U uuid device
+
+Create a swap partition on C<device> with UUID C<uuid>.
+
 =head2 mount
 
  mount device mountpoint
@@ -917,6 +1103,14 @@ on the underlying device.
 The filesystem options C<sync> and C<noatime> are set with this
 call, in order to improve reliability.
 
+=head2 mount-loop
+
+ mount-loop file mountpoint
+
+This command lets you mount C<file> (a filesystem image
+in a file) on a mount point.  It is entirely equivalent to
+the command C<mount -o loop file mountpoint>.
+
 =head2 mount-options
 
  mount-options options device mountpoint
@@ -956,6 +1150,22 @@ Some internal mounts are not shown.
 This moves a file from C<src> to C<dest> where C<dest> is
 either a destination filename or destination directory.
 
+=head2 ntfs-3g-probe
+
+ ntfs-3g-probe true|false device
+
+This command runs the L<ntfs-3g.probe(8)> command which probes
+an NTFS C<device> for mountability.  (Not all NTFS volumes can
+be mounted read-write, and some cannot be mounted at all).
+
+C<rw> 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.
+
+The return value is an integer which C<0> if the operation
+would succeed, or some non-zero value documented in the
+L<ntfs-3g.probe(8)> manual page.
+
 =head2 ping-daemon
 
  ping-daemon
@@ -1057,6 +1267,44 @@ command.
 
 Remove the single directory C<path>.
 
+=head2 scrub-device
+
+ scrub-device device
+
+This command writes patterns over C<device> to make data retrieval
+more difficult.
+
+It is an interface to the L<scrub(1)> program.  See that
+manual page for more details.
+
+B<This command is dangerous.  Without careful use you
+can easily destroy all your data>.
+
+=head2 scrub-file
+
+ scrub-file file
+
+This command writes patterns over a file to make data retrieval
+more difficult.
+
+The file is I<removed> after scrubbing.
+
+It is an interface to the L<scrub(1)> program.  See that
+manual page for more details.
+
+=head2 scrub-freespace
+
+ scrub-freespace dir
+
+This command creates the directory C<dir> and then fills it
+with files until the filesystem is full, and scrubs the files
+as for C<scrub-file>, and deletes them.
+The intention is to scrub any free space on the partition
+containing C<dir>.
+
+It is an interface to the L<scrub(1)> program.  See that
+manual page for more details.
+
 =head2 set-append | append
 
  set-append append
@@ -1105,6 +1353,21 @@ L<tune2fs(8)> manpage.
 You can use either C<tune2fs-l> or C<get-e2uuid>
 to return the existing UUID of a filesystem.
 
+=head2 set-memsize | memsize
+
+ set-memsize memsize
+
+This sets the memory size in megabytes allocated to the
+qemu subprocess.  This only has any effect if called before
+C<launch>.
+
+You can also change this by setting the environment
+variable C<LIBGUESTFS_MEMSIZE> before the handle is
+created.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
 =head2 set-path | path
 
  set-path path
@@ -1170,7 +1433,7 @@ can easily destroy all your data>.
 
 =head2 sfdisk-N
 
- sfdisk-N device n cyls heads sectors line
+ sfdisk-N device partnum cyls heads sectors line
 
 This runs L<sfdisk(8)> option to modify just the single
 partition C<n> (note: C<n> counts from 1).
@@ -1210,6 +1473,38 @@ This displays the partition table on C<device>, in the
 human-readable output of the L<sfdisk(8)> command.  It is
 not intended to be parsed.
 
+=head2 sh
+
+ sh command
+
+This call runs a command from the guest filesystem via the
+guest's C</bin/sh>.
+
+This is like C<command>, but passes the command to:
+
+ /bin/sh -c "command"
+
+Depending on the guest's shell, this usually results in
+wildcards being expanded, shell expressions being interpolated
+and so on.
+
+All the provisos about C<command> apply to this call.
+
+=head2 sh-lines
+
+ sh-lines command
+
+This is the same as C<sh>, but splits the result
+into a list of lines.
+
+See also: C<command-lines>
+
+=head2 sleep
+
+ sleep secs
+
+Sleep for C<secs> seconds.
+
 =head2 stat
 
  stat path
@@ -1267,6 +1562,33 @@ underlying disk image.
 You should always call this if you have modified a disk image, before
 closing the handle.
 
+=head2 tail
+
+ tail path
+
+This command returns up to the last 10 lines of a file as
+a list of strings.
+
+Because of the message protocol, there is a transfer limit 
+of somewhere between 2MB and 4MB.  To transfer large files you should use
+FTP.
+
+=head2 tail-n
+
+ tail-n nrlines path
+
+If the parameter C<nrlines> is a positive number, this returns the last
+C<nrlines> lines of the file C<path>.
+
+If the parameter C<nrlines> is a negative number, this returns lines
+from the file C<path>, starting with the C<-nrlines>th line.
+
+If the parameter C<nrlines> is zero, this returns an empty list.
+
+Because of the message protocol, there is a transfer limit 
+of somewhere between 2MB and 4MB.  To transfer large files you should use
+FTP.
+
 =head2 tar-in
 
  tar-in (tarfile|-) directory
@@ -1331,6 +1653,22 @@ manpage for more details.  The list of fields returned isn't
 clearly defined, and depends on both the version of C<tune2fs>
 that libguestfs was built against, and the filesystem itself.
 
+=head2 umask
+
+ umask mask
+
+This function sets the mask used for creating new files and
+device nodes to C<mask & 0777>.
+
+Typical umask values would be C<022> which creates new files
+with permissions like "-rw-r--r--" or "-rwxr-xr-x", and
+C<002> which creates new files with permissions like
+"-rw-rw-r--" or "-rwxrwxr-x".
+
+See also L<umask(2)>, C<mknod>, C<mkdir>.
+
+This call returns the previous umask.
+
 =head2 umount | unmount
 
  umount pathordevice
@@ -1422,6 +1760,27 @@ See also C<vgs-full>.
 List all the volumes groups detected.  This is the equivalent
 of the L<vgs(8)> command.  The "full" version includes all fields.
 
+=head2 wc-c
+
+ wc-c path
+
+This command counts the characters in a file, using the
+C<wc -c> external command.
+
+=head2 wc-l
+
+ wc-l path
+
+This command counts the lines in a file, using the
+C<wc -l> external command.
+
+=head2 wc-w
+
+ wc-w path
+
+This command counts the words in a file, using the
+C<wc -w> external command.
+
 =head2 write-file
 
  write-file path content size
@@ -1453,6 +1812,8 @@ How many blocks are zeroed isn't specified (but it's I<not> enough
 to securely wipe the device).  It should be sufficient to remove
 any partition tables, filesystem superblocks and so on.
 
+See also: C<scrub-device>.
+
 =head2 zerofree
 
  zerofree device