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]

 



On Wed, Nov 24, 2010 at 06:46:28AM -0800, Dan Nicholson wrote:
> On Wed, Nov 24, 2010 at 2:14 AM, Linus Walleij
> <linus.ml.walleij@xxxxxxxxx> wrote:
> > 2010/11/3  <lan.liu@xxxxxxxxx>:
> >
> >> 45-libmtp8.rules
> >> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp"
> >> SYMLINK+="libmtp-%k", MODE="666", GROUP="plugdev"
> >
> > This file - 45-libmtp8.rules is some distro file, what libmtp generates
> > is libmtp.rules, which is autogenerated from a device database by the
> > program found in examples/hotplug.c.
> >
> > Can you provide a patch to hotplug.c that adds this line to libmtp.rules?
> >
> > If you do that you will get this change into every distribution.
> 
> Every distribution does not have the plugdev group, though.
> Furthermore, I don't see the point of making the mode 666 while also
> setting the group to narrow the scope.
> 
> Might I suggest instead that the program be used not to set the
> permissions, but to set the attributes consistently. E.g.,
> 
> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp", ENV{ID_MTP_DEVICE}="1"
> 
> If we know that all mtp devices have the environment variable
> ID_MTP_DEVICE, then it's very easy to add a rule controlling the
> permissions.
> 
> ENV{ID_MTP_DEVICE}=="?*", MODE="666"
> 
> Even better, if we let the udev people know that there is some
> attribute like ID_MTP_DEVICE that's set for all mtp devices, they can
> add a rule for udev-acl, which dynamically updates the ACLs on all
> distros. See how the gphoto2 devices are handled here:
> 
> http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=extras/udev-acl/70-acl.rules;h=e3ff31c22e5c96af6478a715aa39928f7ba025bd;hb=HEAD
> 
> In fact, it seems they already have a rule to manage the ACLs on
> PTP/MTP devices. What do you think?

Errm, folks.

The upstream people have decided on the tag and the handling already, 
and I have implemented it in libgphoto2 udev rule generator already
(you benefit from it already this way btw ;)

A line in the "new style" udev from libgphoto2:

ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="30f2", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="proprietary", ENV{ID_MEDIA_PLAYER}="1"

For libmtp this would probably be e.g.:
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="30f2", ENV{ID_MEDIA_PLAYER}="1"

Thats it, the rest handling will be done using ACLs from the regular udev code.

Ciao, Marcus
--
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