hal/hald/linux block_class_device.c, 1.86.2.6, 1.86.2.7 net_class_device.c, 1.21.2.2, 1.21.2.3

David Zeuthen david at freedesktop.org
Thu Jan 6 19:07:47 PST 2005


Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv5456/hald/linux

Modified Files:
      Tag: hal-0_4-stable-branch
	block_class_device.c net_class_device.c 
Log Message:
2005-01-06  David Zeuthen  <davidz at redhat.com>

	* hald/linux/net_class_device.c (net_class_pre_process): Add some
	fairly ugly code for checking in /proc/net/wireless whether an
	interface is wireless since the 2.6.10 kernel appears not put the
	wireless/ directory in sysfs anymore. Sigh.

	* hald/linux/block_class_device.c (block_class_pre_process): Allow
	probing of drive_id and for fstype on IDE devices that doesn't
	use removable media



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.86.2.6
retrieving revision 1.86.2.7
diff -u -d -r1.86.2.6 -r1.86.2.7
--- block_class_device.c	3 Jan 2005 15:45:06 -0000	1.86.2.6
+++ block_class_device.c	7 Jan 2005 03:07:45 -0000	1.86.2.7
@@ -1308,8 +1308,11 @@
 		 * cause inifite loops of hotplug events, cf. broken ide-cs driver and
 		 * broken zip drives. Merely accessing the top-level block device if it
 		 * or any of it partitions are not mounted causes the loop.
+		 *
+		 * Also allow this for devices without removable media
 		 */
