-
Notifications
You must be signed in to change notification settings - Fork 804
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 |
which are counterpart of lfs_getattr and lfs_setattr but work with lfs_file_t not a file path