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

realpath in stdlib.h but not in library #81

Closed
binji opened this issue Jul 10, 2019 · 7 comments
Closed

realpath in stdlib.h but not in library #81

binji opened this issue Jul 10, 2019 · 7 comments

Comments

@binji
Copy link
Member

binji commented Jul 10, 2019

I assume we won't have realpath for WASI MVP, is that correct? It seems to included in stdlib.h.

@sunfishcode
Copy link
Member

Yeah, WASI doesn't have absolute paths, so the standard realpath doesn't fit. I filed #82 to remove the declarations.

That said, besides making paths absolute, realpath also resolves symbolic links, resolves .. and . paths, and trims redundant / characters. We could conceivably have a realpath which does those things and maybe also resolves relative paths to be rooted at ., which might be enough for some use cases.

@sbc100
Copy link
Member

sbc100 commented Jul 11, 2019

It doesn't have absolute paths at the syscall layer, but doesn't it kind of emulate them in libpreopen? I mean if the concept of PWD exists then can't realpath just use getcwd() to construct an abspath?

@sunfishcode
Copy link
Member

We don't currently have getcwd either :-). libpreopen maps from absolute path to base + relative path, which isn't enough to do getcwd.

Should we add a getcwd? It does leak information about the host, and we can't easily virtualize or remap it because the main purpose is to get a string that you can send to another process or serialize out somewhere to be read by the outside world, so it has to reflect the actual host path name.

@pchickey
Copy link
Collaborator

I think we should encourage the programs that require these sort of absolute path functions to implement them totally in userland, if possible. I wouldn't want to expose the host's "real" cwd at all, but it should be possible to define these functions such that it always pretends to be under /home/wasi or something, right?

@sbc100
Copy link
Member

sbc100 commented Jul 11, 2019

No, I'm not talking about exposing the real host cwd. But we can build cwd in userspace based on the pre-opened root fd can't we? I'm surprised libpreopen doesn't do this already. Wouldn'tit be as simple as doing: base + global_cwd + relative?

I don't understand what you mean about sending the string to the outside world. Paths only make sense within a given module, right? Or at least within modules that shared the same virtualized view of the filesystem.

@binji
Copy link
Member Author

binji commented Jul 15, 2019

Right, I'd imagine it would be similar to running in a chroot.

@sunfishcode
Copy link
Member

The original issue here is fixed in a413650; we no longer declare realpath.

If anyone's interested in introducing a concept of a cwd, even without exposing the host cwd, we'd need new WASI support, so we should discuss this in the WASI issue tracker.

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

No branches or pull requests

4 participants