--- libftdi-0.20/src/ftdi.c 2012-11-16 10:32:50.000000000 -0600 +++ ftdi.eperm.c 2012-11-16 10:30:12.303281040 -0600 @@ -358,6 +358,8 @@ int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct usb_device * dev, char * manufacturer, int mnf_len, char * description, int desc_len, char * serial, int serial_len) { + int err; + if ((ftdi==NULL) || (dev==NULL)) return -1; @@ -366,27 +368,33 @@ if (manufacturer != NULL) { - if (usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iManufacturer, manufacturer, mnf_len) <= 0) + if ((err = usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iManufacturer, manufacturer, mnf_len)) <= 0) { ftdi_usb_close_internal (ftdi); + if (err == -EPERM) + ftdi_error_return(-4, usb_strerror()); ftdi_error_return(-7, usb_strerror()); } } if (description != NULL) { - if (usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iProduct, description, desc_len) <= 0) + if ((err = usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iProduct, description, desc_len)) <= 0) { ftdi_usb_close_internal (ftdi); + if (err == -EPERM) + ftdi_error_return(-4, usb_strerror()); ftdi_error_return(-8, usb_strerror()); } } if (serial != NULL) { - if (usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iSerialNumber, serial, serial_len) <= 0) + if ((err = usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iSerialNumber, serial, serial_len)) <= 0) { ftdi_usb_close_internal (ftdi); + if (err == -EPERM) + ftdi_error_return(-4, usb_strerror()); ftdi_error_return(-9, usb_strerror()); } } @@ -641,6 +649,7 @@ struct usb_bus *bus; struct usb_device *dev; char string[256]; + int err; usb_init(); @@ -664,9 +673,11 @@ if (description != NULL) { - if (usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iProduct, string, sizeof(string)) <= 0) + if ((err = usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iProduct, string, sizeof(string))) <= 0) { ftdi_usb_close_internal (ftdi); + if (err == -EPERM) + ftdi_error_return(-4, "unable to fetch product description"); ftdi_error_return(-8, "unable to fetch product description"); } if (strncmp(string, description, sizeof(string)) != 0) @@ -678,9 +689,11 @@ } if (serial != NULL) { - if (usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iSerialNumber, string, sizeof(string)) <= 0) + if ((err = usb_get_string_simple(ftdi->usb_dev, dev->descriptor.iSerialNumber, string, sizeof(string))) <= 0) { ftdi_usb_close_internal (ftdi); + if (err == -EPERM) + ftdi_error_return(-4, "unable to fetch serial number"); ftdi_error_return(-9, "unable to fetch serial number"); } if (strncmp(string, serial, sizeof(string)) != 0)