From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Tue, 23 Sep 2008 14:44:54 +0000 (+0100) Subject: Warn if data file is missing. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=6d60df50895e83763a20c4ec62ef0ec334cd7676;p=virt-mem.git Warn if data file is missing. --- diff --git a/extract/codegen/pahole_parser.ml b/extract/codegen/pahole_parser.ml index 029ecde..19cbbf1 100644 --- a/extract/codegen/pahole_parser.ml +++ b/extract/codegen/pahole_parser.ml @@ -79,6 +79,10 @@ and string_of_f_type = function | FInteger -> "int" | FString width -> sprintf "char[%d]" width +let file_exists name = + try Unix.access name [Unix.F_OK]; true + with Unix.Unix_error _ -> false + (* Regular expressions. We really really should use ocaml-mikmatch ... *) let re_oldformat = Pcre.regexp "^RPM: \\d+: \\(build \\d+\\) ([-\\w]+) ([\\w.]+) ([\\w.]+) \\(.*?\\) (\\w+)" let re_keyvalue = Pcre.regexp "^(\\w+): (.*)" @@ -151,6 +155,23 @@ let list_kernels path = basename = basename; arch = arch; kernel_version = version } ) infos in + + (* Check the .data, .data.gz or .data.bz2 file exists, and skip with + * a warning if not. + *) + let infos = List.filter ( + fun { basename = basename } -> + if not (file_exists (basename ^ ".data")) && + not (file_exists (basename ^ ".data.gz")) && + not (file_exists (basename ^ ".data.bz2")) then ( + eprintf "warning: %s: no data file found for this kernel - skipping\n%!" + basename; + false + ) + else + true + ) infos in + infos (* XXX This would be better as a proper lex/yacc parser. @@ -175,10 +196,6 @@ let load_structures { basename = basename } struct_names = ) struct_names; (* Now read the data file and parse out the structures of interest. *) - let file_exists name = - try Unix.access name [Unix.F_OK]; true - with Unix.Unix_error _ -> false - in let close_process_in cmd chan = match Unix.close_process_in chan with | Unix.WEXITED 0 -> ()