1 |
commit: 9f6e05671d6d48faa7b83aec05a637bcdfcb3f82 |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Dec 7 23:56:02 2015 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Dec 8 18:09:33 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=9f6e0567 |
7 |
|
8 |
Convert rc_sys() calls to detect_container() and detect_vm() |
9 |
|
10 |
src/librc/librc-depend.c | 5 ++++- |
11 |
src/rc/_usage.c | 5 ++++- |
12 |
src/rc/rc-misc.c | 6 ++++-- |
13 |
src/rc/rc.c | 20 ++++++++++++++++---- |
14 |
4 files changed, 28 insertions(+), 8 deletions(-) |
15 |
|
16 |
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c |
17 |
index c9c06ad..14cf297 100644 |
18 |
--- a/src/librc/librc-depend.c |
19 |
+++ b/src/librc/librc-depend.c |
20 |
@@ -753,7 +753,7 @@ rc_deptree_update(void) |
21 |
char *depend, *depends, *service, *type, *nosys, *onosys; |
22 |
size_t i, k, l; |
23 |
bool retval = true; |
24 |
- const char *sys = rc_sys(); |
25 |
+ const char *sys = NULL; |
26 |
struct utsname uts; |
27 |
|
28 |
/* Some init scripts need RC_LIBEXECDIR to source stuff |
29 |
@@ -860,6 +860,9 @@ rc_deptree_update(void) |
30 |
|
31 |
/* Phase 2 - if we're a special system, remove services that don't |
32 |
* work for them. This doesn't stop them from being run directly. */ |
33 |
+ sys = detect_container(); |
34 |
+ if (!sys) |
35 |
+ sys = detect_vm(); |
36 |
if (sys) { |
37 |
len = strlen(sys); |
38 |
nosys = xmalloc(len + 2); |
39 |
|
40 |
diff --git a/src/rc/_usage.c b/src/rc/_usage.c |
41 |
index 2ab0fa6..a6bad4d 100644 |
42 |
--- a/src/rc/_usage.c |
43 |
+++ b/src/rc/_usage.c |
44 |
@@ -56,7 +56,10 @@ show_version(void) |
45 |
const char *systype = NULL; |
46 |
|
47 |
printf("%s (OpenRC", applet); |
48 |
- if ((systype = rc_sys())) |
49 |
+ systype = detect_container(); |
50 |
+ if (!systype) |
51 |
+ systype = detect_vm(); |
52 |
+ if (systype) |
53 |
printf(" [%s]", systype); |
54 |
printf(") %s", VERSION); |
55 |
#ifdef BRANDING |
56 |
|
57 |
diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c |
58 |
index 1e2af0a..263c0ed 100644 |
59 |
--- a/src/rc/rc-misc.c |
60 |
+++ b/src/rc/rc-misc.c |
61 |
@@ -139,7 +139,7 @@ env_config(void) |
62 |
char *np; |
63 |
char *npp; |
64 |
char *tok; |
65 |
- const char *sys = rc_sys(); |
66 |
+ const char *sys = NULL; |
67 |
char buffer[PATH_MAX]; |
68 |
|
69 |
/* Ensure our PATH is prefixed with the system locations first |
70 |
@@ -190,7 +190,9 @@ env_config(void) |
71 |
} else |
72 |
setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1); |
73 |
|
74 |
- if (sys) |
75 |
+ sys = detect_container(); |
76 |
+ if (!sys) |
77 |
+ sys = detect_vm(); |
78 |
setenv("RC_SYS", sys, 1); |
79 |
|
80 |
#ifdef PREFIX |
81 |
|
82 |
diff --git a/src/rc/rc.c b/src/rc/rc.c |
83 |
index 8f69333..ddc3c78 100644 |
84 |
--- a/src/rc/rc.c |
85 |
+++ b/src/rc/rc.c |
86 |
@@ -274,7 +274,11 @@ open_shell(void) |
87 |
struct passwd *pw; |
88 |
|
89 |
#ifdef __linux__ |
90 |
- const char *sys = rc_sys(); |
91 |
+ const char *sys = NULL; |
92 |
+ |
93 |
+ sys = detect_container(); |
94 |
+ if (!sys) |
95 |
+ sys = detect_vm(); |
96 |
|
97 |
/* VSERVER and OPENVZ systems cannot really drop to shells */ |
98 |
if (sys && |
99 |
@@ -480,7 +484,10 @@ do_sysinit() |
100 |
uts.machine); |
101 |
#endif |
102 |
|
103 |
- if ((sys = rc_sys())) |
104 |
+ sys = detect_container(); |
105 |
+ if (!sys) |
106 |
+ sys = detect_vm(); |
107 |
+ if (sys) |
108 |
printf(" [%s]", sys); |
109 |
|
110 |
printf("%s\n\n", ecolor(ECOLOR_NORMAL)); |
111 |
@@ -495,7 +502,10 @@ do_sysinit() |
112 |
|
113 |
/* init may have mounted /proc so we can now detect or real |
114 |
* sys */ |
115 |
- if ((sys = rc_sys())) |
116 |
+ sys = detect_container(); |
117 |
+ if (!sys) |
118 |
+ sys = detect_vm(); |
119 |
+ if (sys) |
120 |
setenv("RC_SYS", sys, 1); |
121 |
} |
122 |
|
123 |
@@ -846,7 +856,9 @@ main(int argc, char **argv) |
124 |
eerrorx("%s: %s", applet, strerror(errno)); |
125 |
/* NOTREACHED */ |
126 |
case 'S': |
127 |
- systype = rc_sys(); |
128 |
+ systype = detect_container(); |
129 |
+ if (!systype) |
130 |
+ systype = detect_vm(); |
131 |
if (systype) |
132 |
printf("%s\n", systype); |
133 |
exit(EXIT_SUCCESS); |