From: Greg KH <gregkh@linuxfoundation.org>
To: stsp <stsp2@yandex.ru>
Cc: linux-serial@vger.kernel.org,
Linux kernel <linux-kernel@vger.kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Johan Hovold <johan@kernel.org>
Subject: Re: [regression] ENOTTY returned for tty fds
Date: Wed, 24 Jul 2024 12:15:39 +0200 [thread overview]
Message-ID: <2024072401-obtain-heap-6d8d@gregkh> (raw)
In-Reply-To: <be1a3839-23a6-4726-9018-3d18a27163be@yandex.ru>
On Wed, Jul 24, 2024 at 12:55:22PM +0300, stsp wrote:
> 24.07.2024 12:08, Greg KH пишет:
> > On Wed, Jul 24, 2024 at 11:07:32AM +0300, stsp wrote:
> > > 24.07.2024 09:51, Greg KH пишет:
> > > > What caused this change/regression?
> > > I have absolutely no idea.
> > > I've found it by debugging userspace,
> > > and wrote a test-case to make sure the
> > > problem is not in user-space.
> > So this has always worked this way? Or has it changed? If changed,
> > when did it work before?
>
> OK, I did some extensive digging, and
> now am pretty sure its this one:
>
> commit 1b8b20868a6d64cfe8174a21b25b74367bdf0560
> Author: Johan Hovold <johan@kernel.org>
> AuthorDate: Wed Apr 7 11:52:02 2021 +0200
> Commit: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> CommitDate: Sat Apr 10 10:36:34 2021 +0200
>
> tty: fix return value for unsupported ioctls
>
> Drivers should return -ENOTTY ("Inappropriate I/O control operation")
> when an ioctl isn't supported, while -EINVAL is used for invalid
> arguments.
>
> > > > And does any real-world programs
> > > > rely on this?
> > > dosemu
> > It does this today or wants to do this in the future?
>
> It does so since 2003/03/15, according
> to a change-log (so for 21 year now).
> Adding Herbert Xu to CC as an author of
> that feature.
>
> > > > What exactly are you trying to determine with this ioctl
> > > > test?
> > > Whether it is a PTS (Pseudo-Tty-Slave), or
> > > a real comport with MSR signalling.
> > Why is that needed?
>
> To fake modem status lines, mustly DCD.
>
>
> > And why not do it how other programs (like stty)
> > does it?
>
> I am not sure stty is interested in faking
> modem status lines. It doesn't seem to be
> using TIOCM ioctls at all.
>
> > > > Is there a different way to determine that?
> > > I am not aware of any "canonical" way
> > > of determining this. Maybe you tell me. :)
> > > So far the only fix I know, is to stop checking
> > > errno. But you return ENOTTY for a tty-associated
> > > fd (isatty(fd)==1), so I believe this is a
> > > bug in a kernel.
> > isatty() is a libc provided function, not a kernel call.
> It seems to be using TCGETS ioctl() and looks
> for it to not return an error.
> I still think returning ENOTTY where TCGETS
> succeeds, is more than strange.
> I looked at the tty code of current linux kernel,
> and it returns EOPNOTSUPP in most such cases.
> At least that makes sense, but ENOTTY?
-ENOTTY is the documented result of invalid ioctl arguments sent, I am
pretty sure POSIX requires this somewhere. So this was fixing a
requirement here...
thanks,
greg k-h
next prev parent reply other threads:[~2024-07-24 10:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b6f4aa5c-10ba-411b-994b-6dbed2bf63db@yandex.ru>
[not found] ` <2024072452-pegboard-undying-4245@gregkh>
2024-07-24 8:07 ` [regression] ENOTTY returned for tty fds stsp
2024-07-24 9:08 ` Greg KH
2024-07-24 9:55 ` stsp
2024-07-24 10:15 ` Greg KH [this message]
2024-07-24 10:53 ` Herbert Xu
2024-07-24 10:58 ` Herbert Xu
2024-07-31 10:25 ` Greg KH
2024-07-31 16:12 ` Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024072401-obtain-heap-6d8d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=stsp2@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox