Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LibOS] Ignore O_TRUNC flag for FIFO files #1401

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libos/src/fs/libos_namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ int dentry_open(struct libos_handle* hdl, struct libos_dentry* dent, int flags)
/* truncate regular writable file if O_TRUNC is given */
if ((flags & O_TRUNC) && ((flags & O_RDWR) | (flags & O_WRONLY))
&& (dent->inode->type != S_IFDIR)
&& (dent->inode->type != S_IFIFO)
&& (dent->inode->type != S_IFLNK)) {

if (!(fs->fs_ops && fs->fs_ops->truncate))
Expand Down
2 changes: 1 addition & 1 deletion libos/src/fs/pipe/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int fifo_open(struct libos_handle* hdl, struct libos_dentry* dent, int fl
* one end (read or write) in our emulation, so we treat such FIFOs as read-only. This
* covers most apps seen in the wild (in particular, LTP apps). */
log_warning("FIFO (named pipe) '%s' cannot be opened in read-write mode in Gramine. "
"Treating it as read-only.", dent->mount->path);
"Treating it as read-only.", dent->name);
flags = (flags & ~O_ACCMODE) | O_RDONLY;
}

Expand Down
4 changes: 2 additions & 2 deletions libos/test/regression/mkfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ int main(int argc, char** argv) {
/* server */
fd = -1;
while (fd < 0) {
/* wait until client is ready for read */
/* wait until client is ready for read (O_TRUNC flag here is only for testing) */
errno = 0;
fd = open(FIFO_PATH, O_NONBLOCK | O_WRONLY);
fd = open(FIFO_PATH, O_NONBLOCK | O_WRONLY | O_TRUNC);
if (fd < 0 && errno != ENXIO) {
perror("[parent] open error");
return 1;
Expand Down