fs/spiffs: I have been test with apps/examples/fstest which provides a good exercise but of the FS internals but not of the user interface. I build an SPIFFS aware NSH configuration and found and fixed a number of glaring usability errors: (1) Missing logic to stat the SPIFFS root directory, (2) Confusion in use to two similarly named struct field... caused files to be unexpectedly deleted. (3) Fixed a sempahore deadlock condition. And (5) Fix /procfs/mount. It was unaware of the SPIFFS file system type.
This commit is contained in:
parent
e90723307e
commit
6a12213fbb
@ -108,6 +108,12 @@ FAR const char *fs_gettype(FAR struct statfs *statbuf)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_SPIFFS
|
||||
case SPIFFS_SUPER_MAGIC:
|
||||
fstype = "spiffs";
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NFS
|
||||
case NFS_SUPER_MAGIC:
|
||||
fstype = "nfs";
|
||||
|
@ -1312,16 +1312,16 @@ int spiffs_page_delete(FAR struct spiffs_s *fs, int16_t pgndx)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_create
|
||||
* Name: spiffs_fobj_create
|
||||
*
|
||||
* Description:
|
||||
* Create an object index header page with empty index and undefined length
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_create(FAR struct spiffs_s *fs,
|
||||
int16_t objid, const uint8_t name[],
|
||||
uint8_t type, FAR int16_t *objhdr_pgndx)
|
||||
int spiffs_fobj_create(FAR struct spiffs_s *fs,
|
||||
int16_t objid, const uint8_t name[],
|
||||
uint8_t type, FAR int16_t *objhdr_pgndx)
|
||||
{
|
||||
struct spiffs_pgobj_ndxheader_s objndx_hdr;
|
||||
int16_t blkndx;
|
||||
@ -1389,10 +1389,10 @@ int spiffs_object_create(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)&objndx_hdr,
|
||||
SPIFFS_EV_NDXNEW, objid, 0,
|
||||
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry),
|
||||
SPIFFS_UNDEFINED_LEN);
|
||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)&objndx_hdr,
|
||||
SPIFFS_EV_NDXNEW, objid, 0,
|
||||
SPIFFS_OBJ_LOOKUP_ENTRY_TO_PGNDX(fs, blkndx, entry),
|
||||
SPIFFS_UNDEFINED_LEN);
|
||||
|
||||
if (objhdr_pgndx)
|
||||
{
|
||||
@ -1403,7 +1403,7 @@ int spiffs_object_create(FAR struct spiffs_s *fs,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_update_index_hdr
|
||||
* Name: spiffs_fobj_update_ndxhdr
|
||||
*
|
||||
* Description:
|
||||
* Update object index header with any combination of name/size/index.
|
||||
@ -1413,12 +1413,12 @@ int spiffs_object_create(FAR struct spiffs_s *fs,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj,
|
||||
int16_t objid, int16_t objhdr_pgndx,
|
||||
FAR uint8_t *new_objhdr_data,
|
||||
const uint8_t name[],
|
||||
uint32_t size, FAR int16_t *new_pgndx)
|
||||
int spiffs_fobj_update_ndxhdr(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj,
|
||||
int16_t objid, int16_t objhdr_pgndx,
|
||||
FAR uint8_t *new_objhdr_data,
|
||||
const uint8_t name[],
|
||||
uint32_t size, FAR int16_t *new_pgndx)
|
||||
{
|
||||
FAR struct spiffs_pgobj_ndxheader_s *objhdr;
|
||||
int16_t new_objhdr_pgndx;
|
||||
@ -1484,11 +1484,11 @@ int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
|
||||
|
||||
/* callback on object index update */
|
||||
|
||||
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)objhdr,
|
||||
new_objhdr_data ? SPIFFS_EV_NDXUPD :
|
||||
SPIFFS_EV_NDXUPD_HDR, objid,
|
||||
objhdr->phdr.spndx, new_objhdr_pgndx,
|
||||
objhdr->size);
|
||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)objhdr,
|
||||
new_objhdr_data ? SPIFFS_EV_NDXUPD :
|
||||
SPIFFS_EV_NDXUPD_HDR, objid,
|
||||
objhdr->phdr.spndx, new_objhdr_pgndx,
|
||||
objhdr->size);
|
||||
if (fobj != NULL)
|
||||
{
|
||||
fobj->objhdr_pgndx = new_objhdr_pgndx; /* If this is not in the
|
||||
@ -1500,16 +1500,16 @@ int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_event
|
||||
* Name: spiffs_fobj_event
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void spiffs_object_event(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_page_objndx_s *objndx,
|
||||
int ev, int16_t objid_raw, int16_t spndx,
|
||||
int16_t new_pgndx, uint32_t new_size)
|
||||
void spiffs_fobj_event(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_page_objndx_s *objndx,
|
||||
int ev, int16_t objid_raw, int16_t spndx,
|
||||
int16_t new_pgndx, uint32_t new_size)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG_FS_INFO
|
||||
FAR static const char *evname[] =
|
||||
@ -1626,16 +1626,15 @@ void spiffs_object_event(FAR struct spiffs_s *fs,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_open_bypage
|
||||
* Name: spiffs_fobj_open_bypage
|
||||
*
|
||||
* Description:
|
||||
* Open object by page index
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
||||
FAR struct spiffs_file_s *fobj, uint16_t flags,
|
||||
uint16_t mode)
|
||||
int spiffs_fobj_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
||||
FAR struct spiffs_file_s *fobj)
|
||||
{
|
||||
struct spiffs_pgobj_ndxheader_s objndx_hdr;
|
||||
off_t physoff;
|
||||
@ -1662,13 +1661,16 @@ int spiffs_object_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
||||
ret = spiffs_cache_read(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, 0,
|
||||
physoff, sizeof(int16_t), (FAR uint8_t *)&objid);
|
||||
|
||||
/* Fill in the parts of the open file structure known only to the core
|
||||
* logic.
|
||||
*/
|
||||
|
||||
fobj->objhdr_pgndx = pgndx;
|
||||
fobj->size = objndx_hdr.size;
|
||||
fobj->offset = 0;
|
||||
fobj->objndx_pgndx = pgndx;
|
||||
fobj->objndx_spndx = 0;
|
||||
fobj->objid = objid;
|
||||
fobj->flags = flags;
|
||||
|
||||
ret = spiffs_validate_objndx(&objndx_hdr.phdr, fobj->objid, 0);
|
||||
if (ret < 0)
|
||||
@ -1682,7 +1684,7 @@ int spiffs_object_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_append
|
||||
* Name: spiffs_fobj_append
|
||||
*
|
||||
* Description:
|
||||
* Append to object. Deep current object index (header) page in fs->work
|
||||
@ -1690,9 +1692,9 @@ int spiffs_object_open_bypage(FAR struct spiffs_s *fs, int16_t pgndx,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t offset,
|
||||
FAR uint8_t *data, size_t len)
|
||||
int spiffs_fobj_append(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t offset,
|
||||
FAR uint8_t *data, size_t len)
|
||||
{
|
||||
struct spiffs_page_header_s phdr;
|
||||
FAR struct spiffs_pgobj_ndxheader_s *objhdr;
|
||||
@ -1795,14 +1797,14 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
{
|
||||
/* Was a nonempty object, update to new page */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
fs->work, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
fs->work, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -1835,20 +1837,20 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||
objndx->phdr.spndx, cur_objndx_pgndx,
|
||||
0);
|
||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||
objndx->phdr.spndx, cur_objndx_pgndx,
|
||||
0);
|
||||
|
||||
/* Update length in object index header page */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -1924,10 +1926,10 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
memset(fs->work, 0xff, SPIFFS_GEO_PAGE_SIZE(fs));
|
||||
memcpy(fs->work, &phdr, sizeof(struct spiffs_page_header_s));
|
||||
|
||||
spiffs_object_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXNEW, fobj->objid,
|
||||
cur_objndx_spndx, cur_objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXNEW, fobj->objid,
|
||||
cur_objndx_spndx, cur_objndx_pgndx, 0);
|
||||
|
||||
finfo("objid=%04x create objndx page, %04x:%04x, written=%d\n",
|
||||
fobj->objid, cur_objndx_pgndx, cur_objndx_spndx,
|
||||
@ -2133,17 +2135,17 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
return ret2;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||
objndx->phdr.spndx, cur_objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||
objndx->phdr.spndx, cur_objndx_pgndx, 0);
|
||||
|
||||
/* Update size in object header index page */
|
||||
|
||||
ret2 = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
ret2 = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
|
||||
finfo("objid=%04x store new size II %d in objhdr, %04x:%04x, "
|
||||
"written=%d, ret=%d\n",
|
||||
@ -2152,7 +2154,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
|
||||
if (ret2 < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret2);
|
||||
return ret2;
|
||||
}
|
||||
@ -2189,11 +2191,11 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
return ret2;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD_HDR, fobj->objid,
|
||||
objhdr->phdr.spndx, cur_objndx_pgndx,
|
||||
objhdr->size);
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD_HDR, fobj->objid,
|
||||
objhdr->phdr.spndx, cur_objndx_pgndx,
|
||||
objhdr->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2201,11 +2203,10 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
* copy.
|
||||
*/
|
||||
|
||||
ret2 = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
fs->work, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
ret2 = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, fs->work, 0,
|
||||
offset + written,
|
||||
&new_objhdr_page);
|
||||
|
||||
finfo("objid=%04x store modified objhdr page, %04x:%04x, "
|
||||
"written=%d\n",
|
||||
@ -2213,7 +2214,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
|
||||
if (ret2 < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret2);
|
||||
return ret2;
|
||||
}
|
||||
@ -2224,7 +2225,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_modify
|
||||
* Name: spiffs_fobj_modify
|
||||
*
|
||||
* Description:
|
||||
* Modify object. Keep current object index (header) page in fs->work
|
||||
@ -2232,7 +2233,7 @@ int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t offset,
|
||||
FAR uint8_t *data, size_t len)
|
||||
{
|
||||
@ -2296,17 +2297,17 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
{
|
||||
/* Store previous object index header page */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
fs->work, 0, 0,
|
||||
&new_objhdr_pgndx);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
fs->work, 0, 0,
|
||||
&new_objhdr_pgndx);
|
||||
|
||||
finfo("Store modified objhdr page, %04x:%04x, written=%d\n",
|
||||
new_objhdr_pgndx, 0, written);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -2338,7 +2339,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs,
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)objndx,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid,
|
||||
objndx->phdr.spndx, new_objndx_pgndx,
|
||||
@ -2632,24 +2633,24 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
return ret2;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)objndx,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid, objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)objndx,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid, objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wrote within object index header page */
|
||||
|
||||
ret2 = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, fs->work, 0,
|
||||
0, &new_objhdr_pgndx);
|
||||
ret2 = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, fs->work, 0, 0,
|
||||
&new_objhdr_pgndx);
|
||||
|
||||
finfo("Store modified objhdr page, %04x:%04x, written=%d\n",
|
||||
new_objhdr_pgndx, 0, written);
|
||||
|
||||
if (ret2 < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret2);
|
||||
return ret2;
|
||||
}
|
||||
@ -2700,7 +2701,7 @@ int spiffs_find_objhdr_pgndx(FAR struct spiffs_s *fs,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spiffs_object_truncate
|
||||
* Name: spiffs_fobj_truncate
|
||||
*
|
||||
* Description:
|
||||
* Truncates object to new size. If new size is NULL, object may be removed
|
||||
@ -2708,9 +2709,9 @@ int spiffs_find_objhdr_pgndx(FAR struct spiffs_s *fs,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t new_size,
|
||||
bool remove_full)
|
||||
int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t new_size,
|
||||
bool remove_full)
|
||||
{
|
||||
FAR struct spiffs_pgobj_ndxheader_s *objhdr;
|
||||
FAR struct spiffs_page_objndx_s *objndx;
|
||||
@ -2818,8 +2819,8 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, NULL, SPIFFS_EV_NDXDEL, fobj->objid,
|
||||
objndx->phdr.spndx, objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs, NULL, SPIFFS_EV_NDXDEL, fobj->objid,
|
||||
objndx->phdr.spndx, objndx_pgndx, 0);
|
||||
if (prev_objndx_spndx > 0)
|
||||
{
|
||||
/* Update object index header page, unless we totally want
|
||||
@ -2840,14 +2841,14 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
finfo("Update objndx hdr page %04x:%04x to size=%d\n",
|
||||
fobj->objhdr_pgndx, prev_objndx_spndx, cur_size);
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj,
|
||||
fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
0, 0, cur_size,
|
||||
&new_objhdr_pgndx);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj,
|
||||
fobj->objid,
|
||||
fobj->objhdr_pgndx,
|
||||
0, 0, cur_size,
|
||||
&new_objhdr_pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -3115,8 +3116,8 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, NULL, SPIFFS_EV_NDXDEL, fobj->objid,
|
||||
0, objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs, NULL, SPIFFS_EV_NDXDEL, fobj->objid,
|
||||
0, objndx_pgndx, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3129,13 +3130,13 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
SPIFFS_GEO_PAGE_SIZE(fs) -
|
||||
sizeof(struct spiffs_pgobj_ndxheader_s));
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
objndx_pgndx, fs->work,
|
||||
0, SPIFFS_UNDEFINED_LEN,
|
||||
&new_objhdr_pgndx);
|
||||
if (ret < 0)
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
objndx_pgndx, fs->work,
|
||||
0, SPIFFS_UNDEFINED_LEN,
|
||||
&new_objhdr_pgndx);
|
||||
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -3147,12 +3148,12 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
|
||||
finfo("Update object index header page with indices and size\n");
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
objndx_pgndx, fs->work, 0,
|
||||
cur_size, &new_objhdr_pgndx);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
objndx_pgndx, fs->work, 0,
|
||||
cur_size, &new_objhdr_pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n",
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
@ -3183,9 +3184,9 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, (FAR struct spiffs_page_objndx_s *)objhdr,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid, objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs, (FAR struct spiffs_page_objndx_s *)objhdr,
|
||||
SPIFFS_EV_NDXUPD, fobj->objid, objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
|
||||
finfo("Store modified objndx page, %04x:%04x\n",
|
||||
new_objndx_pgndx, cur_objndx_spndx);
|
||||
@ -3196,12 +3197,12 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
|
||||
/* Update object index header page with new size */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0, 0,
|
||||
cur_size, &new_objhdr_pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -446,28 +446,27 @@ int spiffs_page_move(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_page_header_s *page_hdr, int16_t src_pgndx,
|
||||
FAR int16_t *dst_pgndx);
|
||||
int spiffs_page_delete(FAR struct spiffs_s *fs, int16_t pgndx);
|
||||
int spiffs_object_create(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_create(FAR struct spiffs_s *fs,
|
||||
int16_t objid, const uint8_t name[], uint8_t type,
|
||||
FAR int16_t *objhdr_pgndx);
|
||||
int spiffs_object_update_index_hdr(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_update_ndxhdr(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, int16_t objid, int16_t objhdr_pgndx,
|
||||
FAR uint8_t *new_objhdr_data, const uint8_t name[],
|
||||
uint32_t size, FAR int16_t *new_pgndx);
|
||||
void spiffs_object_event(FAR struct spiffs_s *fs,
|
||||
void spiffs_fobj_event(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_page_objndx_s * objndx, int ev, int16_t objid,
|
||||
int16_t spndx, int16_t new_pgndx, uint32_t new_size);
|
||||
int spiffs_object_open_bypage(FAR struct spiffs_s *fs,
|
||||
int16_t pgndx, FAR struct spiffs_file_s *f, uint16_t flags,
|
||||
uint16_t mode);
|
||||
int spiffs_object_append(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_open_bypage(FAR struct spiffs_s *fs,
|
||||
int16_t pgndx, FAR struct spiffs_file_s *f);
|
||||
int spiffs_fobj_append(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t offset, FAR uint8_t *data,
|
||||
size_t len);
|
||||
ssize_t spiffs_object_read(FAR struct spiffs_s *fs, FAR
|
||||
FAR struct spiffs_file_s *fobj, off_t offset, size_t len,
|
||||
FAR uint8_t *dest);
|
||||
int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_truncate(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t new_size, bool remove_full);
|
||||
int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
int spiffs_fobj_modify(FAR struct spiffs_s *fs,
|
||||
FAR struct spiffs_file_s *fobj, off_t offset, FAR uint8_t *data,
|
||||
size_t len);
|
||||
int spiffs_find_objhdr_pgndx(FAR struct spiffs_s *fs,
|
||||
|
@ -698,19 +698,19 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)&phdr,
|
||||
SPIFFS_EV_NDXMOV, id,
|
||||
phdr.spndx, new_pgndx, 0);
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)&phdr,
|
||||
SPIFFS_EV_NDXMOV, id,
|
||||
phdr.spndx, new_pgndx, 0);
|
||||
|
||||
/* Move wipes obj_lu, reload it */
|
||||
|
||||
ret = spiffs_cache_read(fs,
|
||||
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
|
||||
0,
|
||||
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
|
||||
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
|
||||
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work);
|
||||
SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ,
|
||||
0,
|
||||
blkndx * SPIFFS_GEO_BLOCK_SIZE(fs) +
|
||||
SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page),
|
||||
SPIFFS_GEO_PAGE_SIZE(fs), fs->lu_work);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_cache_read() failed: %d\n", ret);
|
||||
@ -730,13 +730,13 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
ret = spiffs_page_delete(fs, cur_pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_event() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_event() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs, NULL,
|
||||
SPIFFS_EV_NDXDEL, id,
|
||||
phdr.spndx, cur_pgndx, 0);
|
||||
spiffs_fobj_event(fs, NULL,
|
||||
SPIFFS_EV_NDXDEL, id,
|
||||
phdr.spndx, cur_pgndx, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -784,7 +784,7 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
(FAR uint8_t *)&phdr);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_event() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_event() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -794,9 +794,9 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
spiffs_gcinfo("Find objndx spndx=%04x\n", gc.cur_objndx_spndx);
|
||||
|
||||
ret = spiffs_objlu_find_id_and_span(fs,
|
||||
gc.cur_objid | SPIFFS_OBJID_NDXFLAG,
|
||||
gc.cur_objndx_spndx, 0,
|
||||
&objndx_pgndx);
|
||||
gc.cur_objid | SPIFFS_OBJID_NDXFLAG,
|
||||
gc.cur_objndx_spndx, 0,
|
||||
&objndx_pgndx);
|
||||
if (ret == -ENOENT)
|
||||
{
|
||||
/* On borked systems we might get an ERR_NOT_FOUND here -
|
||||
@ -883,17 +883,17 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
{
|
||||
/* Store object index header page */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, 0,
|
||||
gc.cur_objid | SPIFFS_OBJID_NDXFLAG,
|
||||
gc.cur_objndx_pgndx, fs->work, 0,
|
||||
0, &new_objndx_pgndx);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, 0,
|
||||
gc.cur_objid | SPIFFS_OBJID_NDXFLAG,
|
||||
gc.cur_objndx_pgndx, fs->work, 0,
|
||||
0, &new_objndx_pgndx);
|
||||
|
||||
spiffs_gcinfo("Store modified objhdr page=%04x:%04x\n",
|
||||
new_objndx_pgndx, 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_update_index_hdr() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_update_ndxhdr() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -915,11 +915,11 @@ static int spiffs_gc_clean(FAR struct spiffs_s *fs, int16_t blkndx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
spiffs_object_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, gc.cur_objid,
|
||||
objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
spiffs_fobj_event(fs,
|
||||
(FAR struct spiffs_page_objndx_s *)fs->work,
|
||||
SPIFFS_EV_NDXUPD, gc.cur_objid,
|
||||
objndx->phdr.spndx,
|
||||
new_objndx_pgndx, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -431,11 +431,11 @@ static int spiffs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
goto errout_with_fileobject;
|
||||
}
|
||||
|
||||
ret = spiffs_object_create(fs, objid, (FAR const uint8_t *)relpath,
|
||||
DTYPE_FILE, &pgndx);
|
||||
ret = spiffs_fobj_create(fs, objid, (FAR const uint8_t *)relpath,
|
||||
DTYPE_FILE, &pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_create() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_create() failed: %d\n", ret);
|
||||
goto errout_with_fileobject;
|
||||
}
|
||||
|
||||
@ -451,10 +451,10 @@ static int spiffs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
/* Open the file */
|
||||
|
||||
ret = spiffs_object_open_bypage(fs, pgndx, fobj, oflags, mode);
|
||||
ret = spiffs_fobj_open_bypage(fs, pgndx, fobj);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_open_bypage() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_open_bypage() failed: %d\n", ret);
|
||||
goto errout_with_fileobject;
|
||||
}
|
||||
|
||||
@ -462,10 +462,10 @@ static int spiffs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
if ((oflags & O_TRUNC) != 0)
|
||||
{
|
||||
ret = spiffs_object_truncate(fs, fobj, 0, false);
|
||||
ret = spiffs_fobj_truncate(fs, fobj, 0, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_truncate() failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_truncate() failed: %d\n", ret);
|
||||
goto errout_with_fileobject;
|
||||
}
|
||||
}
|
||||
@ -556,7 +556,6 @@ static int spiffs_close(FAR struct file *filep)
|
||||
*/
|
||||
|
||||
spiffs_fobj_free(fs, fobj, (fobj->flags & SFO_FLAG_UNLINKED) != 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Release the lock on the file system */
|
||||
@ -570,7 +569,7 @@ static int spiffs_close(FAR struct file *filep)
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t spiffs_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct inode *inode;
|
||||
FAR struct spiffs_s *fs;
|
||||
@ -664,7 +663,7 @@ static ssize_t spiffs_write(FAR struct file *filep, FAR const char *buffer,
|
||||
fobj->cache_page = spiffs_cache_page_get_byobjid(fs, fobj);
|
||||
}
|
||||
|
||||
if ((fobj->flags & O_DIRECT) == 0)
|
||||
if ((fobj->oflags & O_DIRECT) == 0)
|
||||
{
|
||||
if (buflen < (size_t)SPIFFS_GEO_PAGE_SIZE(fs))
|
||||
{
|
||||
@ -871,7 +870,8 @@ static off_t spiffs_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Verify the resulting file position */
|
||||
@ -987,7 +987,8 @@ static int spiffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
ret = spiffs_erase_block(fs, blkndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
return spiffs_map_errno(ret);
|
||||
ferr("ERROR: spiffs_erase_block() failed: %d\n", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
blkndx++;
|
||||
@ -1191,12 +1192,12 @@ static int spiffs_truncate(FAR struct file *filep, off_t length)
|
||||
|
||||
spiffs_lock_volume(fs);
|
||||
|
||||
/* REVISIT: spiffs_object_truncate() can only truncate to smaller sizes. */
|
||||
/* REVISIT: spiffs_fobj_truncate() can only truncate to smaller sizes. */
|
||||
|
||||
ret = spiffs_object_truncate(fs, fobj, length, false);
|
||||
ret = spiffs_fobj_truncate(fs, fobj, length, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_truncate failed: %d/n", ret);
|
||||
ferr("ERROR: spiffs_fobj_truncate failed: %d/n", ret);
|
||||
}
|
||||
|
||||
/* Check if we need to reset the file pointer. Probably could use
|
||||
@ -1656,22 +1657,22 @@ static int spiffs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
|
||||
|
||||
/* Use the page index to open the file */
|
||||
|
||||
ret = spiffs_object_open_bypage(fs, pgndx, fobj, 0, 0);
|
||||
ret = spiffs_fobj_open_bypage(fs, pgndx, fobj);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_open_bypage failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_open_bypage failed: %d\n", ret);
|
||||
kmm_free(fobj);
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Now we can remove the file by truncating it to zero length */
|
||||
|
||||
ret = spiffs_object_truncate(fs, fobj, 0, true);
|
||||
ret = spiffs_fobj_truncate(fs, fobj, 0, true);
|
||||
kmm_free(fobj);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_truncate failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_truncate failed: %d\n", ret);
|
||||
goto errout_with_lock;
|
||||
}
|
||||
}
|
||||
@ -1780,12 +1781,13 @@ static int spiffs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
||||
fobj = (FAR struct spiffs_file_s *)kmm_zalloc(sizeof(struct spiffs_file_s));
|
||||
if (fobj == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* Use the page index to open the file */
|
||||
|
||||
ret = spiffs_object_open_bypage(fs, oldpgndx, fobj, 0, 0);
|
||||
ret = spiffs_fobj_open_bypage(fs, oldpgndx, fobj);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_fobj;
|
||||
@ -1793,10 +1795,10 @@ static int spiffs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
||||
|
||||
/* Then update the file name */
|
||||
|
||||
ret = spiffs_object_update_index_hdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0,
|
||||
(FAR const uint8_t *)newrelpath, 0,
|
||||
&newpgndx);
|
||||
ret = spiffs_fobj_update_ndxhdr(fs, fobj, fobj->objid,
|
||||
fobj->objhdr_pgndx, 0,
|
||||
(FAR const uint8_t *)newrelpath, 0,
|
||||
&newpgndx);
|
||||
|
||||
errout_with_fobj:
|
||||
kmm_free(fobj);
|
||||
@ -1815,12 +1817,22 @@ static int spiffs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
{
|
||||
FAR struct spiffs_s *fs;
|
||||
int16_t pgndx;
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
finfo("mountpt=%p relpath=%s buf=%p\n", mountpt, relpath, buf);
|
||||
DEBUGASSERT(mountpt != NULL && relpath != NULL && buf != NULL);
|
||||
|
||||
if (strlen(relpath) > CONFIG_SPIFFS_NAME_MAX - 1)
|
||||
/* Skip over any leading directory separators (shouldn't be any) */
|
||||
|
||||
for (; *relpath == '/'; relpath++)
|
||||
{
|
||||
}
|
||||
|
||||
/* Handle long file names */
|
||||
|
||||
len = strlen(relpath);
|
||||
if (len > CONFIG_SPIFFS_NAME_MAX - 1)
|
||||
{
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
@ -1834,20 +1846,35 @@ static int spiffs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
|
||||
spiffs_lock_volume(fs);
|
||||
|
||||
/* Find the object associated with this relative path */
|
||||
/* Handle stat of the SPIFFS root directory */
|
||||
|
||||
ret = spiffs_find_objhdr_pgndx(fs, (FAR const uint8_t *)relpath, &pgndx);
|
||||
if (ret < 0)
|
||||
if (len == 0)
|
||||
{
|
||||
goto errout_with_lock;
|
||||
memset(buf, 0, sizeof(struct stat));
|
||||
|
||||
buf->st_mode = S_IFDIR | S_IRWXO | S_IRWXG | S_IRWXU;
|
||||
buf->st_blksize = fs->geo.blocksize;
|
||||
buf->st_blocks = fs->media_size / fs->geo.blocksize;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* And get information about the object */
|
||||
|
||||
ret = spiffs_stat_pgndx(fs, pgndx, 0, buf);
|
||||
if (ret < 0)
|
||||
else
|
||||
{
|
||||
ferr("ERROR: spiffs_stat_pgndx failed: %d\n", ret);
|
||||
/* Find the object associated with this relative path */
|
||||
|
||||
ret = spiffs_find_objhdr_pgndx(fs, (FAR const uint8_t *)relpath,
|
||||
&pgndx);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
/* And get information about the object */
|
||||
|
||||
ret = spiffs_stat_pgndx(fs, pgndx, 0, buf);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_stat_pgndx failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
errout_with_lock:
|
||||
|
@ -234,7 +234,7 @@ ssize_t spiffs_fflush_cache(FAR struct spiffs_s *fs,
|
||||
* flushing the cache.
|
||||
*/
|
||||
|
||||
if ((fobj->flags & O_DIRECT) == 0)
|
||||
if ((fobj->oflags & O_DIRECT) == 0)
|
||||
{
|
||||
if (fobj->cache_page == 0)
|
||||
{
|
||||
@ -300,8 +300,8 @@ ssize_t spiffs_fobj_write(FAR struct spiffs_s *fs,
|
||||
ssize_t wrsize;
|
||||
|
||||
wrsize = MIN((ssize_t)(fobj->size - offset), remaining);
|
||||
nwritten = spiffs_object_modify(fs, fobj, offset,
|
||||
(FAR uint8_t *)buffer, wrsize);
|
||||
nwritten = spiffs_fobj_modify(fs, fobj, offset,
|
||||
(FAR uint8_t *)buffer, wrsize);
|
||||
if (nwritten <= 0)
|
||||
{
|
||||
return nwritten;
|
||||
@ -318,8 +318,8 @@ ssize_t spiffs_fobj_write(FAR struct spiffs_s *fs,
|
||||
{
|
||||
ssize_t nappend;
|
||||
|
||||
nappend = spiffs_object_append(fs, fobj, offset,
|
||||
(FAR uint8_t *)buffer, remaining);
|
||||
nappend = spiffs_fobj_append(fs, fobj, offset,
|
||||
(FAR uint8_t *)buffer, remaining);
|
||||
if (nappend < 0)
|
||||
{
|
||||
return (ssize_t)nappend;
|
||||
@ -363,7 +363,7 @@ ssize_t spiffs_fobj_read(FAR struct spiffs_s *fs,
|
||||
|
||||
/* Make sure that read access is supported */
|
||||
|
||||
if ((fobj->flags & O_RDONLY) == 0)
|
||||
if ((fobj->oflags & O_RDONLY) == 0)
|
||||
{
|
||||
return -EACCES;
|
||||
}
|
||||
@ -472,10 +472,10 @@ void spiffs_fobj_free(FAR struct spiffs_s *fs,
|
||||
|
||||
if (unlink)
|
||||
{
|
||||
ret = spiffs_object_truncate(fs, fobj, 0, true);
|
||||
ret = spiffs_fobj_truncate(fs, fobj, 0, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_object_truncate failed: %d\n", ret);
|
||||
ferr("ERROR: spiffs_fobj_truncate failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user