获取SCSI的供应商名称 [英] Get vendor name of SCSI

查看:218
本文介绍了获取SCSI的供应商名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能在Linux和放大器的SCSI设备的供应商名称; C?

How can I get the vendor name of SCSI device on linux & c?

推荐答案

您可以使用的 libudev 找到SCSI设备并读取供应商属性(未经测试):

You can use libudev to find SCSI devices and read the vendor attribute (untested):

struct udev *context = udev_new();
struct udev_enumerate *enumerator = udev_enumerate_new(context);
udev_enumerate_add_match_subsystem(enumerator, "scsi");
udev_enumerate_scan_devices(enumerator);
struct udev_list_entry *scsi_devices = udev_enumerate_get_list_entry(enumerator);
struct udev_list_entry *current = 0;
udev_list_entry_foreach(current, scsi_devices) {
    struct udev_device *device = udev_device_new_from_syspath(
            context, udev_list_entry_get_name(current));
    const char *vendor = udev_device_get_sysattr_value(device, "vendor");
    printf("%s\n", vendor);
}

这篇关于获取SCSI的供应商名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