Commit 2245a433 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

tty: use a pair of dev and rdev to identify a terminal

We can't use only a terminal device, because we can not distinguish
two pty-s from different mounts in this case.

$ mount -t devpts -o newinstance xxx pts1
$ mount -t devpts -o newinstance xxx pts2
$ stat pts1/0
Device: 27h/39d	Inode: 3           Links: 1     Device type: 88,0
$ stat pts2/0
Device: 28h/40d	Inode: 3           Links: 1     Device type: 88,0
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5d75e1f4
......@@ -366,7 +366,7 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
default: {
char more[32];
if (is_tty(maj, minor(p->stat.st_rdev))) {
if (is_tty(p->stat.st_rdev, p->stat.st_dev)) {
struct fd_link link;
if (fill_fdlink(lfd, p, &link))
......
......@@ -12,10 +12,10 @@
extern const struct fdtype_ops tty_dump_ops;
struct tty_driver;
struct tty_driver *get_tty_driver(int major, int minor);
static inline int is_tty(int major, int minor)
struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev);
static inline int is_tty(dev_t rdev, dev_t dev)
{
return get_tty_driver(major, minor) != NULL;
return get_tty_driver(rdev, dev) != NULL;
}
extern int dump_verify_tty_sids(void);
......
......@@ -60,6 +60,7 @@ message tty_info_entry {
* TTY type.
*/
optional tty_pty_entry pty = 12;
optional uint32 dev = 13;
};
message tty_file_entry {
......
......@@ -232,8 +232,13 @@ static struct tty_driver pts_driver = {
.open = pty_open_ptmx,
};
struct tty_driver *get_tty_driver(int major, int minor)
struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
{
int major, minor;
major = major(rdev);
minor = minor(rdev);
switch (major) {
case TTYAUX_MAJOR:
if (minor == 2)
......@@ -1356,7 +1361,7 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg)
}
INIT_LIST_HEAD(&info->sibling);
info->driver = get_tty_driver(major(info->tie->rdev), minor(info->tie->rdev));
info->driver = get_tty_driver(info->tie->rdev, info->tie->dev);
info->create = tty_is_master(info);
info->inherit = false;
info->ctl_tty = NULL;
......@@ -1501,6 +1506,8 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d
info.sid = pti->sid;
info.pgrp = pti->pgrp;
info.rdev = p->stat.st_rdev;
info.dev = p->stat.st_dev;
info.has_dev = true;
info.locked = pti->st_lock;
info.exclusive = pti->st_excl;
info.packet_mode = pti->st_pckt;
......@@ -1581,7 +1588,7 @@ static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
if (dump_one_reg_file(lfd, id, p))
return -1;
driver = get_tty_driver(major(p->stat.st_rdev), minor(p->stat.st_rdev));
driver = get_tty_driver(p->stat.st_rdev, p->stat.st_dev);
if (driver->fd_get_index)
index = driver->fd_get_index(lfd, p);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment