mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-21 01:06:58 +00:00
cr-dump: call stat for /proc/pid/fd/X directly
This patch can be committed instead of: [PATCH 1/6] cr-dump: move parasite_drain_fds_seized out of dump_task_files [PATCH 2/6] cr-dump: fix dumping file locks in a mount namespace readlink is not required here and a file can be unavailable, if a process is in another mnt namespace Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
8587f7dec1
commit
d6ae662374
1 changed files with 5 additions and 18 deletions
23
cr-dump.c
23
cr-dump.c
|
|
@ -694,36 +694,23 @@ err:
|
|||
static int get_fd_by_ino(unsigned long i_no, struct parasite_drain_fd *dfds,
|
||||
pid_t pid)
|
||||
{
|
||||
int i, ret = -1;
|
||||
char path[PATH_MAX];
|
||||
char buf[40];
|
||||
int i;
|
||||
char buf[PATH_MAX];
|
||||
struct stat fd_stat;
|
||||
|
||||
i = 0;
|
||||
while (i < dfds->nr_fds) {
|
||||
for (i = 0; i < dfds->nr_fds; i++) {
|
||||
snprintf(buf, sizeof(buf), "/proc/%d/fd/%d", pid,
|
||||
dfds->fds[i]);
|
||||
buf[39] = '\0';
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
ret = readlink(buf, path, sizeof(path));
|
||||
if (ret < 0) {
|
||||
pr_err("Read link %s failed!\n", buf);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (stat(path, &fd_stat) == -1) {
|
||||
i++;
|
||||
pr_msg("Could not get %s stat!\n", path);
|
||||
if (stat(buf, &fd_stat) == -1) {
|
||||
pr_msg("Could not get %s stat!\n", buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fd_stat.st_ino == i_no)
|
||||
return dfds->fds[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue