Squashed commit of the following:

fs/spiffs:  Finished review, update, and repartitioning of spiffs_core.c.

    fs/spiffs:  Converted macro SPIFFS_VALIDATE_OBJIX to a function.

    fs/spiffs:  Move SPIFFS_VALIDATE_DATA and SPIFFS_CHECK_RES macros inline.
This commit is contained in:
Gregory Nutt 2018-09-25 12:14:43 -06:00
parent 5e69b6e09f
commit 8373784afe
7 changed files with 1864 additions and 1300 deletions

View File

@ -77,7 +77,6 @@ extern "C"
#define SPIFFS_ERR_INDEX_FREE -10018
#define SPIFFS_ERR_INDEX_LU -10019
#define SPIFFS_ERR_INDEX_INVALID -10020
#define SPIFFS_ERR_INTERNAL -10050
/* Flags on open file/directory options */

View File

@ -109,11 +109,11 @@ static int spiffs_check_get_data_pgndx(FAR struct spiffs_s *fs,
/* Find the object index for the object ID and span index */
ret = spiffs_obj_lu_find_id_and_span(fs, objid | SPIFFS_OBJ_ID_IX_FLAG,
objndx_spndx, 0, objndx_pgndx);
ret = spiffs_objlu_find_id_and_span(fs, objid | SPIFFS_OBJ_ID_IX_FLAG,
objndx_spndx, 0, objndx_pgndx);
if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -124,14 +124,14 @@ static int spiffs_check_get_data_pgndx(FAR struct spiffs_s *fs,
{
/* Get the referenced page from object index header */
addr += sizeof(struct spiffs_pgobj_ixheader_s) +
addr += sizeof(struct spiffs_pgobj_ndxheader_s) +
data_spndx * sizeof(int16_t);
}
else
{
/* Get the referenced page from object index */
addr += sizeof(spiffs_page_object_ix) +
addr += sizeof(struct spiffs_page_objndx_s) +
SPIFFS_OBJ_IX_ENTRY(fs, data_spndx) *
sizeof(int16_t);
}
@ -230,11 +230,11 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
/* Find free entry */
ret = spiffs_obj_lu_find_free(fs, fs->free_blkndx,
fs->free_entry, &blkndx, &entry);
ret = spiffs_objlu_find_free(fs, fs->free_blkndx,
fs->free_entry, &blkndx, &entry);
if (ret < 0)
{
fwarn("WARNING: spiffs_obj_lu_find_free() failed: %d\n", ret);
fwarn("WARNING: spiffs_objlu_find_free() failed: %d\n", ret);
return ret;
}
@ -299,13 +299,13 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
if (objndx_spndx == 0)
{
((FAR int16_t *)((FAR uint8_t *)fs->lu_work +
sizeof(struct spiffs_pgobj_ixheader_s)))[data_spndx] =
sizeof(struct spiffs_pgobj_ndxheader_s)))[data_spndx] =
new_data_pgndx;
}
else
{
((FAR int16_t *)((FAR uint8_t *)fs->lu_work +
sizeof(spiffs_page_object_ix)))[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] =
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] =
new_data_pgndx;
}
@ -360,14 +360,14 @@ static int spiffs_check_delobj_lazy(FAR struct spiffs_s *fs, int16_t objid)
uint8_t flags = 0xff;
int ret;
ret = spiffs_obj_lu_find_id_and_span(fs, objid, 0, 0, &objhdr_pgndx);
ret = spiffs_objlu_find_id_and_span(fs, objid, 0, 0, &objhdr_pgndx);
if (ret == -ENOENT)
{
return OK;
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -531,18 +531,18 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* with same objid and span index is found
*/
ret = spiffs_obj_lu_find_id_and_span(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx, 0);
ret = spiffs_objlu_find_id_and_span(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx, 0);
if (ret == -ENOENT)
{
/* No such index page found, check for a data page amongst page
* headers. lu cannot be trusted
*/
ret = spiffs_obj_lu_find_id_and_span_byphdr(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
0, 0, 0);
ret = spiffs_objlu_find_id_and_span_byphdr(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
0, 0, 0);
if (ret == OK)
{
int16_t new_pgndx;
@ -568,7 +568,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span_byphdr() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span_byphdr() failed: %d\n", ret);
return ret;
}
}
@ -675,10 +675,10 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* and span index
*/
ret = spiffs_obj_lu_find_id_and_span(fs,
lu_objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, 0,
&objndx_pgndx_lu);
ret = spiffs_objlu_find_id_and_span(fs,
lu_objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, 0,
&objndx_pgndx_lu);
if (ret == -ENOENT)
{
ret = OK;
@ -686,7 +686,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -694,10 +694,10 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* span index
*/
ret = spiffs_obj_lu_find_id_and_span(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, 0,
&objndx_pgndx_ph);
ret = spiffs_objlu_find_id_and_span(fs,
pghdr->objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, 0,
&objndx_pgndx_ph);
if (ret == -ENOENT)
{
ret = OK;
@ -705,7 +705,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -724,9 +724,9 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* span index
*/
ret = spiffs_obj_lu_find_id_and_span(fs,
lu_objid & ~SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &data_pgndx_lu);
ret = spiffs_objlu_find_id_and_span(fs,
lu_objid & ~SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &data_pgndx_lu);
if (ret == -ENOENT)
{
ret = OK;
@ -734,7 +734,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -742,9 +742,9 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
* and span index
*/
ret = spiffs_obj_lu_find_id_and_span(fs,
pghdr->objid & ~SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &data_pgndx_ph);
ret = spiffs_objlu_find_id_and_span(fs,
pghdr->objid & ~SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &data_pgndx_ph);
if (ret == -ENOENT)
{
ret = OK;
@ -752,7 +752,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -823,9 +823,9 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
/* see if other data page exists for given objid and span index */
ret = spiffs_obj_lu_find_id_and_span(fs,
lu_objid & ~SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx, &data_pgndx);
ret = spiffs_objlu_find_id_and_span(fs,
lu_objid & ~SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx, &data_pgndx);
if (ret == -ENOENT)
{
ret = OK;
@ -833,16 +833,16 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
/* See if other object index exists for given objid and span index */
ret = spiffs_obj_lu_find_id_and_span(fs,
lu_objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx,
&objndx_pgndx_d);
ret = spiffs_objlu_find_id_and_span(fs,
lu_objid | SPIFFS_OBJ_ID_IX_FLAG,
pghdr->spndx, cur_pgndx,
&objndx_pgndx_d);
if (ret == -ENOENT)
{
ret = OK;
@ -850,7 +850,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -1225,8 +1225,8 @@ static int spiffs_check_objidconsistency_callback(FAR struct spiffs_s *fs,
/* Not in temporary index, try finding it */
ret = spiffs_obj_lu_find_id_and_span(fs, objid | SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &objhdr_pgndx);
ret = spiffs_objlu_find_id_and_span(fs, objid | SPIFFS_OBJ_ID_IX_FLAG,
0, 0, &objhdr_pgndx);
retc = SPIFFS_VIS_COUNTINUE_RELOAD;
if (ret == OK)
@ -1244,7 +1244,7 @@ static int spiffs_check_objidconsistency_callback(FAR struct spiffs_s *fs,
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -1448,7 +1448,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
data_spndx_offset = 0;
object_page_index =
(FAR int16_t *)((FAR uint8_t *)fs->lu_work +
sizeof(struct spiffs_pgobj_ixheader_s));
sizeof(struct spiffs_pgobj_ndxheader_s));
}
else
{
@ -1459,7 +1459,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
SPIFFS_OBJ_IX_LEN(fs) * (pghdr.spndx - 1);
object_page_index =
(FAR int16_t *)((FAR uint8_t *) fs->lu_work +
sizeof(spiffs_page_object_ix));
sizeof(struct spiffs_page_objndx_s));
}
/* For all entries in index */
@ -1485,10 +1485,11 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Check for data page elsewhere */
ret = spiffs_obj_lu_find_id_and_span(fs,
objndx_phdr->objid & ~SPIFFS_OBJ_ID_IX_FLAG,
data_spndx_offset + i,
0, &data_pgndx);
ret = spiffs_objlu_find_id_and_span(fs,
objndx_phdr->objid &
~SPIFFS_OBJ_ID_IX_FLAG,
data_spndx_offset + i,
0, &data_pgndx);
if (ret == -ENOENT)
{
ret = OK;
@ -1496,7 +1497,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n",
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
ret);
return ret;
}
@ -1561,12 +1562,12 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
{
/* Valid reference. read referenced page header */
struct spiffs_page_header_s rp_hdr;
struct spiffs_page_header_s rphdr;
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, rpgndx),
sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&rp_hdr);
(FAR uint8_t *)&rphdr);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@ -1575,9 +1576,9 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
/* Cross reference page header check */
if (rp_hdr.objid != (pghdr.objid & ~SPIFFS_OBJ_ID_IX_FLAG) ||
rp_hdr.spndx != data_spndx_offset + i ||
(rp_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX |
if (rphdr.objid != (pghdr.objid & ~SPIFFS_OBJ_ID_IX_FLAG) ||
rphdr.spndx != data_spndx_offset + i ||
(rphdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX |
SPIFFS_PH_FLAG_USED)) !=
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_INDEX))
{
@ -1588,15 +1589,16 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
rpgndx,
pghdr.objid & ~SPIFFS_OBJ_ID_IX_FLAG,
data_spndx_offset + i,
rp_hdr.objid, rp_hdr.spndx,
rp_hdr.flags);
rphdr.objid, rphdr.spndx,
rphdr.flags);
/* Try finding correct page */
ret = spiffs_obj_lu_find_id_and_span(fs,
pghdr.objid & ~SPIFFS_OBJ_ID_IX_FLAG,
data_spndx_offset + i, rpgndx,
&data_pgndx);
ret = spiffs_objlu_find_id_and_span(fs,
pghdr.objid &
~SPIFFS_OBJ_ID_IX_FLAG,
data_spndx_offset + i, rpgndx,
&data_pgndx);
if (ret == -ENOENT)
{
ret = OK;
@ -1604,7 +1606,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
}
else if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_find_id_and_span() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n", ret);
return ret;
}
@ -1783,7 +1785,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
}
else
{
struct spiffs_page_header_s rp_hdr;
struct spiffs_page_header_s rphdr;
/* Pointing to something else, check what */
@ -1792,7 +1794,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
0,
SPIFFS_PAGE_TO_PADDR(fs, rpgndx),
sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&rp_hdr);
(FAR uint8_t *)&rphdr);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@ -1800,8 +1802,8 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
}
if (((pghdr.objid & ~SPIFFS_OBJ_ID_IX_FLAG) ==
rp_hdr.objid) &&
((rp_hdr.flags & (SPIFFS_PH_FLAG_INDEX |
rphdr.objid) &&
((rphdr.flags & (SPIFFS_PH_FLAG_INDEX |
SPIFFS_PH_FLAG_DELET |
SPIFFS_PH_FLAG_USED |
SPIFFS_PH_FLAG_FINAL)) ==
@ -1828,13 +1830,13 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
("PA: corresponding ref is weird: "
"%04x %s%s%s%s, rewrite this "
"%04x\n", rpgndx,
(rp_hdr.flags & SPIFFS_PH_FLAG_INDEX) ? "" :
(rphdr.flags & SPIFFS_PH_FLAG_INDEX) ? "" :
"INDEX ",
(rp_hdr.flags & SPIFFS_PH_FLAG_DELET) ? "" :
(rphdr.flags & SPIFFS_PH_FLAG_DELET) ? "" :
"DELETED ",
(rp_hdr.flags & SPIFFS_PH_FLAG_USED) ?
(rphdr.flags & SPIFFS_PH_FLAG_USED) ?
"NOTUSED " : "",
(rp_hdr.flags & SPIFFS_PH_FLAG_FINAL) ?
(rphdr.flags & SPIFFS_PH_FLAG_FINAL) ?
"NOTFINAL " : "", cur_pgndx);
rewrite_ndx_to_this = true;

File diff suppressed because it is too large Load Diff

View File

@ -160,6 +160,8 @@
* obj.objid:0123 span.ndx:0005 flags:DATA
*/
#define SPIFFS_ERR_INTERNAL (-256)
/* visitor result, continue searching */
#define SPIFFS_VIS_COUNTINUE (SPIFFS_ERR_INTERNAL - 20)
@ -286,12 +288,12 @@
/* entries in an object header page index */
#define SPIFFS_OBJ_HDR_IX_LEN(fs) \
((SPIFFS_CFG_LOG_PAGE_SZ(fs) - sizeof(struct spiffs_pgobj_ixheader_s))/sizeof(int16_t))
((SPIFFS_CFG_LOG_PAGE_SZ(fs) - sizeof(struct spiffs_pgobj_ndxheader_s))/sizeof(int16_t))
/* entries in an object page index */
#define SPIFFS_OBJ_IX_LEN(fs) \
((SPIFFS_CFG_LOG_PAGE_SZ(fs) - sizeof(spiffs_page_object_ix))/sizeof(int16_t))
((SPIFFS_CFG_LOG_PAGE_SZ(fs) - sizeof(struct spiffs_page_objndx_s))/sizeof(int16_t))
/* object index entry for given data span index */
@ -343,31 +345,7 @@
#define SPIFFS_PH_FLAG_IXDELE (1<<6)
#define SPIFFS_CHECK_RES(res) \
do { \
if ((res) < OK) return (res); \
} while (0);
#define SPIFFS_VALIDATE_OBJIX(_ph, _objid, _spndx) \
if (((_ph).flags & SPIFFS_PH_FLAG_USED) != 0) return SPIFFS_ERR_IS_FREE; \
if (((_ph).flags & SPIFFS_PH_FLAG_DELET) == 0) return SPIFFS_ERR_DELETED; \
if (((_ph).flags & SPIFFS_PH_FLAG_FINAL) != 0) return SPIFFS_ERR_NOT_FINALIZED; \
if (((_ph).flags & SPIFFS_PH_FLAG_INDEX) != 0) return SPIFFS_ERR_NOT_INDEX; \
if (((_objid) & SPIFFS_OBJ_ID_IX_FLAG) == 0) return SPIFFS_ERR_NOT_INDEX; \
if ((_ph).spndx != (_spndx)) return SPIFFS_ERR_INDEX_SPAN_MISMATCH;
/* if ((_spndx) == 0 && ((_ph).flags & SPIFFS_PH_FLAG_IXDELE) == 0) return
* SPIFFS_ERR_DELETED;
*/
#define SPIFFS_VALIDATE_DATA(_ph, _objid, _spndx) \
if (((_ph).flags & SPIFFS_PH_FLAG_USED) != 0) return SPIFFS_ERR_IS_FREE; \
if (((_ph).flags & SPIFFS_PH_FLAG_DELET) == 0) return SPIFFS_ERR_DELETED; \
if (((_ph).flags & SPIFFS_PH_FLAG_FINAL) != 0) return SPIFFS_ERR_NOT_FINALIZED; \
if (((_ph).flags & SPIFFS_PH_FLAG_INDEX) == 0) return SPIFFS_ERR_IS_INDEX; \
if ((_objid) & SPIFFS_OBJ_ID_IX_FLAG) return SPIFFS_ERR_IS_INDEX; \
if ((_ph).spndx != (_spndx)) return SPIFFS_ERR_DATA_SPAN_MISMATCH;
/* check objid, only visit matching objec ids */
/* Check objid, only visit matching objec ids */
#define SPIFFS_VIS_CHECK_ID (1<<0)
@ -394,66 +372,68 @@
/* page header, part of each page except object lookup pages
* NB: this is always aligned when the data page is an object index,
* as in this case struct spiffs_page_object_ix is used
* as in this case struct spiffs_page_objndx_s is used
*/
begin_packed_struct struct spiffs_page_header_s
{
int16_t objid; /* object objid */
int16_t spndx; /* object span index */
uint8_t flags; /* flags */
int16_t objid; /* object objid */
int16_t spndx; /* object span index */
uint8_t flags; /* flags */
} end_packed_struct;
/* object index header page header */
begin_packed_struct struct spiffs_pgobj_ixheader_s
begin_packed_struct struct spiffs_pgobj_ndxheader_s
{
struct spiffs_page_header_s p_hdr; /* common page header */
uint32_t size; /* size of object */
uint8_t type; /* type of object */
uint8_t name[CONFIG_SPIFFS_NAME_MAX]; /* name of object */
struct spiffs_page_header_s phdr; /* common page header */
uint32_t size; /* size of object */
uint8_t type; /* type of object */
uint8_t name[CONFIG_SPIFFS_NAME_MAX]; /* name of object */
} end_packed_struct;
/* object index page header */
typedef begin_packed_struct struct
begin_packed_struct struct spiffs_page_objndx_s
{
struct spiffs_page_header_s p_hdr;
struct spiffs_page_header_s phdr;
uint8_t _align[4 - ((sizeof(struct spiffs_page_header_s) & 3) ==
0 ? 4 : (sizeof(struct spiffs_page_header_s) & 3))];
} begin_packed_struct spiffs_page_object_ix;
} begin_packed_struct;
/* callback func for object lookup visitor */
typedef int (*spiffs_visitor_f)(FAR struct spiffs_s *fs, int16_t objid,
int16_t blkndx, int ix_entry,
FAR const void *user_const,
FAR void *user_var);
typedef int (*spiffs_callback_t)(FAR struct spiffs_s *fs, int16_t objid,
int16_t blkndx, int entry,
FAR const void *user_const,
FAR void *user_var);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int spiffs_validate_objix(FAR struct spiffs_page_header_s *ph,
int16_t objid, int16_t spndx);
int spiffs_phys_cpy(FAR struct spiffs_s *fs,
int16_t objid, uint32_t dst, uint32_t src, uint32_t len);
int16_t objid, uint32_t dest, uint32_t src, uint32_t len);
int spiffs_foreach_objlu(FAR struct spiffs_s *fs, int16_t starting_block,
int starting_lu_entry, uint8_t flags, int16_t objid,
spiffs_visitor_f v, FAR const void *user_const,
FAR void *user_var, FAR int16_t *block_ix, int *lu_entry);
spiffs_callback_t v, FAR const void *user_const,
FAR void *user_var, FAR int16_t *blkndx, int *lu_entry);
int spiffs_erase_block(FAR struct spiffs_s *fs, int16_t blkndx);
int spiffs_obj_lu_scan(FAR struct spiffs_s *fs);
int spiffs_obj_lu_find_free_obj_id(FAR struct spiffs_s *fs,
int spiffs_objlu_scan(FAR struct spiffs_s *fs);
int spiffs_objlu_find_free_obj_id(FAR struct spiffs_s *fs,
int16_t *objid, FAR const uint8_t *conflicting_name);
int spiffs_obj_lu_find_free(FAR struct spiffs_s *fs,
int spiffs_objlu_find_free(FAR struct spiffs_s *fs,
int16_t starting_block, int starting_lu_entry,
FAR int16_t *block_ix, FAR int *lu_entry);
int spiffs_obj_lu_find_id(FAR struct spiffs_s *fs,
FAR int16_t *blkndx, FAR int *lu_entry);
int spiffs_objlu_find_id(FAR struct spiffs_s *fs,
int16_t starting_block, int starting_lu_entry, int16_t objid,
FAR int16_t *block_ix, FAR int *lu_entry);
int spiffs_obj_lu_find_id_and_span(FAR struct spiffs_s *fs,
FAR int16_t *blkndx, FAR int *lu_entry);
int spiffs_objlu_find_id_and_span(FAR struct spiffs_s *fs,
int16_t objid, int16_t spndx, int16_t exclusion_pgndx,
FAR int16_t *pgndx);
int spiffs_obj_lu_find_id_and_span_byphdr(FAR struct spiffs_s *fs,
int spiffs_objlu_find_id_and_span_byphdr(FAR struct spiffs_s *fs,
int16_t objid, int16_t spndx, int16_t exclusion_pgndx,
FAR int16_t *pgndx);
int spiffs_page_allocate_data(FAR struct spiffs_s *fs,
@ -472,8 +452,8 @@ int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
FAR struct spiffs_file_s *fobj, int16_t objid, int16_t objhdr_pgndx,
FAR uint8_t *new_objhdr_data, const uint8_t name[],
uint32_t size, FAR int16_t *new_pgndx);
void spiffs_cb_object_event(FAR struct spiffs_s *fs,
FAR spiffs_page_object_ix * objndx, int ev, int16_t objid,
void spiffs_object_event(FAR struct spiffs_s *fs,
FAR struct spiffs_page_objndx_s * objndx, int ev, int16_t objid,
int16_t spndx, int16_t new_pgndx, uint32_t new_size);
int spiffs_object_open_bypage(FAR struct spiffs_s *fs,
int16_t pgndx, FAR struct spiffs_file_s *f, uint16_t flags,
@ -483,7 +463,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
size_t len);
ssize_t spiffs_object_read(FAR struct spiffs_s *fs, FAR
FAR struct spiffs_file_s *fobj, off_t offset, size_t len,
FAR uint8_t *dst);
FAR uint8_t *dest);
int spiffs_object_truncate(FAR struct spiffs_s *fs,
FAR struct spiffs_file_s *fobj, off_t new_size, bool remove_full);
int spiffs_object_modify(FAR struct spiffs_s *fs,

View File

@ -158,13 +158,13 @@ static int spiffs_gc_erase_block(FAR struct spiffs_s *fs, int16_t blkndx)
static int spiffs_gc_epage_stats(FAR struct spiffs_s *fs, int16_t blkndx)
{
FAR int16_t *obj_lu_buf = (int16_t *) fs->lu_work;
uint32_t dele = 0;
uint32_t allo = 0;
int entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(int16_t));
int cur_entry = 0;
int obj_lookup_page = 0;
int ret = OK;
FAR int16_t *objlu_buf = (int16_t *) fs->lu_work;
uint32_t dele = 0;
uint32_t allo = 0;
int entries_per_page = (SPIFFS_CFG_LOG_PAGE_SZ(fs) / sizeof(int16_t));
int cur_entry = 0;
int obj_lookup_page = 0;
int ret = OK;
/* Check each object lookup page */
@ -183,7 +183,7 @@ static int spiffs_gc_epage_stats(FAR struct spiffs_s *fs, int16_t blkndx)
cur_entry <
(int)(SPIFFS_PAGES_PER_BLOCK(fs) - SPIFFS_OBJ_LOOKUP_PAGES(fs)))
{
int16_t id = obj_lu_buf[cur_entry - entry_offset];
int16_t id = objlu_buf[cur_entry - entry_offset];
if (id == SPIFFS_OBJ_ID_FREE)
{
@ -233,15 +233,15 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs,
FAR int *candidate_count, bool fs_crammed)
{
FAR int32_t *cand_scores;
FAR int16_t *obj_lu_buf = (FAR int16_t *)fs->lu_work;
FAR int16_t *objlu_buf = (FAR int16_t *)fs->lu_work;
FAR int16_t *cand_blocks;
uint32_t blocks = fs->geo.neraseblocks;
int16_t cur_block = 0;
uint32_t cur_block_addr = 0;
uint32_t blocks = fs->geo.neraseblocks;
int16_t cur_block = 0;
uint32_t cur_block_addr = 0;
int entries_per_page;
int max_candidates;
int cur_entry = 0;
int ret = OK;
int cur_entry = 0;
int ret = OK;
/* Using fs->work area as sorted candidate memory,
* (int16_t)cand_blkndx/(int32_t)score
@ -297,7 +297,7 @@ static int spiffs_gc_find_candidate(FAR struct spiffs_s *fs,
(int)(SPIFFS_PAGES_PER_BLOCK(fs) -
SPIFFS_OBJ_LOOKUP_PAGES(fs)))
{
int16_t id = obj_lu_buf[cur_entry - entry_offset];
int16_t id = objlu_buf[cur_entry - entry_offset];
if (id == SPIFFS_OBJ_ID_FREE)
{
@ -449,19 +449,22 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
/* This is the global localizer being pushed and popped */
int cur_entry = 0;
FAR int16_t *obj_lu_buf = (FAR int16_t *)fs->lu_work;
struct spiffs_gc_s gc; /* Our stack frame/state */
int16_t cur_pgndx = 0;
FAR struct spiffs_pgobj_ixheader_s *objhdr =
(FAR struct spiffs_pgobj_ixheader_s *) fs->work;
spiffs_page_object_ix *objndx = (spiffs_page_object_ix *)fs->work;
FAR int16_t *objlu_buf;
FAR struct spiffs_pgobj_ndxheader_s *objhdr;
FAR struct spiffs_page_objndx_s *objndx;
int16_t cur_pgndx = 0;
int cur_entry = 0;
spiffs_gcinfo("Cleaning block %04x\n", blkndx);
memset(&gc, 0, sizeof(struct spiffs_gc_s));
gc.state = FIND_OBJ_DATA;
objlu_buf = (FAR int16_t *)fs->lu_work;
objhdr = (FAR struct spiffs_pgobj_ndxheader_s *) fs->work;
objndx = (struct spiffs_page_objndx_s *)fs->work;
if (fs->free_blkndx == blkndx)
{
/* Move free cursor to next block, cannot use free pages from the block
@ -507,7 +510,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
(int)(SPIFFS_PAGES_PER_BLOCK(fs) -
SPIFFS_OBJ_LOOKUP_PAGES(fs)))
{
int16_t id = obj_lu_buf[cur_entry - entry_offset];
int16_t id = objlu_buf[cur_entry - entry_offset];
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, cur_entry);
@ -543,13 +546,13 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
if (id == gc.cur_objid)
{
struct spiffs_page_header_s p_hdr;
struct spiffs_page_header_s phdr;
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, cur_pgndx),
sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&p_hdr);
(FAR uint8_t *)&phdr);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@ -557,9 +560,9 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
}
spiffs_gcinfo("Found data page %04x:%04x @%04x\n",
gc.cur_objid, p_hdr.spndx, cur_pgndx);
gc.cur_objid, phdr.spndx, cur_pgndx);
if (SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, p_hdr.spndx) !=
if (SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, phdr.spndx) !=
gc.cur_objndx_spndx)
{
spiffs_gcinfo("No objndx spndx match, take in another run\n");
@ -567,15 +570,15 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
else
{
int16_t new_data_pgndx;
if (p_hdr.flags & SPIFFS_PH_FLAG_DELET)
if (phdr.flags & SPIFFS_PH_FLAG_DELET)
{
/* Move page */
ret = spiffs_page_move(fs, 0, 0, id, &p_hdr,
ret = spiffs_page_move(fs, 0, 0, id, &phdr,
cur_pgndx, &new_data_pgndx);
spiffs_gcinfo("Move objndx=%04x:%04x page=%04x to %04x\n",
gc.cur_objid, p_hdr.spndx,
gc.cur_objid, phdr.spndx,
cur_pgndx, new_data_pgndx);
if (ret < 0)
@ -607,7 +610,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
*/
spiffs_gcinfo("Wipe objndx=%04x:%04x page=%04x\n",
id, p_hdr.spndx, cur_pgndx);
id, phdr.spndx, cur_pgndx);
ret = spiffs_page_delete(fs, cur_pgndx);
if (ret < 0)
@ -628,24 +631,25 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
/* Update object index header page */
((FAR int16_t *)((FAR uint8_t *)objhdr +
sizeof(struct spiffs_pgobj_ixheader_s)))[p_hdr.spndx] =
sizeof(struct spiffs_pgobj_ndxheader_s)))[phdr.spndx] =
new_data_pgndx;
spiffs_gcinfo("Wrote page=%04x to objhdr entry=%04x in mem\n",
new_data_pgndx,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, p_hdr.spndx));
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, phdr.spndx));
}
else
{
/* Update object index page */
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(spiffs_page_object_ix)))[SPIFFS_OBJ_IX_ENTRY(fs, p_hdr.spndx)] =
new_data_pgndx;
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, phdr.spndx)] =
new_data_pgndx;
spiffs_gcinfo("Wrote page=%04x to objndx entry=%04x in mem\n",
new_data_pgndx,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, p_hdr.spndx));
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, phdr.spndx));
}
}
}
@ -660,7 +664,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
{
/* Found an index object id */
struct spiffs_page_header_s p_hdr;
struct spiffs_page_header_s phdr;
int16_t new_pgndx;
/* Load header */
@ -670,22 +674,22 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
0,
SPIFFS_PAGE_TO_PADDR(fs, cur_pgndx),
sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&p_hdr);
(FAR uint8_t *)&phdr);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
return ret;
}
if (p_hdr.flags & SPIFFS_PH_FLAG_DELET)
if (phdr.flags & SPIFFS_PH_FLAG_DELET)
{
/* Move page */
ret = spiffs_page_move(fs, 0, 0, id, &p_hdr,
ret = spiffs_page_move(fs, 0, 0, id, &phdr,
cur_pgndx, &new_pgndx);
spiffs_gcinfo("Move objndx=%04x:%04x page=%04x to %04x\n",
id, p_hdr.spndx, cur_pgndx,
id, phdr.spndx, cur_pgndx,
new_pgndx);
if (ret < 0)
@ -694,19 +698,19 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
return ret;
}
spiffs_cb_object_event(fs,
(spiffs_page_object_ix *)&p_hdr,
SPIFFS_EV_IX_MOV, id,
p_hdr.spndx, new_pgndx, 0);
spiffs_object_event(fs,
(FAR struct spiffs_page_objndx_s *)&phdr,
SPIFFS_EV_IX_MOV, id,
phdr.spndx, new_pgndx, 0);
/* Move wipes obj_lu, reload it */
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_CFG_LOG_BLOCK_SZ(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_CFG_LOG_PAGE_SZ(fs), fs->lu_work);
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
0,
blkndx * SPIFFS_CFG_LOG_BLOCK_SZ(fs) +
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
SPIFFS_CFG_LOG_PAGE_SZ(fs), fs->lu_work);
if (ret < 0)
{
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
@ -721,19 +725,18 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
*/
spiffs_gcinfo("Wipe objndx=%04x:%04x page=%04x\n",
id, p_hdr.spndx, cur_pgndx);
id, phdr.spndx, cur_pgndx);
ret = spiffs_page_delete(fs, cur_pgndx);
if (ret < 0)
{
ferr("ERROR: spiffs_cb_object_event() failed: %d\n", ret);
ferr("ERROR: spiffs_object_event() failed: %d\n", ret);
return ret;
}
spiffs_cb_object_event(fs, NULL,
SPIFFS_EV_IX_DEL, id,
p_hdr.spndx,
cur_pgndx, 0);
spiffs_object_event(fs, NULL,
SPIFFS_EV_IX_DEL, id,
phdr.spndx, cur_pgndx, 0);
}
}
break;
@ -764,7 +767,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
case FIND_OBJ_DATA:
if (gc.objid_found)
{
struct spiffs_page_header_s p_hdr;
struct spiffs_page_header_s phdr;
int16_t objndx_pgndx;
/* Handle found data page. Find out corresponding objndx page
@ -778,19 +781,19 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, cur_pgndx),
sizeof(struct spiffs_page_header_s),
(FAR uint8_t *)&p_hdr);
(FAR uint8_t *)&phdr);
if (ret < 0)
{
ferr("ERROR: spiffs_cb_object_event() failed: %d\n", ret);
ferr("ERROR: spiffs_object_event() failed: %d\n", ret);
return ret;
}
gc.cur_objndx_spndx =
SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, p_hdr.spndx);
SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, phdr.spndx);
spiffs_gcinfo("Find objndx spndx=%04x\n", gc.cur_objndx_spndx);
ret = spiffs_obj_lu_find_id_and_span(fs,
ret = spiffs_objlu_find_id_and_span(fs,
gc.cur_objid | SPIFFS_OBJ_ID_IX_FLAG,
gc.cur_objndx_spndx, 0,
&objndx_pgndx);
@ -842,9 +845,15 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
* index, a check must run or lot of data may be lost
*/
SPIFFS_VALIDATE_OBJIX(objndx->p_hdr,
gc.cur_objid | SPIFFS_OBJ_ID_IX_FLAG,
gc.cur_objndx_spndx);
ret = spiffs_validate_objix(&objndx->phdr,
gc.cur_objid | SPIFFS_OBJ_ID_IX_FLAG,
gc.cur_objndx_spndx);
if (ret < 0)
{
ferr("ERROR: spiffs_validate_objix() failed: %d\n", ret);
return ret;
}
gc.cur_objndx_pgndx = objndx_pgndx;
}
else
@ -898,7 +907,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
&new_objndx_pgndx);
spiffs_gcinfo("Store modified objndx page=%04x:%04x\n",
new_objndx_pgndx, objndx->p_hdr.spndx);
new_objndx_pgndx, objndx->phdr.spndx);
if (ret < 0)
{
@ -906,11 +915,11 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
return ret;
}
spiffs_cb_object_event(fs,
(FAR spiffs_page_object_ix *)fs->work,
SPIFFS_EV_IX_UPD, gc.cur_objid,
objndx->p_hdr.spndx,
new_objndx_pgndx, 0);
spiffs_object_event(fs,
(FAR struct spiffs_page_objndx_s *)fs->work,
SPIFFS_EV_IX_UPD, gc.cur_objid,
objndx->phdr.spndx,
new_objndx_pgndx, 0);
}
}
break;
@ -957,7 +966,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
int spiffs_gc_quick(FAR struct spiffs_s *fs, uint16_t max_free_pages)
{
FAR int16_t *obj_lu_buf = (int16_t *) fs->lu_work;
FAR int16_t *objlu_buf = (int16_t *) fs->lu_work;
uint32_t cur_block_addr = 0;
uint32_t blocks = fs->geo.neraseblocks;
int16_t cur_block = 0;
@ -998,7 +1007,7 @@ int spiffs_gc_quick(FAR struct spiffs_s *fs, uint16_t max_free_pages)
(int)(SPIFFS_PAGES_PER_BLOCK(fs) -
SPIFFS_OBJ_LOOKUP_PAGES(fs)))
{
int16_t id = obj_lu_buf[cur_entry - entry_offset];
int16_t id = objlu_buf[cur_entry - entry_offset];
if (id == SPIFFS_OBJ_ID_DELETED)
{
@ -1179,7 +1188,6 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
ferr("ERROR: spiffs_gc_epage_stats() failed: %d\n", ret);
return ret;
}
SPIFFS_CHECK_RES(ret);
ret = spiffs_gc_erase_block(fs, cand);
if (ret < 0)

View File

@ -271,10 +271,10 @@ static int spiffs_consistency_check(FAR struct spiffs_s *fs)
}
}
status = spiffs_obj_lu_scan(fs);
status = spiffs_objlu_scan(fs);
if (status < 0)
{
fwarn("WARNING spiffs_obj_lu_scan failed: %d\n", status);
fwarn("WARNING spiffs_objlu_scan failed: %d\n", status);
if (ret == OK)
{
ret = status;
@ -289,11 +289,11 @@ static int spiffs_consistency_check(FAR struct spiffs_s *fs)
****************************************************************************/
static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
int16_t objid, int16_t blkndx, int ix_entry,
int16_t objid, int16_t blkndx, int entry,
FAR const void *user_const,
FAR void *user_var)
{
struct spiffs_pgobj_ixheader_s objhdr;
struct spiffs_pgobj_ndxheader_s objhdr;
int16_t pgndx;
int ret;
@ -303,10 +303,10 @@ static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
return SPIFFS_VIS_COUNTINUE;
}
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, ix_entry);
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, pgndx),
sizeof(struct spiffs_pgobj_ixheader_s),
sizeof(struct spiffs_pgobj_ndxheader_s),
(FAR uint8_t *) & objhdr);
if (ret < 0)
{
@ -315,8 +315,8 @@ static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
}
if ((objid & SPIFFS_OBJ_ID_IX_FLAG) &&
objhdr.p_hdr.spndx == 0 &&
(objhdr.p_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL |
objhdr.phdr.spndx == 0 &&
(objhdr.phdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL |
SPIFFS_PH_FLAG_IXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE))
{
@ -411,7 +411,7 @@ static int spiffs_open(FAR struct file *filep, FAR const char *relpath,
/* The file does not exist. We need to create the it. */
ret = spiffs_obj_lu_find_free_obj_id(fs, &objid, 0);
ret = spiffs_objlu_find_free_obj_id(fs, &objid, 0);
if (ret < 0)
{
goto errout_with_fileobject;
@ -881,8 +881,8 @@ static off_t spiffs_seek(FAR struct file *filep, off_t offset, int whence)
{
int16_t pgndx;
ret = spiffs_obj_lu_find_id_and_span(fs, fobj->objid | SPIFFS_OBJ_ID_IX_FLAG,
objndx_spndx, 0, &pgndx);
ret = spiffs_objlu_find_id_and_span(fs, fobj->objid | SPIFFS_OBJ_ID_IX_FLAG,
objndx_spndx, 0, &pgndx);
if (ret < 0)
{
goto errout_with_lock;
@ -1158,7 +1158,7 @@ static int spiffs_truncate(FAR struct file *filep, off_t length)
ret = spiffs_object_truncate(fs, fobj, length, false);
if (ret < 0)
{
ferr("ERROR: spiffs_object_truncate failed: %d/n", ret);
ferr("ERROR: spiffs_object_truncate failed: %d/n", ret);
}
/* Check if we need to reset the file pointer. Probably could use
@ -1301,7 +1301,7 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
fs = (FAR struct spiffs_s *)kmm_zalloc(sizeof(struct spiffs_s));
if (fs == NULL)
{
ferr("ERROR: Failed to allocate volume structure\n");
ferr("ERROR: Failed to allocate volume structure\n");
return -ENOMEM;
}
@ -1312,7 +1312,7 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
ret = MTD_IOCTL(mtd, MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&fs->geo));
if (ret < 0)
{
ferr("ERROR: MTD_IOCTL(MTDIOC_GEOMETRY) failed: %d\n", ret);
ferr("ERROR: MTD_IOCTL(MTDIOC_GEOMETRY) failed: %d\n", ret);
goto errout_with_volume;
}
@ -1338,7 +1338,7 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
if (fs->cache == NULL)
{
ferr("ERROR: Failed to allocate volume structure\n");
ferr("ERROR: Failed to allocate volume structure\n");
ret = -ENOMEM;
goto errout_with_volume;
}
@ -1356,7 +1356,7 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
if (work == NULL)
{
ferr("ERROR: Failed to allocate work buffer\n");
ferr("ERROR: Failed to allocate work buffer\n");
ret = -ENOMEM;
goto errout_with_cache;
}
@ -1367,10 +1367,10 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
/* Check the file system */
ret = spiffs_obj_lu_scan(fs);
ret = spiffs_objlu_scan(fs);
if (ret < 0)
{
ferr("ERROR: spiffs_obj_lu_scan() failed: %d\n", ret);
ferr("ERROR: spiffs_objlu_scan() failed: %d\n", ret);
goto errout_with_work;
}

View File

@ -79,7 +79,7 @@
int spiffs_stat_pgndx(FAR struct spiffs_s *fs, int16_t pgndx, int16_t objid,
FAR struct stat *buf)
{
struct spiffs_pgobj_ixheader_s objhdr;
struct spiffs_pgobj_ndxheader_s objhdr;
uint32_t obj_id_addr;
int16_t ndx;
mode_t mode;
@ -87,7 +87,7 @@ int spiffs_stat_pgndx(FAR struct spiffs_s *fs, int16_t pgndx, int16_t objid,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, objid,
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
sizeof(struct spiffs_pgobj_ixheader_s),
sizeof(struct spiffs_pgobj_ndxheader_s),
(FAR uint8_t *) & objhdr);
if (ret < 0)
{