38 #include <linux/kernel.h>
39 #include <linux/errno.h>
40 #include <linux/uio.h>
42 #include <linux/wait.h>
44 #include <linux/poll.h>
46 #include <linux/sched.h>
53 #include <linux/string.h>
54 #include <linux/slab.h>
56 #include <linux/module.h>
62 #include <asm/xen/hypervisor.h>
121 size_t len, loff_t *ppos)
145 unsigned sz =
min((
unsigned)len - i, rb->
len - rb->
cons);
211 while (!list_empty(list)) {
252 free_watch_adapter(watch);
265 int path_len, tok_len, body_len,
data_len = 0;
274 path_len =
strlen(path) + 1;
275 tok_len =
strlen(token) + 1;
277 data_len = vec[
len] - vec[2] + 1;
278 body_len = path_len + tok_len +
data_len;
285 ret = queue_reply(&staging_q, &
hdr,
sizeof(
hdr));
287 ret = queue_reply(&staging_q, path, path_len);
289 ret = queue_reply(&staging_q, token, tok_len);
291 ret = queue_reply(&staging_q, vec[2], data_len);
295 list_splice_tail(&staging_q, &adap->
dev_data->read_buffers);
298 queue_cleanup(&staging_q);
303 static int xenbus_write_transaction(
unsigned msg_type,
334 BUG_ON(&trans->list == &u->transactions);
341 rc = queue_reply(&staging_q, &u->u.
msg,
sizeof(u->u.msg));
343 rc = queue_reply(&staging_q, reply, u->u.msg.len);
348 queue_cleanup(&staging_q);
358 static int xenbus_write_watch(
unsigned msg_type,
struct xenbus_file_priv *u)
378 watch = alloc_watch_adapter(path, token);
384 watch->
watch.callback = watch_fired;
389 free_watch_adapter(watch);
400 free_watch_adapter(watch);
414 .len =
sizeof(reply.body)
420 rc = queue_reply(&u->
read_buffers, &reply,
sizeof(reply));
429 static ssize_t xenbus_file_write(
struct file *filp,
430 const char __user *ubuf,
431 size_t len, loff_t *ppos)
500 msg_type = u->
u.
msg.type;
506 ret = xenbus_write_watch(msg_type, u);
511 ret = xenbus_write_transaction(msg_type, u);
525 static int xenbus_file_open(
struct inode *
inode,
struct file *filp)
551 static int xenbus_file_release(
struct inode *inode,
struct file *filp)
572 free_watch_adapter(watch);
595 .read = xenbus_file_read,
596 .write = xenbus_file_write,
597 .open = xenbus_file_open,
598 .release = xenbus_file_release,
599 .poll = xenbus_file_poll,
606 .name =
"xen/xenbus",
610 static int __init xenbus_init(
void)
623 static void __exit xenbus_exit(
void)