mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
fs/mnemofs: Refactor path logic, direntry size bug fix, open free bug fix
Refactoring path logic to prevent logic flaws, direntry size bug fix to allow proper direntry traversal, open free bug fix to prevent memory leak after close. Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
01bac59cb7
commit
0be6dfb552
@@ -25,6 +25,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <debug.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <nuttx/compiler.h>
|
||||
@@ -89,8 +90,8 @@
|
||||
|
||||
#else
|
||||
|
||||
#define NAND_RAM_LOG
|
||||
#define NAND_RAM_STATUS_LOG
|
||||
#define NAND_RAM_LOG(str, ...)
|
||||
#define NAND_RAM_STATUS_LOG(str, ...)
|
||||
|
||||
#endif /* CONFIG_MTD_NAND_RAM_DEBUG */
|
||||
|
||||
@@ -197,10 +198,12 @@ static void nand_ram_storage_status(void)
|
||||
|
||||
static inline void nand_ram_status(void)
|
||||
{
|
||||
#ifdef CONFIG_MTD_NAND_RAM_DEBUG
|
||||
if (nand_ram_ins_i % NAND_RAM_STATUS_LEVEL == 0)
|
||||
{
|
||||
nand_ram_storage_status();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -353,12 +356,19 @@ int nand_ram_rawread(FAR struct nand_raw_s *raw, off_t block,
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
memcpy(data, (const void *)read_page_data, NAND_RAM_PAGE_SIZE);
|
||||
if (nand_ram_flash_spare[read_page].free == NAND_RAM_PAGE_FREE)
|
||||
{
|
||||
memset(data, 0, NAND_RAM_PAGE_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(data, (const void *)read_page_data, NAND_RAM_PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
if (spare != NULL)
|
||||
{
|
||||
memcpy(spare, (const void *)read_page_spare, NAND_RAM_PAGE_SIZE);
|
||||
memcpy(spare, (const void *)read_page_spare, NAND_RAM_SPARE_SIZE);
|
||||
}
|
||||
|
||||
NAND_RAM_LOG("[LOWER %lu | %s] Done\n", nand_ram_ins_i, "rawread");
|
||||
@@ -420,6 +430,7 @@ int nand_ram_rawwrite(FAR struct nand_raw_s *raw, off_t block,
|
||||
|
||||
nand_ram_flash_spare[write_page].n_write++;
|
||||
|
||||
memset((void *)write_page_data, 0, NAND_RAM_PAGE_SIZE);
|
||||
if (data != NULL)
|
||||
{
|
||||
memcpy((void *)write_page_data, data, NAND_RAM_PAGE_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user