in src/main/c/Posix/PosixHelperFunctions.c [274:296]
static char isUsbSerialSubsystem(const char *subsystemLink)
{
// Attempt to read the path that the subsystem link points to
struct stat fileInfo;
char *subsystem = NULL, isUsbSerial = 0;
if (lstat(subsystemLink, &fileInfo) == 0)
{
ssize_t bufferSize = fileInfo.st_size ? (fileInfo.st_size + 1) : PATH_MAX;
subsystem = (char*)malloc(bufferSize);
if (subsystem)
{
ssize_t subsystemSize = readlink(subsystemLink, subsystem, bufferSize);
if (subsystemSize >= 0)
{
subsystem[subsystemSize] = '\0';
if (strcmp(1 + strrchr(subsystem, '/'), "usb-serial") == 0)
isUsbSerial = 1;
}
free(subsystem);
}
}
return isUsbSerial;
}