1ff662b5cSJustin T. Gibbs /****************************************************************************** 2ff662b5cSJustin T. Gibbs * xenstorevar.h 3ff662b5cSJustin T. Gibbs * 4ff662b5cSJustin T. Gibbs * Method declarations and structures for accessing the XenStore.h 5ff662b5cSJustin T. Gibbs * 6ff662b5cSJustin T. Gibbs * Copyright (C) 2005 Rusty Russell, IBM Corporation 7ff662b5cSJustin T. Gibbs * Copyright (C) 2005 XenSource Ltd. 8ff662b5cSJustin T. Gibbs * Copyright (C) 2009,2010 Spectra Logic Corporation 9ff662b5cSJustin T. Gibbs * 10ff662b5cSJustin T. Gibbs * This file may be distributed separately from the Linux kernel, or 11ff662b5cSJustin T. Gibbs * incorporated into other software packages, subject to the following license: 12ff662b5cSJustin T. Gibbs * 13ff662b5cSJustin T. Gibbs * Permission is hereby granted, free of charge, to any person obtaining a copy 14ff662b5cSJustin T. Gibbs * of this source file (the "Software"), to deal in the Software without 15ff662b5cSJustin T. Gibbs * restriction, including without limitation the rights to use, copy, modify, 16ff662b5cSJustin T. Gibbs * merge, publish, distribute, sublicense, and/or sell copies of the Software, 17ff662b5cSJustin T. Gibbs * and to permit persons to whom the Software is furnished to do so, subject to 18ff662b5cSJustin T. Gibbs * the following conditions: 19ff662b5cSJustin T. Gibbs * 20ff662b5cSJustin T. Gibbs * The above copyright notice and this permission notice shall be included in 21ff662b5cSJustin T. Gibbs * all copies or substantial portions of the Software. 22ff662b5cSJustin T. Gibbs * 23ff662b5cSJustin T. Gibbs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24ff662b5cSJustin T. Gibbs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25ff662b5cSJustin T. Gibbs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26ff662b5cSJustin T. Gibbs * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27ff662b5cSJustin T. Gibbs * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28ff662b5cSJustin T. Gibbs * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 29ff662b5cSJustin T. Gibbs * IN THE SOFTWARE. 30ff662b5cSJustin T. Gibbs */ 31ff662b5cSJustin T. Gibbs 32ff662b5cSJustin T. Gibbs #ifndef _XEN_XENSTORE_XENSTOREVAR_H 33ff662b5cSJustin T. Gibbs #define _XEN_XENSTORE_XENSTOREVAR_H 34ff662b5cSJustin T. Gibbs 35ff662b5cSJustin T. Gibbs #include <sys/queue.h> 36ff662b5cSJustin T. Gibbs #include <sys/bus.h> 37ff662b5cSJustin T. Gibbs #include <sys/eventhandler.h> 38ff662b5cSJustin T. Gibbs #include <sys/malloc.h> 39ff662b5cSJustin T. Gibbs #include <sys/sbuf.h> 40ff662b5cSJustin T. Gibbs 41ff662b5cSJustin T. Gibbs #include <machine/stdarg.h> 42ff662b5cSJustin T. Gibbs 4376acc41fSJustin T. Gibbs #include <xen/xen-os.h> 44*ad7dd514SElliott Mitchell #include <contrib/xen/grant_table.h> 45*ad7dd514SElliott Mitchell #include <contrib/xen/io/xenbus.h> 46*ad7dd514SElliott Mitchell #include <contrib/xen/io/xs_wire.h> 47ff662b5cSJustin T. Gibbs 48ff662b5cSJustin T. Gibbs #include "xenbus_if.h" 49ff662b5cSJustin T. Gibbs 50ff662b5cSJustin T. Gibbs /* XenStore allocations including XenStore data returned to clients. */ 51ff662b5cSJustin T. Gibbs MALLOC_DECLARE(M_XENSTORE); 52ff662b5cSJustin T. Gibbs 53ff662b5cSJustin T. Gibbs struct xs_watch; 54ff662b5cSJustin T. Gibbs 55283d6f72SJustin T. Gibbs typedef void (xs_watch_cb_t)(struct xs_watch *, const char **vec, 56283d6f72SJustin T. Gibbs unsigned int len); 57ff662b5cSJustin T. Gibbs 58ff662b5cSJustin T. Gibbs /* Register callback to watch subtree (node) in the XenStore. */ 59ff662b5cSJustin T. Gibbs struct xs_watch 60ff662b5cSJustin T. Gibbs { 61ff662b5cSJustin T. Gibbs LIST_ENTRY(xs_watch) list; 62ff662b5cSJustin T. Gibbs 63ff662b5cSJustin T. Gibbs /* Path being watched. */ 64ff662b5cSJustin T. Gibbs char *node; 65ff662b5cSJustin T. Gibbs 66ff662b5cSJustin T. Gibbs /* Callback (executed in a process context with no locks held). */ 67ff662b5cSJustin T. Gibbs xs_watch_cb_t *callback; 68283d6f72SJustin T. Gibbs 69283d6f72SJustin T. Gibbs /* Callback client data untouched by the XenStore watch mechanism. */ 70283d6f72SJustin T. Gibbs uintptr_t callback_data; 714e4e43dcSRoger Pau Monné 724e4e43dcSRoger Pau Monné /* Maximum number of pending watch events to be delivered. */ 734e4e43dcSRoger Pau Monné unsigned int max_pending; 744e4e43dcSRoger Pau Monné 754e4e43dcSRoger Pau Monné /* 764e4e43dcSRoger Pau Monné * Private counter used by xenstore to keep track of the pending 774e4e43dcSRoger Pau Monné * watches. Protected by xs.watch_events_lock. 784e4e43dcSRoger Pau Monné */ 794e4e43dcSRoger Pau Monné unsigned int pending; 80ff662b5cSJustin T. Gibbs }; 81ff662b5cSJustin T. Gibbs LIST_HEAD(xs_watch_list, xs_watch); 82ff662b5cSJustin T. Gibbs 83ff662b5cSJustin T. Gibbs typedef int (*xs_event_handler_t)(void *); 84ff662b5cSJustin T. Gibbs 85ff662b5cSJustin T. Gibbs struct xs_transaction 86ff662b5cSJustin T. Gibbs { 87ff662b5cSJustin T. Gibbs uint32_t id; 88ff662b5cSJustin T. Gibbs }; 89ff662b5cSJustin T. Gibbs 90ff662b5cSJustin T. Gibbs #define XST_NIL ((struct xs_transaction) { 0 }) 91ff662b5cSJustin T. Gibbs 92ff662b5cSJustin T. Gibbs /** 93cfa0b7b8SRoger Pau Monné * Check if Xenstore is initialized. 94cfa0b7b8SRoger Pau Monné * 95cfa0b7b8SRoger Pau Monné * \return True if initialized, false otherwise. 96cfa0b7b8SRoger Pau Monné */ 97cfa0b7b8SRoger Pau Monné bool xs_initialized(void); 98cfa0b7b8SRoger Pau Monné 99cfa0b7b8SRoger Pau Monné /** 100cfa0b7b8SRoger Pau Monné * Return xenstore event channel port. 101cfa0b7b8SRoger Pau Monné * 102cfa0b7b8SRoger Pau Monné * \return event channel port. 103cfa0b7b8SRoger Pau Monné */ 104cfa0b7b8SRoger Pau Monné evtchn_port_t xs_evtchn(void); 105cfa0b7b8SRoger Pau Monné 106cfa0b7b8SRoger Pau Monné /** 107cfa0b7b8SRoger Pau Monné * Return xenstore page physical memory address. 108cfa0b7b8SRoger Pau Monné * 109cfa0b7b8SRoger Pau Monné * \return xenstore page physical address. 110cfa0b7b8SRoger Pau Monné */ 111cfa0b7b8SRoger Pau Monné vm_paddr_t xs_address(void); 112cfa0b7b8SRoger Pau Monné 113cfa0b7b8SRoger Pau Monné /** 114ff662b5cSJustin T. Gibbs * Fetch the contents of a directory in the XenStore. 115ff662b5cSJustin T. Gibbs * 116ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 117ff662b5cSJustin T. Gibbs * \param dir The dirname of the path to read. 118ff662b5cSJustin T. Gibbs * \param node The basename of the path to read. 119ff662b5cSJustin T. Gibbs * \param num The returned number of directory entries. 120ff662b5cSJustin T. Gibbs * \param result An array of directory entry strings. 121ff662b5cSJustin T. Gibbs * 122ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 123ff662b5cSJustin T. Gibbs * type of failure. 124ff662b5cSJustin T. Gibbs * 125ff662b5cSJustin T. Gibbs * \note The results buffer is malloced and should be free'd by the 126ff662b5cSJustin T. Gibbs * caller with 'free(*result, M_XENSTORE)'. 127ff662b5cSJustin T. Gibbs */ 128ff662b5cSJustin T. Gibbs int xs_directory(struct xs_transaction t, const char *dir, 129ff662b5cSJustin T. Gibbs const char *node, unsigned int *num, const char ***result); 130ff662b5cSJustin T. Gibbs 131ff662b5cSJustin T. Gibbs /** 132ff662b5cSJustin T. Gibbs * Determine if a path exists in the XenStore. 133ff662b5cSJustin T. Gibbs * 134ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 135ff662b5cSJustin T. Gibbs * \param dir The dirname of the path to read. 136ff662b5cSJustin T. Gibbs * \param node The basename of the path to read. 137ff662b5cSJustin T. Gibbs * 138ff662b5cSJustin T. Gibbs * \retval 1 The path exists. 139ff662b5cSJustin T. Gibbs * \retval 0 The path does not exist or an error occurred attempting 140ff662b5cSJustin T. Gibbs * to make that determination. 141ff662b5cSJustin T. Gibbs */ 142ff662b5cSJustin T. Gibbs int xs_exists(struct xs_transaction t, const char *dir, const char *node); 143ff662b5cSJustin T. Gibbs 144ff662b5cSJustin T. Gibbs /** 145ff662b5cSJustin T. Gibbs * Get the contents of a single "file". Returns the contents in 146ff662b5cSJustin T. Gibbs * *result which should be freed with free(*result, M_XENSTORE) after 147ff662b5cSJustin T. Gibbs * use. The length of the value in bytes is returned in *len. 148ff662b5cSJustin T. Gibbs * 149ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 150ff662b5cSJustin T. Gibbs * \param dir The dirname of the file to read. 151ff662b5cSJustin T. Gibbs * \param node The basename of the file to read. 152ff662b5cSJustin T. Gibbs * \param len The amount of data read. 153ff662b5cSJustin T. Gibbs * \param result The returned contents from this file. 154ff662b5cSJustin T. Gibbs * 155ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 156ff662b5cSJustin T. Gibbs * type of failure. 157ff662b5cSJustin T. Gibbs * 158ff662b5cSJustin T. Gibbs * \note The results buffer is malloced and should be free'd by the 159ff662b5cSJustin T. Gibbs * caller with 'free(*result, M_XENSTORE)'. 160ff662b5cSJustin T. Gibbs */ 161ff662b5cSJustin T. Gibbs int xs_read(struct xs_transaction t, const char *dir, 162ff662b5cSJustin T. Gibbs const char *node, unsigned int *len, void **result); 163ff662b5cSJustin T. Gibbs 164ff662b5cSJustin T. Gibbs /** 165ff662b5cSJustin T. Gibbs * Write to a single file. 166ff662b5cSJustin T. Gibbs * 167ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 168ff662b5cSJustin T. Gibbs * \param dir The dirname of the file to write. 169ff662b5cSJustin T. Gibbs * \param node The basename of the file to write. 170ff662b5cSJustin T. Gibbs * \param string The NUL terminated string of data to write. 171ff662b5cSJustin T. Gibbs * 172ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 173ff662b5cSJustin T. Gibbs * type of failure. 174ff662b5cSJustin T. Gibbs */ 175ff662b5cSJustin T. Gibbs int xs_write(struct xs_transaction t, const char *dir, 176ff662b5cSJustin T. Gibbs const char *node, const char *string); 177ff662b5cSJustin T. Gibbs 178ff662b5cSJustin T. Gibbs /** 179ff662b5cSJustin T. Gibbs * Create a new directory. 180ff662b5cSJustin T. Gibbs * 181ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 182ff662b5cSJustin T. Gibbs * \param dir The dirname of the directory to create. 183ff662b5cSJustin T. Gibbs * \param node The basename of the directory to create. 184ff662b5cSJustin T. Gibbs * 185ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 186ff662b5cSJustin T. Gibbs * type of failure. 187ff662b5cSJustin T. Gibbs */ 188ff662b5cSJustin T. Gibbs int xs_mkdir(struct xs_transaction t, const char *dir, 189ff662b5cSJustin T. Gibbs const char *node); 190ff662b5cSJustin T. Gibbs 191ff662b5cSJustin T. Gibbs /** 192ff662b5cSJustin T. Gibbs * Remove a file or directory (directories must be empty). 193ff662b5cSJustin T. Gibbs * 194ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 195ff662b5cSJustin T. Gibbs * \param dir The dirname of the directory to remove. 196ff662b5cSJustin T. Gibbs * \param node The basename of the directory to remove. 197ff662b5cSJustin T. Gibbs * 198ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 199ff662b5cSJustin T. Gibbs * type of failure. 200ff662b5cSJustin T. Gibbs */ 201ff662b5cSJustin T. Gibbs int xs_rm(struct xs_transaction t, const char *dir, const char *node); 202ff662b5cSJustin T. Gibbs 203ff662b5cSJustin T. Gibbs /** 204ff662b5cSJustin T. Gibbs * Destroy a tree of files rooted at dir/node. 205ff662b5cSJustin T. Gibbs * 206ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 207ff662b5cSJustin T. Gibbs * \param dir The dirname of the directory to remove. 208ff662b5cSJustin T. Gibbs * \param node The basename of the directory to remove. 209ff662b5cSJustin T. Gibbs * 210ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 211ff662b5cSJustin T. Gibbs * type of failure. 212ff662b5cSJustin T. Gibbs */ 213ff662b5cSJustin T. Gibbs int xs_rm_tree(struct xs_transaction t, const char *dir, 214ff662b5cSJustin T. Gibbs const char *node); 215ff662b5cSJustin T. Gibbs 216ff662b5cSJustin T. Gibbs /** 217ff662b5cSJustin T. Gibbs * Start a transaction. 218ff662b5cSJustin T. Gibbs * 219ff662b5cSJustin T. Gibbs * Changes by others will not be seen during the lifetime of this 220ff662b5cSJustin T. Gibbs * transaction, and changes will not be visible to others until it 221ff662b5cSJustin T. Gibbs * is committed (xs_transaction_end). 222ff662b5cSJustin T. Gibbs * 223ff662b5cSJustin T. Gibbs * \param t The returned transaction. 224ff662b5cSJustin T. Gibbs * 225ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 226ff662b5cSJustin T. Gibbs * type of failure. 227ff662b5cSJustin T. Gibbs */ 228ff662b5cSJustin T. Gibbs int xs_transaction_start(struct xs_transaction *t); 229ff662b5cSJustin T. Gibbs 230ff662b5cSJustin T. Gibbs /** 231ff662b5cSJustin T. Gibbs * End a transaction. 232ff662b5cSJustin T. Gibbs * 233ff662b5cSJustin T. Gibbs * \param t The transaction to end/commit. 234ff662b5cSJustin T. Gibbs * \param abort If non-zero, the transaction is discarded 235ff662b5cSJustin T. Gibbs * instead of committed. 236ff662b5cSJustin T. Gibbs * 237ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 238ff662b5cSJustin T. Gibbs * type of failure. 239ff662b5cSJustin T. Gibbs */ 240ff662b5cSJustin T. Gibbs int xs_transaction_end(struct xs_transaction t, int abort); 241ff662b5cSJustin T. Gibbs 242ff662b5cSJustin T. Gibbs /* 243ff662b5cSJustin T. Gibbs * Single file read and scanf parsing of the result. 244ff662b5cSJustin T. Gibbs * 245ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 246ff662b5cSJustin T. Gibbs * \param dir The dirname of the path to read. 247ff662b5cSJustin T. Gibbs * \param node The basename of the path to read. 248ff662b5cSJustin T. Gibbs * \param scancountp The number of input values assigned (i.e. the result 249ff662b5cSJustin T. Gibbs * of scanf). 250ff662b5cSJustin T. Gibbs * \param fmt Scanf format string followed by a variable number of 251ff662b5cSJustin T. Gibbs * scanf input arguments. 252ff662b5cSJustin T. Gibbs * 253ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 254ff662b5cSJustin T. Gibbs * type of failure. 255ff662b5cSJustin T. Gibbs */ 256ff662b5cSJustin T. Gibbs int xs_scanf(struct xs_transaction t, 257ff662b5cSJustin T. Gibbs const char *dir, const char *node, int *scancountp, const char *fmt, ...) 258ff662b5cSJustin T. Gibbs __attribute__((format(scanf, 5, 6))); 259ff662b5cSJustin T. Gibbs 260ff662b5cSJustin T. Gibbs /** 261ff662b5cSJustin T. Gibbs * Printf formatted write to a XenStore file. 262ff662b5cSJustin T. Gibbs * 263ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 264ff662b5cSJustin T. Gibbs * \param dir The dirname of the path to read. 265ff662b5cSJustin T. Gibbs * \param node The basename of the path to read. 266ff662b5cSJustin T. Gibbs * \param fmt Printf format string followed by a variable number of 267ff662b5cSJustin T. Gibbs * printf arguments. 268ff662b5cSJustin T. Gibbs * 269ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 270ff662b5cSJustin T. Gibbs * type of write failure. 271ff662b5cSJustin T. Gibbs */ 272ff662b5cSJustin T. Gibbs int xs_printf(struct xs_transaction t, const char *dir, 273ff662b5cSJustin T. Gibbs const char *node, const char *fmt, ...) 274ff662b5cSJustin T. Gibbs __attribute__((format(printf, 4, 5))); 275ff662b5cSJustin T. Gibbs 276ff662b5cSJustin T. Gibbs /** 277ff662b5cSJustin T. Gibbs * va_list version of xenbus_printf(). 278ff662b5cSJustin T. Gibbs * 279ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 280ff662b5cSJustin T. Gibbs * \param dir The dirname of the path to read. 281ff662b5cSJustin T. Gibbs * \param node The basename of the path to read. 282ff662b5cSJustin T. Gibbs * \param fmt Printf format string. 283ff662b5cSJustin T. Gibbs * \param ap Va_list of printf arguments. 284ff662b5cSJustin T. Gibbs * 285ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 286ff662b5cSJustin T. Gibbs * type of write failure. 287ff662b5cSJustin T. Gibbs */ 288ff662b5cSJustin T. Gibbs int xs_vprintf(struct xs_transaction t, const char *dir, 289ff662b5cSJustin T. Gibbs const char *node, const char *fmt, va_list ap); 290ff662b5cSJustin T. Gibbs 291ff662b5cSJustin T. Gibbs /** 292ff662b5cSJustin T. Gibbs * Multi-file read within a single directory and scanf parsing of 293ff662b5cSJustin T. Gibbs * the results. 294ff662b5cSJustin T. Gibbs * 295ff662b5cSJustin T. Gibbs * \param t The XenStore transaction covering this request. 296ff662b5cSJustin T. Gibbs * \param dir The dirname of the paths to read. 297ff662b5cSJustin T. Gibbs * \param ... A variable number of argument triples specifying 298ff662b5cSJustin T. Gibbs * the file name, scanf-style format string, and 299ff662b5cSJustin T. Gibbs * output variable (pointer to storage of the results). 300ff662b5cSJustin T. Gibbs * The last triple in the call must be terminated 301ff662b5cSJustin T. Gibbs * will a final NULL argument. A NULL format string 302ff662b5cSJustin T. Gibbs * will cause the entire contents of the given file 303ff662b5cSJustin T. Gibbs * to be assigned as a NUL terminated, M_XENSTORE heap 304ff662b5cSJustin T. Gibbs * backed, string to the output parameter of that tuple. 305ff662b5cSJustin T. Gibbs * 306ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 307ff662b5cSJustin T. Gibbs * type of read failure. 308ff662b5cSJustin T. Gibbs * 309ff662b5cSJustin T. Gibbs * Example: 310ff662b5cSJustin T. Gibbs * char protocol_abi[64]; 311ff662b5cSJustin T. Gibbs * uint32_t ring_ref; 312ff662b5cSJustin T. Gibbs * char *dev_type; 313ff662b5cSJustin T. Gibbs * int error; 314ff662b5cSJustin T. Gibbs * 315ff662b5cSJustin T. Gibbs * error = xenbus_gather(XBT_NIL, xenbus_get_node(dev), 316ff662b5cSJustin T. Gibbs * "ring-ref", "%" PRIu32, &ring_ref, 317ff662b5cSJustin T. Gibbs * "protocol", "%63s", protocol_abi, 318ff662b5cSJustin T. Gibbs * "device-type", NULL, &dev_type, 319ff662b5cSJustin T. Gibbs * NULL); 320ff662b5cSJustin T. Gibbs * 321ff662b5cSJustin T. Gibbs * ... 322ff662b5cSJustin T. Gibbs * 323ff662b5cSJustin T. Gibbs * free(dev_type, M_XENSTORE); 324ff662b5cSJustin T. Gibbs */ 325ff662b5cSJustin T. Gibbs int xs_gather(struct xs_transaction t, const char *dir, ...); 326ff662b5cSJustin T. Gibbs 327ff662b5cSJustin T. Gibbs /** 328ff662b5cSJustin T. Gibbs * Register a XenStore watch. 329ff662b5cSJustin T. Gibbs * 330ff662b5cSJustin T. Gibbs * XenStore watches allow a client to be notified via a callback (embedded 331ff662b5cSJustin T. Gibbs * within the watch object) of changes to an object in the XenStore. 332ff662b5cSJustin T. Gibbs * 333283d6f72SJustin T. Gibbs * \param watch An xs_watch struct with it's node and callback fields 334ff662b5cSJustin T. Gibbs * properly initialized. 335ff662b5cSJustin T. Gibbs * 336ff662b5cSJustin T. Gibbs * \return On success, 0. Otherwise an errno value indicating the 337ff662b5cSJustin T. Gibbs * type of write failure. EEXIST errors from the XenStore 338ff662b5cSJustin T. Gibbs * are supressed, allowing multiple, physically different, 339ff662b5cSJustin T. Gibbs * xenbus_watch objects, to watch the same path in the XenStore. 340ff662b5cSJustin T. Gibbs */ 341ff662b5cSJustin T. Gibbs int xs_register_watch(struct xs_watch *watch); 342ff662b5cSJustin T. Gibbs 343ff662b5cSJustin T. Gibbs /** 344ff662b5cSJustin T. Gibbs * Unregister a XenStore watch. 345ff662b5cSJustin T. Gibbs * 346ff662b5cSJustin T. Gibbs * \param watch An xs_watch object previously used in a successful call 347ff662b5cSJustin T. Gibbs * to xs_register_watch(). 348ff662b5cSJustin T. Gibbs * 349ff662b5cSJustin T. Gibbs * The xs_watch object's node field is not altered by this call. 350ff662b5cSJustin T. Gibbs * It is the caller's responsibility to properly dispose of both the 351ff662b5cSJustin T. Gibbs * watch object and the data pointed to by watch->node. 352ff662b5cSJustin T. Gibbs */ 353ff662b5cSJustin T. Gibbs void xs_unregister_watch(struct xs_watch *watch); 354ff662b5cSJustin T. Gibbs 355ff662b5cSJustin T. Gibbs /** 356ff662b5cSJustin T. Gibbs * Allocate and return an sbuf containing the XenStore path string 357ff662b5cSJustin T. Gibbs * <dir>/<name>. If name is the NUL string, the returned sbuf contains 358ff662b5cSJustin T. Gibbs * the path string <dir>. 359ff662b5cSJustin T. Gibbs * 360ff662b5cSJustin T. Gibbs * \param dir The NUL terminated directory prefix for new path. 361ff662b5cSJustin T. Gibbs * \param name The NUL terminated basename for the new path. 362ff662b5cSJustin T. Gibbs * 363ff662b5cSJustin T. Gibbs * \return A buffer containing the joined path. 364ff662b5cSJustin T. Gibbs */ 365ff662b5cSJustin T. Gibbs struct sbuf *xs_join(const char *, const char *); 366ff662b5cSJustin T. Gibbs 36741716b8dSRoger Pau Monné /** 36841716b8dSRoger Pau Monné * Lock the xenstore request mutex. 36941716b8dSRoger Pau Monné */ 37041716b8dSRoger Pau Monné void xs_lock(void); 37141716b8dSRoger Pau Monné 37241716b8dSRoger Pau Monné /** 37341716b8dSRoger Pau Monné * Unlock the xenstore request mutex. 37441716b8dSRoger Pau Monné */ 37541716b8dSRoger Pau Monné void xs_unlock(void); 37641716b8dSRoger Pau Monné 377ff662b5cSJustin T. Gibbs #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ 378