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

Added '.' and '..' special folder t WASI fd_readdir return (for #3033) #3065

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,10 @@ pub fn fd_readdir<M: MemorySize>(
(entry.name.to_string(), stat.st_filetype, stat.st_ino)
}),
);
// adding . and .. special folders
// TODO: inode
Copy link
Member

Choose a reason for hiding this comment

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

What is this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as line 1310

entry_vec.push((".".to_string(), __WASI_FILETYPE_DIRECTORY, 0));
entry_vec.push(("..".to_string(), __WASI_FILETYPE_DIRECTORY, 0));
Comment on lines +1326 to +1327
Copy link
Member

Choose a reason for hiding this comment

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

Ummm... what about the root? We shouldn't add .. to readdir in the root.
Can you also add a test case for this? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But, isn't Root the next match here?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I hesitated is adding "." to a root readdir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the root cause was completly different: it's not a buffer size issue here, it's the missing "." and "..". All the 201 folder appears correctly, just missing the special folders

Copy link
Contributor Author

@ptitSeb ptitSeb Aug 2, 2022

Choose a reason for hiding this comment

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

So no, adding "." to fd_readdir of root is a bad idea, it breaks things (tests that read root).

entry_vec.sort_by(|a, b| a.0.cmp(&b.0));
entry_vec
}
Expand Down