project-machine / puzzlefs

Apache License 2.0
381 stars 18 forks source link

add a reader/ package for reading puzzlefs images #7

Closed tych0 closed 3 years ago

tych0 commented 3 years ago

This package consists of two layers:

  1. a "puzzlefs" module, which does the reading of the wire format and piecing it together (e.g. turning a local offset reference to a directory into an actual directory listing, or reading a file from file chunks, neither of which are are appropriate for the wire format).

  2. a "fuse" module, which does the fuse bits (mostly responding with -EROFS or simple file/dir listing responses for now)

There are a couple of rust uglinesses in this code: the first is all of the casts back and forth between usize and u64 in file_read(). This won't matter for x86_64 since they're the same size, but for other platforms it might fail. It's also just ugly. I spent a while trying to figure out a nicer way to do this and eventually gave up :)

The second is exporting test code from the builder package to the reader package: we'd like to build filesystems with known contents to test with, but not expose a function to do this as a public API since it won't make sense for other people. However, it doesn't seem to be possible to only expose functions in test mode across packages, so we might have to experiment with rust features or something to accomplish this. For now, we just export the function as part of the public API. Also, the fuse bits could be better tested with different chunking parameters so that it ends up reading things from different chunks sort of like fastcdc_fs.rs does; it would be nice to export that stuff to tests somehow as well.

Signed-off-by: Tycho Andersen tycho@tycho.pizza