Changeset View
Changeset View
Standalone View
Standalone View
sbin/nvmecontrol/reset.c
- This file was copied to sbin/nvmecontrol/opts.h.
Show All 35 Lines | |||||
#include <fcntl.h> | #include <fcntl.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 RESET_USAGE \ | #define RESET_USAGE \ | ||||
"reset <controller id>\n" | "reset <controller id>\n" | ||||
#define RESET_ARGS \ | |||||
"<controller id>" | |||||
#define RESET_DESCR \ | |||||
"Perform a controller-level reset." | |||||
static void | static void | ||||
reset(const struct nvme_function *nf, int argc, char *argv[]) | reset(const struct nvme_function *nf, int argc, char *argv[]) | ||||
{ | { | ||||
int ch, fd; | int ch, fd; | ||||
while ((ch = getopt(argc, argv, "")) != -1) { | while ((ch = getopt(argc, argv, "")) != -1) { | ||||
switch ((char)ch) { | switch ((char)ch) { | ||||
default: | default: | ||||
usage(nf); | usage(nf); | ||||
} | } | ||||
} | } | ||||
/* Check that a controller was specified. */ | /* Check that a controller was specified. */ | ||||
if (optind >= argc) | if (optind >= argc) | ||||
usage(nf); | usage(nf); | ||||
open_dev(argv[optind], &fd, 1, 1); | open_dev(argv[optind], &fd, 1, 1); | ||||
if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) | if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) | ||||
err(1, "reset request to %s failed", argv[optind]); | err(1, "reset request to %s failed", argv[optind]); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
NVME_COMMAND(top, reset, reset, RESET_USAGE); | NVME_COMMAND(top, reset, reset, RESET_USAGE, RESET_ARGS, RESET_DESCR); |