littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.9k stars 771 forks source link

esp_littlefs: Failed to unlink path "/flash/index.html". Has open FD. #918

Open grooves38 opened 6 months ago

grooves38 commented 6 months ago

Hello,

I'm working on native ESP-IDF 4.4 .4 with a ESP32 I try to delete a file which was opened before but correctly closed,

I got the error: esp_littlefs: Failed to unlink path "/flash/index.html". Has open FD.

I tried straight forward:

    f = fopen(file_name, "rb"); 
    fclose(f); 
    unlink(file_name);                               // erase if exists

Does not help, only a unregister, re-register works, but that is not a solution same code works with SPIFFS

any hints ?

Regards, Mike

geky commented 5 months ago

Hi @grooves38, this looks like an issue in the ESP-IDF layer. The littlefs core (this repo) doesn't actually care if a file is open in unlink.

You will probably need to open an issue in ESP-IDF to find someone who knows what the issue might be. The fact that SPIFFS works is curious, but it could be a different in the integration for the two filesystem there. They do need to support what is probably subtly different filesystem APIs.