[PATCH 2/2] ntdll: Do a device check before returning a default serial port name.
Alex Henrie
alexhenrie24 at gmail.com
Wed Dec 23 22:58:44 CST 2015
Fixes https://bugs.winehq.org/show_bug.cgi?id=39793
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
dlls/ntdll/directory.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index f3c6aa2..05cc2a0 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -83,6 +83,9 @@
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
#include <time.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -336,6 +339,21 @@ static char *get_default_com_device( int num )
ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/ttyS256") );
if (!ret) return NULL;
sprintf( ret, "/dev/ttyS%d", num - 1 );
+
+ /* ttyS0 through ttyS3 always exist on Linux even if they don't work */
+ /* do a basic functionality check like NTDETECT does before advertising a serial port */
+ {
+ int fd;
+ struct termios attrs;
+
+ fd = open( ret, O_RDONLY );
+ if ( tcgetattr( fd, &attrs ) < 0 )
+ {
+ RtlFreeHeap( GetProcessHeap(), 0, ret );
+ ret = NULL;
+ }
+ close( fd );
+ }
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuau256") );
if (!ret) return NULL;
--
2.6.4
More information about the wine-patches
mailing list