hal/hald/linux2 osspec.c,1.30,1.31

David Zeuthen david at freedesktop.org
Mon Oct 31 07:54:56 PST 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv5798/hald/linux2

Modified Files:
	osspec.c 
Log Message:
2005-10-31  David Zeuthen  <davidz at redhat.com>

        * hald/linux2/osspec.c (netlink_detection_data_ready): Look at all
        netlink messages, not just the first one.
        Patch from Jon Nettleton <jon.nettleton at gmail.com>.



Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- osspec.c	25 Oct 2005 16:06:13 -0000	1.30
+++ osspec.c	31 Oct 2005 15:54:54 -0000	1.31
@@ -217,9 +217,7 @@
 
 	do {
 		errno = 0;
-		bytes_read = recvfrom (fd,
-				   buf + total_read,
-				   sizeof (buf) - total_read,
+		bytes_read = recvfrom (fd, buf, sizeof (buf),
 				   MSG_DONTWAIT,
 				   (struct sockaddr*)&nladdr, &nladdrlen);
 		if (nladdrlen != sizeof(nladdr)) {
@@ -230,34 +228,33 @@
 			HAL_ERROR(("Spoofed packet received on netlink socket"));
 			return TRUE;
 		}
-		if (bytes_read > 0)
-			total_read += bytes_read;
-	} while (bytes_read > 0 || errno == EINTR);
 
-	if (bytes_read < 0 && errno != EAGAIN) {
-		HAL_ERROR (("Error reading data off netlink socket"));
-		return TRUE;
-	}
+		if (bytes_read < 0 && errno != EAGAIN) {
+			HAL_ERROR (("Error reading data off netlink socket"));
+			return TRUE;
+		} else if ( bytes_read < 0 ) {
+			return TRUE;
+		} else {
+			HAL_INFO (("bytes_read=%d buf='%s'", bytes_read, buf));
+		}
 
-	if (total_read > 0) {
-		HAL_INFO (("total_read=%d buf='%s'", total_read, buf));
-	}
+		/* Handle event: "mount@/block/hde" */
+		if (g_str_has_prefix (buf, "mount")) {
+			gchar sysfs_path[HAL_PATH_MAX];
+			g_strlcpy (sysfs_path, get_hal_sysfs_path (), sizeof (sysfs_path));
+			g_strlcat (sysfs_path, ((char *) buf) + sizeof ("mount"), sizeof (sysfs_path));
+			blockdev_mount_status_changed (sysfs_path, TRUE);
+		}
 
-	/* Handle event: "mount@/block/hde" */
-	if (g_str_has_prefix (buf, "mount")) {
-		gchar sysfs_path[HAL_PATH_MAX];
-		g_strlcpy (sysfs_path, get_hal_sysfs_path (), sizeof (sysfs_path));
-		g_strlcat (sysfs_path, ((char *) buf) + sizeof ("mount"), sizeof (sysfs_path));
-		blockdev_mount_status_changed (sysfs_path, TRUE);
-	}
+		/* Handle event: "umount@/block/hde" */
+		if (g_str_has_prefix (buf, "umount")) {
+			gchar sysfs_path[HAL_PATH_MAX];
+			g_strlcpy (sysfs_path, get_hal_sysfs_path (), sizeof (sysfs_path));
+			g_strlcat (sysfs_path, ((char *) buf) + sizeof ("umount"), sizeof (sysfs_path));
+			blockdev_mount_status_changed (sysfs_path, FALSE);
+		}
 
-	/* Handle event: "umount@/block/hde" */
-	if (g_str_has_prefix (buf, "umount")) {
-		gchar sysfs_path[HAL_PATH_MAX];
-		g_strlcpy (sysfs_path, get_hal_sysfs_path (), sizeof (sysfs_path));
-		g_strlcat (sysfs_path, ((char *) buf) + sizeof ("umount"), sizeof (sysfs_path));
-		blockdev_mount_status_changed (sysfs_path, FALSE);
-	}
+	} while (bytes_read > 0 || errno == EINTR);
 
 	return TRUE;
 }




More information about the hal-commit mailing list