-
Notifications
You must be signed in to change notification settings - Fork 810
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
littlefs: Add lfs_file_getattr and lfs_file_setattr #1045
base: master
Are you sure you want to change the base?
Conversation
which are counterpart of lfs_getattr and lfs_setattr but work with lfs_file_t not a file path Signed-off-by: zhouliang3 <[email protected]>
bf6c839
to
2b9c758
Compare
@geky I think the ci error isn't related to this patch:
|
Hi @xiaoxiang781216, thanks for creating a PR.
You are correct, sorry about that. GitHub introduced some breaking changes somewhat recently and it's made things a bit of a mess. This would need to be rebased on to the This isn't the first time In littlefs, writes to a file are not committed until This gets tricky for metadata, where we can't rely on on-disk copy-on-write data structures. The current assumption is that a file's metadata fits in RAM, with custom attributes being backed by the user-provided Calling The only way I could see |
Hello, I'm glad to see you reply to this PR. I have two questions about it:
|
Yes! I'm not opposed to it. I've considered adding it myself, but there is one extremely niche corner case that has made me hesitate. Consider removing a file with attrs: lfs_file_open(&lfs, &file, "file.txt", LFS_O_RDONLY) => 0;
lfs_remove(&lfs, "file.txt") => 0;
lfs_file_getattr(&lfs, &file, 't', buffer, sizeof(buffer)) => ?; If these attrs live on disk, Is this practically an issue? To be honest I'm not sure. On one hand it risks burning users with niche POSIX incompatibilities. On the other hand So, I'm not opposed to it, but that's why I've held off so far. -- Though before bringing it in,
Yes, this would satisfy littlefs's powerloss model. But it would the be the only API that requires malloc to work. My original thinking was that At least If we do add a malloc-backed A malloc-backed |
Thanks for your comments. I split out
I also found this problem during testing. Are there differences in the way different file systems handle some details? Perhaps this behavior is acceptable?🤔
As for the implementation of
Thank you for your idea. I will consider whether there is a simpler and more efficient way to implement the modification of |
Thanks for creating #1047. I'm sorry but I think it may need to be left unmerged for a while. I think the custom attribute API in its entirety needs an overhaul in order to hammer out these corner cases.
This is a good question. But digging around it seems most filesystems that support custom attributes also use inodes, which avoids the problem (inodes on disk are only cleaned up after the last file close). Which raises the question should littlefs introduce inodes? The downside of inodes is they introduce more complexity, add more things that can go wrong during powerloss, etc, and increase the overhead of small inline files. On the other inodes would solve the problem of unique per-file ids, which some users have asked for...
In hindsight we probably don't really need The fact that |
This has also been in the back of my mind the past week. A couple ideas how we could improve things long term:
Just brainstorming, but I think long-term the best solution will be to add some mix of 4., 1., and 2., to cover the different use cases. I didn't expect this API to become such a mess when first adding it! |
And sorry for blocking #1047, but I think it's worth waiting on it. Note that if we adopt 4., These API differences would be difficult to fix retroactively. |
which are counterpart of lfs_getattr and lfs_setattr but work with lfs_file_t not a file path