Page MenuHomeFreeBSD

D48220.id148445.diff
No OneTemporary

D48220.id148445.diff

diff --git a/sbin/nvmecontrol/devlist.c b/sbin/nvmecontrol/devlist.c
--- a/sbin/nvmecontrol/devlist.c
+++ b/sbin/nvmecontrol/devlist.c
@@ -27,11 +27,13 @@
*/
#include <sys/param.h>
+#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
+#include <libnvmf.h>
#include <libutil.h>
#include <paths.h>
#include <stddef.h>
@@ -39,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
+#include <time.h>
#include <unistd.h>
#include "nvmecontrol.h"
@@ -112,6 +115,30 @@
}
}
+static bool
+fabrics_status(int fd)
+{
+ static struct timespec now;
+ static bool now_initted;
+ struct nvmf_connection_status cs;
+ struct timespec delta;
+
+ if (nvmf_connection_status(fd, &cs) != 0)
+ return (true);
+
+ if (cs.is_connected)
+ return (true);
+
+ if (!now_initted) {
+ clock_gettime(CLOCK_REALTIME_FAST, &now);
+ now_initted = true;
+ }
+
+ timespecsub(&now, &cs.last_disconnect, &delta);
+ printf(" (disconnected for %ju seconds)", (uintmax_t)delta.tv_sec);
+ return (false);
+}
+
static bool
scan_controller(int ctrlr)
{
@@ -121,6 +148,7 @@
uint8_t mn[64];
uint32_t nsid;
int fd, ret;
+ bool connected;
snprintf(name, sizeof(name), "%s%d", NVME_CTRLR_PREFIX, ctrlr);
@@ -138,7 +166,13 @@
}
nvme_strvis(mn, cdata.mn, sizeof(mn), NVME_MODEL_NUMBER_LENGTH);
- printf("%6s: %s\n", name, mn);
+ printf("%6s: %s", name, mn);
+ connected = fabrics_status(fd);
+ printf("\n");
+ if (!connected) {
+ close(fd);
+ return (true);
+ }
nsid = 0;
for (;;) {

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 1, 5:34 AM (17 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34544249
Default Alt Text
D48220.id148445.diff (1 KB)

Event Timeline