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
cpu/native: add host fs access via VFS #19315
Conversation
c86c65c
to
4fc5c3c
Compare
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.
Looks straightforward enough to me, with minor comments, and no testing yet.
On a remark / future-evolvability level, I hope that we'll on the long run alter our VFS away from the highly libc dependent structs (stat etc) we have now into something suitably small and understand- and implementable (most flags and modes are just ignored by most file systems). How we use POSIX concepts does make this file system very straightforward, but if and when we change the VFS, we'll have to change a lot of implementations anyway, and this would be just one more.
Shall I squash? |
I added a subfolder inside the To avoid cluttering the directory too much, empty folders are removed when |
As all old comments are addressed, yes, please squash and rebase.
I'd appreciate that. Unless a file system is explicitly configured, it's a toss-up whether the embedded target board's file system would even match what's used on native, so let's rather go for something that's obviously native-only instead of using something that looks like it might be what'd be used on the board but isn't.
I'm not so happy with how these paths are composed. Per the original description, I see how multiple running instances can be an issue, especially given that RIOT will not expect file system content to "just change". But then, same is true for MTD based FSes, right? I don't have a good way forward. In My Ideal World native FS (and probably also MTD) would use file locking to grab its backend, and failure would result in a printed message at startup a la "Unable to mount FS due to concurrent access; consider passing the RIOT_FS_NATIVE environment variable with a different directory to each instance". Would that work for you? |
How about adding an |
Would work for me. Do you think it'd make sense to make the base path
also into a runtime configuration (either via argument or environment)?
|
That's a bit more tricky as we get that from a XFA and I didn't want |
Right, because there can be multiple mount points (and the one currently
given with `-D` is only the one on the auto mount point).
So IIUC the behavior would be:
* automount, no argument => `./native` gets mounted
* automount, no argument, FS_NATIVE_DIR override to "" => `.` gets
mounted
* automount, --isolate-fs => `./native/${_native_id}` gets mounted
* explicit mount, no argument => whatever is in the `.hostpath` of the
struct gets mounted
* explicit mount, --isolate-fs => `./${.hostpath}/${_native_id}` gets
mounted`
Works for me.
|
Worked like a charm! Compiled fine with clang & asan. |
Rebased again to solve the merge conflict. |
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.
Just nits!
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.
I've gone through the code, and have some comments. I'll give it a test run in the next iteration.
|
||
static int _rename(vfs_mount_t *mountp, const char *from_path, const char *to_path) | ||
{ | ||
static char path_a[PATH_MAX]; |
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.
I wonder whether it's warranted to have two PATH_MAX buffers around for an operation that can't be GC'd at link time because it's behind the file system driver -- but it's OK, we're on native, nothing in here will eat significant resources of the host anyway.
(If this were targetting embedded, I'd suggest to have static buffers per compilation unit and use them as needed).
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.
My concerns as well as @Teufelchen1's have been addressed (thus dismissing the review).
LGTM and passes tests, let's ship it.
It said "just nits" and the nits have been picked.
Thank you for the review! bors merge |
Build succeeded: |
Contribution description
It is often quite handy to access files from Linux on RIOT and the other way round.
With
native
this is very straightforward asnative
is just a Linux process.This adds a VFS driver to access the host file system from
native
.Testing procedure
Run e.g.
tests/vfs_default
This will create a folder
nvm0
in the current working directory that is also accessible from RIOT.To change the exported directory to the current dir, set
You should now be able to access the directory of the example from withing RIOT:
Maybe this should be the default on
native
instead of littlefs2?Issues/PRs references