Am 06.04.2010 14:26, schrieb Kay Sievers:
On Tue, Apr 6, 2010 at 14:19, Martin Pitt<martin.pitt@xxxxxxxxxx> wrote:
Kay, do you know why [2] was done in the first place? Do you happen to
have a pointer to a bug etc. which describes the problems with CD
burning sessions?
Harald said, he has several bugs with cd burning caused by cdrom_id
and blkid opening the device when a uevent is handled during cd
burning. I did not receive any such bug.
Kay
https://bugzilla.redhat.com/show_bug.cgi?id=481346
https://bugzilla.redhat.com/show_bug.cgi?id=566535
We might want to apply the attached patches.
From 194c5c10b65499e52864132ed542845b4c2e757c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@xxxxxxxxxx>
Date: Tue, 6 Apr 2010 14:34:32 +0200
Subject: [PATCH 1/2] cdrom_id: remove debugging code
---
extras/cdrom_id/cdrom_id.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c
index e485768..036ef28 100644
--- a/extras/cdrom_id/cdrom_id.c
+++ b/extras/cdrom_id/cdrom_id.c
@@ -126,7 +126,6 @@ static int is_mounted(const char *device)
if (fp == NULL)
return -ENOSYS;
while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
- printf("got %u %u\n", maj, min);
if (makedev(maj, min) == statbuf.st_rdev) {
mounted = 1;
break;
--
1.6.6.1
From cb3d97513fec69c4f75cf24651a16404dd576da4 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@xxxxxxxxxx>
Date: Tue, 6 Apr 2010 14:37:21 +0200
Subject: [PATCH 2/2] cdrom_id: retry to open the device, if EBUSY
---
extras/cdrom_id/cdrom_id.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c
index 036ef28..5e0ddba 100644
--- a/extras/cdrom_id/cdrom_id.c
+++ b/extras/cdrom_id/cdrom_id.c
@@ -591,12 +591,29 @@ int main(int argc, char *argv[])
goto exit;
}
- fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL));
- if (fd < 0) {
- info(udev, "unable to open '%s'\n", node);
- fprintf(stderr, "unable to open '%s'\n", node);
- rc = 1;
- goto exit;
+
+ {
+ int errno_open=0;
+ int i = 0;
+
+ do {
+ int excl = is_mounted(node) ? 0 : O_EXCL;
+ fd = open(node, O_RDONLY|O_NONBLOCK|excl);
+ errno_open = errno;
+ if (fd < 0) {
+ if (errno_open != EBUSY || i >= 100) {
+ char *strerr = strerror(errno_open);
+ info(udev, "unable to open '%s': %s\n", node, strerr);
+ fprintf(stderr, "unable to open '%s': %s\n", node, strerr);
+ rc = 1;
+ goto exit;
+ } else {
+ fprintf(stderr, "unable to open '%s' exclusively: retrying (%d/100)\n", node, i);
+ usleep((useconds_t)(400000.0 + 400000.0 * rand() * 1.0 / (RAND_MAX+1.0)));
+ i++;
+ }
+ }
+ } while ((fd < 0) && (errno_open == EBUSY));
}
info(udev, "probing: '%s'\n", node);
--
1.6.6.1