diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0013-sysv-generator-add-support-for-executing-scripts-und.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0013-sysv-generator-add-support-for-executing-scripts-und.patch | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0013-sysv-generator-add-support-for-executing-scripts-und.patch b/meta/recipes-core/systemd/systemd/0013-sysv-generator-add-support-for-executing-scripts-und.patch new file mode 100644 index 0000000000..ac67f65685 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0013-sysv-generator-add-support-for-executing-scripts-und.patch | |||
@@ -0,0 +1,133 @@ | |||
1 | From 6736de4a3caf9a0b3c888c6cc05103ab1b86907d 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 13/36] 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 | 47 ++++++++++++++++++++++++++++--------- | ||
16 | 1 file changed, 36 insertions(+), 11 deletions(-) | ||
17 | |||
18 | diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c | ||
19 | index b5925a4..ea06d6a 100644 | ||
20 | --- a/src/sysv-generator/sysv-generator.c | ||
21 | +++ b/src/sysv-generator/sysv-generator.c | ||
22 | @@ -44,7 +44,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 | @@ -59,6 +60,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 | @@ -67,7 +71,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 | static const char *arg_dest = "/tmp"; | ||
51 | @@ -86,6 +90,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 | @@ -711,17 +717,31 @@ static int fix_order(SysvStub *s, Hashmap *all_services) { | ||
61 | if (s->has_lsb && other->has_lsb) | ||
62 | continue; | ||
63 | |||
64 | - if (other->sysv_start_priority < s->sysv_start_priority) { | ||
65 | - r = strv_extend(&s->after, other->name); | ||
66 | + /* All scripts under /etc/rcS.d should execute before scripts under | ||
67 | + * /etc/rcN.d */ | ||
68 | + if (!other->from_rcsd && s->from_rcsd) { | ||
69 | + r = strv_extend(&s->before, other->name); | ||
70 | if (r < 0) | ||
71 | return log_oom(); | ||
72 | |||
73 | - } else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
74 | - r = strv_extend(&s->before, other->name); | ||
75 | + } else if (other->from_rcsd && !s->from_rcsd) { | ||
76 | + r = strv_extend(&s->after, other->name); | ||
77 | if (r < 0) | ||
78 | return log_oom(); | ||
79 | - } else | ||
80 | - continue; | ||
81 | + } else { | ||
82 | + if (other->sysv_start_priority < s->sysv_start_priority) { | ||
83 | + r = strv_extend(&s->after, other->name); | ||
84 | + if (r < 0) | ||
85 | + return log_oom(); | ||
86 | + } | ||
87 | + else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
88 | + r = strv_extend(&s->before, other->name); | ||
89 | + if (r < 0) | ||
90 | + return log_oom(); | ||
91 | + } | ||
92 | + else | ||
93 | + continue; | ||
94 | + } | ||
95 | |||
96 | /* FIXME: Maybe we should compare the name here lexicographically? */ | ||
97 | } | ||
98 | @@ -788,6 +808,8 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) { | ||
99 | return log_oom(); | ||
100 | |||
101 | service->sysv_start_priority = -1; | ||
102 | + service->default_dependencies = true; | ||
103 | + service->from_rcsd = false; | ||
104 | service->name = name; | ||
105 | service->path = fpath; | ||
106 | name = fpath = NULL; | ||
107 | @@ -871,9 +893,11 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic | ||
108 | |||
109 | if (de->d_name[0] == 'S') { | ||
110 | |||
111 | - if (rcnd_table[i].type == RUNLEVEL_UP) | ||
112 | + if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) { | ||
113 | service->sysv_start_priority = MAX(a*10 + b, service->sysv_start_priority); | ||
114 | - | ||
115 | + service->default_dependencies = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?false:true; | ||
116 | + service->from_rcsd = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?true:false; | ||
117 | + } | ||
118 | r = set_ensure_allocated(&runlevel_services[i], NULL); | ||
119 | if (r < 0) { | ||
120 | log_oom(); | ||
121 | @@ -887,7 +911,8 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic | ||
122 | } | ||
123 | |||
124 | } else if (de->d_name[0] == 'K' && | ||
125 | - (rcnd_table[i].type == RUNLEVEL_DOWN)) { | ||
126 | + (rcnd_table[i].type == RUNLEVEL_DOWN || | ||
127 | + rcnd_table[i].type == RUNLEVEL_SYSINIT)) { | ||
128 | |||
129 | r = set_ensure_allocated(&shutdown_services, NULL); | ||
130 | if (r < 0) { | ||
131 | -- | ||
132 | 1.8.3.1 | ||
133 | |||