summaryrefslogtreecommitdiffstats
path: root/hw/virtio-9p-local.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-04-29 17:45:00 +0530
committerAnthony Liguori <aliguori@us.ibm.com>2010-05-03 12:17:39 -0500
commit8cf89e007a37fff75c06e5a4564d530e51c1ec98 (patch)
tree9f61b946fd58bfb08c82982460fecea0d7b474e8 /hw/virtio-9p-local.c
parentc494dd6f28dbacd855bca894c664bf1f9836afe9 (diff)
downloadhqemu-8cf89e007a37fff75c06e5a4564d530e51c1ec98.zip
hqemu-8cf89e007a37fff75c06e5a4564d530e51c1ec98.tar.gz
virtio-9p: Add P9_TWSTAT support
Implement P9_TWSTAT support. This gets file and directory creation to work. [jvrao@linux.vnet.ibm.com: strdup to qemu_strdup conversion] [aneesh.kumar@linux.vnet.ibm.com: v9fs_fix_path] Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-9p-local.c')
-rw-r--r--hw/virtio-9p-local.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c
index f6781ca..5a011f3 100644
--- a/hw/virtio-9p-local.c
+++ b/hw/virtio-9p-local.c
@@ -212,6 +212,51 @@ static int local_link(FsContext *ctx, const char *oldpath, const char *newpath)
return err;
}
+static int local_truncate(FsContext *ctx, const char *path, off_t size)
+{
+ return truncate(rpath(ctx, path), size);
+}
+
+static int local_rename(FsContext *ctx, const char *oldpath,
+ const char *newpath)
+{
+ char *tmp;
+ int err;
+
+ tmp = qemu_strdup(rpath(ctx, oldpath));
+ if (tmp == NULL) {
+ return -1;
+ }
+
+ err = rename(tmp, rpath(ctx, newpath));
+ if (err == -1) {
+ int serrno = errno;
+ qemu_free(tmp);
+ errno = serrno;
+ } else {
+ qemu_free(tmp);
+ }
+
+ return err;
+
+}
+
+static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid)
+{
+ return chown(rpath(ctx, path), uid, gid);
+}
+
+static int local_utime(FsContext *ctx, const char *path,
+ const struct utimbuf *buf)
+{
+ return utime(rpath(ctx, path), buf);
+}
+
+static int local_fsync(FsContext *ctx, int fd)
+{
+ return fsync(fd);
+}
+
FileOperations local_ops = {
.lstat = local_lstat,
.setuid = local_setuid,
@@ -235,4 +280,9 @@ FileOperations local_ops = {
.open2 = local_open2,
.symlink = local_symlink,
.link = local_link,
+ .truncate = local_truncate,
+ .rename = local_rename,
+ .chown = local_chown,
+ .utime = local_utime,
+ .fsync = local_fsync,
};
OpenPOWER on IntegriCloud