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

Using lfs_dir_tell at the end of a directory succeds, but then lfs_dir_seek fails #785

Closed
sosthene-nitrokey opened this issue Mar 13, 2023 · 2 comments
Labels
needs investigation no idea what is wrong

Comments

@sosthene-nitrokey
Copy link
Contributor

sosthene-nitrokey commented Mar 13, 2023

Behaviour

When iterating over a directory with lfs_dir_open and lfs_dir_read in a loop, if after calling lfs_dir_read on the last file, one calls lfs_dir_tell, the call success. However, calling lfs_dir_seek with the given value fails with -22 (invalid).

Expected behaviour

I'd expect this to succeed and only further calls to lfs_dir_read to fail. It would also be reasonable to have lfs_dir_tell fail too with a NOENT error..

Reproducer

The test_dirs doesn't iterate over all the files created in the directory, so this bug doesn't happen in the test suite. See #786 for an updated test suite that triggers the bug.

@geky
Copy link
Member

geky commented Apr 18, 2023

Hi @sosthene-nitrokey, thanks for creating an issue. I agree with your evaluation.

Out of curiosity I tested telldir/seekdir locally on Linux and it returns a NULL dirent without error. It makes sense as this matches the behavior of file tell/seek when at the end of a file.

I created #805 to fix this, let me know if you see any issues with it.

@sosthene-nitrokey
Copy link
Contributor Author

sosthene-nitrokey commented Jun 27, 2023

Fixed by #805, included in 2.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation no idea what is wrong
Projects
None yet
Development

No branches or pull requests

2 participants