mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
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>
This commit is contained in:
parent
f41db099c7
commit
6b3b279bd6
6 changed files with 52 additions and 4 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "virtio-9p.h"
|
||||
#include "fsdev/qemu-fsdev.h"
|
||||
#include "9p-xattr.h"
|
||||
#include "9p-util.h"
|
||||
#include "coth.h"
|
||||
#include "trace.h"
|
||||
#include "migration/blocker.h"
|
||||
|
@ -2281,7 +2282,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu,
|
|||
count += len;
|
||||
v9fs_stat_free(&v9stat);
|
||||
v9fs_path_free(&path);
|
||||
saved_dir_pos = dent->d_off;
|
||||
saved_dir_pos = qemu_dirent_off(dent);
|
||||
}
|
||||
|
||||
v9fs_readdir_unlock(&fidp->fs.dir);
|
||||
|
@ -2420,6 +2421,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
|
|||
V9fsString name;
|
||||
int len, err = 0;
|
||||
int32_t count = 0;
|
||||
off_t off;
|
||||
struct dirent *dent;
|
||||
struct stat *st;
|
||||
struct V9fsDirEnt *entries = NULL;
|
||||
|
@ -2480,12 +2482,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp,
|
|||
qid.version = 0;
|
||||
}
|
||||
|
||||
off = qemu_dirent_off(dent);
|
||||
v9fs_string_init(&name);
|
||||
v9fs_string_sprintf(&name, "%s", dent->d_name);
|
||||
|
||||
/* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */
|
||||
len = pdu_marshal(pdu, 11 + count, "Qqbs",
|
||||
&qid, dent->d_off,
|
||||
&qid, off,
|
||||
dent->d_type, &name);
|
||||
|
||||
v9fs_string_free(&name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue