Skip to content

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