Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2019 21:56:10 +0000 (UTC)
From:      Boris Samorodov <bsam@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r492865 - in head/devel/libserialport: . files
Message-ID:  <201902132156.x1DLuAPK070844@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bsam
Date: Wed Feb 13 21:56:10 2019
New Revision: 492865
URL: https://svnweb.freebsd.org/changeset/ports/492865

Log:
  devel/libserialport: Don't open serial ports when enumerating
  
  PR:		230843
  Submitted by:	kevans

Added:
  head/devel/libserialport/files/
  head/devel/libserialport/files/patch-freebsd.c   (contents, props changed)
Modified:
  head/devel/libserialport/Makefile

Modified: head/devel/libserialport/Makefile
==============================================================================
--- head/devel/libserialport/Makefile	Wed Feb 13 21:07:13 2019	(r492864)
+++ head/devel/libserialport/Makefile	Wed Feb 13 21:56:10 2019	(r492865)
@@ -3,6 +3,7 @@
 
 PORTNAME=	libserialport
 PORTVERSION=	0.1.1
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	http://sigrok.org/download/source/libserialport/
 

Added: head/devel/libserialport/files/patch-freebsd.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/libserialport/files/patch-freebsd.c	Wed Feb 13 21:56:10 2019	(r492865)
@@ -0,0 +1,37 @@
+--- freebsd.c.orig	2018-07-17 13:22:11 UTC
++++ freebsd.c
+@@ -327,9 +327,8 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***li
+ 	DIR *dir;
+ 	struct dirent entry;
+ 	struct dirent *result;
+-	struct termios tios;
+ 	char name[PATH_MAX];
+-	int fd, ret;
++	int ret;
+ 
+ 	DEBUG("Enumerating tty devices");
+ 	if (!(dir = opendir("/dev")))
+@@ -353,21 +352,10 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***li
+ 		DEBUG_FMT("Found device %s", name);
+ 
+ 		/* Check that we can open tty/cua device in rw mode - we need that. */
+-		if ((fd = open(name, O_RDWR | O_NONBLOCK | O_NOCTTY | O_TTY_INIT | O_CLOEXEC)) < 0) {
+-			DEBUG("Open failed, skipping");
++		if (access(name, R_OK | W_OK) != 0) {
++			DEBUG("access(2) check failed, skipping");
+ 			continue;
+ 		}
+-
+-		/* Sanity check if we got a real tty. */
+-		if (!isatty(fd)) {
+-			close(fd);
+-			continue;
+-		}
+-
+-		ret = tcgetattr(fd, &tios);
+-		close(fd);
+-		if (ret < 0 || cfgetospeed(&tios) <= 0 || cfgetispeed(&tios) <= 0)
+-			continue;
+ 
+ 		DEBUG_FMT("Found port %s", name);
+ 		DBG("%s: %s\n", __func__, entry.d_name);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902132156.x1DLuAPK070844>