aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/cofile.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-08-25 07:48:15 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-25 07:48:15 -0500
commit444dc48298c480e42e15a8fe676be737d8a6b2a1 (patch)
treebc76c5afaa746c8c27d0457e2035fe38ee45fb6c /hw/9pfs/cofile.c
parent5b15f27516ce3249c80bd2e0458d8d61f20da415 (diff)
parent5f524c1ebcc5e0dec0de8940d34f9adb3c7887a1 (diff)
Merge remote-tracking branch 'aneesh/for-upstream-2' into staging
Diffstat (limited to 'hw/9pfs/cofile.c')
-rw-r--r--hw/9pfs/cofile.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
index a4c0ae75cc..e388146422 100644
--- a/hw/9pfs/cofile.c
+++ b/hw/9pfs/cofile.c
@@ -30,3 +30,134 @@ int v9fs_co_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)
});
return err;
}
+
+int v9fs_co_fstat(V9fsState *s, int fd, struct stat *stbuf)
+{
+ int err;
+
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->fstat(&s->ctx, fd, stbuf);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_open(V9fsState *s, V9fsFidState *fidp, int flags)
+{
+ int err;
+
+ v9fs_co_run_in_worker(
+ {
+ fidp->fs.fd = s->ops->open(&s->ctx, fidp->path.data, flags);
+ if (fidp->fs.fd == -1) {
+ err = -errno;
+ } else {
+ err = 0;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_open2(V9fsState *s, V9fsFidState *fidp, char *fullname, gid_t gid,
+ int flags, int mode)
+{
+ int err;
+ FsCred cred;
+
+ cred_init(&cred);
+ cred.fc_mode = mode & 07777;
+ cred.fc_uid = fidp->uid;
+ cred.fc_gid = gid;
+ v9fs_co_run_in_worker(
+ {
+ fidp->fs.fd = s->ops->open2(&s->ctx, fullname, flags, &cred);
+ err = 0;
+ if (fidp->fs.fd == -1) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_close(V9fsState *s, V9fsFidState *fidp)
+{
+ int fd;
+ int err;
+
+ fd = fidp->fs.fd;
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->close(&s->ctx, fd);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_fsync(V9fsState *s, V9fsFidState *fidp, int datasync)
+{
+ int fd;
+ int err;
+
+ fd = fidp->fs.fd;
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->fsync(&s->ctx, fd, datasync);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath)
+{
+ int err;
+
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->link(&s->ctx, oldpath->data, newpath->data);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_pwritev(V9fsState *s, V9fsFidState *fidp,
+ struct iovec *iov, int iovcnt, int64_t offset)
+{
+ int fd;
+ int err;
+
+ fd = fidp->fs.fd;
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->pwritev(&s->ctx, fd, iov, iovcnt, offset);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}
+
+int v9fs_co_preadv(V9fsState *s, V9fsFidState *fidp,
+ struct iovec *iov, int iovcnt, int64_t offset)
+{
+ int fd;
+ int err;
+
+ fd = fidp->fs.fd;
+ v9fs_co_run_in_worker(
+ {
+ err = s->ops->preadv(&s->ctx, fd, iov, iovcnt, offset);
+ if (err < 0) {
+ err = -errno;
+ }
+ });
+ return err;
+}