2
[root@archlinux xtricman]# ls -l /dev/pts
total 0
crw--w---- 1 xtricman tty  136, 0 Feb 24 19:24 0
c--------- 1 root     root   5, 2 Feb 24 19:10 ptmx
[root@archlinux xtricman]# ls -l /mnt
total 12
brw-r--r-- 1 root root 136, 0 Feb 24 19:17 dev_node
crw-r--r-- 1 root root 136, 0 Feb 24 19:17 dev_node_c
drwx------ 2 root root  12288 Feb 24 19:12 lost+found
[root@archlinux xtricman]# exec 6<>/dev/pts/0
[root@archlinux xtricman]# exec 7<>/mnt/dev_node
bash: /mnt/dev_node: No such device or address
[root@archlinux xtricman]# exec 7<>/mnt/dev_node_c
bash: /mnt/dev_node_c: Input/output error

/dev/pts is the mount point of a devpts, /mnt is the mount point of an ext4.

I want to know, since both the three device nodes(/dev/pts/0,/mnt/dev_node,/mnt/dev_node_c) all have the same major and minor number, why can I only open the /dev/pts/0 but not the other two?

Even if I can understand that a block device of (major=136,minor=0) doesn't exist, what does the "Input/output error" of character device (major=136,minor=0) mean? Why do I get this error?

1

Well, dev_node is a block device (the b at the start of the line in the ls output tells this), so it's not at all the same as the others. It just happens to have the same major number, but the numbers are not related between block devices and character devices.

Documentation/admin-guide/devices.txt in the Linux kernel source tells what it is:

 136 block      Mylex DAC960 PCI RAID controller; ninth controller
                  0 = /dev/rd/c8d0      First disk, whole disk

You probably don't have a Mylex RAID controller, let alone nine of them, so No such device or address seems an appropriate response.

dev_node_c though looks to be the same as your /dev/pts/0. But the device nodes in /dev/pts are automatically generated, there's a special virtual filesystem (devpts) for it. It's shown in the output of mount, as usual:

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) 

I tested that, and indeed copying a device node from there /dev/pts/15 to another filesystem doesn't work. Also, mounting another copy of devpts seems to create a clean instance, the pseudo ttys in /dev/pts aren't visible in the other copy. So it may indeed be that the pseudo tty nodes are tied to that particular instance of the devpts filesystem, and so the nodes don't work at all outside of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.