-		if (hal_device_property_get_bool (stordev, "storage.media_check_enabled")) {
+		if (hal_device_property_get_bool (stordev, "storage.media_check_enabled") ||
+		    !hal_device_property_get_bool (stordev, "storage.removable")) {
 			dbus_uint64_t size = 0;
 			const char *stordev_device_file;
 
@@ -1384,6 +1387,17 @@
 	 ************************************************************/
 
 
+	snprintf (attr_path, SYSFS_PATH_MAX, "%s/removable", sysfs_path);
+	attr = sysfs_open_attribute (attr_path);
+	if (sysfs_read_attribute (attr) >= 0) {
+		if (attr->value [0] == '0')
+			has_removable_media = FALSE;
+		else
+			has_removable_media = TRUE;
+
+		sysfs_close_attribute (attr);
+	} 	
+
 	/* defaults */
 	hal_device_property_set_string (stordev, "storage.drive_type", "disk");
 
@@ -1438,8 +1452,11 @@
 		 * cause inifite loops of hotplug events, cf. broken ide-cs driver and
 		 * broken zip drives. Merely accessing the top-level block device if it
 		 * or any of it partitions are not mounted causes the loop.
+		 *
+		 * Also allow this when we don't have removable media.
 		 */
-		if (hal_device_property_get_bool (stordev, "storage.media_check_enabled")) {
+		if (hal_device_property_get_bool (stordev, "storage.media_check_enabled") ||
+		    !has_removable_media) {
 			const char *device_file;
 			struct drive_id *did;
 
@@ -1589,17 +1606,6 @@
 		
 	}
 
-	snprintf (attr_path, SYSFS_PATH_MAX, "%s/removable", sysfs_path);
-	attr = sysfs_open_attribute (attr_path);
-	if (sysfs_read_attribute (attr) >= 0) {
-		if (attr->value [0] == '0')
-			has_removable_media = FALSE;
-		else
-			has_removable_media = TRUE;
-
-		sysfs_close_attribute (attr);
-	} 
-	
 	hal_device_property_set_bool (stordev, "storage.removable", has_removable_media);
 
 	if (hal_device_has_property (stordev, "storage.drive_type") &&

Index: net_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/net_class_device.c,v
retrieving revision 1.21.2.2
retrieving revision 1.21.2.3
diff -u -d -r1.21.2.2 -r1.21.2.3
--- net_class_device.c	3 Jan 2005 22:07:39 -0000	1.21.2.2
+++ net_class_device.c	7 Jan 2005 03:07:45 -0000	1.21.2.3
@@ -525,7 +525,7 @@
 	const char *media;
 	char wireless_path[SYSFS_PATH_MAX];
 	char driver_path[SYSFS_PATH_MAX];
-	dbus_bool_t is_80211 = FALSE;
+	dbus_bool_t is_80211;
 	int ifindex;
 	int flags;
 	struct stat statbuf;
@@ -537,13 +537,7 @@
 	hal_device_property_set_string (d, "net.interface",
 					class_device->name);
 
-	/* Check to see if this interface supports wireless extensions */
 	is_80211 = FALSE;
-	snprintf (wireless_path, SYSFS_PATH_MAX, "%s/wireless", sysfs_path);
-	if (stat (wireless_path, &statbuf) == 0) {
-		hal_device_add_capability (d, "net.80211");
-		is_80211 = TRUE;
-	}
 
 	/* Check driver link (may be unavailable for PCMCIA devices) */
 	snprintf (driver_path, SYSFS_PATH_MAX, "%s/driver", sysfs_path);
@@ -566,11 +560,61 @@
 		media_type = parse_dec (attr->value);
 	}
 
+	if (media_type == ARPHRD_ETHER) {
+		FILE *f;
+		dbus_bool_t is_wireless;
+
+
+		is_wireless = FALSE;
+
+		f = fopen ("/proc/net/wireless", "ro");
+		if (f != NULL) {
+			unsigned int i;
+			unsigned int ifname_len;
+			char buf[128];
+
+			ifname_len = strlen (class_device->name);
+
+			do {
+				if (fgets (buf, sizeof (buf), f) == NULL)
+					break;
+
+				for (i=0; i < sizeof (buf); i++) {
+					if (isspace (buf[i]))
+						continue;
+					else
+						break;
+				}
+
+				if (strncmp (class_device->name, buf + i, ifname_len) == 0) {
+					is_wireless = TRUE;
+					break;
+				}
+
+			} while (TRUE);
+			fclose (f);
+		}
+
+		if (is_wireless) {
+		/* Check to see if this interface supports wireless extensions */
+		/*
+		snprintf (wireless_path, SYSFS_PATH_MAX, "%s/wireless", sysfs_path);
+		if (stat (wireless_path, &statbuf) == 0) {
+		*/
+			hal_device_property_set_string (d, "info.category", "net.80211");
+			hal_device_add_capability (d, "net.80211");
+			is_80211 = TRUE;
+		} else {
+			hal_device_property_set_string (d, "info.category", "net.80203");
+			hal_device_add_capability (d, "net.80203");
+		}
+	}
+
 	attr = sysfs_get_classdev_attr (class_device, "flags");
 	if (attr != NULL) {
 		flags = parse_hex (attr->value);
 		hal_device_property_set_bool (d, "net.interface_up", flags & IFF_UP);
-		if (!is_80211) {
+		if (!is_80211 && media_type == ARPHRD_ETHER) {
 			/* TODO: for some reason IFF_RUNNING isn't exported in flags */
 			/*hal_device_property_set_bool (d, "net.80203.link", flags & IFF_RUNNING);*/
 			mii_get_link (d);
@@ -618,13 +662,6 @@
 	hal_device_property_set_string (d, "net.media", media);
 
 	hal_device_add_capability (d, "net");
-	if (is_80211) {
-		hal_device_property_set_string (d, "info.category", "net.80211");
-		hal_device_add_capability (d, "net.80211");
-	} else {
-		hal_device_property_set_string (d, "info.category", "net.80203");
-		hal_device_add_capability (d, "net.80203");
-	}
 
 #if PCMCIA_SUPPORT_ENABLE
 	/* Add PCMCIA specific entries for PCMCIA cards */




More information about the hal-commit mailing list