mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
fixed check for remaining size on WOFS
This commit is contained in:
parent
a9ebeac525
commit
c2227a7645
@ -280,8 +280,10 @@ static _ssize_t romfs_write_r( struct _reent *r, int fd, const void* ptr, size_t
|
|||||||
if( pfd->offset != pfd->size )
|
if( pfd->offset != pfd->size )
|
||||||
return 0;
|
return 0;
|
||||||
// Check if we have enough space left on the device. Always keep 1 byte for the final 0xFF
|
// Check if we have enough space left on the device. Always keep 1 byte for the final 0xFF
|
||||||
if( pfd->baseaddr + pfd->size + len > pfsdata->max_size - 1 )
|
// and ROMFS_ALIGN - 1 bytes for aligning the contents of the file data in the worst case
|
||||||
len = pfsdata->max_size - ( pfd->baseaddr + pfd->size ) - 1;
|
// scenario (so ROMFS_ALIGN bytes in total)
|
||||||
|
if( pfd->baseaddr + pfd->size + len > pfsdata->max_size - ROMFS_ALIGN )
|
||||||
|
len = pfsdata->max_size - ( pfd->baseaddr + pfd->size ) - ROMFS_ALIGN;
|
||||||
pfsdata->writef( ptr, pfd->offset + pfd->baseaddr, len, pfsdata );
|
pfsdata->writef( ptr, pfd->offset + pfd->baseaddr, len, pfsdata );
|
||||||
pfd->offset += len;
|
pfd->offset += len;
|
||||||
pfd->size += len;
|
pfd->size += len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user