PSARC/2016/137 libusb 1.0 s11u3-sru
authorJan Parcel <jan.parcel@oracle.com>
Wed, 06 Jul 2016 18:36:46 -0700
branchs11u3-sru
changeset 6359 f969c4942506
parent 6358 3b2a73b969a9
child 6360 9d123b58131d
PSARC/2016/137 libusb 1.0 22583186 Need to update libusb.so to the latest opensource version available 23008017 invalid free in sunos_async_callback() in libusb 22978185 libusb 1.0 manpage 23500244 packaging and manpage fixes in libusb-1
components/libusb-1/Makefile
components/libusb-1/libusb-1.0.license
components/libusb-1/libusb-1.3lib
components/libusb-1/libusb-1.p5m
components/libusb-1/patches/01-libusb.patch
components/libusb-1/patches/02-libusb.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/Makefile	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,73 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+include ../../make-rules/shared-macros.mk
+
+COMPILER=		gcc
+COMPONENT_NAME=		libusb
+COMPONENT_VERSION=	1.0.20
+COMPONENT_PROJECT_URL=	http://libusb.info/
+COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
+COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.bz2
+COMPONENT_ARCHIVE_HASH=	\
+	sha256:cb057190ba0a961768224e4dc6883104c6f945b2bf2ef90d7da39e7c1834f7ff
+COMPONENT_ARCHIVE_URL=	\
+	http://sourceforge.net/projects/libusb/files/libusb-1.0/$(COMPONENT_SRC)/$(COMPONENT_ARCHIVE)
+COMPONENT_BUGDB=	library/libusb
+
+TPNO=			26906
+
+include $(WS_MAKE_RULES)/prep.mk
+include $(WS_MAKE_RULES)/configure.mk
+include $(WS_MAKE_RULES)/ips.mk
+include $(WS_MAKE_RULES)/lint-libraries.mk
+
+CONFIGURE_ENV += "CFLAGS=$(CFLAGS)"
+
+CONFIGURE_OPTIONS  += --enable-static=no
+CONFIGURE_OPTIONS  += --enable-log
+
+COMPONENT_BUILD_ARGS += "LDFLAGS=$(LDFLAGS)"
+COMPONENT_BUILD_ARGS += "INSTALL=$(INSTALL)"
+COMPONENT_BUILD_ARGS += "MAKE=$(GMAKE)"
+COMPONENT_BUILD_ARGS += -C doc docs
+
+ASLR_MODE = $(ASLR_ENABLE)
+
+PROTOUSRSHAREDOCDIR = $(PROTOUSRSHAREDIR)/doc/libusb-1.0
+
+COMPONENT_PREP_ACTION = (cd $(@D); $(AUTORECONF) -if)
+
+configure:	$(CONFIGURE_32_and_64)
+
+build:		$(BUILD_32_and_64)
+
+install:	$(INSTALL_32_and_64)
+	cd $(BUILD_DIR_64); \
+	$(MKDIR) -p $(PROTOUSRSHAREDOCDIR); \
+	$(CP) -r doc/html $(PROTOUSRSHAREDOCDIR)
+
+test:		$(TEST_32_and_64)
+
+system-test:    $(SYSTEM_TESTS_NOT_IMPLEMENTED)
+
+REQUIRED_PACKAGES += system/library
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/libusb-1.0.license	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,504 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/libusb-1.3lib	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,85 @@
+'\" te
+.\" Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+.TH libusb-1.0 3LIB "10 April 2016" "SunOS 5.11" "Interface Libraries"
+.SH NAME
+libusb-1, libusb-1.0 \- A cross-platform user library to access USB devices
+.SH SYNOPSIS
+.LP
+.nf
+cc [ \fIflag\fR... ] \fB-I\fR/usr/include/libusb-1.0 \fIfile\fR... \e
+    \fB -lusb-1.0 \fR [ \fIlibrary\fR... ]
+#include <libusb.h>
+.fi
+
+.SH DESCRIPTION
+.sp
+.LP
+The \fBlibusb 1.0\fR provides a set of APIs to manage USB devices without a kernel driver. It is an open-source API supported on Linux, MacOS X, Solaris, and NetBSD. See http://libusb.info.
+.sp
+.LP
+Complete documentation for this library can be found at \fB/usr/share/doc/libusb-1.0/html/index.html\fR. 
+.sp
+.LP
+NOTE, libusb 1.0 API is not compatible to libusb 0.1, see \fBlibusb\fR(3LIB) for the API information of version 0.1.x.
+.SH INTERFACES
+.sp
+.LP
+See \fB/usr/share/doc/libusb-1.0/html/api.html\fR for the complete list of \fBlibusb 1.0\fR functions, structures and enumerations. The shared object \fBlibusb-1.0.so.0\fR provides the public interfaces. See \fBIntro\fR(3) for additional information on shared object interfaces.
+.sp
+
+.sp
+
+.SH FILES
+.sp
+.ne 2
+.mk
+.na
+\fB\fB/usr/lib/libusb-1.0.so.0\fR\fR
+.ad
+.RS 29n
+.rt  
+shared object
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fB/usr/lib/64/libusb-1.0.so.0\fR\fR
+.ad
+.RS 29n
+.rt  
+64-bit shared object
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fB/usr/lib/pkgconfig/libusb-1.0.pc\fR\fR
+.ad
+.RS 29n
+.rt  
+.sp
+script to determine linking environment
+.RE
+
+.sp
+.ne 2
+.mk
+.na
+\fB\fB/usr/lib/64/pkgconfig/libusb-1.0.pc\fR\fR
+.ad
+.RS 29n
+.rt  
+.sp
+script to determine 64-bit linking environment
+.RE
+
+.SH SEE ALSO
+.sp
+.LP
+\fBIntro\fR(3), \fBlibusb\fR(3LIB)
+.sp
+.LP
+http://libusb.info
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/libusb-1.p5m	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,106 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+
+<transform file path=usr.*/man/.+ -> default mangler.man.stability "Pass-through Volatile" >
+set name=pkg.fmri \
+    value=pkg:/library/libusb-1@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary value="A cross-platform user library to access USB devices"
+set name=pkg.description \
+    value="A cross-platform user library to support libusb 1.0 APIs"
+set name=com.oracle.info.description value="Libusb 1.0"
+set name=com.oracle.info.tpno value=$(TPNO)
+set name=info.classification value=org.opensolaris.category.2008:Development/C
+set name=info.source-url value=$(COMPONENT_ARCHIVE_URL)
+set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
+set name=org.opensolaris.arc-caseid value=PSARC/2016/137
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+dir  path=usr/include/libusb-1.0
+file path=usr/include/libusb-1.0/libusb.h
+link path=usr/lib/$(MACH64)/libusb-1.0.so target=libusb-1.0.so.0.1.0
+link path=usr/lib/$(MACH64)/libusb-1.0.so.0 target=libusb-1.0.so.0.1.0
+file path=usr/lib/$(MACH64)/libusb-1.0.so.0.1.0
+file path=usr/lib/$(MACH64)/pkgconfig/libusb-1.0.pc
+link path=usr/lib/libusb-1.0.so target=libusb-1.0.so.0.1.0
+link path=usr/lib/libusb-1.0.so.0 target=libusb-1.0.so.0.1.0
+file path=usr/lib/libusb-1.0.so.0.1.0
+file path=usr/lib/pkgconfig/libusb-1.0.pc
+file path=usr/share/doc/libusb-1.0/html/annotated.html
+file path=usr/share/doc/libusb-1.0/html/api.html
+file path=usr/share/doc/libusb-1.0/html/bc_s.png
+file path=usr/share/doc/libusb-1.0/html/caveats.html
+file path=usr/share/doc/libusb-1.0/html/classes.html
+file path=usr/share/doc/libusb-1.0/html/closed.png
+file path=usr/share/doc/libusb-1.0/html/contexts.html
+file path=usr/share/doc/libusb-1.0/html/doxygen.css
+file path=usr/share/doc/libusb-1.0/html/doxygen.png
+file path=usr/share/doc/libusb-1.0/html/dynsections.js
+file path=usr/share/doc/libusb-1.0/html/files.html
+file path=usr/share/doc/libusb-1.0/html/functions.html
+file path=usr/share/doc/libusb-1.0/html/functions_vars.html
+file path=usr/share/doc/libusb-1.0/html/group__asyncio.html
+file path=usr/share/doc/libusb-1.0/html/group__desc.html
+file path=usr/share/doc/libusb-1.0/html/group__dev.html
+file path=usr/share/doc/libusb-1.0/html/group__hotplug.html
+file path=usr/share/doc/libusb-1.0/html/group__lib.html
+file path=usr/share/doc/libusb-1.0/html/group__misc.html
+file path=usr/share/doc/libusb-1.0/html/group__poll.html
+file path=usr/share/doc/libusb-1.0/html/group__syncio.html
+file path=usr/share/doc/libusb-1.0/html/hotplug.html
+file path=usr/share/doc/libusb-1.0/html/index.html
+file path=usr/share/doc/libusb-1.0/html/io.html
+file path=usr/share/doc/libusb-1.0/html/jquery.js
+file path=usr/share/doc/libusb-1.0/html/libusb_8h_source.html
+file path=usr/share/doc/libusb-1.0/html/modules.html
+file path=usr/share/doc/libusb-1.0/html/mtasync.html
+file path=usr/share/doc/libusb-1.0/html/nav_f.png
+file path=usr/share/doc/libusb-1.0/html/nav_h.png
+file path=usr/share/doc/libusb-1.0/html/open.png
+file path=usr/share/doc/libusb-1.0/html/packetoverflow.html
+file path=usr/share/doc/libusb-1.0/html/pages.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__bos__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__bos__dev__capability__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__config__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__container__id__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__control__setup.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__device__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__endpoint__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__interface__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__interface.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__iso__packet__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__pollfd.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__ss__endpoint__companion__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__ss__usb__device__capability__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__transfer.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__usb__2__0__extension__descriptor.html
+file path=usr/share/doc/libusb-1.0/html/structlibusb__version.html
+file path=usr/share/doc/libusb-1.0/html/tab_a.png
+file path=usr/share/doc/libusb-1.0/html/tab_b.png
+file path=usr/share/doc/libusb-1.0/html/tab_h.png
+file path=usr/share/doc/libusb-1.0/html/tab_s.png
+file path=usr/share/doc/libusb-1.0/html/tabs.css
+file path=usr/share/doc/libusb-1.0/html/version__nano_8h_source.html
+file path=usr/share/doc/libusb-1.0/html/version_8h_source.html
+file libusb-1.3lib path=usr/share/man/man3lib/libusb-1.3lib
+license libusb-1.0.license license=LGPLv2.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/patches/01-libusb.patch	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,1451 @@
+Solaris support for libusb 1.0, see upstream bug https://github.com/libusb/libusb/issues/169
+
+diff -Naur libusb-1.0.20/configure.ac libusb-1.0.20.new/configure.ac
+--- libusb-1.0.20/configure.ac	2015-09-05 10:20:40.000000000 -0700
++++ libusb-1.0.20.new/configure.ac	2016-03-10 00:35:25.712129055 -0800
+@@ -95,6 +95,12 @@
+ 	backend="haiku"
+ 	threads="posix"
+ 	;;
++*-solaris*)
++	AC_MSG_RESULT([SunOS])
++	backend="sunos"
++	threads="posix"
++	;;
++
+ *)
+ 	AC_MSG_ERROR([unsupported operating system])
+ esac
+@@ -157,6 +163,16 @@
+ 	AC_CHECK_HEADERS([poll.h])
+ 	AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+ 	;;
++
++sunos)
++	AC_DEFINE(OS_SUNOS, 1, [SunOS backend])
++	AC_SUBST(OS_SUNOS)
++	THREAD_CFLAGS="-pthread"
++	LIBS="-pthread -ldevinfo"
++	AC_CHECK_HEADERS([poll.h])
++	AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
++	;;
++
+ netbsd)
+ 	AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
+ 	AC_SUBST(OS_NETBSD)
+@@ -187,6 +203,7 @@
+ AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
+ AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
+ AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
++AM_CONDITIONAL(OS_SUNOS, test "x$backend" = xsunos)
+ AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
+ AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
+ AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku)
+diff -Naur libusb-1.0.20/libusb/Makefile.am libusb-1.0.20.new/libusb/Makefile.am
+--- libusb-1.0.20/libusb/Makefile.am	2015-09-05 10:20:40.000000000 -0700
++++ libusb-1.0.20.new/libusb/Makefile.am	2016-03-10 00:19:22.549380102 -0800
+@@ -9,6 +9,7 @@
+ DARWIN_USB_SRC = os/darwin_usb.c
+ OPENBSD_USB_SRC = os/openbsd_usb.c
+ NETBSD_USB_SRC = os/netbsd_usb.c
++SUNOS_USB_SRC = os/sunos_usb.c os/sunos_usb.h
+ WINDOWS_USB_SRC = os/poll_windows.c os/windows_usb.c libusb-1.0.rc libusb-1.0.def
+ WINCE_USB_SRC = os/wince_usb.c os/wince_usb.h
+ 
+@@ -49,6 +50,10 @@
+ OS_SRC = $(NETBSD_USB_SRC) $(POSIX_POLL_SRC)
+ endif
+ 
++if OS_SUNOS
++OS_SRC = $(SUNOS_USB_SRC) $(POSIX_POLL_SRC)
++endif
++
+ if OS_HAIKU
+ OS_SRC = $(POSIX_POLL_SRC)
+ SUBDIRS = os/haiku
+diff -Naur libusb-1.0.20/libusb/core.c libusb-1.0.20.new/libusb/core.c
+--- libusb-1.0.20/libusb/core.c	2015-09-05 10:30:43.000000000 -0700
++++ libusb-1.0.20.new/libusb/core.c	2016-03-10 00:20:40.154945235 -0800
+@@ -58,6 +58,8 @@
+ const struct usbi_os_backend * const usbi_backend = &wince_backend;
+ #elif defined(OS_HAIKU)
+ const struct usbi_os_backend * const usbi_backend = &haiku_usb_raw_backend;
++#elif defined(OS_SUNOS)
++const struct usbi_os_backend * const usbi_backend = &sunos_backend;
+ #else
+ #error "Unsupported OS"
+ #endif
+diff -Naur libusb-1.0.20/libusb/libusbi.h libusb-1.0.20.new/libusb/libusbi.h
+--- libusb-1.0.20/libusb/libusbi.h	2015-09-13 17:36:19.000000000 -0700
++++ libusb-1.0.20.new/libusb/libusbi.h	2016-03-10 00:23:08.647355689 -0800
+@@ -493,7 +493,8 @@
+ int usbi_clear_event(struct libusb_context *ctx);
+ 
+ /* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
+-#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_HAIKU)
++#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) || \
++	defined(OS_HAIKU) || defined(OS_SUNOS)
+ #include <unistd.h>
+ #include "os/poll_posix.h"
+ #elif defined(OS_WINDOWS) || defined(OS_WINCE)
+@@ -1091,6 +1092,7 @@
+ extern const struct usbi_os_backend windows_backend;
+ extern const struct usbi_os_backend wince_backend;
+ extern const struct usbi_os_backend haiku_usb_raw_backend;
++extern const struct usbi_os_backend sunos_backend;
+ 
+ extern struct list_head active_contexts_list;
+ extern usbi_mutex_static_t active_contexts_lock;
+diff -Naur libusb-1.0.20/libusb/os/sunos_usb.c libusb-1.0.20.new/libusb/os/sunos_usb.c
+--- libusb-1.0.20/libusb/os/sunos_usb.c	1969-12-31 16:00:00.000000000 -0800
++++ libusb-1.0.20.new/libusb/os/sunos_usb.c	2016-03-10 00:24:36.641449583 -0800
+@@ -0,0 +1,1259 @@
++/*
++ *
++ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include <config.h>
++
++#include <sys/time.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <strings.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <aio.h>
++#include <libdevinfo.h>
++#include <sys/usb/clients/ugen/usb_ugen.h>
++#include <sys/usb/usba.h>
++#include <sys/pci.h>
++
++#include "libusbi.h"
++#include "sunos_usb.h"
++
++/*
++ * Backend functions
++ */
++static int sunos_init(struct libusb_context *);
++static void sunos_exit(void);
++static int sunos_get_device_list(struct libusb_context *,
++    struct discovered_devs **);
++static int sunos_open(struct libusb_device_handle *);
++static void sunos_close(struct libusb_device_handle *);
++static int sunos_get_device_descriptor(struct libusb_device *,
++    uint8_t*, int *);
++static int sunos_get_active_config_descriptor(struct libusb_device *,
++    uint8_t*, size_t, int *);
++static int sunos_get_config_descriptor(struct libusb_device *, uint8_t,
++    uint8_t*, size_t, int *);
++static int sunos_get_configuration(struct libusb_device_handle *, int *);
++static int sunos_set_configuration(struct libusb_device_handle *, int);
++static int sunos_claim_interface(struct libusb_device_handle *, int);
++static int sunos_release_interface(struct libusb_device_handle *, int);
++static int sunos_set_interface_altsetting(struct libusb_device_handle *,
++    int, int);
++static int sunos_clear_halt(struct libusb_device_handle *, uint8_t);
++static int sunos_reset_device(struct libusb_device_handle *);
++static void sunos_destroy_device(struct libusb_device *);
++static int sunos_submit_transfer(struct usbi_transfer *);
++static int sunos_cancel_transfer(struct usbi_transfer *);
++static void sunos_clear_transfer_priv(struct usbi_transfer *);
++static int sunos_handle_transfer_completion(struct usbi_transfer *);
++static int sunos_clock_gettime(int, struct timespec *);
++
++/*
++ * Private functions
++ */
++static int _errno_to_libusb(int);
++static int sunos_usb_get_status(int fd);
++
++static int sunos_init(struct libusb_context *ctx)
++{
++	return (LIBUSB_SUCCESS);
++}
++
++static void sunos_exit(void)
++{
++	usbi_dbg("");
++}
++
++static int
++sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
++{
++	int	proplen;
++	int	n, *addr, *port_prop;
++	char	*phypath;
++	uint8_t	*rdata;
++	struct libusb_device_descriptor	*descr;
++	sunos_dev_priv_t	*dpriv = (sunos_dev_priv_t *)dev->os_priv;
++
++	/* Device descriptors */
++	proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
++	    "usb-dev-descriptor", &rdata);
++	if (proplen <= 0) {
++
++		return (LIBUSB_ERROR_IO);
++	}
++
++	descr = (struct libusb_device_descriptor *)rdata;
++	bcopy(descr, &dpriv->dev_descr, LIBUSB_DT_DEVICE_SIZE);
++	dpriv->dev_descr.bcdUSB = libusb_cpu_to_le16(descr->bcdUSB);
++	dpriv->dev_descr.idVendor = libusb_cpu_to_le16(descr->idVendor);
++	dpriv->dev_descr.idProduct = libusb_cpu_to_le16(descr->idProduct);
++	dpriv->dev_descr.bcdDevice = libusb_cpu_to_le16(descr->bcdDevice);
++
++	/* Raw configuration descriptors */
++	proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
++	    "usb-raw-cfg-descriptors", &rdata);
++	if (proplen <= 0) {
++		usbi_dbg("can't find raw config descriptors");
++
++		return (LIBUSB_ERROR_IO);
++	}
++	dpriv->raw_cfgdescr = calloc(1, proplen);
++	if (dpriv->raw_cfgdescr == NULL) {
++		return (LIBUSB_ERROR_NO_MEM);
++	} else {
++		bcopy(rdata, dpriv->raw_cfgdescr, proplen);
++	}
++
++	n = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", &port_prop);
++
++	if ((n != 1) || (*port_prop <= 0)) {
++		return (LIBUSB_ERROR_IO);
++	}
++	dev->port_number = *port_prop;
++
++	/* device physical path */
++	phypath = di_devfs_path(node);
++	if (phypath) {
++		dpriv->phypath = strdup(phypath);
++		di_devfs_path_free(phypath);
++	} else {
++		free(dpriv->raw_cfgdescr);
++
++		return (LIBUSB_ERROR_IO);
++	}
++
++	/* address */
++	n = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "assigned-address", &addr);
++	if (n != 1 || *addr == 0) {
++		usbi_dbg("can't get address");
++	} else {
++		dev->device_address = *addr;
++	}
++
++	/* speed */
++	if (di_prop_exists(DDI_DEV_T_ANY, node, "low-speed") == 1) {
++		dev->speed = LIBUSB_SPEED_LOW;
++	} else if (di_prop_exists(DDI_DEV_T_ANY, node, "high-speed") == 1) {
++		dev->speed = LIBUSB_SPEED_HIGH;
++	} else if (di_prop_exists(DDI_DEV_T_ANY, node, "full-speed") == 1) {
++		dev->speed = LIBUSB_SPEED_FULL;
++	} else if (di_prop_exists(DDI_DEV_T_ANY, node, "super-speed") == 1) {
++		dev->speed = LIBUSB_SPEED_SUPER;
++	}
++
++	usbi_dbg("vid=%x pid=%x, path=%s, bus_nmber=0x%x, port_number=%d, "
++	    "speed=%d", dpriv->dev_descr.idVendor, dpriv->dev_descr.idProduct,
++	    dpriv->phypath, dev->bus_number, dev->port_number, dev->speed);
++
++	return (LIBUSB_SUCCESS);
++}
++
++
++static int
++sunos_add_devices(di_devlink_t link, void *arg)
++{
++	struct devlink_cbarg	*largs = (struct devlink_cbarg *)arg;
++	struct node_args	*nargs;
++	di_node_t		myself, pnode;
++	uint64_t		session_id = 0;
++	uint16_t		bdf = 0;
++	struct libusb_device	*dev;
++	sunos_dev_priv_t	*devpriv;
++	const char		*path, *newpath;
++	int			 n, i;
++	int			*addr_prop;
++	uint8_t			bus_number = 0;
++
++	nargs = (struct node_args *)largs->nargs;
++	myself = largs->myself;
++	if (nargs->last_ugenpath) {
++		/* the same node's links */
++		return (DI_WALK_CONTINUE);
++	}
++
++	/*
++	 * Construct session ID.
++	 * session ID = ...parent hub addr|hub addr|dev addr.
++	 */
++	pnode = myself;
++	i = 0;
++	while (pnode != DI_NODE_NIL) {
++		if (di_prop_exists(DDI_DEV_T_ANY, pnode, "root-hub") == 1) {
++			/* walk to root */
++			uint32_t *regbuf = NULL;
++			uint32_t reg;
++
++			n = di_prop_lookup_ints(DDI_DEV_T_ANY, pnode, "reg",
++			    (int **)&regbuf);
++			reg = regbuf[0];
++			bdf = (PCI_REG_BUS_G(reg) << 8) |
++			    (PCI_REG_DEV_G(reg) << 3) | PCI_REG_FUNC_G(reg);
++			session_id |= (bdf << i * 8);
++
++			/* same as 'unit-address' property */
++			bus_number =
++			    (PCI_REG_DEV_G(reg) << 3) | PCI_REG_FUNC_G(reg);
++
++			usbi_dbg("device bus address=%s:%x",
++			    di_bus_addr(pnode), bus_number);
++
++			break;
++		}
++
++		/* usb_addr */
++		n = di_prop_lookup_ints(DDI_DEV_T_ANY, pnode,
++		    "assigned-address", &addr_prop);
++		if ((n != 1) || (addr_prop[0] == 0)) {
++			usbi_dbg("cannot get valid usb_addr");
++
++			return (DI_WALK_CONTINUE);
++		}
++
++		session_id |= ((addr_prop[0] & 0xff) << i * 8);
++		if (++i > 7)
++			break;
++
++		pnode = di_parent_node(pnode);
++	}
++
++	path = di_devlink_path(link);
++	dev = usbi_get_device_by_session_id(nargs->ctx, session_id);
++	if (dev == NULL) {
++		dev = usbi_alloc_device(nargs->ctx, session_id);
++		if (dev == NULL) {
++			usbi_dbg("can't alloc device");
++
++			return (DI_WALK_TERMINATE);
++		}
++		devpriv = (sunos_dev_priv_t *)dev->os_priv;
++		if ((newpath = strrchr(path, '/')) == NULL) {
++			libusb_unref_device(dev);
++
++			return (DI_WALK_TERMINATE);
++		}
++		devpriv->ugenpath = strndup(path, strlen(path) -
++		    strlen(newpath));
++		dev->bus_number = bus_number;
++
++		if (sunos_fill_in_dev_info(myself, dev) != LIBUSB_SUCCESS) {
++			libusb_unref_device(dev);
++
++			return (DI_WALK_TERMINATE);
++		}
++		if (usbi_sanitize_device(dev) < 0) {
++			libusb_unref_device(dev);
++			usbi_dbg("sanatize failed: ");
++			return (DI_WALK_TERMINATE);
++		}
++	} else {
++		usbi_dbg("Dev %s exists", path);
++	}
++
++	devpriv = (sunos_dev_priv_t *)dev->os_priv;
++	if (nargs->last_ugenpath == NULL) {
++		/* first device */
++		nargs->last_ugenpath = devpriv->ugenpath;
++
++		if (discovered_devs_append(*(nargs->discdevs), dev) == NULL) {
++			usbi_dbg("cannot append device");
++		}
++
++		/*
++		 * we alloc and hence ref this dev. We don't need to ref it
++		 * hereafter. Front end or app should take care of their ref.
++		 */
++		libusb_unref_device(dev);
++	}
++
++	usbi_dbg("Device %s %s id=0x%llx, devcount:%d, bdf=%x",
++	    devpriv->ugenpath, path, (uint64_t)session_id,
++	    (*nargs->discdevs)->len, bdf);
++
++	return (DI_WALK_CONTINUE);
++}
++
++static int
++sunos_walk_minor_node_link(di_node_t node, void *args)
++{
++        di_minor_t minor = DI_MINOR_NIL;
++        char *minor_path;
++        struct devlink_cbarg arg;
++	struct node_args *nargs = (struct node_args *)args;
++	di_devlink_handle_t devlink_hdl = nargs->dlink_hdl;
++
++	/* walk each minor to find ugen devices */
++        while ((minor = di_minor_next(node, minor)) != DI_MINOR_NIL) {
++                minor_path = di_devfs_minor_path(minor);
++                arg.nargs = args;
++		arg.myself = node;
++                arg.minor = minor;
++                (void) di_devlink_walk(devlink_hdl,
++		    "^usb/[0-9a-f]+[.][0-9a-f]+", minor_path,
++		    DI_PRIMARY_LINK, (void *)&arg, sunos_add_devices);
++                di_devfs_path_free(minor_path);
++        }
++
++	/* switch to a different node */
++	nargs->last_ugenpath = NULL;
++
++	return (DI_WALK_CONTINUE);
++}
++
++int
++sunos_get_device_list(struct libusb_context * ctx,
++	struct discovered_devs **discdevs)
++{
++	di_node_t root_node;
++	struct node_args args;
++	di_devlink_handle_t devlink_hdl;
++
++	args.ctx = ctx;
++	args.discdevs = discdevs;
++	args.last_ugenpath = NULL;
++	if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
++		usbi_dbg("di_int() failed: %s", strerror(errno));
++		return (LIBUSB_ERROR_IO);
++	}
++
++	if ((devlink_hdl = di_devlink_init(NULL, 0)) == NULL) {
++		di_fini(root_node);
++		usbi_dbg("di_devlink_init() failed: %s", strerror(errno));
++
++		return (LIBUSB_ERROR_IO);
++	}
++	args.dlink_hdl = devlink_hdl;
++
++	/* walk each node to find USB devices */
++	if (di_walk_node(root_node, DI_WALK_SIBFIRST, &args,
++	    sunos_walk_minor_node_link) == -1) {
++		usbi_dbg("di_walk_node() failed: %s", strerror(errno));
++		di_fini(root_node);
++
++		return (LIBUSB_ERROR_IO);
++	}
++
++	di_fini(root_node);
++	di_devlink_fini(&devlink_hdl);
++
++	usbi_dbg("%d devices", (*discdevs)->len);
++
++	return ((*discdevs)->len);
++}
++
++static int
++sunos_usb_open_ep0(sunos_dev_handle_priv_t *hpriv, sunos_dev_priv_t *dpriv)
++{
++	char filename[PATH_MAX + 1];
++
++	if (hpriv->eps[0].datafd > 0) {
++
++		return (LIBUSB_SUCCESS);
++	}
++	snprintf(filename, PATH_MAX, "%s/cntrl0", dpriv->ugenpath);
++
++	usbi_dbg("opening %s", filename);
++	hpriv->eps[0].datafd = open(filename, O_RDWR);
++	if (hpriv->eps[0].datafd < 0) {
++		return(_errno_to_libusb(errno));
++	}
++
++	snprintf(filename, PATH_MAX, "%s/cntrl0stat", dpriv->ugenpath);
++	hpriv->eps[0].statfd = open(filename, O_RDONLY);
++	if (hpriv->eps[0].statfd < 0) {
++		close(hpriv->eps[0].datafd);
++		hpriv->eps[0].datafd = -1;
++
++		return(_errno_to_libusb(errno));
++	}
++
++	return (LIBUSB_SUCCESS);
++}
++
++static void
++sunos_usb_close_all_eps(sunos_dev_handle_priv_t *hdev)
++{
++	int i;
++
++	/* not close ep0 */
++	for (i = 1; i < USB_MAXENDPOINTS; i++) {
++		if (hdev->eps[i].datafd != -1) {
++			(void) close(hdev->eps[i].datafd);
++			hdev->eps[i].datafd = -1;
++		}
++		if (hdev->eps[i].statfd != -1) {
++			(void) close(hdev->eps[i].statfd);
++			hdev->eps[i].statfd = -1;
++		}
++	}
++}
++
++static void
++sunos_usb_close_ep0(sunos_dev_handle_priv_t *hdev, sunos_dev_priv_t *dpriv)
++{
++	if (hdev->eps[0].datafd >= 0) {
++		close(hdev->eps[0].datafd);
++		close(hdev->eps[0].statfd);
++		hdev->eps[0].datafd = -1;
++		hdev->eps[0].statfd = -1;
++	}
++}
++
++static uchar_t
++sunos_usb_ep_index(uint8_t ep_addr)
++{
++	return ((ep_addr & LIBUSB_ENDPOINT_ADDRESS_MASK) +
++	    ((ep_addr & LIBUSB_ENDPOINT_DIR_MASK) ? 16 : 0));
++}
++
++static int
++sunos_find_interface(struct libusb_device_handle *hdev,
++    uint8_t endpoint, uint8_t *interface)
++{
++	struct libusb_config_descriptor *config;
++	int r;
++	int iface_idx;
++
++	r = libusb_get_active_config_descriptor(hdev->dev, &config);
++	if (r < 0) {
++		return (LIBUSB_ERROR_INVALID_PARAM);
++	}
++
++	for (iface_idx = 0; iface_idx < config->bNumInterfaces; iface_idx++) {
++		const struct libusb_interface *iface =
++		    &config->interface[iface_idx];
++		int altsetting_idx;
++
++		for (altsetting_idx = 0; altsetting_idx < iface->num_altsetting;
++		    altsetting_idx++) {
++			const struct libusb_interface_descriptor *altsetting =
++			    &iface->altsetting[altsetting_idx];
++			int ep_idx;
++
++			for (ep_idx = 0; ep_idx < altsetting->bNumEndpoints;
++			    ep_idx++) {
++				const struct libusb_endpoint_descriptor *ep =
++					&altsetting->endpoint[ep_idx];
++				if (ep->bEndpointAddress == endpoint) {
++					*interface = iface_idx;
++					libusb_free_config_descriptor(config);
++
++					return (LIBUSB_SUCCESS);
++				}
++			}
++		}
++	}
++	libusb_free_config_descriptor(config);
++
++	return (LIBUSB_ERROR_INVALID_PARAM);
++}
++
++static int
++sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
++    uint8_t ep_addr, int ep_type)
++{
++	char	filename[PATH_MAX + 1], statfilename[PATH_MAX + 1];
++	char	cfg_num[16], alt_num[16];
++	int	fd, fdstat, mode;
++	uint8_t	ifc = 0;
++	uint8_t	ep_index;
++	sunos_dev_handle_priv_t *hpriv;
++
++	usbi_dbg("open ep 0x%02x", ep_addr);
++	hpriv = (sunos_dev_handle_priv_t *)hdl->os_priv;
++	ep_index = sunos_usb_ep_index(ep_addr);
++	/* ep already opened */
++	if ((hpriv->eps[ep_index].datafd > 0) &&
++	    (hpriv->eps[ep_index].statfd > 0)) {
++		usbi_dbg("ep 0x%02x already opened, return success",
++			ep_addr);
++
++		return (0);
++	}
++
++	if (sunos_find_interface(hdl, ep_addr, &ifc) < 0) {
++		usbi_dbg("can't find interface for endpoint 0x%02x",
++		    ep_addr);
++
++		return (LIBUSB_ERROR_ACCESS);
++	}
++
++	/* create filename */
++	if (hpriv->config_index > 0) {
++		(void) snprintf(cfg_num, sizeof (cfg_num), "cfg%d",
++		    hpriv->config_index + 1);
++	} else {
++		bzero(cfg_num, sizeof (cfg_num));
++	}
++
++	if (hpriv->altsetting[ifc] > 0) {
++		(void) snprintf(alt_num, sizeof (alt_num), ".%d",
++		    hpriv->altsetting[ifc]);
++	} else {
++		bzero(alt_num, sizeof (alt_num));
++	}
++
++	(void) snprintf(filename, PATH_MAX, "%s/%sif%d%s%s%d",
++	    hpriv->dpriv->ugenpath, cfg_num, ifc, alt_num,
++	    (ep_addr & LIBUSB_ENDPOINT_DIR_MASK) ? "in" :
++	    "out", (ep_addr & LIBUSB_ENDPOINT_ADDRESS_MASK));
++	(void) snprintf(statfilename, PATH_MAX, "%sstat", filename);
++
++	/*
++	 * for interrupt IN endpoints, we need to enable one xfer
++	 * mode before opening the endpoint
++	 */
++	if ((ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT) &&
++	    (ep_addr & LIBUSB_ENDPOINT_IN)) {
++		char	control = USB_EP_INTR_ONE_XFER;
++		int	count;
++
++		/* open the status device node for the ep first RDWR */
++		if ((fdstat = open(statfilename, O_RDWR)) == -1) {
++			usbi_dbg("can't open %s RDWR: %d",
++				statfilename, errno);
++		} else {
++			count = write(fdstat, &control, sizeof (control));
++			if (count != 1) {
++				/* this should have worked */
++				usbi_dbg("can't write to %s: %d",
++					statfilename, errno);
++				(void) close(fdstat);
++
++				return (errno);
++			}
++			/* close status node and open xfer node first */
++			close (fdstat);
++		}
++	}
++
++	/* open the xfer node first in case alt needs to be changed */
++	if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
++		mode = O_RDWR;
++	} else if (ep_addr & LIBUSB_ENDPOINT_IN) {
++		mode = O_RDONLY;
++	} else {
++		mode = O_WRONLY;
++	}
++
++	/*
++	 * IMPORTANT: must open data xfer node first and then open stat node
++	 * Otherwise, it will fail on multi-config or multi-altsetting devices
++	 * with "Device Busy" error. See ugen_epxs_switch_cfg_alt() and
++	 * ugen_epxs_check_alt_switch() in ugen driver source code.
++	 */
++	if ((fd = open(filename, mode)) == -1) {
++		usbi_dbg("can't open %s: %d(%s)", filename, errno,
++		    strerror(errno));
++
++		return (errno);
++	}
++	/* open the status node */
++	if ((fdstat = open(statfilename, O_RDONLY)) == -1) {
++		usbi_dbg("can't open %s: %d", statfilename, errno);
++
++		(void) close(fd);
++
++		return (errno);
++	}
++
++	hpriv->eps[ep_index].datafd = fd;
++	hpriv->eps[ep_index].statfd = fdstat;
++	usbi_dbg("ep=0x%02x datafd=%d, statfd=%d", ep_addr, fd, fdstat);
++
++	return (0);
++}
++
++int
++sunos_open(struct libusb_device_handle *handle)
++{
++	sunos_dev_handle_priv_t	*hpriv;
++	sunos_dev_priv_t	*dpriv;
++	int	i;
++	int	ret;
++
++	hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
++	dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++	hpriv->dpriv = dpriv;
++
++	/* set all file descriptors to "closed" */
++	for (i = 0; i < USB_MAXENDPOINTS; i++) {
++		hpriv->eps[i].datafd = -1;
++		hpriv->eps[i].statfd = -1;
++	}
++
++	if ((ret = sunos_usb_open_ep0(hpriv, dpriv)) != LIBUSB_SUCCESS) {
++		usbi_dbg("fail: %d", ret);
++		return (ret);
++	}
++
++	return (LIBUSB_SUCCESS);
++}
++
++void
++sunos_close(struct libusb_device_handle *handle)
++{
++	sunos_dev_handle_priv_t *hpriv;
++	sunos_dev_priv_t *dpriv;
++
++	usbi_dbg("");
++	if (!handle) {
++		return;
++	}
++
++	hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
++	if (!hpriv) {
++		return;
++	}
++	dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++	if (!dpriv) {
++		return;
++	}
++
++	sunos_usb_close_all_eps(hpriv);
++	sunos_usb_close_ep0(hpriv, dpriv);
++}
++
++int
++sunos_get_device_descriptor(struct libusb_device *dev, uint8_t *buf,
++    int *host_endian)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
++
++	memcpy(buf, &dpriv->dev_descr, LIBUSB_DT_DEVICE_SIZE);
++	*host_endian = 0;
++
++	return (LIBUSB_SUCCESS);
++}
++
++int
++sunos_get_active_config_descriptor(struct libusb_device *dev,
++    uint8_t *buf, size_t len, int *host_endian)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
++	struct libusb_config_descriptor *cfg;
++
++	cfg = (struct libusb_config_descriptor *)dpriv->raw_cfgdescr;
++	len = MIN(len, libusb_le16_to_cpu(cfg->wTotalLength));
++	memcpy(buf, dpriv->raw_cfgdescr, len);
++	*host_endian = 0;
++	usbi_dbg("len %d", len);
++
++	return (len);
++}
++
++int
++sunos_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
++    uint8_t *buf, size_t len, int *host_endian)
++{
++	/* XXX */
++	return(sunos_get_active_config_descriptor(dev, buf, len, host_endian));
++}
++
++int
++sunos_get_configuration(struct libusb_device_handle *handle, int *config)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++
++	*config = dpriv->cfgvalue;
++
++	usbi_dbg("bConfigurationValue %d", *config);
++
++	return (LIBUSB_SUCCESS);
++}
++
++int
++sunos_set_configuration(struct libusb_device_handle *handle, int config)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++	usbi_dbg("bConfigurationValue %d", config);
++
++	if (dpriv->ugenpath == NULL)
++		return (LIBUSB_ERROR_NOT_SUPPORTED);
++
++	if (config < 1 || config > dpriv->dev_descr.bNumConfigurations)
++		return (LIBUSB_ERROR_INVALID_PARAM);
++
++	dpriv->cfgvalue = config;
++
++	return (LIBUSB_SUCCESS);
++}
++
++int
++sunos_claim_interface(struct libusb_device_handle *handle, int iface)
++{
++	usbi_dbg("iface %d", iface);
++	if (iface < 0) {
++		return (LIBUSB_ERROR_INVALID_PARAM);
++	}
++
++	return (LIBUSB_SUCCESS);
++}
++
++int
++sunos_release_interface(struct libusb_device_handle *handle, int iface)
++{
++	sunos_dev_handle_priv_t *hpriv =
++	    (sunos_dev_handle_priv_t *)handle->os_priv;
++
++	usbi_dbg("iface %d", iface);
++	if (iface < 0) {
++		return (LIBUSB_ERROR_INVALID_PARAM);
++	}
++
++	/* XXX: can we release it? */
++	hpriv->altsetting[iface] = 0;
++
++	return (LIBUSB_SUCCESS);
++}
++
++int
++sunos_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
++    int altsetting)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++	sunos_dev_handle_priv_t *hpriv =
++	    (sunos_dev_handle_priv_t *)handle->os_priv;
++
++	usbi_dbg("iface %d, setting %d", iface, altsetting);
++
++	if (iface < 0 || altsetting < 0) {
++		return (LIBUSB_ERROR_INVALID_PARAM);
++	}
++	if (dpriv->ugenpath == NULL)
++		return (LIBUSB_ERROR_NOT_FOUND);
++
++	/* XXX: can we switch altsetting? */
++	hpriv->altsetting[iface] = altsetting;
++
++	return (LIBUSB_SUCCESS);
++}
++
++static void
++usb_dump_data(unsigned char *data, size_t size)
++{
++	int i;
++
++	if (getenv("LIBUSB_DEBUG") == NULL) {
++		return;
++	}
++
++	(void) fprintf(stderr, "data dump:");
++	for (i = 0; i < size; i++) {
++		if (i % 16 == 0) {
++			(void) fprintf(stderr, "\n%08x	", i);
++		}
++		(void) fprintf(stderr, "%02x ", (uchar_t)data[i]);
++	}
++	(void) fprintf(stderr, "\n");
++}
++
++static void
++sunos_async_callback(union sigval arg)
++{
++	struct sunos_transfer_priv *tpriv =
++	    (struct sunos_transfer_priv *)arg.sival_ptr;
++	struct libusb_transfer *xfer = tpriv->transfer;
++	struct aiocb *aiocb = &tpriv->aiocb;
++	int ret;
++	sunos_dev_handle_priv_t *hpriv;
++	uint8_t ep;
++
++	hpriv = (sunos_dev_handle_priv_t *)xfer->dev_handle->os_priv;
++	ep = sunos_usb_ep_index(xfer->endpoint);
++
++	ret = aio_error(aiocb);
++	if (ret != 0) {
++		xfer->status = sunos_usb_get_status(hpriv->eps[ep].statfd);
++	} else {
++		xfer->actual_length =
++		    LIBUSB_TRANSFER_TO_USBI_TRANSFER(xfer)->transferred =
++		    aio_return(aiocb);
++	}
++
++	usb_dump_data(xfer->buffer, xfer->actual_length);
++
++	usbi_dbg("ret=%d, len=%d, actual_len=%d", ret, xfer->length,
++	    xfer->actual_length);
++
++	/* async notification */
++	usbi_signal_transfer_completion(LIBUSB_TRANSFER_TO_USBI_TRANSFER(xfer));
++	free(aiocb);
++}
++
++static int
++sunos_do_async_io(struct libusb_transfer *transfer)
++{
++	int ret = -1;
++	struct aiocb *aiocb;
++	sunos_dev_handle_priv_t *hpriv;
++	uint8_t ep;
++	struct sunos_transfer_priv *tpriv;
++
++	usbi_dbg("");
++
++	tpriv = usbi_transfer_get_os_priv(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer));
++	hpriv = (sunos_dev_handle_priv_t *)transfer->dev_handle->os_priv;
++	ep = sunos_usb_ep_index(transfer->endpoint);
++
++	tpriv->transfer = transfer;
++	aiocb = &tpriv->aiocb;
++	bzero(aiocb, sizeof (*aiocb));
++	aiocb->aio_fildes = hpriv->eps[ep].datafd;
++	aiocb->aio_buf = transfer->buffer;
++	aiocb->aio_nbytes = transfer->length;
++	aiocb->aio_lio_opcode =
++	    ((transfer->endpoint & LIBUSB_ENDPOINT_DIR_MASK) ==
++	    LIBUSB_ENDPOINT_IN) ? LIO_READ:LIO_WRITE;
++	aiocb->aio_sigevent.sigev_notify = SIGEV_THREAD;
++	aiocb->aio_sigevent.sigev_value.sival_ptr = tpriv;
++	aiocb->aio_sigevent.sigev_notify_function = sunos_async_callback;
++
++	if (aiocb->aio_lio_opcode == LIO_READ) {
++		ret = aio_read(aiocb);
++	} else {
++		ret = aio_write(aiocb);
++	}
++
++	return (ret);
++}
++
++/* return the number of bytes read/written */
++static int
++usb_do_io(int fd, int stat_fd, char *data, size_t size, int flag, int *status)
++{
++	int error;
++	int ret = -1;
++
++	usbi_dbg("usb_do_io(): datafd=%d statfd=%d size=0x%x flag=%s",
++	    fd, stat_fd, size, flag? "WRITE":"READ");
++
++	switch (flag) {
++	case READ:
++		errno = 0;
++		ret = read(fd, data, size);
++		usb_dump_data(data, size);
++		break;
++	case WRITE:
++		usb_dump_data(data, size);
++		errno = 0;
++		ret = write(fd, data, size);
++		break;
++	}
++
++	usbi_dbg("usb_do_io(): amount=%d", ret);
++
++	if (ret < 0) {
++		int save_errno = errno;
++
++		usbi_dbg("TID=%x io %s errno=%d(%s) ret=%d", pthread_self(),
++		    flag?"WRITE":"READ", errno, strerror(errno), ret);
++
++		/* sunos_usb_get_status will do a read and overwrite errno */
++		error = sunos_usb_get_status(stat_fd);
++		usbi_dbg("io status=%d errno=%d(%s)", error,
++			save_errno, strerror(save_errno));
++
++		if (status) {
++			*status = save_errno;
++		}
++
++		return (save_errno);
++
++	} else if (status) {
++		*status = 0;
++	}
++
++	return (ret);
++}
++
++static int
++solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
++{
++	int		ret = -1, setup_ret;
++	int		status;
++	sunos_dev_handle_priv_t *hpriv;
++	struct		libusb_device_handle *hdl = transfer->dev_handle;
++	uint16_t	wLength;
++	uint8_t		*data = transfer->buffer;
++
++	hpriv = (sunos_dev_handle_priv_t *)hdl->os_priv;
++	wLength = transfer->length - LIBUSB_CONTROL_SETUP_SIZE;
++
++	if (hpriv->eps[0].datafd == -1) {
++		usbi_dbg("ep0 not opened");
++
++		return (LIBUSB_ERROR_NOT_FOUND);
++	}
++
++	if ((data[0] & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) {
++		usbi_dbg("IN request");
++		ret = usb_do_io(hpriv->eps[0].datafd,
++		    hpriv->eps[0].statfd, (char *)data, LIBUSB_CONTROL_SETUP_SIZE,
++		    WRITE, (int *)&status);
++	} else {
++		usbi_dbg("OUT request");
++		ret = usb_do_io(hpriv->eps[0].datafd, hpriv->eps[0].statfd,
++		    transfer->buffer, transfer->length, WRITE,
++		    (int *)&transfer->status);
++	}
++
++	setup_ret = ret;
++	if (ret < LIBUSB_CONTROL_SETUP_SIZE) {
++		usbi_dbg("error sending control msg: %d", ret);
++
++		return (LIBUSB_ERROR_IO);
++	}
++
++	ret = transfer->length - LIBUSB_CONTROL_SETUP_SIZE;
++
++	/* Read the remaining bytes for IN request */
++	if ((wLength) && ((data[0] & LIBUSB_ENDPOINT_DIR_MASK) ==
++	    LIBUSB_ENDPOINT_IN)) {
++		usbi_dbg("DATA: %d", transfer->length - setup_ret);
++		ret = usb_do_io(hpriv->eps[0].datafd,
++			hpriv->eps[0].statfd,
++			(char *)transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE,
++			wLength, READ, (int *)&transfer->status);
++	}
++
++	if (ret >= 0) {
++		transfer->actual_length = ret;
++		LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer)->transferred = ret;
++	}
++	usbi_dbg("Done: ctrl data bytes %d", ret);
++
++	/* sync transfer handling */
++	ret = usbi_handle_transfer_completion(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer),
++	    transfer->status);
++
++	return (ret);
++}
++
++int
++sunos_clear_halt(struct libusb_device_handle *handle, uint8_t endpoint)
++{
++	int ret;
++
++	usbi_dbg("endpoint=0x%02x", endpoint);
++
++	ret = libusb_control_transfer(handle, LIBUSB_ENDPOINT_OUT |
++	    LIBUSB_RECIPIENT_ENDPOINT | LIBUSB_REQUEST_TYPE_STANDARD,
++	    LIBUSB_REQUEST_CLEAR_FEATURE, 0, endpoint, NULL, 0, 1000);
++
++	usbi_dbg("ret=%d", ret);
++
++	return (ret);
++}
++
++int
++sunos_reset_device(struct libusb_device_handle *handle)
++{
++	usbi_dbg("");
++
++	return (LIBUSB_ERROR_NOT_SUPPORTED);
++}
++
++void
++sunos_destroy_device(struct libusb_device *dev)
++{
++	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
++
++	usbi_dbg("");
++
++	free(dpriv->raw_cfgdescr);
++	free(dpriv->ugenpath);
++	free(dpriv->phypath);
++}
++
++int
++sunos_submit_transfer(struct usbi_transfer *itransfer)
++{
++	struct	libusb_transfer *transfer;
++	struct	libusb_device_handle *hdl;
++	int	err = 0;
++
++	transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
++	hdl = transfer->dev_handle;
++
++	err = sunos_check_device_and_status_open(hdl,
++	    transfer->endpoint, transfer->type);
++	if (err < 0) {
++
++		return (_errno_to_libusb(err));
++	}
++
++	switch (transfer->type) {
++	case LIBUSB_TRANSFER_TYPE_CONTROL:
++		/* sync transfer */
++		usbi_dbg("CTRL transfer: %d", transfer->length);
++		err = solaris_submit_ctrl_on_default(transfer);
++		break;
++
++	case LIBUSB_TRANSFER_TYPE_BULK:
++		/* fallthru */
++	case LIBUSB_TRANSFER_TYPE_INTERRUPT:
++		if (transfer->type == LIBUSB_TRANSFER_TYPE_BULK)
++			usbi_dbg("BULK transfer: %d", transfer->length);
++		else
++			usbi_dbg("INTR transfer: %d", transfer->length);
++		err = sunos_do_async_io(transfer);
++		break;
++
++	case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
++		/* Isochronous/Stream is not supported */
++
++		/* fallthru */
++	case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
++		if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)
++			usbi_dbg("ISOC transfer: %d", transfer->length);
++		else
++			usbi_dbg("BULK STREAM transfer: %d", transfer->length);
++		err = LIBUSB_ERROR_NOT_SUPPORTED;
++		break;
++	}
++
++	return (err);
++}
++
++int
++sunos_cancel_transfer(struct usbi_transfer *itransfer)
++{
++	sunos_xfer_priv_t	*tpriv;
++	sunos_dev_handle_priv_t	*hpriv;
++	struct libusb_transfer	*transfer;
++	struct aiocb	*aiocb;
++	uint8_t		ep;
++	int		ret;
++
++	tpriv = usbi_transfer_get_os_priv(itransfer);
++	aiocb = &tpriv->aiocb;
++	transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
++	hpriv = (sunos_dev_handle_priv_t *)transfer->dev_handle->os_priv;
++	ep = sunos_usb_ep_index(transfer->endpoint);
++
++	ret = aio_cancel(hpriv->eps[ep].datafd, aiocb);
++
++	usbi_dbg("aio->fd=%d fd=%d ret = %d, %s", aiocb->aio_fildes,
++	    hpriv->eps[ep].datafd, ret, (ret == AIO_CANCELED)?
++	    strerror(0):strerror(errno));
++
++	if (ret != AIO_CANCELED) {
++		ret = _errno_to_libusb(errno);
++	} else {
++	/*
++	 * we don't need to call usbi_handle_transfer_cancellation(),
++	 * because we'll handle everything in sunos_async_callback.
++	 */
++		ret = LIBUSB_SUCCESS;
++	}
++
++	return (ret);
++}
++
++void
++sunos_clear_transfer_priv(struct usbi_transfer *itransfer)
++{
++	usbi_dbg("");
++
++	/* Nothing to do */
++}
++
++int
++sunos_handle_transfer_completion(struct usbi_transfer *itransfer)
++{
++	return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_COMPLETED);
++}
++
++int
++sunos_clock_gettime(int clkid, struct timespec *tp)
++{
++	usbi_dbg("clock %d", clkid);
++
++	if (clkid == USBI_CLOCK_REALTIME)
++		return clock_gettime(CLOCK_REALTIME, tp);
++
++	if (clkid == USBI_CLOCK_MONOTONIC)
++		return clock_gettime(CLOCK_MONOTONIC, tp);
++
++	return (LIBUSB_ERROR_INVALID_PARAM);
++}
++
++int
++_errno_to_libusb(int err)
++{
++	usbi_dbg("error: %s (%d)", strerror(err), err);
++
++	switch (err) {
++	case EIO:
++		return (LIBUSB_ERROR_IO);
++	case EACCES:
++		return (LIBUSB_ERROR_ACCESS);
++	case ENOENT:
++		return (LIBUSB_ERROR_NO_DEVICE);
++	case ENOMEM:
++		return (LIBUSB_ERROR_NO_MEM);
++	case ETIMEDOUT:
++		return (LIBUSB_ERROR_TIMEOUT);
++	}
++
++	return (LIBUSB_ERROR_OTHER);
++}
++
++/*
++ * sunos_usb_get_status:
++ *	gets status of endpoint
++ *
++ * Returns: ugen's last cmd status
++ */
++static int
++sunos_usb_get_status(int fd)
++{
++	int status, ret;
++
++	usbi_dbg("sunos_usb_get_status(): fd=%d", fd);
++
++	ret = read(fd, &status, sizeof (status));
++	if (ret == sizeof (status)) {
++		switch (status) {
++		case USB_LC_STAT_NOERROR:
++			usbi_dbg("No Error");
++			break;
++		case USB_LC_STAT_CRC:
++			usbi_dbg("CRC Timeout Detected\n");
++			break;
++		case USB_LC_STAT_BITSTUFFING:
++			usbi_dbg("Bit Stuffing Violation\n");
++			break;
++		case USB_LC_STAT_DATA_TOGGLE_MM:
++			usbi_dbg("Data Toggle Mismatch\n");
++			break;
++		case USB_LC_STAT_STALL:
++			usbi_dbg("End Point Stalled\n");
++			break;
++		case USB_LC_STAT_DEV_NOT_RESP:
++			usbi_dbg("Device is Not Responding\n");
++			break;
++		case USB_LC_STAT_PID_CHECKFAILURE:
++			usbi_dbg("PID Check Failure\n");
++			break;
++		case USB_LC_STAT_UNEXP_PID:
++			usbi_dbg("Unexpected PID\n");
++			break;
++		case USB_LC_STAT_DATA_OVERRUN:
++			usbi_dbg("Data Exceeded Size\n");
++			break;
++		case USB_LC_STAT_DATA_UNDERRUN:
++			usbi_dbg("Less data received\n");
++			break;
++		case USB_LC_STAT_BUFFER_OVERRUN:
++			usbi_dbg("Buffer Size Exceeded\n");
++			break;
++		case USB_LC_STAT_BUFFER_UNDERRUN:
++			usbi_dbg("Buffer Underrun\n");
++			break;
++		case USB_LC_STAT_TIMEOUT:
++			usbi_dbg("Command Timed Out\n");
++			break;
++		case USB_LC_STAT_NOT_ACCESSED:
++			usbi_dbg("Not Accessed by h/w\n");
++			break;
++		case USB_LC_STAT_UNSPECIFIED_ERR:
++			usbi_dbg("Unspecified Error\n");
++			break;
++		case USB_LC_STAT_NO_BANDWIDTH:
++			usbi_dbg("No Bandwidth\n");
++			break;
++		case USB_LC_STAT_HW_ERR:
++			usbi_dbg("Host Controller h/w Error\n");
++			break;
++		case USB_LC_STAT_SUSPENDED:
++			usbi_dbg("Device was Suspended\n");
++			break;
++		case USB_LC_STAT_DISCONNECTED:
++			usbi_dbg("Device was Disconnected\n");
++			break;
++		case USB_LC_STAT_INTR_BUF_FULL:
++			usbi_dbg("Interrupt buffer was full\n");
++			break;
++		case USB_LC_STAT_INVALID_REQ:
++			usbi_dbg("Request was Invalid\n");
++			break;
++		case USB_LC_STAT_INTERRUPTED:
++			usbi_dbg("Request was Interrupted\n");
++			break;
++		case USB_LC_STAT_NO_RESOURCES:
++			usbi_dbg("No resources available for "
++			    "request\n");
++			break;
++		case USB_LC_STAT_INTR_POLLING_FAILED:
++			usbi_dbg("Failed to Restart Poll");
++			break;
++		default:
++			usbi_dbg("Error Not Determined %d\n",
++			    status);
++			break;
++		}
++	} else {
++		usbi_dbg("read stat error: %s",strerror(errno));
++		status = -1;
++	}
++
++	return (status);
++}
++
++const struct usbi_os_backend sunos_backend = {
++        .name = "Solaris",
++        .caps = 0,
++        .init = sunos_init,
++        .exit = sunos_exit,
++        .get_device_list = sunos_get_device_list,
++        .get_device_descriptor = sunos_get_device_descriptor,
++        .get_active_config_descriptor = sunos_get_active_config_descriptor,
++        .get_config_descriptor = sunos_get_config_descriptor,
++        .hotplug_poll = NULL,
++        .open = sunos_open,
++        .close = sunos_close,
++        .get_configuration = sunos_get_configuration,
++        .set_configuration = sunos_set_configuration,
++
++        .claim_interface = sunos_claim_interface,
++        .release_interface = sunos_release_interface,
++        .set_interface_altsetting = sunos_set_interface_altsetting,
++        .clear_halt = sunos_clear_halt,
++        .reset_device = sunos_reset_device, /* TODO */
++        .alloc_streams = NULL,
++        .free_streams = NULL,
++        .kernel_driver_active = NULL,
++        .detach_kernel_driver = NULL,
++        .attach_kernel_driver = NULL,
++        .destroy_device = sunos_destroy_device,
++        .submit_transfer = sunos_submit_transfer,
++        .cancel_transfer = sunos_cancel_transfer,
++	.handle_events = NULL,
++        .clear_transfer_priv = sunos_clear_transfer_priv,
++        .handle_transfer_completion = sunos_handle_transfer_completion,
++        .clock_gettime = sunos_clock_gettime,
++        .device_priv_size = sizeof(sunos_dev_priv_t),
++        .device_handle_priv_size = sizeof(sunos_dev_handle_priv_t),
++        .transfer_priv_size = sizeof(sunos_xfer_priv_t),
++};
+diff -Naur libusb-1.0.20/libusb/os/sunos_usb.h libusb-1.0.20.new/libusb/os/sunos_usb.h
+--- libusb-1.0.20/libusb/os/sunos_usb.h	1969-12-31 16:00:00.000000000 -0800
++++ libusb-1.0.20.new/libusb/os/sunos_usb.h	2016-03-10 00:24:37.910437590 -0800
+@@ -0,0 +1,74 @@
++/*
++ *
++ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef	__SUNOS_H__
++#define	__SUNOS_H__
++
++#include <libdevinfo.h>
++#include <pthread.h>
++#include "libusbi.h"
++
++#define	READ	0
++#define	WRITE	1
++
++typedef struct sunos_device_priv {
++	uint8_t	cfgvalue;		/* active config value */
++	uint8_t	*raw_cfgdescr;		/* active config descriptor */
++	struct libusb_device_descriptor	dev_descr;	/* usb device descriptor */
++	char	*ugenpath;		/* name of the ugen(4) node */
++	char	*phypath;		/* physical path */
++} sunos_dev_priv_t;
++
++typedef	struct endpoint {
++	int datafd;	/* data file */
++	int statfd;	/* state file */
++} sunos_ep_priv_t;
++
++typedef struct sunos_device_handle_priv {
++	uint8_t			altsetting[USB_MAXINTERFACES];	/* a interface's alt */
++	uint8_t			config_index;
++	sunos_ep_priv_t		eps[USB_MAXENDPOINTS];
++	sunos_dev_priv_t	*dpriv; /* device private */
++} sunos_dev_handle_priv_t;
++
++typedef	struct sunos_transfer_priv {
++	struct aiocb		aiocb;
++	struct libusb_transfer	*transfer;
++} sunos_xfer_priv_t;
++
++struct node_args {
++	struct libusb_context	*ctx;
++	struct discovered_devs	**discdevs;
++	const char		*last_ugenpath;
++	di_devlink_handle_t	dlink_hdl;
++};
++
++struct devlink_cbarg {
++	struct node_args	*nargs;	/* di node walk arguments */
++	di_node_t		myself;	/* the di node */
++	di_minor_t		minor;
++};
++
++/* AIO callback args */
++struct aio_callback_args{
++	struct libusb_transfer *transfer;
++	struct aiocb aiocb;
++};
++
++#endif /* __SUNOS_H__ */
+diff -Naur libusb-1.0.20/libusb-1.0.pc.in libusb-1.0.20.new/libusb-1.0.pc.in
+--- libusb-1.0.20/libusb-1.0.pc.in	2015-07-28 22:18:38.000000000 -0700
++++ libusb-1.0.20.new/libusb-1.0.pc.in	2016-03-10 00:17:29.567059098 -0800
+@@ -4,7 +4,7 @@
+ includedir=@includedir@
+ 
+ Name: libusb-1.0
+-Description: C API for USB device access from Linux, Mac OS X, Windows and OpenBSD/NetBSD userspace
++Description: C API for USB device access from Linux, Mac OS X, Windows, OpenBSD/NetBSD and Solaris userspace
+ Version: @VERSION@
+ Libs: -L${libdir} -lusb-1.0
+ Libs.private: @LIBS@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libusb-1/patches/02-libusb.patch	Wed Jul 06 18:36:46 2016 -0700
@@ -0,0 +1,117 @@
+Fix unnecessary free(), active config value and descriptor, and identifier.
+
+--- libusb-1.0.20/libusb/os/sunos_usb.h	2016-04-06 20:05:55.785721970 -0700
++++ libusb/libusb/os/sunos_usb.h	2016-04-06 20:02:21.487553309 -0700
+@@ -1,6 +1,6 @@
+ /*
+  *
+- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2016, Oracle and/or its affiliates.
+  *
+  * This library is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+@@ -17,8 +17,8 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ 
+-#ifndef	__SUNOS_H__
+-#define	__SUNOS_H__
++#ifndef	LIBUSB_SUNOS_H
++#define	LIBUSB_SUNOS_H
+ 
+ #include <libdevinfo.h>
+ #include <pthread.h>
+@@ -71,4 +71,4 @@
+ 	struct aiocb aiocb;
+ };
+ 
+-#endif /* __SUNOS_H__ */
++#endif /* LIBUSB_SUNOS_H */
+--- libusb-1.0.20/libusb/os/sunos_usb.c	2016-04-06 20:05:55.785428005 -0700
++++ libusb/libusb/os/sunos_usb.c	2016-04-06 20:02:21.487451492 -0700
+@@ -1,6 +1,6 @@
+ /*
+  *
+- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2016, Oracle and/or its affiliates.
+  *
+  * This library is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+@@ -122,6 +122,8 @@
+ 		return (LIBUSB_ERROR_NO_MEM);
+ 	} else {
+ 		bcopy(rdata, dpriv->raw_cfgdescr, proplen);
++		dpriv->cfgvalue = ((struct libusb_config_descriptor *)
++		    rdata)->bConfigurationValue;
+ 	}
+ 
+ 	n = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", &port_prop);
+@@ -651,12 +653,40 @@
+ {
+ 	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
+ 	struct libusb_config_descriptor *cfg;
++	int proplen;
++	di_node_t node;
++	uint8_t	*rdata;
++
++	/*
++	 * Keep raw configuration descriptors updated, in case config
++	 * has ever been changed through setCfg.
++	 */
++	if ((node = di_init(dpriv->phypath, DINFOCPYALL)) == DI_NODE_NIL) {
++		usbi_dbg("di_int() failed: %s", strerror(errno));
++		return (LIBUSB_ERROR_IO);
++	}
++	proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
++	    "usb-raw-cfg-descriptors", &rdata);
++	if (proplen <= 0) {
++		usbi_dbg("can't find raw config descriptors");
++
++		return (LIBUSB_ERROR_IO);
++	}
++	dpriv->raw_cfgdescr = realloc(dpriv->raw_cfgdescr, proplen);
++	if (dpriv->raw_cfgdescr == NULL) {
++		return (LIBUSB_ERROR_NO_MEM);
++	} else {
++		bcopy(rdata, dpriv->raw_cfgdescr, proplen);
++		dpriv->cfgvalue = ((struct libusb_config_descriptor *)
++		    rdata)->bConfigurationValue;
++	}
++	di_fini(node);
+ 
+ 	cfg = (struct libusb_config_descriptor *)dpriv->raw_cfgdescr;
+ 	len = MIN(len, libusb_le16_to_cpu(cfg->wTotalLength));
+ 	memcpy(buf, dpriv->raw_cfgdescr, len);
+ 	*host_endian = 0;
+-	usbi_dbg("len %d", len);
++	usbi_dbg("path:%s len %d", dpriv->phypath, len);
+ 
+ 	return (len);
+ }
+@@ -685,7 +715,10 @@
+ sunos_set_configuration(struct libusb_device_handle *handle, int config)
+ {
+ 	sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
++	sunos_dev_handle_priv_t *hpriv;
++
+ 	usbi_dbg("bConfigurationValue %d", config);
++	hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
+ 
+ 	if (dpriv->ugenpath == NULL)
+ 		return (LIBUSB_ERROR_NOT_SUPPORTED);
+@@ -694,6 +727,7 @@
+ 		return (LIBUSB_ERROR_INVALID_PARAM);
+ 
+ 	dpriv->cfgvalue = config;
++	hpriv->config_index = config - 1;
+ 
+ 	return (LIBUSB_SUCCESS);
+ }
+@@ -797,7 +831,6 @@
+ 
+ 	/* async notification */
+ 	usbi_signal_transfer_completion(LIBUSB_TRANSFER_TO_USBI_TRANSFER(xfer));
+-	free(aiocb);
+ }
+ 
+ static int