Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Sep 2012 01:33:39 GMT
From:      Alberto Villa <avilla@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/171727: [patch] sysutils/hal: fix two issues and add dependency on sysutils/hal-info
Message-ID:  <201209180133.q8I1XdQh043831@red.freebsd.org>
Resent-Message-ID: <201209180140.q8I1e5On027458@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         171727
>Category:       ports
>Synopsis:       [patch] sysutils/hal: fix two issues and add dependency on sysutils/hal-info
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 18 01:40:05 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Alberto Villa
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
FreeBSD woodstock.peanuts 10.0-CURRENT FreeBSD 10.0-CURRENT #13 r239665: Sat Aug 25 02:49:34 CEST 2012     root@woodstock.peanuts:/usr/obj/usr/src/sys/HPDV6  amd64
>Description:
1. A new drm entry (nvidia_card) is added on every iteration of osspec_probe(), because no check is done to see if the entry is already there.

2. storage.removable.media_available and storage.removable.media_size are set only for optical drives, while they should be set also for hotpluggable drives.

3. hal-info adds many useful definitions to the HAL device list, but many users don't know about the port.
>How-To-Repeat:
1. Grep `lshal` for "nvidia_card" (on systems mounting an Nvidia, of course): there are multiple entries, with no differences. Systems with removable devices will have many of them, while other systems could have fewer. One is enough, though.

2. Check if those properties are set for hotpluggable devices.
>Fix:
1. Add a check to avoid duplicating the entry.

2. Set the properties for any storage device, as the Linux backend does. It's not wrong to do that only for optical drives, as they are the only true "removable" devices (along with tape and floppy drives), as USB sticks should only be marked as "hotpluggable", but since our backend does the same wrong assumption as the Linux one, it's better to pursue that road (it's a bit late to change). This means that the properties will also be set for non-hotpluggable devices (hard disks), but that's not a problem, as the properties should not be checked if storage.removable is false. This also mimics Linux backend behaviour, and, to be fair, HAL spec is not at all complete in the definition of the properties.

3. Adding a dependency on hal-info ensures that everyone gets the best possible "HAL experience" (sounds a bit too much :). For instance, I now have my iPod detected as such in KDE, with a nice icon shown in place of the plain USB stick one.

Patch attached with submission follows:

Index: Makefile
===================================================================
--- Makefile	(revision 304374)
+++ Makefile	(working copy)
@@ -8,7 +8,7 @@
 
 PORTNAME=	hal
 DISTVERSION=	0.5.14
-PORTREVISION=	19
+PORTREVISION=	20
 CATEGORIES=	sysutils
 MASTER_SITES=	http://hal.freedesktop.org/releases/
 
@@ -19,7 +19,8 @@
 LIB_DEPENDS=	polkit.2:${PORTSDIR}/sysutils/policykit \
 		volume_id.0:${PORTSDIR}/devel/libvolume_id \
 		ck-connector.0:${PORTSDIR}/sysutils/consolekit
-RUN_DEPENDS=	${LOCALBASE}/share/pciids/pci.ids:${PORTSDIR}/misc/pciids
+RUN_DEPENDS=	${LOCALBASE}/share/pciids/pci.ids:${PORTSDIR}/misc/pciids \
+		${LOCALBASE}/share/hal/fdi/information/10freedesktop/30-keymap-misc.fdi:${PORTSDIR}/sysutils/hal-info
 
 USE_GETTEXT=	yes
 USE_GMAKE=	yes
--- hald/freebsd/hf-drm.c.orig	2012-09-12 01:45:35.665050510 +0200
+++ hald/freebsd/hf-drm.c	2012-09-12 01:25:28.125106626 +0200
@@ -234,6 +234,12 @@
   {
     HalDevice *parent = HAL_DEVICE(l->data);
 
+    if (hf_device_store_match(hald_get_gdl(),
+			      "info.parent", HAL_PROPERTY_TYPE_STRING, hal_device_get_udi(parent),
+			      "info.subsystem", HAL_PROPERTY_TYPE_STRING, "drm",
+			      NULL))
+      continue;
+
     if (! hal_device_property_get_bool(parent, "info.ignore"))
       {
         Card *card;
--- hald/freebsd/probing/probe-storage.c.orig	2012-09-12 01:46:34.554977683 +0200
+++ hald/freebsd/probing/probe-storage.c	2012-09-12 01:38:45.000000000 +0200
@@ -236,7 +236,27 @@
 
       hfp_cdrom_free(cdrom);
     }
-  else if (! has_children) /* by definition, if it has children it has no fs */
+  else
+    {
+      int fd;
+      off_t size;
+
+      fd = open(device_file, O_RDONLY | O_NONBLOCK);
+      if (fd > -1)
+	{
+	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error);
+	  if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0)
+	    {
+	      libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error);
+	    }
+	  close(fd);
+	}
+      else
+	{
+	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error);
+	}
+
+      if (! has_children) /* by definition, if it has children it has no fs */
     {
       struct volume_id *vid;
 
@@ -249,6 +269,7 @@
 
       volume_id_close(vid);
     }
+    }
 
  end:
   return ret;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209180133.q8I1XdQh043831>