Description: Fix FTBFS caused by glibc removing termio.h and struct termio
 The <termio.h> header and struct termio are no longer provided by
 newer glibc, so building fails with "fatal error: termio.h: No such
 file or directory". Switch to the POSIX termios interface instead:
 include <termios.h> and <sys/ioctl.h> in utils/magsgtty.h, and use
 struct termios with the TCGETS/TCSETSF ioctls in textio/txInput.c
 instead of struct termio with TCGETA/TCSETAF.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: other
Forwarded: not-needed
Last-Update: 2026-09-04

--- magic-8.3.105+ds.1.orig/textio/txInput.c
+++ magic-8.3.105+ds.1/textio/txInput.c
@@ -1209,10 +1209,10 @@ TxGetLine(dest, maxChars)
 
 void
 txGetTermState(buf)
-    struct termio *buf;
+    struct termios *buf;
 
 {
-    ioctl( fileno( stdin ), TCGETA, buf);
+    ioctl( fileno( stdin ), TCGETS, buf);
 }
 
 #else
@@ -1246,13 +1246,13 @@ txGetTermState(buf)
 void
 txSetTermState(buf)
 #if defined(SYSV) || defined(CYGWIN)
-    struct termio *buf;
+    struct termios *buf;
 #else
     txTermState *buf;
 #endif /* SYSV */
 {
 #if defined(SYSV) || defined(CYGWIN)
-    ioctl( fileno(stdin), TCSETAF, buf );
+    ioctl( fileno(stdin), TCSETSF, buf );
 #else
     /* set the current terminal characteristics */
     (void) ioctl(fileno(stdin), TIOCSETN, (char *) &(buf->tx_i_sgtty) );
@@ -1281,7 +1281,7 @@ txSetTermState(buf)
 void
 txInitTermRec(buf)
 #if defined(SYSV) || defined(CYGWIN)
-    struct termio *buf;
+    struct termios *buf;
 #else
     txTermState *buf;
 #endif /* SYSV */
@@ -1302,7 +1302,7 @@ txInitTermRec(buf)
 
 
 #if defined(SYSV) || defined(CYGWIN)
-struct termio closeTermState;
+struct termios closeTermState;
 #else
 static txTermState closeTermState;
 #endif /* SYSV */
@@ -1329,7 +1329,7 @@ void
 txSaveTerm()
 {
 #if defined(SYSV) || defined(CYGWIN)
-    ioctl( fileno( stdin ), TCGETA, &closeTermState);
+    ioctl( fileno( stdin ), TCGETS, &closeTermState);
     txEraseChar = closeTermState.c_cc[VERASE];
     txKillChar =  closeTermState.c_cc[VKILL];
     TxEOFChar = closeTermState.c_cc[VEOF];
@@ -1370,7 +1370,7 @@ void
 TxSetTerminal()
 {
 #if defined(SYSV) || defined(CYGWIN)
-    struct termio buf;
+    struct termios buf;
 #else
     txTermState buf;
 #endif /* SYSV */
--- magic-8.3.105+ds.1.orig/utils/magsgtty.h
+++ magic-8.3.105+ds.1/utils/magsgtty.h
@@ -36,7 +36,13 @@
 #include <sys/ioctl_compat.h>
 
 #else
-#include <termio.h>
+/* <termio.h> (and struct termio) was removed from newer glibc.
+ * Use the POSIX termios interface instead; <termios.h> and
+ * <sys/ioctl.h> provide struct termios, TCGETS/TCSETSF and the
+ * c_cc indices used by this code.
+ */
+#include <termios.h>
+#include <sys/ioctl.h>
 #endif
 
 #endif	/* _MAGSGTTY_H */

