int is_microsoft_nvme_device()

in src/identify_disks.c [217:238]


int is_microsoft_nvme_device(const char *device_name)
{
    char vendor_id_path[MAX_PATH];
    snprintf(vendor_id_path, sizeof(vendor_id_path), "%s/%s/device/vendor", SYS_CLASS_NVME_PATH, device_name);

    FILE *file = fopen(vendor_id_path, "r");
    if (file == NULL)
    {
        return 0;
    }

    unsigned int vendor_id;
    int result = fscanf(file, "%x", &vendor_id);
    fclose(file);

    if (result != 1)
    {
        return 0;
    }

    return vendor_id == MICROSOFT_NVME_VENDOR_ID;
}