Adding upstream version 1.12.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
3b95ae912c
commit
ac60c09ef6
457 changed files with 159628 additions and 0 deletions
5663
plugins/wdc/wdc-nvme.c
Normal file
5663
plugins/wdc/wdc-nvme.c
Normal file
File diff suppressed because it is too large
Load diff
38
plugins/wdc/wdc-nvme.h
Normal file
38
plugins/wdc/wdc-nvme.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#undef CMD_INC_FILE
|
||||
#define CMD_INC_FILE plugins/wdc/wdc-nvme
|
||||
|
||||
#if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ)
|
||||
#define WDC_NVME
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
PLUGIN(NAME("wdc", "Western Digital vendor specific extensions"),
|
||||
COMMAND_LIST(
|
||||
ENTRY("cap-diag", "WDC Capture-Diagnostics", wdc_cap_diag)
|
||||
ENTRY("drive-log", "WDC Drive Log", wdc_drive_log)
|
||||
ENTRY("get-crash-dump", "WDC Crash Dump", wdc_get_crash_dump)
|
||||
ENTRY("get-pfail-dump", "WDC Pfail Dump", wdc_get_pfail_dump)
|
||||
ENTRY("id-ctrl", "WDC identify controller", wdc_id_ctrl)
|
||||
ENTRY("purge", "WDC Purge", wdc_purge)
|
||||
ENTRY("purge-monitor", "WDC Purge Monitor", wdc_purge_monitor)
|
||||
ENTRY("vs-internal-log", "WDC Internal Firmware Log", wdc_vs_internal_fw_log)
|
||||
ENTRY("vs-nand-stats", "WDC NAND Statistics", wdc_vs_nand_stats)
|
||||
ENTRY("vs-smart-add-log", "WDC Additional Smart Log", wdc_vs_smart_add_log)
|
||||
ENTRY("clear-pcie-correctable-errors", "WDC Clear PCIe Correctable Error Count", wdc_clear_pcie_correctable_errors)
|
||||
ENTRY("drive-essentials", "WDC Drive Essentials", wdc_drive_essentials)
|
||||
ENTRY("get-drive-status", "WDC Get Drive Status", wdc_drive_status)
|
||||
ENTRY("clear-assert-dump", "WDC Clear Assert Dump", wdc_clear_assert_dump)
|
||||
ENTRY("drive-resize", "WDC Drive Resize", wdc_drive_resize)
|
||||
ENTRY("vs-fw-activate-history", "WDC Get FW Activate History", wdc_vs_fw_activate_history)
|
||||
ENTRY("clear-fw-activate-history", "WDC Clear FW Activate History", wdc_clear_fw_activate_history)
|
||||
ENTRY("vs-telemetry-controller-option", "WDC Enable/Disable Controller Initiated Telemetry Log", wdc_vs_telemetry_controller_option)
|
||||
ENTRY("vs-error-reason-identifier", "WDC Telemetry Reason Identifier", wdc_reason_identifier)
|
||||
ENTRY("log-page-directory", "WDC Get Log Page Directory", wdc_log_page_directory)
|
||||
ENTRY("namespace-resize", "WDC NamespaceDrive Resize", wdc_namespace_resize)
|
||||
ENTRY("vs-drive-info", "WDC Get Drive Info", wdc_vs_drive_info)
|
||||
)
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#include "define_cmd.h"
|
146
plugins/wdc/wdc-utils.c
Normal file
146
plugins/wdc/wdc-utils.c
Normal file
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
* Author: Jeff Lien <jeff.lien@wdc.com>,
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include "wdc-utils.h"
|
||||
|
||||
int wdc_UtilsSnprintf(char *buffer, unsigned int sizeOfBuffer, const char *format, ...)
|
||||
{
|
||||
int res = 0;
|
||||
va_list vArgs;
|
||||
|
||||
va_start(vArgs, format);
|
||||
res = vsnprintf(buffer, sizeOfBuffer, format, vArgs);
|
||||
va_end(vArgs);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void wdc_UtilsDeleteCharFromString(char* buffer, int buffSize, char charToRemove)
|
||||
{
|
||||
int i = 0;
|
||||
int count = 0;
|
||||
|
||||
if (!buffer || !buffSize)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Traverse the given string. If current character is not charToRemove,
|
||||
* then place it at index count++
|
||||
*/
|
||||
for (i = 0; ((i < buffSize) && (buffer[i] != '\0')); i++) {
|
||||
if (buffer[i] != charToRemove)
|
||||
buffer[count++] = buffer[i];
|
||||
}
|
||||
buffer[count] = '\0';
|
||||
}
|
||||
|
||||
int wdc_UtilsGetTime(PUtilsTimeInfo timeInfo)
|
||||
{
|
||||
time_t currTime;
|
||||
struct tm currTimeInfo;
|
||||
|
||||
if(!timeInfo)
|
||||
return WDC_STATUS_INVALID_PARAMETER;
|
||||
|
||||
tzset();
|
||||
time(&currTime);
|
||||
localtime_r(&currTime, &currTimeInfo);
|
||||
|
||||
timeInfo->year = currTimeInfo.tm_year + 1900;
|
||||
timeInfo->month = currTimeInfo.tm_mon + 1;
|
||||
timeInfo->dayOfWeek = currTimeInfo.tm_wday;
|
||||
timeInfo->dayOfMonth = currTimeInfo.tm_mday;
|
||||
timeInfo->hour = currTimeInfo.tm_hour;
|
||||
timeInfo->minute = currTimeInfo.tm_min;
|
||||
timeInfo->second = currTimeInfo.tm_sec;
|
||||
timeInfo->msecs = 0;
|
||||
timeInfo->isDST = currTimeInfo.tm_isdst;
|
||||
timeInfo->zone = -currTimeInfo.tm_gmtoff / 60;
|
||||
|
||||
return WDC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int wdc_UtilsCreateDir(char *path)
|
||||
{
|
||||
int retStatus;
|
||||
int status = WDC_STATUS_SUCCESS;
|
||||
|
||||
if (!path )
|
||||
return WDC_STATUS_INVALID_PARAMETER;
|
||||
|
||||
retStatus = mkdir(path, 0x999);
|
||||
if (retStatus < 0) {
|
||||
if (errno == EEXIST)
|
||||
status = WDC_STATUS_DIR_ALREADY_EXISTS;
|
||||
else if (errno == ENOENT)
|
||||
status = WDC_STATUS_PATH_NOT_FOUND;
|
||||
else
|
||||
status = WDC_STATUS_CREATE_DIRECTORY_FAILED;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int wdc_WriteToFile(char *fileName, char *buffer, unsigned int bufferLen)
|
||||
{
|
||||
int status = WDC_STATUS_SUCCESS;
|
||||
FILE *file;
|
||||
size_t bytesWritten = 0;
|
||||
|
||||
file = fopen(fileName, "ab+");
|
||||
if (!file) {
|
||||
status = WDC_STATUS_UNABLE_TO_OPEN_FILE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
bytesWritten = fwrite(buffer, 1, bufferLen, file);
|
||||
if (bytesWritten != bufferLen)
|
||||
status = WDC_STATUS_UNABLE_TO_WRITE_ALL_DATA;
|
||||
|
||||
end:
|
||||
if(file)
|
||||
fclose(file);
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the strings ignoring their cases.
|
||||
*
|
||||
* @param pcSrc Points to a null terminated string for comapring.
|
||||
* @param pcDst Points to a null terminated string for comapring.
|
||||
*
|
||||
* @returns zero if the string matches or
|
||||
* 1 if the pcSrc string is lexically higher than pcDst or
|
||||
* -1 if the pcSrc string is lexically lower than pcDst.
|
||||
*/
|
||||
int wdc_UtilsStrCompare(char *pcSrc, char *pcDst)
|
||||
{
|
||||
while ((toupper(*pcSrc) == toupper(*pcDst)) && (*pcSrc != '\0')) {
|
||||
pcSrc++;
|
||||
pcDst++;
|
||||
}
|
||||
return *pcSrc - *pcDst;
|
||||
}
|
||||
|
77
plugins/wdc/wdc-utils.h
Normal file
77
plugins/wdc/wdc-utils.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
* Author: Jeff Lien <jeff.lien@wdc.com>,
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Create Dir Command Status */
|
||||
#define WDC_STATUS_SUCCESS 0
|
||||
#define WDC_STATUS_FAILURE -1
|
||||
#define WDC_STATUS_INSUFFICIENT_MEMORY -2
|
||||
#define WDC_STATUS_INVALID_PARAMETER -3
|
||||
#define WDC_STATUS_FILE_SIZE_ZERO -27
|
||||
#define WDC_STATUS_UNABLE_TO_WRITE_ALL_DATA -34
|
||||
#define WDC_STATUS_DIR_ALREADY_EXISTS -36
|
||||
#define WDC_STATUS_PATH_NOT_FOUND -37
|
||||
#define WDC_STATUS_CREATE_DIRECTORY_FAILED -38
|
||||
#define WDC_STATUS_DELETE_DIRECTORY_FAILED -39
|
||||
#define WDC_STATUS_UNABLE_TO_OPEN_FILE -40
|
||||
#define WDC_STATUS_UNABLE_TO_OPEN_ZIP_FILE -41
|
||||
#define WDC_STATUS_UNABLE_TO_ARCHIVE_EXCEEDED_FILES_LIMIT -256
|
||||
#define WDC_STATUS_NO_DATA_FILE_AVAILABLE_TO_ARCHIVE -271
|
||||
|
||||
#define WDC_NVME_FIRMWARE_REV_LEN 9 /* added 1 for end delimiter */
|
||||
#define WDC_SERIAL_NO_LEN 20
|
||||
#define SECONDS_IN_MIN 60
|
||||
#define MAX_PATH_LEN 256
|
||||
|
||||
typedef struct _UtilsTimeInfo
|
||||
{
|
||||
unsigned int year;
|
||||
unsigned int month;
|
||||
unsigned int dayOfWeek;
|
||||
unsigned int dayOfMonth;
|
||||
unsigned int hour;
|
||||
unsigned int minute;
|
||||
unsigned int second;
|
||||
unsigned int msecs;
|
||||
unsigned char isDST; /*0 or 1 */
|
||||
int zone; /* Zone value like +530 or -300 */
|
||||
} UtilsTimeInfo, *PUtilsTimeInfo;
|
||||
|
||||
int wdc_UtilsSnprintf(char *buffer, unsigned int sizeOfBuffer, const char *format, ...);
|
||||
void wdc_UtilsDeleteCharFromString(char* buffer, int buffSize, char charToRemove);
|
||||
int wdc_UtilsGetTime(PUtilsTimeInfo timeInfo);
|
||||
int wdc_UtilsStrCompare(char *pcSrc, char *pcDst);
|
||||
int wdc_UtilsCreateDir(char *path);
|
||||
int wdc_WriteToFile(char *fileName, char *buffer, unsigned int bufferLen);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue