Changeset View
Changeset View
Standalone View
Standalone View
sbin/nvmecontrol/firmware.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "nvmecontrol.h" | #include "nvmecontrol.h" | ||||
#define FIRMWARE_USAGE \ | #define FIRMWARE_USAGE \ | ||||
"firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n" | "firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n" | ||||
#define FIRMWARE_ARGS \ | |||||
"<controller id>" | |||||
#define FIRMWARE_DESCR \ | |||||
"Download firmware image to controller." | |||||
static int | static int | ||||
slot_has_valid_firmware(int fd, int slot) | slot_has_valid_firmware(int fd, int slot) | ||||
{ | { | ||||
struct nvme_firmware_page fw; | struct nvme_firmware_page fw; | ||||
int has_fw = false; | int has_fw = false; | ||||
read_logpage(fd, NVME_LOG_FIRMWARE_SLOT, | read_logpage(fd, NVME_LOG_FIRMWARE_SLOT, | ||||
NVME_GLOBAL_NAMESPACE_TAG, &fw, sizeof(fw)); | NVME_GLOBAL_NAMESPACE_TAG, &fw, sizeof(fw)); | ||||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | if (reboot_required) { | ||||
controller); | controller); | ||||
} | } | ||||
} | } | ||||
close(fd); | close(fd); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
NVME_COMMAND(top, firmware, firmware, FIRMWARE_USAGE); | NVME_COMMAND(top, firmware, firmware, FIRMWARE_USAGE, FIRMWARE_ARGS, FIRMWARE_DESCR); |