Commit c04cffb7 authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

Restore pipe flags

pipe_loop00 passed with this patch.

When we restore a regular fd (not pipe) we do use flags
directly in open() call.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 6949e0f0
......@@ -249,7 +249,7 @@ static int collect_pipe(int pid, struct pipe_entry *e, int p_fd)
if (pipes[i].pid > pid && !pipe_is_rw(&pipes[i])) {
pipes[i].pid = pid;
} else if (pipes[i].pid == pid) {
switch (e->flags) {
switch (e->flags & O_ACCMODE) {
case O_RDONLY:
pipes[i].status |= PIPE_RDONLY;
break;
......@@ -275,17 +275,13 @@ static int collect_pipe(int pid, struct pipe_entry *e, int p_fd)
pipes[nr_pipes].pid = pid;
pipes[nr_pipes].users = 1;
switch (e->flags) {
switch (e->flags & O_ACCMODE) {
case O_RDONLY:
pipes[nr_pipes].status = PIPE_RDONLY;
break;
case O_WRONLY:
pipes[nr_pipes].status = PIPE_WRONLY;
break;
default:
pr_err("%d: Unknown pipe status pipeid %d\n",
pid, e->pipeid);
break;
}
nr_pipes++;
......@@ -881,6 +877,21 @@ static int prepare_and_sigreturn(int pid)
return 0;
}
#define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
static int set_fd_flags(int fd, int flags)
{
int old;
old = fcntl(fd, F_GETFL, 0);
if (old < 0)
return old;
flags = (SETFL_MASK & flags) | (old & ~SETFL_MASK);
return fcntl(fd, F_SETFL, flags);
}
static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int pipes_fd)
{
unsigned long time = 1000;
......@@ -946,6 +957,10 @@ static int create_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
tmp = reopen_fd_as(e->fd, pi->read_fd);
}
if (tmp < 0)
return 1;
tmp = set_fd_flags(e->fd, e->flags);
if (tmp < 0)
return 1;
......@@ -991,6 +1006,10 @@ static int attach_pipe(int pid, struct pipe_entry *e, struct pipe_info *pi, int
lseek(pipes_fd, e->bytes, SEEK_CUR);
tmp = set_fd_flags(e->fd, e->flags);
if (tmp < 0)
return 1;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment