TMPFS: In open write/append mode, need to set the file position to the end of the file
This commit is contained in:
parent
2c385b81f8
commit
185b941c27
@ -1346,6 +1346,7 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
FAR struct inode *inode;
|
||||
FAR struct tmpfs_s *fs;
|
||||
FAR struct tmpfs_file_s *tfo;
|
||||
off_t offset;
|
||||
int ret;
|
||||
|
||||
fvdbg("filep: %p\n", filep);
|
||||
@ -1456,6 +1457,18 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
|
||||
filep->f_priv = tfo;
|
||||
|
||||
/* In write/append mode, we need to set the file pointer to the end of the
|
||||
* file.
|
||||
*/
|
||||
|
||||
offset = 0;
|
||||
if ((oflags & (O_APPEND | O_WRONLY)) == (O_APPEND | O_WRONLY))
|
||||
{
|
||||
offset = tfo->tfo_size;
|
||||
}
|
||||
|
||||
filep->f_pos = offset;
|
||||
|
||||
/* Unlock the file file object, but retain the reference count */
|
||||
|
||||
tmpfs_unlock_file(tfo);
|
||||
|
Loading…
Reference in New Issue
Block a user