All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: "Linux-Kernel, " <linux-kernel@vger.kernel.org>,
	linux-hotplug-devel@lists.sourceforge.net
Subject: udev, PROGRAM and races...
Date: Wed, 5 Apr 2006 00:22:58 +0200	[thread overview]
Message-ID: <20060405002258.18fddd87@werewolf.auna.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1797 bytes --]

Hi...

I (well, the distro I use) has a little problem with creation of links
for CD-ROM devices.

For example, in my box, hda is a DVDRW and hdd is a DVD reader.
I think I should have something like
cdrom0 -> hda
cdrom1 -> hdd
dvd0 -> hda
dvd1 -> hdd
cdrw0 -> hda
dvdrw0 -> hda

(with optional cdrom and dvd links to the default one, say just the
first).

This is done with rule like:

SUBSYSTEM=="block", ACTION=="add", ENV{ID_CDROM}=="?*", PROGRAM="/lib/udev/udev_cdrom_helper", SYMLINK+="%c"

This helper tries to get the next free %d index to create cdrom%d, for
example.
The problem is that the launch of both helpers for hda and add seems to be done
in parallel and the helper gets racy, so both cdroms get id 0, and the last
that comes owns it:

helper instance for hda        helper instance for hdd
Does cdrom0 exist ? No
                               Does cdrom0 exist ? No
ln -sf hda cdrom0
                               ln -sf hdd cdrom0

????

Is there any way to serialize the calls to 'PROGRAM'. I tried something like:

SUBSYSTEM=="block", ACTION=="add", ENV{ID_CDROM}=="?*",
PROGRAM="/usr/bin/flock /sys/block /lib/udev/udev_cdrom_helper", SYMLINK+="%c"

But looks a lot ugly.

Any standard way to do this ?
Can I still use %e, or is it really really deprecated ? this was easy:

ENV{ID_CDROM_CD_RW}=="?*",  SYMLINK+="burner%e", MODE="0666", GROUP="cdwriter"
ENV{ID_CDROM_DVD_R}=="?*",  SYMLINK+="burner%e", MODE="0666", GROUP="cdwriter"

TIA

--
J.A. Magallon <jamagallon()able!es>     \               Software is like sex:
werewolf!able!es                         \         It's better when it's free
Mandriva Linux release 2006.1 (Cooker) for i586
Linux 2.6.16-jam5 (gcc 4.1.1 20060330 (prerelease)) #1 SMP PREEMPT Tue

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

             reply	other threads:[~2006-04-04 22:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-04 22:22 J.A. Magallon [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-04-05 19:10 udev, PROGRAM and races Andrey Borzenkov

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=20060405002258.18fddd87@werewolf.auna.net \
    --to=jamagallon@able.es \
    --cc=linux-hotplug-devel@lists.sourceforge.net \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.