From: Will Cohen <wwcohen@gmail.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Christian Schoenebeck <qemu_oss@crudebyte.com>,
Greg Kurz <groug@kaod.org>,
hi@alyssa.is, Michael Roitzsch <reactorcontrol@icloud.com>,
Will Cohen <wwcohen@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Keno Fischer <keno@juliacomputing.com>
Subject: [PATCH v5 03/11] 9p: darwin: Handle struct stat(fs) differences
Date: Mon, 7 Feb 2022 17:40:16 -0500 [thread overview]
Message-ID: <20220207224024.87745-4-wwcohen@gmail.com> (raw)
In-Reply-To: <20220207224024.87745-1-wwcohen@gmail.com>
From: Keno Fischer <keno@juliacomputing.com>
Signed-off-by: Keno Fischer <keno@juliacomputing.com>
Signed-off-by: Michael Roitzsch <reactorcontrol@icloud.com>
[Will Cohen: - Note lack of f_namelen and f_frsize on Darwin
- Ensure that tv_sec and tv_nsec are both
initialized for Darwin and non-Darwin]
Signed-off-by: Will Cohen <wwcohen@gmail.com>
---
hw/9pfs/9p-proxy.c | 22 ++++++++++++++++++++--
hw/9pfs/9p-synth.c | 2 ++
hw/9pfs/9p.c | 16 ++++++++++++++--
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 09bd9f1464..b1664080d8 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -123,10 +123,16 @@ static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs)
stfs->f_bavail = prstfs->f_bavail;
stfs->f_files = prstfs->f_files;
stfs->f_ffree = prstfs->f_ffree;
+#ifdef CONFIG_DARWIN
+ /* f_namelen and f_frsize do not exist on Darwin */
+ stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU;
+ stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU;
+#else
stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU;
stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU;
stfs->f_namelen = prstfs->f_namelen;
stfs->f_frsize = prstfs->f_frsize;
+#endif
}
/* Converts proxy_stat structure to VFS stat structure */
@@ -143,12 +149,24 @@ static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)
stbuf->st_size = prstat->st_size;
stbuf->st_blksize = prstat->st_blksize;
stbuf->st_blocks = prstat->st_blocks;
+ stbuf->st_atime = prstat->st_atim_sec;
+ stbuf->st_mtime = prstat->st_mtim_sec;
+ stbuf->st_ctime = prstat->st_ctim_sec;
+#ifdef CONFIG_DARWIN
+ stbuf->st_atimespec.tv_sec = prstat->st_atim_sec;
+ stbuf->st_mtimespec.tv_sec = prstat->st_mtim_sec;
+ stbuf->st_ctimespec.tv_sec = prstat->st_ctim_sec;
+ stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec;
+ stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec;
+ stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec;
+#else
stbuf->st_atim.tv_sec = prstat->st_atim_sec;
+ stbuf->st_mtim.tv_sec = prstat->st_mtim_sec;
+ stbuf->st_ctim.tv_sec = prstat->st_ctim_sec;
stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;
- stbuf->st_mtime = prstat->st_mtim_sec;
stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;
- stbuf->st_ctime = prstat->st_ctim_sec;
stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;
+#endif
}
/*
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index b38088e066..4a4a776d06 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -427,7 +427,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path,
stbuf->f_bsize = 512;
stbuf->f_blocks = 0;
stbuf->f_files = synth_node_count;
+#ifndef CONFIG_DARWIN
stbuf->f_namelen = NAME_MAX;
+#endif
return 0;
}
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 9c63e14b28..1563d7b7c6 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1313,11 +1313,17 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf,
v9lstat->st_blksize = stat_to_iounit(pdu, stbuf);
v9lstat->st_blocks = stbuf->st_blocks;
v9lstat->st_atime_sec = stbuf->st_atime;
- v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec;
v9lstat->st_mtime_sec = stbuf->st_mtime;
- v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec;
v9lstat->st_ctime_sec = stbuf->st_ctime;
+#ifdef CONFIG_DARWIN
+ v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec;
+ v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec;
+ v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec;
+#else
+ v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec;
+ v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec;
v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec;
+#endif
/* Currently we only support BASIC fields in stat */
v9lstat->st_result_mask = P9_STATS_BASIC;
@@ -3519,9 +3525,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf)
f_bavail = stbuf->f_bavail / bsize_factor;
f_files = stbuf->f_files;
f_ffree = stbuf->f_ffree;
+#ifdef CONFIG_DARWIN
+ fsid_val = (unsigned int)stbuf->f_fsid.val[0] |
+ (unsigned long long)stbuf->f_fsid.val[1] << 32;
+ f_namelen = NAME_MAX;
+#else
fsid_val = (unsigned int) stbuf->f_fsid.__val[0] |
(unsigned long long)stbuf->f_fsid.__val[1] << 32;
f_namelen = stbuf->f_namelen;
+#endif
return pdu_marshal(pdu, offset, "ddqqqqqqd",
f_type, f_bsize, f_blocks, f_bfree,
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2022-02-07 22:44 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-07 22:40 [PATCH v5 00/11] 9p: Add support for darwin Will Cohen
2022-02-07 22:40 ` [PATCH v5 01/11] 9p: linux: Fix a couple Linux assumptions Will Cohen
2022-02-07 22:40 ` [PATCH v5 02/11] 9p: Rename 9p-util -> 9p-util-linux Will Cohen
2022-02-07 22:40 ` Will Cohen [this message]
2022-02-07 22:40 ` [PATCH v5 04/11] 9p: darwin: Handle struct dirent differences Will Cohen
2022-02-07 22:40 ` [PATCH v5 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Will Cohen
2022-02-07 22:40 ` [PATCH v5 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Will Cohen
2022-02-08 12:20 ` Christian Schoenebeck
2022-02-08 13:45 ` Will Cohen
2022-02-07 22:40 ` [PATCH v5 07/11] 9p: darwin: *xattr_nofollow implementations Will Cohen
2022-02-07 22:40 ` [PATCH v5 08/11] 9p: darwin: Compatibility for f/l*xattr Will Cohen
2022-02-07 22:40 ` [PATCH v5 09/11] 9p: darwin: Implement compatibility for mknodat Will Cohen
2022-02-07 22:56 ` Christian Schoenebeck
2022-02-08 13:36 ` Will Cohen
2022-02-08 15:02 ` Christian Schoenebeck
2022-02-08 15:57 ` Will Cohen
2022-02-08 16:11 ` Christian Schoenebeck
2022-02-08 16:19 ` Will Cohen
2022-02-08 18:04 ` Will Cohen
2022-02-08 18:28 ` Christian Schoenebeck
2022-02-08 19:48 ` Christian Schoenebeck
2022-02-08 22:57 ` Will Cohen
2022-02-09 13:33 ` Akihiko Odaki
2022-02-09 14:08 ` Christian Schoenebeck
2022-02-09 18:20 ` Will Cohen
2022-02-09 23:10 ` Akihiko Odaki
2022-02-10 15:46 ` Will Cohen
2022-02-09 13:50 ` Christian Schoenebeck
2022-02-08 10:55 ` Philippe Mathieu-Daudé via
2022-02-07 22:40 ` [PATCH v5 10/11] 9p: darwin: meson: Allow VirtFS on Darwin Will Cohen
2022-02-07 23:44 ` Christian Schoenebeck
2022-02-07 23:47 ` Will Cohen
2022-02-07 22:40 ` [PATCH v5 11/11] 9p: darwin: Adjust assumption on virtio-9p-test Will Cohen
2022-02-08 10:16 ` Greg Kurz
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=20220207224024.87745-4-wwcohen@gmail.com \
--to=wwcohen@gmail.com \
--cc=groug@kaod.org \
--cc=hi@alyssa.is \
--cc=keno@juliacomputing.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=reactorcontrol@icloud.com \
--cc=thuth@redhat.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 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).