-
Notifications
You must be signed in to change notification settings - Fork 2
Add a chunk reading API. #18
Conversation
893da59 to
25ae084
Compare
robin-nitrokey
left a comment
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 good to me, just two notes:
- The commit contains some changes that look unrelated (
WrapKeyData). Did you include them intentionally? - I think the request and reply types should be called
ReadFileChunkandWriteFileChunkfor consistency.
Yes. Initially I used the But since I ended up adding an Edit: done it. |
3bbae12 to
b7933bf
Compare
|
There's one remaining issue with this API: If a client starts writing data to a file, it is immediately committed to the filesystem, even before all chunks have been written. This could lead to truncated data being stored. |
|
So should we maybe add some safe-guard mechanism ? |
The issue is that its existence would need to be checked every time we read a file. So the solution would probably be to write the file to another directory |
|
This sounds better. Do we have a proper Looking on it from another side: We should anyways be more defensive about contents which are read from the filesystem. Essentially plausibility checks or similar mechanisms after reading data might be something the application should be responsible for and this would also catch such issues right ? |
|
There's a rename that works as a move.
I don't understand what you mean? Checksums? |
3fd6c28 to
5823f4e
Compare
That's great, yeah then let's go for it, but I would suggest to not "waste" another directory for it but moreover just have something like
goood question :D checksums might be too heavy, maybe keeping filesizes ... haven't thought this through, but generally I would see the application being responsible to check if data read from the filesystem is not corrupt. |
|
The issue I have with |
|
What do you think about first writing to volatile and then copying chunk by chunk to the target storage? This would at least mean that syscalls are atomic. We could still use some renaming mechanism (leading dot?) to avoid file corruption if the final syscall is aborted e. g. due to power loss. |
|
I don't see what it would bring to do so. We could easily have some garbage collection on startup if you're afraid of a missed call to |
|
It would slightly remove the required writes to the real FS and avoid the need for another directory. |
|
You would still need a directory in the volatile filesystem (one for each target filesystem). But indeed it would save the physical FS. I'll do that. |
758d9a7 to
cff7d2a
Compare
cff7d2a to
aa634db
Compare
An upstream PR will be prepared once trussed-dev#96 and trussed-dev/littlefs2#34 are merged.