static int is_ssd(const char *file) { blkid_probe probe; char wholedisk[32]; char sysfs_path[PATH_MAX]; dev_t devno; int fd; char rotational; int ret; probe = blkid_new_probe_from_filename(file); if (!probe) return 0; /* Device number of this disk (possibly a partition) */ devno = blkid_probe_get_devno(probe); if (!devno) { blkid_free_probe(probe); return 0; } /* Get whole disk name (not full path) for this devno */ ret = blkid_devno_to_wholedisk(devno, wholedisk, sizeof(wholedisk), NULL); if (ret) { blkid_free_probe(probe); return 0; } snprintf(sysfs_path, PATH_MAX, "/sys/block/%s/queue/rotational", wholedisk); blkid_free_probe(probe); fd = open(sysfs_path, O_RDONLY); if (fd < 0) { return 0; } if (read(fd, &rotational, sizeof(char)) < sizeof(char)) { close(fd); return 0; } close(fd); return !atoi((const char *)&rotational); }
uint32_t size; /* stripe unit 512-byte blocks */ uint32_t width; /* the number of stripe members or RAID data disks */ } evms_stripe_info; static int is_evms_device(dev_t devno) { if (major(devno) == EVMS_MAJOR) return 1; return blkid_driver_has_major("evms", major(devno)); } static int probe_evms_tp(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__))) { struct evms_stripe_info evms; dev_t devno = blkid_probe_get_devno(pr); if (!devno) goto nothing; /* probably not a block device */ if (!is_evms_device(devno)) goto nothing; memset(&evms, 0, sizeof(evms)); if (ioctl(pr->fd, EVMS_GET_STRIPE_INFO, &evms)) goto nothing; blkid_topology_set_minimum_io_size(pr, evms.size << 9); blkid_topology_set_optimal_io_size(pr, (evms.size * evms.width) << 9);