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#include <linux/utsname.h>
30
31
32#define P9_ROW_MAXTAG 255
33
34
35
36
37
38
39
40enum p9_proto_versions{
41 p9_proto_legacy,
42 p9_proto_2000u,
43 p9_proto_2000L,
44};
45
46
47
48
49
50
51
52
53
54
55
56
57enum p9_trans_status {
58 Connected,
59 BeginDisconnect,
60 Disconnected,
61 Hung,
62};
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80enum p9_req_status_t {
81 REQ_STATUS_IDLE,
82 REQ_STATUS_ALLOC,
83 REQ_STATUS_UNSENT,
84 REQ_STATUS_SENT,
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
160 struct p9_idpool *fidpool;
161 struct list_head fidlist;
162
163 struct p9_idpool *tagpool;
164 struct p9_req_t *reqs[P9_ROW_MAXTAG];
165 int max_tag;
166
167 char name[__NEW_UTS_LEN + 1];
168};
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185struct p9_fid {
186 struct p9_client *clnt;
187 u32 fid;
188 int mode;
189 struct p9_qid qid;
190 u32 iounit;
191 kuid_t uid;
192
193 void *rdir;
194
195 struct list_head flist;
196 struct hlist_node dlist;
197};
198
199
200
201
202
203
204
205
206
207struct p9_dirent {
208 struct p9_qid qid;
209 u64 d_off;
210 unsigned char d_type;
211 char d_name[256];
212};
213
214struct iov_iter;
215
216int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
217int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid,
218 const char *name);
219int p9_client_renameat(struct p9_fid *olddirfid, const char *old_name,
220 struct p9_fid *newdirfid, const char *new_name);
221struct p9_client *p9_client_create(const char *dev_name, char *options);
222void p9_client_destroy(struct p9_client *clnt);
223void p9_client_disconnect(struct p9_client *clnt);
224void p9_client_begin_disconnect(struct p9_client *clnt);
225struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
226 const char *uname, kuid_t n_uname, const char *aname);
227struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
228 const unsigned char * const *wnames, int clone);
229int p9_client_open(struct p9_fid *fid, int mode);
230int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
231 char *extension);
232int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, const char *newname);
233int p9_client_symlink(struct p9_fid *fid, const char *name, const char *symname,
234 kgid_t gid, struct p9_qid *qid);
235int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, u32 mode,
236 kgid_t gid, struct p9_qid *qid);
237int p9_client_clunk(struct p9_fid *fid);
238int p9_client_fsync(struct p9_fid *fid, int datasync);
239int p9_client_remove(struct p9_fid *fid);
240int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags);
241int p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err);
242int p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err);
243int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
244int p9dirent_read(struct p9_client *clnt, char *buf, int len,
245 struct p9_dirent *dirent);
246struct p9_wstat *p9_client_stat(struct p9_fid *fid);
247int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
248int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr);
249
250struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
251 u64 request_mask);
252
253int p9_client_mknod_dotl(struct p9_fid *oldfid, const char *name, int mode,
254 dev_t rdev, kgid_t gid, struct p9_qid *);
255int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
256 kgid_t gid, struct p9_qid *);
257int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
258int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);
259struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
260void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status);
261
262int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int);
263int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *);
264void p9stat_free(struct p9_wstat *);
265
266int p9_is_proto_dotu(struct p9_client *clnt);
267int p9_is_proto_dotl(struct p9_client *clnt);
268struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *);
269int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int);
270int p9_client_readlink(struct p9_fid *fid, char **target);
271
272#endif
273