We no longer care about numerical runlevels, #184733.
This commit is contained in:
parent
ae160bf293
commit
1cda2a2036
@ -1,6 +1,10 @@
|
|||||||
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
||||||
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
||||||
|
|
||||||
|
10 Jul 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
|
We no longer care about numerical runlevels, #184733.
|
||||||
|
|
||||||
09 Jul 2007; Roy Marples <uberlord@gentoo.org>:
|
09 Jul 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
Add an option to fork ldconfig in env-update, #182794
|
Add an option to fork ldconfig in env-update, #182794
|
||||||
|
131
src/rc.c
131
src/rc.c
@ -475,6 +475,30 @@ static void set_ksoftlevel (const char *runlevel)
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_ksoftlevel (char *buffer, int buffer_len)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (! rc_exists (RC_SVCDIR "ksoftlevel"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (! (fp = fopen (RC_SVCDIR "ksoftlevel", "r"))) {
|
||||||
|
eerror ("fopen `%s': %s", RC_SVCDIR "ksoftlevel",
|
||||||
|
strerror (errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgets (buffer, buffer_len, fp)) {
|
||||||
|
i = strlen (buffer) - 1;
|
||||||
|
if (buffer[i] == '\n')
|
||||||
|
buffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (fp);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
static void wait_for_services ()
|
static void wait_for_services ()
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@ -753,10 +777,22 @@ int main (int argc, char **argv)
|
|||||||
RUNLEVEL = getenv ("RUNLEVEL");
|
RUNLEVEL = getenv ("RUNLEVEL");
|
||||||
PREVLEVEL = getenv ("PREVLEVEL");
|
PREVLEVEL = getenv ("PREVLEVEL");
|
||||||
|
|
||||||
if (RUNLEVEL && newlevel) {
|
|
||||||
if (strcmp (RUNLEVEL, "S") == 0 || strcmp (RUNLEVEL, "1") == 0) {
|
/* Load current softlevel */
|
||||||
|
runlevel = rc_get_runlevel ();
|
||||||
|
|
||||||
|
/* Check we're in the runlevel requested, ie from
|
||||||
|
rc single
|
||||||
|
rc shutdown
|
||||||
|
rc reboot
|
||||||
|
*/
|
||||||
|
if (newlevel) {
|
||||||
|
if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0 &&
|
||||||
|
RUNLEVEL &&
|
||||||
|
(strcmp (RUNLEVEL, "S") == 0 ||
|
||||||
|
strcmp (RUNLEVEL, "1") == 0))
|
||||||
|
{
|
||||||
/* OK, we're either in runlevel 1 or single user mode */
|
/* OK, we're either in runlevel 1 or single user mode */
|
||||||
if (strcmp (newlevel, RC_LEVEL_SYSINIT) == 0) {
|
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -820,68 +856,12 @@ int main (int argc, char **argv)
|
|||||||
mark_interactive ();
|
mark_interactive ();
|
||||||
|
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
} else if (strcmp (newlevel, RC_LEVEL_SINGLE) == 0) {
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
/* Parse the inittab file so we can work out the level to telinit */
|
|
||||||
if (strcmp (newlevel, RC_LEVEL_BOOT) != 0 &&
|
|
||||||
strcmp (newlevel, RC_LEVEL_SINGLE) != 0)
|
|
||||||
{
|
|
||||||
char **inittab = rc_get_list (NULL, "/etc/inittab");
|
|
||||||
char *line;
|
|
||||||
char *p;
|
|
||||||
char *token;
|
|
||||||
char lvl[2] = {0, 0};
|
|
||||||
|
|
||||||
STRLIST_FOREACH (inittab, line, i) {
|
|
||||||
p = line;
|
|
||||||
token = strsep (&p, ":");
|
|
||||||
if (! token || token[0] != 'l')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((token = strsep (&p, ":")) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Snag the level */
|
|
||||||
lvl[0] = token[0];
|
|
||||||
|
|
||||||
/* The name is spaced after this */
|
|
||||||
if ((token = strsep (&p, " ")) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((token = strsep (&p, " ")) == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strcmp (token, newlevel) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rc_strlist_free (inittab);
|
|
||||||
|
|
||||||
/* We have a level, so telinit into it */
|
|
||||||
if (lvl[0] == 0) {
|
|
||||||
eerrorx ("%s: couldn't find a runlevel called `%s'",
|
|
||||||
applet, newlevel);
|
|
||||||
} else {
|
|
||||||
execl ("/sbin/telinit", "/sbin/telinit", lvl, (char *) NULL);
|
|
||||||
eerrorx ("%s: unable to exec `/sbin/telinit': %s",
|
|
||||||
applet, strerror (errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check we're in the runlevel requested, ie from
|
|
||||||
rc single
|
|
||||||
rc shutdown
|
|
||||||
rc reboot
|
|
||||||
*/
|
|
||||||
if (newlevel) {
|
|
||||||
if (strcmp (newlevel, RC_LEVEL_SINGLE) == 0) {
|
|
||||||
if (! RUNLEVEL ||
|
if (! RUNLEVEL ||
|
||||||
(strcmp (RUNLEVEL, "S") != 0 &&
|
(strcmp (RUNLEVEL, "S") != 0 &&
|
||||||
strcmp (RUNLEVEL, "1") != 0))
|
strcmp (RUNLEVEL, "1") != 0))
|
||||||
{
|
{
|
||||||
|
einfo ("Setting %s", runlevel);
|
||||||
/* Remember the current runlevel for when we come back */
|
/* Remember the current runlevel for when we come back */
|
||||||
set_ksoftlevel (runlevel);
|
set_ksoftlevel (runlevel);
|
||||||
single_user ();
|
single_user ();
|
||||||
@ -911,18 +891,9 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Export our current softlevel */
|
|
||||||
runlevel = rc_get_runlevel ();
|
|
||||||
|
|
||||||
/* Now we start handling our children */
|
/* Now we start handling our children */
|
||||||
signal (SIGCHLD, handle_signal);
|
signal (SIGCHLD, handle_signal);
|
||||||
|
|
||||||
/* If we're in the default runlevel and ksoftlevel exists, we should use
|
|
||||||
that instead */
|
|
||||||
if (newlevel &&
|
|
||||||
rc_exists (RC_SVCDIR "ksoftlevel") &&
|
|
||||||
strcmp (newlevel, RC_LEVEL_DEFAULT) == 0)
|
|
||||||
{
|
|
||||||
/* We should only use ksoftlevel if we were in single user mode
|
/* We should only use ksoftlevel if we were in single user mode
|
||||||
If not, we need to erase ksoftlevel now. */
|
If not, we need to erase ksoftlevel now. */
|
||||||
if (PREVLEVEL &&
|
if (PREVLEVEL &&
|
||||||
@ -930,21 +901,13 @@ int main (int argc, char **argv)
|
|||||||
strcmp (PREVLEVEL, "S") == 0 ||
|
strcmp (PREVLEVEL, "S") == 0 ||
|
||||||
strcmp (PREVLEVEL, "N") == 0))
|
strcmp (PREVLEVEL, "N") == 0))
|
||||||
{
|
{
|
||||||
FILE *fp;
|
if (get_ksoftlevel (ksoftbuffer, sizeof (ksoftbuffer)))
|
||||||
|
|
||||||
if (! (fp = fopen (RC_SVCDIR "ksoftlevel", "r")))
|
|
||||||
eerror ("fopen `%s': %s", RC_SVCDIR "ksoftlevel",
|
|
||||||
strerror (errno));
|
|
||||||
else {
|
|
||||||
if (fgets (ksoftbuffer, sizeof (ksoftbuffer), fp)) {
|
|
||||||
i = strlen (ksoftbuffer) - 1;
|
|
||||||
if (ksoftbuffer[i] == '\n')
|
|
||||||
ksoftbuffer[i] = 0;
|
|
||||||
newlevel = ksoftbuffer;
|
newlevel = ksoftbuffer;
|
||||||
}
|
} else if (! RUNLEVEL ||
|
||||||
fclose (fp);
|
(strcmp (RUNLEVEL, "1") != 0 &&
|
||||||
}
|
strcmp (RUNLEVEL, "S") != 0 &&
|
||||||
} else
|
strcmp (RUNLEVEL, "N") != 0))
|
||||||
|
{
|
||||||
set_ksoftlevel (NULL);
|
set_ksoftlevel (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
src/rc.h
5
src/rc.h
@ -8,8 +8,13 @@
|
|||||||
#ifndef __RC_H__
|
#ifndef __RC_H__
|
||||||
#define __RC_H__
|
#define __RC_H__
|
||||||
|
|
||||||
|
#define SENTINEL
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC__MINOR )
|
||||||
|
# if (GCC_VERSION >= 3005)
|
||||||
|
# undef SENTINEL
|
||||||
# define SENTINEL __attribute__ ((__sentinel__))
|
# define SENTINEL __attribute__ ((__sentinel__))
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user