NetBSD-Bugs archive

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

Re: misc/38425 (savecore confused if getbootfile(3) fails)



The following reply was made to PR misc/38425; it has been noted by GNATS.

From: Thor Lancelot Simon <tls%rek.tjls.com@localhost>
To: Andrew Doran <ad%netbsd.org@localhost>
Cc: Simon Burge <simonb%NetBSD.org@localhost>, gnats-bugs%NetBSD.org@localhost, 
tls%netbsd.org@localhost
Subject: Re: misc/38425 (savecore confused if getbootfile(3) fails)
Date: Fri, 20 Mar 2009 12:19:03 -0400

 On Sun, Feb 22, 2009 at 09:18:18AM +0000, Andrew Doran wrote:
 > 
 > Making it use /dev/ksyms like Thor proposed would improve the situation..
 
 Try the below - savecore had a stupid bug (it should probably not feed
 a filename to libkvm at all, but it certainly should not feed the wrong
 one) and libkvm had all the right code but the wrong default.
 
 On Christos' suggestion I have not changed getbootfile() as I originally
 planned.  I am sorely tempted however to remove it from the system as it
 seems to only be used wrong -- literally everywhere it is used, what is
 really wanted is "where do I get the kernel symbols", not "what name
 was supplied to the boot loader".
 
 Thor
 
 Index: sbin/savecore/savecore.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/savecore/savecore.c,v
 retrieving revision 1.76
 diff -u -r1.76 savecore.c
 --- sbin/savecore/savecore.c   20 Oct 2008 10:34:54 -0000      1.76
 +++ sbin/savecore/savecore.c   20 Mar 2009 16:09:56 -0000
 @@ -229,7 +229,11 @@
                dirname = argv[0];
  
        if (kernel == NULL) {
 -              kernel = getbootfile();
 +              if (access(_PATH_KSYMS, R_OK) == 0) {
 +                      kernel = _PATH_KSYMS;
 +              } else {
 +                      kernel = getbootfile();
 +              }
        }
  
        (void)time(&now);
 Index: lib/libkvm/kvm.c
 ===================================================================
 RCS file: /cvsroot/src/lib/libkvm/kvm.c,v
 retrieving revision 1.92
 diff -u -r1.92 kvm.c
 --- lib/libkvm/kvm.c   15 Jan 2008 14:16:30 -0000      1.92
 +++ lib/libkvm/kvm.c   20 Mar 2009 16:09:57 -0000
 @@ -288,6 +288,10 @@
  
        ufgiven = (uf != NULL);
        if (!ufgiven) {
 +              if (access(_PATH_KSYMS, R_OK) == 0) {
 +                      uf = _PATH_KSYMS;
 +                      goto got_symfile;
 +              }
  #ifdef CPU_BOOTED_KERNEL
                /* 130 is 128 + '/' + '\0' */
                static char booted_kernel[130];
 @@ -315,6 +319,7 @@
                _kvm_err(kd, kd->program, "exec file name too long");
                goto failed;
        }
 +got_symfile:
        if (flag & ~O_RDWR) {
                _kvm_err(kd, kd->program, "bad flags arg");
                goto failed;
 


Home | Main Index | Thread Index | Old Index