mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
hw/9pfs: Abstract open state of fid to V9fsFidOpenState
To implement synthetic file system in Qemu we may not really require file descriptor and Dir *. Make generic code use V9fsFidOpenState instead. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This commit is contained in:
parent
2c74c2cb4b
commit
cc720ddb54
8 changed files with 179 additions and 141 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue