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

Diff of /trunk/src/rc.c

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

Revision 2786 Revision 2792
335 eerrorx ("%s: unknown applet", applet); 335 eerrorx ("%s: unknown applet", applet);
336 336
337 return (ok ? EXIT_SUCCESS : EXIT_FAILURE); 337 return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
338} 338}
339 339
340#ifdef __linux__
341static char *proc_getent (const char *ent)
342{
343 FILE *fp;
344 char buffer[RC_LINEBUFFER];
345 char *p;
346 char *value = NULL;
347 int i;
348
349 if (! (fp = fopen ("/proc/cmdline", "r"))) {
350 eerror ("failed to open `/proc/cmdline': %s", strerror (errno));
351 return (NULL);
352 }
353
354 memset (buffer, 0, sizeof (buffer));
355 if (fgets (buffer, RC_LINEBUFFER, fp) &&
356 (p = strstr (buffer, ent)))
357 {
358 i = p - buffer;
359 if (i == '\0' || buffer[i - 1] == ' ') {
360 /* Trim the trailing carriage return if present */
361 i = strlen (buffer) - 1;
362 if (buffer[i] == '\n')
363 buffer[i] = 0;
364
365 p += strlen (ent);
366 if (*p == '=')
367 p++;
368 value = strdup (strsep (&p, " "));
369 }
370 } else
371 errno = ENOENT;
372 fclose (fp);
373
374 return (value);
375}
376#endif
377
340static char read_key (bool block) 378static char read_key (bool block)
341{ 379{
342 struct termios termios; 380 struct termios termios;
343 char c = 0; 381 char c = 0;
344 int fd = fileno (stdin); 382 int fd = fileno (stdin);
796 strcmp (RUNLEVEL, "1") == 0)) 834 strcmp (RUNLEVEL, "1") == 0))
797 { 835 {
798 /* OK, we're either in runlevel 1 or single user mode */ 836 /* OK, we're either in runlevel 1 or single user mode */
799 struct utsname uts; 837 struct utsname uts;
800#ifdef __linux__ 838#ifdef __linux__
801 FILE *fp; 839 char *cmd;
802#endif 840#endif
803 841
804 /* exec init-early.sh if it exists 842 /* exec init-early.sh if it exists
805 * This should just setup the console to use the correct 843 * This should just setup the console to use the correct
806 * font. Maybe it should setup the keyboard too? */ 844 * font. Maybe it should setup the keyboard too? */
822 860
823 setenv ("RC_SOFTLEVEL", newlevel, 1); 861 setenv ("RC_SOFTLEVEL", newlevel, 1);
824 rc_plugin_run (rc_hook_runlevel_start_in, newlevel); 862 rc_plugin_run (rc_hook_runlevel_start_in, newlevel);
825 run_script (INITSH); 863 run_script (INITSH);
826 864
865#ifdef __linux__
827 /* If we requested a softlevel, save it now */ 866 /* If we requested a softlevel, save it now */
828#ifdef __linux__
829 set_ksoftlevel (NULL); 867 set_ksoftlevel (NULL);
830 868 if ((cmd = proc_getent ("softlevel"))) {
831 if ((fp = fopen ("/proc/cmdline", "r"))) {
832 char buffer[RC_LINEBUFFER];
833 char *soft;
834
835 memset (buffer, 0, sizeof (buffer));
836 if (fgets (buffer, RC_LINEBUFFER, fp) &&
837 (soft = strstr (buffer, "softlevel=")))
838 {
839 i = soft - buffer;
840 if (i == 0 || buffer[i - 1] == ' ') {
841 char *level;
842
843 /* Trim the trailing carriage return if present */
844 i = strlen (buffer) - 1;
845 if (buffer[i] == '\n')
846 buffer[i] = 0;
847
848 soft += strlen ("softlevel=");
849 level = strsep (&soft, " ");
850 set_ksoftlevel (level); 869 set_ksoftlevel (cmd);
851 } 870 free (cmd);
852 }
853 fclose (fp);
854 } 871 }
872
855#endif 873#endif
856 rc_plugin_run (rc_hook_runlevel_start_out, newlevel); 874 rc_plugin_run (rc_hook_runlevel_start_out, newlevel);
857 875
858 if (want_interactive ()) 876 if (want_interactive ())
859 mark_interactive (); 877 mark_interactive ();
1207 types = NULL; 1225 types = NULL;
1208 rc_strlist_free (start_services); 1226 rc_strlist_free (start_services);
1209 start_services = deporder; 1227 start_services = deporder;
1210 deporder = NULL; 1228 deporder = NULL;
1211 1229
1230#ifdef __linux__
1231 /* mark any services skipped as started */
1232 if (PREVLEVEL && strcmp (PREVLEVEL, "N") == 0) {
1233 if ((service = proc_getent ("noinitd"))) {
1234 char *p = service;
1235 char *token;
1236
1237 while ((token = strsep (&p, ",")))
1238 rc_mark_service (token, rc_service_started);
1239 free (service);
1240 }
1241 }
1242#endif
1243
1244
1212 STRLIST_FOREACH (start_services, service, i) { 1245 STRLIST_FOREACH (start_services, service, i) {
1213 if (rc_service_state (service, rc_service_stopped)) { 1246 if (rc_service_state (service, rc_service_stopped)) {
1214 pid_t pid; 1247 pid_t pid;
1215 1248
1216 if (! interactive) 1249 if (! interactive)
1248 /* Wait for our services to finish */ 1281 /* Wait for our services to finish */
1249 wait_for_services (); 1282 wait_for_services ();
1250 1283
1251 rc_plugin_run (rc_hook_runlevel_start_out, runlevel); 1284 rc_plugin_run (rc_hook_runlevel_start_out, runlevel);
1252 1285
1286#ifdef __linux__
1287 /* mark any services skipped as stopped */
1288 if (PREVLEVEL && strcmp (PREVLEVEL, "N") == 0) {
1289 if ((service = proc_getent ("noinitd"))) {
1290 char *p = service;
1291 char *token;
1292
1293 while ((token = strsep (&p, ",")))
1294 rc_mark_service (token, rc_service_stopped);
1295 free (service);
1296 }
1297 }
1298#endif
1299
1253 /* Store our interactive status for boot */ 1300 /* Store our interactive status for boot */
1254 if (interactive && strcmp (runlevel, bootlevel) == 0) 1301 if (interactive && strcmp (runlevel, bootlevel) == 0)
1255 mark_interactive (); 1302 mark_interactive ();
1256 else { 1303 else {
1257 if (rc_exists (INTERACTIVE)) 1304 if (rc_exists (INTERACTIVE))

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

  ViewVC Help
Powered by ViewVC 1.1.20