public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Christian Ruppert" <idl0r@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: src/librc/
Date: Sun, 15 Jan 2012 00:05:09 +0000 (UTC)	[thread overview]
Message-ID: <14625346c07a2a66fe77ce578c9423918bec1d97.idl0r@gentoo> (raw)

commit:     14625346c07a2a66fe77ce578c9423918bec1d97
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 23:38:47 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 00:02:11 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=14625346

Allow overriding of rc.conf options via kernel cmdline

This adds a new function that allows us to override some specific rc.conf
options via the kernel cmdline aka /proc/cmdline.
This makes esp. sense in cases where a rc_parallel enabled system has boot
issues. Simply disable rc_parallel by appending rc_parallel=no to your kernel
cmdline.

---
 src/librc/librc-misc.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index cebc9e8..a5daa07 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -214,6 +214,60 @@ rc_config_list(const char *file)
 }
 librc_hidden_def(rc_config_list)
 
+/*
+ * Override some specific rc.conf options via kernel cmdline
+ */
+#ifdef __linux__
+static RC_STRINGLIST *rc_config_override(RC_STRINGLIST *config) {
+	RC_STRINGLIST *overrides;
+	RC_STRING *cline, *override, *config_np;
+	char *tmp = NULL;
+	char *value = NULL;
+	size_t varlen = 0;
+	size_t len = 0;
+
+	overrides = rc_stringlist_new();
+
+	/* A list of variables which may be overriden through cmdline */
+	rc_stringlist_add(overrides, "rc_parallel");
+
+	TAILQ_FOREACH(override, overrides, entries) {
+		varlen = strlen(override->value);
+		value = rc_proc_getent(override->value);
+
+		/* No need to continue if there's nothing to override */
+		if (!value) {
+			free(value);
+			continue;
+		}
+
+		if (value != NULL) {
+			len = (varlen + strlen(value) + 2);
+			tmp = xmalloc(sizeof(char) * len);
+			snprintf(tmp, len, "%s=%s", override->value, value);
+		}
+
+		/* Whenever necessary remove the old config entry first to prevent duplicates */
+		TAILQ_FOREACH_SAFE(cline, config, entries, config_np) {
+			if (strncmp(override->value, cline->value, varlen) == 0 && cline->value[varlen] == '=') {
+				rc_stringlist_delete(config, cline->value);
+				break;
+			}
+		}
+
+		/* Add the option (var/value) to the current config */
+		rc_stringlist_add(config, tmp);
+
+		free(tmp);
+		free(value);
+	}
+
+	rc_stringlist_free(overrides);
+
+	return config;
+}
+#endif
+
 RC_STRINGLIST *
 rc_config_load(const char *file)
 {
@@ -287,6 +341,10 @@ rc_config_load(const char *file)
 	}
 	rc_stringlist_free(list);
 
+#ifdef __linux__
+	config = rc_config_override(config);
+#endif
+
 	return config;
 }
 librc_hidden_def(rc_config_load)



             reply	other threads:[~2012-01-15  0:05 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15  0:05 Christian Ruppert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-08-06 22:52 [gentoo-commits] proj/openrc:master commit in: src/librc/ William Hubbs
2018-06-28 18:03 William Hubbs
2018-06-22 20:57 William Hubbs
2018-06-20 22:45 William Hubbs
2018-05-22 22:12 William Hubbs
2018-05-22 22:12 William Hubbs
2017-11-30 19:58 William Hubbs
2017-11-14 19:22 William Hubbs
2017-10-26 18:58 William Hubbs
2017-10-24 15:43 William Hubbs
2016-12-20  0:29 William Hubbs
2016-08-15 18:48 William Hubbs
2016-01-19  6:12 William Hubbs
2016-01-19  6:12 William Hubbs
2016-01-19  6:12 William Hubbs
2016-01-19  6:12 William Hubbs
2015-12-08 18:53 William Hubbs
2015-11-05 18:53 William Hubbs
2015-11-05 18:53 William Hubbs
2015-05-04 15:10 William Hubbs
2015-01-12 16:44 William Hubbs
2014-11-01 22:05 William Hubbs
2014-10-24 15:45 William Hubbs
2014-10-23 19:13 William Hubbs
2014-10-23 17:57 William Hubbs
2014-10-20 20:59 William Hubbs
2014-07-19 18:06 William Hubbs
2014-06-20 21:22 William Hubbs
2013-10-21 19:53 William Hubbs
2013-10-04 19:07 William Hubbs
2013-10-04 19:07 William Hubbs
2013-04-14  3:45 William Hubbs
2012-10-05  3:28 William Hubbs
2012-02-25 21:02 William Hubbs
2012-02-25 16:57 Christian Ruppert
2012-01-30 19:33 William Hubbs
2012-01-24 18:41 Christian Ruppert
2012-01-21  3:41 William Hubbs
2012-01-16 18:16 William Hubbs
2011-11-07 15:58 William Hubbs
2011-07-13 19:39 Christian Ruppert
2011-07-09 21:15 Christian Ruppert
2011-06-28 16:47 Christian Ruppert
2011-05-28 16:02 Mike Frysinger
2011-04-28  0:18 William Hubbs
2011-04-28  0:18 William Hubbs
2011-04-09 19:56 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14625346c07a2a66fe77ce578c9423918bec1d97.idl0r@gentoo \
    --to=idl0r@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox