+ if (stats_dict == NULL)
+ {
+ DEBUG ("CFDictionaryGetValue (%s) failed.",
+ kIOBlockStorageDriverStatisticsKey);
+ CFRelease (props_dict);
+ IOObjectRelease (disk_child);
+ IOObjectRelease (disk);
+ continue;
+ }
+
+ if (IORegistryEntryCreateCFProperties (disk_child,
+ (CFMutableDictionaryRef *) &child_dict,
+ kCFAllocatorDefault,
+ kNilOptions)
+ != kIOReturnSuccess)
+ {
+ DEBUG ("IORegistryEntryCreateCFProperties (disk_child) failed.");
+ IOObjectRelease (disk_child);
+ CFRelease (props_dict);
+ IOObjectRelease (disk);
+ continue;
+ }
+
+ /* kIOBSDNameKey */
+ disk_major = (int) dict_get_value (child_dict,
+ kIOBSDMajorKey);
+ disk_minor = (int) dict_get_value (child_dict,
+ kIOBSDMinorKey);
+ read_ops = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsReadsKey);
+ read_byt = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsBytesReadKey);
+ read_tme = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsTotalReadTimeKey);
+ write_ops = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsWritesKey);
+ write_byt = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsBytesWrittenKey);
+ /* This property describes the number of nanoseconds spent
+ * performing writes since the block storage driver was
+ * instantiated. It is one of the statistic entries listed
+ * under the top-level kIOBlockStorageDriverStatisticsKey
+ * property table. It has an OSNumber value. */
+ write_tme = dict_get_value (stats_dict,
+ kIOBlockStorageDriverStatisticsTotalWriteTimeKey);
+
+ if (snprintf (disk_name, 64, "%i-%i", disk_major, disk_minor) >= 64)
+ {
+ DEBUG ("snprintf (major, minor) failed.");
+ CFRelease (child_dict);
+ IOObjectRelease (disk_child);
+ CFRelease (props_dict);
+ IOObjectRelease (disk);
+ continue;
+ }
+ DEBUG ("disk_name = %s", disk_name);
+
+ if ((read_byt != -1LL) || (write_byt != -1LL))
+ disk_submit (disk_name, "disk_octets", read_byt, write_byt);
+ if ((read_ops != -1LL) || (write_ops != -1LL))
+ disk_submit (disk_name, "disk_ops", read_ops, write_ops);
+ if ((read_tme != -1LL) || (write_tme != -1LL))
+ disk_submit (disk_name, "disk_time",
+ read_tme / 1000,
+ write_tme / 1000);
+
+ CFRelease (child_dict);
+ IOObjectRelease (disk_child);
+ CFRelease (props_dict);
+ IOObjectRelease (disk);
+ }
+ IOObjectRelease (disk_list);
+/* #endif HAVE_IOKIT_IOKITLIB_H */
+
+#elif KERNEL_LINUX