Skip to content

Fix the issue #3612 , Updating the SPIFFS to f5e26c4 #3623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cores/esp8266/spiffs/spiffs_hydrogen.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
if ((fd->flags & SPIFFS_O_APPEND)) {
fd->fdoffset = fd->size == SPIFFS_UNDEFINED_LEN ? 0 : fd->size;
}

offset = fd->fdoffset;

#if SPIFFS_CACHE_WR
Expand Down
8 changes: 7 additions & 1 deletion cores/esp8266/spiffs/spiffs_nucleus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,18 @@ void spiffs_cb_object_event(
#if SPIFFS_TEMPORAL_FD_CACHE
if (cur_fd->score == 0) continue; // never used fd
#endif
SPIFFS_DBG(" callback: setting fd "_SPIPRIfd":"_SPIPRIid"(fdoffs:"_SPIPRIi" offs:"_SPIPRIi") objix_hdr_pix to "_SPIPRIpg", size:"_SPIPRIi"\n", SPIFFS_FH_OFFS(fs, cur_fd->file_nbr), cur_fd->obj_id, cur_fd->fdoffset, cur_fd->offset, new_pix, new_size);
SPIFFS_DBG(" callback: setting fd "_SPIPRIfd":"_SPIPRIid"(fdoffs:"_SPIPRIi" offs:"_SPIPRIi") objix_hdr_pix to "_SPIPRIpg", size:"_SPIPRIi"\n",
SPIFFS_FH_OFFS(fs, cur_fd->file_nbr), cur_fd->obj_id, cur_fd->fdoffset, cur_fd->offset, new_pix, new_size);
cur_fd->objix_hdr_pix = new_pix;
if (new_size != 0) {
// update size and offsets for fds to this file
cur_fd->size = new_size;
u32_t act_new_size = new_size == SPIFFS_UNDEFINED_LEN ? 0 : new_size;
#if SPIFFS_CACHE_WR
if (act_new_size > 0 && cur_fd->cache_page) {
act_new_size = MAX(act_new_size, cur_fd->cache_page->offset + cur_fd->cache_page->size);
}
#endif
if (cur_fd->offset > act_new_size) {
cur_fd->offset = act_new_size;
}
Expand Down
22 changes: 19 additions & 3 deletions cores/esp8266/spiffs/spiffs_nucleus.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@
#define SPIFFS_OBJ_ID_DELETED ((spiffs_obj_id)0)
#define SPIFFS_OBJ_ID_FREE ((spiffs_obj_id)-1)



#if defined(__GNUC__) || defined(__clang__)
/* For GCC and clang */
#define SPIFFS_PACKED __attribute__((packed))
#elif defined(__ICCARM__) || defined(__CC_ARM)
/* For IAR ARM and Keil MDK-ARM compilers */
#define SPIFFS_PACKED

#else
/* Unknown compiler */
#define SPIFFS_PACKED
#endif



#if SPIFFS_USE_MAGIC
#if !SPIFFS_USE_MAGIC_LENGTH
#define SPIFFS_MAGIC(fs, bix) \
Expand Down Expand Up @@ -464,7 +480,7 @@ typedef struct {
// 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
typedef struct __attribute(( packed )) {
typedef struct SPIFFS_PACKED {
// object id
spiffs_obj_id obj_id;
// object span index
Expand All @@ -474,7 +490,7 @@ typedef struct __attribute(( packed )) {
} spiffs_page_header;

// object index header page header
typedef struct __attribute(( packed ))
typedef struct SPIFFS_PACKED
#if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
__attribute(( aligned(sizeof(spiffs_page_ix)) ))
#endif
Expand All @@ -496,7 +512,7 @@ typedef struct __attribute(( packed ))
} spiffs_page_object_ix_header;

// object index page header
typedef struct __attribute(( packed )) {
typedef struct SPIFFS_PACKED {
spiffs_page_header p_hdr;
u8_t _align[4 - ((sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3))];
} spiffs_page_object_ix;
Expand Down