package protocol-9p

  1. Overview
  2. Docs
An implementation of the 9p protocol in pure OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

protocol-9p-2.1.0.tbz
sha256=28bace4c680708495bf3f8c936ade387870887c39c507318ecab456bf8824845
sha512=5c4a421211e84ddc2a4588d3d7d1979de83e32e8e5cde926ea0c93272720b67f009ead0ad51d087a62bffbad884390f02e030752c435f442115ee82ce932b741

doc/protocol-9p/Protocol_9p/Server/index.html

Module Protocol_9p.ServerSource

Given a transport (a Mirage FLOW), construct a 9P server on top.

Sourcetype exn_converter = Protocol_9p__.Protocol_9p_info.t -> exn -> Protocol_9p__.Protocol_9p_response.payload

An exception converter transforms the given OCaml exception into a 9P error response. 9P clients like Linux work better if they receive 9P2000.u errno values which happen to match their local errno definition.

Here is an example converter for Linux and OS X hosts:

let unix_exn_converter info exn =
  let is_unix = (info.Protocol_9p_info.version = Types.Version.unix) in
  match exn with
  | Unix.Unix_error(err, _, _) ->
    let host = match info.Protocol_9p_info.aname with
      | "linux#/" when is_unix -> Some Errno_host.Linux.v4_0_5
      | "osx#/" when is_unix -> Some Errno_host.OSX.v10_11_1
      | _ -> None
    in
    let errno = match host with
      | None -> None
      | Some host -> match Errno_unix.of_unix ~host err with
        | [] -> None
        | errno::_ -> match Errno.to_code ~host errno with
          | None -> None
          | Some i -> Some (Int32.of_int i)
    in
    Response.Err {
      Response.Err.ename = Unix.error_message err;
      errno;
    }
  | e ->
    Response.Err {
      Response.Err.ename = Printexc.to_string e;
      errno = None;
    }
Sourcemodule Make (Log : sig ... end) (FLOW : Mirage_flow.S) (Filesystem : sig ... end) : sig ... end