aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/cofile.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/9pfs/cofile.c')
-rw-r--r--hw/9pfs/cofile.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
index 692811e5ab..586b0382f6 100644
--- a/hw/9pfs/cofile.c
+++ b/hw/9pfs/cofile.c
@@ -61,7 +61,7 @@ int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
return err;
}
-int v9fs_co_fstat(V9fsPDU *pdu, int fd, struct stat *stbuf)
+int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
{
int err;
V9fsState *s = pdu->s;
@@ -71,7 +71,7 @@ int v9fs_co_fstat(V9fsPDU *pdu, int fd, struct stat *stbuf)
}
v9fs_co_run_in_worker(
{
- err = s->ops->fstat(&s->ctx, fd, stbuf);
+ err = s->ops->fstat(&s->ctx, &fidp->fs, stbuf);
if (err < 0) {
err = -errno;
}
@@ -90,8 +90,8 @@ int v9fs_co_open(V9fsPDU *pdu, V9fsFidState *fidp, int flags)
v9fs_path_read_lock(s);
v9fs_co_run_in_worker(
{
- fidp->fs.fd = s->ops->open(&s->ctx, &fidp->path, flags);
- if (fidp->fs.fd == -1) {
+ err = s->ops->open(&s->ctx, &fidp->path, flags, &fidp->fs);
+ if (err == -1) {
err = -errno;
} else {
err = 0;
@@ -130,9 +130,9 @@ int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid,
v9fs_path_read_lock(s);
v9fs_co_run_in_worker(
{
- fidp->fs.fd = s->ops->open2(&s->ctx, &fidp->path,
- name->data, flags, &cred);
- if (fidp->fs.fd == -1) {
+ err = s->ops->open2(&s->ctx, &fidp->path,
+ name->data, flags, &cred, &fidp->fs);
+ if (err < 0) {
err = -errno;
} else {
v9fs_path_init(&path);
@@ -141,12 +141,12 @@ int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid,
err = s->ops->lstat(&s->ctx, &path, stbuf);
if (err < 0) {
err = -errno;
- s->ops->close(&s->ctx, fidp->fs.fd);
+ s->ops->close(&s->ctx, &fidp->fs);
} else {
v9fs_path_copy(&fidp->path, &path);
}
} else {
- s->ops->close(&s->ctx, fidp->fs.fd);
+ s->ops->close(&s->ctx, &fidp->fs);
}
v9fs_path_free(&path);
}
@@ -161,7 +161,7 @@ int v9fs_co_open2(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString *name, gid_t gid,
return err;
}
-int v9fs_co_close(V9fsPDU *pdu, int fd)
+int v9fs_co_close(V9fsPDU *pdu, V9fsFidOpenState *fs)
{
int err;
V9fsState *s = pdu->s;
@@ -171,7 +171,7 @@ int v9fs_co_close(V9fsPDU *pdu, int fd)
}
v9fs_co_run_in_worker(
{
- err = s->ops->close(&s->ctx, fd);
+ err = s->ops->close(&s->ctx, fs);
if (err < 0) {
err = -errno;
}
@@ -184,16 +184,15 @@ int v9fs_co_close(V9fsPDU *pdu, int fd)
int v9fs_co_fsync(V9fsPDU *pdu, V9fsFidState *fidp, int datasync)
{
- int fd, err;
+ int err;
V9fsState *s = pdu->s;
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
- fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
- err = s->ops->fsync(&s->ctx, fd, datasync);
+ err = s->ops->fsync(&s->ctx, &fidp->fs, datasync);
if (err < 0) {
err = -errno;
}
@@ -226,16 +225,15 @@ int v9fs_co_link(V9fsPDU *pdu, V9fsFidState *oldfid,
int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
struct iovec *iov, int iovcnt, int64_t offset)
{
- int fd, err;
+ int err;
V9fsState *s = pdu->s;
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
- fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
- err = s->ops->pwritev(&s->ctx, fd, iov, iovcnt, offset);
+ err = s->ops->pwritev(&s->ctx, &fidp->fs, iov, iovcnt, offset);
if (err < 0) {
err = -errno;
}
@@ -246,16 +244,15 @@ int v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
int v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp,
struct iovec *iov, int iovcnt, int64_t offset)
{
- int fd, err;
+ int err;
V9fsState *s = pdu->s;
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
- fd = fidp->fs.fd;
v9fs_co_run_in_worker(
{
- err = s->ops->preadv(&s->ctx, fd, iov, iovcnt, offset);
+ err = s->ops->preadv(&s->ctx, &fidp->fs, iov, iovcnt, offset);
if (err < 0) {
err = -errno;
}