From: "H. Peter Anvin" <hpa@zytor.com>
To: Ned Ulbricht <nedu@netscape.net>,
"Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Greg KH <gregkh@linuxfoundation.org>,
"Theodore Ts'o" <tytso@mit.edu>,
Maarten Brock <Maarten.Brock@sttls.nl>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: RFC: Serial port DTR/RTS - O_<something>
Date: Tue, 18 Nov 2025 09:31:33 -0800 [thread overview]
Message-ID: <274BA19A-1432-481F-9BA1-6983DFABD542@zytor.com> (raw)
In-Reply-To: <06279d25-73d6-01f5-dcf8-8667415048d2@netscape.net>
On November 18, 2025 8:33:07 AM PST, Ned Ulbricht <nedu@netscape.net> wrote:
>On 11/15/25 16:47, H. Peter Anvin wrote:
>> On 2025-11-15 13:29, Ned Ulbricht wrote:
>>> |
>>> | O_TTY_INIT
>>>
>>> https://pubs.opengroup.org/onlinepubs/9799919799/
>>>
>>> That's what motivates my first-glance preference to name this new flag,
>>> which will have approximately opposite behavior, as O_TTY_NOINIT.
>>>
>>> But as a generic abstraction, I more prefer O_KEEP.
>>>
>>
>> O_KEEP seems a little vague, but O_KEEPCONFIG seems like a decent name.
>>
>> It seems like we don't have several new flags:
>>
>> O_EXEC
>> O_SEARCH
>> O_CLOFORK
>> O_TTY_INIT
>> O_RSYNC
>> O_NOCLOBBER
>>
>> Some of them *may* be possible to construct with existing Linux options, I'm
>> not 100% sure; in particular O_SEARCH might be the same as (O_DIRECTORY|O_PATH).
>>
>> O_NOCLOBBER looks like an odd in-between between O_EXCL and
>> (O_EXCL|O_NOFOLLOW); stated to be specifically to implement the shell
>> "noclobber" semantic.
>
>"(O_EXCL|O_NOFOLLOW)" provokes a thought...
>
>As essential context, fs/open.c build_open_flags() has:
>
>if (flags & O_CREAT) {
> op->intent |= LOOKUP_CREATE;
> if (flags & O_EXCL) {
> op->intent |= LOOKUP_EXCL;
> flags |= O_NOFOLLOW;
> }
>}
>
>if (!(flags & O_NOFOLLOW))
> lookup_flags |= LOOKUP_FOLLOW;
>
>So with that context, just imagine hypothetically implementing both a
>non-zero O_TTY_INIT flag and an O_KEEPCONFIG flag. What would
>build_open_flags() look like to handle the case where userspace
>simultaneously asserts both flags? Even if it's documented, specified
>as unspecified behavior, what would the code actually do?
>
>Or, alternatively, should an hypothetical standardization insist that in
>any implementation, one of O_TTY_INIT, O_KEEPCONFIG must be #define'd 0?
>
>
>Ned
It's not actually a contradiction: it means preserve all configuration *except* the minimal termios tweaks required to bring it inside the POSIX compliant envelope, notably setting winsize to "appropriate default parameters."
Linux doesn't have a lot of such settings, but I can see at least one *very useful* one: bringing B19200 and B38400 (EXTA and EXTB), which can be tweaked by setserial, back to their proper baud rates.
There are even two ways to do that: either keep the B19200/B38400 setting and change the baud rate, or keep the baud rate and change termios to match (using BOTHER if necessary; after my changes to glibc 2.42+ BOTHER is a private interface between glibc and the kernel and thus doesn't break POSIX compliance.)
A fairly reasonable implementation would be the first with O_TTY_INIT and the second with O_TTY_INIT | O_KEEPCONFIG.
Flags in termios that probably should be cleared by O_TTY_INIT are CMSPAR, OLCUC, IUCLC, IMAXBEL, ECHOPRT, ECHOKE, FLUSHO, PENDIN, IEXTEN and EXTPROC; I'm not sure about ADDRB, CRTSCTS, IUTF8 or the line discipline; at least with O_KEEPCONFIG at least CRTSCTS ought to be kept I would think, as changing it would have immediate effect visible to
Obviously an application that wants to absolutely minimize changes must not pass O_TTY_INIT.
The other (and simpler!) option is to simply declare O_KEEPCONFIG | O_TTY_INIT as a reserved bit combination and return -EINVAL until we find a good reason to do anything different.
next prev parent reply other threads:[~2025-11-18 17:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 7:53 RFC: Serial port DTR/RTS - O_NRESETDEV H. Peter Anvin
2025-11-07 17:37 ` Theodore Ts'o
2025-11-09 2:25 ` H. Peter Anvin
2025-11-10 3:35 ` Theodore Ts'o
2025-11-10 5:00 ` H. Peter Anvin
2025-11-10 10:06 ` Maarten Brock
2025-11-10 20:19 ` Theodore Ts'o
2025-11-10 21:05 ` H. Peter Anvin
2025-11-11 3:51 ` Theodore Ts'o
2025-11-11 3:57 ` H. Peter Anvin
2025-11-11 4:38 ` Theodore Ts'o
2025-11-11 10:21 ` Maarten Brock
2025-11-11 21:28 ` H. Peter Anvin
2025-11-12 11:22 ` Greg KH
2025-11-12 16:09 ` H. Peter Anvin
2025-11-12 16:46 ` Greg KH
2025-11-12 19:12 ` H. Peter Anvin
2025-11-12 19:39 ` Greg KH
2025-11-12 19:53 ` H. Peter Anvin
2025-11-12 19:55 ` H. Peter Anvin
2025-11-13 22:24 ` RFC: Serial port DTR/RTS - O_<something> H. Peter Anvin
2025-11-14 10:26 ` Maarten Brock
2025-11-14 18:49 ` Maciej W. Rozycki
2025-11-14 18:53 ` H. Peter Anvin
2025-11-15 21:29 ` Ned Ulbricht
2025-11-15 22:29 ` H. Peter Anvin
2025-11-16 0:47 ` H. Peter Anvin
2025-11-18 16:33 ` Ned Ulbricht
2025-11-18 17:31 ` H. Peter Anvin [this message]
2025-11-18 18:05 ` H. Peter Anvin
2025-11-20 13:31 ` Ned Ulbricht
2025-11-10 5:20 ` RFC: Serial port DTR/RTS - O_NRESETDEV H. Peter Anvin
2025-11-09 20:43 ` Maciej W. Rozycki
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=274BA19A-1432-481F-9BA1-6983DFABD542@zytor.com \
--to=hpa@zytor.com \
--cc=Maarten.Brock@sttls.nl \
--cc=gregkh@linuxfoundation.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=nedu@netscape.net \
--cc=tytso@mit.edu \
/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
all inboxes | Powered by JetHome®