/[baselayout]/trunk/src/rc.c
Gentoo

Diff of /trunk/src/rc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2785 Revision 2786
462static void set_ksoftlevel (const char *runlevel) 462static void set_ksoftlevel (const char *runlevel)
463{ 463{
464 FILE *fp; 464 FILE *fp;
465 465
466 if (! runlevel || 466 if (! runlevel ||
467 strcmp (runlevel, RC_LEVEL_BOOT) == 0 || 467 strcmp (runlevel, getenv ("RC_BOOTLEVEL")) == 0 ||
468 strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || 468 strcmp (runlevel, RC_LEVEL_SINGLE) == 0 ||
469 strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) 469 strcmp (runlevel, RC_LEVEL_SYSINIT) == 0)
470 { 470 {
471 if (rc_exists (RC_SVCDIR "ksoftlevel") && 471 if (rc_exists (RC_SVCDIR "ksoftlevel") &&
472 unlink (RC_SVCDIR "ksoftlevel") != 0) 472 unlink (RC_SVCDIR "ksoftlevel") != 0)
642#include "_usage.c" 642#include "_usage.c"
643 643
644int main (int argc, char **argv) 644int main (int argc, char **argv)
645{ 645{
646 char *runlevel = NULL; 646 char *runlevel = NULL;
647 const char *bootlevel = NULL;
647 char *newlevel = NULL; 648 char *newlevel = NULL;
648 char *service = NULL; 649 char *service = NULL;
649 char **deporder = NULL; 650 char **deporder = NULL;
650 int i = 0; 651 int i = 0;
651 int j = 0; 652 int j = 0;
778 779
779 interactive = rc_exists (INTERACTIVE); 780 interactive = rc_exists (INTERACTIVE);
780 rc_plugin_load (); 781 rc_plugin_load ();
781 782
782 /* Load current softlevel */ 783 /* Load current softlevel */
784 bootlevel = getenv ("RC_BOOTLEVEL");
783 runlevel = rc_get_runlevel (); 785 runlevel = rc_get_runlevel ();
784 786
785 /* Check we're in the runlevel requested, ie from 787 /* Check we're in the runlevel requested, ie from
786 rc single 788 rc single
787 rc shutdown 789 rc shutdown
963#else 965#else
964 /* BSD's on the other hand populate /dev automagically and use devd. 966 /* BSD's on the other hand populate /dev automagically and use devd.
965 The only downside of this approach and ours is that we have to hard code 967 The only downside of this approach and ours is that we have to hard code
966 the device node to the init script to simulate the coldplug into 968 the device node to the init script to simulate the coldplug into
967 runlevel for our dependency tree to work. */ 969 runlevel for our dependency tree to work. */
968 if (newlevel && strcmp (newlevel, RC_LEVEL_BOOT) == 0 && 970 if (newlevel && strcmp (newlevel, bootlevel) == 0 &&
969 (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 || 971 (strcmp (runlevel, RC_LEVEL_SINGLE) == 0 ||
970 strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) && 972 strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) &&
971 rc_is_env ("RC_COLDPLUG", "yes")) 973 rc_is_env ("RC_COLDPLUG", "yes"))
972 { 974 {
973 /* The net interfaces are easy - they're all in net /dev/net :) */ 975 /* The net interfaces are easy - they're all in net /dev/net :) */
1013 1015
1014 types = rc_strlist_add (NULL, "ineed"); 1016 types = rc_strlist_add (NULL, "ineed");
1015 types = rc_strlist_add (types, "iuse"); 1017 types = rc_strlist_add (types, "iuse");
1016 types = rc_strlist_add (types, "iafter"); 1018 types = rc_strlist_add (types, "iafter");
1017 deporder = rc_get_depends (deptree, types, stop_services, 1019 deporder = rc_get_depends (deptree, types, stop_services,
1018 runlevel, depoptions); 1020 runlevel, depoptions | RC_DEP_STOP);
1019 rc_strlist_free (stop_services); 1021 rc_strlist_free (stop_services);
1020 rc_strlist_free (types); 1022 rc_strlist_free (types);
1021 stop_services = deporder; 1023 stop_services = deporder;
1022 deporder = NULL; 1024 deporder = NULL;
1023 types = NULL; 1025 types = NULL;
1027 coldplugged_services = rc_ls_dir (coldplugged_services, 1029 coldplugged_services = rc_ls_dir (coldplugged_services,
1028 RC_SVCDIR_COLDPLUGGED, RC_LS_INITD); 1030 RC_SVCDIR_COLDPLUGGED, RC_LS_INITD);
1029 1031
1030 /* Load our start services now. 1032 /* Load our start services now.
1031 We have different rules dependent on runlevel. */ 1033 We have different rules dependent on runlevel. */
1032 if (newlevel && strcmp (newlevel, RC_LEVEL_BOOT) == 0) { 1034 if (newlevel && strcmp (newlevel, bootlevel) == 0) {
1033 if (coldplugged_services) { 1035 if (coldplugged_services) {
1034 einfon ("Device initiated services:"); 1036 einfon ("Device initiated services:");
1035 STRLIST_FOREACH (coldplugged_services, service, i) { 1037 STRLIST_FOREACH (coldplugged_services, service, i) {
1036 printf (" %s", service); 1038 printf (" %s", service);
1037 start_services = rc_strlist_add (start_services, service); 1039 start_services = rc_strlist_add (start_services, service);
1049 if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 && 1051 if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 &&
1050 strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 && 1052 strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
1051 strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0) 1053 strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)
1052 { 1054 {
1053 /* We need to include the boot runlevel services if we're not in it */ 1055 /* We need to include the boot runlevel services if we're not in it */
1054 start_services = rc_ls_dir (start_services, RC_RUNLEVELDIR RC_LEVEL_BOOT, 1056 char **services = rc_services_in_runlevel (bootlevel);
1055 RC_LS_INITD); 1057
1058 start_services = rc_strlist_join (start_services, services);
1059 services = rc_services_in_runlevel (newlevel ? newlevel : runlevel);
1060 start_services = rc_strlist_join (start_services, services);
1061 services = NULL;
1062
1056 STRLIST_FOREACH (coldplugged_services, service, i) 1063 STRLIST_FOREACH (coldplugged_services, service, i)
1057 start_services = rc_strlist_add (start_services, service); 1064 start_services = rc_strlist_add (start_services, service);
1058 1065
1059 tmp = rc_strcatpaths (RC_RUNLEVELDIR,
1060 newlevel ? newlevel : runlevel, (char *) NULL);
1061 start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
1062 CHAR_FREE (tmp);
1063 } 1066 }
1064 } 1067 }
1065 1068
1066 /* Save out softlevel now */ 1069 /* Save out softlevel now */
1067 if (going_down) 1070 if (going_down)
1197 /* Order the services to start */ 1200 /* Order the services to start */
1198 types = rc_strlist_add (NULL, "ineed"); 1201 types = rc_strlist_add (NULL, "ineed");
1199 types = rc_strlist_add (types, "iuse"); 1202 types = rc_strlist_add (types, "iuse");
1200 types = rc_strlist_add (types, "iafter"); 1203 types = rc_strlist_add (types, "iafter");
1201 deporder = rc_get_depends (deptree, types, start_services, 1204 deporder = rc_get_depends (deptree, types, start_services,
1202 runlevel, depoptions); 1205 runlevel, depoptions | RC_DEP_START);
1203 rc_strlist_free (types); 1206 rc_strlist_free (types);
1204 types = NULL; 1207 types = NULL;
1205 rc_strlist_free (start_services); 1208 rc_strlist_free (start_services);
1206 start_services = deporder; 1209 start_services = deporder;
1207 deporder = NULL; 1210 deporder = NULL;
1246 wait_for_services (); 1249 wait_for_services ();
1247 1250
1248 rc_plugin_run (rc_hook_runlevel_start_out, runlevel); 1251 rc_plugin_run (rc_hook_runlevel_start_out, runlevel);
1249 1252
1250 /* Store our interactive status for boot */ 1253 /* Store our interactive status for boot */
1251 if (interactive && strcmp (runlevel, RC_LEVEL_BOOT) == 0) 1254 if (interactive && strcmp (runlevel, bootlevel) == 0)
1252 mark_interactive (); 1255 mark_interactive ();
1253 else { 1256 else {
1254 if (rc_exists (INTERACTIVE)) 1257 if (rc_exists (INTERACTIVE))
1255 unlink (INTERACTIVE); 1258 unlink (INTERACTIVE);
1256 } 1259 }

Legend:
Removed from v.2785  
changed lines
  Added in v.2786

  ViewVC Help
Powered by ViewVC 1.1.20