CIL: Include dynlink for OCaml 3.11.
[ocaml-bitstring.git] / cil-tools / ext3.ml
1 (* This is an example program using an imported C structure.
2  *
3  * The C structure is imported from <linux/ext3_fs.h> via "ext3.c"
4  * by the bitstring-import-c program, and saved as "ext3.bmpp".
5  *
6  * Then we can load "ext3.bmpp" here.
7  *)
8
9 open Printf
10
11 open bitmatch "ext3.bmpp"
12
13 let () =
14   (* Load a real ext3 superblock from the examples directory. *)
15   let bits = Bitstring.bitstring_of_file "examples/ext3_sb" in
16
17   bitmatch bits with
18   | { :ext2_super_block } ->
19       printf "ext3 superblock:\n";
20       printf "  s_inodes_count = %ld\n" s_inodes_count;
21       printf "  s_blocks_count = %ld\n" s_blocks_count;
22       printf "  s_free_inodes_count = %ld\n" s_free_inodes_count;
23       printf "  s_free_blocks_count = %ld\n" s_free_blocks_count;
24       printf "  s_uuid = %S\n" s_uuid;
25       printf "  s_volume_name = %S\n" s_volume_name;
26       printf "  s_last_mounted = %S\n" s_last_mounted
27
28   | { _ } ->
29       failwith "input is not an ext2/3 superblock"