@@ -171,9 +171,10 @@ fi
AC_SUBST([systemd_unitdir])
AM_CONDITIONAL([ENABLE_SYSTEMD_UNITS], [test "x$with_systemd" = "xyes"])
-ndctl_monitorconfdir=${sysconfdir}/ndctl
+ndctl_confdir=${sysconfdir}/ndctl.conf.d
+ndctl_conf=ndctl.conf
ndctl_monitorconf=monitor.conf
-AC_SUBST([ndctl_monitorconfdir])
+AC_SUBST([ndctl_confdir])
AC_SUBST([ndctl_monitorconf])
daxctl_modprobe_datadir=${datadir}/daxctl
@@ -129,6 +129,7 @@ struct ndctl_ctx {
int regions_init;
void *userdata;
struct list_head busses;
+ const char *config_path;
int busses_init;
struct udev *udev;
struct udev_queue *udev_queue;
@@ -265,6 +265,22 @@ NDCTL_EXPORT void ndctl_set_userdata(struct ndctl_ctx *ctx, void *userdata)
ctx->userdata = userdata;
}
+NDCTL_EXPORT int ndctl_set_config_path(struct ndctl_ctx *ctx, char *config_path)
+{
+ if ((!ctx) || (!config_path))
+ return -EINVAL;
+ ctx->config_path = config_path;
+
+ return 0;
+}
+
+NDCTL_EXPORT const char *ndctl_get_config_path(struct ndctl_ctx *ctx)
+{
+ if (ctx == NULL)
+ return NULL;
+ return ctx->config_path;
+}
+
/**
* ndctl_new - instantiate a new library context
* @ctx: context to establish
@@ -327,6 +343,10 @@ NDCTL_EXPORT int ndctl_new(struct ndctl_ctx **ctx)
if (!c->udev_queue)
err(c, "failed to retrieve udev queue\n");
+ rc = ndctl_set_config_path(c, NDCTL_CONF_DIR);
+ if (rc)
+ dbg(c, "Unable to set config path: %s\n", strerror(-rc));
+
c->kmod_ctx = kmod_ctx;
c->daxctl_ctx = daxctl_ctx;
@@ -92,6 +92,8 @@ int ndctl_get_log_priority(struct ndctl_ctx *ctx);
void ndctl_set_log_priority(struct ndctl_ctx *ctx, int priority);
void ndctl_set_userdata(struct ndctl_ctx *ctx, void *userdata);
void *ndctl_get_userdata(struct ndctl_ctx *ctx);
+int ndctl_set_config_path(struct ndctl_ctx *ctx, char *config_path);
+const char *ndctl_get_config_path(struct ndctl_ctx *ctx);
enum ndctl_persistence_domain {
PERSISTENCE_NONE = 0,
@@ -7,7 +7,7 @@ BUILT_SOURCES = config.h
config.h: $(srcdir)/Makefile.am
$(AM_V_GEN) echo "/* Autogenerated by ndctl/Makefile.am */" >$@ && \
echo '#define NDCTL_CONF_FILE \
- "$(ndctl_monitorconfdir)/$(ndctl_monitorconf)"' >>$@
+ "$(ndctl_confdir)/$(ndctl_monitorconf)"' >>$@
$(AM_V_GEN) echo '#define NDCTL_KEYS_DIR "$(ndctl_keysdir)"' >>$@
ndctl_SOURCES = ndctl.c \
@@ -74,7 +74,7 @@ ndctl_SOURCES += ../test/libndctl.c \
test.c
endif
-monitor_configdir = $(ndctl_monitorconfdir)
+monitor_configdir = $(ndctl_confdir)
monitor_config_DATA = $(ndctl_monitorconf)
if ENABLE_SYSTEMD_UNITS
@@ -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 ndctl/Makefile.am */" >$@ && \
+ echo '#define NDCTL_CONF_DIR "$(ndctl_confdir)"' >>$@
+
pkginclude_HEADERS = ../libndctl.h ../ndctl.h
lib_LTLIBRARIES = libndctl.la
@@ -454,4 +454,6 @@ LIBNDCTL_25 {
LIBNDCTL_26 {
ndctl_bus_nfit_translate_spa;
+ ndctl_set_config_path;
+ ndctl_get_config_path;
} LIBNDCTL_25;