ia64/xen-unstable

view tools/fs-back/fs-backend.h @ 18065:5f529c74a712

fs-backend: Fix freelist implementation

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 15 17:59:31 2008 +0100 (2008-07-15)
parents a1a3fe600ef3
children 649c975b72f0
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>
11 #define ROOT_NODE "backend/vfs"
12 #define EXPORTS_SUBNODE "exports"
13 #define EXPORTS_NODE ROOT_NODE"/"EXPORTS_SUBNODE
14 #define WATCH_NODE EXPORTS_NODE"/requests"
16 struct fs_export
17 {
18 int export_id;
19 char *export_path;
20 char *name;
21 struct fs_export *next;
22 };
24 struct fs_request
25 {
26 int active;
27 void *page; /* Pointer to mapped grant */
28 struct fsif_request req_shadow;
29 struct aiocb aiocb;
30 };
33 struct mount
34 {
35 struct fs_export *export;
36 int dom_id;
37 char *frontend;
38 int mount_id; /* = backend id */
39 grant_ref_t gref;
40 evtchn_port_t remote_evtchn;
41 int evth; /* Handle to the event channel */
42 evtchn_port_t local_evtchn;
43 int gnth;
44 struct fsif_back_ring ring;
45 int nr_entries;
46 struct fs_request *requests;
47 unsigned short *freelist;
48 };
51 /* Handle to XenStore driver */
52 extern struct xs_handle *xsh;
54 bool xenbus_create_request_node(void);
55 int xenbus_register_export(struct fs_export *export);
56 int xenbus_get_watch_fd(void);
57 void xenbus_read_mount_request(struct mount *mount, char *frontend);
58 void xenbus_write_backend_node(struct mount *mount);
59 void xenbus_write_backend_ready(struct mount *mount);
61 /* File operations, implemented in fs-ops.c */
62 struct fs_op
63 {
64 int type; /* Type of request (from fsif.h) this handlers
65 are responsible for */
66 void (*dispatch_handler)(struct mount *mount, struct fsif_request *req);
67 void (*response_handler)(struct mount *mount, struct fs_request *req);
68 };
70 /* This NULL terminated array of all file requests handlers */
71 extern struct fs_op *fsops[];
73 static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
74 {
75 freelist[id + 1] = freelist[0];
76 freelist[0] = id;
77 }
79 static inline unsigned short get_id_from_freelist(unsigned short* freelist)
80 {
81 unsigned int id = freelist[0];
82 freelist[0] = freelist[id + 1];
83 return id;
84 }
86 #endif /* __LIB_FS_BACKEND__ */