Skip to content

Commit 3d9e146

Browse files
authored
Merge pull request #293 from igaw/fix-sysconfdir
fabrics: Allow to change sysconfdir for hostnqn and hostid file
2 parents 7b86551 + f356ab0 commit 3d9e146

4 files changed

Lines changed: 37 additions & 24 deletions

File tree

doc/meson.build

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,28 @@ if want_docs != 'false'
3535
list_man_pages = find_program('list-man-pages.sh')
3636
if want_docs_build
3737
foreach apif : api_files
38-
afile = files('../src/nvme/' + apif)
39-
c = run_command(list_man_pages, afile)
40-
man_pages = c.stdout().split()
41-
foreach page : man_pages
42-
custom_target(
43-
page.underscorify() + '_man',
44-
input: afile,
45-
output: page + '.2',
46-
capture: true,
47-
command: [kernel_doc,
48-
'-module', 'libnvme',
49-
'-man',
50-
'-function',
51-
page,
52-
afile],
53-
install: true,
54-
install_dir: mandir)
38+
foreach file : files('../src/nvme/' + apif)
39+
subst = configure_file(
40+
input: file,
41+
output: '@[email protected]',
42+
configuration: conf)
43+
c = run_command(list_man_pages, subst)
44+
man_pages = c.stdout().split()
45+
foreach page : man_pages
46+
custom_target(
47+
page.underscorify() + '_man',
48+
input: subst,
49+
output: page + '.2',
50+
capture: true,
51+
command: [kernel_doc,
52+
'-module', 'libnvme',
53+
'-man',
54+
'-function',
55+
page,
56+
subst],
57+
install: true,
58+
install_dir: mandir)
59+
endforeach
5560
endforeach
5661
endforeach
5762
else
@@ -69,9 +74,13 @@ if want_docs != 'false'
6974
rsts = []
7075
foreach apif : api_files
7176
afile = files('../src/nvme/' + apif)
77+
subst = configure_file(
78+
input: afile,
79+
output: '@[email protected]',
80+
configuration: conf)
7281
rst = custom_target(
7382
apif.underscorify() + '_rst',
74-
input: afile,
83+
input: subst,
7584
output: '@BASENAME@._rst',
7685
capture: true,
7786
command: [kernel_doc,

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ includedir = join_paths(prefixdir, get_option('includedir'))
2929
datadir = join_paths(prefixdir, get_option('datadir'))
3030
mandir = join_paths(prefixdir, get_option('mandir'))
3131
bindir = join_paths(prefixdir, get_option('bindir'))
32+
sysconfdir = join_paths(prefixdir, get_option('sysconfdir'))
3233

3334
pkgconfiglibdir = get_option('pkgconfiglibdir') == '' ? join_paths(libdir, 'pkgconfig') : get_option('pkgconfiglibdir')
3435

3536
################################################################################
3637
conf = configuration_data()
3738

39+
conf.set('SYSCONFDIR', sysconfdir)
40+
3841
# Check for libuuid availability
3942
libuuid_dep = dependency('uuid', required: true)
4043
conf.set('CONFIG_LIBUUID', libuuid_dep.found(), description: 'Is libuuid required?')

src/nvme/fabrics.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@
4141
#define NVMF_HOSTID_SIZE 37
4242
#define UUID_SIZE 37 /* 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + \0 */
4343

44+
#define NVMF_HOSTNQN_FILE "SYSCONFDIR/nvme/hostnqn"
45+
#define NVMF_HOSTID_FILE "SYSCONFDIR/nvme/hostid"
46+
4447
const char *nvmf_dev = "/dev/nvme-fabrics";
45-
const char *nvmf_hostnqn_file = "/etc/nvme/hostnqn";
46-
const char *nvmf_hostid_file = "/etc/nvme/hostid";
4748

4849
const char *arg_str(const char * const *strings,
4950
size_t array_size, size_t idx)
@@ -967,12 +968,12 @@ static char *nvmf_read_file(const char *f, int len)
967968

968969
char *nvmf_hostnqn_from_file()
969970
{
970-
return nvmf_read_file(nvmf_hostnqn_file, NVMF_NQN_SIZE);
971+
return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE);
971972
}
972973

973974
char *nvmf_hostid_from_file()
974975
{
975-
return nvmf_read_file(nvmf_hostid_file, NVMF_HOSTID_SIZE);
976+
return nvmf_read_file(NVMF_HOSTID_FILE, NVMF_HOSTID_SIZE);
976977
}
977978

978979
/**

src/nvme/fabrics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ char *nvmf_hostnqn_generate();
203203

204204
/**
205205
* nvmf_hostnqn_from_file() - Reads the host nvm qualified name from the config
206-
* default location in /etc/nvme/
206+
* default location in @SYSCONFDIR@/nvme/
207207
* Return: The host nqn, or NULL if unsuccessful. If found, the caller
208208
* is responsible to free the string.
209209
*/
210210
char *nvmf_hostnqn_from_file();
211211

212212
/**
213213
* nvmf_hostid_from_file() - Reads the host identifier from the config default
214-
* location in /etc/nvme/.
214+
* location in @SYSCONFDIR@/nvme/.
215215
* Return: The host identifier, or NULL if unsuccessful. If found, the caller
216216
* is responsible to free the string.
217217
*/

0 commit comments

Comments
 (0)