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

file not visible in SPIFFS_readdir #90

Closed
benpicco-tmp opened this issue May 20, 2016 · 3 comments
Closed

file not visible in SPIFFS_readdir #90

benpicco-tmp opened this issue May 20, 2016 · 3 comments

Comments

@benpicco-tmp
Copy link

Hi,
you' ve always been curious about 'interesting' spiffs states, so I've got this one for you: In this dump there is a file called cli.bin.a32 but it does not show up when querying all files like this

void ls(void) {
    spiffs_DIR dir;
    struct spiffs_dirent file;

    SPIFFS_opendir(&spi_fs, 0, &dir);

    while (SPIFFS_readdir(&dir, &file)) {
        printf("\t%d %s\n", file.size, file.name);
    }

    SPIFFS_closedir(&dir);
}
> ls
2016-05-20 10:56:20,956 - INFO #    0 .volaWare
2016-05-20 10:56:20,978 - INFO #    68736 cli.bin

However, after deleting cli.bin

> rm_all
2016-05-20 10:56:25,434 - INFO #    deleting cli.bin…
> ls
2016-05-20 10:56:37,208 - INFO #    0 .volaWare
2016-05-20 10:56:37,229 - INFO #    4 cli.bin.a32

it shows up!

I have no trouble opening/reading the file at any time.

my config is

    cfg.phys_erase_block = BLOCK_4K;    // 4096
    cfg.log_block_size   = BLOCK_4K;
    cfg.log_page_size    = 128;

hidden_file.spiffs

@pellepl
Copy link
Owner

pellepl commented May 24, 2016

Thanks, I will have a peek at it as soon as I can (somewhat chaotic right
now).

Cheers / Peter

2016-05-20 11:54 GMT+02:00 benpicco-tmp notifications@github.com:

Hi,
you' ve always been curious about 'interesting' spiffs states, so I've got
this one for you: In this dump there is a file called cli.bin.a32 but it
does not show up when querying all files like this

void ls(void) {
spiffs_DIR dir;
struct spiffs_dirent file;

SPIFFS_opendir(&spi_fs, 0, &dir);

while (SPIFFS_readdir(&dir, &file)) {
    printf("\t%d %s\n", file.size, file.name);
}

SPIFFS_closedir(&dir);

}

ls
2016-05-20 10:56:20,956 - INFO # 0 .volaWare
2016-05-20 10:56:20,978 - INFO # 68736 cli.bin

However, after deleting cli.bin…

rm_all
2016-05-20 10:56:25,434 - INFO # deleting cli.bin…
ls
2016-05-20 10:56:37,208 - INFO # 0 .volaWare
2016-05-20 10:56:37,229 - INFO # 4 cli.bin.a32

it shows up!

I have no trouble opening/reading the file at any time.

my config is

cfg.phys_erase_block = BLOCK_4K;    // 4096
cfg.log_block_size   = BLOCK_4K;
cfg.log_page_size    = 128;

hidden_file.spiffs http://flauschlabor.de/foobar/hidden_file.spiffs


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#90

pellepl added a commit that referenced this issue Jun 7, 2016
Iterator bug - if an iteration was callbacked at last page in block -1,
the resumed iteration would skip the last page in block.
Fixing this revealed another bug, where free page marker was not advanced
but pointing to the same page found before when searching for new free page.
This is probably not a problem, as when searching for free pages the found
free page always becomes occupied. A new free page scan will simply skip
the previously found free page, which has been allocated by now. However,
it is suboptimal. Also, it might have messed with the wear leveling a bit.
@pellepl
Copy link
Owner

pellepl commented Jun 7, 2016

Thanks for finding this. It was a corner case indeed, but could lead to potentially very weird behaviour. Please retest with the new patch.

Cheers!

@pellepl
Copy link
Owner

pellepl commented Jul 20, 2016

Ok to close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants