linux-user: Implement ioctl cmd TIOCGPTPEER
authorAndreas Schwab <schwab@suse.de>
Mon, 29 Jan 2018 10:47:06 +0000 (11:47 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Sun, 18 Feb 2018 17:52:32 +0000 (18:52 +0100)
With glibc 2.27 the openpty function prefers the TIOCGPTPEER ioctl.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <mvmbmhdosb9.fsf_-_@suse.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
20 files changed:
linux-user/aarch64/termbits.h
linux-user/alpha/termbits.h
linux-user/arm/termbits.h
linux-user/cris/termbits.h
linux-user/hppa/termbits.h
linux-user/i386/termbits.h
linux-user/ioctls.h
linux-user/m68k/termbits.h
linux-user/microblaze/termbits.h
linux-user/mips/termbits.h
linux-user/nios2/termbits.h
linux-user/openrisc/termbits.h
linux-user/ppc/termbits.h
linux-user/s390x/termbits.h
linux-user/sh4/termbits.h
linux-user/sparc/termbits.h
linux-user/sparc64/termbits.h
linux-user/syscall.c
linux-user/tilegx/termbits.h
linux-user/x86_64/termbits.h

index b64ba974cf1cd356c239cfcd4de01442ea8af536..f9f80f0f378b897708bb15559d8a12738a43387c 100644 (file)
@@ -187,6 +187,8 @@ struct target_termios {
         /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK       TARGET_IOW('T', 0x31, int)
         /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41)
+        /* Safely open the slave */
 
 #define TARGET_FIONCLEX         0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX          0x5451
index 6406b6a7991078f6be57e30034a7645df0edd451..139bc87fa6d268f386afa297cce51a811f6c50f4 100644 (file)
@@ -245,6 +245,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_TIOCSERCONFIG   0x5453
 #define TARGET_TIOCSERGWILD    0x5454
index 7772df175ca8aaff57b3445a3db7e49e3e169c77..a61e138ec4b15a8b14b2235445ce3ed5ec7cd0f3 100644 (file)
@@ -185,6 +185,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index fc82ca084ec4628121b77a6099c6e7cb5445ba56..c825cd2f5e44951f1ac2ee8b7fd94dd8133f3115 100644 (file)
@@ -182,6 +182,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index e9633ef1194d2078ef9f2599e4b1b662170d7b05..ad51c9c9118ffb4855cf277557029c52525d651d 100644 (file)
@@ -186,6 +186,8 @@ struct target_termios {
         /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK       TARGET_IOW('T', 0x31, int)
         /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41)
+        /* Safely open the slave */
 
 #define TARGET_FIONCLEX         0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX          0x5451
index e051a3af749149f3f54e2a6a962725b65f31b951..32dd0dde5d612fcd081c93d7053dafa0147ef356 100644 (file)
@@ -195,6 +195,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index 35cad6f944c1b30578d11ae61ec6477c16998848..586c794639e2603dea2b766034f9400d52cf9555 100644 (file)
@@ -40,6 +40,9 @@
      IOCTL(TIOCSETD, IOC_W, MK_PTR(TYPE_INT))
      IOCTL(TIOCGPTN, IOC_R, MK_PTR(TYPE_INT))
      IOCTL(TIOCSPTLCK, IOC_W, MK_PTR(TYPE_INT))
+#ifdef TIOCGPTPEER
+     IOCTL_SPECIAL(TIOCGPTPEER, 0, do_ioctl_tiocgptpeer, TYPE_INT)
+#endif
      IOCTL(FIOCLEX, 0, TYPE_NULL)
      IOCTL(FIONCLEX, 0, TYPE_NULL)
      IOCTL(FIOASYNC, IOC_W, MK_PTR(TYPE_INT))
index f7982fb6c25d34a64266853190d3a87ca3a7fa1b..9df58dc5cb8ffbeb97a5ac248c39023ada0afb3c 100644 (file)
@@ -196,6 +196,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index fc82ca084ec4628121b77a6099c6e7cb5445ba56..c825cd2f5e44951f1ac2ee8b7fd94dd8133f3115 100644 (file)
@@ -182,6 +182,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index a0bcad09461d76e128fb13d0fd9adcbd36a2bc8b..49a72c5539022aacfff55dbc0af40ff1bb4ed452 100644 (file)
@@ -233,6 +233,7 @@ struct target_termios {
 #define TARGET_TIOCGPKT         TARGET_IOR('T', 0x38, int)
 #define TARGET_TIOCGPTLCK       TARGET_IOR('T', 0x39, int)
 #define TARGET_TIOCGEXCL        TARGET_IOR('T', 0x40, int)
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41)
 
 /* I hope the range from 0x5480 on is free ... */
 #define TARGET_TIOCSCTTY       0x5480          /* become controlling tty */
index b64ba974cf1cd356c239cfcd4de01442ea8af536..f9f80f0f378b897708bb15559d8a12738a43387c 100644 (file)
@@ -187,6 +187,8 @@ struct target_termios {
         /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK       TARGET_IOW('T', 0x31, int)
         /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41)
+        /* Safely open the slave */
 
 #define TARGET_FIONCLEX         0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX          0x5451
index 373af77215732e9fa91147c903fa351977b44609..231a49806b10c8edf3bcd7add1a32ccf7b5826c0 100644 (file)
@@ -245,6 +245,8 @@ struct target_termios3 {
 #define TARGET_TIOCGPTN        TARGET_IOR('T', 0x30, unsigned int)
 /* Lock/unlock Pty */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T', 0x31, int)
+/* Safely open the slave */
+#define TARGET_TIOCGPTPEER     TARGET_IO('T', 0x41)
 /* Get primary device node of /dev/console */
 #define TARGET_TIOCGDEV        TARGET_IOR('T', 0x32, unsigned int)
 #define TARGET_TCGETX          0x5432 /* SYS5 TCGETX compatibility */
index 73e7151756f1068f375adeeac1789cae74156b43..a5b1bb783b9663cc710fbc8898e30ce0e0df3a02 100644 (file)
@@ -219,6 +219,7 @@ struct target_termios {
 #define TARGET_TIOCGSID        0x5429  /* Return the session ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_TIOCSERCONFIG   0x5453
 #define TARGET_TIOCSERGWILD    0x5454
index 2a78a05594abcbf48e4befdd6c711e9522963f75..8bcca89cd7c09c9452f31b0e8230c9178711371b 100644 (file)
@@ -252,6 +252,7 @@ struct target_ktermios {
 #define TARGET_TIOCGPTN        _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK      _IOW('T',0x31, int)  /* Lock/unlock Pty */
 #define TARGET_TIOCGDEV        _IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451
index 2ff774f6ba19f3cad71aefbff3c554a7b88e23f4..5723ed7752379b4a88cebd729a28aeb8b67c4891 100644 (file)
@@ -250,6 +250,7 @@ ID of FD */
 #define TARGET_TIOCGPTN        TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-m
 ux device) */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER     TARGET_IO('T', 0x41) /* Safely open the slave */
 
 
 #define TARGET_TIOCSERCONFIG   TARGET_IO('T', 83) /* 0x5453 */
index 691600d27a71fa57ee7dfdc9c5f9d3b9bdd6134d..113d6dfbdb285acdb56835c69897569bba30e358 100644 (file)
@@ -245,6 +245,7 @@ struct target_termios {
 /* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */
 #define TARGET_TIOCGPTN        TARGET_IOR('t', 134, unsigned int) /* Get Pty Number */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('t', 135, int) /* Lock/unlock PTY */
+#define TARGET_TIOCGPTPEER      TARGET_IO('t', 137) /* Safely open the slave */
 
 /* Little f */
 #define TARGET_FIOCLEX         TARGET_IO('f', 1)
index 691600d27a71fa57ee7dfdc9c5f9d3b9bdd6134d..113d6dfbdb285acdb56835c69897569bba30e358 100644 (file)
@@ -245,6 +245,7 @@ struct target_termios {
 /* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */
 #define TARGET_TIOCGPTN        TARGET_IOR('t', 134, unsigned int) /* Get Pty Number */
 #define TARGET_TIOCSPTLCK      TARGET_IOW('t', 135, int) /* Lock/unlock PTY */
+#define TARGET_TIOCGPTPEER      TARGET_IO('t', 137) /* Safely open the slave */
 
 /* Little f */
 #define TARGET_FIOCLEX         TARGET_IO('f', 1)
index 82b35a6bdff5a58c0cc6a82aacc43c10b60ac3ea..effc3a08816222120832e5b8aebd314ea70380d4 100644 (file)
@@ -5636,6 +5636,15 @@ static abi_long do_ioctl_kdsigaccept(const IOCTLEntry *ie, uint8_t *buf_temp,
     return get_errno(safe_ioctl(fd, ie->host_cmd, sig));
 }
 
+#ifdef TIOCGPTPEER
+static abi_long do_ioctl_tiocgptpeer(const IOCTLEntry *ie, uint8_t *buf_temp,
+                                     int fd, int cmd, abi_long arg)
+{
+    int flags = target_to_host_bitmask(arg, fcntl_flags_tbl);
+    return get_errno(safe_ioctl(fd, ie->host_cmd, flags));
+}
+#endif
+
 static IOCTLEntry ioctl_entries[] = {
 #define IOCTL(cmd, access, ...) \
     { TARGET_ ## cmd, cmd, #cmd, access, 0, {  __VA_ARGS__ } },
index 91ec23654e3a4ca0ff57b5e09a3847d60d49491c..966daec0880f1f3dea7685a3a42f87268c02b930 100644 (file)
@@ -242,6 +242,7 @@ struct target_termios2 {
 #define TARGET_TIOCGPKT                 TARGET_IOR('T', 0x38, int)
 #define TARGET_TIOCGPTLCK               TARGET_IOR('T', 0x39, int)
 #define TARGET_TIOCGEXCL                TARGET_IOR('T', 0x40, int)
+#define TARGET_TIOCGPTPEER              TARGET_IO('T', 0x41)
 
 #define TARGET_FIONCLEX                 0x5450
 #define TARGET_FIOCLEX                  0x5451
index 387e74259279bdd585a207a6e59e155c7e3f2e62..f5776a8aa6f641235cf190694c909807d6956213 100644 (file)
@@ -215,6 +215,7 @@ struct target_termios {
 #define TARGET_TCSETSF2         TARGET_IOW('T',0x2D, struct termios2)
 #define TARGET_TIOCGPTN         TARGET_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TARGET_TIOCSPTLCK       TARGET_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TARGET_TIOCGPTPEER      TARGET_IO('T', 0x41) /* Safely open the slave */
 
 #define TARGET_FIONCLEX        0x5450  /* these numbers need to be adjusted. */
 #define TARGET_FIOCLEX         0x5451