Issues with addon-storage

Thomas Petazzoni thomas.petazzoni at enix.org
Mon Dec 18 10:39:29 PST 2006


Hi,

[ I've already sent this message yesterday at 12:48, but that didn't
  reach the list, for some reason. I hope you'll not receive both of
  them. ]

I'm using HAL 0.5.8.1 on Debian unstable, and I have some problems with
addon-storage.

When I insert an USB key, everything works fine, the device appears in
HAL, and the volumes are mounted thanks to gnome-volume-manager (I'm
not using Gnome, but XFCE, and I'm running gnome-volume-manager by
hand).

However, when I unplug the USB key, it sometimes doesn't work:
hald-addon-storage fails at opening /dev/sda, and loops forever trying
to open /dev/sda every two seconds. However, this doesn't happen all
the time: it sometimes work, sometimes not. The logs of hald
--daemon=no --verbose=yes where the first unplug of the USB key
triggered the problem are available at
http://lolut.utbm.info/~thomas/hal.log. The message is:

[15395]: 11:55:59.179 [E] addon-storage.c:423: open failed
for /dev/sda: No such file or directory

My understanding may be completely wrong, but I think it's something
with udev removing the /dev/sda entry upon removal of the USB key.
Sometimes, the /dev/sda entry is removed before hald-addon-storage had
the time to open() it (and it that case, hald-addon-storage loops
forever). Sometimes, the /dev/sda entry is removed after
hald-addon-storage open()ed it, and in that case it works.

And of course, once hald is waiting for hald-addon-storage to exit or
do something, it doesn't handle the other plugging/unplugging events.

My problem looks somewhat similar to
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=402835 or
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400773.

What do you think about that ?

BTW, I made a quick look at the addon-storage.c code, and I don't
understand why close(fd) is called when fd is certainly < 0. See
attached patch (not compiled, not tested).

I can of course test patches and provide more debugging information if
needed.

Sincerly,

Thomas

diff --git a/hald/linux/addons/addon-storage.c b/hald/linux/addons/addon-storage.c
index 22247cf..5b57593 100644
--- a/hald/linux/addons/addon-storage.c
+++ b/hald/linux/addons/addon-storage.c
@@ -415,13 +415,11 @@ main (int argc, char *argv[])
 			fd = open (device_file, O_RDONLY);
 			if (fd < 0 && errno == ENOMEDIUM) {
 				got_media = FALSE;
-				close (fd);
 			} else if (fd >= 0) {
 				got_media = TRUE;
 				close (fd);
 			} else {
 				HAL_ERROR (("open failed for %s: %s", device_file, strerror (errno))); 
-				close (fd);
 				goto skip_check;
 			}
 		}
-- 
PETAZZONI Thomas - thomas.petazzoni at enix.org 
http://{thomas,sos,kos}.enix.org - Jabber: thomas.petazzoni at jabber.dk
http://{agenda,livret}dulibre.org - http://www.toulibre.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/hal/attachments/20061218/0608d6e4/signature.pgp


More information about the hal mailing list