Commit Graph

2 Commits

Author SHA1 Message Date
Christopher Haster
e50a0677c0 Changed lfs_dir_read to return 0 on success
Before:
If an entry is found, lfs_dir_read returns 1
If at end of directory, lfs_dir_read returns 0

After:
If an entry is found, lfs_dir_read returns 0
If at end of directory, lfs_dir_read returns LFS_ERR_NOENT

---

lfs_dir_read is a bit of an odd function. It's supposed to match
lfs_file_read, but instead of reading bytes, it reads directory
entries.

Its POSIX equivalent, readdir, indicates whether or not we reached
the end of the directory by returning a NULL pointer:

struct dirent *readdir(DIR *dirp);

But this API needed to change for littlefs, since we don't use errno,
instead returning errors as signed integers through all API functions,
including lfs_dir_read.  So, in an effort to match lfs_file_read,
lfs_dir_read returned the "number" of directory entries read, limited
to either 0 or 1.

Perhaps unsurprisingly, this turned out to be confusing to users,
and a better API was proposed hathach to instead return either 0
or LFS_ERR_NOENT, an error which can't occur for other reasons in
lfs_dir_read.

Suggested by hathach
2020-12-24 23:15:02 -06:00
Christopher Haster
aab6aa0ed9 Cleaned up test script and directory naming
- Removed old tests and test scripts
- Reorganize the block devices to live under one directory
- Plugged new test framework into Makefile

renamed:
- scripts/test_.py -> scripts/test.py
- tests_ -> tests
- {file,ram,test}bd/* -> bd/*

It took a surprising amount of effort to make the Makefile behave since
it turns out the "test_%" rule could override "tests/test_%.toml.test"
which is generated as part of test.py.
2020-01-27 10:16:29 -06:00