+static
+int lttng_enumerate_block_devices(struct lttng_session *session)
+{
+ struct class_dev_iter iter;
+ struct device *dev;
+
+ class_dev_iter_init(&iter, gendisk_block_class(), NULL,
+ gendisk_device_type());
+ while ((dev = class_dev_iter_next(&iter))) {
+ struct disk_part_iter piter;
+ struct gendisk *disk = dev_to_disk(dev);
+ struct hd_struct *part;
+
+ /*
+ * Don't show empty devices or things that have been
+ * suppressed
+ */
+ if (get_capacity(disk) == 0 ||
+ (disk->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
+ continue;
+
+ disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
+ while ((part = disk_part_iter_next(&piter))) {
+ char name_buf[BDEVNAME_SIZE];
+ char *p;
+
+ p = gendisk_name(disk, part->partno, name_buf);
+ if (!p) {
+ disk_part_iter_exit(&piter);
+ class_dev_iter_exit(&iter);
+ return -ENOSYS;
+ }
+ trace_lttng_statedump_block_device(session,
+ part_devt(part), name_buf);
+ }
+ disk_part_iter_exit(&piter);
+ }
+ class_dev_iter_exit(&iter);
+ return 0;
+}
+