- Edited
I’ve been struggling with this all week now. I am trying to get littlefs to create a directory in /lfs
but it fails with error -22. I was able to get it to work once, but now… nothing.
This is my code snippet:
...
char dname[MAX_PATH_LEN];
// create data directory if it doesn't exist
printk("Creating data directory...\n");
// STORE_FORWARD_DIR defined as "sfdata"
snprintf(dname, sizeof(dname), "%s/%s", mp->mnt_point, STORE_FORWARD_DIR);
int rc = fs_mkdir(dname);
if (rc && rc != -EEXIST) {
printk(" mkdir(%s) error -> rc=%d\n", dname, rc);
return rc;
}
printk(" mkdir(%s) SUCCESS -> rc=%d\n", dname, rc);
...
I’ve tried numerous variations of this but no luck. The one time I was able to create it the file system worked perfectly but then I decided to attempt a reset the file system by erasing the flash area. However this seemed to corrupt the flash device and I was not longer able to do anything with it. I assumed I wrecked the flash and ordered more boards assuming that was my problem.
On a brand new board, this still does not work and I am at a loss. Naturally there are other implementations I could choose that do not require a subdirectory, but I am more concerned that I am doing something fundamentally wrong and I don’t want to deploy devices with a critical fault so I really need to get something so basic working properly.
Has anyone tried this yet?