Linux – Why are `/dev/ptmx` and `/dev/pts/ptmx` not device files

linuxpseudoterminal

https://unix.stackexchange.com/a/492304/674 says

On Linux, using devpts, there is no master device file. The process on the master end uses a file descriptor, which it gets by opening ptmx, but there’s no corresponding device node.

Did the author refer to /dev/ptmx or /dev/pts/ptmx?

Why are /dev/ptmx and /dev/pts/ptmx not device files? What types of files are they?

What is the difference between /dev/ptmx and /dev/pts/ptmx?

Thanks.

On Lubuntu 18.04

$ file /dev/ptmx 
/dev/ptmx: character special (5/2)
$ file /dev/pts/ptmx 
/dev/pts/ptmx: character special (5/2)

$ sudo su

# stat -L /dev/fd/3 3<> /dev/pts/ptmx
  File: /dev/fd/3
  Size: 0           Blocks: 0          IO Block: 1024   character special file
Device: 15h/21d Inode: 2           Links: 1     Device type: 5,2
Access: (0000/c---------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-11-21 13:39:10.544000218 -0500
Modify: 2018-11-21 13:39:10.544000218 -0500
Change: 2018-11-21 13:39:10.544000218 -0500
 Birth: -

# stat -L /dev/fd/3 3<> /dev/ptmx
  File: /dev/fd/3
  Size: 0           Blocks: 0          IO Block: 4096   character special file
Device: 6h/6d   Inode: 87          Links: 1     Device type: 5,2
Access: (0666/crw-rw-rw-)  Uid: (    0/    root)   Gid: (    5/     tty)
Access: 2019-01-06 07:19:54.372098540 -0500
Modify: 2019-01-06 07:19:54.372098540 -0500
Change: 2018-11-21 13:39:30.372098540 -0500
 Birth: -

Best Answer

The context was “A pseudoterminal has a pair of master and slave.” When I wrote “there is no master device file”, I meant that there is no device node in the file system corresponding to the master end of a pseudoterminal connection, unlike the slave end. I wasn’t referring to either /dev/ptmx or /dev/pts/ptmx.

/dev/ptmx and /dev/pts/ptmx are device nodes, as indicated by their type in the output of ls or stat. They have the same major and minor, which means they provide access to the same device.

See JdeBP’s answer to Where does `/dev/pts/ptmx` come from? for the history of both device nodes (and the reason why there are two on Linux nowadays).

Related Question