Skip to contentSkip to conversation

ioctl02: Use correct termios structure

PATCH In review Martin Doucha 4 participants 4 messages Feb 26, 2024 – Jan 30, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ioctl02: Use correct termios structure

The termios structure definition in <termios.h> is incompatible with direct ioctl() calls. The correct definition is in <asm/termbits.h>

---
 testcases/kernel/syscalls/ioctl/ioctl02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl02.c +1 -1
index aab80b251..f3bfb239a 100644
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <termios.h>
+#include <asm/termbits.h>
 
 #include "lapi/ioctl.h"
 #include "tst_test.h"
Signature · 5 lines
2.42.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Martin,

Quoted 2 lines

The termios structure definition in <termios.h> is incompatible with direct ioctl() calls. The correct definition is in <asm/termbits.h>

Thanks, merged!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Martin Doucha

Hi all,

FYI this LTP commit merged as 697a06a827 [1] which is needed to fix ioctl02.c test on ppc64le on all kernel versions breaks compilation on Buildroot bootlin-sparc64-glibc toolchain (gcc: 13.3.0, kernel headers: 4.19.255, glibc: 2.39):

In file included from br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/sys/ioctl.h:29,
from ../../../../include/lapi/ioctl.h:11,
from ioctl02.c:31:
br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/bits/ioctl-types.h:36:8: error: redefinition of ‘struct termio’
36 | struct termio
| ^~~~~~
In file included from ioctl02.c:29:
br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm/termbits.h:17:8: note: originally defined here
17 | struct termio {

The problem is with kernel <asm/termbits.h> incompatibility with glibc <bits/ioctl-types.h> included via <sys/ioctl.h> which is needed by ioctl02.c and also by LTP library include/safe_macros_fn.h.

This problem was fixed a year ago in kernel v6.10-rc1 in commit c32d18e7942d ("sparc: move struct termio to asm/termios.h") [2].

Because nobody noticed this change I suppose nobody uses LTP on sparc64 or people compile LTP on sparc64 with new kernel headers.

@Cyril @Martin FYI another example of conflicting glibc and kernel headers (not listed in [3]). IMHO nothing to be done on LTP side unless we can magically put back <termios.h> and have ppc64le working with it.

@Buildroot As I wrote, because LTP needs this fix for ppc64le (arch actually tested by LTP developers), the only solution for Buildroot is to require toolchain based on v6.10 kernel headers for sparc64 (quite a big limitation for several cross compilation toolchain, some are based on 4.19 kernel headers, 5.11 requirement for musl effectively disables LTP on Buildroot on musl).

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/commit/697a06a827978887e4c88710dc7d31d6f3ee816a
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c32d18e7942d7589b62e301eb426b32623366565
[3] https://sourceware.org/glibc/wiki/Synchronizing_Headers

Quoted 21 lines

The termios structure definition in <termios.h> is incompatible with direct ioctl() calls. The correct definition is in <asm/termbits.h>

---
 testcases/kernel/syscalls/ioctl/ioctl02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl02.c +1 -1
index aab80b251..f3bfb239a 100644
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <termios.h>
+#include <asm/termbits.h>
 
 #include "lapi/ioctl.h"
 #include "tst_test.h"
#3 lore raw
Quoted 36 lines · Petr Vorel

Hi all,

FYI this LTP commit merged as 697a06a827 [1] which is needed to fix ioctl02.c test on ppc64le on all kernel versions breaks compilation on Buildroot bootlin-sparc64-glibc toolchain (gcc: 13.3.0, kernel headers: 4.19.255, glibc: 2.39):

In file included from br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/sys/ioctl.h:29,
from ../../../../include/lapi/ioctl.h:11,
from ioctl02.c:31:
br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/bits/ioctl-types.h:36:8: error: redefinition of ‘struct termio’
36 | struct termio
| ^~~~~~
In file included from ioctl02.c:29:
br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm/termbits.h:17:8: note: originally defined here
17 | struct termio {

The problem is with kernel <asm/termbits.h> incompatibility with glibc <bits/ioctl-types.h> included via <sys/ioctl.h> which is needed by ioctl02.c and also by LTP library include/safe_macros_fn.h.

This problem was fixed a year ago in kernel v6.10-rc1 in commit c32d18e7942d ("sparc: move struct termio to asm/termios.h") [2].

Because nobody noticed this change I suppose nobody uses LTP on sparc64 or people compile LTP on sparc64 with new kernel headers.

@Cyril @Martin FYI another example of conflicting glibc and kernel headers (not listed in [3]). IMHO nothing to be done on LTP side unless we can magically put back <termios.h> and have ppc64le working with it.

@Buildroot As I wrote, because LTP needs this fix for ppc64le (arch actually tested by LTP developers), the only solution for Buildroot is to require toolchain based on v6.10 kernel headers for sparc64 (quite a big limitation for several cross compilation toolchain, some are based on 4.19 kernel headers, 5.11 requirement for musl effectively disables LTP on Buildroot on musl).

Quoted 6 lines

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/commit/697a06a827978887e4c88710dc7d31d6f3ee816a
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c32d18e7942d7589b62e301eb426b32623366565
[3] https://sourceware.org/glibc/wiki/Synchronizing_Headers

The patch in [2] was also applied to stable branches, so it is also included in v6.6.74, v6.1.127, v5.15.177, v5.10.233, and v5.4.289 kernel versions that are currently used by Buildroot master.

For the 4.19 kernel it is in place since v4.19.316.

Cheers,
Andreas