[PATCH v4] linux/termio: remove <termio.h> and struct termio

H. Peter Anvin hpa@zytor.com
Sat Apr 26 20:21:46 GMT 2025


On 4/25/25 08:44, Florian Weimer wrote:
> * H. Peter Anvin:
> 
>> The <termio.h> interface is absolutely ancient: it was obsoleted by
>> <termios.h> already in the first version of POSIX (1988) and thus
>> predates the very first version of Linux. Unfortunately, some constant
>> macros are used both by <termio.h> and <termios.h>; particularly
>> problematic is the baud rate constants since the termio interface
>> *requires* that the baud rate is set via an enumeration as part of
>> c_cflag.
>>
>> In preparation of revamping the termios interface to support the
>> arbitrary baud rate capability that the Linux kernel has supported
>> since 2008, remove <termio.h> in the hope that no one still uses this
>> archaic interface.
>>
>> Note that there is no actual code in glibc to support termio: it is
>> purely an unabstracted ioctl() interface.
>>
>> [ v4: fix botched patch ]
>> [ v3: rebase onto current master ceeffd970c56893885cbf8382ae34b015f177850 ]
>> [ v2: remove separate struct termio definitions for mips and sparc ]
>>
>> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
>> ---
>>   NEWS                                               |  5 +++++
>>   sysdeps/unix/sysv/linux/Makefile                   |  6 ------
>>   sysdeps/unix/sysv/linux/bits/ioctl-types.h         | 11 -----------
>>   sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h    | 12 ------------
>>   sysdeps/unix/sysv/linux/powerpc/bits/ioctl-types.h | 11 -----------
>>   sysdeps/unix/sysv/linux/termio.h                   |  6 ------
>>   6 files changed, 5 insertions(+), 46 deletions(-)
>>   delete mode 100644 sysdeps/unix/sysv/linux/termio.h
> 
> I've pushed that.  It's headed towards Fedora rawhide, so we'll see if
> there's any breakage soon.  Likewise for OpenSUSE tumbleweed.
> 

So Linaro reports that this breaks gcc libsanitizer. This is simply 
because of the following lines

sanitizer_common/sanitizer_platform_limits_posix.cpp [488-490]:

#if SANITIZER_GLIBC || SANITIZER_ANDROID
   unsigned struct_termio_sz = sizeof(struct termio);
#endif

struct_termio_sz is then used in sanitizer_common_interceptors_ioctl.inc.

I see a few ways of fixing this:

1. In glibc: remove <termio.h> but leave the definition of struct termio 
in <sys/ioctl.h>

2. Completely remove the above statement in gcc;

3. Do a weird hack in gcc hard-coding the size of legacy struct termio;

4. In gcc, get struct termio from <linux/termios.h> instead. This is 
arguably More Correct anyway; libsanitizer is formally incorrect because 
it gets the termios ioctls wrong (confusing glibc struct termios with 
the kernel one.)

The real issue I guess is if we want to leave the struct termio in 
sys/ioctl.h for the time being to avoid breaking the gcc build, or if we 
want to push a patch into gcc and accept the breakage of libsanitizer in 
the short term. I suspect the answer is no, and that we should thus fall 
back on only removing <termio.h> for now.



More information about the Libc-alpha mailing list