Skip to content

Commit

Permalink
fs/shm: support shm_open with flags O_TRUNC
Browse files Browse the repository at this point in the history
  • Loading branch information
Donny9 authored and acassis committed Oct 31, 2024
1 parent d1e5b38 commit 47478e5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fs/shm/shm_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name,
inode_release(inode);
goto errout_with_sem;
}

/* If the shared memory object already exists, truncate it to
* zero bytes.
*/

if ((oflags & O_TRUNC) == O_TRUNC && inode->i_private != NULL)
{
shmfs_free_object(inode->i_private);
inode->i_private = NULL;
inode->i_size = 0;
}
}
else
{
Expand Down

0 comments on commit 47478e5

Please sign in to comment.