[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 04/11] 9p: darwin: Handle struct dirent differences
From: |
Christian Schoenebeck |
Subject: |
Re: [PATCH v3 04/11] 9p: darwin: Handle struct dirent differences |
Date: |
Wed, 02 Feb 2022 18:37:37 +0100 |
On Mittwoch, 2. Februar 2022 16:07:09 CET Will Cohen wrote:
> Does the version proposed in v3 address the V9fsFidState issues? In 9p.c
> for v2 to v3, we propose
>
> - return telldir(fidp->fs.dir.stream);
> + return v9fs_co_telldir(pdu, fidp);
>
> and in codir.c from v2 to v3 we propose
> - saved_dir_pos = telldir(fidp->fs.dir.stream);
> + saved_dir_pos = s->ops->telldir(&s->ctx, &fidp->fs);
>
> This removes the direct access to fidp->, and we hope this should be
> sufficient to avoid the concurrency
> and undefined behaviors you noted in the v2 review.
I am not sure why you think that you are no longer accessing fidp, you still
do, just in a slightly different way.
Let me propose a different solution: on macOS there is 'd_seekoff' in struct
dirent. As already discussed that dirent field is apparently unused (zero) by
macOS. So what about filling this dirent field (early, on driver level, not on
server/controller level [9p.c]) with telldir() for macOS, then you have the
same info as other systems provide with dirent field 'd_off' later on.
Then you can add an inline helper function or a macro to deal with macOS vs.
RoW, e.g.:
inline
off_t qemu_dirent_off(struct dirent *dent)
{
#ifdef CONFIG_DARWIN
return dent->d_seekoff;
#else
return dent->d_off;
#endif
}
And in 9p.c at all locations where dent->d_off is currently accessed, you
would just use that helper instead.
Best regards,
Christian Schoenebeck