summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-11-08 00:31:09 -0500
committerLennart Poettering <lennart@poettering.net>2010-11-10 22:38:44 +0100
commite9ddabc246ced239cbce436e16792dc4c3d1b52d (patch)
treeb14a4b8a026547baa4876da64021a0211315be99 /src/main.c
parent70ca520f43d8cd3f9c6895d20ec87498b626bd75 (diff)
manager: parse RD_TIMESTAMP passed from initrd
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index f7d76a2941..cd73ee2cff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -871,12 +871,31 @@ fail:
return r;
}
+static struct dual_timestamp* parse_initrd_timestamp(struct dual_timestamp *t) {
+ const char *e;
+ unsigned long long a, b;
+
+ assert(t);
+
+ if (!(e = getenv("RD_TIMESTAMP")))
+ return NULL;
+
+ if (sscanf(e, "%llu %llu", &a, &b) != 2)
+ return NULL;
+
+ t->realtime = (usec_t) a;
+ t->monotonic = (usec_t) b;
+
+ return t;
+}
+
int main(int argc, char *argv[]) {
Manager *m = NULL;
int r, retval = EXIT_FAILURE;
FDSet *fds = NULL;
bool reexecute = false;
const char *shutdown_verb = NULL;
+ dual_timestamp initrd_timestamp = { 0ULL, 0ULL };
if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
/* This is compatbility support for SysV, where
@@ -965,9 +984,13 @@ int main(int argc, char *argv[]) {
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
arg_running_as == MANAGER_SYSTEM);
- /* Unset some environment variables passed in from the kernel
- * that don't really make sense for us. */
if (arg_running_as == MANAGER_SYSTEM) {
+ /* Parse the data passed to us by the initrd and unset it */
+ parse_initrd_timestamp(&initrd_timestamp);
+ filter_environ("RD_");
+
+ /* Unset some environment variables passed in from the
+ * kernel that don't really make sense for us. */
unsetenv("HOME");
unsetenv("TERM");
}
@@ -1030,6 +1053,9 @@ int main(int argc, char *argv[]) {
m->mount_auto = arg_mount_auto;
m->swap_auto = arg_swap_auto;
+ if (dual_timestamp_is_set(&initrd_timestamp))
+ m->initrd_timestamp = initrd_timestamp;
+
if (arg_console)
manager_set_console(m, arg_console);