From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH v2 nvme-cli 4/4] fabrics: Take the hostnqn parameter from a conf file if not given
Date: Mon, 8 Aug 2016 14:58:00 +0300 [thread overview]
Message-ID: <1470657480-5868-5-git-send-email-sagi@grimberg.me> (raw)
In-Reply-To: <1470657480-5868-1-git-send-email-sagi@grimberg.me>
In order to allow persistent hostnqns, take the hostnqn parameter
for /etc/nvme/hostnqn if exists.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
fabrics.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/fabrics.c b/fabrics.c
index 54ed8e17b527..90308f07d0fb 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -57,6 +57,7 @@ struct config {
#define BUF_SIZE 4096
#define PATH_NVME_FABRICS "/dev/nvme-fabrics"
#define PATH_NVMF_DISC "/etc/nvme/nvmf_disc"
+#define PATH_NVMF_HOSTNQN "/etc/nvme/hostnqn"
#define MAX_DISC_ARGS 10
enum {
@@ -405,6 +406,25 @@ static void save_discovery_log(struct nvmf_disc_rsp_page_hdr *log, int numrec)
close(fd);
}
+static int nvmf_hostnqn_file(void)
+{
+ FILE *f;
+ char hostnqn[255];
+
+ f = fopen(PATH_NVMF_HOSTNQN, "r");
+ if (f == NULL)
+ return false;
+
+ if (fgets(hostnqn, sizeof(hostnqn), f) == NULL)
+ return false;
+
+ cfg.hostnqn = strdup(hostnqn);
+ if (!cfg.hostnqn)
+ return false;
+
+ return true;
+}
+
static int build_options(char *argstr, int max_len)
{
int len;
@@ -449,7 +469,7 @@ static int build_options(char *argstr, int max_len)
max_len -= len;
}
- if (cfg.hostnqn) {
+ if (cfg.hostnqn || nvmf_hostnqn_file()) {
len = snprintf(argstr, max_len, ",hostnqn=%s", cfg.hostnqn);
if (len < 0)
return -EINVAL;
--
1.9.1
next prev parent reply other threads:[~2016-08-08 11:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 11:57 [PATCH v2 nvme-cli 0/4] Useful fabrics patches Sagi Grimberg
2016-08-08 11:57 ` [PATCH v2 nvme-cli 1/4] fabrics: Allow ipv6 address resolution Sagi Grimberg
2016-08-08 21:17 ` J Freyensee
2016-08-08 11:57 ` [PATCH v2 nvme-cli 2/4] fabrics: stringify discover output Sagi Grimberg
2016-08-08 13:31 ` Christoph Hellwig
2016-08-08 11:57 ` [PATCH v2 nvme-cli 3/4] fabrics: Allow discover params to come from a conf file Sagi Grimberg
2016-08-08 13:35 ` Christoph Hellwig
2016-08-08 21:29 ` J Freyensee
2016-08-09 6:52 ` Sagi Grimberg
2016-08-08 21:51 ` J Freyensee
2016-08-09 6:58 ` Sagi Grimberg
2016-08-08 11:58 ` Sagi Grimberg [this message]
2016-08-08 13:36 ` [PATCH v2 nvme-cli 4/4] fabrics: Take the hostnqn parameter from a conf file if not given Christoph Hellwig
2016-08-08 21:37 ` J Freyensee
2016-08-08 15:36 ` [PATCH v2 nvme-cli 0/4] Useful fabrics patches Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470657480-5868-5-git-send-email-sagi@grimberg.me \
--to=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).