ia64/xen-unstable

view tools/xenstore/xs.h @ 8740:3d7ea7972b39

Update patches for linux 2.6.15.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Feb 02 17:16:00 2006 +0000 (2006-02-02)
parents e629bb62c63e
children 9a1809ce711b
line source
1 /*
2 Xen Store Daemon providing simple tree-like database.
3 Copyright (C) 2005 Rusty Russell IBM Corporation
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
20 #ifndef _XS_H
21 #define _XS_H
23 #include <xs_lib.h>
25 #define XBT_NULL 0
27 struct xs_handle;
28 typedef uint32_t xs_transaction_t;
30 /* On failure, these routines set errno. */
32 /* Connect to the xs daemon.
33 * Returns a handle or NULL.
34 */
35 struct xs_handle *xs_daemon_open(void);
36 struct xs_handle *xs_domain_open(void);
38 /* Connect to the xs daemon (readonly for non-root clients).
39 * Returns a handle or NULL.
40 */
41 struct xs_handle *xs_daemon_open_readonly(void);
43 /* Close the connection to the xs daemon. */
44 void xs_daemon_close(struct xs_handle *);
46 /* Get contents of a directory.
47 * Returns a malloced array: call free() on it after use.
48 * Num indicates size.
49 */
50 char **xs_directory(struct xs_handle *h, xs_transaction_t t,
51 const char *path, unsigned int *num);
53 /* Get the value of a single file, nul terminated.
54 * Returns a malloced value: call free() on it after use.
55 * len indicates length in bytes, not including terminator.
56 */
57 void *xs_read(struct xs_handle *h, xs_transaction_t t,
58 const char *path, unsigned int *len);
60 /* Write the value of a single file.
61 * Returns false on failure.
62 */
63 bool xs_write(struct xs_handle *h, xs_transaction_t t,
64 const char *path, const void *data, unsigned int len);
66 /* Create a new directory.
67 * Returns false on failure, or success if it already exists.
68 */
69 bool xs_mkdir(struct xs_handle *h, xs_transaction_t t,
70 const char *path);
72 /* Destroy a file or directory (and children).
73 * Returns false on failure, or if it doesn't exist.
74 */
75 bool xs_rm(struct xs_handle *h, xs_transaction_t t,
76 const char *path);
78 /* Get permissions of node (first element is owner, first perms is "other").
79 * Returns malloced array, or NULL: call free() after use.
80 */
81 struct xs_permissions *xs_get_permissions(struct xs_handle *h,
82 xs_transaction_t t,
83 const char *path, unsigned int *num);
85 /* Set permissions of node (must be owner).
86 * Returns false on failure.
87 */
88 bool xs_set_permissions(struct xs_handle *h, xs_transaction_t t,
89 const char *path, struct xs_permissions *perms,
90 unsigned int num_perms);
92 /* Watch a node for changes (poll on fd to detect, or call read_watch()).
93 * When the node (or any child) changes, fd will become readable.
94 * Token is returned when watch is read, to allow matching.
95 * Returns false on failure.
96 */
97 bool xs_watch(struct xs_handle *h, const char *path, const char *token);
99 /* Return the FD to poll on to see if a watch has fired. */
100 int xs_fileno(struct xs_handle *h);
102 /* Find out what node change was on (will block if nothing pending).
103 * Returns array containing the path and token. Use XS_WATCH_* to access these
104 * elements. Call free() after use.
105 */
106 char **xs_read_watch(struct xs_handle *h, unsigned int *num);
108 /* Remove a watch on a node: implicitly acks any outstanding watch.
109 * Returns false on failure (no watch on that node).
110 */
111 bool xs_unwatch(struct xs_handle *h, const char *path, const char *token);
113 /* Start a transaction: changes by others will not be seen during this
114 * transaction, and changes will not be visible to others until end.
115 * You can only have one transaction at any time.
116 * Returns NULL on failure.
117 */
118 xs_transaction_t xs_transaction_start(struct xs_handle *h);
120 /* End a transaction.
121 * If abandon is true, transaction is discarded instead of committed.
122 * Returns false on failure: if errno == EAGAIN, you have to restart
123 * transaction.
124 */
125 bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t,
126 bool abort);
128 /* Introduce a new domain.
129 * This tells the store daemon about a shared memory page, event channel and
130 * store path associated with a domain: the domain uses these to communicate.
131 */
132 bool xs_introduce_domain(struct xs_handle *h,
133 unsigned int domid,
134 unsigned long mfn,
135 unsigned int eventchn);
136 /* Release a domain.
137 * Tells the store domain to release the memory page to the domain.
138 */
139 bool xs_release_domain(struct xs_handle *h, unsigned int domid);
141 /* Query the home path of a domain. Call free() after use.
142 */
143 char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
145 /* Return whether the domain specified has been introduced to xenstored.
146 */
147 bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
149 /* Only useful for DEBUG versions */
150 char *xs_debug_command(struct xs_handle *h, const char *cmd,
151 void *data, unsigned int len);
153 #endif /* _XS_H */
155 /*
156 * Local variables:
157 * c-file-style: "linux"
158 * indent-tabs-mode: t
159 * c-indent-level: 8
160 * c-basic-offset: 8
161 * tab-width: 8
162 * End:
163 */