chiark / gitweb /
manager: introduce watch_init() initializer for watches
[elogind.git] / src / core / unit.c
index 4eea5b57ae49107dcba461397460e38582d96677..82dd617e35175cba8a3d71adb795932d4a8db647 100644 (file)
@@ -613,7 +613,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
         /* If syslog or kernel logging is requested, make sure our own
          * logging daemon is run first. */
 
-        if (u->manager->running_as == MANAGER_SYSTEM)
+        if (u->manager->running_as == SYSTEMD_SYSTEM)
                 if ((r = unit_add_two_dependencies_by_name(u, UNIT_REQUIRES, UNIT_AFTER, SPECIAL_JOURNALD_SOCKET, NULL, true)) < 0)
                         return r;
 
@@ -1023,7 +1023,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
                                SD_MESSAGE_UNIT_RELOADING;
 
         log_struct(LOG_INFO,
-                   "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(mid),
+                   MESSAGE_ID(mid),
                    "UNIT=%s", u->id,
                    "MESSAGE=%s", buf,
                    NULL);
@@ -1438,7 +1438,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
                         check_unneeded_dependencies(u);
 
                 if (ns != os && ns == UNIT_FAILED) {
-                        log_notice("Unit %s entered failed state.", u->id);
+                        log_struct(LOG_NOTICE,
+                                   "MESSAGE=Unit %s entered failed state", u->id,
+                                   "UNIT=%s", u->id,
+                                   NULL);
                         unit_trigger_on_failure(u);
                 }
         }
@@ -1577,7 +1580,8 @@ int unit_watch_timer(Unit *u, usec_t delay, Watch *w) {
         } else if (w->type == WATCH_INVALID) {
 
                 ours = true;
-                if ((fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC)) < 0)
+                fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC);
+                if (fd < 0)
                         return -errno;
         } else
                 assert_not_reached("Invalid watch type");
@@ -2590,7 +2594,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
 
         if (u->unit_file_state < 0 && u->fragment_path)
                 u->unit_file_state = unit_file_get_state(
-                                u->manager->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
+                                u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER,
                                 NULL, path_get_file_name(u->fragment_path));
 
         return u->unit_file_state;
@@ -2673,7 +2677,7 @@ int unit_exec_context_defaults(Unit *u, ExecContext *c) {
                                 return -ENOMEM;
                 }
 
-        if (u->manager->running_as == MANAGER_USER &&
+        if (u->manager->running_as == SYSTEMD_USER &&
             !c->working_directory) {
 
                 r = get_home_dir(&c->working_directory);
@@ -2684,6 +2688,17 @@ int unit_exec_context_defaults(Unit *u, ExecContext *c) {
         return 0;
 }
 
+ExecContext *unit_get_exec_context(Unit *u) {
+        size_t offset;
+        assert(u);
+
+        offset = UNIT_VTABLE(u)->exec_context_offset;
+        if (offset <= 0)
+                return NULL;
+
+        return (ExecContext*) ((uint8_t*) u + offset);
+}
+
 static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
         [UNIT_ACTIVE] = "active",
         [UNIT_RELOADING] = "reloading",