]> err.no Git - systemd/commitdiff
uniformly suffix time span properties with their unit
authorLennart Poettering <lennart@poettering.net>
Sun, 4 Jul 2010 19:12:10 +0000 (21:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 4 Jul 2010 19:12:10 +0000 (21:12 +0200)
fixme
man/systemd.exec.xml
man/systemd.timer.xml
src/dbus-execute.c
src/dbus-execute.h
src/dbus-timer.c
src/execute.c
src/execute.h
src/load-fragment.c
src/timer.c

diff --git a/fixme b/fixme
index 55e47d71cee355db1f16e5816e70237b1a09f300..8143f013b107b13c510d02b53a2963ec44ae47e5 100644 (file)
--- a/fixme
+++ b/fixme
 
 * get rid of Subscribe() in systemctl
 
-* Unify NS, USec, NSec, Sec suffixes in properties, use format_timespan
+* use format_timespan where applicable
 
 * Turn around negative options
 
+* Add missing man pages: update systemd.1, finish daemon.7
+
 External:
 
 * patch /etc/init.d/functions with:
index 6e9051db7446184bc7cc03a9493992456b70883f..83eef32f55531f19a07d8378cc505147f5b9a789 100644 (file)
                         </varlistentry>
 
                         <varlistentry>
-                                <term><varname>TimerSlackNS=</varname></term>
+                                <term><varname>TimerSlackNSec=</varname></term>
                                 <listitem><para>Sets the timer slack
                                 in nanoseconds for the executed
-                                processes The timer slack controls the accuracy
-                                of wake-ups triggered by timers. See
+                                processes The timer slack controls the
+                                accuracy of wake-ups triggered by
+                                timers. See
                                 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
-                                for more information.</para></listitem>
+                                for more information. Note that in
+                                contrast to most other time span
+                                definitions this value is takes a
+                                nano-seconds integer and does not
+                                understand any other
+                                units.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
index ef89693f14632c30b7d505c0adc5bbb5bf94f642..557a45e0fe186f99bfc149e55cc0c1fc50f790f7 100644 (file)
 
                 <variablelist>
                         <varlistentry>
-                                <term><varname>OnActive=</varname></term>
-                                <term><varname>OnBootup=</varname></term>
-                                <term><varname>OnStartup=</varname></term>
-                                <term><varname>OnUnitActive=</varname></term>
-                                <term><varname>OnUnitInactive=</varname></term>
+                                <term><varname>OnActiveSec=</varname></term>
+                                <term><varname>OnBootSec=</varname></term>
+                                <term><varname>OnStartupSec=</varname></term>
+                                <term><varname>OnUnitActiveSec=</varname></term>
+                                <term><varname>OnUnitInactiveSec=</varname></term>
 
                                 <listitem><para>Defines timers
                                 relative to different starting points:
-                                <varname>OnActive=</varname> defines a
+                                <varname>OnActiveSec=</varname> defines a
                                 timer relative to the moment the timer
                                 itself is
-                                activated. <varname>OnBootup=</varname>
+                                activated. <varname>OnBootSec=</varname>
                                 defines a timer relative to when the
                                 machine was booted
-                                up. <varname>OnStartup=</varname>
+                                up. <varname>OnStartupSec=</varname>
                                 defines a timer relative to when
                                 systemd was
-                                started. <varname>OnUnitActive=</varname>
+                                started. <varname>OnUnitActiveSec=</varname>
                                 defines a timer relative to when the
                                 unit the timer is activating was last
-                                activated. <varname>OnUnitInactive=</varname>
+                                activated. <varname>OnUnitInactiveSec=</varname>
                                 defines a timer relative to when the
                                 unit the timer is activating was last
                                 deactivated.</para>
                                 <para>Multiple directives may be
                                 combined of the same and of different
                                 types. For example, by combining
-                                <varname>OnBoot=</varname> and
-                                <varname>OnUnitActive=</varname> it is
+                                <varname>OnBootSec=</varname> and
+                                <varname>OnUnitActiveSec=</varname> it is
                                 possible to define a timer that
                                 elapses in regular intervals and
                                 activates a specific service each
 
                                 <para>The arguments to the directives
                                 are time spans configured in
-                                seconds. Example: "OnBoot=50" means
+                                seconds. Example: "OnBootSec=50" means
                                 50s after boot-up. The argument may
                                 also include time units. Example:
-                                "OnBoot=5h 30min" means 5 hours and 30
+                                "OnBootSec=5h 30min" means 5 hours and 30
                                 minutes after boot-up. For details
                                 about the syntax of time spans see
                                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
 
                                 <para>If a timer configured with
-                                <varname>OnBootup=</varname> or
-                                <varname>OnStartup=</varname> is
+                                <varname>OnBootSec=</varname> or
+                                <varname>OnStartupSec=</varname> is
                                 already in the past when the timer
                                 unit is activated, it will immediately
                                 elapse and the configured unit is
index 529f72dfa09afc936831924bf81efa6743bbb825..d37bd5560ed31361b5c5ff31f9e606ead0da73f7 100644 (file)
@@ -171,7 +171,7 @@ int bus_execute_append_affinity(Manager *m, DBusMessageIter *i, const char *prop
         return 0;
 }
 
-int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_execute_append_timer_slack_nsec(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         ExecContext *c = data;
         uint64_t u;
 
@@ -180,8 +180,8 @@ int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char
         assert(property);
         assert(c);
 
-        if (c->timer_slack_ns_set)
-                u = (uint64_t) c->timer_slack_ns_set;
+        if (c->timer_slack_nsec_set)
+                u = (uint64_t) c->timer_slack_nsec;
         else
                 u = (uint64_t) prctl(PR_GET_TIMERSLACK);
 
index 95d400d28bb8f5b65e9ab15066ce033da5372d60..5208159695ef3ec9ea16fcb6408fbdaa79133a4f 100644 (file)
         { interface, "CPUSchedulingPolicy",           bus_execute_append_cpu_sched_policy, "i", &(context)                         }, \
         { interface, "CPUSchedulingPriority",         bus_execute_append_cpu_sched_priority, "i", &(context)                       }, \
         { interface, "CPUAffinity",                   bus_execute_append_affinity,"ay",    &(context)                              }, \
-        { interface, "TimerSlackNS",                  bus_execute_append_timer_slack_ns, "t", &(context)                           }, \
+        { interface, "TimerSlackNSec",                bus_execute_append_timer_slack_nsec, "t", &(context)                           }, \
         { interface, "CPUSchedulingResetOnFork",      bus_property_append_bool,   "b",     &(context).cpu_sched_reset_on_fork      }, \
         { interface, "NonBlocking",                   bus_property_append_bool,   "b",     &(context).non_blocking                 }, \
         { interface, "StandardInput",                 bus_execute_append_input,   "s",     &(context).std_input                    }, \
@@ -158,7 +158,7 @@ int bus_execute_append_ioprio(Manager *m, DBusMessageIter *i, const char *proper
 int bus_execute_append_cpu_sched_policy(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_execute_append_cpu_sched_priority(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_execute_append_affinity(Manager *m, DBusMessageIter *i, const char *property, void *data);
-int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_execute_append_timer_slack_nsec(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_execute_append_capabilities(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_execute_append_rlimits(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_execute_append_command(Manager *m, DBusMessageIter *u, const char *property, void *data);
index d548227b5ae31ef419f6f0b4e47455f9fef019f7..0cd37d9718da58abefe3a99da6016e6c8f56bbe6 100644 (file)
@@ -29,7 +29,7 @@
         " <interface name=\"org.freedesktop.systemd1.Timer\">\n"        \
         "  <property name=\"Unit\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"Timers\" type=\"a(stt)\" access=\"read\"/>\n" \
-        "  <property name=\"NextElapse\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"NextElapseUSec\" type=\"t\" access=\"read\"/>\n" \
         " </interface>\n"
 
 #define INTROSPECTION                                                   \
@@ -57,13 +57,30 @@ static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *p
                 return -ENOMEM;
 
         LIST_FOREACH(value, k, p->values) {
-                const char *t = timer_base_to_string(k->base);
+                char *buf;
+                const char *t;
+                size_t l;
+                bool b;
 
-                if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) ||
-                    !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &t) ||
-                    !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->value) ||
-                    !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->next_elapse) ||
-                    !dbus_message_iter_close_container(&sub, &sub2))
+                t = timer_base_to_string(k->base);
+                assert(endswith(t, "Sec"));
+
+                /* s/Sec/USec/ */
+                l = strlen(t);
+                if (!(buf = new(char, l+2)))
+                        return -ENOMEM;
+
+                memcpy(buf, t, l-3);
+                memcpy(buf+l-3, "USec", 5);
+
+                b = dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) &&
+                        dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &buf) &&
+                        dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->value) &&
+                        dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->next_elapse) &&
+                        dbus_message_iter_close_container(&sub, &sub2);
+
+                free(buf);
+                if (!b)
                         return -ENOMEM;
         }
 
