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
1 changed files with 2 additions and 0 deletions

View File

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