mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-02 04:46:46 -05:00
Add smartctl_scan into support module
This commit is contained in:
parent
ebabaacfe9
commit
74026ddca8
3 changed files with 43 additions and 27 deletions
|
|
@ -439,7 +439,6 @@ int smartctl_attribute(FILE* f, uint64_t* smart, char* serial)
|
|||
char* s;
|
||||
|
||||
s = fgets(buf, sizeof(buf), f);
|
||||
|
||||
if (s == 0)
|
||||
break;
|
||||
|
||||
|
|
@ -489,3 +488,34 @@ int smartctl_attribute(FILE* f, uint64_t* smart, char* serial)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int smartctl_scan(FILE* f, tommy_list* list)
|
||||
{
|
||||
while (1) {
|
||||
char buf[256];
|
||||
char* s;
|
||||
|
||||
s = fgets(buf, sizeof(buf), f);
|
||||
if (s == 0)
|
||||
break;
|
||||
|
||||
if (*s == '/') {
|
||||
char* sep = strchr(s, ' ');
|
||||
if (sep) {
|
||||
devinfo_t* devinfo;
|
||||
|
||||
/* clear everything after the first space */
|
||||
*sep = 0;
|
||||
|
||||
devinfo = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
pathcpy(devinfo->file, sizeof(devinfo->file), s);
|
||||
|
||||
/* insert in the list */
|
||||
tommy_list_insert_tail(list, &devinfo->node, devinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue