qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Guohuai Shi <guohuai.shi@windriver.com>,
	Greg Kurz <groug@kaod.org>, Bin Meng <bin.meng@windriver.com>
Subject: Re: [PATCH v2 06/19] hw/9pfs: Add missing definitions for Windows
Date: Mon, 14 Nov 2022 17:40:36 +0100	[thread overview]
Message-ID: <6443328.Q0H0RdsSbn@silver> (raw)
In-Reply-To: <20221111042225.1115931-7-bin.meng@windriver.com>

On Friday, November 11, 2022 5:22:12 AM CET Bin Meng wrote:
> 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>
> 
> ---
> 
> Changes in v2:
> - Add S_IFLNK related macros to support symbolic link
> 
>  fsdev/file-op-9p.h | 33 +++++++++++++++++++++++++++++++++
>  hw/9pfs/9p.h       | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 66 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;
> +};
> +

Does it make sense to define all of these, even though not being used?

> +#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..957a7e4ccc 100644
> --- a/hw/9pfs/9p.h
> +++ b/hw/9pfs/9p.h
> @@ -3,13 +3,46 @@
>  
>  #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
> +
> +#define NAME_MAX            MAX_PATH

That's not quite the same. MAX_PATH on Windows corresponds to PATH_MAX on
POSIX, which is the max. length of an entire path (i.e. drive, multiple
directory names, filename, backslashes). AFAICS MAX_PATH is 260 on Windows.

The max. length of a single filename component OTOH is 255 on Windows by
default. I don't know if there is a macro for the latter, if not, maybe
just hard coding it here for now?

> +
> +/* 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)))
> +
> +#ifndef S_IFLNK
> +/*
> + * 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.
> + */
> +#define S_IFLNK         0xA000
> +#define S_ISUID         0x0800
> +#define S_ISGID         0x0400
> +#define S_ISVTX         0x0200
> +
> +#define S_ISLNK(mode)   ((mode & S_IFMT) == S_IFLNK)
> +#endif /* S_IFLNK */
> +
> +#endif /* CONFIG_WIN32 */
> +
>  enum {
>      P9_TLERROR = 6,
>      P9_RLERROR,
> 




  reply	other threads:[~2022-11-15  0:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  4:22 [PATCH v2 00/19] At present there is no Windows support for 9p file system Bin Meng
2022-11-11  4:22 ` [PATCH v2 01/19] qemu/xattr.h: Exclude <sys/xattr.h> for Windows Bin Meng
2022-11-11  4:22 ` [PATCH v2 02/19] hw/9pfs: Drop unnecessary *xattr wrapper API declarations Bin Meng
2022-11-18  8:42   ` Greg Kurz
2022-11-18 13:10     ` Christian Schoenebeck
2022-11-11  4:22 ` [PATCH v2 03/19] hw/9pfs: Replace the direct call to xxxat() APIs with a wrapper Bin Meng
2022-11-11  4:22 ` [PATCH v2 04/19] osdep.h: Introduce a QEMU file descriptor type Bin Meng
2022-11-11  9:07   ` Daniel P. Berrangé
2022-11-11  9:23     ` Bin Meng
2022-11-11  9:29       ` Daniel P. Berrangé
2022-11-11  4:22 ` [PATCH v2 05/19] hw/9pfs: Update 9pfs to use the new QemuFd_t type Bin Meng
2022-11-18  9:29   ` Greg Kurz
2022-11-18 13:38     ` Christian Schoenebeck
2022-11-19 10:19       ` Greg Kurz
2022-11-19 15:22         ` Bin Meng
2022-11-11  4:22 ` [PATCH v2 06/19] hw/9pfs: Add missing definitions for Windows Bin Meng
2022-11-14 16:40   ` Christian Schoenebeck [this message]
2022-11-16  9:01     ` Shi, Guohuai
2022-11-16 12:52       ` Christian Schoenebeck
2022-11-11  4:22 ` [PATCH v2 07/19] hw/9pfs: Implement Windows specific utilities functions for 9pfs Bin Meng
2022-11-17 15:55   ` Christian Schoenebeck
2022-11-17 16:38     ` Shi, Guohuai
2022-11-11  4:22 ` [PATCH v2 08/19] hw/9pfs: Update the local fs driver to support Windows Bin Meng
2022-11-11  4:22 ` [PATCH v2 09/19] hw/9pfs: Support getting current directory offset for Windows Bin Meng
2022-11-11  4:22 ` [PATCH v2 10/19] hw/9pfs: Add a helper qemu_stat_rdev() Bin Meng
2022-11-11  4:22 ` [PATCH v2 11/19] hw/9pfs: Add a helper qemu_stat_blksize() Bin Meng
2022-11-11  4:22 ` [PATCH v2 12/19] hw/9pfs: Disable unsupported flags and features for Windows Bin Meng
2022-11-11  4:22 ` [PATCH v2 13/19] hw/9pfs: Update v9fs_set_fd_limit() " Bin Meng
2022-11-11  4:22 ` [PATCH v2 14/19] hw/9pfs: Add Linux error number definition Bin Meng
2022-11-11  4:22 ` [PATCH v2 15/19] hw/9pfs: Translate Windows errno to Linux value Bin Meng
2022-11-11  4:22 ` [PATCH v2 16/19] fsdev: Disable proxy fs driver on Windows Bin Meng
2022-11-11  4:22 ` [PATCH v2 17/19] hw/9pfs: Update synth fs driver for Windows Bin Meng
2022-11-11 10:30   ` Philippe Mathieu-Daudé
2022-11-11  4:22 ` [PATCH v2 18/19] tests/qtest: virtio-9p-test: Adapt the case for win32 Bin Meng
2022-11-11  7:48   ` Thomas Huth
2022-11-11  4:22 ` [PATCH v2 19/19] meson.build: Turn on virtfs for Windows Bin Meng

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=6443328.Q0H0RdsSbn@silver \
    --to=qemu_oss@crudebyte.com \
    --cc=bin.meng@windriver.com \
    --cc=groug@kaod.org \
    --cc=guohuai.shi@windriver.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).