mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-20 01:54:28 +00:00
files: Remove O_CLOEXEC from file flags
The kernel artificially adds the O_CLOEXEC flag when reading from the /proc/fdinfo/fd interface if FD_CLOEXEC is set on the file descriptor used to access the file. This commit removes the O_CLOEXEC flag in our file flags. To restore the proper FD_CLOEXEC value in each of the file descriptors, CRIU uses fcntl(F_GETFD) to retrieve the FD_CLOEXEC status, and restore it later with fcntl(F_SETFD). This is necessary because multiple file descriptors may point to the same open file.
This commit is contained in:
parent
2ac43cd426
commit
8255caf27b
1 changed files with 7 additions and 1 deletions
|
|
@ -382,7 +382,13 @@ static int fill_fd_params(struct pid *owner_pid, int fd, int lfd,
|
|||
p->fs_type = fsbuf.f_type;
|
||||
p->fd = fd;
|
||||
p->pos = fdinfo.pos;
|
||||
p->flags = fdinfo.flags;
|
||||
/*
|
||||
* The kernel artificially adds the O_CLOEXEC flag on the file pointer
|
||||
* flags by looking at the flags on the file descriptor (see kernel
|
||||
* code fs/proc/fd.c). FD_CLOEXEC is a file descriptor property, which
|
||||
* is saved in fd_flags.
|
||||
*/
|
||||
p->flags = fdinfo.flags & ~O_CLOEXEC;
|
||||
p->mnt_id = fdinfo.mnt_id;
|
||||
p->pid = owner_pid->real;
|
||||
p->fd_flags = opts->flags;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue