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
Provide a function for probing for LFS #947
Comments
naturally, we must at least know the block size. |
I'm curious, what would this gain over Unless I'm missing something, everything that is in the superblock should be accessible via |
is lfs_mount guaranteed to not modify the fs? the reason for probing is that we want to provide exact disk_version to lfs_mount to avoid upgrading the disk format (we want to preserve compatibility with older firmware for now). |
there is no runtime read-only mount option, only LFS_READONLY. i guess lfs_mount ro + lfs_fs_stat would be a way. |
Ah yes, In general littlefs has some pretty strong guarantees around not mutating the disk until an actual mutation API is called (
I've been thinking of adding a runtime LFS_M_READONLY flag to But there's other mount flags that could be useful in the future.
This is a valid point. We should probably make a failing The notorious "Corrupted dir pair" log (here) can probably be downgraded to LFS_DEBUG, though I'm not sure if there's other error logs that can be hit. I do like the idea and design of the Since this can be implemented on the user's side: int lfs_probe(lfs_t *lfs, const struct lfs_config *cfg,
struct lfs_fs_stat *fsstat) {
int err = lfs_mount(lfs, cfg);
if (err) {
return err;
}
err = lfs_fs_stat(lfs, fsstat);
if (err) {
return err;
}
err = lfs_unmount(lfs);
if (err) {
return err;
}
return 0;
} I'm also curious if there's any prior art. From what I understand most filesystems rely on
I'm probably missing something, but would this be more easily accomplished by setting If configured this way, littlefs should error with LFS_ERR_INVAL if it encounters an lfs2.1 disk version (here, oh look another error log) |
yes, but that would hard-code the version and won't be as flexible during migration. thus our disk_ver migration plan is:
we implemented (1) about 6 months ago but haven't done (2) yet, so even our latest firmware still comes with disk_ver 2.0 images. when we update out image generation to 2.1 (probably in a month or so), we'll still maintain 6+ month rollback compatibility window because of the version probing behavior. had we hard-coded |
Ah I see, thanks for clarifying. Yeah, I can't think of a better solution with littlefs's current API. If/when we have mount flags, adding LFS_M_NOUPGRADE (or more likely requiring LFS_M_UPGRADE to upgrade) would make a lot of sense. |
can't mount flags be added to |
That's a good point, it would be inconsistent with I was also considering adding But there are some... more disruptive changes bubbling down the pipeline. If we're going to have major API breakages somewhat soon I think trying to add flags to If things take longer than expected (as they usually do) I'll consider adding LFS_M_NOUPGRADE to |
Just thinking out loud. Another option might be to try mounting first with Not sure if this is better or worse than mount->fs_stat->unmount->mount. |
but we'd need to store them anyway and presumably check? e.g. so, my wishlist for flags:
|
Ah sorry, this is in the context of some other changes that move away from needing
It's not very clear what the best solution is, but I think we may just want to treat errors during |
It would be nice to have a function that would probe a device for LFS and return the parameters if found (the
lfs_superblock_t
structure).The text was updated successfully, but these errors were encountered: