ttyname.3: document ENODEV error code
PATCH 1/1 ttyname.3: document ENODEV error code
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
man3/ttyname.3 +7 -1
@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).
@@ -92,4 +97,5 @@ POSIX.1-2001, POSIX.1-2008, 4.2BSD. .BR tty (1), .BR fstat (2), .BR ctermid (3), -.BR isatty (3) +.BR isatty (3), +.BR pts (4)
Signature · 5 lines
ldv -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAPP7u0WL2wa2MLavq22q616=-pHNPyNXqLpPGzR4JqYzGA16-A@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAPP7u0WL2wa2MLavq22q616=-pHNPyNXqLpPGzR4JqYzGA16-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi,
Quoted 24 lines · Christian Brauner
Hi,
Thanks Dmitry. One comment
On 20 Mar 2017 9:51 p.m., "Dmitry V. Levin" <ldv-u2l5PoMzF/[email protected]> wrote:
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-0@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found.
Quoted 4 lines
I think it would be good to explicitly mention that ENODEV is set in case the fd does not refer to a pts device in its namespace. Otherwise users might take this as an indication that this is a more generic error which is not the case.
In fact, this is a more generic error than a namespace mismatch, although the latter is the most likely reason.
Imagine that the corresponding file inside /dev/pts/ is not available for some reason and the stat call has failed. This situation could be reproduced e.g. by bind-mounting an empty directory to /dev/pts. A subsequent ttyname invocation would end up with ENODEV because the device is literally not available although it's withing the same namespace.
I don't mind if you change the description to mention the namespace case as the most likely, but please do not make it the only case when ENODEV can happen.
Signature · 1 line
ldv
A message that is not in the archive (sent off-list or not yet received): 20170320215823.GA28075-u2l5PoMzF/[email protected]
Hi Dmitry,
Quoted 41 lines · Dmitry V. Levin
Hi,
Quoted 24 lines · Christian Brauner
Hi,
Thanks Dmitry. One comment
On 20 Mar 2017 9:51 p.m., "Dmitry V. Levin" <ldv-u2l5PoMzF/[email protected]> wrote:
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-0@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found.Quoted 4 lines
I think it would be good to explicitly mention that ENODEV is set in case the fd does not refer to a pts device in its namespace. Otherwise users might take this as an indication that this is a more generic error which is not the case.
In fact, this is a more generic error than a namespace mismatch, although the latter is the most likely reason.
Imagine that the corresponding file inside
/dev/pts/is not available for some reason and the stat call has failed. This situation could be reproduced e.g. by bind-mounting an empty directory to/dev/pts. A subsequent ttyname invocation would end up with ENODEV because the device is literally not available although it's withing the same namespace.
Quoted 3 lines
I don't mind if you change the description to mention the namespace case as the most likely, but please do not make it the only case when ENODEV can happen.
I'm open on this point. If someone wants to write a suitable patch, I'll probably take it.
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): a3314168-ac99-28ef-2916-4da65adc8377-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Sorry, for the late reply.
Quoted 44 lines · Michael Kerrisk (man-pages)
Hi Dmitry,
Quoted 41 lines · Dmitry V. Levin
Hi,
Quoted 24 lines · Christian Brauner
Hi,
Thanks Dmitry. One comment
On 20 Mar 2017 9:51 p.m., "Dmitry V. Levin" <ldv-u2l5PoMzF/[email protected]> wrote:
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-0@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found.Quoted 4 lines
I think it would be good to explicitly mention that ENODEV is set in case the fd does not refer to a pts device in its namespace. Otherwise users might take this as an indication that this is a more generic error which is not the case.
In fact, this is a more generic error than a namespace mismatch, although the latter is the most likely reason.
Imagine that the corresponding file inside
/dev/pts/is not available for some reason and the stat call has failed. This situation could be reproduced e.g. by bind-mounting an empty directory to/dev/pts. A subsequent ttyname invocation would end up with ENODEV because the device is literally not available although it's withing the same namespace.
Quoted 6 lines
Quoted 3 lines
I don't mind if you change the description to mention the namespace case as the most likely, but please do not make it the only case when ENODEV can happen.
I'm open on this point. If someone wants to write a suitable patch, I'll probably take it.
This point is in my opinion crucial. The over-mounting scenario is still a valid case for most programs that do not actually care about what /dev/pts/<n> is actually used to go on which is a nice side-effect of the patch. The namespace part should be mentioned since ttyname{_r}() explicitly does not return anything when it detects that /proc/self/fd/<n> points to /dev/pts/<n> but /dev/pts/<n> does not exist in the same namespace. This was the original motivation when we wrote the patch. So users that get ENODEV from ttyname{_r}() should be aware that resolving the symlink manually afterwards doesn't give them a /dev/pts/<n> path valid in the current namespace.
I'll put this on my TODO list but if someone is willing to send a patch right away
please do so. :)
Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAPP7u0Ux2_pKFdS1X0_5SbR_MmvAmcR7+f=XcUOXWJ1Fr0naWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 66 lines · Christian Brauner
Sorry, for the late reply.
Quoted 44 lines · Michael Kerrisk (man-pages)
Hi Dmitry,
Quoted 41 lines · Dmitry V. Levin
Hi,
Quoted 24 lines · Christian Brauner
Hi,
Thanks Dmitry. One comment
On 20 Mar 2017 9:51 p.m., "Dmitry V. Levin" <ldv-u2l5PoMzF/[email protected]> wrote:
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-0@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found.Quoted 4 lines
I think it would be good to explicitly mention that ENODEV is set in case the fd does not refer to a pts device in its namespace. Otherwise users might take this as an indication that this is a more generic error which is not the case.
In fact, this is a more generic error than a namespace mismatch, although the latter is the most likely reason.
Imagine that the corresponding file inside
/dev/pts/is not available for some reason and the stat call has failed. This situation could be reproduced e.g. by bind-mounting an empty directory to/dev/pts. A subsequent ttyname invocation would end up with ENODEV because the device is literally not available although it's withing the same namespace.Quoted 6 lines
Quoted 3 lines
I don't mind if you change the description to mention the namespace case as the most likely, but please do not make it the only case when ENODEV can happen.
I'm open on this point. If someone wants to write a suitable patch, I'll probably take it.
This point is in my opinion crucial. The over-mounting scenario is still a valid case for most programs that do not actually care about what /dev/pts/<n> is actually used to go on which is a nice side-effect of the patch. The namespace part should be mentioned since ttyname{_r}() explicitly does not return anything when it detects that /proc/self/fd/<n> points to /dev/pts/<n> but /dev/pts/<n> does not exist in the same namespace. This was the original motivation when we wrote the patch. So users that get ENODEV from ttyname{_r}() should be aware that resolving the symlink manually afterwards doesn't give them a /dev/pts/<n> path valid in the current namespace.
Quoted 3 lines
I'll put this on my TODO list but if someone is willing to send a patch right away
please do so. :)
Hi Christian,
I think you may be best placed to know what you want to convey here. I'd be happy to receive a patch.
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): c3bc0470-b6a6-2ecb-dcb2-97e355c1e307-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hi Christian,
Pink on the below!
Cheers,
Michael
Quoted 82 lines · Michael Kerrisk (man-pages)
Quoted 66 lines · Christian Brauner
Sorry, for the late reply.
Quoted 44 lines · Michael Kerrisk (man-pages)
Hi Dmitry,
Quoted 41 lines · Dmitry V. Levin
Hi,
Quoted 24 lines · Christian Brauner
Hi,
Thanks Dmitry. One comment
On 20 Mar 2017 9:51 p.m., "Dmitry V. Levin" <ldv-u2l5PoMzF/[email protected]> wrote:
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-0@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found.Quoted 4 lines
I think it would be good to explicitly mention that ENODEV is set in case the fd does not refer to a pts device in its namespace. Otherwise users might take this as an indication that this is a more generic error which is not the case.
In fact, this is a more generic error than a namespace mismatch, although the latter is the most likely reason.
Imagine that the corresponding file inside
/dev/pts/is not available for some reason and the stat call has failed. This situation could be reproduced e.g. by bind-mounting an empty directory to/dev/pts. A subsequent ttyname invocation would end up with ENODEV because the device is literally not available although it's withing the same namespace.Quoted 6 lines
Quoted 3 lines
I don't mind if you change the description to mention the namespace case as the most likely, but please do not make it the only case when ENODEV can happen.
I'm open on this point. If someone wants to write a suitable patch, I'll probably take it.
This point is in my opinion crucial. The over-mounting scenario is still a valid case for most programs that do not actually care about what /dev/pts/<n> is actually used to go on which is a nice side-effect of the patch. The namespace part should be mentioned since ttyname{_r}() explicitly does not return anything when it detects that /proc/self/fd/<n> points to /dev/pts/<n> but /dev/pts/<n> does not exist in the same namespace. This was the original motivation when we wrote the patch. So users that get ENODEV from ttyname{_r}() should be aware that resolving the symlink manually afterwards doesn't give them a /dev/pts/<n> path valid in the current namespace.
Quoted 3 lines
I'll put this on my TODO list but if someone is willing to send a patch right away
please do so. :)Hi Christian,
I think you may be best placed to know what you want to convey here. I'd be happy to receive a patch.
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 8c7cb5df-bc2f-94d4-0a17-6efdf86f43b3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/1 ttyname(3): add NOTES section
--- man3/ttyname.3 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
man3/ttyname.3 +17 -1
@@ -75,7 +75,7 @@ was too small to allow storing the pathname. .\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 .B ENODEV File descriptor refers to a slave pseudoterminal device -but the corresponding pathname could not be found. +but the corresponding pathname could not be found (see NOTES). .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).
@@ -93,6 +93,22 @@ T} Thread safety MT-Safe .TE .SH CONFORMING TO POSIX.1-2001, POSIX.1-2008, 4.2BSD. +.SH NOTES +Processes keeping a file descriptor to a +.BR pts (4) +device open when switching to +.BR mount_namespaces (7) +that use a different +.IR /dev/ptmx +instance may still accidently find that a device path of the same name +for that file descriptor exists. However, this device path refers to a +different device and thus cannot not be used to modify the device that +the file descriptor refers to. Calling +.BR ttyname (7) +or +.BR ttyname_r (7) +on the file descriptor in such a mount namespace will cause these +functions to return NULL and set errno to ENODEV. .SH SEE ALSO .BR tty (1), .BR fstat (2),
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170421200509.23616-1-christian.brauner-GeWIH/[email protected]
Re: [PATCH] ttyname(3): add NOTES section
Quoted 22 lines · Christian Brauner
--- man3/ttyname.3 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)man3/ttyname.3 +1
-1@@ -75,7 +75,7 @@ was too small to allow storing the pathname. .\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 .B ENODEV File descriptor refers to a slave pseudoterminal device -but the corresponding pathname could not be found. +but the corresponding pathname could not be found (see NOTES). .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).@@ -93,6 +93,22 @@ T} Thread safety MT-Safe .TE .SH CONFORMING TO POSIX.1-2001, POSIX.1-2008, 4.2BSD.
man3/ttyname.3 T} Thread safety MT-Safe · line 105
Quoted 10 lines
man3/ttyname.3 +10
-0+.SH NOTES +Processes keeping a file descriptor to a +.BR pts (4) +device open when switching to +.BR mount_namespaces (7) +that use a different +.IR /dev/ptmx +instance may still accidently find that a device path of the same name +for that file descriptor exists. However, this device path refers to a +different device and thus cannot not be used to modify the device that
s/to modify the device/to access the device/
Signature · 1 line
ldv
A message that is not in the archive (sent off-list or not yet received): 20170423115237.GA26862-u2l5PoMzF/[email protected]
Re: [PATCH] ttyname(3): add NOTES section
Quoted 27 lines · Dmitry V. Levin
Quoted 26 lines · Christian Brauner
--- man3/ttyname.3 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)man3/ttyname.3 +5
-1@@ -75,7 +75,7 @@ was too small to allow storing the pathname. .\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 .B ENODEV File descriptor refers to a slave pseudoterminal device -but the corresponding pathname could not be found. +but the corresponding pathname could not be found (see NOTES). .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).@@ -93,6 +93,22 @@ T} Thread safety MT-Safe .TE .SH CONFORMING TO POSIX.1-2001, POSIX.1-2008, 4.2BSD. +.SH NOTES +Processes keeping a file descriptor to a +.BR pts (4) +device open when switching to
Quoted 8 lines
man3/ttyname.3 T} Thread safety MT-Safe · line 105
Quoted 6 lines
man3/ttyname.3 +6
-0+.BR mount_namespaces (7) +that use a different +.IR /dev/ptmx +instance may still accidently find that a device path of the same name +for that file descriptor exists. However, this device path refers to a +different device and thus cannot not be used to modify the device thats/to modify the device/to access the device/
Thanks, Dmitry. Fixed!
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Michael Kerrisk (man-pages)
AppliedRe: [PATCH] ttyname(3): add NOTES section
In reply to a message not in the archiveHello Christian,
Quoted 1 line · Christian Brauner
Thanks! Applied.
Cheers,
Michael
Quoted 41 lines
--- man3/ttyname.3 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)man3/ttyname.3 +17
-1@@ -75,7 +75,7 @@ was too small to allow storing the pathname. .\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 .B ENODEV File descriptor refers to a slave pseudoterminal device -but the corresponding pathname could not be found. +but the corresponding pathname could not be found (see NOTES). .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).@@ -93,6 +93,22 @@ T} Thread safety MT-Safe .TE .SH CONFORMING TO POSIX.1-2001, POSIX.1-2008, 4.2BSD. +.SH NOTES +Processes keeping a file descriptor to a +.BR pts (4) +device open when switching to +.BR mount_namespaces (7) +that use a different +.IR /dev/ptmx +instance may still accidently find that a device path of the same name +for that file descriptor exists. However, this device path refers to a +different device and thus cannot not be used to modify the device that +the file descriptor refers to. Calling +.BR ttyname (7) +or +.BR ttyname_r (7) +on the file descriptor in such a mount namespace will cause these +functions to return NULL and set errno to ENODEV. .SH SEE ALSO .BR tty (1), .BR fstat (2),
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170320205104.GA27434-u2l5PoMzF/[email protected]
Quoted 3 lines · Dmitry V. Levin
--- man3/ttyname.3 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Thanks, Dmitry! Applied.
Cheers,
Michael
Quoted 24 lines
man3/ttyname.3 +7
-1@@ -71,6 +71,11 @@ File descriptor does not refer to a terminal device. .RB ( ttyname_r ()) .I buflen was too small to allow storing the pathname. +.TP +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.B ENODEV +File descriptor refers to a slave pseudoterminal device +but the corresponding pathname could not be found. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7).@@ -92,4 +97,5 @@ POSIX.1-2001, POSIX.1-2008, 4.2BSD. .BR tty (1), .BR fstat (2), .BR ctermid (3), -.BR isatty (3) +.BR isatty (3), +.BR pts (4)
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html