@@ -76,9 +93,9 @@ static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *p
 DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         const BusProperty properties[] = {
                 BUS_UNIT_PROPERTIES,
-                { "org.freedesktop.systemd1.Timer", "Unit",       bus_property_append_string, "s",      u->timer.unit->meta.id },
-                { "org.freedesktop.systemd1.Timer", "Timers",     bus_timer_append_timers,    "a(stt)", u                      },
-                { "org.freedesktop.systemd1.Timer", "NextElapse", bus_property_append_usec,   "t",      &u->timer.next_elapse  },
+                { "org.freedesktop.systemd1.Timer", "Unit",           bus_property_append_string, "s",      u->timer.unit->meta.id },
+                { "org.freedesktop.systemd1.Timer", "Timers",         bus_timer_append_timers,    "a(stt)", u                      },
+                { "org.freedesktop.systemd1.Timer", "NextElapseUSec", bus_property_append_usec,   "t",      &u->timer.next_elapse  },
                 { NULL, NULL, NULL, NULL, NULL }
         };
 
index f3f95ff754e5d15b76d3d42642288bd7e2f56cf1..982b7d1bcd90158ee4e11b27e565724f270c9ff2 100644 (file)
@@ -1083,8 +1083,8 @@ int exec_spawn(ExecCommand *command,
                                 goto fail;
                         }
 
