Skip to content
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

lfs_filebd.c seems to assume errno values #946

Open
yamt opened this issue Feb 27, 2024 · 2 comments
Open

lfs_filebd.c seems to assume errno values #946

yamt opened this issue Feb 27, 2024 · 2 comments
Labels
needs fix we know what is wrong tooling

Comments

@yamt
Copy link
Contributor

yamt commented Feb 27, 2024

functions in lfs_filebd.c (eg. lfs_filebd_read) returns a negative errno. (eg. -errno)
it doesn't necessarily match with enum lfs_error values.

@geky geky added needs fix we know what is wrong tooling labels Feb 28, 2024
@geky
Copy link
Member

geky commented Feb 28, 2024

Hi @yamt, thanks for creating an issue.

Ah yes, I can see where this could be an problem.

The exact solution though seems a bit unclear. We really shouldn't be mapping all OS errors into littlefs errors in the bd since 1. littlefs doesn't define all OS errors and 2. this can mess up littlefs internals.

These should probably all be mapped to LFS_ERR_IO, though it's a shame to lose the extra error info. At least lfs_filebd_create can return some of the more useful errors, which is where we call open.


I'm curious, did you run into an actual error during use? From what I understand most modern OSs read/write/lseek don't really ever error unless you yank the harddrive out of the machine.

@yamt
Copy link
Contributor Author

yamt commented Feb 28, 2024

Hi @yamt, thanks for creating an issue.

Ah yes, I can see where this could be an problem.

The exact solution though seems a bit unclear. We really shouldn't be mapping all OS errors into littlefs errors in the bd since 1. littlefs doesn't define all OS errors and 2. this can mess up littlefs internals.

These should probably all be mapped to LFS_ERR_IO, though it's a shame to lose the extra error info. At least lfs_filebd_create can return some of the more useful errors, which is where we call open.

i guess leaving the original errno in LFS_FILEBD_TRACE is good enough.

I'm curious, did you run into an actual error during use? From what I understand most modern OSs read/write/lseek don't really ever error unless you yank the harddrive out of the machine.

no. i was just reading the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs fix we know what is wrong tooling
Projects
None yet
Development

No branches or pull requests

2 participants