1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef NET_9P_CLIENT_H
27#define NET_9P_CLIENT_H
28
29
30#define P9_ROW_MAXTAG 255
31
32
33
34
35
36
37
38enum p9_proto_versions{
39 p9_proto_legacy,
40 p9_proto_2000u,
41 p9_proto_2000L,
42};
43
44
45
46
47
48
49
50
51
52
53
54
55enum p9_trans_status {
56 Connected,
57 BeginDisconnect,
58 Disconnected,
59 Hung,
60};
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79enum p9_req_status_t {
80 REQ_STATUS_IDLE,
81 REQ_STATUS_ALLOC,
82 REQ_STATUS_UNSENT,
83 REQ_STATUS_SENT,
84 REQ_STATUS_FLSH,
85 REQ_STATUS_RCVD,
86 REQ_STATUS_FLSHD,
87 REQ_STATUS_ERROR,
88};
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112struct p9_req_t {
113 int status;
114 int t_err;
115 wait_queue_head_t *wq;
116 struct p9_fcall *tc;
117 struct p9_fcall *rc;
118 void *aux;
119
120 struct list_head req_list;
121};
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152struct p9_client {
153 spinlock_t lock;
154 unsigned int msize;
155 unsigned char proto_version;
156 struct p9_trans_module *trans_mod;
157 enum p9_trans_status status;
158 void *trans;
159 struct p9_conn *conn;
160
161 struct p9_idpool *fidpool;
162 struct list_head fidlist;
163
164 struct p9_idpool *tagpool;
165 struct p9_req_t *reqs[P9_ROW_MAXTAG];
166 int max_tag;
167};
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184struct p9_fid {
185 struct p9_client *clnt;
186 u32 fid;
187 int mode;
188 struct p9_qid qid;
189 u32 iounit;
190 uid_t uid;
191
192 void *rdir;
193
194 struct list_head flist;
195 struct list_head dlist;
196};
197
198
199
200
201
202
203
204
205
206struct p9_dirent {
207 struct p9_qid qid;
208 u64 d_off;
209 unsigned char d_type;
210 char d_name[256];
211};
212
213int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
214int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid,
215 const char *name);
216int p9_client_renameat(struct p9_fid *olddirfid, const char *old_name,
217 struct p9_fid *newdirfid, const char *new_name);
218struct p9_client *p9_client_create(const char *dev_name, char *options);
219void p9_client_destroy(struct p9_client *clnt);
220void p9_client_disconnect(struct p9_client *clnt);
221void p9_client_begin_disconnect(struct p9_client *clnt);
222struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
223 char *uname, u32 n_uname, char *aname);
224struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
225 char **wnames, int clone);
226int p9_client_open(struct p9_fid *fid, int mode);
227int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
228 char *extension);
229int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, char *newname);
230int p9_client_symlink(struct p9_fid *fid, char *name, char *symname, gid_t gid,
231 struct p9_qid *qid);
232int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
233 gid_t gid, struct p9_qid *qid);
234int p9_client_clunk(struct p9_fid *fid);
235int p9_client_fsync(struct p9_fid *fid, int datasync);
236int p9_client_remove(struct p9_fid *fid);
237int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags);
238int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
239 u64 offset, u32 count);
240int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
241 u64 offset, u32 count);
242int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
243int p9dirent_read(struct p9_client *clnt, char *buf, int len,
244 struct p9_dirent *dirent);
245struct p9_wstat *p9_client_stat(struct p9_fid *fid);
246int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
247int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr);
248
249struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
250 u64 request_mask);
251
252int p9_client_mknod_dotl(struct p9_fid *oldfid, char *name, int mode,
253 dev_t rdev, gid_t gid, struct p9_qid *);
254int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
255 gid_t gid, struct p9_qid *);
256int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
257int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);
258struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
259void p9_client_cb(struct p9_client *c, struct p9_req_t *req);
260
261int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int);
262int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *);
263void p9stat_free(struct p9_wstat *);
264
265int p9_is_proto_dotu(struct p9_client *clnt);
266int p9_is_proto_dotl(struct p9_client *clnt);
267struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *);
268int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int);
269int p9_client_readlink(struct p9_fid *fid, char **target);
270
271#endif
272