~ubuntu-branches/debian/jessie/systemd/jessie

« back to all changes in this revision

Viewing changes to src/unit.h

  • Committer: Package Import Robot
  • Author(s): Tollef Fog Heen, Tollef Fog Heen, Michael Biebl
  • Date: 2012-04-03 19:59:17 UTC
  • mfrom: (1.1.10) (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20120403195917-l532urrbg4pkreas
Tags: 44-1
[ Tollef Fog Heen ]
* New upstream version.
  - Backport 3492207: journal: PAGE_SIZE is not known on ppc and other
    archs
  - Backport 5a2a2a1: journal: react with immediate rotation to a couple
    of more errors
  - Backport 693ce21: util: never follow symlinks in rm_rf_children()
    Fixes CVE-2012-1174, closes: #664364
* Drop output message from init-functions hook, it's pointless.
* Only rmdir /lib/init/rw if it exists.
* Explicitly order debian-fixup before sysinit.target to prevent a
  possible race condition with the creation of sockets.  Thanks to
  Michael Biebl for debugging this.
* Always restart the initctl socket on upgrades, to mask sysvinit
  removing it.

[ Michael Biebl ]
* Remove workaround for non-interactive sessions from pam config again.
* Create compat /dev/initctl symlink in case we are upgrading from a system
  running a newer version of sysvinit (using /run/initctl) and sysvinit is
  replaced with systemd-sysv during the upgrade. Closes: #663219
* Install new man pages.
* Build-Depend on valac (>= 0.12) instead of valac-0.12. Closes: #663323

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <stdbool.h>
26
26
#include <stdlib.h>
27
27
 
28
 
typedef union Unit Unit;
29
 
typedef struct Meta Meta;
 
28
typedef struct Unit Unit;
30
29
typedef struct UnitVTable UnitVTable;
31
30
typedef enum UnitType UnitType;
32
31
typedef enum UnitLoadState UnitLoadState;
33
32
typedef enum UnitActiveState UnitActiveState;
34
33
typedef enum UnitDependency UnitDependency;
 
34
typedef struct UnitRef UnitRef;
35
35
 
36
36
#include "set.h"
37
37
#include "util.h"
119
119
        /* On Failure */
120
120
        UNIT_ON_FAILURE,
121
121
 
 
122
        /* Triggers (i.e. a socket triggers a service) */
 
123
        UNIT_TRIGGERS,
 
124
        UNIT_TRIGGERED_BY,
 
125
 
 
126
        /* Propagate reloads */
 
127
        UNIT_PROPAGATE_RELOAD_TO,
 
128
        UNIT_PROPAGATE_RELOAD_FROM,
 
129
 
122
130
        /* Reference information for GC logic */
123
131
        UNIT_REFERENCES,              /* Inverse of 'references' is 'referenced_by' */
124
132
        UNIT_REFERENCED_BY,
132
140
#include "cgroup.h"
133
141
#include "cgroup-attr.h"
134
142
 
135
 
struct Meta {
 
143
struct Unit {
136
144
        Manager *manager;
137
145
 
138
146
        UnitType type;
156
164
 
157
165
        usec_t job_timeout;
158
166
 
 
167
        /* References to this */
 
168
        LIST_HEAD(UnitRef, refs);
 
169
 
159
170
        /* Conditions to check */
160
171
        LIST_HEAD(Condition, conditions);
161
172
 
171
182
        CGroupAttribute *cgroup_attributes;
172
183
 
173
184
        /* Per type list */
174
 
        LIST_FIELDS(Meta, units_by_type);
 
185
        LIST_FIELDS(Unit, units_by_type);
175
186
 
176
187
        /* Load queue */
177
 
        LIST_FIELDS(Meta, load_queue);
 
188
        LIST_FIELDS(Unit, load_queue);
178
189
 
179
190
        /* D-Bus queue */
180
 
        LIST_FIELDS(Meta, dbus_queue);
 
191
        LIST_FIELDS(Unit, dbus_queue);
181
192
 
182
193
        /* Cleanup queue */
183
 
        LIST_FIELDS(Meta, cleanup_queue);
 
194
        LIST_FIELDS(Unit, cleanup_queue);
184
195
 
185
196
        /* GC queue */
186
 
        LIST_FIELDS(Meta, gc_queue);
 
197
        LIST_FIELDS(Unit, gc_queue);
187
198
 
188
199
        /* Used during GC sweeps */
189
200
        unsigned gc_marker;
237
248
        bool in_audit:1;
238
249
};
239
250
 
 
251
struct UnitRef {
 
252
        /* Keeps tracks of references to a unit. This is useful so
 
253
         * that we can merge two units if necessary and correct all
 
254
         * references to them */
 
255
 
 
256
        Unit* unit;
 
257
        LIST_FIELDS(UnitRef, refs);
 
258
};
 
259
 
240
260
#include "service.h"
241
261
#include "timer.h"
242
262
#include "socket.h"
248
268
#include "swap.h"
249
269
#include "path.h"
250
270
 
251
 
union Unit {
252
 
        Meta meta;
253
 
        Service service;
254
 
        Timer timer;
255
 
        Socket socket;
256
 
        Target target;
257
 
        Device device;
258
 
        Mount mount;
259
 
        Automount automount;
260
 
        Snapshot snapshot;
261
 
        Swap swap;
262
 
        Path path;
263
 
};
264
 
 
265
271
struct UnitVTable {
266
272
        const char *suffix;
267
273
 
 
274
        /* How much memory does an object of this unit type need */
 
275
        size_t object_size;
 
276
 
268
277
        /* Config file sections this unit type understands, separated
269
278
         * by NUL chars */
270
279
        const char *sections;
389
398
 
390
399
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
391
400
 
392
 
#define UNIT_VTABLE(u) unit_vtable[(u)->meta.type]
 
401
#define UNIT_VTABLE(u) unit_vtable[(u)->type]
393
402
 
394
403
/* For casting a unit into the various unit types */
395
404
#define DEFINE_CAST(UPPERCASE, MixedCase)                               \
396
405
        static inline MixedCase* UPPERCASE(Unit *u) {                   \
397
 
                if (_unlikely_(!u || u->meta.type != UNIT_##UPPERCASE)) \
 
406
                if (_unlikely_(!u || u->type != UNIT_##UPPERCASE))      \
398
407
                        return NULL;                                    \
399
408
                                                                        \
400
409
                return (MixedCase*) u;                                  \
401
410
        }
402
411
 
403
412
/* For casting the various unit types into a unit */
404
 
#define UNIT(u) ((Unit*) (&(u)->meta))
 
413
#define UNIT(u) (&(u)->meta)
405
414
 
406
415
DEFINE_CAST(SOCKET, Socket);
407
416
DEFINE_CAST(TIMER, Timer);
414
423
DEFINE_CAST(SWAP, Swap);
415
424
DEFINE_CAST(PATH, Path);
416
425
 
417
 
Unit *unit_new(Manager *m);
 
426
Unit *unit_new(Manager *m, size_t size);
418
427
void unit_free(Unit *u);
419
428
 
420
429
int unit_add_name(Unit *u, const char *name);
512
521
 
513
522
int unit_coldplug(Unit *u);
514
523
 
515
 
void unit_status_printf(Unit *u, const char *format, ...);
 
524
void unit_status_printf(Unit *u, const char *status, const char *format, ...);
516
525
 
517
526
bool unit_need_daemon_reload(Unit *u);
518
527
 
536
545
 
537
546
UnitFileState unit_get_unit_file_state(Unit *u);
538
547
 
 
548
Unit* unit_ref_set(UnitRef *ref, Unit *u);
 
549
void unit_ref_unset(UnitRef *ref);
 
550
 
 
551
#define UNIT_DEREF(ref) ((ref).unit)
 
552
 
539
553
const char *unit_load_state_to_string(UnitLoadState i);
540
554
UnitLoadState unit_load_state_from_string(const char *s);
541
555