* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device
2010-11-24 14:46 [Libmtp-discuss] udev and libmtp: detect a new mtp device based Dan Nicholson
@ 2010-11-24 15:05 ` Marcus Meissner
2010-11-28 21:12 ` [Libmtp-discuss] udev and libmtp: detect a new mtp device based Linus Walleij
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Marcus Meissner @ 2010-11-24 15:05 UTC (permalink / raw)
To: linux-hotplug
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@gmail.com> wrote:
> > 2010/11/3 <lan.liu@nokia.com>:
> >
> >> 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ãff31c22e5c96af6478a715aa39928f7ba025bd;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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
2010-11-24 14:46 [Libmtp-discuss] udev and libmtp: detect a new mtp device based Dan Nicholson
2010-11-24 15:05 ` [Libmtp-discuss] udev and libmtp: detect a new mtp device Marcus Meissner
@ 2010-11-28 21:12 ` Linus Walleij
2010-11-28 21:25 ` Linus Walleij
2010-11-28 22:12 ` Linus Walleij
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2010-11-28 21:12 UTC (permalink / raw)
To: linux-hotplug
2010/11/24 Marcus Meissner <marcus@jet.franken.de>:
> 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.
I've fixed this in the examples/hotplug.c file last week, so yes this
should be enough for now atleast.
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
2010-11-24 14:46 [Libmtp-discuss] udev and libmtp: detect a new mtp device based Dan Nicholson
2010-11-24 15:05 ` [Libmtp-discuss] udev and libmtp: detect a new mtp device Marcus Meissner
2010-11-28 21:12 ` [Libmtp-discuss] udev and libmtp: detect a new mtp device based Linus Walleij
@ 2010-11-28 21:25 ` Linus Walleij
2010-11-28 22:12 ` Linus Walleij
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2010-11-28 21:25 UTC (permalink / raw)
To: linux-hotplug
2010/11/26 <lan.liu@nokia.com>:
> change on 'example/hotplug.c' on release 1.0.1 (the most recent release I
> get from “http://libmtp.sourceforge.net/download.php”),
1.0.3 is the latest, sorry that page isn't working, I will hack it to redirect
to the SF download page unless Sean has some time to fix it like soon-ish...
> to generate
> following rule for mtp device:
> #For Nokia-based devices,their interface string descriptor contains 'mtp'
> pattern,consider it to be a mtp device
> ATTR{idVendor}="0421", PROGRAM="/usr/local/bin/check_mtp_device.sh
> /sys$env{DEVPATH} mtp",
Aha clever!
> SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1",
> ENV{ID_MEDIA_PLAYER}="1"
Hm I only added ID_MEDIA_PLAYER, I guess ID_MTP_DEVICE wouldn't
hurt so I have added that too.
> ENV{ID_MTP_DEVICE}="?*", MODE="666"
Aha yeah that solves an immediate problem for many people I guess.
> 1. Makefile need to be updated so that 'check_mtp_device.sh' could be
> installed , since I am new with this, could anybody give me a help?
> Currently, I hardcode the install path as '/usr/local/bin/' in rule file.
This is not the hard thing. The hard thing is that scripts like
"check_mtp_device.sh" take a long time to invoke, and I would
prefer to have it rewritten in plain C.
That would make it simpler to add OS descriptor probing too,
if desired.
examples/devicecheck.c
Installs as <prefix>/bin/mtp-devicecheck
And is used from the udev script.
Can it be done?
> 2. Currently, after you run 'make install', the generated 'libmtp.rules'
> will NOT be automatically copied to '/etc/udev/rules.d' or
> '/lib/udev/rules.d'(the directory where udev rules files located on Ubuntu
> system), user has to copy it manually. Thus we still could not provide an
> out-of-box experience for these devices.
Such is life, copying it into Ubuntu/Debian/Fedora/whatever locations
is a task for the packager.
If libmtp can help with any of this, the packagers (which are on this
list) should voice their needs...
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
2010-11-24 14:46 [Libmtp-discuss] udev and libmtp: detect a new mtp device based Dan Nicholson
` (2 preceding siblings ...)
2010-11-28 21:25 ` Linus Walleij
@ 2010-11-28 22:12 ` Linus Walleij
3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2010-11-28 22:12 UTC (permalink / raw)
To: linux-hotplug
2010/11/24 Dan Nicholson <dbn.lists@gmail.com>:
> Every distribution does not have the plugdev group, though.
Yeah that shouldn't be hardcoded. The hotplug.c program already
supports supplying a custom actions string for those who need
it, like distro packagers.
> 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"
Yep that's how to do it.
> 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ãff31c22e5c96af6478a715aa39928f7ba025bd;hb=HEAD
> In fact, it seems they already have a rule to manage the ACLs on
> PTP/MTP devices. What do you think?
Yes! It already recognize ID_MEDIA_PLAYER it seems? And I
added that to all of them...
Linus
^ permalink raw reply [flat|nested] 5+ messages in thread