Skip to content

Commit

Permalink
[LibOS] Ignore O_TRUNC flag for FIFO files
Browse files Browse the repository at this point in the history
Signed-off-by: Sonali Saha <sonali.saha@intel.com>
  • Loading branch information
sahason committed Jun 19, 2023
1 parent 514df18 commit 65f1788
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libos/src/fs/libos_namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,13 @@ int dentry_open(struct libos_handle* hdl, struct libos_dentry* dent, int flags)
hdl->dir_info.dents = NULL;
}

/* truncate regular writable file if O_TRUNC is given */
/* truncate regular writable file if O_TRUNC is given
* See `man 2 open`
* Ignore O_TRUNC flag for FIFO files. */
if ((flags & O_TRUNC) && ((flags & O_RDWR) | (flags & O_WRONLY))
&& (dent->inode->type != S_IFDIR)
&& (dent->inode->type != S_IFLNK)) {
&& (dent->inode->type != S_IFLNK)
&& strcmp(fs->name, "fifo")) {

if (!(fs->fs_ops && fs->fs_ops->truncate))
return -EINVAL;
Expand Down

0 comments on commit 65f1788

Please sign in to comment.