Linux: Fix #70 race condition in sysfs_get_device_list()
Linux: Fix #70 race condition in sysfs_get_device_list()

Change the way libusb chooses between using sysfs and usbfs for information
about the attached devies.  Using the old method, a race condition could
occur if a device was unplugged just before (or during) the call to
libusb_get_device_list(), corrupting the internal sysfs_can_relate_devices
and sysfs_has_descriptors variables and preventing libusb_get_device_list()
from working in future calls.

The old method was based on the assumption that if certain sysfs files
(eg: busnum) could not be opened, that indicated an inadequacy of sysfs
(ie: the running kernel's sysfs version did not contain those files),
when in reality those files couldn't be opened because the device had
been unplugged.

The new method checks the adequacy of sysfs during libusb_init()
(op_init()) and if a sysfs file cannot be opened, it is now assumed that
it is because the device has been unplugged, not because sysfs is
inadequate.

Signed-off-by: Alan Ott <91e38e63b890fbb214c8914809fde03c73e7f24d@signal11.us>
[stuge: Include closedir() bugfix posted in ticket by Arne Laansoo]
[stuge: Remove dead code in sysfs_scan_device() found by Hans de Goede]

LudovicRousseau/libusbx,TeamExodus/external_libusbx,byterom/android_external_libusbx,DirtyUnicorns/android_external_libusbx,CyanogenMod/android_external_libusbx,tonyarkles/libusb,pbatard/libusbx,philemonf/libusb,SpecLad/libusb-android,bra1nb3am3r/libusb,dickens/libusb,andyvand/libusb,BuLogics/libusb,ThirdProject/android_external_libusbx,mojca/libusb_pico,tklauser/libusb,Distrotech/libusb,SimplyComplexCo/libusb,dmitrykos/libusb,tonyarkles/libusb,avakar/libusbx,DirtyUnicorns/android_external_libusbx,AmesianX/libusb,Distrotech/libusb,ThirdProject/android_external_libusbx,mojca/libusb_pico,andyvand/libusb,ndurner/libusbx-suse10,dickens/libusb,PAC-ROM/android_external_libusbx,RealVNC/libusbx,dasdeepak/libusb,araisrobo/libusbx,ButterflyNetwork/libusb,bert/libusb,PersonifyInc/libusbx,philemonf/libusb,libusb/libusb,wuzhenda/libusb,bert/libusb,daiguangbao/libusb,jwrdegoede/libusbx,TeamExodus/external_libusbx,hjelmn/libusbx-temp,SpecLad/libusb-android,bra1nb3am3r/libusb,HounD/libusb-v1.0.19,SpecLad/libusb-android,tklauser/libusb,jwrdegoede/libusbx,DirtyUnicorns/android_external_libusbx,BuLogics/libusb,legege/libusb,ButterflyNetwork/libusb,manctl/usb,anilgit90/libusb,anilgit90/libusb,philemonf/libusb,legege/libusb,hjelmn/libusbx-temp,kuldeepdhaka/libusb,kuldeepdhaka/libusb,pbatard/libusbx-hp,RealVNC/libusbx,dasdeepak/libusb,erhuabushuo/libusb,ndurner/libusbx-suse10,dmitrykos/libusb,avakar/libusbx,PersonifyInc/libusbx,ndurner/libusbx-suse10,LudovicRousseau/libusbx,tonyarkles/libusb,YesVideo/libusb,dickens/libusb,LudovicRousseau/libusb,hjelmn/libusb-darwin,ButterflyNetwork/libusb,byterom/android_external_libusbx,erhuabushuo/libusb,tenderlove/libusb,tklauser/libusb,erhuabushuo/libusb,pbatard/libusbx-hp,dmitrykos/libusb,tenderlove/libusb,SimplyComplexCo/libusb,libusb/libusb,ButterflyNetwork/libusb,JENETRIC/libusb,CyanogenMod/android_external_libusbx,hjelmn/libusb-darwin,kuldeepdhaka/libusb,SimplyComplexCo/libusb,ashima/libusb,LightInMotion/libusb,leapmotion/libusb,byterom/android_external_libusbx,manctl/usb,HounD/libusb-v1.0.19,dasdeepak/libusb,PersonifyInc/libusbx,andyvand/libusb,bra1nb3am3r/libusb,leapmotion/libusb,ButterflyNetwork/libusb,AmesianX/libusb,araisrobo/libusbx,JENETRIC/libusb,JENETRIC/libusb,HounD/libusb-v1.0.19,PAC-ROM/android_external_libusbx,ashima/libusb,legege/libusb,TeamExodus/external_libusbx,AmesianX/libusb,daiguangbao/libusb,Distrotech/libusb,wuzhenda/libusb,anilgit90/libusb,hjelmn/libusbx-temp,araisrobo/libusbx,philemonf/libusb,weizhenwei/libusb,leapmotion/libusb,pbatard/libusbx-hp,daiguangbao/libusb,LudovicRousseau/libusb,jwrdegoede/libusbx,YesVideo/libusb,PAC-ROM/android_external_libusbx,dmitrykos/libusb,vlovich/libusb,weizhenwei/libusb,vlovich/libusb,YesVideo/libusb,wuzhenda/libusb,weizhenwei/libusb,ashima/libusb,LightInMotion/libusb,LudovicRousseau/libusbx,ThirdProject/android_external_libusbx,BuLogics/libusb,CyanogenMod/android_external_libusbx,pbatard/libusbx,LudovicRousseau/libusb,libusb/libusb