All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bin.meng@windriver.com>
To: Greg Kurz <groug@kaod.org>,
	Christian Schoenebeck <qemu_oss@crudebyte.com>,
	qemu-devel@nongnu.org
Cc: Guohuai Shi <guohuai.shi@windriver.com>
Subject: [PATCH v3 04/17] hw/9pfs: Add missing definitions for Windows
Date: Mon, 19 Dec 2022 18:20:08 +0800	[thread overview]
Message-ID: <20221219102022.2167736-5-bin.meng@windriver.com> (raw)
In-Reply-To: <20221219102022.2167736-1-bin.meng@windriver.com>

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



  parent reply	other threads:[~2022-12-19 10:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19 10:20 [PATCH v3 00/17] hw/9pfs: Add 9pfs support for Windows Bin Meng
2022-12-19 10:20 ` [PATCH v3 01/17] qemu/xattr.h: Exclude <sys/xattr.h> " Bin Meng
2022-12-19 10:20 ` [PATCH v3 02/17] hw/9pfs: Drop unnecessary *xattr wrapper API declarations Bin Meng
2022-12-19 10:20 ` [PATCH v3 03/17] hw/9pfs: Replace the direct call to xxxat() APIs with a wrapper Bin Meng
2022-12-19 10:20 ` Bin Meng [this message]
2022-12-19 10:20 ` [PATCH v3 05/17] hw/9pfs: Implement Windows specific utilities functions for 9pfs Bin Meng
2022-12-19 10:20 ` [PATCH v3 06/17] hw/9pfs: Update the local fs driver to support Windows Bin Meng
2022-12-19 10:20 ` [PATCH v3 07/17] hw/9pfs: Support getting current directory offset for Windows Bin Meng
2022-12-21 14:48   ` Christian Schoenebeck
2022-12-21 18:02     ` Shi, Guohuai
2022-12-28 11:51       ` Christian Schoenebeck
2022-12-29  6:03         ` Shi, Guohuai
2022-12-30 13:36           ` Christian Schoenebeck
2022-12-19 10:20 ` [PATCH v3 08/17] hw/9pfs: update helper qemu_stat_rdev() Bin Meng
2022-12-19 10:20 ` [PATCH v3 09/17] hw/9pfs: Add a helper qemu_stat_blksize() Bin Meng
2022-12-19 10:20 ` [PATCH v3 10/17] hw/9pfs: Disable unsupported flags and features for Windows Bin Meng
2022-12-19 10:20 ` [PATCH v3 11/17] hw/9pfs: Update v9fs_set_fd_limit() " Bin Meng
2022-12-19 10:20 ` [PATCH v3 12/17] hw/9pfs: Add Linux error number definition Bin Meng
2022-12-19 10:20 ` [PATCH v3 13/17] hw/9pfs: Translate Windows errno to Linux value Bin Meng
2022-12-19 10:20 ` [PATCH v3 14/17] fsdev: Disable proxy fs driver on Windows Bin Meng
2022-12-19 10:20 ` [PATCH v3 15/17] hw/9pfs: Update synth fs driver for Windows Bin Meng
2022-12-19 10:20 ` [PATCH v3 16/17] tests/qtest: virtio-9p-test: Adapt the case for win32 Bin Meng
2022-12-19 10:20 ` [PATCH v3 17/17] meson.build: Turn on virtfs for Windows Bin Meng
2022-12-21 14:14 ` [PATCH v3 00/17] hw/9pfs: Add 9pfs support " Christian Schoenebeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221219102022.2167736-5-bin.meng@windriver.com \
    --to=bin.meng@windriver.com \
    --cc=groug@kaod.org \
    --cc=guohuai.shi@windriver.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.