fs/spiffs: Costmetic name changes more more consistency.

This commit is contained in:
Gregory Nutt 2018-09-26 15:50:55 -06:00
parent d59893a456
commit 31e6fb561b
7 changed files with 98 additions and 98 deletions

View File

@ -56,7 +56,7 @@ extern "C"
#define SPIFFS_CACHE_FLAG_DIRTY (1 << 0)
#define SPIFFS_CACHE_FLAG_WRTHRU (1 << 1)
#define SPIFFS_CACHE_FLAG_OBJLU (1 << 2)
#define SPIFFS_CACHE_FLAG_OBJIX (1 << 3)
#define SPIFFS_CACHE_FLAG_OBJNDX (1 << 3)
#define SPIFFS_CACHE_FLAG_DATA (1 << 4)
#define SPIFFS_CACHE_FLAG_TYPE_WR (1 << 7)

View File

@ -105,7 +105,7 @@ static int spiffs_check_get_data_pgndx(FAR struct spiffs_s *fs,
/* Calculate object index span index for given data page span index */
objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
/* Find the object index for the object ID and span index */
@ -132,7 +132,7 @@ static int spiffs_check_get_data_pgndx(FAR struct spiffs_s *fs,
/* Get the referenced page from object index */
addr += sizeof(struct spiffs_page_objndx_s) +
SPIFFS_OBJ_IX_ENTRY(fs, data_spndx) *
SPIFFS_OBJNDX_ENTRY(fs, data_spndx) *
sizeof(int16_t);
}
@ -238,11 +238,11 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
return ret;
}
free_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
free_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
/* Calculate object index span index for given data page span index */
int16_t objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
int16_t objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
if (objndx_spndx == 0)
{
/* Calculate index in index header */
@ -253,7 +253,7 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
{
/* Calculate entry in index */
entry = SPIFFS_OBJ_IX_ENTRY(fs, data_spndx);
entry = SPIFFS_OBJNDX_ENTRY(fs, data_spndx);
}
/* Load index */
@ -285,10 +285,10 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
return -EFAULT;
}
if ((objndx_phdr->flags & (SPIFFS_PH_FLAG_USED | SPIFFS_PH_FLAG_IXDELE |
if ((objndx_phdr->flags & (SPIFFS_PH_FLAG_USED | SPIFFS_PH_FLAG_NDXDELE |
SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_FINAL |
SPIFFS_PH_FLAG_DELET)) !=
(SPIFFS_PH_FLAG_IXDELE | SPIFFS_PH_FLAG_DELET))
(SPIFFS_PH_FLAG_NDXDELE | SPIFFS_PH_FLAG_DELET))
{
spiffs_page_delete(fs, free_pgndx);
return -EFAULT;
@ -305,7 +305,7 @@ static int spiffs_check_rewrite_index(FAR struct spiffs_s *fs,
else
{
((FAR int16_t *)((FAR uint8_t *)fs->lu_work +
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] =
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] =
new_data_pgndx;
}
@ -387,7 +387,7 @@ static int spiffs_check_delobj_lazy(FAR struct spiffs_s *fs, int16_t objid)
/* Clear the deleted flag in FLASH to mark the page deleted */
flags &= ~SPIFFS_PH_FLAG_IXDELE;
flags &= ~SPIFFS_PH_FLAG_NDXDELE;
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_UPDT, 0,
SPIFFS_PAGE_TO_PADDR(fs, objhdr_pgndx) +
offsetof(struct spiffs_page_header_s, flags),
@ -587,7 +587,7 @@ static int spiffs_check_luentry_validate(FAR struct spiffs_s *fs,
delete_page = true;
if ((pghdr->flags & SPIFFS_PH_FLAG_DELET) == 0 ||
(pghdr->flags & SPIFFS_PH_FLAG_FINAL) ||
(pghdr->flags & (SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_IXDELE)) == 0)
(pghdr->flags & (SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_NDXDELE)) == 0)
{
/* Page deleted or not finalized, just remove it */
}
@ -1053,7 +1053,7 @@ static int spiffs_lucheck_callback(FAR struct spiffs_s *fs, int16_t objid,
int ret = OK;
bool reload_lu = false;
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, cur_block, cur_entry);
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, cur_block, cur_entry);
/* Load header */
@ -1151,7 +1151,7 @@ static int spiffs_check_objidconsistency_callback(FAR struct spiffs_s *fs,
struct spiffs_page_header_s pghdr;
int16_t cur_pgndx;
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, cur_block, cur_entry);
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, cur_block, cur_entry);
/* Load header */
@ -1166,7 +1166,7 @@ static int spiffs_check_objidconsistency_callback(FAR struct spiffs_s *fs,
if (pghdr.spndx == 0 &&
(pghdr.flags & (SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_FINAL |
SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) ==
SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET))
{
spiffs_checkinfo("pgndx=%04x, objid=%04x spndx=%04x "
@ -1184,8 +1184,8 @@ static int spiffs_check_objidconsistency_callback(FAR struct spiffs_s *fs,
}
if ((pghdr.flags & (SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_FINAL |
SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE))
SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE))
{
return retc;
}
@ -1409,7 +1409,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
}
if ((pghdr.flags & SPIFFS_PH_FLAG_DELET) &&
(pghdr.flags & SPIFFS_PH_FLAG_IXDELE) &&
(pghdr.flags & SPIFFS_PH_FLAG_NDXDELE) &&
(pghdr.flags & (SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_USED)) == 0)
{
FAR struct spiffs_page_header_s *objndx_phdr;
@ -1444,7 +1444,7 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
{
/* object header page index */
entries = SPIFFS_OBJ_HDR_IX_LEN(fs);
entries = SPIFFS_OBJHDR_NDXLEN(fs);
data_spndx_offset = 0;
object_page_index =
(FAR int16_t *)((FAR uint8_t *)fs->lu_work +
@ -1454,9 +1454,9 @@ int spiffs_check_pgconsistency(FAR struct spiffs_s *fs)
{
/* Object page index */
entries = SPIFFS_OBJ_IX_LEN(fs);
data_spndx_offset = SPIFFS_OBJ_HDR_IX_LEN(fs) +
SPIFFS_OBJ_IX_LEN(fs) * (pghdr.spndx - 1);
entries = SPIFFS_OBJNDX_LEN(fs);
data_spndx_offset = SPIFFS_OBJHDR_NDXLEN(fs) +
SPIFFS_OBJNDX_LEN(fs) * (pghdr.spndx - 1);
object_page_index =
(FAR int16_t *)((FAR uint8_t *) fs->lu_work +
sizeof(struct spiffs_page_objndx_s));

View File

@ -180,7 +180,7 @@ static int spiffs_page_index_check(FAR struct spiffs_s *fs,
}
#ifdef CONFIG_SPIFFS_PAGE_CHECK
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid, SPIFFS_PAGE_TO_PADDR(fs, pgndx),
sizeof(struct spiffs_page_header_s), (uint8_t *) & ph);
if (ret < 0)
@ -250,7 +250,7 @@ static int spiffs_objlu_find_id_and_span_callback(FAR struct spiffs_s *fs,
int16_t pgndx;
int ret;
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
ret = spiffs_cache_read(fs, 0, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
@ -265,7 +265,7 @@ static int spiffs_objlu_find_id_and_span_callback(FAR struct spiffs_s *fs,
(ph.flags & (SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_DELET |
SPIFFS_PH_FLAG_USED)) == SPIFFS_PH_FLAG_DELET &&
!((objid & SPIFFS_OBJID_NDXFLAG) != 0 &&
(ph.flags & SPIFFS_PH_FLAG_IXDELE) == 0 && ph.spndx == 0) &&
(ph.flags & SPIFFS_PH_FLAG_NDXDELE) == 0 && ph.spndx == 0) &&
(user_const == NULL || *((FAR const int16_t *)user_const) != pgndx))
{
return OK;
@ -298,7 +298,7 @@ static int spiffs_find_objhdr_pgndx_callback(FAR struct spiffs_s *fs, int16_t ob
return SPIFFS_VIS_COUNTINUE;
}
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
0, SPIFFS_PAGE_TO_PADDR(fs, pgndx),
@ -312,8 +312,8 @@ static int spiffs_find_objhdr_pgndx_callback(FAR struct spiffs_s *fs, int16_t ob
if (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))
SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE))
{
if (strcmp((FAR const char *)user_const, (FAR char *)objhdr.name) == 0)
{
@ -352,7 +352,7 @@ static int
if (conflicting_name != NULL && (objid & SPIFFS_OBJID_NDXFLAG) != 0)
{
struct spiffs_pgobj_ndxheader_s objhdr;
int16_t pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
int16_t pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
int ret;
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
@ -368,8 +368,8 @@ static int
if (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))
SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE))
{
if (strcmp((FAR const char *)user_const,
(FAR char *)objhdr.name) == 0)
@ -986,7 +986,7 @@ int spiffs_objlu_find_id_and_span(FAR struct spiffs_s *fs, int16_t objid,
if (pgndx != NULL)
{
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
}
fs->lu_blkndx = blkndx;
@ -1032,7 +1032,7 @@ int spiffs_objlu_find_id_and_span_byphdr(FAR struct spiffs_s *fs,
if (pgndx != NULL)
{
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
}
fs->lu_blkndx = blkndx;
@ -1132,7 +1132,7 @@ int spiffs_page_allocate_data(FAR struct spiffs_s *fs, int16_t objid,
if (pgndx != NULL)
{
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
}
return ret;
@ -1171,7 +1171,7 @@ int spiffs_page_move(FAR struct spiffs_s *fs,
return ret;
}
free_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
free_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
if (dst_pgndx != NULL)
{
@ -1348,7 +1348,7 @@ int spiffs_object_create(FAR struct spiffs_s *fs,
}
finfo("Found free page @ %04x blkndx=%04x entry=%04x\n",
(int16_t) SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry),
(int16_t) SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry),
blkndx, entry);
/* Occupy page in object lookup */
@ -1391,12 +1391,12 @@ int spiffs_object_create(FAR struct spiffs_s *fs,
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)&objndx_hdr,
SPIFFS_EV_NDXNEW, objid, 0,
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry),
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry),
SPIFFS_UNDEFINED_LEN);
if (objhdr_pgndx)
{
*objhdr_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
*objhdr_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
}
return ret < 0 ? ret : OK;
@ -1436,7 +1436,7 @@ int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
{
/* Read object index header page */
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, objhdr_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -1645,7 +1645,7 @@ int spiffs_object_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
int ret = OK;
physoff = SPIFFS_PAGE_TO_PADDR(fs, pgndx);
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid, physoff,
sizeof(struct spiffs_pgobj_ndxheader_s),
(FAR uint8_t *)&objndx_hdr);
@ -1741,7 +1741,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
/* Calculate object index page span index */
cur_objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
cur_objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
/* Handle storing and loading of object indices */
@ -1779,7 +1779,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
}
ret = spiffs_cache_write(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_UPDT,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs),
@ -1824,7 +1824,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
}
ret = spiffs_cache_write(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_UPDT,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs),
@ -1873,7 +1873,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx);
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -1898,7 +1898,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
/* On subsequent passes, create a new object index page */
len_objndx_spndx =
SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs,(fobj->size - 1) /
SPIFFS_OBJNDX_ENTRY_SPNDX(fs,(fobj->size - 1) /
SPIFFS_DATA_PAGE_SIZE(fs));
if (written > 0 || cur_objndx_spndx > len_objndx_spndx)
@ -1964,7 +1964,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
fobj->objid, pgndx, fobj->size);
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
SPIFFS_GEO_PAGE_SIZE(fs),
@ -2035,9 +2035,9 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
/* Get data page from object index page */
data_page =
((FAR int16_t *)((FAR uint8_t *) objndx +
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)];
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)];
}
ret = spiffs_page_data_check(fs, fobj, data_page, data_spndx);
@ -2084,11 +2084,11 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
((FAR int16_t *)((FAR uint8_t *) objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] = data_page;
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] = data_page;
finfo("objid=%04x wrote page=%04x to objndx entry %04x in mem\n",
fobj->objid, data_page,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, data_spndx));
(int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
}
/* Update internals */
@ -2123,7 +2123,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
return ret2;
}
ret2 = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_UPDT,
ret2 = spiffs_cache_write(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -2179,7 +2179,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
}
ret2 = spiffs_cache_write(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_UPDT,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -2276,7 +2276,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
/* Calculate object index page span index */
cur_objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
cur_objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
/* Handle storing and loading of object indices */
@ -2356,7 +2356,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
cur_objndx_pgndx, cur_objndx_spndx);
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -2403,7 +2403,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
finfo("Found object index at page=%04x\n", pgndx);
ret = spiffs_cache_read(fs,
SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -2449,7 +2449,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
orig_data_pgndx =
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)];
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)];
}
phdr.objid = fobj->objid & ~SPIFFS_OBJID_NDXFLAG;
@ -2579,11 +2579,11 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
/* Update object index page */
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] =
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] =
data_pgndx;
finfo("Wrote page %04x to objndx entry %04x in mem\n",
data_pgndx, (int16_t)SPIFFS_OBJ_IX_ENTRY(fs, data_spndx));
data_pgndx, (int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
}
/* Update internals */
@ -2690,7 +2690,7 @@ int spiffs_find_objhdr_pgndx(FAR struct spiffs_s *fs,
if (pgndx != NULL)
{
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
*pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
}
fs->lu_blkndx = blkndx;
@ -2771,9 +2771,9 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
if (remove_full && new_size == 0)
{
uint8_t flags = ~(SPIFFS_PH_FLAG_USED | SPIFFS_PH_FLAG_INDEX |
SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE);
SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_NDXDELE);
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_UPDT,
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, fobj->objhdr_pgndx) +
offsetof(struct spiffs_page_header_s, flags),
@ -2789,7 +2789,7 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
while (cur_size > new_size)
{
cur_objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
cur_objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
/* Put object index for current data span index in work buffer */
@ -2880,7 +2880,7 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
finfo("Load objndx page %04x:%04x for data spndx=%04x\n",
objndx_pgndx, cur_objndx_spndx, data_spndx);
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -2924,11 +2924,11 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
data_pgndx =
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)];
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)];
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] = SPIFFS_OBJID_FREE;
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] = SPIFFS_OBJID_FREE;
}
finfo("Got data pgndx %04x\n", data_pgndx);
@ -3062,7 +3062,7 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
finfo("Wrote page=%04x to objhdr entry %04x in mem\n",
new_data_pgndx,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, data_spndx));
(int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
}
else
{
@ -3070,11 +3070,11 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)] = new_data_pgndx;
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] = new_data_pgndx;
finfo("Wrote page %04x to objndx entry=%04x in mem\n",
new_data_pgndx,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, data_spndx));
(int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
}
cur_size = new_size;
@ -3242,7 +3242,7 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
{
uint32_t len_to_read;
cur_objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
cur_objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
if (prev_objndx_spndx != cur_objndx_spndx)
{
/* Load current object index (header) page */
@ -3278,7 +3278,7 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
finfo("Load objndx page %d:%d for data spndx=%d\n",
objndx_pgndx, cur_objndx_spndx, data_spndx);
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
fobj->objid,
SPIFFS_PAGE_TO_PADDR(fs, objndx_pgndx),
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
@ -3317,7 +3317,7 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
data_pgndx =
((FAR int16_t *)((FAR uint8_t *) objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, data_spndx)];
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)];
}
/* All remaining data */

