|
From: <la...@no...> - 2010-12-06 09:11:50
|
Hi, Thanks for your kindly feedback, I understand your concern, please see my comments labeled as [Lan], thanks. Regards, Lan Liu -----Original Message----- From: ext Linus Walleij [mailto:lin...@gm...] Sent: Sunday, December 05, 2010 6:23 PM To: lib...@li... Cc: Li Feng.5 (Nokia-MS/Beijing); Tarvainen Miska (Nokia-MS/Beijing); Quadros Roger (Nokia-MS/Helsinki); Wang Hongyu (Nokia-MS/Beijing); lin...@vg... Subject: Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based on its USB interface descriptor 2010/12/2 <la...@no...>: > to > re-write as a c program, we have to read each sub-dir entries under this > device path, search if there exist a file with filename 'interface', if > found, read out its contents to check if certain pattern, like 'mtp' exist. Yep. *Or* you can just start invoke libusb from the same C program, iterate over devices and use the np_ interfaces to match the bus number passed as argument (parsed out) and then investigate the interface using libusb. Which is the proper way, since you can abort scanning once the interface is not PTP or proprietary. [Lan]I am afraid the approach to use libusb to access devices may not work. At least, on my Ubuntu system. When this program/script is invoked by udev daemon,the device node under '/dev' directory for this new device is not created. After udev daemon finished its dealing of udev rule file, it will create the device node for this device with the name as, eg, '/dev/bus/usb/001/005', '001' is the bus number, while '005' is the device number. I verified this by writing a test program, which will check the existence of the device node file, as a result, it return error, with global 'errno' set as 2, indicating no such file. Also, in this test program, it you try to find devices under each bus directory, such as ‘/dev/bus/usb/001’,it found no devices. so maybe it is not possible to use libusb to access this device at this moment. While in libmtp, there is already the check for mtp device, including both string descriptor and MS descriptor, since this check is invoked by applications, at that time, the device node has already been created, Thus no such problem. So I think to write a program to be invoked by udev to check mtp device, we could only depend On the info exported to sysfs. Why's your opinion? If I miss something, please tell me. Thanks. > With bash script, one line of code can achieve this: > grep -i mtp `find -name interface`, > it is much simple , what's your opinion, will there be a significant > performance decrease by implementing as a bash script? Yes there will be. It needs to check *every* device plugged in, and that is not going to be popular with distributions. The overhead of forking an entire shell for this is IMO not acceptable. For example people are now rewriting startup scripts in C in order to speed up boot so there is some kind of trend away from forking shells for everything and instead writing a small pice of native code to do the trick. I may be wrong. I don't know all the weird stuff people execute when a device is plugged in, maybe several hundred bash scripts are already being invoked for every USB device plugged in? Then surely it's no big deal. [Lan] Got it. If needed, I can re-write this as a c program, to check The string descriptor under sysfs to see if it is a mtp device. [Lan] > For MS OS descriptor, I am not sure whether it has been > exported to sys fs by kernel, It isn't, that is why I want this simple C program invoking libusb instead. That way it can use the libmtp functions to probe the new device. > even yes, string descriptor is much more simple to deal with, > thus currently we do not use MS OS descriptor approach. > Of course, I have to admit this does not cover devices who > do not set its string descriptors. Yes for the devices *you* are interested in it works, but I have to take the entire libmtp community and legacy devices into account and try to fix it in a way that works for everyone. [Lan] I fully understand your concern: to provide a solution to cover as more devices As possible. But if MS OS descriptor is not exported under sysfs, then maybe we have Difficulty to achieve this currently, for the reason mentioned above. Yours, Linus Walleij ------------------------------------------------------------------------------ What happens now with your Lotus Notes apps - do you make another costly upgrade, or settle for being marooned without product support? Time to move off Lotus Notes and onto the cloud with Force.com, apps are easier to build, use, and manage than apps on traditional platforms. Sign up for the Lotus Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d _______________________________________________ Libmtp-discuss mailing list Lib...@li... https://lists.sourceforge.net/lists/listinfo/libmtp-discuss |