reset.c (67350cb56a69468c118bd4ccf6e361b7ebfa9eb4) reset.c (f634b4c1be662a3abd518e82b5090ee1d5209c48)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (C) 2012-2013 Intel Corporation
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 27 unchanged lines hidden (view full) ---

36#include <fcntl.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41
42#include "nvmecontrol.h"
43
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (C) 2012-2013 Intel Corporation
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 27 unchanged lines hidden (view full) ---

36#include <fcntl.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41
42#include "nvmecontrol.h"
43
44#define RESET_USAGE \
45 "reset <controller id>\n"
44static struct options {
45 const char *dev;
46} opt = {
47 .dev = NULL
48};
46
49
50static const struct args args[] = {
51 { arg_string, &opt.dev, "controller-id" },
52 { arg_none, NULL, NULL },
53};
54
47static void
55static void
48reset(const struct nvme_function *nf, int argc, char *argv[])
56reset(const struct cmd *f, int argc, char *argv[])
49{
57{
50 int ch, fd;
58 int fd;
51
59
52 while ((ch = getopt(argc, argv, "")) != -1) {
53 switch ((char)ch) {
54 default:
55 usage(nf);
56 }
57 }
60 arg_parse(argc, argv, f);
61 open_dev(opt.dev, &fd, 1, 1);
58
62
59 /* Check that a controller was specified. */
60 if (optind >= argc)
61 usage(nf);
62
63 open_dev(argv[optind], &fd, 1, 1);
64 if (ioctl(fd, NVME_RESET_CONTROLLER) < 0)
65 err(1, "reset request to %s failed", argv[optind]);
66
67 exit(0);
68}
69
63 if (ioctl(fd, NVME_RESET_CONTROLLER) < 0)
64 err(1, "reset request to %s failed", argv[optind]);
65
66 exit(0);
67}
68
70NVME_COMMAND(top, reset, reset, RESET_USAGE);
69static struct cmd reset_cmd = {
70 .name = "reset",
71 .fn = reset,
72 .descr = "Perform a controller-level reset.",
73 .args = args,
74};
75
76CMD_COMMAND(reset_cmd);