| 1 | #ifndef XENBUS_H__ |
|---|
| 2 | #define XENBUS_H__ |
|---|
| 3 | |
|---|
| 4 | typedef unsigned long xenbus_transaction_t; |
|---|
| 5 | #define XBT_NIL ((xenbus_transaction_t)0) |
|---|
| 6 | |
|---|
| 7 | /* Initialize the XenBus system. */ |
|---|
| 8 | void init_xenbus(void); |
|---|
| 9 | |
|---|
| 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); |
|---|
| 14 | |
|---|
| 15 | char *xenbus_watch_path(xenbus_transaction_t xbt, const char *path); |
|---|
| 16 | void wait_for_watch(void); |
|---|
| 17 | char* xenbus_wait_for_value(const char*,const char*); |
|---|
| 18 | |
|---|
| 19 | /* Associates a value with a path. Returns a malloc'd error string on |
|---|
| 20 | failure. */ |
|---|
| 21 | char *xenbus_write(xenbus_transaction_t xbt, const char *path, const char *value); |
|---|
| 22 | |
|---|
| 23 | /* Removes the value associated with a path. Returns a malloc'd error |
|---|
| 24 | string on failure. */ |
|---|
| 25 | char *xenbus_rm(xenbus_transaction_t xbt, const char *path); |
|---|
| 26 | |
|---|
| 27 | /* List the contents of a directory. Returns a malloc'd error string |
|---|
| 28 | on failure and sets *contents to NULL. On success, *contents is |
|---|
| 29 | set to a malloc'd array of pointers to malloc'd strings. The array |
|---|
| 30 | is NULL terminated. May block. */ |
|---|
| 31 | char *xenbus_ls(xenbus_transaction_t xbt, const char *prefix, char ***contents); |
|---|
| 32 | |
|---|
| 33 | /* Reads permissions associated with a path. Returns a malloc'd error |
|---|
| 34 | string on failure and sets *value to NULL. On success, *value is |
|---|
| 35 | set to a malloc'd copy of the value. */ |
|---|
| 36 | char *xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value); |
|---|
| 37 | |
|---|
| 38 | /* Sets the permissions associated with a path. Returns a malloc'd |
|---|
| 39 | error string on failure. */ |
|---|
| 40 | char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm); |
|---|
| 41 | |
|---|
| 42 | /* Start a xenbus transaction. Returns the transaction in xbt on |
|---|
| 43 | success or a malloc'd error string otherwise. */ |
|---|
| 44 | char *xenbus_transaction_start(xenbus_transaction_t *xbt); |
|---|
| 45 | |
|---|
| 46 | /* End a xenbus transaction. Returns a malloc'd error string if it |
|---|
| 47 | fails. abort says whether the transaction should be aborted. |
|---|
| 48 | Returns 1 in *retry iff the transaction should be retried. */ |
|---|
| 49 | char *xenbus_transaction_end(xenbus_transaction_t, int abort, |
|---|
| 50 | int *retry); |
|---|
| 51 | |
|---|
| 52 | /* Read path and parse it as an integer. Returns -1 on error. */ |
|---|
| 53 | int xenbus_read_integer(char *path); |
|---|
| 54 | |
|---|
| 55 | #endif /* XENBUS_H__ */ |
|---|