generator: Put all the daemon procedure numbers (proc_nr) into a single table.

Daemon 'proc_nr's have to be assigned monotonically and uniquely to
each daemon function.  However in practice it can be difficult to work
out which is the next free proc_nr.  Placing all of them into a single
table in a new file (proc_nr.ml) should make this easier.
This commit is contained in:
Richard W.M. Jones
2017-02-21 10:58:41 +00:00
parent cf3001c2ed
commit 3a4a491712
16 changed files with 583 additions and 512 deletions

View File

@@ -349,7 +349,8 @@ To add a new API action there are two changes:
=item 1.
You need to add a description of the call (name, parameters, return
type, tests, documentation) to F<generator/actions_*.ml>.
type, tests, documentation) to F<generator/actions_*.ml> and
possibly F<generator/proc_nr.ml>.
There are two sorts of API action, depending on whether the call goes
through to the daemon in the appliance, or is serviced entirely by the

View File

@@ -93,6 +93,8 @@ sources = \
pr.mli \
prepopts.ml \
prepopts.mli \
proc_nr.ml \
proc_nr.mli \
python.ml \
python.mli \
ruby.ml \
@@ -116,6 +118,7 @@ objects = \
common_utils.cmo \
types.cmo \
utils.cmo \
proc_nr.cmo \
actions_augeas.cmo \
actions_core.cmo \
actions_core_deprecated.cmo \

View File

@@ -28,6 +28,7 @@ everything is exported.
Some notable files in this directory:
actions_*.ml The libguestfs API.
proc_nr.ml Procedure numbers associated with each API.
structs.ml Structures returned by the API.
c.ml Generate C API.
<lang>.ml Generate bindings for <lang>.

View File

@@ -187,7 +187,7 @@ let generate_xdr () =
pr "};\n";
pr "\n";
pr "const GUESTFS_MAX_PROC_NR = %d;\n" max_proc_nr;
pr "const GUESTFS_MAX_PROC_NR = %d;\n" Proc_nr.max_proc_nr;
pr "\n";
pr "/* The remote procedure call protocol. */\n";

View File

@@ -108,37 +108,43 @@ let non_daemon_functions, daemon_functions =
List.map make_camel_case_if_not_set daemon_functions in
non_daemon_functions, daemon_functions
(* Before we add the non_daemon_functions and daemon_functions to
* a single list, verify the proc_nr field which should be the only
* difference between them. (Note more detailed checking is done
* in checks.ml).
(* Verify that no proc_nr field is set. These are added from
* [proc_nr.ml] and must not be present in the [actions_*.ml] files.
*)
let () =
let check_no_proc_nr = function
| { proc_nr = None } -> ()
| { name = name; proc_nr = Some _ } ->
failwithf "definition of %s must not include proc_nr, use proc_nr.ml to define procedure numbers" name
in
List.iter check_no_proc_nr non_daemon_functions;
List.iter check_no_proc_nr daemon_functions
(* Now add proc_nr to all daemon functions using the mapping table
* from [proc_nr.ml].
*)
let daemon_functions =
let assoc =
let map = List.map (fun (nr, name) -> (name, nr)) Proc_nr.proc_nr in
fun name ->
try List.assoc name map
with Not_found ->
failwithf "no proc_nr listed for %s" name
in
List.map (
fun f -> { f with proc_nr = Some (assoc f.name) }
) daemon_functions
(* Check there are no entries in the proc_nr table which aren't
* associated with a daemon function.
*)
let () =
List.iter (
function
| { name = name; proc_nr = None } ->
failwithf "daemon function %s should have proc_nr = Some n > 0" name
| { name = name; proc_nr = Some n } when n <= 0 ->
failwithf "daemon function %s should have proc_nr = Some n > 0" name
| { proc_nr = Some _ } -> ()
) daemon_functions;
List.iter (
function
| { name = name; proc_nr = Some _ } ->
failwithf "non-daemon function %s should have proc_nr = None" name
| { proc_nr = None } -> ()
) non_daemon_functions
(* This is used to generate the lib/MAX_PROC_NR file which
* contains the maximum procedure number, a surrogate for the
* ABI version number. See lib/Makefile.am for the details.
*)
let max_proc_nr =
let proc_nrs = List.map (
function { proc_nr = Some n } -> n | { proc_nr = None } -> assert false
) daemon_functions in
List.fold_left max 0 proc_nrs
fun (_, name) ->
if not (List.exists (fun { name = n } -> name = n) daemon_functions) then
failwithf "proc_nr entry for %s does not correspond to a daemon function"
name
) Proc_nr.proc_nr
(* All functions. *)
let actions = non_daemon_functions @ daemon_functions

View File

@@ -52,7 +52,3 @@ val is_documented : Types.action -> bool
val test_functions : Types.action list
(** Internal test functions used to test the language bindings. *)
val max_proc_nr : int
(** The largest procedure number used (also saved in [lib/MAX_PROC_NR] and
used as the minor version number of the shared library). *)

View File

