[Bug 223117] [PATCH] sysutils/nut USB drivers process errors in wrong way and sometimes kill themselves without real reason

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Oct 19 15:28:34 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223117

            Bug ID: 223117
           Summary: [PATCH] sysutils/nut USB drivers process errors in
                    wrong way and sometimes kill themselves without real
                    reason
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: cy at FreeBSD.org
          Reporter: lev at FreeBSD.org
          Keywords: patch
          Assignee: cy at FreeBSD.org
             Flags: maintainer-feedback?(cy at FreeBSD.org)

Created attachment 187311
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=187311&action=edit
Patch to place into file/ directory.

It is well-known problem, mostly with blazer_usb drive, but not limited to it,
that sometimes USB driver reports "Permission error" and exits without any
visible reason (permissions are Ok or driver run as root). This problem was
reported on mailing lists and forums for FreeBSD 9, 10 and 11, and not for
other operating systems.

I found reason for these problems: current (2.7.4) version of NUT uses
libusb-0.1 API. All processing of USB errors in NUT sources assumes that
"return values less than zero" of libusb-0.1 calls means "negated errno codes",
and have special processing for some errors, like "-EPERM" (which is -1, as
EPERM is 1). 

FreeBSD uses wrappers around libusb-1.0 API to provide libusb-0.1 API and uses
libusb-1.0 error codes (which are negative!), and -1 is LIBUSB_ERROR_IO, whcih
should not kill driver but must trigger reconnect.

NUT has project to use libusb-1.0 API, and, I hope, they fix this problem in
the course of this project (I've reported this problem to NUT developers), but
for now I've hacked up quick-n-dirty patch to fix problem with nut 2.7.4.

Main problem with this patch, is I copy'n'pasted error definitions from
"/usr/include/libusb.h", as I found that it is hard to include system include
together with project-local include.

Patch is attached. Please note, that it is patch for "files/" directory, not
patch for port directory, PORTREVISION must be tweaked as well.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-ports-bugs mailing list