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 libc defined but not implemented (IDFGH-6119) #7798

Closed
ivmarkov opened this issue Oct 29, 2021 · 4 comments
Closed

realpath libc defined but not implemented (IDFGH-6119) #7798

ivmarkov opened this issue Oct 29, 2021 · 4 comments
Labels
Resolution: Done Issue is done internally Status: Resolved Issue is done internally Type: Feature Request Feature request for IDF

Comments

@ivmarkov
Copy link
Contributor

ivmarkov commented Oct 29, 2021

Currently, the Rust STD equivalent of realpath (fs::canonicalize) is implemented to call into realpath, and as a result, usage of fs::realpath results in a linkage error. This is not so ideal.

How do we feel about implementing realpath in ESP-IDF itself? Basically "Option A" as documented here:
https://github.com/ivmarkov/rust-esp32-std-demo/blob/6611e765441d8cc3a6d018ece935f521b4fe7e79/src/main.rs#L975

@ivmarkov ivmarkov added the Type: Feature Request Feature request for IDF label Oct 29, 2021
@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 29, 2021
@github-actions github-actions bot changed the title realpath libc defined but not implemented realpath libc defined but not implemented (IDFGH-6119) Oct 29, 2021
@igrr
Copy link
Member

igrr commented Oct 29, 2021

@ivmarkov Thanks for the suggestion, we can implement realpath in IDF. We can't use the newlib code you've linked because it is released under LGPL, i think. However given the absence of symlinks the implementation shouldn't be difficult.

@ivmarkov
Copy link
Contributor Author

Sure - the linked code was just an example that the function can be trivially implemented in terms of parsing the path and handling the ..s and skipping the .s (that is - in the absence of symlinks on FAT and no current directory).

If you decide to implement this one, perhaps it makes sense to also implement:

  • getcwd - to always return /, as realpath would be expanding relative directories as if cwd is /
  • chdir - to fail with ENOSYS

@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed Resolution: Done Issue is done internally Status: Resolved Issue is done internally and removed Status: Opened Issue is new Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed labels Dec 9, 2021
espressif-bot pushed a commit that referenced this issue Dec 27, 2021
@ivmarkov
Copy link
Contributor Author

@igrr realpath implementation works great. Tested:

  • Usage of realpath via Rust's fs::canonicalize API
  • Crate panic_abort now works without the panic_immediate_abort option, which allows Rust code to print nice panic / assertion messages before giving control to ESP-IDF's panic handler.

Please merge into v4.4
I'll probably backport this code into v4.3.1 in the form of a patch that is applied (as usu.) when compiling the ESP-IDF for Rust.

@igrr
Copy link
Member

igrr commented Jan 4, 2022

Backported to release/v4.4 in f158a0d, will be part of v4.4-rc1.

dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 4, 2022
dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Resolved Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants