Hello all,
- My goal is: I want to create a file system in RAM, for long term storge
- My actions are:
I tried to follow the instructions from : https://mongoose-os.com/docs/mongoose-os/api/drivers/vfs-common.md
Here is my code:
#define FS_PATH "/mnt"
#define FS_TYPE "RAM"
#define FS_SIZE 65536
#define FS_ERASE_BYTE 0
#define FS_FILL_BYTE 0
#define FS_FLASH_CHECK 0
/** Creates and mountes a file system*/
void init_filesystem()
{
bool ret_val = false;
char *fs_address = malloc(FS_SIZE);
char ram_dev_opts[128];
char ram_fs_opts[128];
// Register fielsystem type and make it available for use in mkfs and mount.
ret_val = mgos_vfs_dev_ram_init();
if(!ret_val){
LOG(LL_ERROR, ("Filesystem could not be registered. Aborting."));
return;
}
sprintf(ram_dev_opts, "{addr: %d, size: %d, erase_byte: %d, fill_byte: %d, flash_check: %d}", (int32_t) fs_address, FS_SIZE, FS_ERASE_BYTE, FS_FILL_BYTE, FS_FLASH_CHECK);
sprintf(ram_fs_opts, "{addr: %d, size: %d}", (int32_t) fs_address, FS_SIZE);
// Create the filesystem.
ret_val = mgos_vfs_mkfs(MGOS_VFS_DEV_TYPE_RAM, ram_dev_opts, "LFS", ram_fs_opts);
if(!ret_val){
LOG(LL_ERROR, ("Filesystem could not be created. Aborting."));
return;
}
// Mount the filesystem
ret_val = mgos_vfs_mount(FS_PATH, MGOS_VFS_DEV_TYPE_RAM, ram_dev_opts, "LFS", ram_fs_opts);
if(!ret_val){
LOG(LL_ERROR, ("Filesystem could not be mounted. Aborting."));
return;
}
}
- The result I see is:
mgos_vfs_dev_ram.c:82 65536 bytes @ 0x3ffc85a8, eb 0x00, fb 0x00, fc no
[Jul 9 17:50:48.690] mgos_vfs.c:101 Create LFS (dev 0x3ffc84f4, opts {addr: 1073513896, size: 65536})
[Jul 9 17:50:48.699] mgos_vfs_lfs.c:248 size 65536 rs 64 ps 64 bs 4096 => 0
[Jul 9 17:50:48.704] mgos_vfs_dev.c:203 refs 0
[Jul 9 17:50:48.708] mgos_vfs_dev_ram.c:82 65536 bytes @ 0x3ffc85a8, eb 0x00, fb 0x00, fc no
[Jul 9 17:50:48.714] mgos_vfs.c:148 /mnt: LFS @ , opts {addr: 1073513896, size: 65536}
[Jul 9 17:50:48.721] lfs error:966: Corrupted dir pair at 0 1
[Jul 9 17:50:48.725] mgos_vfs_lfs.c:224 size 65536 rs 64 ps 64 bs 4096 => -84
[Jul 9 17:50:48.730] mgos_vfs.c:156 FS LFS {addr: 1073513896, size: 65536}: mount failed
[Jul 9 17:50:48.738] mgos_vfs_dev.c:203 refs 0
[Jul 9 17:50:48.741] filesystem.c:38 Filesystem could not be mounted. Aborting.
- My expectation & question is:
I would like to get some instruction on how a RAM file system must be correctly created. I clearly get some stuff wrong.
Thank you