mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 11:04:35 +00:00
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: Andrey Vagin <avagin@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
parent
6949e0f09f
commit
c04cffb7ce
1 changed files with 25 additions and 6 deletions
31
cr-restore.c
31
cr-restore.c
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue