aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs/9p-proxy.c
diff options
context:
space:
mode:
authorKeno Fischer <keno@juliacomputing.com>2022-02-27 17:35:15 -0500
committerChristian Schoenebeck <qemu_oss@crudebyte.com>2022-03-07 11:49:31 +0100
commit6b3b279bd670c6a2fa23c9049820c814f0e2c846 (patch)
tree7d13227f1a5f4a4a916910215a45cfdd358cf5ab /hw/9pfs/9p-proxy.c
parentf41db099c71151291c269bf48ad006de9cbd9ca6 (diff)
downloadqemu-6b3b279bd670c6a2fa23c9049820c814f0e2c846.zip
qemu-6b3b279bd670c6a2fa23c9049820c814f0e2c846.tar.gz
qemu-6b3b279bd670c6a2fa23c9049820c814f0e2c846.tar.bz2
9p: darwin: Handle struct dirent differences
On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset and inject it into d_seekoff, and create a qemu_dirent_off helper to call it appropriately when appropriate. Signed-off-by: Keno Fischer <keno@juliacomputing.com> [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch <reactorcontrol@icloud.com> [Will Cohen: - Adjust to pass testing - Ensure that d_seekoff is filled using telldir on darwin, and create qemu_dirent_off helper to decide which to access] [Fabian Franz: - Add telldir error handling for darwin] Signed-off-by: Fabian Franz <fabianfranz.oss@gmail.com> [Will Cohen: - Ensure that telldir error handling uses signed int - Cleanup of telldir error handling - Remove superfluous error handling for qemu_dirent_off - Adjust formatting - Use qemu_dirent_off in codir.c - Declare qemu_dirent_off as static to prevent linker error - Move qemu_dirent_off above the end-of-file endif to fix compilation] Signed-off-by: Will Cohen <wwcohen@gmail.com> Message-Id: <20220227223522.91937-5-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Diffstat (limited to 'hw/9pfs/9p-proxy.c')
-rw-r--r--hw/9pfs/9p-proxy.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index b166408..8b4b5cf 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -706,7 +706,21 @@ static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs)
static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs)
{
- return readdir(fs->dir.stream);
+ struct dirent *entry;
+ entry = readdir(fs->dir.stream);
+#ifdef CONFIG_DARWIN
+ if (!entry) {
+ return NULL;
+ }
+ int td;
+ td = telldir(fs->dir.stream);
+ /* If telldir fails, fail the entire readdir call */
+ if (td < 0) {
+ return NULL;
+ }
+ entry->d_seekoff = td;
+#endif
+ return entry;
}
static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)