ia64/xen-unstable

view extras/mini-os/include/xenbus.h @ 16838:945820bfedb6

minios: POSIX fixes
Fixes some functions which are POSIX. Also make them ifndef HAVE_LIBC.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 22 14:20:22 2008 +0000 (2008-01-22)
parents 76d88d1da324
children a3bddc22d2f5
line source
1 #ifndef XENBUS_H__
2 #define XENBUS_H__
4 typedef unsigned long xenbus_transaction_t;
5 #define XBT_NIL ((xenbus_transaction_t)0)
7 /* Initialize the XenBus system. */
8 void init_xenbus(void);
10 /* Read the value associated with a path. Returns a malloc'd error
11 string on failure and sets *value to NULL. On success, *value is
12 set to a malloc'd copy of the value. */
13 char *xenbus_read(xenbus_transaction_t xbt, const char *path, char **value);
15 /* Watch event queue */
16 struct xenbus_event {
17 /* Keep these two as this for xs.c */
18 char *path;
19 char *token;
20 struct xenbus_event *next;
21 };
23 char *xenbus_watch_path_token(xenbus_transaction_t xbt, const char *path, const char *token, struct xenbus_event *volatile *events);
24 char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, const char *token);
25 extern struct wait_queue_head xenbus_watch_queue;
26 void xenbus_wait_for_watch(void);
27 char **xenbus_wait_for_watch_return(void);
28 char* xenbus_wait_for_value(const char *path, const char *value);
30 /* When no token is provided, use a global queue. */
31 #define XENBUS_WATCH_PATH_TOKEN "xenbus_watch_path"
32 extern struct xenbus_event * volatile xenbus_events;
33 #define xenbus_watch_path(xbt, path) xenbus_watch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN, NULL)
34 #define xenbus_unwatch_path(xbt, path) xenbus_unwatch_path_token(xbt, path, XENBUS_WATCH_PATH_TOKEN)
37 /* Associates a value with a path. Returns a malloc'd error string on
38 failure. */
39 char *xenbus_write(xenbus_transaction_t xbt, const char *path, const char *value);
41 struct write_req {
42 const void *data;
43 unsigned len;
44 };
46 /* Send a message to xenbus, in the same fashion as xb_write, and
47 block waiting for a reply. The reply is malloced and should be
48 freed by the caller. */
49 struct xsd_sockmsg *
50 xenbus_msg_reply(int type,
51 xenbus_transaction_t trans,
52 struct write_req *io,
53 int nr_reqs);
55 /* Removes the value associated with a path. Returns a malloc'd error
56 string on failure. */
57 char *xenbus_rm(xenbus_transaction_t xbt, const char *path);
59 /* List the contents of a directory. Returns a malloc'd error string
60 on failure and sets *contents to NULL. On success, *contents is
61 set to a malloc'd array of pointers to malloc'd strings. The array
62 is NULL terminated. May block. */
63 char *xenbus_ls(xenbus_transaction_t xbt, const char *prefix, char ***contents);
65 /* Reads permissions associated with a path. Returns a malloc'd error
66 string on failure and sets *value to NULL. On success, *value is
67 set to a malloc'd copy of the value. */
68 char *xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value);
70 /* Sets the permissions associated with a path. Returns a malloc'd
71 error string on failure. */
72 char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm);
74 /* Start a xenbus transaction. Returns the transaction in xbt on
75 success or a malloc'd error string otherwise. */
76 char *xenbus_transaction_start(xenbus_transaction_t *xbt);
78 /* End a xenbus transaction. Returns a malloc'd error string if it
79 fails. abort says whether the transaction should be aborted.
80 Returns 1 in *retry iff the transaction should be retried. */
81 char *xenbus_transaction_end(xenbus_transaction_t, int abort,
82 int *retry);
84 /* Read path and parse it as an integer. Returns -1 on error. */
85 int xenbus_read_integer(char *path);
87 /* Contraction of snprintf and xenbus_write(path/node). */
88 char* xenbus_printf(xenbus_transaction_t xbt,
89 char* node, char* path,
90 char* fmt, ...);
92 #endif /* XENBUS_H__ */