Linux Hotplug development
 help / color / mirror / Atom feed
From: Marcus Meissner <marcus@jet.franken.de>
To: linux-hotplug@vger.kernel.org
Subject: Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device
Date: Wed, 24 Nov 2010 15:05:20 +0000	[thread overview]
Message-ID: <20101124150520.GC8306@jet.franken.de> (raw)
In-Reply-To: <AANLkTimamoY-ui9bSB8ThKGw8=r4x5NDokugnCZ=uERe@mail.gmail.com>

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

  reply	other threads:[~2010-11-24 15:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-11-28 21:12 ` Linus Walleij
2010-11-28 21:25 ` Linus Walleij
2010-11-28 22:12 ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101124150520.GC8306@jet.franken.de \
    --to=marcus@jet.franken.de \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox