tests: Rename capitests -> tests/c-api.
[libguestfs.git] / generator / generator_actions.ml
index fe40fbf..f7a6a6c 100644 (file)
@@ -747,6 +747,10 @@ FreeBSD.
 
 NetBSD.
 
+=item \"hurd\"
+
+GNU/Hurd.
+
 =item \"unknown\"
 
 The operating system type could not be determined.
@@ -2714,7 +2718,7 @@ This uses the L<blockdev(8)> command.");
    [InitScratchFS, Always, TestOutput (
       (* Pick a file from cwd which isn't likely to change. *)
       [["mkdir"; "/upload"];
-       ["upload"; "../COPYING.LIB"; "/upload/COPYING.LIB"];
+       ["upload"; "../../COPYING.LIB"; "/upload/COPYING.LIB"];
        ["checksum"; "md5"; "/upload/COPYING.LIB"]],
       Digest.to_hex (Digest.file "COPYING.LIB"))],
    "upload a file from the local machine",
@@ -2730,7 +2734,7 @@ See also C<guestfs_download>.");
    [InitScratchFS, Always, TestOutput (
       (* Pick a file from cwd which isn't likely to change. *)
       [["mkdir"; "/download"];
-       ["upload"; "../COPYING.LIB"; "/download/COPYING.LIB"];
+       ["upload"; "../../COPYING.LIB"; "/download/COPYING.LIB"];
        ["download"; "/download/COPYING.LIB"; "testdownload.tmp"];
        ["upload"; "testdownload.tmp"; "/download/upload"];
        ["checksum"; "md5"; "/download/upload"]],
@@ -4815,10 +4819,31 @@ for the file until you write to it).  To create a non-sparse
 file of zeroes, use C<guestfs_fallocate64> instead.");
 
   ("utimens", (RErr, [Pathname "path"; Int64 "atsecs"; Int64 "atnsecs"; Int64 "mtsecs"; Int64 "mtnsecs"], []), 201, [],
+   (* Test directories, named pipes etc (RHBZ#761451, RHBZ#761460) *)
    [InitScratchFS, Always, TestOutputStruct (
-      [["touch"; "/utimens"];
-       ["utimens"; "/utimens"; "12345"; "67890"; "9876"; "5432"];
-       ["stat"; "/utimens"]], [CompareWithInt ("mtime", 9876)])],
+      [["touch"; "/utimens-file"];
+       ["utimens"; "/utimens-file"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-file"]], [CompareWithInt ("mtime", 9876)]);
+    InitScratchFS, Always, TestOutputStruct (
+      [["mkdir"; "/utimens-dir"];
+       ["utimens"; "/utimens-dir"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-dir"]], [CompareWithInt ("mtime", 9876)]);
+    InitScratchFS, Always, TestOutputStruct (
+      [["mkfifo"; "0o644"; "/utimens-fifo"];
+       ["utimens"; "/utimens-fifo"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-fifo"]], [CompareWithInt ("mtime", 9876)]);
+    InitScratchFS, Always, TestOutputStruct (
+      [["ln_sf"; "/utimens-file"; "/utimens-link"];
+       ["utimens"; "/utimens-link"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-link"]], [CompareWithInt ("mtime", 9876)]);
+    InitScratchFS, Always, TestOutputStruct (
+      [["mknod_b"; "0o644"; "8"; "0"; "/utimens-block"];
+       ["utimens"; "/utimens-block"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-block"]], [CompareWithInt ("mtime", 9876)]);
+    InitScratchFS, Always, TestOutputStruct (
+      [["mknod_c"; "0o644"; "1"; "3"; "/utimens-char"];
+       ["utimens"; "/utimens-char"; "12345"; "67890"; "9876"; "5432"];
+       ["stat"; "/utimens-char"]], [CompareWithInt ("mtime", 9876)])],
    "set timestamp of a file with nanosecond precision",
    "\
 This command sets the timestamps of a file with nanosecond
@@ -5911,7 +5936,7 @@ See also C<guestfs_part_to_partnum>.");
   ("upload_offset", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"; Int64 "offset"], []), 273, [Progress],
    (let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in
     [InitScratchFS, Always, TestOutput (
-       [["upload_offset"; "../COPYING.LIB"; "/upload_offset"; "0"];
+       [["upload_offset"; "../../COPYING.LIB"; "/upload_offset"; "0"];
         ["checksum"; "md5"; "/upload_offset"]], md5)]),
    "upload a file from the local machine with offset",
    "\
@@ -5939,7 +5964,7 @@ See also C<guestfs_upload>, C<guestfs_pwrite>.");
     [InitScratchFS, Always, TestOutput (
        (* Pick a file from cwd which isn't likely to change. *)
        [["mkdir"; "/download_offset"];
-        ["upload"; "../COPYING.LIB"; "/download_offset/COPYING.LIB"];
+        ["upload"; "../../COPYING.LIB"; "/download_offset/COPYING.LIB"];
         ["download_offset"; "/download_offset/COPYING.LIB"; "testdownload.tmp"; offset; size];
         ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING.LIB"; offset];
         ["checksum"; "md5"; "/download_offset/COPYING.LIB"]], md5)]),
@@ -6432,6 +6457,146 @@ To get the current values of filesystem parameters, see
 C<guestfs_tune2fs_l>.  For precise details of how tune2fs
 works, see the L<tune2fs(8)> man page.");
 
+  ("md_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
+   [],
+   "create a Linux md (RAID) device",
+   "\
+Create a Linux md (RAID) device named C<name> on the devices
+in the list C<devices>.
+
+The optional parameters are:
+
+=over 4
+
+=item C<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.
+
+As examples:
+
+If C<devices = [\"/dev/sda\"]> and C<missingbitmap = 0x1> then
+the resulting array would be C<[E<lt>missingE<gt>, \"/dev/sda\"]>.
+
+If C<devices = [\"/dev/sda\"]> and C<missingbitmap = 0x2> then
+the resulting array would be C<[\"/dev/sda\", E<lt>missingE<gt>]>.
+
+This defaults to C<0> (no missing devices).
+
+The length of C<devices> + the number of bits set in
+C<missingbitmap> must equal C<nrdevices> + C<spare>.
+
+=item C<nrdevices>
+
+The number of active RAID devices.
+
+If not set, this defaults to the length of C<devices> plus
+the number of bits set in C<missingbitmap>.
+
+=item C<spare>
+
+The number of spare devices.
+
+If not set, this defaults to C<0>.
+
+=item C<chunk>
+
+The chunk size in bytes.
+
+=item C<level>
+
+The RAID level, which can be one of:
+I<linear>, I<raid0>, I<0>, I<stripe>, I<raid1>, I<1>, I<mirror>,
+I<raid4>, I<4>, I<raid5>, I<5>, I<raid6>, I<6>, I<raid10>, I<10>.
+Some of these are synonymous, and more levels may be added in future.
+
+If not set, this defaults to C<raid1>.
+
+=back");
+
+  ("list_md_devices", (RStringList "devices", [], []), 300, [],
+   [],
+   "list Linux md (RAID) devices",
+   "\
+List all Linux md devices.");
+
+  ("md_detail", (RHashtable "info", [Device "md"], []), 301,  [Optional "mdadm"],
+   [],
+   "obtain metadata for an MD device",
+   "\
+This command exposes the output of 'mdadm -DY <md>'. The following fields are
+usually present in the returned hash. Other fields may also be present.
+
+=over
+
+=item C<level>
+
+The raid level of the MD device.
+
+=item C<devices>
+
+The number of underlying devices in the MD device.
+
+=item C<metadata>
+
+The metadata version used.
+
+=item C<uuid>
+
+The UUID of the MD device.
+
+=item C<name>
+
+The name of the MD device.
+
+=back");
+
+  ("md_stop", (RErr, [Device "md"], []), 302, [Optional "mdadm"],
+   [],
+   "stop a Linux md (RAID) device",
+   "\
+This command deactivates the MD array named C<md>.  The
+device is stopped, but it is not destroyed or zeroed.");
+
+  ("blkid", (RHashtable "info", [Device "device"], []), 303, [],
+   [InitScratchFS, Always, TestOutputHashtable (
+      [["blkid"; "/dev/sdb1"]],
+      ["TYPE", "ext2";
+       "USAGE", "filesystem";
+       "PART_ENTRY_NUMBER", "1";
+       "PART_ENTRY_TYPE", "0x83";
+       "PART_ENTRY_OFFSET", "128";
+       "PART_ENTRY_SIZE", "102145"])],
+   "print block device attributes",
+   "\
+This command returns block device attributes for C<device>. The following fields are
+usually present in the returned hash. Other fields may also be present.
+
+=over
+
+=item C<UUID>
+
+The uuid of this device.
+
+=item C<LABEL>
+
+The label of this device.
+
+=item C<VERSION>
+
+The version of blkid command.
+
+=item C<TYPE>
+
+The filesystem type or RAID of this device.
+
+=item C<USAGE>
+
+The usage of this device, for example C<filesystem> or C<raid>.
+
+=back");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
@@ -6510,6 +6675,16 @@ them with the help of L</glob> like this:
 
  glob copy-out /home/* .");
 
+  ("delete_event", (RErr,[], []), -1, [], [],
+   "delete a previously registered event handler",
+   " delete-event name
+
+Delete the event handler which was previously registered as C<name>.
+If multiple event handlers were registered with the same name, they
+are all deleted.
+
+See also the guestfish commands C<event> and C<list-events>.");
+
   ("display", (RErr,[], []), -1, [], [],
    "display an image",
    " display filename
@@ -6541,6 +6716,39 @@ The editor is C<$EDITOR>.  However if you use the alternate
 commands C<vi> or C<emacs> you will get those corresponding
 editors.");
 
+  ("event", (RErr,[], []), -1, [], [],
+   "register a handler for an event or events",
+   " event name eventset \"shell script ...\"
+
+Register a shell script fragment which is executed when an
+event is raised.  See L<guestfs(3)/guestfs_set_event_callback>
+for a discussion of the event API in libguestfs.
+
+The C<name> parameter is a name that you give to this event
+handler.  It can be any string (even the empty string) and is
+simply there so you can delete the handler using the guestfish
+C<delete-event> command.
+
+The C<eventset> parameter is a comma-separated list of one
+or more events, for example C<close> or C<close,trace>.  The
+special value C<*> means all events.
+
+The third and final parameter is the shell script fragment
+(or any external command) that is executed when any of the
+events in the eventset occurs.  It is executed using
+C<$SHELL -c>, or if C<$SHELL> is not set then C</bin/sh -c>.
+
+The shell script fragment receives callback parameters as
+arguments C<$1>, C<$2> etc.  The actual event that was
+called is available in the environment variable C<$EVENT>.
+
+ event \"\" close \"echo closed\"
+ event messages appliance,library,trace \"echo $@\"
+ event \"\" progress \"echo progress: $3/$4\"
+ event \"\" * \"echo $EVENT $@\"
+
+See also the guestfish commands C<delete-event> and C<list-events>.");
+
   ("glob", (RErr,[], []), -1, [], [],
    "expand wildcards in command",
    " glob command args...
@@ -6595,6 +6803,13 @@ itself.
 
 Note that C<!cd> won't do what you might expect.");
 
+  ("list_events", (RErr,[], []), -1, [], [],
+   "list event handlers",
+   " list-events
+
+List the event handlers registered using the guestfish
+C<event> command.");
+
   ("man", (RErr,[], []), -1, [FishAlias "manual"], [],
    "open the manual",
    "  man