Re: [PATCH] Add better debugging capabilities to loader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Without the devel argument, the behaviour won't change. Modifications to init were mostly to start the shell afterwards so we can collect the coredump. This shouldn't be hard to include to linuxrc.s390 as well. 

--
Martin Sivák
msivak@xxxxxxxxxx
Red Hat Czech
Anaconda team / Brno, CZ

----- "Steffen Maier" <maier@xxxxxxxxxxxxxxxxxx> wrote:

> If loader no more dumps but init.c only, s390x won't get anaconda
> dumps,
> since it's got its own init aka linuxrc.s390 which is a shell script
> and
> I don't know from the top of my head if the C code for dumping could
> be
> scripted there as well. That would be a pity from s390x point of
> view.
> 
> In general dumping in init vs. loader seems like a good idea.
> 
> On 06/30/2010 01:26 PM, Martin Sivak wrote:
> > - when development ('devel' argument) mode is requested, init
> enables
> >   core dumping and starts shell in the case of unexpected exit
> > ---
> >  loader/init.c   |   54
> +++++++++++++++++++++++++++++++++++++++++++++++++-----
> >  loader/loader.c |    7 -------
> >  2 files changed, 49 insertions(+), 12 deletions(-)
> > 
> > diff --git a/loader/init.c b/loader/init.c
> > index 175f1d7..820d3ef 100644
> > --- a/loader/init.c
> > +++ b/loader/init.c
> > @@ -44,6 +44,7 @@
> >  #include <sys/stat.h>
> >  #include <sys/swap.h>
> >  #include <sys/time.h>
> > +#include <sys/resource.h>
> >  #include <sys/types.h>
> >  #include <sys/un.h>
> >  #include <sys/wait.h>
> > @@ -516,9 +517,11 @@ int main(int argc, char **argv) {
> >      int doShutdown =0;
> >      reboot_action shutdown_method = HALT;
> >      int isSerial = 0;
> > +    int isDebugMode = 0;
> >      char * console = NULL;
> >      int doKill = 1;
> >      char * argvc[15];
> > +    char buf[1024];
> >      char ** argvp = argvc;
> >      char twelve = 12;
> >      struct serial_struct si;
> > @@ -563,6 +566,25 @@ int main(int argc, char **argv) {
> >          fatal_error(1);
> >      printf("done\n");
> > 
> > +    /* unless the user specifies that they want utf8 */
> > +    int fdn;
> > +    if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
> > +        int len = read(fdn, buf, sizeof(buf) - 1);
> > +        close(fdn);
> > +        if (len > 0 && strstr(buf, "devel")) {
> > +            printf("Enabling development mode - cores will be
> dumped\n");
> > +            isDebugMode = 1;
> > +        }
> > +    }
> > +
> > +    /* these args are only for testing from commandline */
> > +    for (i = 1; i < argc; i++) {
> > +        if (!strcmp (argv[i], "serial")) {
> > +            isSerial = 1;
> > +            break;
> > +        }
> > +    }
> > +
> >      printf("creating /dev filesystem... "); 
> >      fflush(stdout);
> >      if (mount("/dev", "/dev", "tmpfs", 0, NULL))
> > @@ -618,14 +640,17 @@ int main(int argc, char **argv) {
> >          fatal_error(1);
> >      printf("done\n");
> > 
> > -    /* these args are only for testing from commandline */
> > -    for (i = 1; i < argc; i++) {
> > -        if (!strcmp (argv[i], "serial")) {
> > -            isSerial = 1;
> > -            break;
> > +    if (isDebugMode) {
> > +        /* if anaconda dies suddenly we are doomed, so at least
> make a coredump */
> > +        struct rlimit corelimit = { RLIM_INFINITY, 
> RLIM_INFINITY};
> > +        int ret = setrlimit(RLIMIT_CORE, &corelimit);
> > +        if (ret) {
> > +            perror("setrlimit failed - no coredumps will be
> available");
> >          }
> >      }
> > 
> > +
> > +
> >      doKill = getKillPolicy();
> > 
> >  #if !defined(__s390__) && !defined(__s390x__)
> > @@ -872,6 +897,25 @@ int main(int argc, char **argv) {
> >              printf("-- received signal %d", WTERMSIG(waitStatus));
> >          }
> >          printf("\n");
> > +
> > +        /* If debug mode was requested, spawn shell */
> > +        if(isDebugMode) {
> > +            pid_t shellpid;
> > +
> > +            printf("Development mode requested spawning
> shell...\n");
> > +
> > +            if ((shellpid = fork()) == 0) {
> > +                execl("/sbin/bash", "/sbin/bash", NULL);
> > +            }
> > +            else if (shellpid > 0) {
> > +                waitpid(shellpid, NULL, 0);
> > +            }
> > +            else {
> > +                perror("Execution of debug shell failed.");
> > +            }
> > +
> > +        }
> > +
> >      } else {
> >          shutdown_method = REBOOT;
> >      }
> > diff --git a/loader/loader.c b/loader/loader.c
> > index 46f6f5e..8287311 100644
> > --- a/loader/loader.c
> > +++ b/loader/loader.c
> > @@ -2385,13 +2385,6 @@ int main(int argc, char ** argv) {
> >      stopNewt();
> >      closeLog();
> > 
> > -    /* if anaconda dies suddenly we are doomed, so at least make a
> coredump */
> > -    struct rlimit corelimit = { RLIM_INFINITY,  RLIM_INFINITY};
> > -    ret = setrlimit(RLIMIT_CORE, &corelimit);
> > -    if (ret) {
> > -        perror("setrlimit failed");
> > -    }
> > -
> >      if (FL_RESCUE(flags)) {
> >          fmt = _("Running anaconda %s, the %s rescue mode - please
> wait.\n");
> >      } else {
> 
> Steffen
> 
> Linux on System z Development
> 
> IBM Deutschland Research & Development GmbH
> Vorsitzender des Aufsichtsrats: Martin Jetter
> Geschäftsführung: Dirk Wittkopp
> Sitz der Gesellschaft: Böblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294
> 
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list



[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux