ia64/xen-unstable

view tools/xenstore/xenstored_core.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 a90d670c98b9
children 689da5e0a970
line source
1 /*
2 Internal interfaces for Xen Store Daemon.
3 Copyright (C) 2005 Rusty Russell IBM Corporation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
20 #ifndef _XENSTORED_CORE_H
21 #define _XENSTORED_CORE_H
23 #include <sys/types.h>
24 #include <dirent.h>
25 #include <stdbool.h>
26 #include <stdint.h>
27 #include <errno.h>
28 #include "xs_lib.h"
29 #include "list.h"
30 #include "tdb.h"
32 struct buffered_data
33 {
34 struct list_head list;
36 /* Are we still doing the header? */
37 bool inhdr;
39 /* How far are we? */
40 unsigned int used;
42 union {
43 struct xsd_sockmsg msg;
44 char raw[sizeof(struct xsd_sockmsg)];
45 } hdr;
47 /* The actual data. */
48 char *buffer;
49 };
51 struct connection;
52 typedef int connwritefn_t(struct connection *, const void *, unsigned int);
53 typedef int connreadfn_t(struct connection *, void *, unsigned int);
55 struct connection
56 {
57 struct list_head list;
59 /* The file descriptor we came in on. */
60 int fd;
62 /* Who am I? 0 for socket connections. */
63 unsigned int id;
65 /* Is this a read-only connection? */
66 bool can_write;
68 /* Buffered incoming data. */
69 struct buffered_data *in;
71 /* Buffered output data */
72 struct list_head out_list;
74 /* Transaction context for current request (NULL if none). */
75 struct transaction *transaction;
77 /* List of in-progress transactions. */
78 struct list_head transaction_list;
79 uint32_t next_transaction_id;
81 /* The domain I'm associated with, if any. */
82 struct domain *domain;
84 /* My watches. */
85 struct list_head watches;
87 /* Methods for communicating over this connection: write can be NULL */
88 connwritefn_t *write;
89 connreadfn_t *read;
90 };
91 extern struct list_head connections;
93 struct node {
94 const char *name;
96 /* Database I came from */
97 TDB_CONTEXT *tdb;
99 /* Parent (optional) */
100 struct node *parent;
102 /* Permissions. */
103 unsigned int num_perms;
104 struct xs_permissions *perms;
106 /* Contents. */
107 unsigned int datalen;
108 void *data;
110 /* Children, each nul-terminated. */
111 unsigned int childlen;
112 char *children;
113 };
115 /* Break input into vectors, return the number, fill in up to num of them. */
116 unsigned int get_strings(struct buffered_data *data,
117 char *vec[], unsigned int num);
119 /* Is child node a child or equal to parent node? */
120 bool is_child(const char *child, const char *parent);
122 void send_reply(struct connection *conn, enum xsd_sockmsg_type type,
123 const void *data, unsigned int len);
125 /* Some routines (write, mkdir, etc) just need a non-error return */
126 void send_ack(struct connection *conn, enum xsd_sockmsg_type type);
128 /* Send an error: error is usually "errno". */
129 void send_error(struct connection *conn, int error);
131 /* Canonicalize this path if possible. */
132 char *canonicalize(struct connection *conn, const char *node);
134 /* Check if node is an event node. */
135 bool check_event_node(const char *node);
137 /* Get this node, checking we have permissions. */
138 struct node *get_node(struct connection *conn,
139 const char *name,
140 enum xs_perm_type perm);
142 /* Get TDB context for this connection */
143 TDB_CONTEXT *tdb_context(struct connection *conn);
145 /* Destructor for tdbs: required for transaction code */
146 int destroy_tdb(void *_tdb);
148 /* Replace the tdb: required for transaction code */
149 bool replace_tdb(const char *newname, TDB_CONTEXT *newtdb);
151 /* Fail due to excessive corruption, capitalist pigdogs! */
152 void __attribute__((noreturn)) corrupt(struct connection *conn,
153 const char *fmt, ...);
155 struct connection *new_connection(connwritefn_t *write, connreadfn_t *read);
158 /* Is this a valid node name? */
159 bool is_valid_nodename(const char *node);
162 /* Tracing infrastructure. */
163 void trace_create(const void *data, const char *type);
164 void trace_destroy(const void *data, const char *type);
165 void trace_watch_timeout(const struct connection *conn, const char *node, const char *token);
166 void trace(const char *fmt, ...);
168 extern int event_fd;
170 #endif /* _XENSTORED_CORE_H */
172 /*
173 * Local variables:
174 * c-file-style: "linux"
175 * indent-tabs-mode: t
176 * c-indent-level: 8
177 * c-basic-offset: 8
178 * tab-width: 8
179 * End:
180 */