-                if (context->timer_slack_ns_set)
-                        if (prctl(PR_SET_TIMERSLACK, context->timer_slack_ns_set) < 0) {
+                if (context->timer_slack_nsec_set)
+                        if (prctl(PR_SET_TIMERSLACK, context->timer_slack_nsec) < 0) {
                                 r = EXIT_TIMERSLACK;
                                 goto fail;
                         }
@@ -1468,8 +1468,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
                 fputs("\n", f);
         }
 
-        if (c->timer_slack_ns_set)
-                fprintf(f, "%sTimerSlackNS: %lu\n", prefix, c->timer_slack_ns);
+        if (c->timer_slack_nsec_set)
+                fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, c->timer_slack_nsec);
 
         fprintf(f,
                 "%sStandardInput: %s\n"
index aa5f56667759ecd521d6244c28b57be669a75293..1ab6a24d9b2c9e2a460f50049f96ec5ac77746ae 100644 (file)
@@ -95,7 +95,7 @@ struct ExecContext {
 
         cpu_set_t *cpuset;
         unsigned cpuset_ncpus;
-        unsigned long timer_slack_ns;
+        unsigned long timer_slack_nsec;
 
         ExecInput std_input;
         ExecOutput std_output;
@@ -135,7 +135,7 @@ struct ExecContext {
         bool nice_set:1;
         bool ioprio_set:1;
         bool cpu_sched_set:1;
-        bool timer_slack_ns_set:1;
+        bool timer_slack_nsec_set:1;
 
         /* This is not exposed to the user but available
          * internally. We need it to make sure that whenever we spawn
index a5ea0e41b09cd8ab857384907c600b951bedf432..8e777fdbcfde1a487322b0dc7fbbd81e1315b79b 100644 (file)
@@ -857,7 +857,7 @@ static int config_parse_bounding_set(
         return 0;
 }
 
-static int config_parse_timer_slack_ns(
+static int config_parse_timer_slack_nsec(
                 const char *filename,
                 unsigned line,
                 const char *section,
@@ -880,7 +880,7 @@ static int config_parse_timer_slack_ns(
                 return r;
         }
 
-        c->timer_slack_ns = u;
+        c->timer_slack_nsec = u;
 
         return 0;
 }
@@ -1373,7 +1373,7 @@ static void dump_items(FILE *f, const ConfigItem *items) {
                 { config_parse_capabilities,     "CAPABILITIES" },
                 { config_parse_secure_bits,      "SECUREBITS" },
                 { config_parse_bounding_set,     "BOUNDINGSET" },
-                { config_parse_timer_slack_ns,   "TIMERSLACK" },
+                { config_parse_timer_slack_nsec, "TIMERSLACK" },
                 { config_parse_limit,            "LIMIT" },
                 { config_parse_cgroup,           "CGROUP [...]" },
                 { config_parse_deps,             "UNIT [...]" },
@@ -1468,7 +1468,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "Capabilities",           config_parse_capabilities,    &(context),                                      section   }, \
                 { "SecureBits",             config_parse_secure_bits,     &(context),                                      section   }, \
                 { "CapabilityBoundingSetDrop", config_parse_bounding_set, &(context),                                      section   }, \
-                { "TimerSlackNS",           config_parse_timer_slack_ns,  &(context),                                      section   }, \
+                { "TimerSlackNSec",         config_parse_timer_slack_nsec,&(context),                                      section   }, \
                 { "LimitCPU",               config_parse_limit,           &(context).rlimit[RLIMIT_CPU],                   section   }, \
                 { "LimitFSIZE",             config_parse_limit,           &(context).rlimit[RLIMIT_FSIZE],                 section   }, \
                 { "LimitDATA",              config_parse_limit,           &(context).rlimit[RLIMIT_DATA],                  section   }, \
@@ -1574,11 +1574,11 @@ static int load_from_path(Unit *u, const char *path) {
                 { "What",                   config_parse_path,            &u->swap.parameters_fragment.what,               "Swap"    },
                 { "Priority",               config_parse_int,             &u->swap.parameters_fragment.priority,           "Swap"    },
 
-                { "OnActive",               config_parse_timer,           &u->timer,                                       "Timer"   },
-                { "OnBoot",                 config_parse_timer,           &u->timer,                                       "Timer"   },
-                { "OnStartup",              config_parse_timer,           &u->timer,                                       "Timer"   },
-                { "OnUnitActive",           config_parse_timer,           &u->timer,                                       "Timer"   },
-                { "OnUnitInactive",         config_parse_timer,           &u->timer,                                       "Timer"   },
+                { "OnActiveSec",            config_parse_timer,           &u->timer,                                       "Timer"   },
+                { "OnBootSec",              config_parse_timer,           &u->timer,                                       "Timer"   },
+                { "OnStartupSec",           config_parse_timer,           &u->timer,                                       "Timer"   },
+                { "OnUnitActiveSec",        config_parse_timer,           &u->timer,                                       "Timer"   },
+                { "OnUnitInactiveSec",      config_parse_timer,           &u->timer,                                       "Timer"   },
                 { "Unit",                   config_parse_timer_unit,      &u->timer,                                       "Timer"   },
 
                 { "PathExists",             config_parse_path_spec,       &u->path,                                        "Path"    },
index e3c916bb0faf717b9f5e63e78c433b6d10aecc24..b4521e6efc9b5acd57648e2912dfdbeffcd40732 100644 (file)
@@ -440,11 +440,11 @@ static const char* const timer_state_table[_TIMER_STATE_MAX] = {
 DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);
 
 static const char* const timer_base_table[_TIMER_BASE_MAX] = {
-        [TIMER_ACTIVE] = "OnActive",
-        [TIMER_BOOT] = "OnBoot",
-        [TIMER_STARTUP] = "OnStartup",
-        [TIMER_UNIT_ACTIVE] = "OnUnitActive",
-        [TIMER_UNIT_INACTIVE] = "OnUnitInactive"
+        [TIMER_ACTIVE] = "OnActiveSec",
+        [TIMER_BOOT] = "OnBootSec",
+        [TIMER_STARTUP] = "OnStartupSec",
+        [TIMER_UNIT_ACTIVE] = "OnUnitActiveSec",
+        [TIMER_UNIT_INACTIVE] = "OnUnitInactiveSec"
 };
 
 DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);