-
Notifications
You must be signed in to change notification settings - Fork 816
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
Fix return value of lfs_rename() #917
Fix return value of lfs_rename() #917
Conversation
Tests passed ✓, Code: 16836 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 800 B (+0.0%)
|
Hi @tomscii, thanks for this. This does look more correct in terms of following POSIX. The only concern is if this will break any existing code. Code may be relying on LFS_ERR_NOTDIR for both cases. I'll plan on bringing this in on the next minor release. If it's an issue, we'll learn, otherwise I think the strategy may be to allow error codes to change to match POSIX on minor releases. |
When lfs_rename() is called trying to rename (move) a file to an existing directory, LFS_ERR_ISDIR is (correctly) returned. However, in the opposite case, if one tries to rename (move) a directory to a path currently occupied by a regular file, LFS_ERR_NOTDIR should be returned (since the error is that the destination is NOT a directory), but in reality, LFS_ERR_ISDIR is returned in this case as well. This commit fixes the code so that in the latter case, LFS_ERR_NOTDIR is returned.
I've gone ahead and updating this PR for two minor reasons:
Let me know if anything looks concerning. |
Tests passed ✓, Code: 16836 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 800 B (+0.0%)
|
@geky Looks great, thank you! |
This is on master now, thanks for the PR! |
Excellent! Thanks for all your hard work maintaining LittleFS! |
When lfs_rename() is called trying to rename (move) a file to an existing directory, LFS_ERR_ISDIR is (correctly) returned. However, in the opposite case, if one tries to rename (move) a directory to a path currently occupied by a regular file, LFS_ERR_NOTDIR should be returned (since the error is that the destination is NOT a directory), but in reality, LFS_ERR_ISDIR is returned in this case as well.
This commit fixes the code so that in the latter case, LFS_ERR_NOTDIR is returned.