diff options
author | David Zeuthen <david@fubar.dk> | 2004-03-30 00:04:36 +0000 |
---|---|---|
committer | David Zeuthen <david@fubar.dk> | 2004-03-30 00:04:36 +0000 |
commit | 11a968c5c4a49207645594bbb5e729f56994661a (patch) | |
tree | 1ab34c98f55d03e8c675b5dc272cf5c43e6b8a0d | |
parent | 1b9ece3222b4eae5aeedb39a942a104b309e51f8 (diff) |
sysfs_mnt_path should be a "char []" not a "char * []", also use PATH_MAX
instead of 255, and finally use "const char" as appropriate
media detection on CD-ROM's from the patch from Robert
(storage.cdrom.media_type) (block_class_tick): Comment out noisy debug
statement when polling
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | hald/linux/block_class_device.c | 39 | ||||
-rw-r--r-- | tools/linux/hal_hotplug.c | 41 |
3 files changed, 71 insertions, 21 deletions
@@ -1,3 +1,15 @@ +2004-03-29 Robert Love <rml@ximian.com> + + * tools/linux/hal_hotplug.c: sysfs_mnt_path should be a "char []" + not a "char * []", also use PATH_MAX instead of 255, and finally + use "const char" as appropriate + +2004-03-30 David Zeuthen <david@fubar.dk> + + * hald/linux/block_class_device.c (detect_media): media detection + on CD-ROM's from the patch from Robert (storage.cdrom.media_type) + (block_class_tick): Comment out noisy debug statement when polling + 2004-03-30 David Zeuthen <david@fubar.dk> * hald/main.c (device_get_all_properties): Comment out noise trace diff --git a/hald/linux/block_class_device.c b/hald/linux/block_class_device.c index bf07e792..649edce9 100644 --- a/hald/linux/block_class_device.c +++ b/hald/linux/block_class_device.c @@ -1074,11 +1074,10 @@ detect_media (HalDevice * d) * only one child) */ - close (fd); - child = ds_device_find_by_key_value_string ("info.parent", d->udi, TRUE); if (child == NULL) { + int type; char udi[256]; /* nope, add child */ @@ -1110,6 +1109,40 @@ detect_media (HalDevice * d) ds_property_set_string (child, "info.udi", udi); ds_device_set_udi (child, udi); + /* set disc media type as appropriate */ + type = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT); + close(fd); + switch (type) { + case CDS_AUDIO: /* audio CD */ + ds_property_set_string (child, + "storage.cdrom.media_type", + "audio"); + break; + case CDS_MIXED: /* mixed mode CD */ + ds_property_set_string (child, + "storage.cdrom.media_type", + "mixed"); + break; + case CDS_DATA_1: /* data CD */ + case CDS_DATA_2: + case CDS_XA_2_1: + case CDS_XA_2_2: + ds_property_set_string (child, + "storage.cdrom.media_type", + "data"); + break; + case CDS_NO_INFO: /* blank or invalid CD */ + ds_property_set_string (child, + "storage.cdrom.media_type", + "blank"); + break; + default: /* should never see this */ + ds_property_set_string (child, + "storage.cdrom.media_type", + "unknown"); + break; + } + /* add new device */ ds_gdl_add (child); @@ -1162,7 +1195,7 @@ block_class_tick (ClassDeviceHandler *self) etc_mtab_process_all_block_devices (FALSE); } - HAL_INFO (("exiting")); + /*HAL_INFO (("exiting"));*/ return TRUE; } diff --git a/tools/linux/hal_hotplug.c b/tools/linux/hal_hotplug.c index 3a63e1c2..ef5ab527 100644 --- a/tools/linux/hal_hotplug.c +++ b/tools/linux/hal_hotplug.c @@ -36,6 +36,7 @@ #include <unistd.h> #include <mntent.h> #include <syslog.h> +#include <linux/limits.h> #include <dbus/dbus.h> @@ -54,7 +55,7 @@ */ -static char *sysfs_mnt_path[255]; +static char sysfs_mnt_path[PATH_MAX]; /** Get the mount path for sysfs. A side-effect is that sysfs_mnt_path * is set on success. @@ -77,7 +78,7 @@ get_sysfs_mnt_path () && (mntent = getmntent (mnt)) != NULL) { if (strcmp (mntent->mnt_type, "sysfs") == 0) { dirlen = strlen (mntent->mnt_dir); - if (dirlen <= (255 - 1)) { + if (dirlen <= (PATH_MAX - 1)) { strcpy (sysfs_mnt_path, mntent->mnt_dir); } else { ret = -1; @@ -92,7 +93,8 @@ get_sysfs_mnt_path () return ret; } -static char *file_list_usb[] = { "idProduct", +static const char *file_list_usb[] = { + "idProduct", "idVendor", "bcdDevice", "bMaxPower", @@ -109,23 +111,26 @@ static char *file_list_usb[] = { "idProduct", NULL }; -static char *file_list_usbif[] = { "bInterfaceClass", +static const char *file_list_usbif[] = { + "bInterfaceClass", "bInterfaceSubClass", "bInterfaceProtocol", "bInterfaceNumber", NULL }; -static char *file_list_scsi_device[] = { NULL }; +static const char *file_list_scsi_device[] = { NULL }; -static char *file_list_scsi_host[] = { NULL }; +static const char *file_list_scsi_host[] = { NULL }; -static char *file_list_block[] = { "dev", +static const char *file_list_block[] = { + "dev", "size", NULL }; -static char *file_list_pci[] = { "device", +static const char *file_list_pci[] = { + "device", "vendor", "subsystem_device", "subsystem_vendor", @@ -137,13 +142,12 @@ static int wait_for_sysfs_info (char *devpath, char *hotplug_type) { size_t devpath_len; - char **file_list; + const char **file_list; int num_tries; int rc; struct stat stat_buf; - char *file; int i; - char path[255]; + char path[PATH_MAX]; syslog (LOG_NOTICE, "waiting for %s info at %s", hotplug_type, devpath); @@ -201,8 +205,8 @@ wait_for_sysfs_info (char *devpath, char *hotplug_type) num_tries++; /* first, check directory */ - strncpy (path, sysfs_mnt_path, 255); - strncat (path, devpath, 255); + strncpy (path, sysfs_mnt_path, PATH_MAX); + strncat (path, devpath, PATH_MAX); /*printf("path0 = %s\n", path); */ @@ -213,12 +217,13 @@ wait_for_sysfs_info (char *devpath, char *hotplug_type) /* second, check each requested file */ for (i = 0; file_list[i] != NULL; i++) { - file = file_list[i]; + const char *file; - strncpy (path, sysfs_mnt_path, 255); - strncat (path, devpath, 255); - strncat (path, "/", 255); - strncat (path, file, 255); + file = file_list[i]; + strncpy (path, sysfs_mnt_path, PATH_MAX); + strncat (path, devpath, PATH_MAX); + strncat (path, "/", PATH_MAX); + strncat (path, file, PATH_MAX); /*printf("path1 = %s\n", path); */ |