mirror of
https://github.com/pellepl/spiffs.git
synced 2026-09-22 08:57:35 +00:00
push const all the way
This commit is contained in:
+8
-6
@@ -440,9 +440,10 @@ static s32_t spiffs_lookup_check_validate(spiffs *fs, spiffs_obj_id lu_obj_id, s
|
||||
}
|
||||
|
||||
static s32_t spiffs_lookup_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block, int cur_entry,
|
||||
u32_t user_data, void *user_p) {
|
||||
u32_t user_data, const void *user_const_p, void *user_var_p) {
|
||||
(void)user_data;
|
||||
(void)user_p;
|
||||
(void)user_const_p;
|
||||
(void)user_var_p;
|
||||
s32_t res = SPIFFS_OK;
|
||||
spiffs_page_header p_hdr;
|
||||
spiffs_page_ix cur_pix = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, cur_block, cur_entry);
|
||||
@@ -475,7 +476,7 @@ s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) {
|
||||
|
||||
CHECK_CB(fs, SPIFFS_CHECK_LOOKUP, SPIFFS_CHECK_PROGRESS, 0, 0);
|
||||
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_lookup_check_v, 0, 0, 0, 0);
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_lookup_check_v, 0, 0, 0, 0, 0);
|
||||
|
||||
if (res == SPIFFS_VIS_END) {
|
||||
res = SPIFFS_OK;
|
||||
@@ -873,11 +874,12 @@ static int spiffs_object_index_search(spiffs *fs, spiffs_obj_id obj_id) {
|
||||
}
|
||||
|
||||
static s32_t spiffs_object_index_consistency_check_v(spiffs *fs, spiffs_obj_id obj_id, spiffs_block_ix cur_block,
|
||||
int cur_entry, u32_t user_data, void *user_p) {
|
||||
int cur_entry, u32_t user_data, const void *user_const_p, void *user_var_p) {
|
||||
(void)user_data;
|
||||
(void)user_const_p;
|
||||
s32_t res_c = SPIFFS_VIS_COUNTINUE;
|
||||
s32_t res = SPIFFS_OK;
|
||||
u32_t *log_ix = (u32_t *)user_p;
|
||||
u32_t *log_ix = (u32_t*)user_var_p;
|
||||
spiffs_obj_id *obj_table = (spiffs_obj_id *)fs->work;
|
||||
|
||||
CHECK_CB(fs, SPIFFS_CHECK_INDEX, SPIFFS_CHECK_PROGRESS,
|
||||
@@ -978,7 +980,7 @@ s32_t spiffs_object_index_consistency_check(spiffs *fs) {
|
||||
u32_t obj_id_log_ix = 0;
|
||||
CHECK_CB(fs, SPIFFS_CHECK_INDEX, SPIFFS_CHECK_PROGRESS, 0, 0);
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_object_index_consistency_check_v, 0, &obj_id_log_ix,
|
||||
0, 0);
|
||||
0, 0, 0);
|
||||
if (res == SPIFFS_VIS_END) {
|
||||
res = SPIFFS_OK;
|
||||
}
|
||||
|
||||
+14
-11
@@ -174,9 +174,9 @@ s32_t SPIFFS_creat(spiffs *fs, const char *path, spiffs_mode mode) {
|
||||
spiffs_obj_id obj_id;
|
||||
s32_t res;
|
||||
|
||||
res = spiffs_obj_lu_find_free_obj_id(fs, &obj_id, (u8_t *)path);
|
||||
res = spiffs_obj_lu_find_free_obj_id(fs, &obj_id, (const u8_t*)path);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
res = spiffs_object_create(fs, obj_id, (u8_t *)path, SPIFFS_TYPE_FILE, 0);
|
||||
res = spiffs_object_create(fs, obj_id, (const u8_t*)path, SPIFFS_TYPE_FILE, 0);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
SPIFFS_UNLOCK(fs);
|
||||
return 0;
|
||||
@@ -194,7 +194,7 @@ spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs
|
||||
s32_t res = spiffs_fd_find_new(fs, &fd);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (u8_t*)path, &pix);
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (const u8_t*)path, &pix);
|
||||
if ((flags & SPIFFS_CREAT) == 0) {
|
||||
if (res < SPIFFS_OK) {
|
||||
spiffs_fd_return(fs, fd->file_nbr);
|
||||
@@ -218,7 +218,7 @@ spiffs_file SPIFFS_open(spiffs *fs, const char *path, spiffs_flags flags, spiffs
|
||||
spiffs_fd_return(fs, fd->file_nbr);
|
||||
}
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
res = spiffs_object_create(fs, obj_id, (u8_t*)path, SPIFFS_TYPE_FILE, &pix);
|
||||
res = spiffs_object_create(fs, obj_id, (const u8_t*)path, SPIFFS_TYPE_FILE, &pix);
|
||||
if (res < SPIFFS_OK) {
|
||||
spiffs_fd_return(fs, fd->file_nbr);
|
||||
}
|
||||
@@ -534,7 +534,7 @@ s32_t SPIFFS_remove(spiffs *fs, const char *path) {
|
||||
res = spiffs_fd_find_new(fs, &fd);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (u8_t *)path, &pix);
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (const u8_t*)path, &pix);
|
||||
if (res != SPIFFS_OK) {
|
||||
spiffs_fd_return(fs, fd->file_nbr);
|
||||
}
|
||||
@@ -615,7 +615,7 @@ s32_t SPIFFS_stat(spiffs *fs, const char *path, spiffs_stat *s) {
|
||||
s32_t res;
|
||||
spiffs_page_ix pix;
|
||||
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (u8_t*)path, &pix);
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (const u8_t*)path, &pix);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
|
||||
res = spiffs_stat_pix(fs, pix, 0, s);
|
||||
@@ -728,10 +728,10 @@ s32_t SPIFFS_rename(spiffs *fs, const char *old, const char *new) {
|
||||
spiffs_page_ix pix_old, pix_dummy;
|
||||
spiffs_fd *fd;
|
||||
|
||||
s32_t res = spiffs_object_find_object_index_header_by_name(fs, (u8_t*)old, &pix_old);
|
||||
s32_t res = spiffs_object_find_object_index_header_by_name(fs, (const u8_t*)old, &pix_old);
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (u8_t*)new, &pix_dummy);
|
||||
res = spiffs_object_find_object_index_header_by_name(fs, (const u8_t*)new, &pix_dummy);
|
||||
if (res == SPIFFS_ERR_NOT_FOUND) {
|
||||
res = SPIFFS_OK;
|
||||
} else if (res == SPIFFS_OK) {
|
||||
@@ -748,7 +748,7 @@ s32_t SPIFFS_rename(spiffs *fs, const char *old, const char *new) {
|
||||
}
|
||||
SPIFFS_API_CHECK_RES_UNLOCK(fs, res);
|
||||
|
||||
res = spiffs_object_update_index_hdr(fs, fd, fd->obj_id, fd->objix_hdr_pix, 0, (u8_t*)new,
|
||||
res = spiffs_object_update_index_hdr(fs, fd, fd->obj_id, fd->objix_hdr_pix, 0, (const u8_t*)new,
|
||||
0, &pix_dummy);
|
||||
|
||||
spiffs_fd_return(fs, fd->file_nbr);
|
||||
@@ -785,8 +785,10 @@ static s32_t spiffs_read_dir_v(
|
||||
spiffs_block_ix bix,
|
||||
int ix_entry,
|
||||
u32_t user_data,
|
||||
void *user_p) {
|
||||
const void *user_const_p,
|
||||
void *user_var_p) {
|
||||
(void)user_data;
|
||||
(void)user_const_p;
|
||||
s32_t res;
|
||||
spiffs_page_object_ix_header objix_hdr;
|
||||
if (obj_id == SPIFFS_OBJ_ID_FREE || obj_id == SPIFFS_OBJ_ID_DELETED ||
|
||||
@@ -802,7 +804,7 @@ static s32_t spiffs_read_dir_v(
|
||||
objix_hdr.p_hdr.span_ix == 0 &&
|
||||
(objix_hdr.p_hdr.flags& (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) ==
|
||||
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) {
|
||||
struct spiffs_dirent *e = (struct spiffs_dirent *)user_p;
|
||||
struct spiffs_dirent *e = (struct spiffs_dirent*)user_var_p;
|
||||
e->obj_id = obj_id;
|
||||
strcpy((char *)e->name, (char *)objix_hdr.name);
|
||||
e->type = objix_hdr.type;
|
||||
@@ -833,6 +835,7 @@ struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
|
||||
0,
|
||||
spiffs_read_dir_v,
|
||||
0,
|
||||
0,
|
||||
e,
|
||||
&bix,
|
||||
&entry);
|
||||
|
||||
+38
-23
@@ -114,7 +114,8 @@ s32_t spiffs_phys_cpy(
|
||||
// @param obj_id argument object id
|
||||
// @param v visitor callback function
|
||||
// @param user_data any data, passed to the callback visitor function
|
||||
// @param user_p any pointer, passed to the callback visitor function
|
||||
// @param user_const_p any const pointer, passed to the callback visitor function
|
||||
// @param user_var_p any pointer, passed to the callback visitor function
|
||||
// @param block_ix reported block index where match was found
|
||||
// @param lu_entry reported look up index where match was found
|
||||
s32_t spiffs_obj_lu_find_entry_visitor(
|
||||
@@ -125,7 +126,8 @@ s32_t spiffs_obj_lu_find_entry_visitor(
|
||||
spiffs_obj_id obj_id,
|
||||
spiffs_visitor_f v,
|
||||
u32_t user_data,
|
||||
void *user_p,
|
||||
const void *user_const_p,
|
||||
void *user_var_p,
|
||||
spiffs_block_ix *block_ix,
|
||||
int *lu_entry) {
|
||||
s32_t res = SPIFFS_OK;
|
||||
@@ -176,7 +178,8 @@ s32_t spiffs_obj_lu_find_entry_visitor(
|
||||
cur_block,
|
||||
cur_entry,
|
||||
user_data,
|
||||
user_p);
|
||||
user_const_p,
|
||||
user_var_p);
|
||||
if (res == SPIFFS_VIS_COUNTINUE || res == SPIFFS_VIS_COUNTINUE_RELOAD) {
|
||||
if (res == SPIFFS_VIS_COUNTINUE_RELOAD) {
|
||||
res = _spiffs_rd(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
|
||||
@@ -265,10 +268,12 @@ static s32_t spiffs_obj_lu_scan_v(
|
||||
spiffs_block_ix bix,
|
||||
int ix_entry,
|
||||
u32_t user_data,
|
||||
void *user_p) {
|
||||
const void *user_const_p,
|
||||
void *user_var_p) {
|
||||
(void)bix;
|
||||
(void)user_data;
|
||||
(void)user_p;
|
||||
(void)user_const_p;
|
||||
(void)user_var_p;
|
||||
if (obj_id == SPIFFS_OBJ_ID_FREE) {
|
||||
if (ix_entry == 0) {
|
||||
fs->free_blocks++;
|
||||
@@ -369,6 +374,7 @@ s32_t spiffs_obj_lu_scan(
|
||||
spiffs_obj_lu_scan_v,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&bix,
|
||||
&entry);
|
||||
|
||||
@@ -426,7 +432,7 @@ s32_t spiffs_obj_lu_find_id(
|
||||
spiffs_block_ix *block_ix,
|
||||
int *lu_entry) {
|
||||
s32_t res = spiffs_obj_lu_find_entry_visitor(
|
||||
fs, starting_block, starting_lu_entry, SPIFFS_VIS_CHECK_ID, obj_id, 0, 0, 0, block_ix, lu_entry);
|
||||
fs, starting_block, starting_lu_entry, SPIFFS_VIS_CHECK_ID, obj_id, 0, 0, 0, 0, block_ix, lu_entry);
|
||||
if (res == SPIFFS_VIS_END) {
|
||||
res = SPIFFS_ERR_NOT_FOUND;
|
||||
}
|
||||
@@ -440,7 +446,9 @@ static s32_t spiffs_obj_lu_find_id_and_span_v(
|
||||
spiffs_block_ix bix,
|
||||
int ix_entry,
|
||||
u32_t user_data,
|
||||
void *user_p) {
|
||||
const void *user_const_p,
|
||||
void *user_var_p) {
|
||||
(void)user_var_p;
|
||||
s32_t res;
|
||||
spiffs_page_header ph;
|
||||
spiffs_page_ix pix = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, bix, ix_entry);
|
||||
@@ -451,7 +459,7 @@ static s32_t spiffs_obj_lu_find_id_and_span_v(
|
||||
ph.span_ix == (spiffs_span_ix)user_data &&
|
||||
(ph.flags & (SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_USED)) == SPIFFS_PH_FLAG_DELET &&
|
||||
!((obj_id & SPIFFS_OBJ_ID_IX_FLAG) && (ph.flags & SPIFFS_PH_FLAG_IXDELE) == 0 && ph.span_ix == 0) &&
|
||||
(user_p == 0 || *((spiffs_page_ix *)user_p) != pix)) {
|
||||
(user_const_p == 0 || *((const spiffs_page_ix*)user_const_p) != pix)) {
|
||||
return SPIFFS_OK;
|
||||
} else {
|
||||
return SPIFFS_VIS_COUNTINUE;
|
||||
@@ -478,6 +486,7 @@ s32_t spiffs_obj_lu_find_id_and_span(
|
||||
spiffs_obj_lu_find_id_and_span_v,
|
||||
(u32_t)spix,
|
||||
exclusion_pix ? &exclusion_pix : 0,
|
||||
0,
|
||||
&bix,
|
||||
&entry);
|
||||
|
||||
@@ -517,6 +526,7 @@ s32_t spiffs_obj_lu_find_id_and_span_by_phdr(
|
||||
spiffs_obj_lu_find_id_and_span_v,
|
||||
(u32_t)spix,
|
||||
exclusion_pix ? &exclusion_pix : 0,
|
||||
0,
|
||||
&bix,
|
||||
&entry);
|
||||
|
||||
@@ -690,7 +700,7 @@ s32_t spiffs_page_delete(
|
||||
s32_t spiffs_object_create(
|
||||
spiffs *fs,
|
||||
spiffs_obj_id obj_id,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
spiffs_obj_type type,
|
||||
spiffs_page_ix *objix_hdr_pix) {
|
||||
s32_t res = SPIFFS_OK;
|
||||
@@ -721,7 +731,7 @@ s32_t spiffs_object_create(
|
||||
oix_hdr.p_hdr.flags = 0xff & ~(SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_INDEX | SPIFFS_PH_FLAG_USED);
|
||||
oix_hdr.type = type;
|
||||
oix_hdr.size = SPIFFS_UNDEFINED_LEN; // keep ones so we can update later without wasting this page
|
||||
strncpy((char *)&oix_hdr.name, (char *)name, SPIFFS_OBJ_NAME_LEN);
|
||||
strncpy((char*)&oix_hdr.name, (const char*)name, SPIFFS_OBJ_NAME_LEN);
|
||||
|
||||
|
||||
// update page
|
||||
@@ -748,7 +758,7 @@ s32_t spiffs_object_update_index_hdr(
|
||||
spiffs_obj_id obj_id,
|
||||
spiffs_page_ix objix_hdr_pix,
|
||||
u8_t *new_objix_hdr_data,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
u32_t size,
|
||||
spiffs_page_ix *new_pix) {
|
||||
s32_t res = SPIFFS_OK;
|
||||
@@ -772,7 +782,7 @@ s32_t spiffs_object_update_index_hdr(
|
||||
|
||||
// change name
|
||||
if (name) {
|
||||
strncpy((char *)objix_hdr->name, (char *)name, SPIFFS_OBJ_NAME_LEN);
|
||||
strncpy((char*)objix_hdr->name, (const char*)name, SPIFFS_OBJ_NAME_LEN);
|
||||
}
|
||||
if (size) {
|
||||
objix_hdr->size = size;
|
||||
@@ -1336,8 +1346,10 @@ static s32_t spiffs_object_find_object_index_header_by_name_v(
|
||||
spiffs_block_ix bix,
|
||||
int ix_entry,
|
||||
u32_t user_data,
|
||||
void *user_p) {
|
||||
const void *user_const_p,
|
||||
void *user_var_p) {
|
||||
(void)user_data;
|
||||
(void)user_var_p;
|
||||
s32_t res;
|
||||
spiffs_page_object_ix_header objix_hdr;
|
||||
spiffs_page_ix pix = SPIFFS_OBJ_LOOKUP_ENTRY_TO_PIX(fs, bix, ix_entry);
|
||||
@@ -1351,7 +1363,7 @@ static s32_t spiffs_object_find_object_index_header_by_name_v(
|
||||
if (objix_hdr.p_hdr.span_ix == 0 &&
|
||||
(objix_hdr.p_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) ==
|
||||
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) {
|
||||
if (strcmp((char *)user_p, (char *)objix_hdr.name) == 0) {
|
||||
if (strcmp((const char*)user_const_p, (char*)objix_hdr.name) == 0) {
|
||||
return SPIFFS_OK;
|
||||
}
|
||||
}
|
||||
@@ -1362,7 +1374,7 @@ static s32_t spiffs_object_find_object_index_header_by_name_v(
|
||||
// Finds object index header page by name
|
||||
s32_t spiffs_object_find_object_index_header_by_name(
|
||||
spiffs *fs,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
spiffs_page_ix *pix) {
|
||||
s32_t res;
|
||||
spiffs_block_ix bix;
|
||||
@@ -1376,6 +1388,7 @@ s32_t spiffs_object_find_object_index_header_by_name(
|
||||
spiffs_object_find_object_index_header_by_name_v,
|
||||
0,
|
||||
name,
|
||||
0,
|
||||
&bix,
|
||||
&entry);
|
||||
|
||||
@@ -1702,10 +1715,11 @@ typedef struct {
|
||||
} spiffs_free_obj_id_state;
|
||||
|
||||
static s32_t spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
||||
u32_t user_data, void *user_p) {
|
||||
u32_t user_data, const void *user_const_p, void *user_var_p) {
|
||||
(void)user_var_p;
|
||||
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED) {
|
||||
spiffs_obj_id min_obj_id = user_data;
|
||||
u8_t *conflicting_name = (u8_t *)user_p;
|
||||
const u8_t *conflicting_name = (const u8_t*)user_const_p;
|
||||
|
||||
// if conflicting name parameter is given, also check if this name is found in object index hdrs
|
||||
if (conflicting_name && (id & SPIFFS_OBJ_ID_IX_FLAG)) {
|
||||
@@ -1718,7 +1732,7 @@ static s32_t spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id i
|
||||
if (objix_hdr.p_hdr.span_ix == 0 &&
|
||||
(objix_hdr.p_hdr.flags & (SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_FINAL | SPIFFS_PH_FLAG_IXDELE)) ==
|
||||
(SPIFFS_PH_FLAG_DELET | SPIFFS_PH_FLAG_IXDELE)) {
|
||||
if (strcmp((char *)user_p, (char *)objix_hdr.name) == 0) {
|
||||
if (strcmp((const char*)user_const_p, (char*)objix_hdr.name) == 0) {
|
||||
return SPIFFS_ERR_CONFLICTING_NAME;
|
||||
}
|
||||
}
|
||||
@@ -1735,11 +1749,12 @@ static s32_t spiffs_obj_lu_find_free_obj_id_bitmap_v(spiffs *fs, spiffs_obj_id i
|
||||
}
|
||||
|
||||
static s32_t spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
||||
u32_t user_data, void *user_p) {
|
||||
u32_t user_data, const void *user_const_p, void *user_var_p) {
|
||||
(void)user_data;
|
||||
(void)user_var_p;
|
||||
if (id != SPIFFS_OBJ_ID_FREE && id != SPIFFS_OBJ_ID_DELETED && (id & SPIFFS_OBJ_ID_IX_FLAG)) {
|
||||
s32_t res;
|
||||
spiffs_free_obj_id_state *state = (spiffs_free_obj_id_state *)user_p;
|
||||
const spiffs_free_obj_id_state *state = (const spiffs_free_obj_id_state*)user_const_p;
|
||||
spiffs_page_object_ix_header objix_hdr;
|
||||
|
||||
res = _spiffs_rd(fs, SPIFFS_OP_T_OBJ_LU2 | SPIFFS_OP_C_READ,
|
||||
@@ -1768,7 +1783,7 @@ static s32_t spiffs_obj_lu_find_free_obj_id_compact_v(spiffs *fs, spiffs_obj_id
|
||||
// object ids cannot fit into a work buffer, these are grouped. When a group containing free
|
||||
// object ids is found, the object lu is again scanned for object ids within group and bitmasked.
|
||||
// Finally, the bitmask is searched for a free id
|
||||
s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *conflicting_name) {
|
||||
s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, const u8_t *conflicting_name) {
|
||||
s32_t res = SPIFFS_OK;
|
||||
u32_t max_objects = (fs->block_count * SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs)) / 2;
|
||||
spiffs_free_obj_id_state state;
|
||||
@@ -1788,7 +1803,7 @@ s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *co
|
||||
|
||||
memset(fs->work, 0, SPIFFS_CFG_LOG_PAGE_SZ(fs));
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_obj_lu_find_free_obj_id_bitmap_v, state.min_obj_id,
|
||||
conflicting_name, 0, 0);
|
||||
conflicting_name, 0, 0, 0);
|
||||
if (res == SPIFFS_VIS_END) res = SPIFFS_OK;
|
||||
SPIFFS_CHECK_RES(res);
|
||||
// traverse bitmask until found free obj_id
|
||||
@@ -1852,7 +1867,7 @@ s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *co
|
||||
SPIFFS_DBG("free_obj_id: COMP min:%04x max:%04x compact:%i\n", state.min_obj_id, state.max_obj_id, state.compaction);
|
||||
|
||||
memset(fs->work, 0, SPIFFS_CFG_LOG_PAGE_SZ(fs));
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_obj_lu_find_free_obj_id_compact_v, 0, &state, 0, 0);
|
||||
res = spiffs_obj_lu_find_entry_visitor(fs, 0, 0, 0, 0, spiffs_obj_lu_find_free_obj_id_compact_v, 0, &state, 0, 0, 0);
|
||||
if (res == SPIFFS_VIS_END) res = SPIFFS_OK;
|
||||
SPIFFS_CHECK_RES(res);
|
||||
state.conflicting_name = 0; // searched for conflicting name once, no need to do it again
|
||||
|
||||
@@ -460,7 +460,7 @@ typedef struct __attribute(( packed )) {
|
||||
|
||||
// callback func for object lookup visitor
|
||||
typedef s32_t (*spiffs_visitor_f)(spiffs *fs, spiffs_obj_id id, spiffs_block_ix bix, int ix_entry,
|
||||
u32_t user_data, void *user_p);
|
||||
u32_t user_data, const void *user_const_p, void *user_var_p);
|
||||
|
||||
|
||||
#if SPIFFS_CACHE
|
||||
@@ -522,7 +522,8 @@ s32_t spiffs_obj_lu_find_entry_visitor(
|
||||
spiffs_obj_id obj_id,
|
||||
spiffs_visitor_f v,
|
||||
u32_t user_data,
|
||||
void *user_p,
|
||||
const void *user_const_p,
|
||||
void *user_var_p,
|
||||
spiffs_block_ix *block_ix,
|
||||
int *lu_entry);
|
||||
|
||||
@@ -538,7 +539,7 @@ s32_t spiffs_obj_lu_scan(
|
||||
s32_t spiffs_obj_lu_find_free_obj_id(
|
||||
spiffs *fs,
|
||||
spiffs_obj_id *obj_id,
|
||||
u8_t *conflicting_name);
|
||||
const u8_t *conflicting_name);
|
||||
|
||||
s32_t spiffs_obj_lu_find_free(
|
||||
spiffs *fs,
|
||||
@@ -599,7 +600,7 @@ s32_t spiffs_page_delete(
|
||||
s32_t spiffs_object_create(
|
||||
spiffs *fs,
|
||||
spiffs_obj_id obj_id,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
spiffs_obj_type type,
|
||||
spiffs_page_ix *objix_hdr_pix);
|
||||
|
||||
@@ -609,7 +610,7 @@ s32_t spiffs_object_update_index_hdr(
|
||||
spiffs_obj_id obj_id,
|
||||
spiffs_page_ix objix_hdr_pix,
|
||||
u8_t *new_objix_hdr_data,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
u32_t size,
|
||||
spiffs_page_ix *new_pix);
|
||||
|
||||
@@ -661,7 +662,7 @@ s32_t spiffs_object_truncate(
|
||||
|
||||
s32_t spiffs_object_find_object_index_header_by_name(
|
||||
spiffs *fs,
|
||||
u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
const u8_t name[SPIFFS_OBJ_NAME_LEN],
|
||||
spiffs_page_ix *pix);
|
||||
|
||||
// ---------------
|
||||
|
||||
Reference in New Issue
Block a user