View File

@ -212,7 +212,7 @@
/* Converts a object lookup entry to page index */
#define SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, block, entry) \
#define SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, block, entry) \
((block)*SPIFFS_GEO_PAGES_PER_BLOCK(fs) + (SPIFFS_OBJ_LOOKUP_PAGES(fs) + entry))
/* Converts a object lookup entry to physical address of corresponding page */
@ -265,32 +265,32 @@
/* Entries in an object header page index */
#define SPIFFS_OBJ_HDR_IX_LEN(fs) \
#define SPIFFS_OBJHDR_NDXLEN(fs) \
((SPIFFS_GEO_PAGE_SIZE(fs) - sizeof(struct spiffs_pgobj_ndxheader_s))/sizeof(int16_t))
/* Entries in an object page index */
#define SPIFFS_OBJ_IX_LEN(fs) \
#define SPIFFS_OBJNDX_LEN(fs) \
((SPIFFS_GEO_PAGE_SIZE(fs) - sizeof(struct spiffs_page_objndx_s))/sizeof(int16_t))
/* Object index entry for given data span index */
#define SPIFFS_OBJ_IX_ENTRY(fs, spndx) \
((spndx) < SPIFFS_OBJ_HDR_IX_LEN(fs) ? (spndx) : (((spndx)-SPIFFS_OBJ_HDR_IX_LEN(fs))%SPIFFS_OBJ_IX_LEN(fs)))
#define SPIFFS_OBJNDX_ENTRY(fs, spndx) \
((spndx) < SPIFFS_OBJHDR_NDXLEN(fs) ? (spndx) : (((spndx)-SPIFFS_OBJHDR_NDXLEN(fs))%SPIFFS_OBJNDX_LEN(fs)))
/* Object index span index number for given data span index or entry */
#define SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, spndx) \
((spndx) < SPIFFS_OBJ_HDR_IX_LEN(fs) ? 0 : (1+((spndx)-SPIFFS_OBJ_HDR_IX_LEN(fs))/SPIFFS_OBJ_IX_LEN(fs)))
#define SPIFFS_OBJNDX_ENTRY_SPNDX(fs, spndx) \
((spndx) < SPIFFS_OBJHDR_NDXLEN(fs) ? 0 : (1+((spndx)-SPIFFS_OBJHDR_NDXLEN(fs))/SPIFFS_OBJNDX_LEN(fs)))
/* Get data span index for object index span index */
#define SPIFFS_DATA_SPAN_IX_FOR_OBJ_IX_SPAN_IX(fs, spndx) \
((spndx) == 0 ? 0 : (SPIFFS_OBJ_HDR_IX_LEN(fs) + (((spndx)-1) * SPIFFS_OBJ_IX_LEN(fs))))
#define SPIFFS_DATA_SPNDX_FOR_OBJNDX_SPNDX(fs, spndx) \
((spndx) == 0 ? 0 : (SPIFFS_OBJHDR_NDXLEN(fs) + (((spndx)-1) * SPIFFS_OBJNDX_LEN(fs))))
#define SPIFFS_OP_T_OBJ_LU (0 << 0)
#define SPIFFS_OP_T_OBJ_LU2 (1 << 0)
#define SPIFFS_OP_T_OBJ_IX (2 << 0)
#define SPIFFS_OP_T_OBJNDX (2 << 0)
#define SPIFFS_OP_T_OBJ_DA (3 << 0)
#define SPIFFS_OP_C_DELE (0 << 2)
#define SPIFFS_OP_C_UPDT (1 << 2)
@ -321,7 +321,7 @@
/* if 0, this index header is being deleted */
#define SPIFFS_PH_FLAG_IXDELE (1<<6)
#define SPIFFS_PH_FLAG_NDXDELE (1<<6)
/* Check objid, only visit matching objec ids */

View File

@ -63,7 +63,7 @@ enum spiffs_gc_clean_state_e
{
FIND_OBJ_DATA,
MOVE_OBJ_DATA,
MOVE_OBJ_IX,
MOVE_OBJ_NDX,
FINISHED
};
@ -512,7 +512,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
{
int16_t id = objlu_buf[cur_entry - entry_offset];
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, cur_entry);
cur_pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, cur_entry);
/* Act upon object id depending on gc state */
@ -562,7 +562,7 @@ 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, phdr.spndx, cur_pgndx);
if (SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, phdr.spndx) !=
if (SPIFFS_OBJNDX_ENTRY_SPNDX(fs, phdr.spndx) !=
gc.cur_objndx_spndx)
{
spiffs_gcinfo("No objndx spndx match, take in another run\n");
@ -636,7 +636,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
spiffs_gcinfo("Wrote page=%04x to objhdr entry=%04x in mem\n",
new_data_pgndx,
(int16_t)SPIFFS_OBJ_IX_ENTRY(fs, phdr.spndx));
(int16_t)SPIFFS_OBJNDX_ENTRY(fs, phdr.spndx));
}
else
{
@ -644,18 +644,18 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
((FAR int16_t *)((FAR uint8_t *)objndx +
sizeof(struct spiffs_page_objndx_s)))
[SPIFFS_OBJ_IX_ENTRY(fs, phdr.spndx)] =
[SPIFFS_OBJNDX_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, phdr.spndx));
(int16_t)SPIFFS_OBJNDX_ENTRY(fs, phdr.spndx));
}
}
}
break;
case MOVE_OBJ_IX:
case MOVE_OBJ_NDX:
/* Find and evacuate object index pages */
if (id != SPIFFS_OBJID_DELETED &&
@ -789,7 +789,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
}
gc.cur_objndx_spndx =
SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, phdr.spndx);
SPIFFS_OBJNDX_ENTRY_SPNDX(fs, phdr.spndx);
spiffs_gcinfo("Find objndx spndx=%04x\n", gc.cur_objndx_spndx);
@ -862,7 +862,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
* evacuating object indices
*/
gc.state = MOVE_OBJ_IX;
gc.state = MOVE_OBJ_NDX;
cur_entry = 0; /* Restart entry scan index */
}
break;
@ -924,7 +924,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
}
break;
case MOVE_OBJ_IX:
case MOVE_OBJ_NDX:
/* Scanned through all blocks, no more object indices found - our
* work here is done
*/

View File

@ -303,7 +303,7 @@ static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
return SPIFFS_VIS_COUNTINUE;
}
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, blkndx, entry);
pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(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_ndxheader_s),
@ -317,8 +317,8 @@ static int spiffs_readdir_callback(FAR struct spiffs_s *fs,
if ((objid & SPIFFS_OBJID_NDXFLAG) &&
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))
SPIFFS_PH_FLAG_NDXDELE)) ==
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_NDXDELE))
{
FAR struct fs_dirent_s *dir = (FAR struct fs_dirent_s *)user_var;
FAR struct dirent *entryp;
@ -883,7 +883,7 @@ static off_t spiffs_seek(FAR struct file *filep, off_t offset, int whence)
data_spndx = (pos > 0 ? (pos - 1) : 0) / SPIFFS_DATA_PAGE_SIZE(fs);
objndx_spndx = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spndx);
objndx_spndx = SPIFFS_OBJNDX_ENTRY_SPNDX(fs, data_spndx);
if (fobj->objndx_spndx != objndx_spndx)
{
@ -1394,9 +1394,9 @@ static int spiffs_bind(FAR struct inode *mtdinode, FAR const void *data,
finfo("page header length: %u\n",
(unsigned int)sizeof(struct spiffs_page_header_s));
finfo("object header index entries: %u\n",
(unsigned int)SPIFFS_OBJ_HDR_IX_LEN(fs));
(unsigned int)SPIFFS_OBJHDR_NDXLEN(fs));
finfo("object index entries: %u\n",
(unsigned int)SPIFFS_OBJ_IX_LEN(fs));
(unsigned int)SPIFFS_OBJNDX_LEN(fs));
finfo("free blocks: %u\n",
(unsigned int)fs->free_blocks);

View File

@ -85,7 +85,7 @@ int spiffs_stat_pgndx(FAR struct spiffs_s *fs, int16_t pgndx, int16_t objid,
mode_t mode;
int ret;
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_IX | SPIFFS_OP_C_READ, objid,
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ, objid,
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
sizeof(struct spiffs_pgobj_ndxheader_s),
(FAR uint8_t *) & objhdr);