FreeCalypso > hg > fc-am-toolkit
view bootutil/c155_main.c @ 18:c8ad6188b9ed
add c139-gen-fc-* shell script hierarchy
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 10 Jun 2023 08:16:10 +0000 |
parents | 36e65605d16a |
children |
line wrap: on
line source
/* * This C module is the main for c155-analyze-boot utility. */ #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include "../bootmatch/bootmatch.h" extern struct bootmatch bootmatch_c155[]; #define LENGTH_OF_INTEREST 0x2000 static u_char image[LENGTH_OF_INTEREST]; static void read_bin_file(filename) char *filename; { int fd; struct stat st; fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(1); } fstat(fd, &st); if (!S_ISREG(st.st_mode)) { fprintf(stderr, "error: %s is not a regular file\n", filename); exit(1); } if (st.st_size < LENGTH_OF_INTEREST) { fprintf(stderr, "error: %s is too short\n", filename); exit(1); } read(fd, image, LENGTH_OF_INTEREST); close(fd); } main(argc, argv) char **argv; { if (argc != 2) { fprintf(stderr, "usage: %s flashdump.bin\n", argv[0]); exit(1); } read_bin_file(argv[1]); if (check_for_match(image, bootmatch_c155)) puts("ok"); else puts("unknown"); exit(0); }