Skip to content

pkg/littlefs*: align readdir() with documentation#17623

Merged
benpicco merged 2 commits intoRIOT-OS:masterfrom
benpicco:pkg/littlefs-readdir
Feb 8, 2022
Merged

pkg/littlefs*: align readdir() with documentation#17623
benpicco merged 2 commits intoRIOT-OS:masterfrom
benpicco:pkg/littlefs-readdir

Conversation

@benpicco
Copy link
Copy Markdown
Contributor

@benpicco benpicco commented Feb 7, 2022

Contribution description

readdir() should only output the name of the file, but littleFS adds a leading /.

Neither FAT nor Linux will exhibit this behavior. (SPIFFS does not support directories)

    struct dirent *entry;
    DIR *dir = opendir(".");
    while ((entry = readdir(dir))) {
            printf("%s\n", entry->d_name);
    }

This results in surprising failures of code that expects filenames to match that was tested on a different FS, when suddenly there is a / in front of the filename.

Testing procedure

before

> ls /
/.
/..
/test
total 3 files
> ls /test
/.
/..
/0.cnk
/1.cnk
total 4 files

with this patch

> ls /
.
..
test
total 3 files
> ls /test
.
..
0.cnk
1.cnk
total 4 files

Issues/PRs references

`readdir()` should only output the name of the file, but littleFS
adds a leading `/`.

Neither FAT nor Linux will exhibit this behavior.

        struct dirent *entry;
        DIR *dir = opendir(".");
        while ((entry = readdir(dir))) {
                printf("%s\n", entry->d_name);
        }

This results in surprising failures of code that expects filenames
to match that was tested on a different FS, when suddenly there is
a `/` in front of the filename.
@github-actions github-actions bot added the Area: pkg Area: External package ports label Feb 7, 2022
@benpicco benpicco added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Feb 7, 2022
@benpicco benpicco requested a review from chrysn February 7, 2022 22:31
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 7, 2022
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Feb 8, 2022
@benpicco benpicco merged commit 7dca88b into RIOT-OS:master Feb 8, 2022
@benpicco benpicco deleted the pkg/littlefs-readdir branch February 8, 2022 11:34
@OlegHahm OlegHahm added this to the Release 2022.04 milestone Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants