Changeset View
Changeset View
Standalone View
Standalone View
sbin/nvmecontrol/format.c
Show All 37 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 FORMAT_USAGE \ | #define FORMAT_USAGE \ | ||||
"format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n" | "format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n" | ||||
#define FORMAT_ARGS \ | |||||
"<controller id|namespace id>" | |||||
#define FORMAT_DESCR \ | |||||
"Format/erase one or all the namespaces." | |||||
static void | static void | ||||
format(const struct nvme_function *nf, int argc, char *argv[]) | format(const struct nvme_function *nf, int argc, char *argv[]) | ||||
{ | { | ||||
struct nvme_controller_data cd; | struct nvme_controller_data cd; | ||||
struct nvme_namespace_data nsd; | struct nvme_namespace_data nsd; | ||||
struct nvme_pt_command pt; | struct nvme_pt_command pt; | ||||
char path[64]; | char path[64]; | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) | ||||
err(1, "format request failed"); | err(1, "format request failed"); | ||||
if (nvme_completion_is_error(&pt.cpl)) | if (nvme_completion_is_error(&pt.cpl)) | ||||
errx(1, "format request returned error"); | errx(1, "format request returned error"); | ||||
close(fd); | close(fd); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
NVME_COMMAND(top, format, format, FORMAT_USAGE); | NVME_COMMAND(top, format, format, FORMAT_USAGE, FORMAT_ARGS, FORMAT_DESCR); |