Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to get Fids #19

Merged
merged 1 commit into from Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/client.ml
Expand Up @@ -41,6 +41,9 @@ module type S = sig
val clunk: t -> Types.Fid.t -> Response.Clunk.t Error.t Lwt.t
val remove: t -> Types.Fid.t -> Response.Remove.t Error.t Lwt.t
end

val walk_from_root: t -> Types.Fid.t -> string list -> Response.Walk.t Error.t Lwt.t
val with_fid: t -> (Types.Fid.t -> 'a Lwt.t) -> 'a Lwt.t
end

module Make(Log: S.LOG)(FLOW: V1_LWT.FLOW) = struct
Expand Down Expand Up @@ -254,6 +257,8 @@ module Make(Log: S.LOG)(FLOW: V1_LWT.FLOW) = struct
| { Response.payload = p } -> return_error p
end

let walk_from_root t = LowLevel.walk t t.root

let rec allocate_fid t =
let open Lwt in
if t.free_fids = Types.Fid.Set.empty
Expand Down
8 changes: 8 additions & 0 deletions lib/client.mli
Expand Up @@ -79,6 +79,14 @@ module type S = sig
server. The server will "clunk" the fid whether the call succeeds or
fails. *)
end

val walk_from_root: t -> Types.Fid.t -> string list -> Response.Walk.t Error.t Lwt.t
(** [walk_from_root t] is [LowLevel.walk t root], where [root] is the internal Fid
representing the root directory (which is not exposed by the API). *)

val with_fid: t -> (Types.Fid.t -> 'a Lwt.t) -> 'a Lwt.t
(** [with_fid t fn] is the result of running [fn x] with a fresh Fid [x], which
is returned to the free pool when the thread finishes. *)
end

(** Given a transport (a Mirage FLOW), construct a 9P client on top. *)
Expand Down
3 changes: 3 additions & 0 deletions unix/client9p_unix.ml
Expand Up @@ -106,4 +106,7 @@ module Inet(Log: S.LOG) = struct

let remove { client } = LowLevel.remove client
end

let walk_from_root { client } = Client.walk_from_root client
let with_fid { client } = Client.with_fid client
end