Skip to content

Commit

Permalink
vhd-tool: when opening raw images, peek behind any tapdisks
Browse files Browse the repository at this point in the history
When opening a file for reading, if we open a tapdisk device
then `SEEK_DATA` and `SEEK_HOLE` won't work. Instead if we peek
behind the tapdisk then the filesystem can implement `SEEK_*`
(or not).

Signed-off-by: David Scott <dave.scott@citrix.com>
  • Loading branch information
David Scott committed Sep 3, 2015
1 parent be03b7c commit 1322a4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _oasis
Expand Up @@ -16,7 +16,7 @@ Executable "vhd-tool"
MainIs: main.ml
Custom: true
Install: false
BuildDepends: lwt, lwt.unix, lwt.syntax, lwt.preemptive, threads, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.12.0), cohttp.lwt, tar, sha, sha.sha1, io-page.unix, re.str
BuildDepends: lwt, lwt.unix, lwt.syntax, lwt.preemptive, threads, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.12.0), cohttp.lwt, tar, sha, sha.sha1, io-page.unix, threads, tapctl, re.str
CSources: sendfile64_stubs.c

Executable "sparse_dd"
Expand Down
2 changes: 0 additions & 2 deletions src/image.ml
@@ -1,5 +1,3 @@
open Xenstore

let (|>) a b = b a
module Opt = struct
let default d = function
Expand Down
6 changes: 6 additions & 0 deletions src/impl.ml
Expand Up @@ -651,9 +651,15 @@ let make_stream common source relative_to source_format destination_format =
( match relative_to with None -> return None | Some f -> Vhd_IO.openchain ~path f false >>= fun t -> return (Some t) ) >>= fun from ->
Vhd_input.raw ?from t
| "raw", "vhd" ->
let source = match Image.of_device source with
| Some (`Raw x) -> x (* bypass any tapdisk and use the raw file *)
| _ -> source in
Raw_IO.openfile source false >>= fun t ->
Raw_input.vhd t
| "raw", "raw" ->
let source = match Image.of_device source with
| Some (`Raw x) -> x (* bypass any tapdisk and use the raw file *)
| _ -> source in
Raw_IO.openfile source false >>= fun t ->
Raw_input.raw t
| _, _ -> assert false
Expand Down

0 comments on commit 1322a4d

Please sign in to comment.