@@ -1,8 +1,8 @@
11diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
2−index 3f271fc..dc273f4 100644
2+index 45e9a1f9b0..494ee00c66 100644
33--- a/hw/9pfs/9p-local.c
44+++ b/hw/9pfs/9p-local.c
5−@@ -45,6 +45,23 @@
5+@@ -84,6 +84,23 @@ static void unlinkat_preserve_errno(int dirfd, const char *path, int flags)
66
77 #define VIRTFS_META_DIR ".virtfs_metadata"
88
@@ -23,10 +23,10 @@ index 3f271fc..dc273f4 100644
2323+ return 0;
2424+}
2525+
26− static char *local_mapped_attr_path(FsContext *ctx, const char *path)
26+ static FILE *local_fopenat(int dirfd, const char *name, const char *mode)
2727 {
28− int dirlen;
29−@@ -128,6 +145,8 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
28+ int fd, o_mode = 0;
29+@@ -161,6 +178,8 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
3030 if (err) {
3131 goto err_out;
3232 }
@@ -35,28 +35,17 @@ index 3f271fc..dc273f4 100644
3535 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
3636 /* Actual credentials are part of extended attrs */
3737 uid_t tmp_uid;
38−@@ -462,6 +481,11 @@ static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
39− return ret;
40− }
38+@@ -280,6 +299,9 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
39+ {
40+ int fd, ret;
4141
42−+static inline int maybe_chmod(const char *path, mode_t mode)
43−+{
44−+ return is_in_store_path(path) ? 0 : chmod(path, mode);
45−+}
42++ if (is_in_store_path(name))
43++ return 0;
4644+
47− static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
48− {
49− char *buffer;
50−@@ -477,7 +501,7 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
51− } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
52− (fs_ctx->export_flags & V9FS_SM_NONE)) {
53− buffer = rpath(fs_ctx, path);
54−- ret = chmod(buffer, credp->fc_mode);
55−+ ret = maybe_chmod(buffer, credp->fc_mode);
56− g_free(buffer);
57− }
58− return ret;
59−@@ -621,6 +645,8 @@ static int local_fstat(FsContext *fs_ctx, int fid_type,
45+ /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
46+ * Unfortunately, the linux kernel doesn't implement it yet. As an
47+ * alternative, let's open the file and use fchmod() instead. This
48+@@ -661,6 +683,8 @@ static int local_fstat(FsContext *fs_ctx, int fid_type,
6049 if (err) {
6150 return err;
6251 }
@@ -65,13 +54,28 @@ index 3f271fc..dc273f4 100644
6554 if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
6655 /* Actual credentials are part of extended attrs */
6756 uid_t tmp_uid;
68−@@ -916,7 +942,8 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
57+@@ -795,8 +819,11 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
58+ if (err) {
59+ goto out;
60+ }
61+- err = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,
62+- AT_SYMLINK_NOFOLLOW);
63++ if (is_in_store_path(name))
64++ err = 0;
65++ else
66++ err = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,
67++ AT_SYMLINK_NOFOLLOW);
68+ if (err == -1) {
69+ /*
70+ * If we fail to change ownership and if we are
71+@@ -911,7 +938,9 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
72+ goto out;
73+ }
74+
75+- if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
76++ if (is_in_store_path(name)) {
77++ ret = 0;
78++ } else if ((credp->fc_uid == -1 && credp->fc_gid == -1) ||
6979 (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
7080 (fs_ctx->export_flags & V9FS_SM_NONE)) {
71− buffer = rpath(fs_ctx, path);
72−- ret = lchown(buffer, credp->fc_uid, credp->fc_gid);
73−+ ret = is_in_store_path(buffer)
74−+ ? 0 : lchown(buffer, credp->fc_uid, credp->fc_gid);
75− g_free(buffer);
76− } else if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
77− buffer = rpath(fs_ctx, path);
81+ ret = fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,