Skip to content

Conversation

CPunisher
Copy link
Contributor

Fixes: nodejs/node#47193

How telldir and seekdir work depends on the operating system. For example, in ubuntu, telldir returns a relative pos of current dirent iterator. But in macos, telldir returns a self-incrementing counter, which is only valid for one DIR*.

The issue is that every single call to fd_readdir opens and closes the dir, so the cookie becomes invalid on the next call, thus getting infinite loop.

@cjihrig
Copy link
Collaborator

cjihrig commented May 29, 2025

@CPunisher can you rebase this or force push. GitHub isn't giving me the option to start the CI.

@CPunisher CPunisher force-pushed the 04-20-fix/mac-fd_readdir branch from e40e42f to 830670a Compare May 29, 2025 05:36
@cjihrig cjihrig merged commit 392e1f1 into nodejs:main May 29, 2025
7 of 8 checks passed
@CPunisher CPunisher deleted the 04-20-fix/mac-fd_readdir branch June 16, 2025 09:22
@aduh95 aduh95 mentioned this pull request Aug 16, 2025
aduh95 added a commit that referenced this pull request Sep 2, 2025
Notable changes:

- Disallow malformed path with null byte (#266) (7aaa0b4)
- Preserve trailing slash in file path (#268) (afffaaa)
- Disallow absolute path at the raw WASI level (#270) (9811374)
- Error if creating symlink to absolute path (#272) (c8d4f01)
- Add cflite and document normalize path (#280) (6eeddba)
- Resolve old_path in uvwasi_path_symlink() (#303) (98da5ad)
- Use index rather than `telldir`/`seekdir` to represent `fd_readdir` cookie (#298) (392e1f1)
- fix: static library name (#305) (146e516)
- fix: do not put header files in a subfolders (#302) (ec28b58)
- fix: explicitly export symbols (#308) (4e9b4e0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WASI preview 1: fd_readdir ignores cookie argument
2 participants