Skip to content

Commit ceafafd

Browse files
dwsuseigaw
authored andcommitted
fabrics: extend hostnqn/hostid variable inject interface
In order to test none existing hostnqn/hostid files, extend the environment variable interface. When it is set but it's an empty string just return NULL which means no file found. Signed-off-by: Daniel Wagner <[email protected]>
1 parent b88897f commit ceafafd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/nvme/fabrics.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,11 @@ char *nvmf_hostnqn_from_file()
14021402
{
14031403
char *hostnqn = getenv("LIBNVME_HOSTNQN");
14041404

1405-
if (hostnqn)
1405+
if (hostnqn) {
1406+
if (!strcmp(hostnqn, ""))
1407+
return NULL;
14061408
return strdup(hostnqn);
1409+
}
14071410

14081411
return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE);
14091412
}
@@ -1412,8 +1415,11 @@ char *nvmf_hostid_from_file()
14121415
{
14131416
char *hostid = getenv("LIBNVME_HOSTID");
14141417

1415-
if (hostid)
1418+
if (hostid) {
1419+
if (!strcmp(hostid, ""))
1420+
return NULL;
14161421
return strdup(hostid);
1422+
}
14171423

14181424
return nvmf_read_file(NVMF_HOSTID_FILE, NVMF_HOSTID_SIZE);
14191425
}

0 commit comments

Comments
 (0)