[CRIU] [PATCH 11/12] tty: Add external ttys handling

Cyrill Gorcunov gorcunov at gmail.com
Fri Oct 3 01:07:34 PDT 2014


On Fri, Oct 03, 2014 at 12:00:30PM +0400, Andrew Vagin wrote:
> On Fri, Oct 03, 2014 at 11:50:04AM +0400, Cyrill Gorcunov wrote:
> > Some types of ttys (such as /dev/console) should be c/r'ed in
> > simle manner -- just opent them by path on restore, for this
> > sake that named external TTYs are introduced.
> > 
> > For example, for /dev/console one simply need to pass an option
> > 
> > 	--ext-tty 5:1
> 
> Can we use paths instead of maj:min? For example LXC bindmounts a host
> /dev/pty/X to /dev/console.

We can, but the problem is that

static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
{
	int maj = major(p->stat.st_rdev);
	const struct fdtype_ops *ops;

	switch (maj) {
	case MEM_MAJOR:
		ops = &regfile_dump_ops;
		break;
	case TTYAUX_MAJOR:
	case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
	case UNIX98_PTY_SLAVE_MAJOR:
		ops = &tty_dump_ops;
		break;
	case MISC_MAJOR:
		ops = get_misc_dev_ops(minor(p->stat.st_rdev));
		if (ops)
			break;
		/* fallthrough */
	default: {
		char more[32];

		/*
		 * Ext mapping for tty devices.
		 */
-->		if (lookup_ext_tty(maj, minor(p->stat.st_rdev))) {
			ops = &tty_dump_ops;
			goto found;
		}

		sprintf(more, "%d:%d", maj, minor(p->stat.st_rdev));
		return dump_unsupp_fd(p, lfd, img, "chr", more);
	}
	}

found:
	return do_dump_gen_file(p, lfd, ops, img);
}

I'll have to readlink here instead which is inconvenient, so that
what prevents one to simply pass stat of /dev/pty/X here?


More information about the CRIU mailing list