···
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
2
-
index 845675e..43fa036 100644
2
+
index 3f271fc..dc273f4 100644
5
-
@@ -128,6 +128,8 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
7
+
#define VIRTFS_META_DIR ".virtfs_metadata"
9
+
+static int is_in_store_path(const char *path)
11
+
+ static char *store_path = NULL;
12
+
+ int store_path_len = -1;
14
+
+ if (store_path_len == -1) {
15
+
+ if ((store_path = getenv("NIX_STORE")) != NULL)
16
+
+ store_path_len = strlen(store_path);
18
+
+ store_path_len = 0;
21
+
+ if (store_path_len > 0)
22
+
+ return strncmp(path, store_path, strlen(store_path)) == 0;
26
+
static char *local_mapped_attr_path(FsContext *ctx, const char *path)
29
+
@@ -128,6 +145,8 @@ static int local_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
···
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
/* Actual credentials are part of extended attrs */
14
-
@@ -462,6 +464,16 @@ static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
38
+
@@ -462,6 +481,11 @@ static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
18
-
+static int maybe_chmod(const char *path, mode_t mode)
42
+
+static inline int maybe_chmod(const char *path, mode_t mode)
20
-
+ static char *store_path = NULL;
21
-
+ if (store_path == NULL)
22
-
+ store_path = getenv("NIX_STORE");
23
-
+ if (strncmp(path, store_path, strlen(store_path)) != 0)
24
-
+ return chmod(path, mode);
44
+
+ return is_in_store_path(path) ? 0 : chmod(path, mode);
static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
31
-
@@ -477,7 +489,7 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
50
+
@@ -477,7 +501,7 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
buffer = rpath(fs_ctx, path);
···
40
-
@@ -621,6 +633,8 @@ static int local_fstat(FsContext *fs_ctx, int fid_type,
59
+
@@ -621,6 +645,8 @@ static int local_fstat(FsContext *fs_ctx, int fid_type,
···
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
/* Actual credentials are part of extended attrs */
68
+
@@ -916,7 +942,8 @@ static int local_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
69
+
(fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
70
+
(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);
76
+
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
77
+
buffer = rpath(fs_ctx, path);