| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: devlist.c,v 1.5 2018/04/18 10:11:44 nonaka Exp $ */ | | 1 | /* $NetBSD: devlist.c,v 1.5.12.1 2023/04/25 15:25:36 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | | 4 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD |
5 | * | | 5 | * |
6 | * Copyright (C) 2012-2013 Intel Corporation | | 6 | * Copyright (C) 2012-2013 Intel Corporation |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | * SUCH DAMAGE. | | 28 | * SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | #ifndef lint | | 32 | #ifndef lint |
33 | __RCSID("$NetBSD: devlist.c,v 1.5 2018/04/18 10:11:44 nonaka Exp $"); | | 33 | __RCSID("$NetBSD: devlist.c,v 1.5.12.1 2023/04/25 15:25:36 martin Exp $"); |
34 | #if 0 | | 34 | #if 0 |
35 | __FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 329824 2018-02-22 13:32:31Z wma $"); | | 35 | __FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 329824 2018-02-22 13:32:31Z wma $"); |
36 | #endif | | 36 | #endif |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | | | 40 | |
41 | #include <err.h> | | 41 | #include <err.h> |
42 | #include <errno.h> | | 42 | #include <errno.h> |
43 | #include <fcntl.h> | | 43 | #include <fcntl.h> |
44 | #include <paths.h> | | 44 | #include <paths.h> |
45 | #include <stddef.h> | | 45 | #include <stddef.h> |
46 | #include <stdio.h> | | 46 | #include <stdio.h> |
| @@ -108,18 +108,20 @@ devlist(int argc, char *argv[]) | | | @@ -108,18 +108,20 @@ devlist(int argc, char *argv[]) |
108 | sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, | | 108 | sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, |
109 | NVME_NS_PREFIX, i+1); | | 109 | NVME_NS_PREFIX, i+1); |
110 | read_namespace_data(fd, i+1, &nsdata); | | 110 | read_namespace_data(fd, i+1, &nsdata); |
111 | printf(" %10s (%lldMB)\n", | | 111 | printf(" %10s (%lldMB)\n", |
112 | name, | | 112 | name, |
113 | nsdata.nsze * | | 113 | nsdata.nsze * |
114 | (long long)ns_get_sector_size(&nsdata) / | | 114 | (long long)ns_get_sector_size(&nsdata) / |
115 | 1024 / 1024); | | 115 | 1024 / 1024); |
116 | } | | 116 | } |
117 | | | 117 | |
118 | close(fd); | | 118 | close(fd); |
119 | } | | 119 | } |
120 | | | 120 | |
121 | if (found == 0) | | 121 | if (found == 0) { |
122 | printf("No NVMe controllers found.\n"); | | 122 | printf("No NVMe controllers found.\n"); |
| | | 123 | exit(1); |
| | | 124 | } |
123 | | | 125 | |
124 | exit(1); | | 126 | exit(0); |
125 | } | | 127 | } |