debuggers.hg

view tools/fs-back/fs-backend.h @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents d988dd0f05f2
children 3ffdb094c2c0
line source
1 #ifndef __LIB_FS_BACKEND__
2 #define __LIB_FS_BACKEND__
4 #include <aio.h>
5 #include <xs.h>
6 #include <xen/grant_table.h>
7 #include <xen/event_channel.h>
8 #include <xen/io/ring.h>
9 #include <xen/io/fsif.h>
10 #include "sys-queue.h"
12 #define ROOT_NODE "backend/vfs"
13 #define EXPORTS_SUBNODE "exports"
14 #define EXPORTS_NODE ROOT_NODE"/"EXPORTS_SUBNODE
15 #define WATCH_NODE EXPORTS_NODE"/requests"
16 #define MAX_FDS 16
17 #define MAX_RING_SIZE 16
19 struct fs_export
20 {
21 int export_id;
22 char *export_path;
23 char *name;
24 struct fs_export *next;
25 };
27 struct fs_request
28 {
29 struct fs_mount *mount;
30 int id;
31 int active;
32 void *page; /* Pointer to mapped grant */
33 int count;
34 struct fsif_request req_shadow;
35 struct aiocb aiocb;
36 };
39 struct fs_mount
40 {
41 struct fs_export *export;
42 int dom_id;
43 char *frontend;
44 int mount_id; /* = backend id */
45 grant_ref_t grefs[MAX_RING_SIZE];
46 evtchn_port_t remote_evtchn;
47 int evth; /* Handle to the event channel */
48 evtchn_port_t local_evtchn;
49 int gnth;
50 int shared_ring_size; /* in pages */
51 struct fsif_back_ring ring;
52 int nr_entries;
53 struct fs_request *requests;
54 unsigned short *freelist;
55 int fds[MAX_FDS];
56 LIST_ENTRY(fs_mount) entries;
57 };
59 void terminate_mount_request(struct fs_mount *mount);
61 /* Handle to XenStore driver */
62 extern struct xs_handle *xsh;
64 bool xenbus_create_request_node(void);
65 int xenbus_register_export(struct fs_export *export);
66 int xenbus_get_watch_fd(void);
67 int xenbus_read_mount_request(struct fs_mount *mount, char *frontend);
68 bool xenbus_write_backend_node(struct fs_mount *mount);
69 bool xenbus_write_backend_state(struct fs_mount *mount, const char *state);
70 void xenbus_free_backend_node(struct fs_mount *mount);
71 int xenbus_frontend_state_changed(struct fs_mount *mount, const char *oldstate);
72 bool xenbus_watch_frontend_state(struct fs_mount *mount);
73 bool xenbus_unwatch_frontend_state(struct fs_mount *mount);
74 char* xenbus_read_frontend_state(struct fs_mount *mount);
76 /* File operations, implemented in fs-ops.c */
77 struct fs_op
78 {
79 int type; /* Type of request (from fsif.h) this handlers
80 are responsible for */
81 void (*dispatch_handler)(struct fs_mount *mount, struct fsif_request *req);
82 void (*response_handler)(struct fs_mount *mount, struct fs_request *req);
83 };
85 /* This NULL terminated array of all file requests handlers */
86 extern struct fs_op *fsops[];
88 static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
89 {
90 freelist[id + 1] = freelist[0];
91 freelist[0] = id;
92 }
94 static inline unsigned short get_id_from_freelist(unsigned short* freelist)
95 {
96 unsigned int id = freelist[0];
97 freelist[0] = freelist[id + 1];
98 return id;
99 }
101 #endif /* __LIB_FS_BACKEND__ */