aboutsummaryrefslogtreecommitdiff
path: root/src/librc
diff options
context:
space:
mode:
Diffstat (limited to 'src/librc')
-rw-r--r--src/librc/librc-depend.c1
-rw-r--r--src/librc/librc.c29
-rw-r--r--src/librc/rc.h.in10
3 files changed, 40 insertions, 0 deletions
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index a03e1a61..9f592cfe 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -700,6 +700,7 @@ static const char *const depdirs[] =
"options",
"exclusive",
"scheduled",
+ "dynamic",
"tmp",
NULL
};
diff --git a/src/librc/librc.c b/src/librc/librc.c
index d218c8be..ee728b30 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -1317,6 +1317,35 @@ rc_service_delete(const char *runlevel, const char *service)
return (r == 0);
}
+char *
+rc_service_base(const char *service)
+{
+ char *dot = strchr(service, '.');
+ if (!dot)
+ return NULL;
+ return xstrndup(service, dot - service);
+}
+
+char *
+rc_service_dylink(const char *service, const char *target)
+{
+ char *file = rc_service_resolve(service);
+ char *target_file = NULL;
+ if (!exists(file))
+ goto out;
+
+ xasprintf(&target_file, "%s/dynamic/%s", rc_service_dir(), target);
+ if (!exists(target_file) && symlink(file, target_file) == -1) {
+ free(target_file);
+ target_file = NULL;
+ goto out;
+ }
+
+out:
+ free(file);
+ return target_file;
+}
+
RC_STRINGLIST *
rc_services_scheduled_by(const char *service)
{
diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 59fdfda3..794b4353 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -275,6 +275,16 @@ RC_STRINGLIST *rc_service_extra_commands(const char *);
* @return pointer to full path of service */
char *rc_service_resolve(const char *);
+/*! Gets the base service for a multiplexed service
+ * @param multiplexed service to check
+ * @return pointer to base service name or NULL if not multiplexed */
+char *rc_service_base(const char *);
+
+/*! Dynamically multiplexes a service into the runtime directory.
+ * @param service to link
+ * @param target service name */
+char *rc_service_dylink(const char *, const char *);
+
/*! Schedule a service to be started when another service starts
* @param service that starts the scheduled service when started
* @param service_to_start service that will be started */