Does anyone care about a race free ptsname?

From: Eric W. Biederman
Date: Tue Apr 19 2016 - 14:55:46 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> What this does is get rid of the horrible notion of having that
>
> struct inode *ptmx_inode
>
> be the interface between the pty code and devpts. By de-emphasizing the
> ptmx inode, a lot of things actually get cleaner, and we will have a much
> saner way forward.

I will take a look in a minute. Before I do that I want to mention
why I care about /dev/pts/ptmx.

There is a posix function that is widely used called ptsname. It's
function is to take a master file descriptor and returns the path to the
slave.

All we have in the kernel to support ptsname is an ioctl TIOCGPTN that
returns the pty number in the appropriate instance of devpts.

The only way we have today to query which instance of devpts the pty is
on is through fstat and look st_dev to see if the file is on the correct
filesystem. This works when /dev/pts/ptmx is used and fails when
/dev/ptmx is used.

Does anyone else care?

If no one cares I will stop worrying about it and just get on with
fixing the rest of this mess which there definitely seems to be the will
to do.

Eric