savecore: factor out info file handling
Move it to a separate function, allowing its reuse.
Reviewed by: markj
MFC after: 3 days
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34822
(cherry picked from commit cf02cf8dbfe718e1f14cec0cce4663812c0e26f1)