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

Add native RomFS file and directory handling #645

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Bulmanator
Copy link

This exposes some more of the RomFS API to the public facing side allowing file "opening" and directory listing natively without requiring stdio. The main reason for this is to allow reading RomFS files from an arbitary offset without first seeking the file position. As RomFS is read-only this is crucial for contentionless multi-threaded access, but is unfortunately missing from stdio. I kinda just did the directory iteration stuff to round out the API, they both have the added benefit of requiring zero allocation.

The stdio implementation has been updated to use the native APIs as well with a slight caveat when calling romfs_open. It used to return ENOENT if the directory didn't exist but EROFS if the file didn't exist and the O_CREAT flag was set. It now returns EROFS in either case if the O_CREAT flag is set.

I'm happy to write up an example usage for the switchbrew/switch-examples repository.

Find RomFS mounts by name
Find RomFS files by path or with a mount
Iterate RomFS directory entries
To consolidate code paths to make maintenance slightly easier
Useful for turning romfs_direntry files into readable files
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 this pull request may close these issues.

1 participant