ia64/xen-unstable

view extras/mini-os/include/xenbus.h @ 19836:d9890e67d2b7

tools: add SHAREDIR to buildmakevars2file

c/s 19818 dropped SHAREDIR from xen/util/path.py, which broke the "xm
new" command. This patch adds SHAREDIR back to the new
buildmakevars2file-closure function.

Signed-off-by: Ryan O'Connor <rjo@cs.ubc.ca>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:05:10 2009 +0100 (2009-06-25)
parents 18c8270da77c
children
line source
1 #ifndef XENBUS_H__
2 #define XENBUS_H__
4 #include <xen/io/xenbus.h>
6 typedef unsigned long xenbus_transaction_t;
7 #define XBT_NIL ((xenbus_transaction_t)0)
9 /* Initialize the XenBus system. */
10 void init_xenbus(void);
12 /* Read the value associated with a path. Returns a malloc'd error
13 string on failure and sets *value to NULL. On success, *value is
14 set to a malloc'd copy of the value. */
15 char *xenbus_read(xenbus_transaction_t xbt, const char *path, char **value);
17 /* Watch event queue */
18 struct xenbus_event {
19 /* Keep these two as this for xs.c */
20 char *path;
21 char *token;
22 struct xenbus_event *next;
23 };
24 typedef struct xenbus_event *xenbus_event_queue;
26 char *xenbus_watch_path_token(xenbus_transaction_t xbt, const char *path, const char *token, xenbus_event_queue *events);
27 char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, const char *token);
28 extern struct wait_queue_head xenbus_watch_queue;
29 void xenbus_wait_for_watch(xenbus_event_queue *queue);
30 char **xenbus_wait_for_watch_return(xenbus_event_queue *queue);
31 char* xenbus_wait_for_value(const char *path, const char *value, xenbus_event_queue *queue);
32 char *xenbus_wait_for_state_change(const char* path, XenbusState *state, xenbus_event_queue *queue);
33 char *xenbus_switch_state(xenbus_transaction_t xbt, const char* path, XenbusState state);
35 /* When no token is provided, use a global queue. */
36 #define XENBUS_WATCH_PATH_TOKEN "xenbus_watch_path"
37 extern xenbus_event_queue xenbus_events;
38 #define xenbus_watch_path(xbt, path) xenbus_watch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN, NULL)
39 #define xenbus_unwatch_path(xbt, path) xenbus_unwatch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN)
42 /* Associates a value with a path. Returns a malloc'd error string on
43 failure. */
44 char *xenbus_write(xenbus_transaction_t xbt, const char *path, const char *value);
46 struct write_req {
47 const void *data;
48 unsigned len;
49 };
51 /* Send a message to xenbus, in the same fashion as xb_write, and
52 block waiting for a reply. The reply is malloced and should be
53 freed by the caller. */
54 struct xsd_sockmsg *
55 xenbus_msg_reply(int type,
56 xenbus_transaction_t trans,
57 struct write_req *io,
58 int nr_reqs);
60 /* Removes the value associated with a path. Returns a malloc'd error
61 string on failure. */
62 char *xenbus_rm(xenbus_transaction_t xbt, const char *path);
64 /* List the contents of a directory. Returns a malloc'd error string
65 on failure and sets *contents to NULL. On success, *contents is
66 set to a malloc'd array of pointers to malloc'd strings. The array
67 is NULL terminated. May block. */
68 char *xenbus_ls(xenbus_transaction_t xbt, const char *prefix, char ***contents);
70 /* Reads permissions associated with a path. Returns a malloc'd error
71 string on failure and sets *value to NULL. On success, *value is
72 set to a malloc'd copy of the value. */
73 char *xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value);
75 /* Sets the permissions associated with a path. Returns a malloc'd
76 error string on failure. */
77 char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm);
79 /* Start a xenbus transaction. Returns the transaction in xbt on
80 success or a malloc'd error string otherwise. */
81 char *xenbus_transaction_start(xenbus_transaction_t *xbt);
83 /* End a xenbus transaction. Returns a malloc'd error string if it
84 fails. abort says whether the transaction should be aborted.
85 Returns 1 in *retry iff the transaction should be retried. */
86 char *xenbus_transaction_end(xenbus_transaction_t, int abort,
87 int *retry);
89 /* Read path and parse it as an integer. Returns -1 on error. */
90 int xenbus_read_integer(const char *path);
92 /* Contraction of snprintf and xenbus_write(path/node). */
93 char* xenbus_printf(xenbus_transaction_t xbt,
94 const char* node, const char* path,
95 const char* fmt, ...)
96 __attribute__((__format__(printf, 4, 5)));
98 /* Utility function to figure out our domain id */
99 domid_t xenbus_get_self_id(void);
101 /* Reset the XenBus system. */
102 void fini_xenbus(void);
104 #endif /* XENBUS_H__ */