Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based on its USB interface descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/12/2  <lan.liu@xxxxxxxxx>:

> 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.

> 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.

> 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.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux