X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Fgenerator.ml;h=9393bdec725f143883c6a7e9d07f4069d164617c;hb=dd922bedb7c3e85fbbe1eed10e371aec47138a1d;hp=691cf606ab79142a17adb8837e39f5f9959a328b;hpb=9b41eeb91733ee681a6a804464b6930d42ed8fd1;p=libguestfs.git diff --git a/src/generator.ml b/src/generator.ml index 691cf60..9393bde 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3560,6 +3560,15 @@ an external journal on the journal with UUID C. See also C."); + ("modprobe", (RErr, [String "module"]), 194, [], + [InitNone, Always, TestRun [["modprobe"; "ext2"]]], + "load a kernel module", + "\ +This loads a kernel module in the appliance. + +The kernel module must have been whitelisted when libguestfs +was built (see C in the source)."); + ] let all_functions = non_daemon_functions @ daemon_functions @@ -3822,6 +3831,10 @@ let pod2text_memo : ((int * string * string), string list) Hashtbl.t = v with _ -> Hashtbl.create 13 +let pod2text_memo_updated () = + let chan = open_out pod2text_memo_filename in + output_value chan pod2text_memo; + close_out chan (* Useful functions. * Note we don't want to use any external OCaml libraries which @@ -4528,7 +4541,7 @@ and generate_client_actions () = static int check_reply_header (guestfs_h *g, const struct guestfs_message_header *hdr, - int proc_nr, int serial) + unsigned int proc_nr, unsigned int serial) { if (hdr->prog != GUESTFS_PROGRAM) { error (g, \"wrong program (%%d/%%d)\", hdr->prog, GUESTFS_PROGRAM); @@ -5274,7 +5287,7 @@ static void print_error (guestfs_h *g, void *data, const char *msg) } /* FIXME: nearly identical code appears in fish.c */ -static void print_strings (char const *const *argv) +static void print_strings (char *const *argv) { int argc; @@ -5869,7 +5882,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = fun i str -> pr " const char *%s_%d = \"%s\";\n" n i (c_quote str); ) strs; - pr " const char *%s[] = {\n" n; + pr " const char *const %s[] = {\n" n; iteri ( fun i _ -> pr " %s_%d,\n" n i ) strs; @@ -5912,7 +5925,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = | FileIn _, arg | FileOut _, arg -> pr ", \"%s\"" (c_quote arg) | StringList n, _ | DeviceList n, _ -> - pr ", %s" n + pr ", (char **) %s" n | Int _, arg -> let i = try int_of_string arg @@ -6063,6 +6076,21 @@ and generate_fish_cmds () = pr "}\n"; pr "\n"; + let emit_print_list_function typ = + pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n" + typ typ typ; + pr "{\n"; + pr " int i;\n"; + pr "\n"; + pr " for (i = 0; i < %ss->len; ++i) {\n" typ; + pr " printf (\"[%%d] = {\\n\", i);\n"; + pr " print_%s_indent (&%ss->val[i], \" \");\n" typ typ; + pr " printf (\"}\\n\");\n"; + pr " }\n"; + pr "}\n"; + pr "\n"; + in + (* print_* functions *) List.iter ( fun (typ, cols) -> @@ -6114,25 +6142,29 @@ and generate_fish_cmds () = ) cols; pr "}\n"; pr "\n"; - pr "static void print_%s (struct guestfs_%s *%s)\n" typ typ typ; - pr "{\n"; - pr " print_%s_indent (%s, \"\");\n" typ typ; - pr "}\n"; - pr "\n"; - pr "static void print_%s_list (struct guestfs_%s_list *%ss)\n" - typ typ typ; - pr "{\n"; - pr " int i;\n"; - pr "\n"; - pr " for (i = 0; i < %ss->len; ++i) {\n" typ; - pr " printf (\"[%%d] = {\\n\", i);\n"; - pr " print_%s_indent (&%ss->val[i], \" \");\n" typ typ; - pr " printf (\"}\\n\");\n"; - pr " }\n"; - pr "}\n"; - pr "\n"; ) structs; + (* Emit a print_TYPE_list function definition only if that function is used. *) + List.iter ( + function + | typ, (RStructListOnly | RStructAndList) -> + (* generate the function for typ *) + emit_print_list_function typ + | typ, _ -> () (* empty *) + ) rstructs_used; + + (* Emit a print_TYPE function definition only if that function is used. *) + List.iter ( + function + | typ, RStructOnly -> + pr "static void print_%s (struct guestfs_%s *%s)\n" typ typ typ; + pr "{\n"; + pr " print_%s_indent (%s, \"\");\n" typ typ; + pr "}\n"; + pr "\n"; + | typ, _ -> () (* empty *) + ) rstructs_used; + (* run_ actions *) List.iter ( fun (name, style, _, flags, _, _, _) -> @@ -7953,9 +7985,7 @@ and pod2text ~width name longdesc = failwithf "pod2text: process signalled or stopped by signal %d" i ); Hashtbl.add pod2text_memo key lines; - let chan = open_out pod2text_memo_filename in - output_value chan pod2text_memo; - close_out chan; + pod2text_memo_updated (); lines (* Generate ruby bindings. *) @@ -8588,7 +8618,10 @@ Java_com_redhat_et_libguestfs_GuestFS__1close | RErr | RBool _ | RInt _ | RInt64 _ | RConstString _ | RConstOptString _ | RString _ | RBufferOut _ | RStruct _ | RHashtable _ -> false) || - List.exists (function StringList _ -> true | _ -> false) (snd style) in + List.exists (function + | StringList _ -> true + | DeviceList _ -> true + | _ -> false) (snd style) in if needs_i then pr " int i;\n"; @@ -9016,7 +9049,7 @@ and generate_bindtests () = #define safe_malloc guestfs_safe_malloc static void -print_strings (char * const* const argv) +print_strings (char *const *argv) { int argc;