@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
+include::attrs.adoc[]
+
daxctl-reconfigure-device(1)
============================
@@ -250,6 +252,12 @@ ndctl create-namespace --mode=devdax | \
jq -r "\"[reconfigure-device $(uuidgen)]\", \"nvdimm.uuid = \(.uuid)\", \"mode = system-ram\"" >> $config_path
----
+The default location for daxctl config files is under {daxctl_confdir}/,
+and any file with a '.conf' suffix at this location is considered. It is
+acceptable to have multiple files containing ini-style config sections,
+but the {section, subsection} tuple must be unique across all config files
+under {daxctl_confdir}/.
+
include::../copyright.txt[]
SEE ALSO
@@ -178,6 +178,9 @@ AC_SUBST([ndctl_confdir])
AC_SUBST([ndctl_conf])
AC_SUBST([ndctl_monitorconf])
+daxctl_confdir=${sysconfdir}/daxctl.conf.d
+AC_SUBST([daxctl_confdir])
+
daxctl_modprobe_datadir=${datadir}/daxctl
daxctl_modprobe_data=daxctl.conf
AC_SUBST([daxctl_modprobe_datadir])
@@ -37,6 +37,7 @@ struct daxctl_ctx {
struct log_ctx ctx;
int refcount;
void *userdata;
+ const char *config_path;
int regions_init;
struct list_head regions;
struct kmod_ctx *kmod_ctx;
@@ -68,6 +69,22 @@ DAXCTL_EXPORT void daxctl_set_userdata(struct daxctl_ctx *ctx, void *userdata)
ctx->userdata = userdata;
}
+DAXCTL_EXPORT int daxctl_set_config_path(struct daxctl_ctx *ctx,
+ char *config_path)
+{
+ if ((!ctx) || (!config_path))
+ return -EINVAL;
+ ctx->config_path = config_path;
+ return 0;
+}
+
+DAXCTL_EXPORT const char *daxctl_get_config_path(struct daxctl_ctx *ctx)
+{
+ if (ctx == NULL)
+ return NULL;
+ return ctx->config_path;
+}
+
/**
* daxctl_new - instantiate a new library context
* @ctx: context to establish
@@ -99,6 +116,9 @@ DAXCTL_EXPORT int daxctl_new(struct daxctl_ctx **ctx)
*ctx = c;
list_head_init(&c->regions);
c->kmod_ctx = kmod_ctx;
+ rc = daxctl_set_config_path(c, DAXCTL_CONF_DIR);
+ if (rc)
+ dbg(c, "Unable to set config path: %s\n", strerror(-rc));
return 0;
out:
@@ -28,6 +28,8 @@ int daxctl_get_log_priority(struct daxctl_ctx *ctx);
void daxctl_set_log_priority(struct daxctl_ctx *ctx, int priority);
void daxctl_set_userdata(struct daxctl_ctx *ctx, void *userdata);
void *daxctl_get_userdata(struct daxctl_ctx *ctx);
+int daxctl_set_config_path(struct daxctl_ctx *ctx, char *config_path);
+const char *daxctl_get_config_path(struct daxctl_ctx *ctx);
struct daxctl_region;
struct daxctl_region *daxctl_new_region(struct daxctl_ctx *ctx, int id,
@@ -33,11 +33,20 @@ EXTRA_DIST = $(man1_MANS)
CLEANFILES = $(man1_MANS)
+.ONESHELL:
+attrs.adoc: $(srcdir)/Makefile.am
+ $(AM_V_GEN) cat <<- EOF >$@
+ :daxctl_confdir: $(daxctl_confdir)
+ :daxctl_conf: $(daxctl_conf)
+ :ndctl_keysdir: $(ndctl_keysdir)
+ EOF
+
XML_DEPS = \
../../version.m4 \
../copyright.txt \
Makefile \
- $(CONFFILE)
+ $(CONFFILE) \
+ attrs.adoc
RM ?= rm -f
@@ -25,4 +25,5 @@ daxctl_LDADD =\
../libutil.a \
$(UUID_LIBS) \
$(KMOD_LIBS) \
- $(JSON_LIBS)
+ $(JSON_LIBS) \
+ -liniparser
@@ -3,6 +3,12 @@ include $(top_srcdir)/Makefile.am.in
%.pc: %.pc.in Makefile
$(SED_PROCESS)
+DISTCLEANFILES = config.h
+BUILT_SOURCES = config.h
+config.h: $(srcdir)/Makefile.am
+ $(AM_V_GEN) echo "/* Autogenerated by daxctl/Makefile.am */" >$@ && \
+ echo '#define DAXCTL_CONF_DIR "$(daxctl_confdir)"' >>$@
+
pkginclude_HEADERS = ../libdaxctl.h
lib_LTLIBRARIES = libdaxctl.la
@@ -96,4 +96,6 @@ LIBDAXCTL_9 {
global:
daxctl_dev_will_auto_online_memory;
daxctl_dev_has_online_memory;
+ daxctl_set_config_path;
+ daxctl_get_config_path;
} LIBDAXCTL_8;