Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753288AbdHXTWX (ORCPT ); Thu, 24 Aug 2017 15:22:23 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:33528 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbdHXTWV (ORCPT ); Thu, 24 Aug 2017 15:22:21 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170816171211.4021-1-christian.brauner@ubuntu.com> <87pobvruzt.fsf@xmission.com> <87ziazqdfr.fsf@xmission.com> <20170824022436.44adb497@mir> <87378hhi3y.fsf@xmission.com> <87wp5tfynr.fsf@xmission.com> <20170824062432.1e05e6f8@mir> <874lsxezal.fsf@xmission.com> <87y3q8ermg.fsf@xmission.com> From: Linus Torvalds Date: Thu, 24 Aug 2017 12:22:19 -0700 X-Google-Sender-Auth: FcAli_V2rWt3EJCmw4sJMHn-9u4 Message-ID: Subject: Re: [PATCH 0/1] devpts: use dynamic_dname() to generate proc name To: Christian Brauner Cc: "Eric W. Biederman" , Al Viro , Serge Hallyn , Stefan Lippers-Hollmann , Christian Brauner , Thorsten Leemhuis , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2033 Lines: 62 On Thu, Aug 24, 2017 at 12:01 PM, Christian Brauner wrote: > > I've touched on this in my original message, I wonder whether we currently > support mounting devpts at a different a location and expect an open on a > newly created slave to work. Yes. That is very much intended to work. > Say I mount devpts at /mnt and to open("/mnt/ptmx", O_RDWR | O_NOCTTY) and get a new slave pty at /mnt/1 do we > expect open("/mnt/1, O_RDWR | O_NOCTTY) to work? Yes. Except you actually don't want to use "/mnt/ptmx". That ptmx node inside the pts filesystem is garbage that we never actually used, because the permissions aren't sane. It should probably be removed, but because somebody *might* have used it, we have left it alone. So what you're actually *supposed* to do is - create a ptmx node and a pts directory in /mnt - mount devpts on /mnt/pts - use /mnt/ptmx to create new pty's, which should just look up that pts mount directly. And yes, the pathname should then be /mnt/pts/X for the slave side, and /mnt/ptmx for the master. In fact, I just tested that TIOCGPTPEER, including using your original test-program (this is me as root in my home directory): [root@i7 torvalds]# mkdir dummy [root@i7 torvalds]# cd dummy/ [root@i7 dummy]# mknod ptmx c 5 2 [root@i7 dummy]# mkdir pts [root@i7 dummy]# mount -t devpts devpts pts [root@i7 dummy]# ../a.out I point to "/home/torvalds/dummy/pts/0" [root@i7 dummy]# umount pts/ [root@i7 dummy]# cd .. [root@i7 torvalds]# rm -rf dummy There's two things to note there: - look at that "I point to" - it's not hardcoded to /dev/pts/X - look at the pts number: each pts filesystem has its own private numbers, so despite the fact that in another window I *also* have that ptx/0: [torvalds@i7 linux]$ tty /dev/pts/0 that new devpts instance has its *own* pts/0, which is a completely different pty. this is one of those big cleanups we did with the pts filesystem some time ago. Linus