Adding upstream version 2.1~rc0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
1b3a431c1d
commit
8e91e2f7f6
504 changed files with 6751 additions and 2957 deletions
|
@ -1,3 +1,4 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -59,10 +60,13 @@ static char *find_data(char *data)
|
|||
static char *locate_info(char *data, bool is_inner, bool is_class)
|
||||
{
|
||||
char *orig = data;
|
||||
char *locate = find_data(data);
|
||||
char *locate;
|
||||
if (!data)
|
||||
return orig;
|
||||
|
||||
locate = find_data(data);
|
||||
if (!locate)
|
||||
return orig;
|
||||
if (is_class)
|
||||
return locate + 4;
|
||||
if (!is_inner)
|
||||
|
@ -236,7 +240,7 @@ static void pull_class_info(char **_newline, FILE *file, char *class)
|
|||
static int read_sys_node(char *where, char *save, size_t savesz)
|
||||
{
|
||||
char *new;
|
||||
int fd, ret = 0;
|
||||
int fd, ret = 0, len;
|
||||
fd = open(where, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Failed to open %s with errno %s\n",
|
||||
|
@ -244,13 +248,15 @@ static int read_sys_node(char *where, char *save, size_t savesz)
|
|||
return 1;
|
||||
}
|
||||
/* -1 so we can safely use strstr below */
|
||||
if(!read(fd, save, savesz - 1))
|
||||
len = read(fd, save, savesz - 1);
|
||||
if (!len)
|
||||
ret = 1;
|
||||
|
||||
new = strstr(save, "\n");
|
||||
if (new)
|
||||
new[0] = '\0';
|
||||
|
||||
else {
|
||||
save[len] = '\0';
|
||||
new = strstr(save, "\n");
|
||||
if (new)
|
||||
new[0] = '\0';
|
||||
}
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
@ -330,6 +336,7 @@ char *nvme_product_name(int id)
|
|||
continue;
|
||||
if (is_top_level_match(line, vendor, false)) {
|
||||
line[amnt - 1] = '\0';
|
||||
free(device_top);
|
||||
device_top = strdup(line);
|
||||
parse_vendor_device(&line, file,
|
||||
device,
|
||||
|
@ -346,5 +353,5 @@ char *nvme_product_name(int id)
|
|||
error0:
|
||||
fclose(file);
|
||||
error1:
|
||||
return !line ? strdup("NULL") : strdup("Unknown Device");
|
||||
return strdup("NULL");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue