1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <xen/interface/xen.h>
7 #include <xen/interface/io/xenbus.h>
9 typedef unsigned long xenbus_transaction_t;
10 #define XBT_NIL ((xenbus_transaction_t)0)
12 extern u32 xenbus_evtchn;
14 /* Initialize the XenBus system. */
15 void init_xenbus(void);
16 /* Finalize the XenBus system. */
17 void fini_xenbus(void);
20 * xenbus_read() - Read the value associated with a path.
22 * Returns a malloc'd error string on failure and sets *value to NULL.
23 * On success, *value is set to a malloc'd copy of the value.
25 char *xenbus_read(xenbus_transaction_t xbt, const char *path, char **value);
27 char *xenbus_wait_for_state_change(const char *path, XenbusState *state);
28 char *xenbus_switch_state(xenbus_transaction_t xbt, const char *path,
32 * xenbus_write() - Associates a value with a path.
34 * Returns a malloc'd error string on failure.
36 char *xenbus_write(xenbus_transaction_t xbt, const char *path,
40 * xenbus_rm() - Removes the value associated with a path.
42 * Returns a malloc'd error string on failure.
44 char *xenbus_rm(xenbus_transaction_t xbt, const char *path);
47 * xenbus_ls() - List the contents of a directory.
49 * Returns a malloc'd error string on failure and sets *contents to NULL.
50 * On success, *contents is set to a malloc'd array of pointers to malloc'd
51 * strings. The array is NULL terminated. May block.
53 char *xenbus_ls(xenbus_transaction_t xbt, const char *prefix, char ***contents);
56 * xenbus_get_perms() - Reads permissions associated with a path.
58 * Returns a malloc'd error string on failure and sets *value to NULL.
59 * On success, *value is set to a malloc'd copy of the value.
61 char *xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value);
64 * xenbus_set_perms() - Sets the permissions associated with a path.
66 * Returns a malloc'd error string on failure.
68 char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom,
72 * xenbus_transaction_start() - Start a xenbus transaction.
74 * Returns the transaction in xbt on success or a malloc'd error string
77 char *xenbus_transaction_start(xenbus_transaction_t *xbt);
80 * xenbus_transaction_end() - End a xenbus transaction.
82 * Returns a malloc'd error string if it fails. Abort says whether the
83 * transaction should be aborted.
84 * Returns 1 in *retry if the transaction should be retried.
86 char *xenbus_transaction_end(xenbus_transaction_t xbt, int abort,
90 * xenbus_read_integer() - Read path and parse it as an integer.
92 * Returns -1 on error.
94 int xenbus_read_integer(const char *path);
97 * xenbus_read_uuid() - Read path and parse it as 16 byte uuid.
99 * Returns 1 if read and parsing were successful, 0 if not
101 int xenbus_read_uuid(const char *path, unsigned char uuid[16]);
104 * xenbus_printf() - Contraction of snprintf and xenbus_write(path/node).
106 char *xenbus_printf(xenbus_transaction_t xbt,
107 const char *node, const char *path,
108 const char *fmt, ...)
109 __attribute__((__format__(printf, 4, 5)));
112 * xenbus_get_self_id() - Utility function to figure out our domain id
114 domid_t xenbus_get_self_id(void);
116 #endif /* XENBUS_H__ */