mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +00:00
tty: Parse slave peer index from fd_parms
We will use this path in reg-files engine anyway so simply switch to this ability now. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
d6e231ae09
commit
09aa15c7a3
5
files.c
5
files.c
@@ -282,6 +282,11 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
|
|||||||
char more[32];
|
char more[32];
|
||||||
|
|
||||||
if (is_tty(maj, minor(p->stat.st_rdev))) {
|
if (is_tty(maj, minor(p->stat.st_rdev))) {
|
||||||
|
struct fd_link link;
|
||||||
|
|
||||||
|
if (fill_fdlink(lfd, p, &link))
|
||||||
|
return -1;
|
||||||
|
p->link = &link;
|
||||||
ops = &tty_dump_ops;
|
ops = &tty_dump_ops;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
22
tty.c
22
tty.c
@@ -199,7 +199,7 @@ int tty_verify_active_pairs(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_pty_index(u32 id, int lfd, int type)
|
static int parse_pty_index(u32 id, int lfd, const struct fd_parms *p, int type)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
@@ -212,22 +212,14 @@ static int parse_pty_index(u32 id, int lfd, int type)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TTY_TYPE_PTS: {
|
case TTY_TYPE_PTS: {
|
||||||
char path[PATH_MAX];
|
const struct fd_link *link = p->link;
|
||||||
char link[32];
|
char *pos = strrchr(link->name, '/');
|
||||||
int len;
|
|
||||||
|
|
||||||
snprintf(link, sizeof(link), "/proc/self/fd/%d", lfd);
|
if (!pos || pos == (link->name + link->len - 1)) {
|
||||||
len = readlink(link, path, sizeof(path) - 1);
|
pr_err("Unexpected format on path %s\n", link->name + 1);
|
||||||
if (len < 0) {
|
|
||||||
pr_perror("Can't readlink %s", link);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
path[len] = '\0';
|
|
||||||
|
|
||||||
if (sscanf(path, PTS_FMT, &index) != 1) {
|
|
||||||
pr_err("Unexpected format on path %s\n", path);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
index = atoi(pos + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1175,7 +1167,7 @@ static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p)
|
|||||||
pr_info("Dumping tty %d with id %#x\n", lfd, id);
|
pr_info("Dumping tty %d with id %#x\n", lfd, id);
|
||||||
|
|
||||||
type = tty_type(major(p->stat.st_rdev), minor(p->stat.st_rdev));
|
type = tty_type(major(p->stat.st_rdev), minor(p->stat.st_rdev));
|
||||||
index = parse_pty_index(id, lfd, type);
|
index = parse_pty_index(id, lfd, p, type);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user