View | Details | Raw Unified | Return to bug 230843
Collapse All | Expand All

(-)files/patch-freebsd.c (+37 lines)
Line 0 Link Here
1
--- freebsd.c.orig	2018-07-17 13:22:11 UTC
2
+++ freebsd.c
3
@@ -327,9 +327,8 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***li
4
 	DIR *dir;
5
 	struct dirent entry;
6
 	struct dirent *result;
7
-	struct termios tios;
8
 	char name[PATH_MAX];
9
-	int fd, ret;
10
+	int ret;
11
 
12
 	DEBUG("Enumerating tty devices");
13
 	if (!(dir = opendir("/dev")))
14
@@ -353,21 +352,10 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***li
15
 		DEBUG_FMT("Found device %s", name);
16
 
17
 		/* Check that we can open tty/cua device in rw mode - we need that. */
18
-		if ((fd = open(name, O_RDWR | O_NONBLOCK | O_NOCTTY | O_TTY_INIT | O_CLOEXEC)) < 0) {
19
-			DEBUG("Open failed, skipping");
20
+		if (access(name, R_OK | W_OK) != 0) {
21
+			DEBUG("access(2) check failed, skipping");
22
 			continue;
23
 		}
24
-
25
-		/* Sanity check if we got a real tty. */
26
-		if (!isatty(fd)) {
27
-			close(fd);
28
-			continue;
29
-		}
30
-
31
-		ret = tcgetattr(fd, &tios);
32
-		close(fd);
33
-		if (ret < 0 || cfgetospeed(&tios) <= 0 || cfgetispeed(&tios) <= 0)
34
-			continue;
35
 
36
 		DEBUG_FMT("Found port %s", name);
37
 		DBG("%s: %s\n", __func__, entry.d_name);

Return to bug 230843