open Virt_mem_utils
open Virt_mem_mmap
-let usage = s_"NAME
- virt-uname - uname command for virtual machines
-
-SUMMARY
- virt-uname [-options] [domains]
-
-DESCRIPTION
- virt-uname prints the uname information such as OS version,
- architecture and node name for virtual machines running under
- libvirt."
-
-let _, images = Virt_mem.start usage
-
-let () =
+let run debug images =
(* Print new_utsname structure from bitstring. *)
let print_new_utsname name bs =
(* Truncate an OCaml string at the first ASCII NUL character, ie. as
in
List.iter (
- fun (name, arch, mem, lookup_ksym) ->
+ fun (_, name, arch, mem, lookup_ksym) ->
(* In Linux 2.6.25, the symbol is init_uts_ns.
* http://lxr.linux.no/linux/init/version.c
*)
try
let addr = lookup_ksym "init_uts_ns" in
- let bs = Bitmatch.bitstring_of_string (get_bytes mem addr (65*6+4)) in
+ let bs = Bitstring.bitstring_of_string (get_bytes mem addr (65*6+4)) in
(bitmatch bs with
| { _ : 32 : int; (* the kref, atomic_t, always 32 bits *)
new_utsname : -1 : bitstring } ->
let addr = lookup_ksym "system_utsname" in
let bs =
- Bitmatch.bitstring_of_string (get_bytes mem addr (65*6)) in
+ Bitstring.bitstring_of_string (get_bytes mem addr (65*6)) in
print_new_utsname name bs
with
Not_found ->
eprintf (f_"%s: could not find utsname in kernel image\n") name
) images
+
+let summary = s_"uname command for virtual machines"
+let description = s_"\
+virt-uname prints the uname information such as OS version,
+architecture and node name for virtual machines running under
+libvirt."
+
+let () = Virt_mem.register "uname" summary description ~run