aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2015-12-01 17:39:04 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2015-12-01 17:39:04 -0600
commit635e33cdc8f18bb290756633ce0714c496383cfb (patch)
treec23dc30e5b39af965e2f3a099daacac034f00d82 /src
parentbd9456ff3172cc88f32d67bd4e789e2beee43595 (diff)
librc: comsolidate rc_sys_v1 and rc_sys_v2 into rc_sys
These functions were never meant to be used outside of OpenRC, and they were added when we thought we were going to do away with the automatic detection of subsystems. Since the autodetection is not going away, we can combine these functions into rc_sys.
Diffstat (limited to 'src')
-rw-r--r--src/librc/librc.c82
-rw-r--r--src/librc/librc.h2
-rw-r--r--src/librc/rc.h.in8
-rw-r--r--src/test/rc.funcs.list4
4 files changed, 30 insertions, 66 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 8f043131..5e5de8d8 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -210,14 +210,14 @@ found:
}
#endif
-/* New sys identification code
- * Not to be used for any binaries outside of openrc. */
+
const char *
-rc_sys_v2(void)
+rc_sys(void)
{
-#define __STRING_SWITCH(x) { char *__string_switch = x; if (false) {}
-#define __STRING_CASE(y) else if (strcmp(__string_switch,y) == 0)
-#define __STRING_SWITCH_END() }
+#ifdef PREFIX
+ return RC_SYS_PREFIX;
+#endif
+
char *systype = rc_conf_value("rc_sys");
if (systype) {
char *s = systype;
@@ -227,43 +227,11 @@ rc_sys_v2(void)
*s = toupper((unsigned char) *s);
s++;
}
- /* Now do detection */
- __STRING_SWITCH(systype)
- __STRING_CASE(RC_SYS_PREFIX) { return RC_SYS_PREFIX; }
-#ifdef __FreeBSD__
- __STRING_CASE(RC_SYS_JAIL) { return RC_SYS_JAIL; }
-#endif /* __FreeBSD__ */
-#ifdef __NetBSD__
- __STRING_CASE(RC_SYS_XEN0) { return RC_SYS_XEN0; }
- __STRING_CASE(RC_SYS_XENU) { return RC_SYS_XENU; }
-#endif /* __NetBSD__ */
-#ifdef __linux__
- __STRING_CASE(RC_SYS_XEN0) { return RC_SYS_XEN0; }
- __STRING_CASE(RC_SYS_XENU) { return RC_SYS_XENU; }
- __STRING_CASE(RC_SYS_UML) { return RC_SYS_UML; }
- __STRING_CASE(RC_SYS_VSERVER) { return RC_SYS_VSERVER; }
- __STRING_CASE(RC_SYS_OPENVZ) { return RC_SYS_OPENVZ; }
- __STRING_CASE(RC_SYS_LXC) { return RC_SYS_LXC; }
-#endif /* __linux__ */
- __STRING_SWITCH_END()
}
-#undef __STRING_SWITCH
-#undef __STRING_CASE
-#undef __STRING_SWITCH_END
- return NULL;
-}
-librc_hidden_def(rc_sys_v2)
-
-/* Old sys identification code.
- * Not to be used for any binaries outside of openrc. */
-const char *
-rc_sys_v1(void)
-{
-#ifdef PREFIX
- return RC_SYS_PREFIX;
-#else
#ifdef __FreeBSD__
+ if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
+ return RC_SYS_JAIL;
int jailed = 0;
size_t len = sizeof(jailed);
@@ -273,6 +241,12 @@ rc_sys_v1(void)
#endif
#ifdef __NetBSD__
+ if (systype) {
+ if(strcmp(systype, RC_SYS_XEN0) == 0)
+ return RC_SYS_XEN0;
+ if (strcmp(systype, RC_SYS_XENU) == 0)
+ return RC_SYS_XENU;
+ }
if (exists("/kern/xen/privcmd"))
return RC_SYS_XEN0;
if (exists("/kern/xen"))
@@ -280,6 +254,22 @@ rc_sys_v1(void)
#endif
#ifdef __linux__
+ if (systype) {
+ if (strcmp(systype, RC_SYS_XEN0) == 0)
+ return RC_SYS_XEN0;
+ if (strcmp(systype, RC_SYS_XENU) == 0)
+ return RC_SYS_XENU;
+ if (strcmp(systype, RC_SYS_UML) == 0)
+ return RC_SYS_UML;
+ if (strcmp(systype, RC_SYS_VSERVER) == 0)
+ return RC_SYS_VSERVER;
+ if (strcmp(systype, RC_SYS_OPENVZ) == 0)
+ return RC_SYS_OPENVZ;
+ if (strcmp(systype, RC_SYS_LXC) == 0)
+ return RC_SYS_LXC;
+ if (strcmp(systype, RC_SYS_SYSTEMD_NSPAWN) == 0)
+ return RC_SYS_SYSTEMD_NSPAWN;
+ }
if (exists("/proc/xen")) {
if (file_regex("/proc/xen/capabilities", "control_d"))
return RC_SYS_XEN0;
@@ -301,18 +291,6 @@ rc_sys_v1(void)
#endif
return NULL;
-#endif /* PREFIX */
-}
-librc_hidden_def(rc_sys_v1)
-
-const char *
-rc_sys(void)
-{
- if (rc_conf_value("rc_sys")) {
- return rc_sys_v2();
- } else {
- return rc_sys_v1();
- }
}
librc_hidden_def(rc_sys)
diff --git a/src/librc/librc.h b/src/librc/librc.h
index 0824eba7..01bb7403 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -130,8 +130,6 @@ librc_hidden_proto(rc_stringlist_new)
librc_hidden_proto(rc_stringlist_split)
librc_hidden_proto(rc_stringlist_sort)
librc_hidden_proto(rc_sys)
-librc_hidden_proto(rc_sys_v1)
-librc_hidden_proto(rc_sys_v2)
librc_hidden_proto(rc_yesno)
#endif
diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index e3a586f6..141ecb97 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -343,14 +343,6 @@ bool rc_service_daemons_crashed(const char *);
* @return string from RC_SYS_* types or NULL if none detected */
const char *rc_sys(void);
-/*! Returns the type of subsystem using old automatic code
- * @return string from RC_SYS_* types or NULL if none detected */
-const char *rc_sys_v1(void);
-
-/*! Returns the type of subsystem using new rc.conf rc_sys value
- * @return string from RC_SYS_* types or NULL if none detected */
-const char *rc_sys_v2(void);
-
/*! @name Dependency options
* These options can change the services found by the rc_get_depinfo and
* rc_get_depends functions. */
diff --git a/src/test/rc.funcs.list b/src/test/rc.funcs.list
index f4c90b51..c87e470c 100644
--- a/src/test/rc.funcs.list
+++ b/src/test/rc.funcs.list
@@ -112,9 +112,5 @@ rc_stringlist_split
rc_stringlist_split@@RC_1.0
rc_sys
rc_sys@@RC_1.0
-rc_sys_v1
-rc_sys_v1@@RC_1.0
-rc_sys_v2
-rc_sys_v2@@RC_1.0
rc_yesno
rc_yesno@@RC_1.0