@@ -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
+AC_SUBST([daxctl_confdir])
+
daxctl_modprobe_datadir=${datadir}/daxctl
daxctl_modprobe_data=daxctl.conf
AC_SUBST([daxctl_modprobe_datadir])
@@ -17,6 +17,8 @@
#include <util/log.h>
#include <util/sysfs.h>
#include <util/iomem.h>
+#include <util/strbuf.h>
+#include <util/parse-configs.h>
#include <daxctl/libdaxctl.h>
#include "libdaxctl-private.h"
@@ -37,6 +39,7 @@ struct daxctl_ctx {
struct log_ctx ctx;
int refcount;
void *userdata;
+ const char *configs;
int regions_init;
struct list_head regions;
struct kmod_ctx *kmod_ctx;
@@ -68,6 +71,42 @@ DAXCTL_EXPORT void daxctl_set_userdata(struct daxctl_ctx *ctx, void *userdata)
ctx->userdata = userdata;
}
+DAXCTL_EXPORT void daxctl_set_configs_dir(struct daxctl_ctx **ctx, char *conf_dir)
+{
+ struct dirent **namelist;
+ struct strbuf value = STRBUF_INIT;
+ int rc;
+
+ if ((!ctx) || (!conf_dir))
+ return;
+
+ rc = scandir(conf_dir, &namelist, filter_conf_files, alphasort);
+ if (rc == -1) {
+ if (errno != ENOENT)
+ err(*ctx, "scandir for configs failed: %s\n",
+ strerror(errno));
+ return;
+ }
+
+ while (rc--) {
+ if (value.len)
+ strbuf_addstr(&value, " ");
+ strbuf_addstr(&value, conf_dir);
+ strbuf_addstr(&value, "/");
+ strbuf_addstr(&value, namelist[rc]->d_name);
+ free(namelist[rc]);
+ }
+ (*ctx)->configs = strbuf_detach(&value, NULL);
+ free(namelist);
+}
+
+DAXCTL_EXPORT const char *daxctl_get_configs_dir(struct daxctl_ctx *ctx)
+{
+ if (ctx == NULL)
+ return NULL;
+ return ctx->configs;
+}
+
/**
* daxctl_new - instantiate a new library context
* @ctx: context to establish
@@ -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);
+void daxctl_set_configs_dir(struct daxctl_ctx **ctx, char *conf_dir);
+const char *daxctl_get_configs_dir(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
@@ -10,6 +10,7 @@ config.h: $(srcdir)/Makefile.am
"$(daxctl_modprobe_datadir)/$(daxctl_modprobe_data)"' >>$@ && \
echo '#define DAXCTL_MODPROBE_INSTALL \
"$(sysconfdir)/modprobe.d/$(daxctl_modprobe_data)"' >>$@
+ $(AM_V_GEN) echo '#define DAXCTL_CONF_DIR "$(daxctl_confdir)"' >>$@
daxctl_SOURCES =\
daxctl.c \
@@ -13,6 +13,10 @@ libdaxctl_la_SOURCES =\
../../util/iomem.h \
../../util/sysfs.c \
../../util/sysfs.h \
+ ../../util/strbuf.h \
+ ../../util/strbuf.c \
+ ../../util/wrapper.c \
+ ../../util/usage.c \
../../util/log.c \
../../util/log.h \
../../util/parse-configs.h \
@@ -96,4 +96,6 @@ LIBDAXCTL_9 {
global:
daxctl_dev_will_auto_online_memory;
daxctl_dev_has_online_memory;
+ daxctl_set_configs_dir;
+ daxctl_get_configs_dir;
} LIBDAXCTL_8;