Skip to content

Commit 1683b12

Browse files
Lan-Hekaryigrr
authored andcommitted
SPIFFS: update to f5e26c4, fixes #3612 (#3623)
1 parent 1ee17e5 commit 1683b12

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

cores/esp8266/spiffs/spiffs_hydrogen.c

-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ s32_t SPIFFS_write(spiffs *fs, spiffs_file fh, void *buf, s32_t len) {
481481
if ((fd->flags & SPIFFS_O_APPEND)) {
482482
fd->fdoffset = fd->size == SPIFFS_UNDEFINED_LEN ? 0 : fd->size;
483483
}
484-
485484
offset = fd->fdoffset;
486485

487486
#if SPIFFS_CACHE_WR

cores/esp8266/spiffs/spiffs_nucleus.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -1061,12 +1061,18 @@ void spiffs_cb_object_event(
10611061
#if SPIFFS_TEMPORAL_FD_CACHE
10621062
if (cur_fd->score == 0) continue; // never used fd
10631063
#endif
1064-
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);
1064+
SPIFFS_DBG(" callback: setting fd "_SPIPRIfd":"_SPIPRIid"(fdoffs:"_SPIPRIi" offs:"_SPIPRIi") objix_hdr_pix to "_SPIPRIpg", size:"_SPIPRIi"\n",
1065+
SPIFFS_FH_OFFS(fs, cur_fd->file_nbr), cur_fd->obj_id, cur_fd->fdoffset, cur_fd->offset, new_pix, new_size);
10651066
cur_fd->objix_hdr_pix = new_pix;
10661067
if (new_size != 0) {
10671068
// update size and offsets for fds to this file
10681069
cur_fd->size = new_size;
10691070
u32_t act_new_size = new_size == SPIFFS_UNDEFINED_LEN ? 0 : new_size;
1071+
#if SPIFFS_CACHE_WR
1072+
if (act_new_size > 0 && cur_fd->cache_page) {
1073+
act_new_size = MAX(act_new_size, cur_fd->cache_page->offset + cur_fd->cache_page->size);
1074+
}
1075+
#endif
10701076
if (cur_fd->offset > act_new_size) {
10711077
cur_fd->offset = act_new_size;
10721078
}

cores/esp8266/spiffs/spiffs_nucleus.h

+19-3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@
141141
#define SPIFFS_OBJ_ID_DELETED ((spiffs_obj_id)0)
142142
#define SPIFFS_OBJ_ID_FREE ((spiffs_obj_id)-1)
143143

144+
145+
146+
#if defined(__GNUC__) || defined(__clang__)
147+
/* For GCC and clang */
148+
#define SPIFFS_PACKED __attribute__((packed))
149+
#elif defined(__ICCARM__) || defined(__CC_ARM)
150+
/* For IAR ARM and Keil MDK-ARM compilers */
151+
#define SPIFFS_PACKED
152+
153+
#else
154+
/* Unknown compiler */
155+
#define SPIFFS_PACKED
156+
#endif
157+
158+
159+
144160
#if SPIFFS_USE_MAGIC
145161
#if !SPIFFS_USE_MAGIC_LENGTH
146162
#define SPIFFS_MAGIC(fs, bix) \
@@ -464,7 +480,7 @@ typedef struct {
464480
// page header, part of each page except object lookup pages
465481
// NB: this is always aligned when the data page is an object index,
466482
// as in this case struct spiffs_page_object_ix is used
467-
typedef struct __attribute(( packed )) {
483+
typedef struct SPIFFS_PACKED {
468484
// object id
469485
spiffs_obj_id obj_id;
470486
// object span index
@@ -474,7 +490,7 @@ typedef struct __attribute(( packed )) {
474490
} spiffs_page_header;
475491

476492
// object index header page header
477-
typedef struct __attribute(( packed ))
493+
typedef struct SPIFFS_PACKED
478494
#if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
479495
__attribute(( aligned(sizeof(spiffs_page_ix)) ))
480496
#endif
@@ -496,7 +512,7 @@ typedef struct __attribute(( packed ))
496512
} spiffs_page_object_ix_header;
497513

498514
// object index page header
499-
typedef struct __attribute(( packed )) {
515+
typedef struct SPIFFS_PACKED {
500516
spiffs_page_header p_hdr;
501517
u8_t _align[4 - ((sizeof(spiffs_page_header)&3)==0 ? 4 : (sizeof(spiffs_page_header)&3))];
502518
} spiffs_page_object_ix;

0 commit comments

Comments
 (0)