1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
4 * Copyright 2010 Intel Corporation; author: H. Peter Anvin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Boston MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
12 * ----------------------------------------------------------------------- */
22 #include "../../version.h"
26 const char program[] = "sysdump";
27 const char version[] = "SYSDUMP " VERSION_STR " " DATE "\n";
29 __noreturn die(const char *msg)
31 printf("%s: %s\n", program, msg);
35 static void dump_all(struct backend *be, const char *argv[])
39 cpio_writefile(be, "sysdump", version, sizeof version-1);
53 static struct backend *backends[] =
61 __noreturn usage(void)
63 struct backend **bep, *be;
66 for (bep = backends ; (be = *bep) ; bep++)
67 printf(" %s %s %s\n", program, be->name, be->helpmsg);
72 int main(int argc, char *argv[])
74 struct backend **bep, *be;
76 openconsole(&dev_null_r, &dev_stdcon_w);
77 fputs(version, stdout);
82 for (bep = backends ; (be = *bep) ; bep++) {
83 if (!strcmp(be->name, argv[1]))
87 if (!be || argc < be->minargs + 2)
90 /* Do this as early as possible */
93 printf("Backend: %s\n", be->name);
95 /* Do the actual data dump */
96 dump_all(be, (const char **)argv + 2);