mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 18:25:14 +00:00
fs: use __open_proc instead of open("/proc/...", ... )
Processes can run in a mount namespace without /proc. Reported-by: Mr Jenkins Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
4129d3262a
commit
ffe0896ed0
2 changed files with 2 additions and 6 deletions
|
|
@ -778,14 +778,12 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de
|
|||
|
||||
if (S_ISREG(st->st_mode)) {
|
||||
int fd, ret;
|
||||
char lpath[PSFDS];
|
||||
|
||||
/*
|
||||
* Reopen file locally since it may have no read
|
||||
* permissions when drained
|
||||
*/
|
||||
sprintf(lpath, "/proc/self/fd/%d", _fd);
|
||||
fd = open(lpath, O_RDONLY);
|
||||
fd = open_proc(PROC_SELF, "fd/%d", _fd);
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open ghost original file");
|
||||
goto err_out;
|
||||
|
|
|
|||
|
|
@ -299,7 +299,6 @@ static int memfd_open_inode(struct memfd_inode *inode)
|
|||
|
||||
int memfd_open(struct file_desc *d, u32 *fdflags)
|
||||
{
|
||||
char lpath[PSFDS];
|
||||
struct memfd_info *mfi;
|
||||
MemfdFileEntry *mfe;
|
||||
int fd, _fd;
|
||||
|
|
@ -318,14 +317,13 @@ int memfd_open(struct file_desc *d, u32 *fdflags)
|
|||
goto err;
|
||||
|
||||
/* Reopen the fd with original permissions */
|
||||
sprintf(lpath, "/proc/self/fd/%d", fd);
|
||||
flags = fdflags ? *fdflags : mfe->flags;
|
||||
/*
|
||||
* Ideally we should call compat version open() to not force the
|
||||
* O_LARGEFILE file flag with regular open(). It doesn't seem that
|
||||
* important though.
|
||||
*/
|
||||
_fd = open(lpath, flags);
|
||||
_fd = __open_proc(getpid(), 0, flags, "fd/%d", fd);
|
||||
if (_fd < 0) {
|
||||
pr_perror("Can't reopen memfd id=%d", mfe->id);
|
||||
goto err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue