ia64/xen-unstable

view tools/xenstore/xs.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
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 struct xs_handle;
27 /* On failure, these routines set errno. */
29 /* Connect to the xs daemon.
30 * Returns a handle or NULL.
31 */
32 struct xs_handle *xs_daemon_open(void);
34 /* Connect to the xs daemon (readonly for non-root clients).
35 * Returns a handle or NULL.
36 */
37 struct xs_handle *xs_daemon_open_readonly(void);
39 /* Close the connection to the xs daemon. */
40 void xs_daemon_close(struct xs_handle *);
42 /* Get contents of a directory.
43 * Returns a malloced array: call free() on it after use.
44 * Num indicates size.
45 */
46 char **xs_directory(struct xs_handle *h, const char *path, unsigned int *num);
48 /* Get the value of a single file, nul terminated.
49 * Returns a malloced value: call free() on it after use.
50 * len indicates length in bytes, not including terminator.
51 */
52 void *xs_read(struct xs_handle *h, const char *path, unsigned int *len);
54 /* Write the value of a single file.
55 * Returns false on failure. createflags can be 0, O_CREAT, or O_CREAT|O_EXCL.
56 */
57 bool xs_write(struct xs_handle *h, const char *path, const void *data,
58 unsigned int len, int createflags);
60 /* Create a new directory.
61 * Returns false on failure.
62 */
63 bool xs_mkdir(struct xs_handle *h, const char *path);
65 /* Destroy a file or directory (and children).
66 * Returns false on failure.
67 */
68 bool xs_rm(struct xs_handle *h, const char *path);
70 /* Get permissions of node (first element is owner, first perms is "other").
71 * Returns malloced array, or NULL: call free() after use.
72 */
73 struct xs_permissions *xs_get_permissions(struct xs_handle *h,
74 const char *path, unsigned int *num);
76 /* Set permissions of node (must be owner).
77 * Returns false on failure.
78 */
79 bool xs_set_permissions(struct xs_handle *h, const char *path,
80 struct xs_permissions *perms, unsigned int num_perms);
82 /* Watch a node for changes (poll on fd to detect, or call read_watch()).
83 * When the node (or any child) changes, fd will become readable.
84 * Token is returned when watch is read, to allow matching.
85 * Returns false on failure.
86 */
87 bool xs_watch(struct xs_handle *h, const char *path, const char *token);
89 /* Return the FD to poll on to see if a watch has fired. */
90 int xs_fileno(struct xs_handle *h);
92 /* Find out what node change was on (will block if nothing pending).
93 * Returns array of two pointers: path and token, or NULL.
94 * Call free() after use.
95 */
96 char **xs_read_watch(struct xs_handle *h);
98 /* Acknowledge watch on node. Watches must be acknowledged before
99 * any other watches can be read.
100 * Returns false on failure.
101 */
102 bool xs_acknowledge_watch(struct xs_handle *h, const char *token);
104 /* Remove a watch on a node: implicitly acks any outstanding watch.
105 * Returns false on failure (no watch on that node).
106 */
107 bool xs_unwatch(struct xs_handle *h, const char *path, const char *token);
109 /* Start a transaction: changes by others will not be seen during this
110 * transaction, and changes will not be visible to others until end.
111 * Transaction only applies to the given subtree.
112 * You can only have one transaction at any time.
113 * Returns false on failure.
114 */
115 bool xs_transaction_start(struct xs_handle *h, const char *subtree);
117 /* End a transaction.
118 * If abandon is true, transaction is discarded instead of committed.
119 * Returns false on failure, which indicates an error: transactions will
120 * not fail spuriously.
121 */
122 bool xs_transaction_end(struct xs_handle *h, bool abort);
124 /* Introduce a new domain.
125 * This tells the store daemon about a shared memory page, event channel
126 * and store path associated with a domain: the domain uses these to communicate.
127 */
128 bool xs_introduce_domain(struct xs_handle *h, domid_t domid, unsigned long mfn,
129 unsigned int eventchn, const char *path);
131 /* Release a domain.
132 * Tells the store domain to release the memory page to the domain.
133 */
134 bool xs_release_domain(struct xs_handle *h, domid_t domid);
136 /* Only useful for DEBUG versions */
137 char *xs_debug_command(struct xs_handle *h, const char *cmd,
138 void *data, unsigned int len);
140 /* Shut down the daemon. */
141 bool xs_shutdown(struct xs_handle *h);
143 #endif /* _XS_H */