vmm_unix, create_block: first create file, and then truncate

This commit is contained in:
Hannes Mehnert 2018-12-07 00:07:16 +01:00
parent 325f6c3b22
commit 030f5aa379

View file

@ -199,6 +199,8 @@ let create_block name size =
Bos.OS.File.exists block_name >>= function Bos.OS.File.exists block_name >>= function
| true -> Error (`Msg "file already exists") | true -> Error (`Msg "file already exists")
| false -> | false ->
let fd = Unix.(openfile (Fpath.to_string block_name) [O_CREAT] 0o600) in
close_no_err fd ;
bytes_of_mb size >>= fun size' -> bytes_of_mb size >>= fun size' ->
Bos.OS.File.truncate block_name size' Bos.OS.File.truncate block_name size'