fs_sync error -5

Hi there,

Due to Zephyrs filesystem logging backend being too inefficient for our use-case, we decided to implement our own bare-minimum logger. It is meant to write messages directly to a file on the sd-card. All operations (fs_open, fs_write, fs_close) are secured with a mutex and everything is working great.

Except for flushing the file-cache to the 'real' file on the filesystem; fs_sync, for example, works but always return error number 5 (EIO). It also takes very long. To easily reproduce the issue, I've attached a sample application. It contains some functions required for our custom hardware, but changing the fat_fs example and adding the following piece of code, results in the same behaviour.

    fs_file_t_init(&log_file);

    if(fs_open(&log_file, "/SD:/logs/log.txt", FS_O_RDWR | FS_O_CREATE | FS_O_APPEND) != 0){
        LOG_WRN("Failed to open logfile.");
    } else {
        LOG_INF("Opened log file!");
        static const char* log_message = "Hello World!";
        fs_write(&log_file, log_message, strlen(log_message));
        fs_sync(&log_file);
    }
Kind regards and happy holidays,
Jochem
Parents Reply Children
No Data
Related