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

Implement getcwd, chdir #11

Closed
sunfishcode opened this issue Sep 13, 2021 · 6 comments · Fixed by #19
Closed

Implement getcwd, chdir #11

sunfishcode opened this issue Sep 13, 2021 · 6 comments · Fixed by #19

Comments

@sunfishcode
Copy link
Owner

Rust's std::env::current_dir and set_current_dir are implemented by calls to getcwd and chdir. The first half in implementing these is to add support to rsix: these should go in rsix::process. There's already a imp/linux_raw implementation of the getcwd and chdir system calls, so this needs a imp/libc implementation which should just call the libc function, and then a public API in src/process. For getcwd, the public API should take care of allocating the buffer and growing it as needed until getcwd successfully writes the whole string, returning an OsString, similar to readlinkat.

The second step is to implement c-scape support in terms of the rsix public API. It may look odd to do it this way, because rsix will be dynamically allocating, and we'll need to copy the (sub)string out of the dynamic allocated buffer into the fixed-size requested buffer. But one of the goals for c-scape is to help test rsix, and to help prepare for rsix itself to be the low-level API instead of c-scape.

@cole-miller
Copy link
Contributor

I'd love to tackle this if someone else isn't already on the job.

@sunfishcode
Copy link
Owner Author

Go for it! And please ask questions if anything is unclear.

@Urgau
Copy link

Urgau commented Sep 13, 2021

Oh, I just saw this issue. I was just doing these functions in rsix (my pr bytecodealliance/rustix#55).

Sorry @cole-miller if you had started 😀; however i'm not planning to do them for mustang so if you want you can take them to a pr

@cole-miller
Copy link
Contributor

cole-miller commented Sep 13, 2021 via email

@sunfishcode sunfishcode mentioned this issue Sep 15, 2021
16 tasks
@sunfishcode
Copy link
Owner Author

@cole-miller rsix 0.23.0 is now published, which contains the syscall support for getcwd and chdir, so the next step here is to implement them in mustang. Please feel free to ask questions if anything is unclear!

@cole-miller
Copy link
Contributor

Sorry for the delay, I've been occupied with something else. I should be able to submit a PR tomorrow!

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 a pull request may close this issue.

3 participants