Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nodefs readdir handling for directories that contain exotic entries #22925

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hoodmane
Copy link
Contributor

Resolves #22924.

test/test_core.py Outdated Show resolved Hide resolved
test/test_core.py Outdated Show resolved Hide resolved
// If the entry is not a directory, file, or symlink, nodefs
// lookupNode will raise EINVAL. Skip these and continue.
if (e?.errno === {{{ cDefs.EINVAL }}}) {
idx += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idx++

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wonder if this while loop could be re-written into a 4 loop to avoid the duplication?

var startIdx = Math.floor(off / struct_size);
var endIdx = Math.max(stream.getdents.length, startIdx + count)
for (var idx = startIdx; idx < endIdx; idx++) {
  ...
}

if not WINDOWS and not MACOS:
# Add an entry that isn't a directory, file, or link to test that we handle
# it correctly.
os.mkfifo(os.path.join(self.working_dir, 'named_pipe'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macos doesn't support os.mkfifo either? TIL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it is supported on MacOS I'll remove that filter.

@sbc100
Copy link
Collaborator

sbc100 commented Nov 21, 2024

Looks like this perhaps requires a wasmfs change to match? wasmfs.test_fs_nodefs_readdir is now failing. Looks like maybe wasmfs is reporting "." and ".." but the old FS is not ? Maybe we want go back to the old way of verifying the results to avoid having to fix these decrpencies as part of this PR?

@hoodmane
Copy link
Contributor Author

Yeah maybe the best thing to do would be to grab the output and make a series of assertions that it contains or does not contain certain strings? It seems that the order is not stable but the set of lines should be.

@sbc100
Copy link
Collaborator

sbc100 commented Nov 21, 2024

Yeah maybe the best thing to do would be to grab the output and make a series of assertions that it contains or does not contain certain strings? It seems that the order is not stable but the set of lines should be.

Sure. That sounds reasonable. I was a little surprised to see who different the wasmfs output was though. I guess there is stuff we need to address there:

--- expected
+++ actual
@@ -1,12 +1,13 @@
 listing contents of dir=/
 .
 ..
+dev
 tmp
-home
-dev
-proc
 listing contents of dir=/working
+.
+..
 existing
+named_pipe
 stdout
 test_nodefs_readdir.js
 test_nodefs_readdir.wasm

Specifically it looks like wasmfs supports . and .. but the old FS doesn't? Also, the home and proc directories should match too. These are all separate issues though.

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.

NodeFS fails on (folders with) named pipes
2 participants