mirage / ocaml-fat

Read and write FAT format filesystems from OCaml
ISC License
26 stars 18 forks source link

listdir shows items that don't exist #34

Closed talex5 closed 10 years ago

talex5 commented 10 years ago

Test-case (creates "/data", deletes it, then lists "/"):

open Lwt

module F = Fat.Fs.Make(Block)(Io_page)

let (>>|=) x f = x >>= function
  | `Error e -> failwith (Fat.Fs.string_of_filesystem_error e)
  | `Ok v -> f v

let main =
  Block.connect "disk.img" >>= function
  | `Error (`Unknown msg) -> failwith msg
  | `Error _ -> failwith "Block error"
  | `Ok block ->
  F.connect block >>|= fun fs ->
  F.format fs 0x100000L >>|= fun () ->
  F.create fs "/data" >>|= fun () ->
  F.destroy fs "/data" >>|= fun () ->
  F.listdir fs "/" >>|= fun items ->
  List.iter (Printf.printf "Item: %s\n") items;
  print_endline "Done listing.";
  return ()

let () = Lwt_unix.run main

This outputs:

Item:��K�
Done listing.