chiark / gitweb /
Replace /var/run with /run in remaining places
[elogind.git] / src / systemctl / systemctl.c
index e529095f937fab86178d1bca09f3a9b02ca88b47..869271628f8a344b902518e389a2beb7e5cb5fba 100644 (file)
@@ -908,6 +908,31 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
         return 0;
 }
 
+static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
+        usec_t next_elapse;
+
+        assert(nw);
+        assert(next);
+
+        if (next->monotonic != (usec_t) -1 && next->monotonic > 0) {
+                usec_t converted;
+
+                if (next->monotonic > nw->monotonic)
+                        converted = nw->realtime + (next->monotonic - nw->monotonic);
+                else
+                        converted = nw->realtime - (nw->monotonic - next->monotonic);
+
+                if (next->realtime != (usec_t) -1 && next->realtime > 0)
+                        next_elapse = MIN(converted, next->realtime);
+                else
+                        next_elapse = converted;
+
+        } else
+                next_elapse = next->realtime;
+
+        return next_elapse;
+}
+
 static int list_timers(sd_bus *bus, char **args) {
 
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
@@ -930,7 +955,7 @@ static int list_timers(sd_bus *bus, char **args) {
 
         for (u = unit_infos; u < unit_infos + n; u++) {
                 _cleanup_strv_free_ char **triggered = NULL;
-                dual_timestamp next;
+                dual_timestamp next = {};
                 usec_t m;
 
                 if (!endswith(u->id, ".timer"))
@@ -944,26 +969,13 @@ static int list_timers(sd_bus *bus, char **args) {
                 if (r < 0)
                         goto cleanup;
 
-                if (next.monotonic != (usec_t) -1 && next.monotonic > 0) {
-                        usec_t converted;
-
-                        if (next.monotonic > nw.monotonic)
-                                converted = nw.realtime + (next.monotonic - nw.monotonic);
-                        else
-                                converted = nw.realtime - (nw.monotonic - next.monotonic);
-
-                        if (next.realtime != (usec_t) -1 && next.realtime > 0)
-                                m = MIN(converted, next.realtime);
-                        else
-                                m = converted;
-                } else
-                        m = next.realtime;
-
                 if (!GREEDY_REALLOC(timer_infos, size, c+1)) {
                         r = log_oom();
                         goto cleanup;
                 }
 
+                m = calc_next_elapse(&nw, &next);
+
                 timer_infos[c++] = (struct timer_info) {
                         .id = u->id,
                         .next_elapse = m,
@@ -3746,8 +3758,8 @@ static int show_one(
             streq(verb, "status")) {
                 /* According to LSB: "program not running" */
                 /* 0: program is running or service is OK
-                 * 1: program is dead and /var/run pid file exists
-                 * 2: program is dead and /var/lock lock file exists
+                 * 1: program is dead and /run PID file exists
+                 * 2: program is dead and /run/lock lock file exists
                  * 3: program is not running
                  * 4: program or service status is unknown
                  */
@@ -4045,7 +4057,7 @@ static int append_assignment(sd_bus_message *m, const char *assignment) {
         } else if (streq(field, "MemoryLimit")) {
                 off_t bytes;
 
-                r = parse_bytes(eq, &bytes);
+                r = parse_size(eq, 1024, &bytes);
                 if (r < 0) {
                         log_error("Failed to parse bytes specification %s", assignment);
                         return -EINVAL;
@@ -4115,7 +4127,7 @@ static int append_assignment(sd_bus_message *m, const char *assignment) {
                                 return -EINVAL;
                         }
 
-                        r = parse_bytes(bandwidth, &bytes);
+                        r = parse_size(bandwidth, 1000, &bytes);
                         if (r < 0) {
                                 log_error("Failed to parse byte value %s.", bandwidth);
                                 return -EINVAL;
@@ -4175,11 +4187,11 @@ static int set_property(sd_bus *bus, char **args) {
 
         r = sd_bus_message_new_method_call(
                         bus,
+                        &m,
                         "org.freedesktop.systemd1",
                         "/org/freedesktop/systemd1",
                         "org.freedesktop.systemd1.Manager",
-                        "SetUnitProperties",
-                        &m);
+                        "SetUnitProperties");
         if (r < 0)
                 return bus_log_create_error(r);
 
@@ -4490,11 +4502,11 @@ static int set_environment(sd_bus *bus, char **args) {
 
         r = sd_bus_message_new_method_call(
                         bus,
+                        &m,
                         "org.freedesktop.systemd1",
                         "/org/freedesktop/systemd1",
                         "org.freedesktop.systemd1.Manager",
-                        method,
-                        &m);
+                        method);
         if (r < 0)
                 return bus_log_create_error(r);
 
@@ -4521,11 +4533,11 @@ static int import_environment(sd_bus *bus, char **args) {
 
         r = sd_bus_message_new_method_call(
                         bus,
+                        &m,
                         "org.freedesktop.systemd1",
                         "/org/freedesktop/systemd1",
                         "org.freedesktop.systemd1.Manager",
-                        "SetEnvironment",
-                        &m);
+                        "SetEnvironment");
         if (r < 0)
                 return bus_log_create_error(r);
 
@@ -4849,11 +4861,11 @@ static int enable_unit(sd_bus *bus, char **args) {
 
                 r = sd_bus_message_new_method_call(
                                 bus,
+                                &m,
                                 "org.freedesktop.systemd1",
                                 "/org/freedesktop/systemd1",
                                 "org.freedesktop.systemd1.Manager",
-                                method,
-                                &m);
+                                method);
                 if (r < 0)
                         return bus_log_create_error(r);