fs/spiffs/src/spiffs_core.c: Appease nxstyle
This commit is contained in:
parent
c7bfb85584
commit
0b48fed6ee
@ -241,7 +241,8 @@ static int spiffs_objlu_scan_callback(FAR struct spiffs_s *fs, int16_t objid,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int spiffs_objlu_find_id_and_span_callback(FAR struct spiffs_s *fs,
|
static int spiffs_objlu_find_id_and_span_callback(FAR struct spiffs_s *fs,
|
||||||
int16_t objid, int16_t blkndx,
|
int16_t objid,
|
||||||
|
int16_t blkndx,
|
||||||
int entry,
|
int entry,
|
||||||
FAR const void *user_const,
|
FAR const void *user_const,
|
||||||
FAR void *user_var)
|
FAR void *user_var)
|
||||||
@ -283,7 +284,8 @@ static int spiffs_objlu_find_id_and_span_callback(FAR struct spiffs_s *fs,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int spiffs_find_objhdr_pgndx_callback(FAR struct spiffs_s *fs, int16_t objid,
|
static int spiffs_find_objhdr_pgndx_callback(FAR struct spiffs_s *fs,
|
||||||
|
int16_t objid,
|
||||||
int16_t blkndx, int entry,
|
int16_t blkndx, int entry,
|
||||||
FAR const void *user_const,
|
FAR const void *user_const,
|
||||||
FAR void *user_var)
|
FAR void *user_var)
|
||||||
@ -352,7 +354,8 @@ static int
|
|||||||
if (conflicting_name != NULL && (objid & SPIFFS_OBJID_NDXFLAG) != 0)
|
if (conflicting_name != NULL && (objid & SPIFFS_OBJID_NDXFLAG) != 0)
|
||||||
{
|
{
|
||||||
struct spiffs_pgobj_ndxheader_s objhdr;
|
struct spiffs_pgobj_ndxheader_s objhdr;
|
||||||
int16_t pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry);
|
int16_t pgndx = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx,
|
||||||
|
entry);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
|
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
|
||||||
@ -415,7 +418,8 @@ spiffs_objlu_find_free_objid_compact_callback(FAR struct spiffs_s *fs,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ, 0,
|
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ, 0,
|
||||||
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, blkndx, entry),
|
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, blkndx,
|
||||||
|
entry),
|
||||||
sizeof(struct spiffs_pgobj_ndxheader_s),
|
sizeof(struct spiffs_pgobj_ndxheader_s),
|
||||||
(FAR uint8_t *)&objhdr);
|
(FAR uint8_t *)&objhdr);
|
||||||
if (ret >= 0 && objhdr.phdr.spndx == 0 &&
|
if (ret >= 0 && objhdr.phdr.spndx == 0 &&
|
||||||
@ -582,7 +586,8 @@ int spiffs_foreach_objlu(FAR struct spiffs_s *fs, int16_t starting_block,
|
|||||||
int entries_per_page;
|
int entries_per_page;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
entry_count = SPIFFS_GEO_BLOCK_COUNT(fs) * SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs);
|
entry_count = SPIFFS_GEO_BLOCK_COUNT(fs) *
|
||||||
|
SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs);
|
||||||
cur_block = starting_block;
|
cur_block = starting_block;
|
||||||
cur_block_addr = starting_block * SPIFFS_GEO_BLOCK_SIZE(fs);
|
cur_block_addr = starting_block * SPIFFS_GEO_BLOCK_SIZE(fs);
|
||||||
objlu_buf = (FAR int16_t *)fs->lu_work;
|
objlu_buf = (FAR int16_t *)fs->lu_work;
|
||||||
@ -678,7 +683,8 @@ int spiffs_foreach_objlu(FAR struct spiffs_s *fs, int16_t starting_block,
|
|||||||
fs->lu_work);
|
fs->lu_work);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_cache_read() failed: %d\n",
|
ferr("ERROR: spiffs_cache_read() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1233,7 +1239,8 @@ int spiffs_page_move(FAR struct spiffs_s *fs,
|
|||||||
/* Mark finalized in destination page */
|
/* Mark finalized in destination page */
|
||||||
|
|
||||||
phdr->flags &= ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_USED);
|
phdr->flags &= ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_USED);
|
||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT, objid,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
||||||
|
objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, free_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs, free_pgndx) +
|
||||||
offsetof(struct spiffs_page_header_s, flags),
|
offsetof(struct spiffs_page_header_s, flags),
|
||||||
sizeof(uint8_t), (FAR uint8_t *)&phdr->flags);
|
sizeof(uint8_t), (FAR uint8_t *)&phdr->flags);
|
||||||
@ -1371,16 +1378,19 @@ int spiffs_fobj_create(FAR struct spiffs_s *fs,
|
|||||||
objndx_hdr.phdr.objid = objid;
|
objndx_hdr.phdr.objid = objid;
|
||||||
objndx_hdr.phdr.spndx = 0;
|
objndx_hdr.phdr.spndx = 0;
|
||||||
objndx_hdr.phdr.flags =
|
objndx_hdr.phdr.flags =
|
||||||
0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_USED);
|
0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX |
|
||||||
|
SPIFFS_PH_FLAG_USED);
|
||||||
objndx_hdr.type = type;
|
objndx_hdr.type = type;
|
||||||
objndx_hdr.size = SPIFFS_UNDEFINED_LEN;
|
objndx_hdr.size = SPIFFS_UNDEFINED_LEN;
|
||||||
|
|
||||||
strncpy((char *)objndx_hdr.name, (const char *)name, CONFIG_SPIFFS_NAME_MAX);
|
strncpy((char *)objndx_hdr.name, (const char *)name,
|
||||||
|
CONFIG_SPIFFS_NAME_MAX);
|
||||||
|
|
||||||
/* Update page */
|
/* Update page */
|
||||||
|
|
||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT, 0,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT, 0,
|
||||||
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, blkndx, entry),
|
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, blkndx,
|
||||||
|
entry),
|
||||||
sizeof(struct spiffs_pgobj_ndxheader_s),
|
sizeof(struct spiffs_pgobj_ndxheader_s),
|
||||||
(FAR uint8_t *)&objndx_hdr);
|
(FAR uint8_t *)&objndx_hdr);
|
||||||
|
|
||||||
@ -1532,7 +1542,9 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
|
|||||||
fobj != NULL;
|
fobj != NULL;
|
||||||
fobj = next)
|
fobj = next)
|
||||||
{
|
{
|
||||||
/* Set up for the next time through the loop (in case fobj is deleted) */
|
/* Set up for the next time through the loop (in case fobj is
|
||||||
|
* deleted)
|
||||||
|
*/
|
||||||
|
|
||||||
next = (FAR struct spiffs_file_s *)dq_next((FAR dq_entry_t *)fobj);
|
next = (FAR struct spiffs_file_s *)dq_next((FAR dq_entry_t *)fobj);
|
||||||
|
|
||||||
@ -1549,7 +1561,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
|
|||||||
|
|
||||||
if (ev != SPIFFS_EV_NDXDEL)
|
if (ev != SPIFFS_EV_NDXDEL)
|
||||||
{
|
{
|
||||||
finfo("Setting objid=%d (offset=%d) objhdr_pgndx to %04x size=%d\n",
|
finfo("Setting objid=%d (offset=%d) objhdr_pgndx "
|
||||||
|
"to %04x size=%d\n",
|
||||||
fobj->objid, fobj->offset, new_pgndx, new_size);
|
fobj->objid, fobj->offset, new_pgndx, new_size);
|
||||||
|
|
||||||
fobj->objhdr_pgndx = new_pgndx;
|
fobj->objhdr_pgndx = new_pgndx;
|
||||||
@ -1581,7 +1594,8 @@ void spiffs_fobj_event(FAR struct spiffs_s *fs,
|
|||||||
if (fobj->cache_page &&
|
if (fobj->cache_page &&
|
||||||
fobj->cache_page->offset > act_new_size + 1)
|
fobj->cache_page->offset > act_new_size + 1)
|
||||||
{
|
{
|
||||||
spiffs_cacheinfo("File truncated, dropping cache page=%d, "
|
spiffs_cacheinfo("File truncated, "
|
||||||
|
"dropping cache page=%d, "
|
||||||
"no writeback\n",
|
"no writeback\n",
|
||||||
fobj->cache_page->cpndx);
|
fobj->cache_page->cpndx);
|
||||||
|
|
||||||
@ -1662,7 +1676,8 @@ int spiffs_fobj_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
|||||||
|
|
||||||
physoff = SPIFFS_BLOCK_TO_PADDR(fs, blkndx) + entry * sizeof(int16_t);
|
physoff = SPIFFS_BLOCK_TO_PADDR(fs, blkndx) + entry * sizeof(int16_t);
|
||||||
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, 0,
|
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, 0,
|
||||||
physoff, sizeof(int16_t), (FAR uint8_t *)&objid);
|
physoff, sizeof(int16_t),
|
||||||
|
(FAR uint8_t *)&objid);
|
||||||
|
|
||||||
/* Fill in the parts of the open file structure known only to the core
|
/* Fill in the parts of the open file structure known only to the core
|
||||||
* logic.
|
* logic.
|
||||||
@ -1775,10 +1790,12 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
* 0xffffffff)
|
* 0xffffffff)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = spiffs_page_index_check(fs, fobj, cur_objndx_pgndx, 0);
|
ret = spiffs_page_index_check(fs, fobj,
|
||||||
|
cur_objndx_pgndx, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_page_index_check() failed: %d\n",
|
ferr("ERROR: spiffs_page_index_check() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1808,12 +1825,14 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
&new_objhdr_page);
|
&new_objhdr_page);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
finfo("objid=%04x store new objhdr, %04x:%04x, nwritten=%d\n",
|
finfo("objid=%04x store new objhdr, "
|
||||||
|
"%04x:%04x, nwritten=%d\n",
|
||||||
fobj->objid, new_objhdr_page, 0, nwritten);
|
fobj->objid, new_objhdr_page, 0, nwritten);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1825,7 +1844,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
prev_objndx_spndx);
|
prev_objndx_spndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_page_index_check() failed: %d\n", ret);
|
ferr("ERROR: spiffs_page_index_check() failed: "
|
||||||
|
"%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1841,7 +1861,9 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)fs->work,
|
spiffs_fobj_event(fs,
|
||||||
|
(FAR struct spiffs_page_objndx_s *)
|
||||||
|
fs->work,
|
||||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||||
objndx->phdr.spndx, cur_objndx_pgndx,
|
objndx->phdr.spndx, cur_objndx_pgndx,
|
||||||
0);
|
0);
|
||||||
@ -1881,7 +1903,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_cache_read(fs,
|
ret = spiffs_cache_read(fs,
|
||||||
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
|
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
|
SPIFFS_PAGE_TO_PADDR(fs,
|
||||||
|
cur_objndx_pgndx),
|
||||||
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -1915,7 +1938,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX);
|
0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX);
|
||||||
|
|
||||||
ret = spiffs_page_allocate_data(fs,
|
ret = spiffs_page_allocate_data(fs,
|
||||||
fobj->objid | SPIFFS_OBJID_NDXFLAG,
|
fobj->objid |
|
||||||
|
SPIFFS_OBJID_NDXFLAG,
|
||||||
&phdr, 0, 0, 0, 1,
|
&phdr, 0, 0, 0, 1,
|
||||||
&cur_objndx_pgndx);
|
&cur_objndx_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1928,14 +1952,17 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
/* Quick "load" of new object index page */
|
/* Quick "load" of new object index page */
|
||||||
|
|
||||||
memset(fs->work, 0xff, SPIFFS_GEO_PAGE_SIZE(fs));
|
memset(fs->work, 0xff, SPIFFS_GEO_PAGE_SIZE(fs));
|
||||||
memcpy(fs->work, &phdr, sizeof(struct spiffs_page_header_s));
|
memcpy(fs->work, &phdr,
|
||||||
|
sizeof(struct spiffs_page_header_s));
|
||||||
|
|
||||||
spiffs_fobj_event(fs,
|
spiffs_fobj_event(fs,
|
||||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
(FAR struct spiffs_page_objndx_s *)
|
||||||
|
fs->work,
|
||||||
SPIFFS_EV_NDXNEW, fobj->objid,
|
SPIFFS_EV_NDXNEW, fobj->objid,
|
||||||
cur_objndx_spndx, cur_objndx_pgndx, 0);
|
cur_objndx_spndx, cur_objndx_pgndx, 0);
|
||||||
|
|
||||||
finfo("objid=%04x create objndx page, %04x:%04x, nwritten=%d\n",
|
finfo("objid=%04x create objndx page, "
|
||||||
|
"%04x:%04x, nwritten=%d\n",
|
||||||
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx,
|
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx,
|
||||||
nwritten);
|
nwritten);
|
||||||
}
|
}
|
||||||
@ -1956,22 +1983,26 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
{
|
{
|
||||||
ret =
|
ret =
|
||||||
spiffs_objlu_find_id_and_span(fs,
|
spiffs_objlu_find_id_and_span(fs,
|
||||||
fobj->objid | SPIFFS_OBJID_NDXFLAG,
|
fobj->objid |
|
||||||
|
SPIFFS_OBJID_NDXFLAG,
|
||||||
cur_objndx_spndx, 0,
|
cur_objndx_spndx, 0,
|
||||||
&pgndx);
|
&pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
|
ferr("ERROR: spiffs_objlu_find_id_and_span() "
|
||||||
|
"failed: %d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finfo("objid=%04x found object index at page=%04x [fobj size=%d]\n",
|
finfo("objid=%04x found object index at "
|
||||||
|
"page=%04x [fobj size=%d]\n",
|
||||||
fobj->objid, pgndx, fobj->size);
|
fobj->objid, pgndx, fobj->size);
|
||||||
|
|
||||||
ret = spiffs_cache_read(fs,
|
ret = spiffs_cache_read(fs,
|
||||||
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
|
SPIFFS_OP_T_OBJNDX |
|
||||||
|
SPIFFS_OP_C_READ,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
|
SPIFFS_PAGE_TO_PADDR(fs, pgndx),
|
||||||
SPIFFS_GEO_PAGE_SIZE(fs),
|
SPIFFS_GEO_PAGE_SIZE(fs),
|
||||||
@ -2016,7 +2047,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
phdr.flags = 0xff & ~(SPIFFS_PH_FLAG_FINAL); /* Finalize immediately */
|
phdr.flags = 0xff & ~(SPIFFS_PH_FLAG_FINAL); /* Finalize immediately */
|
||||||
|
|
||||||
ret = spiffs_page_allocate_data(fs,
|
ret = spiffs_page_allocate_data(fs,
|
||||||
fobj->objid & ~SPIFFS_OBJID_NDXFLAG,
|
fobj->objid &
|
||||||
|
~SPIFFS_OBJID_NDXFLAG,
|
||||||
&phdr, &data[nwritten], to_write,
|
&phdr, &data[nwritten], to_write,
|
||||||
page_offs, 1, &data_page);
|
page_offs, 1, &data_page);
|
||||||
|
|
||||||
@ -2057,10 +2089,12 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, data_page) +
|
SPIFFS_PAGE_TO_PADDR(fs, data_page) +
|
||||||
sizeof(struct spiffs_page_header_s) + page_offs,
|
sizeof(struct spiffs_page_header_s) +
|
||||||
|
page_offs,
|
||||||
to_write, &data[nwritten]);
|
to_write, &data[nwritten]);
|
||||||
|
|
||||||
finfo("objid=%04x store to existing data page, %04x:%04x offset=%d, "
|
finfo("objid=%04x store to existing data page, "
|
||||||
|
"%04x:%04x offset=%d, "
|
||||||
"len=%d, nwritten=%d\n",
|
"len=%d, nwritten=%d\n",
|
||||||
fobj->objid, data_page, data_spndx, page_offs, to_write,
|
fobj->objid, data_page, data_spndx, page_offs, to_write,
|
||||||
nwritten);
|
nwritten);
|
||||||
@ -2071,14 +2105,17 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update memory representation of object index page with new data page */
|
/* Update memory representation of object index page with new data
|
||||||
|
* page
|
||||||
|
*/
|
||||||
|
|
||||||
if (cur_objndx_spndx == 0)
|
if (cur_objndx_spndx == 0)
|
||||||
{
|
{
|
||||||
/* Update object index header page */
|
/* Update object index header page */
|
||||||
|
|
||||||
((FAR int16_t *)((FAR uint8_t *) objhdr +
|
((FAR int16_t *)((FAR uint8_t *) objhdr +
|
||||||
sizeof(struct spiffs_pgobj_ndxheader_s)))[data_spndx] = data_page;
|
sizeof(struct spiffs_pgobj_ndxheader_s)))[data_spndx] =
|
||||||
|
data_page;
|
||||||
|
|
||||||
finfo("objid=%04x wrote page %04x to objhdr entry=%04x in mem\n",
|
finfo("objid=%04x wrote page %04x to objhdr entry=%04x in mem\n",
|
||||||
fobj->objid, data_page, data_spndx);
|
fobj->objid, data_page, data_spndx);
|
||||||
@ -2170,11 +2207,14 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
|
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
{
|
{
|
||||||
/* Wrote to empty object - simply update size and write whole page */
|
/* Wrote to empty object - simply update size and write whole
|
||||||
|
* page
|
||||||
|
*/
|
||||||
|
|
||||||
objhdr->size = offset + nwritten;
|
objhdr->size = offset + nwritten;
|
||||||
|
|
||||||
finfo("objid=%04x store fresh objhdr page, %04x:%04x, nwritten=%d\n",
|
finfo("objid=%04x store fresh objhdr page, "
|
||||||
|
"%04x:%04x, nwritten=%d\n",
|
||||||
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx, nwritten);
|
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx, nwritten);
|
||||||
|
|
||||||
ret2 = spiffs_page_index_check(fs, fobj, cur_objndx_pgndx,
|
ret2 = spiffs_page_index_check(fs, fobj, cur_objndx_pgndx,
|
||||||
@ -2188,7 +2228,8 @@ ssize_t spiffs_fobj_append(FAR struct spiffs_s *fs,
|
|||||||
ret2 = spiffs_cache_write(fs,
|
ret2 = spiffs_cache_write(fs,
|
||||||
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
|
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_UPDT,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
|
SPIFFS_PAGE_TO_PADDR(fs,
|
||||||
|
cur_objndx_pgndx),
|
||||||
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
||||||
if (ret2 < 0)
|
if (ret2 < 0)
|
||||||
{
|
{
|
||||||
@ -2307,7 +2348,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
fs->work, 0, 0,
|
fs->work, 0, 0,
|
||||||
&new_objhdr_pgndx);
|
&new_objhdr_pgndx);
|
||||||
|
|
||||||
finfo("Store modified objhdr page, %04x:%04x, nwritten=%d\n",
|
finfo("Store modified objhdr page, "
|
||||||
|
"%04x:%04x, nwritten=%d\n",
|
||||||
new_objhdr_pgndx, 0, nwritten);
|
new_objhdr_pgndx, 0, nwritten);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -2327,11 +2369,13 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
prev_objndx_spndx);
|
prev_objndx_spndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_page_index_check() failed: %d\n", ret);
|
ferr("ERROR: spiffs_page_index_check() failed: %d\n",
|
||||||
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = spiffs_page_move(fs, fobj->objid, (FAR uint8_t *)objndx,
|
ret = spiffs_page_move(fs, fobj->objid,
|
||||||
|
(FAR uint8_t *)objndx,
|
||||||
fobj->objid, 0, cur_objndx_pgndx,
|
fobj->objid, 0, cur_objndx_pgndx,
|
||||||
&new_objndx_pgndx);
|
&new_objndx_pgndx);
|
||||||
|
|
||||||
@ -2346,7 +2390,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
spiffs_fobj_event(fs,
|
spiffs_fobj_event(fs,
|
||||||
(FAR struct spiffs_page_objndx_s *)objndx,
|
(FAR struct spiffs_page_objndx_s *)
|
||||||
|
objndx,
|
||||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||||
objndx->phdr.spndx, new_objndx_pgndx,
|
objndx->phdr.spndx, new_objndx_pgndx,
|
||||||
0);
|
0);
|
||||||
@ -2365,7 +2410,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_cache_read(fs,
|
ret = spiffs_cache_read(fs,
|
||||||
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
|
SPIFFS_OP_T_OBJNDX | SPIFFS_OP_C_READ,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, cur_objndx_pgndx),
|
SPIFFS_PAGE_TO_PADDR(fs,
|
||||||
|
cur_objndx_pgndx),
|
||||||
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
SPIFFS_GEO_PAGE_SIZE(fs), fs->work);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -2397,12 +2443,14 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
{
|
{
|
||||||
ret =
|
ret =
|
||||||
spiffs_objlu_find_id_and_span(fs,
|
spiffs_objlu_find_id_and_span(fs,
|
||||||
fobj->objid | SPIFFS_OBJID_NDXFLAG,
|
fobj->objid |
|
||||||
|
SPIFFS_OBJID_NDXFLAG,
|
||||||
cur_objndx_spndx, 0,
|
cur_objndx_spndx, 0,
|
||||||
&pgndx);
|
&pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
|
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2469,17 +2517,20 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
/* A full page, allocate and write a new page of data */
|
/* A full page, allocate and write a new page of data */
|
||||||
|
|
||||||
ret = spiffs_page_allocate_data(fs,
|
ret = spiffs_page_allocate_data(fs,
|
||||||
fobj->objid & ~SPIFFS_OBJID_NDXFLAG,
|
fobj->objid &
|
||||||
|
~SPIFFS_OBJID_NDXFLAG,
|
||||||
&phdr, &data[nwritten], to_write,
|
&phdr, &data[nwritten], to_write,
|
||||||
page_offs, 1, &data_pgndx);
|
page_offs, 1, &data_pgndx);
|
||||||
finfo("Store new data page, %04x:%04x offset=%d, len=%d, nwritten=%d\n",
|
finfo("Store new data page, %04x:%04x offset=%d, "
|
||||||
|
"len=%d, nwritten=%d\n",
|
||||||
data_pgndx, data_spndx, page_offs, to_write, nwritten);
|
data_pgndx, data_spndx, page_offs, to_write, nwritten);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Write to existing page, allocate new and copy unmodified data */
|
/* Write to existing page, allocate new and copy unmodified data */
|
||||||
|
|
||||||
ret = spiffs_page_data_check(fs, fobj, orig_data_pgndx, data_spndx);
|
ret = spiffs_page_data_check(fs, fobj, orig_data_pgndx,
|
||||||
|
data_spndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_page_data_check() failed: %d\n", ret);
|
ferr("ERROR: spiffs_page_data_check() failed: %d\n", ret);
|
||||||
@ -2487,7 +2538,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = spiffs_page_allocate_data(fs,
|
ret = spiffs_page_allocate_data(fs,
|
||||||
fobj->objid & ~SPIFFS_OBJID_NDXFLAG,
|
fobj->objid &
|
||||||
|
~SPIFFS_OBJID_NDXFLAG,
|
||||||
&phdr, 0, 0, 0, 0, &data_pgndx);
|
&phdr, 0, 0, 0, 0, &data_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -2504,8 +2556,10 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_phys_cpy(fs, fobj->objid,
|
ret = spiffs_phys_cpy(fs, fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
||||||
sizeof(struct spiffs_page_header_s),
|
sizeof(struct spiffs_page_header_s),
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs,
|
||||||
sizeof(struct spiffs_page_header_s), page_offs);
|
orig_data_pgndx) +
|
||||||
|
sizeof(struct spiffs_page_header_s),
|
||||||
|
page_offs);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_phys_cpy() failed: %d\n", ret);
|
ferr("ERROR: spiffs_phys_cpy() failed: %d\n", ret);
|
||||||
@ -2520,10 +2574,12 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
ret =
|
ret =
|
||||||
spiffs_phys_cpy(fs, fobj->objid,
|
spiffs_phys_cpy(fs, fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
||||||
sizeof(struct spiffs_page_header_s) + page_offs +
|
sizeof(struct spiffs_page_header_s) +
|
||||||
|
page_offs +
|
||||||
to_write,
|
to_write,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx)
|
SPIFFS_PAGE_TO_PADDR(fs, orig_data_pgndx)
|
||||||
+ sizeof(struct spiffs_page_header_s) + page_offs +
|
+ sizeof(struct spiffs_page_header_s) +
|
||||||
|
page_offs +
|
||||||
to_write,
|
to_write,
|
||||||
SPIFFS_DATA_PAGE_SIZE(fs) -
|
SPIFFS_DATA_PAGE_SIZE(fs) -
|
||||||
(page_offs + to_write));
|
(page_offs + to_write));
|
||||||
@ -2535,8 +2591,10 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
||||||
fobj->objid, SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
fobj->objid,
|
||||||
sizeof(struct spiffs_page_header_s) + page_offs,
|
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
||||||
|
sizeof(struct spiffs_page_header_s) +
|
||||||
|
page_offs,
|
||||||
to_write, &data[nwritten]);
|
to_write, &data[nwritten]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -2548,8 +2606,10 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs, data_pgndx) +
|
||||||
offsetof(struct spiffs_page_header_s, flags),
|
offsetof(struct spiffs_page_header_s,
|
||||||
sizeof(uint8_t), (FAR uint8_t *)&phdr.flags);
|
flags),
|
||||||
|
sizeof(uint8_t),
|
||||||
|
(FAR uint8_t *)&phdr.flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_cache_write() failed: %d\n", ret);
|
ferr("ERROR: spiffs_cache_write() failed: %d\n", ret);
|
||||||
@ -2571,14 +2631,17 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update memory representation of object index page with new data page */
|
/* Update memory representation of object index page with new data
|
||||||
|
* page
|
||||||
|
*/
|
||||||
|
|
||||||
if (cur_objndx_spndx == 0)
|
if (cur_objndx_spndx == 0)
|
||||||
{
|
{
|
||||||
/* Update object index header page */
|
/* Update object index header page */
|
||||||
|
|
||||||
((FAR int16_t *)((FAR uint8_t *)objhdr +
|
((FAR int16_t *)((FAR uint8_t *)objhdr +
|
||||||
sizeof(struct spiffs_pgobj_ndxheader_s)))[data_spndx] = data_pgndx;
|
sizeof(struct spiffs_pgobj_ndxheader_s)))[data_spndx] =
|
||||||
|
data_pgndx;
|
||||||
|
|
||||||
finfo("Wrote page %04x to objhdr entry=%04x in mem\n",
|
finfo("Wrote page %04x to objhdr entry=%04x in mem\n",
|
||||||
data_pgndx, data_spndx);
|
data_pgndx, data_spndx);
|
||||||
@ -2588,8 +2651,8 @@ ssize_t spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
|||||||
/* Update object index page */
|
/* Update object index page */
|
||||||
|
|
||||||
((FAR int16_t *)((FAR uint8_t *)objndx +
|
((FAR int16_t *)((FAR uint8_t *)objndx +
|
||||||
sizeof(struct spiffs_page_objndx_s)))[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] =
|
sizeof(struct spiffs_page_objndx_s)))
|
||||||
data_pgndx;
|
[SPIFFS_OBJNDX_ENTRY(fs, data_spndx)] = data_pgndx;
|
||||||
|
|
||||||
finfo("Wrote page %04x to objndx entry %04x in mem\n",
|
finfo("Wrote page %04x to objndx entry %04x in mem\n",
|
||||||
data_pgndx, (int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
|
data_pgndx, (int16_t)SPIFFS_OBJNDX_ENTRY(fs, data_spndx));
|
||||||
@ -2736,7 +2799,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
* remove the file, then there is nothing to do.
|
* remove the file, then there is nothing to do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((fobj->size == SPIFFS_UNDEFINED_LEN || fobj->size == 0) && !remove_full)
|
if ((fobj->size == SPIFFS_UNDEFINED_LEN || fobj->size == 0) &&
|
||||||
|
!remove_full)
|
||||||
{
|
{
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
|
|
||||||
@ -2775,7 +2839,9 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
cur_size = fobj->size;
|
cur_size = fobj->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Before truncating, check if object is to be fully removed and mark this */
|
/* Before truncating, check if object is to be fully removed and mark
|
||||||
|
* this
|
||||||
|
*/
|
||||||
|
|
||||||
if (remove_full && new_size == 0)
|
if (remove_full && new_size == 0)
|
||||||
{
|
{
|
||||||
@ -2856,7 +2922,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
&new_objhdr_pgndx);
|
&new_objhdr_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2875,7 +2942,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = spiffs_objlu_find_id_and_span(fs,
|
ret = spiffs_objlu_find_id_and_span(fs,
|
||||||
fobj->objid | SPIFFS_OBJID_NDXFLAG,
|
fobj->objid |
|
||||||
|
SPIFFS_OBJID_NDXFLAG,
|
||||||
cur_objndx_spndx, 0,
|
cur_objndx_spndx, 0,
|
||||||
&objndx_pgndx);
|
&objndx_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -2995,8 +3063,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
|
|
||||||
/* Delete last page, partially */
|
/* Delete last page, partially */
|
||||||
|
|
||||||
bytes_to_remove =
|
bytes_to_remove = SPIFFS_DATA_PAGE_SIZE(fs) -
|
||||||
SPIFFS_DATA_PAGE_SIZE(fs) - (new_size % SPIFFS_DATA_PAGE_SIZE(fs));
|
(new_size % SPIFFS_DATA_PAGE_SIZE(fs));
|
||||||
|
|
||||||
finfo("Delete %d bytes from data page=%04x for data spndx=%04x, "
|
finfo("Delete %d bytes from data page=%04x for data spndx=%04x, "
|
||||||
"cur_size=%d\n",
|
"cur_size=%d\n",
|
||||||
@ -3016,7 +3084,8 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
/* Allocate new page and copy unmodified data */
|
/* Allocate new page and copy unmodified data */
|
||||||
|
|
||||||
ret = spiffs_page_allocate_data(fs,
|
ret = spiffs_page_allocate_data(fs,
|
||||||
fobj->objid & ~SPIFFS_OBJID_NDXFLAG,
|
fobj->objid &
|
||||||
|
~SPIFFS_OBJID_NDXFLAG,
|
||||||
&phdr, 0, 0, 0, 0,
|
&phdr, 0, 0, 0, 0,
|
||||||
&new_data_pgndx);
|
&new_data_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -3050,8 +3119,10 @@ int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
|||||||
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
ret = spiffs_cache_write(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
|
||||||
fobj->objid,
|
fobj->objid,
|
||||||
SPIFFS_PAGE_TO_PADDR(fs, new_data_pgndx) +
|
SPIFFS_PAGE_TO_PADDR(fs, new_data_pgndx) +
|
||||||
offsetof(struct spiffs_page_header_s, flags),
|
offsetof(struct spiffs_page_header_s,
|
||||||
sizeof(uint8_t), (FAR uint8_t *)&phdr.flags);
|
flags),
|
||||||
|
sizeof(uint8_t),
|
||||||
|
(FAR uint8_t *)&phdr.flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_cache_write() failed: %d\n", ret);
|
ferr("ERROR: spiffs_cache_write() failed: %d\n", ret);
|
||||||
@ -3274,12 +3345,14 @@ ssize_t spiffs_object_read(FAR struct spiffs_s *fs,
|
|||||||
{
|
{
|
||||||
ret =
|
ret =
|
||||||
spiffs_objlu_find_id_and_span(fs,
|
spiffs_objlu_find_id_and_span(fs,
|
||||||
fobj->objid | SPIFFS_OBJID_NDXFLAG,
|
fobj->objid |
|
||||||
|
SPIFFS_OBJID_NDXFLAG,
|
||||||
cur_objndx_spndx, 0,
|
cur_objndx_spndx, 0,
|
||||||
&objndx_pgndx);
|
&objndx_pgndx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: %d\n",
|
ferr("ERROR: spiffs_objlu_find_id_and_span() failed: "
|
||||||
|
"%d\n",
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3405,7 +3478,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid,
|
|||||||
int16_t free_objid;
|
int16_t free_objid;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
max_objects = (SPIFFS_GEO_BLOCK_COUNT(fs) * SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs)) / 2;
|
max_objects = (SPIFFS_GEO_BLOCK_COUNT(fs) *
|
||||||
|
SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs)) / 2;
|
||||||
free_objid = SPIFFS_OBJID_FREE;
|
free_objid = SPIFFS_OBJID_FREE;
|
||||||
|
|
||||||
state.min_objid = 1;
|
state.min_objid = 1;
|
||||||
@ -3521,7 +3595,9 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid,
|
|||||||
|
|
||||||
if (min_count == 0)
|
if (min_count == 0)
|
||||||
{
|
{
|
||||||
/* No objid in this range, skip compacting and use directly */
|
/* No objid in this range, skip compacting and use
|
||||||
|
* directly
|
||||||
|
*/
|
||||||
|
|
||||||
*objid = min_i * state.compaction + state.min_objid;
|
*objid = min_i * state.compaction + state.min_objid;
|
||||||
return OK;
|
return OK;
|
||||||
@ -3555,9 +3631,8 @@ int spiffs_objlu_find_free_objid(FAR struct spiffs_s *fs, int16_t *objid,
|
|||||||
* byte
|
* byte
|
||||||
*/
|
*/
|
||||||
|
|
||||||
state.compaction =
|
state.compaction = (state.max_objid - state.min_objid) /
|
||||||
(state.max_objid -
|
((SPIFFS_GEO_PAGE_SIZE(fs) / sizeof(uint8_t)));
|
||||||
state.min_objid) / ((SPIFFS_GEO_PAGE_SIZE(fs) / sizeof(uint8_t)));
|
|
||||||
|
|
||||||
finfo("COMP min=%04x max=%04x compact=%d\n",
|
finfo("COMP min=%04x max=%04x compact=%d\n",
|
||||||
state.min_objid, state.max_objid, state.compaction);
|
state.min_objid, state.max_objid, state.compaction);
|
||||||
|
Loading…
Reference in New Issue
Block a user