@@ -26,7 +26,6 @@ let daemon_functions = [
{ defaults with
name = "aug_init"; added = (0, 0, 7);
style = RErr, [Pathname "root"; Int "flags"], [];
proc_nr = Some 16;
tests = [
InitBasicFS, Always, TestResultString (
[["mkdir"; "/etc"];
@@ -91,7 +90,6 @@ To find out more about Augeas, see L<http://augeas.net/>." };
{ defaults with
name = "aug_close"; added = (0, 0, 7);
style = RErr, [], [];
proc_nr = Some 26;
shortdesc = "close the current Augeas handle";
longdesc = "\
Close the current Augeas handle and free up any resources
@@ -102,7 +100,6 @@ Augeas functions." };
{ defaults with
name = "aug_defvar"; added = (0, 0, 7);
style = RInt "nrnodes", [String "name"; OptString "expr"], [];
proc_nr = Some 17;
shortdesc = "define an Augeas variable";
longdesc = "\
Defines an Augeas variable C<name> whose value is the result
@@ -115,7 +112,6 @@ C<0> if C<expr> evaluates to something which is not a nodeset." };
{ defaults with
name = "aug_defnode"; added = (0, 0, 7);
style = RStruct ("nrnodescreated", "int_bool"), [String "name"; String "expr"; String "val"], [];
proc_nr = Some 18;
shortdesc = "define an Augeas node";
longdesc = "\
Defines a variable C<name> whose value is the result of
@@ -132,7 +128,6 @@ if a node was created." };
{ defaults with
name = "aug_get"; added = (0, 0, 7);
style = RString "val", [String "augpath"], [];
proc_nr = Some 19;
shortdesc = "look up the value of an Augeas path";
longdesc = "\
Look up the value associated with C<path>. If C<path>
@@ -141,7 +136,6 @@ matches exactly one node, the C<value> is returned." };
{ defaults with
name = "aug_set"; added = (0, 0, 7);
style = RErr, [String "augpath"; String "val"], [];
proc_nr = Some 20;
tests = [
InitBasicFS, Always, TestResultString (
[["mkdir"; "/etc"];
@@ -162,7 +156,6 @@ C<guestfs_aug_clear> call." };
{ defaults with
name = "aug_insert"; added = (0, 0, 7);
style = RErr, [String "augpath"; String "label"; Bool "before"], [];
proc_nr = Some 21;
tests = [
InitBasicFS, Always, TestResultString (
[["mkdir"; "/etc"];
@@ -189,7 +182,6 @@ with a bracketed index C<[N]>." };
{ defaults with
name = "aug_rm"; added = (0, 0, 7);
style = RInt "nrnodes", [String "augpath"], [];
proc_nr = Some 22;
shortdesc = "remove an Augeas path";
longdesc = "\
Remove C<path> and all of its children.
@@ -199,7 +191,6 @@ On success this returns the number of entries which were removed." };
{ defaults with
name = "aug_mv"; added = (0, 0, 7);
style = RErr, [String "src"; String "dest"], [];
proc_nr = Some 23;
shortdesc = "move Augeas node";
longdesc = "\
Move the node C<src> to C<dest>. C<src> must match exactly
@@ -208,7 +199,6 @@ one node. C<dest> is overwritten if it exists." };
{ defaults with
name = "aug_match"; added = (0, 0, 7);
style = RStringList "matches", [String "augpath"], [];
proc_nr = Some 24;
shortdesc = "return Augeas nodes which match augpath";
longdesc = "\
Returns a list of paths which match the path expression C<path>.
@@ -218,7 +208,6 @@ exactly one node in the current tree." };
{ defaults with
name = "aug_save"; added = (0, 0, 7);
style = RErr, [], [];
proc_nr = Some 25;
shortdesc = "write all pending Augeas changes to disk";
longdesc = "\
This writes all pending changes to disk.
@@ -229,7 +218,6 @@ how files are saved." };
{ defaults with
name = "aug_load"; added = (0, 0, 7);
style = RErr, [], [];
proc_nr = Some 27;
shortdesc = "load files into the tree";
longdesc = "\
Load files into the tree.
@@ -240,7 +228,6 @@ details." };
{ defaults with
name = "aug_ls"; added = (0, 0, 8);
style = RStringList "matches", [String "augpath"], [];
proc_nr = Some 28;
tests = [
InitBasicFS, Always, TestResult (
[["mkdir"; "/etc"];
@@ -257,7 +244,6 @@ C<path/*> and sorting the resulting nodes into alphabetical order." };
{ defaults with
name = "aug_clear"; added = (1, 3, 4);
style = RErr, [String "augpath"], [];
proc_nr = Some 239;
shortdesc = "clear Augeas path";
longdesc = "\
Set the value associated with C<path> to C<NULL>. This
@@ -266,7 +252,6 @@ is the same as the L<augtool(1)> C<clear> command." };
{ defaults with
name = "aug_transform"; added = (1, 35, 2);
style = RErr, [String "lens"; String "file"], [ OBool "remove"];
proc_nr = Some 469;
shortdesc = "add/remove an Augeas lens transformation";
longdesc = "\
Add an Augeas transformation for the specified C<lens> so it can

File diff suppressed because it is too large Load Diff

View File

@@ -113,7 +113,6 @@ let daemon_functions = [
style = RErr, [Device "device";
Int "cyls"; Int "heads"; Int "sectors";
StringList "lines"], [];
proc_nr = Some 43;
deprecated_by = Some "part_add";
shortdesc = "create partitions on a block device";
longdesc = "\
@@ -143,7 +142,6 @@ C<guestfs_part_init>" };
{ defaults with
name = "blockdev_setbsz"; added = (1, 9, 3);
style = RErr, [Device "device"; Int "blocksize"], [];
proc_nr = Some 61;
deprecated_by = Some "mkfs";
shortdesc = "set blocksize of block device";
longdesc = "\
@@ -156,7 +154,6 @@ C<blocksize> option of C<guestfs_mkfs>." };
{ defaults with
name = "tgz_in"; added = (1, 0, 3);
style = RErr, [FileIn "tarball"; Pathname "directory"], [];
proc_nr = Some 71;
deprecated_by = Some "tar_in";
cancellable = true;
tests = [
@@ -173,7 +170,6 @@ I<gzip compressed> tar file) into F<directory>." };
{ defaults with
name = "tgz_out"; added = (1, 0, 3);
style = RErr, [Pathname "directory"; FileOut "tarball"], [];
proc_nr = Some 72;
deprecated_by = Some "tar_out";
cancellable = true;
shortdesc = "pack directory into compressed tarball";
@@ -184,7 +180,6 @@ it to local file C<tarball>." };
{ defaults with
name = "set_e2label"; added = (1, 0, 15);
style = RErr, [Device "device"; String "label"], [];
proc_nr = Some 80;
deprecated_by = Some "set_label";
tests = [
InitBasicFS, Always, TestResultString (
@@ -203,7 +198,6 @@ to return the existing label on a filesystem." };
{ defaults with
name = "get_e2label"; added = (1, 0, 15);
style = RString "label", [Device "device"], [];
proc_nr = Some 81;
deprecated_by = Some "vfs_label";
shortdesc = "get the ext2/3/4 filesystem label";
longdesc = "\
@@ -213,7 +207,6 @@ C<device>." };
{ defaults with
name = "set_e2uuid"; added = (1, 0, 15);
style = RErr, [Device "device"; String "uuid"], [];
proc_nr = Some 82;
deprecated_by = Some "set_uuid";
tests = [
InitBasicFS, Always, TestResultString (
@@ -242,7 +235,6 @@ of a filesystem." };
{ defaults with
name = "get_e2uuid"; added = (1, 0, 15);
style = RString "uuid", [Device "device"], [];
proc_nr = Some 83;
deprecated_by = Some "vfs_uuid";
tests = [
(* We can't predict what UUID will be, so just check
@@ -261,7 +253,6 @@ C<device>." };
style = RErr, [Device "device"; Int "partnum";
Int "cyls"; Int "heads"; Int "sectors";
String "line"], [];
proc_nr = Some 99;
deprecated_by = Some "part_add";
shortdesc = "modify a single partition on a block device";
longdesc = "\
@@ -276,7 +267,6 @@ See also: C<guestfs_part_add>" };
{ defaults with
name = "sfdisk_l"; added = (1, 0, 26);
style = RString "partitions", [Device "device"], [];
proc_nr = Some 100;
deprecated_by = Some "part_list";
shortdesc = "display the partition table";
longdesc = "\
@@ -289,7 +279,6 @@ See also: C<guestfs_part_list>" };
{ defaults with
name = "e2fsck_f"; added = (1, 0, 29);
style = RErr, [Device "device"], [];
proc_nr = Some 108;
deprecated_by = Some "e2fsck";
shortdesc = "check an ext2/ext3 filesystem";
longdesc = "\
@@ -300,7 +289,6 @@ even if the filesystem appears to be clean (I<-f>)." };
{ defaults with
name = "mkswap_L"; added = (1, 0, 55);
style = RErr, [String "label"; Device "device"], [];
proc_nr = Some 131;
deprecated_by = Some "mkswap";
tests = [
InitEmpty, Always, TestRun (
@@ -318,7 +306,6 @@ a limitation of the kernel or swap tools." };
{ defaults with
name = "mkswap_U"; added = (1, 0, 55);
style = RErr, [String "uuid"; Device "device"], [];
proc_nr = Some 132;
deprecated_by = Some "mkswap";
optional = Some "linuxfsuuid";
tests = [
@@ -333,7 +320,6 @@ Create a swap partition on C<device> with UUID C<uuid>." };
{ defaults with
name = "sfdiskM"; added = (1, 0, 55);
style = RErr, [Device "device"; StringList "lines"], [];
proc_nr = Some 139;
deprecated_by = Some "part_add";
shortdesc = "create partitions on a block device";
longdesc = "\
@@ -349,7 +335,6 @@ and C<guestfs_part_disk>" };
{ defaults with
name = "zfile"; added = (1, 0, 59);
style = RString "description", [String "meth"; Pathname "path"], [];
proc_nr = Some 140;
deprecated_by = Some "file";
shortdesc = "determine file type inside a compressed file";
longdesc = "\
@@ -364,7 +349,6 @@ process compressed files." };
{ defaults with
name = "egrep"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 152;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -380,7 +364,6 @@ matching lines." };
{ defaults with
name = "fgrep"; added = (1, 0, 66);
style = RStringList "lines", [String "pattern"; Pathname "path"], [];
proc_nr = Some 153;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -396,7 +379,6 @@ matching lines." };
{ defaults with
name = "grepi"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 154;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -412,7 +394,6 @@ matching lines." };
{ defaults with
name = "egrepi"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 155;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -428,7 +409,6 @@ matching lines." };
{ defaults with
name = "fgrepi"; added = (1, 0, 66);
style = RStringList "lines", [String "pattern"; Pathname "path"], [];
proc_nr = Some 156;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -444,7 +424,6 @@ matching lines." };
{ defaults with
name = "zgrep"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 157;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -460,7 +439,6 @@ matching lines." };
{ defaults with
name = "zegrep"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 158;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -476,7 +454,6 @@ matching lines." };
{ defaults with
name = "zfgrep"; added = (1, 0, 66);
style = RStringList "lines", [String "pattern"; Pathname "path"], [];
proc_nr = Some 159;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -492,7 +469,7 @@ matching lines." };
{ defaults with
name = "zgrepi"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 160;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -508,7 +485,6 @@ matching lines." };
{ defaults with
name = "zegrepi"; added = (1, 0, 66);
style = RStringList "lines", [String "regex"; Pathname "path"], [];
proc_nr = Some 161;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -524,7 +500,6 @@ matching lines." };
{ defaults with
name = "zfgrepi"; added = (1, 0, 66);
style = RStringList "lines", [String "pattern"; Pathname "path"], [];
proc_nr = Some 162;
protocol_limit_warning = true;
deprecated_by = Some "grep";
tests = [
@@ -540,7 +515,6 @@ matching lines." };
{ defaults with
name = "fallocate"; added = (1, 0, 66);
style = RErr, [Pathname "path"; Int "len"], [];
proc_nr = Some 169;
deprecated_by = Some "fallocate64";
tests = [
InitScratchFS, Always, TestResult (
@@ -560,7 +534,6 @@ attaches it as a device." };
{ defaults with
name = "setcon"; added = (1, 0, 67);
style = RErr, [String "context"], [];
proc_nr = Some 185;
optional = Some "selinux";
deprecated_by = Some "selinux_relabel";
shortdesc = "set SELinux security context";
@@ -573,7 +546,6 @@ See the documentation about SELINUX in L<guestfs(3)>." };
{ defaults with
name = "getcon"; added = (1, 0, 67);
style = RString "context", [], [];
proc_nr = Some 186;
optional = Some "selinux";
deprecated_by = Some "selinux_relabel";
shortdesc = "get SELinux security context";
@@ -586,7 +558,6 @@ and C<guestfs_setcon>" };
{ defaults with
name = "mkfs_b"; added = (1, 0, 68);
style = RErr, [String "fstype"; Int "blocksize"; Device "device"], [];
proc_nr = Some 187;
deprecated_by = Some "mkfs";
tests = [
InitEmpty, Always, TestResultString (
@@ -624,7 +595,6 @@ the requested cluster size." };
{ defaults with
name = "mke2journal"; added = (1, 0, 68);
style = RErr, [Int "blocksize"; Device "device"], [];
proc_nr = Some 188;
deprecated_by = Some "mke2fs";
tests = [
InitEmpty, Always, TestResultString (
@@ -647,7 +617,6 @@ to the command:
{ defaults with
name = "mke2journal_L"; added = (1, 0, 68);
style = RErr, [Int "blocksize"; String "label"; Device "device"], [];
proc_nr = Some 189;
deprecated_by = Some "mke2fs";
tests = [
InitEmpty, Always, TestResultString (
@@ -667,7 +636,6 @@ This creates an ext2 external journal on C<device> with label C<label>." };
{ defaults with
name = "mke2journal_U"; added = (1, 0, 68);
style = RErr, [Int "blocksize"; String "uuid"; Device "device"], [];
proc_nr = Some 190;
deprecated_by = Some "mke2fs";
optional = Some "linuxfsuuid";
tests = [
@@ -688,7 +656,6 @@ This creates an ext2 external journal on C<device> with UUID C<uuid>." };
{ defaults with
name = "mke2fs_J"; added = (1, 0, 68);
style = RErr, [String "fstype"; Int "blocksize"; Device "device"; Device "journal"], [];
proc_nr = Some 191;
deprecated_by = Some "mke2fs";
shortdesc = "make ext2/3/4 filesystem with external journal";
longdesc = "\
@@ -703,7 +670,6 @@ See also C<guestfs_mke2journal>." };
{ defaults with
name = "mke2fs_JL"; added = (1, 0, 68);
style = RErr, [String "fstype"; Int "blocksize"; Device "device"; String "label"], [];
proc_nr = Some 192;
deprecated_by = Some "mke2fs";
shortdesc = "make ext2/3/4 filesystem with external journal";
longdesc = "\
@@ -715,7 +681,6 @@ See also C<guestfs_mke2journal_L>." };
{ defaults with
name = "mke2fs_JU"; added = (1, 0, 68);
style = RErr, [String "fstype"; Int "blocksize"; Device "device"; String "uuid"], [];
proc_nr = Some 193;
deprecated_by = Some "mke2fs";
optional = Some "linuxfsuuid";
shortdesc = "make ext2/3/4 filesystem with external journal";
@@ -728,7 +693,6 @@ See also C<guestfs_mke2journal_U>." };
{ defaults with
name = "dd"; added = (1, 0, 80);
style = RErr, [Dev_or_Path "src"; Dev_or_Path "dest"], [];
proc_nr = Some 217;
deprecated_by = Some "copy_device_to_device";
tests = [
InitScratchFS, Always, TestResult (
@@ -753,7 +717,6 @@ This command cannot do partial copies
{ defaults with
name = "txz_in"; added = (1, 3, 2);
style = RErr, [FileIn "tarball"; Pathname "directory"], [];
proc_nr = Some 229;
deprecated_by = Some "tar_in";
optional = Some "xz"; cancellable = true;
tests = [
@@ -770,7 +733,6 @@ I<xz compressed> tar file) into F<directory>." };
{ defaults with
name = "txz_out"; added = (1, 3, 2);
style = RErr, [Pathname "directory"; FileOut "tarball"], [];
proc_nr = Some 230;
deprecated_by = Some "tar_out";
optional = Some "xz"; cancellable = true;
shortdesc = "pack directory into compressed tarball";
@@ -781,7 +743,6 @@ it to local file C<tarball> (as an xz compressed tar archive)." };
{ defaults with
name = "llz"; added = (1, 17, 6);
style = RString "listing", [Pathname "directory"], [];
proc_nr = Some 305;
deprecated_by = Some "lgetxattrs";
shortdesc = "list the files in a directory (long format with SELinux contexts)";
longdesc = "\

View File

@@ -39,7 +39,6 @@ let daemon_functions = [
{ defaults with
name = "debug"; added = (1, 0, 11);
style = RString "result", [String "subcmd"; StringList "extraargs"], [];
proc_nr = Some 76;
visibility = VDebug;
shortdesc = "debugging and internals";
longdesc = "\
@@ -54,7 +53,6 @@ to find out what you can do." };
{ defaults with
name = "debug_upload"; added = (1, 3, 5);
style = RErr, [FileIn "filename"; String "tmpname"; Int "mode"], [];
proc_nr = Some 241;
visibility = VDebug;
cancellable = true;
shortdesc = "upload a file to the appliance (internal use only)";

View File

@@ -45,7 +45,6 @@ let daemon_functions = [
{ defaults with
name = "hivex_open"; added = (1, 19, 35);
style = RErr, [Pathname "filename"], [OBool "verbose"; OBool "debug"; OBool "write"; OBool "unsafe"];
proc_nr = Some 350;
optional = Some "hivex";
tests = [
InitScratchFS, Always, TestRun (
@@ -67,7 +66,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_close"; added = (1, 19, 35);
style = RErr, [], [];
proc_nr = Some 351;
optional = Some "hivex";
shortdesc = "close the current hivex handle";
longdesc = "\
@@ -78,7 +76,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_root"; added = (1, 19, 35);
style = RInt64 "nodeh", [], [];
proc_nr = Some 352;
optional = Some "hivex";
shortdesc = "return the root node of the hive";
longdesc = "\
@@ -89,7 +86,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_name"; added = (1, 19, 35);
style = RString "name", [Int64 "nodeh"], [];
proc_nr = Some 353;
optional = Some "hivex";
shortdesc = "return the name of the node";
longdesc = "\
@@ -100,7 +96,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_children"; added = (1, 19, 35);
style = RStructList ("nodehs", "hivex_node"), [Int64 "nodeh"], [];
proc_nr = Some 354;
optional = Some "hivex";
shortdesc = "return list of nodes which are subkeys of node";
longdesc = "\
@@ -111,7 +106,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_get_child"; added = (1, 19, 35);
style = RInt64 "child", [Int64 "nodeh"; String "name"], [];
proc_nr = Some 355;
optional = Some "hivex";
shortdesc = "return the named child of node";
longdesc = "\
@@ -123,7 +117,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_parent"; added = (1, 19, 35);
style = RInt64 "parent", [Int64 "nodeh"], [];
proc_nr = Some 356;
optional = Some "hivex";
shortdesc = "return the parent of node";
longdesc = "\
@@ -134,7 +127,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_values"; added = (1, 19, 35);
style = RStructList ("valuehs", "hivex_value"), [Int64 "nodeh"], [];
proc_nr = Some 357;
optional = Some "hivex";
shortdesc = "return list of values attached to node";
longdesc = "\
@@ -145,7 +137,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_get_value"; added = (1, 19, 35);
style = RInt64 "valueh", [Int64 "nodeh"; String "key"], [];
proc_nr = Some 358;
optional = Some "hivex";
shortdesc = "return the named value";
longdesc = "\
@@ -158,7 +149,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_value_key"; added = (1, 19, 35);
style = RString "key", [Int64 "valueh"], [];
proc_nr = Some 359;
optional = Some "hivex";
shortdesc = "return the key field from the (key, datatype, data) tuple";
longdesc = "\
@@ -169,7 +159,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_value_type"; added = (1, 19, 35);
style = RInt64 "datatype", [Int64 "valueh"], [];
proc_nr = Some 360;
optional = Some "hivex";
shortdesc = "return the data type from the (key, datatype, data) tuple";
longdesc = "\
@@ -180,7 +169,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_value_value"; added = (1, 19, 35);
style = RBufferOut "databuf", [Int64 "valueh"], [];
proc_nr = Some 361;
optional = Some "hivex";
shortdesc = "return the data field from the (key, datatype, data) tuple";
longdesc = "\
@@ -193,7 +181,6 @@ See also: C<guestfs_hivex_value_utf8>." };
{ defaults with
name = "hivex_commit"; added = (1, 19, 35);
style = RErr, [OptString "filename"], [];
proc_nr = Some 362;
optional = Some "hivex";
tests = [
InitScratchFS, Always, TestRun (
@@ -220,7 +207,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_add_child"; added = (1, 19, 35);
style = RInt64 "nodeh", [Int64 "parent"; String "name"], [];
proc_nr = Some 363;
optional = Some "hivex";
shortdesc = "add a child node";
longdesc = "\
@@ -231,7 +217,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_delete_child"; added = (1, 19, 35);
style = RErr, [Int64 "nodeh"], [];
proc_nr = Some 364;
optional = Some "hivex";
shortdesc = "delete a node (recursively)";
longdesc = "\
@@ -242,7 +227,6 @@ This is a wrapper around the L<hivex(3)> call of the same name." };
{ defaults with
name = "hivex_node_set_value"; added = (1, 19, 35);
style = RErr, [Int64 "nodeh"; String "key"; Int64 "t"; BufferIn "val"], [];
proc_nr = Some 365;
optional = Some "hivex";
shortdesc = "set or replace a single value in a node";
longdesc = "\

View File

@@ -189,7 +189,6 @@ let daemon_functions = [
{ defaults with
name = "download_inode"; added = (1, 33, 14);
style = RErr, [Mountable "device"; Int64 "inode"; FileOut "filename"], [];
proc_nr = Some 464;
optional = Some "sleuthkit";
progress = true; cancellable = true;
shortdesc = "download a file to the local machine given its inode";
@@ -204,7 +203,6 @@ The command is capable of downloading deleted or inaccessible files." };
{ defaults with
name = "internal_filesystem_walk"; added = (1, 33, 39);
style = RErr, [Mountable "device"; FileOut "filename"], [];
proc_nr = Some 466;
visibility = VInternal;
optional = Some "libtsk";
shortdesc = "walk through the filesystem content";
@@ -213,7 +211,6 @@ The command is capable of downloading deleted or inaccessible files." };
{ defaults with
name = "download_blocks"; added = (1, 33, 45);
style = RErr, [Mountable "device"; Int64 "start"; Int64 "stop"; FileOut "filename"], [OBool "unallocated"];
proc_nr = Some 468;
optional = Some "sleuthkit";
progress = true; cancellable = true;
shortdesc = "download the given data units from the disk";
@@ -237,7 +234,6 @@ which data units have not been overwritten yet." };
{ defaults with
name = "internal_find_inode"; added = (1, 35, 6);
style = RErr, [Mountable "device"; Int64 "inode"; FileOut "filename";], [];
proc_nr = Some 470;
visibility = VInternal;
optional = Some "libtsk";
shortdesc = "search the entries associated to the given inode";

View File

@@ -2367,4 +2367,4 @@ and generate_linker_script () =
pr "};\n"
and generate_max_proc_nr () =
pr "%d\n" max_proc_nr
pr "%d\n" Proc_nr.max_proc_nr

View File

@@ -173,26 +173,6 @@ let () =
failwithf "long description of %s should begin with uppercase." name
) (actions @ fish_commands);
(* Check proc_nrs don't overlap. *)
let proc_nrs =
List.map (
function
| { name = name; proc_nr = Some proc_nr } -> (name, proc_nr)
| _ -> assert false
) (actions |> daemon_functions) in
let proc_nrs =
List.sort (fun (_,nr1) (_,nr2) -> compare nr1 nr2) proc_nrs in
let rec loop = function
| [] -> ()
| [_] -> ()
| (name1,nr1) :: ((name2,nr2) :: _ as rest) when nr1 < nr2 ->
loop rest
| (name1,nr1) :: (name2,nr2) :: _ ->
failwithf "%s and %s have conflicting procedure numbers (%d, %d)"
name1 name2 nr1 nr2
in
loop proc_nrs;
(* Check flags. *)
List.iter (
fun ({ name = name; style = ret, _, _ } as f) ->

515
generator/proc_nr.ml Normal file
View File

@@ -0,0 +1,515 @@
(* libguestfs
* Copyright (C) 2009-2017 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
(* Please read generator/README first. *)
(* Each daemon function must have a unique procedure number. Add
* new functions at the end.
*)
let proc_nr = [
1, "mount";
2, "sync";
3, "touch";
5, "ll";
7, "list_devices";
8, "list_partitions";
9, "pvs";
10, "vgs";
11, "lvs";
12, "pvs_full";
13, "vgs_full";
14, "lvs_full";
16, "aug_init";
17, "aug_defvar";
18, "aug_defnode";
19, "aug_get";
20, "aug_set";
21, "aug_insert";
22, "aug_rm";
23, "aug_mv";
24, "aug_match";
25, "aug_save";
26, "aug_close";
27, "aug_load";
28, "aug_ls";
29, "rm";
30, "rmdir";
31, "rm_rf";
32, "mkdir";
33, "mkdir_p";
34, "chmod";
35, "chown";
36, "exists";
37, "is_file";
38, "is_dir";
39, "pvcreate";
40, "vgcreate";
41, "lvcreate";
43, "sfdisk";
44, "write_file";
45, "umount";
46, "mounts";
47, "umount_all";
48, "lvm_remove_all";
49, "file";
50, "command";
51, "command_lines";
54, "statvfs";
55, "tune2fs_l";
56, "blockdev_setro";
57, "blockdev_setrw";
58, "blockdev_getro";
59, "blockdev_getss";
60, "blockdev_getbsz";
61, "blockdev_setbsz";
62, "blockdev_getsz";
63, "blockdev_getsize64";
64, "blockdev_flushbufs";
65, "blockdev_rereadpt";
66, "upload";
67, "download";
68, "checksum";
69, "tar_in";
70, "tar_out";
71, "tgz_in";
72, "tgz_out";
73, "mount_ro";
74, "mount_options";
75, "mount_vfs";
76, "debug";
77, "lvremove";
78, "vgremove";
79, "pvremove";
80, "set_e2label";
81, "get_e2label";
82, "set_e2uuid";
83, "get_e2uuid";
84, "fsck";
85, "zero";
86, "grub_install";
87, "cp";
88, "cp_a";
89, "mv";
90, "drop_caches";
91, "dmesg";
92, "ping_daemon";
93, "equal";
94, "strings";
95, "strings_e";
96, "hexdump";
97, "zerofree";
98, "pvresize";
99, "sfdisk_N";
100, "sfdisk_l";
101, "sfdisk_kernel_geometry";
102, "sfdisk_disk_geometry";
103, "vg_activate_all";
104, "vg_activate";
105, "lvresize";
106, "resize2fs";
108, "e2fsck_f";
109, "sleep";
110, "ntfs_3g_probe";
111, "sh";
112, "sh_lines";
113, "glob_expand";
114, "scrub_device";
115, "scrub_file";
116, "scrub_freespace";
117, "mkdtemp";
118, "wc_l";
119, "wc_w";
120, "wc_c";
121, "head";
122, "head_n";
123, "tail";
124, "tail_n";
125, "df";
126, "df_h";
127, "du";
128, "initrd_list";
129, "mount_loop";
130, "mkswap";
131, "mkswap_L";
132, "mkswap_U";
133, "mknod";
134, "mkfifo";
135, "mknod_b";
136, "mknod_c";
137, "umask";
138, "readdir";
139, "sfdiskM";
140, "zfile";
141, "getxattrs";
142, "lgetxattrs";
143, "setxattr";
144, "lsetxattr";
145, "removexattr";
146, "lremovexattr";
147, "mountpoints";
148, "mkmountpoint";
149, "rmmountpoint";
151, "grep";
152, "egrep";
153, "fgrep";
154, "grepi";
155, "egrepi";
156, "fgrepi";
157, "zgrep";
158, "zegrep";
159, "zfgrep";
160, "zgrepi";
161, "zegrepi";
162, "zfgrepi";
163, "realpath";
164, "ln";
165, "ln_f";
166, "ln_s";
167, "ln_sf";
168, "readlink";
169, "fallocate";
170, "swapon_device";
171, "swapoff_device";
172, "swapon_file";
173, "swapoff_file";
174, "swapon_label";
175, "swapoff_label";
176, "swapon_uuid";
177, "swapoff_uuid";
178, "mkswap_file";
179, "inotify_init";
180, "inotify_add_watch";
181, "inotify_rm_watch";
182, "inotify_read";
183, "inotify_files";
184, "inotify_close";
185, "setcon";
186, "getcon";
187, "mkfs_b";
188, "mke2journal";
189, "mke2journal_L";
190, "mke2journal_U";
191, "mke2fs_J";
192, "mke2fs_JL";
193, "mke2fs_JU";
194, "modprobe";
195, "echo_daemon";
196, "find0";
197, "case_sensitive_path";
198, "vfs_type";
199, "truncate";
200, "truncate_size";
201, "utimens";
202, "mkdir_mode";
203, "lchown";
205, "internal_lxattrlist";
206, "internal_readlinklist";
207, "pread";
208, "part_init";
209, "part_add";
210, "part_disk";
211, "part_set_bootable";
212, "part_set_name";
213, "part_list";
214, "part_get_parttype";
215, "fill";
217, "dd";
218, "filesize";
219, "lvrename";
220, "vgrename";
221, "initrd_cat";
222, "pvuuid";
223, "vguuid";
224, "lvuuid";
225, "vgpvuuids";
226, "vglvuuids";
227, "copy_size";
228, "zero_device";
229, "txz_in";
230, "txz_out";
232, "vgscan";
233, "part_del";
234, "part_get_bootable";
235, "part_get_mbr_id";
236, "part_set_mbr_id";
237, "checksum_device";
238, "lvresize_free";
239, "aug_clear";
240, "get_umask";
241, "debug_upload";
242, "base64_in";
243, "base64_out";
244, "checksums_out";
245, "fill_pattern";
246, "internal_write";
247, "pwrite";
248, "resize2fs_size";
249, "pvresize_size";
250, "ntfsresize_size";
251, "available_all_groups";
252, "fallocate64";
253, "vfs_label";
254, "vfs_uuid";
255, "lvm_set_filter";
256, "lvm_clear_filter";
257, "luks_open";
258, "luks_open_ro";
259, "luks_close";
260, "luks_format";
261, "luks_format_cipher";
262, "luks_add_key";
263, "luks_kill_slot";
264, "is_lv";
265, "findfs_uuid";
266, "findfs_label";
267, "is_chardev";
268, "is_blockdev";
269, "is_fifo";
270, "is_symlink";
271, "is_socket";
272, "part_to_dev";
273, "upload_offset";
274, "download_offset";
275, "pwrite_device";
276, "pread_device";
277, "lvm_canonical_lv_name";
278, "mkfs";
279, "getxattr";
280, "lgetxattr";
281, "resize2fs_M";
282, "internal_autosync";
283, "is_zero";
284, "is_zero_device";
285, "list_9p";
286, "mount_9p";
287, "list_dm_devices";
288, "ntfsresize";
289, "btrfs_filesystem_resize";
290, "internal_write_append";
291, "compress_out";
292, "compress_device_out";
293, "part_to_partnum";
294, "copy_device_to_device";
295, "copy_device_to_file";
296, "copy_file_to_device";
297, "copy_file_to_file";
298, "tune2fs";
299, "md_create";
300, "list_md_devices";
301, "md_detail";
302, "md_stop";
303, "blkid";
304, "e2fsck";
305, "llz";
306, "wipefs";
307, "ntfsfix";
308, "ntfsclone_out";
309, "ntfsclone_in";
310, "set_label";
311, "zero_free_space";
312, "lvcreate_free";
313, "isoinfo_device";
314, "isoinfo";
315, "vgmeta";
316, "md_stat";
317, "mkfs_btrfs";
318, "get_e2attrs";
319, "set_e2attrs";
320, "get_e2generation";
321, "set_e2generation";
322, "btrfs_subvolume_snapshot";
323, "btrfs_subvolume_delete";
324, "btrfs_subvolume_create";
325, "btrfs_subvolume_list";
326, "btrfs_subvolume_set_default";
327, "btrfs_filesystem_sync";
328, "btrfs_filesystem_balance";
329, "btrfs_device_add";
330, "btrfs_device_delete";
331, "btrfs_set_seeding";
332, "btrfs_fsck";
333, "filesystem_available";
334, "fstrim";
335, "device_index";
336, "nr_devices";
337, "xfs_info";
338, "pvchange_uuid";
339, "pvchange_uuid_all";
340, "vgchange_uuid";
341, "vgchange_uuid_all";
342, "utsname";
343, "xfs_growfs";
344, "rsync";
345, "rsync_in";
346, "rsync_out";
347, "ls0";
348, "fill_dir";
349, "xfs_admin";
350, "hivex_open";
351, "hivex_close";
352, "hivex_root";
353, "hivex_node_name";
354, "hivex_node_children";
355, "hivex_node_get_child";
356, "hivex_node_parent";
357, "hivex_node_values";
358, "hivex_node_get_value";
359, "hivex_value_key";
360, "hivex_value_type";
361, "hivex_value_value";
362, "hivex_commit";
363, "hivex_node_add_child";
364, "hivex_node_delete_child";
365, "hivex_node_set_value";
366, "xfs_repair";
367, "rm_f";
368, "mke2fs";
369, "list_disk_labels";
370, "internal_hot_add_drive";
371, "internal_hot_remove_drive_precheck";
372, "internal_hot_remove_drive";
373, "mktemp";
374, "mklost_and_found";
375, "acl_get_file";
376, "acl_set_file";
377, "acl_delete_def_file";
378, "cap_get_file";
379, "cap_set_file";
380, "list_ldm_volumes";
381, "list_ldm_partitions";
382, "ldmtool_create_all";
383, "ldmtool_remove_all";
384, "ldmtool_scan";
385, "ldmtool_scan_devices";
386, "ldmtool_diskgroup_name";
387, "ldmtool_diskgroup_volumes";
388, "ldmtool_diskgroup_disks";
389, "ldmtool_volume_type";
390, "ldmtool_volume_hint";
391, "ldmtool_volume_partitions";
392, "part_set_gpt_type";
393, "part_get_gpt_type";
394, "rename";
395, "is_whole_device";
396, "internal_parse_mountable";
397, "internal_rhbz914931";
399, "syslinux";
400, "extlinux";
401, "cp_r";
402, "remount";
403, "set_uuid";
404, "journal_open";
405, "journal_close";
406, "journal_next";
407, "journal_skip";
408, "internal_journal_get";
409, "journal_get_data_threshold";
410, "journal_set_data_threshold";
411, "aug_setm";
412, "aug_label";
413, "internal_upload";
414, "internal_exit";
415, "copy_attributes";
416, "part_get_name";
417, "blkdiscard";
418, "blkdiscardzeroes";
419, "cpio_out";
420, "journal_get_realtime_usec";
421, "statns";
422, "lstatns";
423, "internal_lstatnslist";
424, "blockdev_setra";
425, "btrfs_subvolume_get_default";
426, "btrfs_subvolume_show";
427, "btrfs_quota_enable";
428, "btrfs_quota_rescan";
429, "btrfs_qgroup_limit";
430, "btrfs_qgroup_create";
431, "btrfs_qgroup_destroy";
432, "btrfs_qgroup_show";
433, "btrfs_qgroup_assign";
434, "btrfs_qgroup_remove";
435, "btrfs_scrub_start";
436, "btrfs_scrub_cancel";
437, "btrfs_scrub_resume";
438, "btrfs_balance_pause";
439, "btrfs_balance_cancel";
440, "btrfs_balance_resume";
443, "btrfs_filesystem_defragment";
444, "btrfs_rescue_chunk_recover";
445, "btrfs_rescue_super_recover";
446, "part_set_gpt_guid";
447, "part_get_gpt_guid";
448, "btrfs_balance_status";
449, "btrfs_scrub_status";
450, "btrfstune_seeding";
451, "btrfstune_enable_extended_inode_refs";
452, "btrfstune_enable_skinny_metadata_extent_refs";
453, "btrfs_image";
454, "part_get_mbr_part_type";
455, "btrfs_replace";
456, "set_uuid_random";
457, "vfs_minimum_size";
458, "internal_feature_available";
459, "part_set_disk_guid";
460, "part_get_disk_guid";
461, "part_set_disk_guid_random";
462, "part_expand_gpt";
463, "ntfscat_i";
464, "download_inode";
465, "btrfs_filesystem_show";
466, "internal_filesystem_walk";
467, "selinux_relabel";
468, "download_blocks";
469, "aug_transform";
470, "internal_find_inode";
471, "mksquashfs";
]
(* End of list. If adding a new entry, add it at the end of the list
* above. Do not modify anything below this line.
*----------------------------------------------------------------------
*)
let max_proc_nr =
(* Checks the list of procedure numbers is monotonically increasing,
* which guarantees there are no duplicates.
*)
let v = ref (fst (List.hd proc_nr) - 1) in
List.iter (
fun (v', _) ->
if !v >= v' then
failwith "proc_nr.ml: list of procedure numbers is not monotonically increasing";
v := v'
) proc_nr;
(* This is used to generate the lib/MAX_PROC_NR file which
* contains the maximum procedure number, a surrogate for the
* ABI version number. See lib/Makefile.am for the details.
*)
!v
let () =
(* Check there are no duplicate names. *)
let h = Hashtbl.create (List.length proc_nr) in
List.iter (
fun (_, name) ->
if Hashtbl.mem h name then
failwith "proc_nr.ml: duplicate name in procedure table";
Hashtbl.add h name true
) proc_nr

25
generator/proc_nr.mli Normal file
View File

@@ -0,0 +1,25 @@
(* libguestfs
* Copyright (C) 2009-2017 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
val proc_nr : (int * string) list
(** The mapping of function names to procedure numbers, used for
daemon functions only. *)
val max_proc_nr : int
(** The largest procedure number used (also saved in [lib/MAX_PROC_NR] and
used as the minor version number of the shared library). *)