| 1 | (* |
| 2 | * Copyright (C) 2006-2007 XenSource Ltd. |
| 3 | * Copyright (C) 2008 Citrix Ltd. |
| 4 | * Author Vincent Hanquez <[email protected]> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published |
| 8 | * by the Free Software Foundation; version 2.1 only. with the special |
| 9 | * exception on linking described in file LICENSE. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Lesser General Public License for more details. |
| 15 | *) |
| 16 | |
| 17 | exception Timeout |
| 18 | |
| 19 | (** Throws this rather than a miscellaneous Unix.connect failed *) |
| 20 | exception Failed_to_connect |
| 21 | |
| 22 | (** perms contains 3 things: |
| 23 | - owner domid. |
| 24 | - other perm: applied to domain that is not owner or in ACL. |
| 25 | - ACL: list of per-domain permission |
| 26 | *) |
| 27 | type perms = Xsraw.perms |
| 28 | |
| 29 | type domid = int |
| 30 | type con |
| 31 | |
| 32 | type xsh = { |
| 33 | con : con; |
| 34 | debug: string list -> string; |
| 35 | directory : string -> string list; |
| 36 | read : string -> string; |
| 37 | readv : string -> string list -> string list; |
| 38 | write : string -> string -> unit; |
| 39 | writev : string -> (string * string) list -> unit; |
| 40 | mkdir : string -> unit; |
| 41 | rm : string -> unit; |
| 42 | getperms : string -> perms; |
| 43 | setperms : string -> perms -> unit; |
| 44 | setpermsv : string -> string list -> perms -> unit; |
| 45 | introduce : domid -> nativeint -> int -> unit; |
| 46 | release : domid -> unit; |
| 47 | resume : domid -> unit; |
| 48 | getdomainpath : domid -> string; |
| 49 | watch : string -> string -> unit; |
| 50 | unwatch : string -> string -> unit; |
| 51 | } |
| 52 | |
| 53 | (** get operations provide a vector of xenstore function that apply to one |
| 54 | connection *) |
| 55 | val get_operations : con -> xsh |
| 56 | |
| 57 | (** create a transaction with a vector of function that can be applied |
| 58 | into the transaction. *) |
| 59 | val transaction : xsh -> (Xst.ops -> 'a) -> 'a |
| 60 | |
| 61 | (** watch manipulation on a connection *) |
| 62 | val has_watchevents : xsh -> bool |
| 63 | val get_watchevent : xsh -> string * string |
| 64 | val read_watchevent : xsh -> string * string |
| 65 | |
| 66 | (** get_fd return the fd of the connection to be able to select on it. |
| 67 | NOTE: it works only for socket-based connection *) |
| 68 | val get_fd : xsh -> Unix.file_descr |
| 69 | |
| 70 | (** wait for watchevent with a timeout. Until the callback return true, |
| 71 | every watch during the time specified, will be pass to the callback. |
| 72 | NOTE: it works only when use with a socket-based connection *) |
| 73 | val read_watchevent_timeout : xsh -> float -> (string * string -> bool) -> unit |
| 74 | |
| 75 | (** register a set of watches, then wait for watchevent. |
| 76 | remove all watches previously set before giving back the hand. *) |
| 77 | val monitor_paths : xsh |
| 78 | -> (string * string) list |
| 79 | -> float |
| 80 | -> (string * string -> bool) |
| 81 | -> unit |
| 82 | |
| 83 | (** open a socket-based xenstored connection *) |
| 84 | val daemon_open : unit -> xsh |
| 85 | |
| 86 | (** open a mmap-based xenstored connection *) |
| 87 | val domain_open : unit -> xsh |
| 88 | |
| 89 | (** close any xenstored connection *) |
| 90 | val close : xsh -> unit |