unit.h revision 613b411c947635136637f8cdd66b94512f761eab
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni This file is part of systemd.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni Copyright 2010 Lennart Poettering
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni systemd is free software; you can redistribute it and/or modify it
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni under the terms of the GNU Lesser General Public License as published by
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni the Free Software Foundation; either version 2.1 of the License, or
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni (at your option) any later version.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni systemd is distributed in the hope that it will be useful, but
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni WITHOUT ANY WARRANTY; without even the implied warranty of
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni Lesser General Public License for more details.
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni You should have received a copy of the GNU Lesser General Public License
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni along with systemd; If not, see <http://www.gnu.org/licenses/>.
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantonitypedef enum UnitActiveState UnitActiveState;
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantonitypedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
4d3e11a2177a45225341ff99c71d168f23ef3b98Craig McDonnellstatic inline bool UNIT_IS_ACTIVE_OR_RELOADING(UnitActiveState t) {
4d3e11a2177a45225341ff99c71d168f23ef3b98Craig McDonnell return t == UNIT_ACTIVE || t == UNIT_RELOADING;
4d3e11a2177a45225341ff99c71d168f23ef3b98Craig McDonnellstatic inline bool UNIT_IS_ACTIVE_OR_ACTIVATING(UnitActiveState t) {
4d3e11a2177a45225341ff99c71d168f23ef3b98Craig McDonnell return t == UNIT_ACTIVE || t == UNIT_ACTIVATING || t == UNIT_RELOADING;
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantonistatic inline bool UNIT_IS_INACTIVE_OR_DEACTIVATING(UnitActiveState t) {
6a2ae9c7fb4d2c40d75cab0edaf940f22c18224fDiego Colantoni return t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_DEACTIVATING;
7741d5b589048a915ad3baea77b81cb81b2dbe4fCraig McDonnellstatic inline bool UNIT_IS_INACTIVE_OR_FAILED(UnitActiveState t) {
7741d5b589048a915ad3baea77b81cb81b2dbe4fCraig McDonnell return t == UNIT_INACTIVE || t == UNIT_FAILED;
enum UnitDependency {
UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' and 'requisite_overridable' is 'soft_required_by' */
#include "manager.h"
#include "job.h"
struct UnitRef {
struct Unit {
char *id; /* One name is special because we use it for identification. Points to an entry in the names set */
char *instance;
char **requires_mounts_for;
char *description;
char **documentation;
char **dropin_paths;
char *cgroup_path;
unsigned gc_marker;
int load_error;
bool stop_when_unneeded;
bool default_dependencies;
bool refuse_manual_start;
/* Don't allow the user to stop this unit manually, allow stopping only indirectly via dependency. */
bool refuse_manual_stop;
bool allow_isolate;
bool ignore_on_isolate;
bool ignore_on_snapshot;
bool condition_result;
bool transient;
struct UnitStatusMessageFormats {
typedef enum UnitSetPropertiesMode {
UNIT_CHECK = 0,
#include "service.h"
#include "timer.h"
#include "socket.h"
#include "target.h"
#include "device.h"
#include "mount.h"
#include "automount.h"
#include "snapshot.h"
#include "swap.h"
#include "path.h"
#include "slice.h"
#include "scope.h"
struct UnitVTable {
const char *private_section;
const char *sections;
void (*bus_name_owner_change)(Unit *u, const char *name, const char *old_owner, const char *new_owner);
int (*bus_set_property)(Unit *u, const char *name, sd_bus_message *message, UnitSetPropertiesMode mode, sd_bus_error *error);
const char *bus_interface;
const char * const * const bus_changing_properties;
return NULL; \
return (MixedCase*) u; \
int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference);
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
int unit_add_two_dependencies_by_name(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name, const char *filename, bool add_reference);
int unit_add_two_dependencies_by_name_inverse(Unit *u, UnitDependency d, UnitDependency e, const char *name, const char *path, bool add_reference);
int unit_kill_common(Unit *u, KillWho who, int signo, pid_t main_pid, pid_t control_pid, sd_bus_error *error);
int set_unit_path(const char *p);
void unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_(4,5);
void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) _printf_(3, 0);
int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) _printf_(4,5);
int unit_write_drop_in_private(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data);
int unit_write_drop_in_private_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) _printf_(4,5);
int unit_kill_context(Unit *u, KillContext *c, bool sigkill, pid_t main_pid, pid_t control_pid, bool main_pid_alien);
#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
#define log_struct_unit(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)