fs/fat: Fix a bug in the FAT ftruncate logic.
This commit is contained in:
parent
376e30dab4
commit
49775ea801
@ -303,7 +303,7 @@ static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
else if (start_sector < dev->rd_nsectors &&
|
||||
start_sector + nsectors <= dev->rd_nsectors)
|
||||
{
|
||||
finfo("Transfer %d bytes from %p\n",
|
||||
finfo("Transfer %d bytes to %p\n",
|
||||
nsectors * dev->rd_sectsize,
|
||||
&dev->rd_buffer[start_sector * dev->rd_sectsize]);
|
||||
|
||||
|
@ -1786,6 +1786,16 @@ static int fat_truncate(FAR struct file *filep, off_t length)
|
||||
|
||||
ret = fat_dirshrink(fs, direntry, length);
|
||||
}
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* The truncation has completed without error. Update the file
|
||||
* size.
|
||||
*/
|
||||
|
||||
ff->ff_size = length;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1797,7 +1807,9 @@ static int fat_truncate(FAR struct file *filep, off_t length)
|
||||
ret = fat_dirextend(fs, ff, length);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* The truncation has completed without error. Update the file size */
|
||||
/* The truncation has completed without error. Update the file
|
||||
* size.
|
||||
*/
|
||||
|
||||
ff->ff_size = length;
|
||||
ret = OK;
|
||||
|
Loading…
Reference in New Issue
Block a user