[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows
From: |
Bin Meng |
Subject: |
[PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows |
Date: |
Mon, 30 Jan 2023 17:51:47 +0800 |
From: Guohuai Shi <guohuai.shi@windriver.com>
Some definitions currently used by the 9pfs codes are only available
on POSIX platforms. Let's add our own ones in preparation to adding
9pfs support for Windows.
Signed-off-by: Guohuai Shi <guohuai.shi@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
fsdev/file-op-9p.h | 33 +++++++++++++++++++++++++++++++++
hw/9pfs/9p.h | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
index 4997677460..7d9a736b66 100644
--- a/fsdev/file-op-9p.h
+++ b/fsdev/file-op-9p.h
@@ -27,6 +27,39 @@
# include <sys/mount.h>
#endif
+#ifdef CONFIG_WIN32
+
+/* POSIX structure not defined in Windows */
+
+typedef uint32_t uid_t;
+typedef uint32_t gid_t;
+
+/* from http://man7.org/linux/man-pages/man2/statfs.2.html */
+typedef uint32_t __fsword_t;
+typedef uint32_t fsblkcnt_t;
+typedef uint32_t fsfilcnt_t;
+
+/* from linux/include/uapi/asm-generic/posix_types.h */
+typedef struct {
+ long __val[2];
+} fsid_t;
+
+struct statfs {
+ __fsword_t f_type;
+ __fsword_t f_bsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsid_t f_fsid;
+ __fsword_t f_namelen;
+ __fsword_t f_frsize;
+ __fsword_t f_flags;
+};
+
+#endif /* CONFIG_WIN32 */
+
#define SM_LOCAL_MODE_BITS 0600
#define SM_LOCAL_DIR_MODE_BITS 0700
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index 2fce4140d1..ada9f14ebc 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -3,13 +3,56 @@
#include <dirent.h>
#include <utime.h>
+#ifndef CONFIG_WIN32
#include <sys/resource.h>
+#endif
#include "fsdev/file-op-9p.h"
#include "fsdev/9p-iov-marshal.h"
#include "qemu/thread.h"
#include "qemu/coroutine.h"
#include "qemu/qht.h"
+#ifdef CONFIG_WIN32
+
+/* Windows does not provide such a macro, typically it is 255 */
+#define NAME_MAX 255
+
+/* macros required for build, values do not matter */
+#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links */
+#define AT_REMOVEDIR 0x200 /* Remove directory instead of file */
+#define O_DIRECTORY 02000000
+
+#define makedev(major, minor) \
+ ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff)))
+#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff))
+#define minor(dev) ((unsigned int)(((dev) & 0xff)))
+
+/*
+ * Currenlty Windows/MinGW does not provide the following flag macros,
+ * so define them here for 9p codes.
+ *
+ * Once Windows/MinGW provides them, remove the defines to prevent conflicts.
+ */
+
+#ifndef S_IFLNK
+#define S_IFLNK 0xA000
+#define S_ISLNK(mode) ((mode & S_IFMT) == S_IFLNK)
+#endif /* S_IFLNK */
+
+#ifndef S_ISUID
+#define S_ISUID 0x0800
+#endif
+
+#ifndef S_ISGID
+#define S_ISGID 0x0400
+#endif
+
+#ifndef S_ISVTX
+#define S_ISVTX 0x0200
+#endif
+
+#endif /* CONFIG_WIN32 */
+
enum {
P9_TLERROR = 6,
P9_RLERROR,
--
2.25.1
- [PATCH v4 00/16] hw/9pfs: Add 9pfs support for Windows, Bin Meng, 2023/01/30
- [PATCH v4 01/16] hw/9pfs: Add missing definitions for Windows,
Bin Meng <=
- [PATCH v4 03/16] hw/9pfs: Replace the direct call to xxxdir() APIs with a wrapper, Bin Meng, 2023/01/30
- [PATCH v4 04/16] hw/9pfs: Implement Windows specific xxxdir() APIs, Bin Meng, 2023/01/30
- [PATCH v4 05/16] hw/9pfs: Update the local fs driver to support Windows, Bin Meng, 2023/01/30
- [PATCH v4 08/16] hw/9pfs: Add a helper qemu_stat_blksize(), Bin Meng, 2023/01/30
- [PATCH v4 02/16] hw/9pfs: Implement Windows specific utilities functions for 9pfs, Bin Meng, 2023/01/30
- [PATCH v4 07/16] hw/9pfs: Update helper qemu_stat_rdev(), Bin Meng, 2023/01/30
- [PATCH v4 10/16] hw/9pfs: Update v9fs_set_fd_limit() for Windows, Bin Meng, 2023/01/30
- [PATCH v4 06/16] hw/9pfs: Support getting current directory offset for Windows, Bin Meng, 2023/01/30
- [PATCH v4 09/16] hw/9pfs: Disable unsupported flags and features for Windows, Bin Meng, 2023/01/30
- [PATCH v4 13/16] fsdev: Disable proxy fs driver on Windows, Bin Meng, 2023/01/30