Adjust checkpoint restore to use same note order as coredumps.
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 1 Mar 2009 07:26:20 +0000 (23:26 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 1 Mar 2009 07:26:20 +0000 (23:26 -0800)
Recent changes to the coredump code broke the checkpoint restore
code (checkpt -r) due to reordering of the ELF notes.  Adjust the
checkpoint restore code to deal with the new ordering.

Reported-by: Samuel J. Greear <sjg@evilcode.net>
sys/kern/kern_checkpoint.c

index 221a6f4..470cd5a 100644 (file)
@@ -73,7 +73,6 @@
 #include <sys/mount.h>
 #include <sys/ckpt.h>
 
-
 static int elf_loadphdrs(struct file *fp,  Elf_Phdr *phdr, int numsegs);
 static int elf_getnotes(struct lwp *lp, struct file *fp, size_t notesz);
 static int elf_demarshalnotes(void *src, prpsinfo_t *psinfo,
@@ -363,6 +362,10 @@ elf_demarshalnotes(void *src, prpsinfo_t *psinfo, prstatus_t *status,
        int off = 0;
 
        TRACE_ENTER;
+       error = elf_getnote(src, &off, "FreeBSD", NT_PRPSINFO,
+                          (void **)&psinfo, sizeof(prpsinfo_t));
+       if (error)
+               goto done;
        error = elf_getnote(src, &off, "FreeBSD", NT_PRSTATUS, 
                           (void **)&status, sizeof(prstatus_t));
        if (error)
@@ -371,10 +374,6 @@ elf_demarshalnotes(void *src, prpsinfo_t *psinfo, prstatus_t *status,
                           (void **)&fpregset, sizeof(prfpregset_t));
        if (error)
                goto done;
-       error = elf_getnote(src, &off, "FreeBSD", NT_PRPSINFO, 
-                          (void **)&psinfo, sizeof(prpsinfo_t));
-       if (error)
-               goto done;
 
        /*
         * The remaining portion needs to be an integer multiple