-
Notifications
You must be signed in to change notification settings - Fork 824
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
lib/wasi: try quick fix for WasiFS::get_inode_at_path #3867
lib/wasi: try quick fix for WasiFS::get_inode_at_path #3867
Conversation
@waynr need to run |
@john-sharratt this looks correct to me, what are your concerns? |
My main concern is that I suspect you will find that this also works in your usecase.... pub(crate) fn get_inode_at_path(
&self,
inodes: &WasiInodes,
base: WasiFd,
path: &str,
follow_symlinks: bool,
) -> Result<InodeGuard, Errno> {
let start_inode = if self.is_wasix.load(Ordering::Acquire) {
let (cur_inode, _) = self.get_current_dir(inodes, base)?;
cur_inode
} else {
self.get_fd_inode(base)?
};
self.get_inode_at_path_inner(inodes, start_inode, path, 0, follow_symlinks)
} Or at least it did with this test...
Reason is that the logic around the base node being an absolute path isn't a valid code path as far as I can see (i.e. it is always false) |
Yeah, this occurred to me, happy to remove that part of the logic. That being said, I don't see how the current master branch approach would ever be valid (except in the edge case where the base directory and the current working directory are the same) given the intent specified in the comment on this method:
Something else I don't understand is how FYI, I say that the base directory is (essentially) ignored in that first logic branch because that's the behavior I observe in master branch -- this function seems to always look for Something else is off about the master branch code in my view. Let's consider the original logic:
On the one hand we say |
This reverts commit 3f0d660.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john-sharratt and @waynr had some discussions about this.
I'm not fully up to date there, but I think the new code should be agreeable, and we also have two new test cases to cover certain conditions.
Description
I've been working on getting wasix-libc's
readdir
function working but havebeen receiving
Errno::Noent
responses frompath_filestat_get
(found inlib/wasi/src/syscalls/wasi/path_filestat_get
).My understanding is that the
path_filestat_get
syscall takes a filedescriptor for the directory and a relative path for the basename of the file
intended to be stat'ed; at least, this is how it appears to be used in
wasix-libc's
readdir
implementation and how downstream libc users ofreaddir
more generally treat it.With the change in this PR,
get_inode_path_at
no longer ignores thebase
fdbut instead uses it to find the file at the given relative
path
. Whenget_inode_path_at
is used in the context ofpath_filestate_get
, this seemsto be the desired/correct behavior.