diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0012-sysv-generator-add-support-for-executing-scripts-und.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0012-sysv-generator-add-support-for-executing-scripts-und.patch | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0012-sysv-generator-add-support-for-executing-scripts-und.patch b/meta/recipes-core/systemd/systemd/0012-sysv-generator-add-support-for-executing-scripts-und.patch new file mode 100644 index 0000000000..82feff0eb9 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0012-sysv-generator-add-support-for-executing-scripts-und.patch | |||
@@ -0,0 +1,143 @@ | |||
1 | From 9e6c907ff1f17deb96c66a607653db4c7da34289 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Mon, 14 Dec 2015 05:09:53 +0000 | ||
4 | Subject: [PATCH 12/16] sysv-generator: add support for executing scripts under | ||
5 | /etc/rcS.d/ | ||
6 | |||
7 | To be compatible, all services translated from scripts under /etc/rcS.d would | ||
8 | run before services translated from scripts under /etc/rcN.d. | ||
9 | |||
10 | Upstream-Status: Inappropriate [OE specific] | ||
11 | |||
12 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | --- | ||
15 | src/sysv-generator/sysv-generator.c | 50 +++++++++++++++++++++++++++++-------- | ||
16 | 1 file changed, 39 insertions(+), 11 deletions(-) | ||
17 | |||
18 | diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c | ||
19 | index 5075548..32d3687 100644 | ||
20 | --- a/src/sysv-generator/sysv-generator.c | ||
21 | +++ b/src/sysv-generator/sysv-generator.c | ||
22 | @@ -46,7 +46,8 @@ | ||
23 | |||
24 | typedef enum RunlevelType { | ||
25 | RUNLEVEL_UP, | ||
26 | - RUNLEVEL_DOWN | ||
27 | + RUNLEVEL_DOWN, | ||
28 | + RUNLEVEL_SYSINIT | ||
29 | } RunlevelType; | ||
30 | |||
31 | static const struct { | ||
32 | @@ -61,6 +62,9 @@ static const struct { | ||
33 | { "rc4.d", SPECIAL_MULTI_USER_TARGET, RUNLEVEL_UP }, | ||
34 | { "rc5.d", SPECIAL_GRAPHICAL_TARGET, RUNLEVEL_UP }, | ||
35 | |||
36 | + /* Debian style rcS.d, also adopted by OE */ | ||
37 | + { "rcS.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT}, | ||
38 | + | ||
39 | /* Standard SysV runlevels for shutdown */ | ||
40 | { "rc0.d", SPECIAL_POWEROFF_TARGET, RUNLEVEL_DOWN }, | ||
41 | { "rc6.d", SPECIAL_REBOOT_TARGET, RUNLEVEL_DOWN } | ||
42 | @@ -69,7 +73,7 @@ static const struct { | ||
43 | directories in this order, and we want to make sure that | ||
44 | sysv_start_priority is known when we first load the | ||
45 | unit. And that value we only know from S links. Hence | ||
46 | - UP must be read before DOWN */ | ||
47 | + UP/SYSINIT must be read before DOWN */ | ||
48 | }; | ||
49 | |||
50 | const char *arg_dest = "/tmp"; | ||
51 | @@ -88,6 +92,8 @@ typedef struct SysvStub { | ||
52 | bool has_lsb; | ||
53 | bool reload; | ||
54 | bool loaded; | ||
55 | + bool default_dependencies; | ||
56 | + bool from_rcsd; | ||
57 | } SysvStub; | ||
58 | |||
59 | static void free_sysvstub(SysvStub *s) { | ||
60 | @@ -204,6 +210,9 @@ static int generate_unit_file(SysvStub *s) { | ||
61 | if (s->description) | ||
62 | fprintf(f, "Description=%s\n", s->description); | ||
63 | |||
64 | + if (!s->default_dependencies) | ||
65 | + fprintf(f, "DefaultDependencies=no\n"); | ||
66 | + | ||
67 | if (!isempty(before)) | ||
68 | fprintf(f, "Before=%s\n", before); | ||
69 | if (!isempty(after)) | ||
70 | @@ -722,17 +731,31 @@ static int fix_order(SysvStub *s, Hashmap *all_services) { | ||
71 | if (s->has_lsb && other->has_lsb) | ||
72 | continue; | ||
73 | |||
74 | - if (other->sysv_start_priority < s->sysv_start_priority) { | ||
75 | - r = strv_extend(&s->after, other->name); | ||
76 | + /* All scripts under /etc/rcS.d should execute before scripts under | ||
77 | + * /etc/rcN.d */ | ||
78 | + if (!other->from_rcsd && s->from_rcsd) { | ||
79 | + r = strv_extend(&s->before, other->name); | ||
80 | if (r < 0) | ||
81 | return log_oom(); | ||
82 | |||
83 | - } else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
84 | - r = strv_extend(&s->before, other->name); | ||
85 | + } else if (other->from_rcsd && !s->from_rcsd) { | ||
86 | + r = strv_extend(&s->after, other->name); | ||
87 | if (r < 0) | ||
88 | return log_oom(); | ||
89 | - } else | ||
90 | - continue; | ||
91 | + } else { | ||
92 | + if (other->sysv_start_priority < s->sysv_start_priority) { | ||
93 | + r = strv_extend(&s->after, other->name); | ||
94 | + if (r < 0) | ||
95 | + return log_oom(); | ||
96 | + } | ||
97 | + else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
98 | + r = strv_extend(&s->before, other->name); | ||
99 | + if (r < 0) | ||
100 | + return log_oom(); | ||
101 | + } | ||
102 | + else | ||
103 | + continue; | ||
104 | + } | ||
105 | |||
106 | /* FIXME: Maybe we should compare the name here lexicographically? */ | ||
107 | } | ||
108 | @@ -799,6 +822,8 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) { | ||
109 | return log_oom(); | ||
110 | |||
111 | service->sysv_start_priority = -1; | ||
112 | + service->default_dependencies = true; | ||
113 | + service->from_rcsd = false; | ||
114 | service->name = name; | ||
115 | service->path = fpath; | ||
116 | name = fpath = NULL; | ||
117 | @@ -882,9 +907,11 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic | ||
118 | |||
119 | if (de->d_name[0] == 'S') { | ||
120 | |||
121 | - if (rcnd_table[i].type == RUNLEVEL_UP) | ||
122 | + if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) { | ||
123 | service->sysv_start_priority = MAX(a*10 + b, service->sysv_start_priority); | ||
124 | - | ||
125 | + service->default_dependencies = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?false:true; | ||
126 | + service->from_rcsd = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?true:false; | ||
127 | + } | ||
128 | r = set_ensure_allocated(&runlevel_services[i], NULL); | ||
129 | if (r < 0) { | ||
130 | log_oom(); | ||
131 | @@ -898,7 +925,8 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic | ||
132 | } | ||
133 | |||
134 | } else if (de->d_name[0] == 'K' && | ||
135 | - (rcnd_table[i].type == RUNLEVEL_DOWN)) { | ||
136 | + (rcnd_table[i].type == RUNLEVEL_DOWN || | ||
137 | + rcnd_table[i].type == RUNLEVEL_SYSINIT)) { | ||
138 | |||
139 | r = set_ensure_allocated(&shutdown_services, NULL); | ||
140 | if (r < 0) { | ||
141 | -- | ||
142 | 2.6.4 | ||
143 | |||