mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
parent
970f279ae4
commit
5bd33b7c8b
@ -119,6 +119,9 @@ AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
|
|||||||
AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
|
AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
|
||||||
[AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
|
[AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
|
||||||
|
|
||||||
|
# Check for readlinkat.
|
||||||
|
AC_CHECK_FUNC([readlinkat], [AC_DEFINE(HAVE_READLINKAT, 1)], [])
|
||||||
|
|
||||||
saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
|
saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
__attribute__((visibility("hidden"))) void foo(void) { }
|
__attribute__((visibility("hidden"))) void foo(void) { }
|
||||||
|
8
linux.c
8
linux.c
@ -161,6 +161,9 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
|||||||
char name[PATH_MAX], target[PATH_MAX];
|
char name[PATH_MAX], target[PATH_MAX];
|
||||||
struct dirent entry, *result;
|
struct dirent entry, *result;
|
||||||
struct serial_struct serial_info;
|
struct serial_struct serial_info;
|
||||||
|
#ifndef HAVE_READLINKAT
|
||||||
|
char buf[sizeof(entry.d_name) + 16];
|
||||||
|
#endif
|
||||||
int len, fd, ioctl_result;
|
int len, fd, ioctl_result;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
int ret = SP_OK;
|
int ret = SP_OK;
|
||||||
@ -171,7 +174,12 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
|||||||
|
|
||||||
DEBUG("Iterating over results");
|
DEBUG("Iterating over results");
|
||||||
while (!readdir_r(dir, &entry, &result) && result) {
|
while (!readdir_r(dir, &entry, &result) && result) {
|
||||||
|
#ifdef HAVE_READLINKAT
|
||||||
len = readlinkat(dirfd(dir), entry.d_name, target, sizeof(target));
|
len = readlinkat(dirfd(dir), entry.d_name, target, sizeof(target));
|
||||||
|
#else
|
||||||
|
snprintf(buf, sizeof(buf), "/sys/class/tty/%s", entry.d_name);
|
||||||
|
len = readlink(buf, target, sizeof(target));
|
||||||
|
#endif
|
||||||
if (len <= 0 || len >= (int) sizeof(target)-1)
|
if (len <= 0 || len >= (int) sizeof(target)-1)
|
||||||
continue;
|
continue;
|
||||||
target[len] = 0;
|
target[len] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user