From: Guohuai Shi <guohuai....@windriver.com>

Some macros (e.g.: VIRTFS_META_DIR) are used by both Linux and macOS,
and will be used by the upcoming Windows support too, extract them
from 9p-local.c to 9p-local.h.

Note local_is_mapped_file_metadata()is changed to an inline function.

Signed-off-by: Guohuai Shi <guohuai....@windriver.com>
Signed-off-by: Bin Meng <bin.m...@windriver.com>
---

 hw/9pfs/9p-local.h | 16 ++++++++++++++++
 hw/9pfs/9p-local.c | 14 --------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/hw/9pfs/9p-local.h b/hw/9pfs/9p-local.h
index 32c72749d9..55ea4b7883 100644
--- a/hw/9pfs/9p-local.h
+++ b/hw/9pfs/9p-local.h
@@ -13,6 +13,22 @@
 #ifndef QEMU_9P_LOCAL_H
 #define QEMU_9P_LOCAL_H
 
+#define VIRTFS_META_DIR ".virtfs_metadata"
+#define VIRTFS_META_ROOT_FILE VIRTFS_META_DIR "_root"
+
+#define ATTR_MAX 100
+
+typedef struct {
+    int mountfd;
+} LocalData;
+
+static inline bool local_is_mapped_file_metadata(FsContext *fs_ctx,
+                                                 const char *name)
+{
+    return
+        !strcmp(name, VIRTFS_META_DIR) || !strcmp(name, VIRTFS_META_ROOT_FILE);
+}
+
 int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags,
                         mode_t mode);
 int local_opendir_nofollow(FsContext *fs_ctx, const char *path);
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index d42ce6d8b8..73beef84a9 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -53,10 +53,6 @@
 #define BTRFS_SUPER_MAGIC 0x9123683E
 #endif
 
-typedef struct {
-    int mountfd;
-} LocalData;
-
 int local_open_nofollow(FsContext *fs_ctx, const char *path, int flags,
                         mode_t mode)
 {
@@ -114,9 +110,6 @@ static void unlinkat_preserve_errno(int dirfd, const char 
*path, int flags)
     errno = serrno;
 }
 
-#define VIRTFS_META_DIR ".virtfs_metadata"
-#define VIRTFS_META_ROOT_FILE VIRTFS_META_DIR "_root"
-
 static FILE *local_fopenat(int dirfd, const char *name, const char *mode)
 {
     int fd, o_mode = 0;
@@ -144,7 +137,6 @@ static FILE *local_fopenat(int dirfd, const char *name, 
const char *mode)
     return fp;
 }
 
-#define ATTR_MAX 100
 static void local_mapped_file_attr(int dirfd, const char *name,
                                    struct stat *stbuf)
 {
@@ -547,12 +539,6 @@ static off_t local_telldir(FsContext *ctx, 
V9fsFidOpenState *fs)
     return telldir(fs->dir.stream);
 }
 
-static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *name)
-{
-    return
-        !strcmp(name, VIRTFS_META_DIR) || !strcmp(name, VIRTFS_META_ROOT_FILE);
-}
-
 static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)
 {
     struct dirent *entry;
-- 
2.25.1


Reply via email to