Revision cc720ddb hw/9pfs/cofile.c
b/hw/9pfs/cofile.c | ||
---|---|---|
61 | 61 |
return err; |
62 | 62 |
} |
63 | 63 |
|
64 |
int v9fs_co_fstat(V9fsPDU *pdu, int fd, struct stat *stbuf)
|
|
64 |
int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
|
|
65 | 65 |
{ |
66 | 66 |
int err; |
67 | 67 |
V9fsState *s = pdu->s; |
... | ... | |
71 | 71 |
} |
72 | 72 |
v9fs_co_run_in_worker( |
73 | 73 |
{ |
74 |
err = s->ops->fstat(&s->ctx, fd, stbuf);
|
|
74 |
err = s->ops->fstat(&s->ctx, &fidp->fs, stbuf);
|
|
75 | 75 |
if (err < 0) { |
76 | 76 |
err = -errno; |
77 | 77 |
} |
... | ... | |
90 | 90 |
v9fs_path_read_lock(s); |
91 | 91 |
v9fs_co_run_in_worker( |
92 | 92 |
{ |
93 |
fidp->fs.fd = s->ops->open(&s->ctx, &fidp->path, flags);
|
|
94 |
if (fidp->fs.fd == -1) {
|
|
93 |
err = s->ops->open(&s->ctx, &fidp->path, flags, &fidp->fs);
|
|
94 |
if (err == -1) {
|
|
95 | 95 |
err = -errno; |
96 | 96 |
} else { |
97 | 97 |
err = 0; |
... | ... | |
130 | 130 |
v9fs_path_read_lock(s); |
131 | 131 |
v9fs_co_run_in_worker( |
132 | 132 |
{ |
133 |
fidp->fs.fd = s->ops->open2(&s->ctx, &fidp->path,
|
|
134 |
name->data, flags, &cred);
|
|
135 |
if (fidp->fs.fd == -1) {
|
|
133 |
err = s->ops->open2(&s->ctx, &fidp->path,
|
|
134 |
name->data, flags, &cred, &fidp->fs);
|
|
135 |
if (err < 0) {
|
|
136 | 136 |
err = -errno; |
137 | 137 |
} else { |
138 | 138 |
v9fs_path_init(&path); |
... | ... | |
141 | 141 |
err = s->ops->lstat(&s->ctx, &path, stbuf); |
142 | 142 |
if (err < 0) { |
143 | 143 |
err = -errno; |
144 |
s->ops->close(&s->ctx, fidp->fs.fd);
|
|
144 |
s->ops->close(&s->ctx, &fidp->fs);
|
|
145 | 145 |
} else { |
146 | 146 |
v9fs_path_copy(&fidp->path, &path); |
147 | 147 |
} |
148 | 148 |
} else { |
149 |
s->ops->close(&s->ctx, fidp->fs.fd);
|
|
149 |
s->ops->close(&s->ctx, &fidp->fs);
|
|
150 | 150 |
} |
151 | 151 |
v9fs_path_free(&path); |
152 | 152 |
} |
... | ... | |
161 | 161 |
return err; |
162 | 162 |
} |
163 | 163 |
|
164 |
int v9fs_co_close(V9fsPDU *pdu, int fd)
|
|
164 |
int v9fs_co_close(V9fsPDU *pdu, V9fsFidOpenState *fs)
|
|
165 | 165 |
{ |
166 | 166 |
int err; |
167 | 167 |
V9fsState *s = pdu->s; |
... | ... | |
171 | 171 |
} |
172 | 172 |
v9fs_co_run_in_worker( |
173 | 173 |
{ |
174 |
err = s->ops->close(&s->ctx, fd);
|
|
174 |
err = s->ops->close(&s->ctx, fs);
|
|
175 | 175 |
if (err < 0) { |
176 | 176 |
err = -errno; |
177 | 177 |
} |
... | ... | |
184 | 184 |
|
185 | 185 |
int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync) |
186 | 186 |
{ |
187 |
int fd, err;
|
|
187 |
int err; |
|
188 | 188 |
V9fsState *s = pdu->s; |
189 | 189 |
|
190 | 190 |
if (v9fs_request_cancelled(pdu)) { |
191 | 191 |
return -EINTR; |
192 | 192 |
} |
193 |
fd = fidp->fs.fd; |
|
194 | 193 |
v9fs_co_run_in_worker( |
195 | 194 |
{ |
196 |
err = s->ops->fsync(&s->ctx, fd, datasync);
|
|
195 |
err = s->ops->fsync(&s->ctx, &fidp->fs, datasync);
|
|
197 | 196 |
if (err < 0) { |
198 | 197 |
err = -errno; |
199 | 198 |
} |
... | ... | |
226 | 225 |
int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp, |
227 | 226 |
struct iovec *iov, int iovcnt, int64_t offset) |
228 | 227 |
{ |
229 |
int fd, err;
|
|
228 |
int err; |
|
230 | 229 |
V9fsState *s = pdu->s; |
231 | 230 |
|
232 | 231 |
if (v9fs_request_cancelled(pdu)) { |
233 | 232 |
return -EINTR; |
234 | 233 |
} |
235 |
fd = fidp->fs.fd; |
|
236 | 234 |
v9fs_co_run_in_worker( |
237 | 235 |
{ |
238 |
err = s->ops->pwritev(&s->ctx, fd, iov, iovcnt, offset);
|
|
236 |
err = s->ops->pwritev(&s->ctx, &fidp->fs, iov, iovcnt, offset);
|
|
239 | 237 |
if (err < 0) { |
240 | 238 |
err = -errno; |
241 | 239 |
} |
... | ... | |
246 | 244 |
int v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp, |
247 | 245 |
struct iovec *iov, int iovcnt, int64_t offset) |
248 | 246 |
{ |
249 |
int fd, err;
|
|
247 |
int err; |
|
250 | 248 |
V9fsState *s = pdu->s; |
251 | 249 |
|
252 | 250 |
if (v9fs_request_cancelled(pdu)) { |
253 | 251 |
return -EINTR; |
254 | 252 |
} |
255 |
fd = fidp->fs.fd; |
|
256 | 253 |
v9fs_co_run_in_worker( |
257 | 254 |
{ |
258 |
err = s->ops->preadv(&s->ctx, fd, iov, iovcnt, offset);
|
|
255 |
err = s->ops->preadv(&s->ctx, &fidp->fs, iov, iovcnt, offset);
|
|
259 | 256 |
if (err < 0) { |
260 | 257 |
err = -errno; |
261 | 258 |
} |
Also available in: Unified diff