Author: trasz
Date: Mon Aug 24 12:33:42 2020
New Revision: 364662
URL: https://svnweb.freebsd.org/changeset/base/364662

Log:
  MFC r355820:
  
  Add a hack to make ^T work for Linux binaries, enabled with
  'compat.linux.preserve_vstatus=1' sysctl.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/share/man/man4/linux.4
  stable/12/sys/compat/linux/linux_ioctl.c
  stable/12/sys/compat/linux/linux_ioctl.h
  stable/12/sys/compat/linux/linux_mib.c
  stable/12/sys/compat/linux/linux_mib.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/man/man4/linux.4
==============================================================================
--- stable/12/share/man/man4/linux.4    Mon Aug 24 12:30:43 2020        
(r364661)
+++ stable/12/share/man/man4/linux.4    Mon Aug 24 12:33:42 2020        
(r364662)
@@ -109,6 +109,14 @@ Recent versions of GNU libc are known to use different
 on the value of this sysctl.
 .It Va compat.linux.oss_version
 Linux Open Sound System version.
+.It Va compat.linux.preserve_vstatus
+When set to 1, it prevents Linux applications from resetting the
+.Xr termios 4
+VSTATUS setting.
+From a user perspective, this makes
+.Va SIGINFO
+work for Linux executables.
+Defaults to 0.
 .Sh FILES
 .Bl -tag -width /compat/linux/dev/shm -compact
 .It Pa /compat/linux

Modified: stable/12/sys/compat/linux/linux_ioctl.c
==============================================================================
--- stable/12/sys/compat/linux/linux_ioctl.c    Mon Aug 24 12:30:43 2020        
(r364661)
+++ stable/12/sys/compat/linux/linux_ioctl.c    Mon Aug 24 12:33:42 2020        
(r364662)
@@ -552,6 +552,8 @@ bsd_to_linux_termios(struct termios *bios, struct linu
        lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD];
        lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE];
        lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT];
+       if (linux_preserve_vstatus)
+               lios->c_cc[LINUX_VSTATUS] = bios->c_cc[VSTATUS];
 
        for (i=0; i<LINUX_NCCS; i++) {
                if (i != LINUX_VMIN && i != LINUX_VTIME &&
@@ -692,6 +694,8 @@ linux_to_bsd_termios(struct linux_termios *lios, struc
        bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD];
        bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE];
        bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT];
+       if (linux_preserve_vstatus)
+               bios->c_cc[VSTATUS] = lios->c_cc[LINUX_VSTATUS];
 
        for (i=0; i<NCCS; i++) {
                if (i != VMIN && i != VTIME &&

Modified: stable/12/sys/compat/linux/linux_ioctl.h
==============================================================================
--- stable/12/sys/compat/linux/linux_ioctl.h    Mon Aug 24 12:30:43 2020        
(r364661)
+++ stable/12/sys/compat/linux/linux_ioctl.h    Mon Aug 24 12:33:42 2020        
(r364662)
@@ -437,6 +437,7 @@
 #define        LINUX_VWERASE           14
 #define        LINUX_VLNEXT            15
 #define        LINUX_VEOL2             16
+#define        LINUX_VSTATUS           18
 #define        LINUX_NCCS              19
 
 #define        LINUX_POSIX_VDISABLE    '\0'

Modified: stable/12/sys/compat/linux/linux_mib.c
==============================================================================
--- stable/12/sys/compat/linux/linux_mib.c      Mon Aug 24 12:30:43 2020        
(r364661)
+++ stable/12/sys/compat/linux/linux_mib.c      Mon Aug 24 12:33:42 2020        
(r364662)
@@ -62,6 +62,10 @@ static unsigned linux_osd_jail_slot;
 
 SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0, "Linux mode");
 
+int linux_preserve_vstatus = 0;
+SYSCTL_INT(_compat_linux, OID_AUTO, preserve_vstatus, CTLFLAG_RWTUN,
+    &linux_preserve_vstatus, 0, "Preserve VSTATUS termios(4) flag");
+
 static int     linux_set_osname(struct thread *td, char *osname);
 static int     linux_set_osrelease(struct thread *td, char *osrelease);
 static int     linux_set_oss_version(struct thread *td, int oss_version);

Modified: stable/12/sys/compat/linux/linux_mib.h
==============================================================================
--- stable/12/sys/compat/linux/linux_mib.h      Mon Aug 24 12:30:43 2020        
(r364661)
+++ stable/12/sys/compat/linux/linux_mib.h      Mon Aug 24 12:33:42 2020        
(r364662)
@@ -62,4 +62,6 @@ int   linux_kernver(struct thread *td);
 
 #define        linux_use26(t)          (linux_kernver(t) >= 
LINUX_KERNVER_2006000)
 
+extern int linux_preserve_vstatus;
+
 #endif /* _LINUX_MIB_H_ */
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to