Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2010-08-27 04:40:20 (GMT)
committer Daniel Drake <dsd@laptop.org>2010-08-27 04:40:20 (GMT)
commit61457d9f1d6fc71a8d1d8b601a533e8e7bacae2e (patch)
tree619c4cc9f656ce5300f9ebc2ab763d193063d190 /bin
parentd3d880bcd174ea7b69e750e5cdcbadd1d9d26f9a (diff)
Use system crcimg
Didn't realise this was available in Fedora.
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile8
-rw-r--r--bin/crcimg.c96
2 files changed, 2 insertions, 102 deletions
diff --git a/bin/Makefile b/bin/Makefile
index ba202a6..4b1c2d8 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -1,17 +1,13 @@
CC=gcc
-all: crcimg zhashfs
-
-crcimg: crc32.c crcimg.c
- $(CC) $^ -o $@
+all: zhashfs
zhashfs: zhashfs.c
$(CC) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DARGTYPE=1 $^ -o $@ -I/usr/include/tomcrypt -ltomcrypt -lz
install: all
install -D -m 0755 zhashfs $(DESTDIR)/usr/libexec/olpc-os-builder/zhashfs
- install -D -m 0755 crcimg $(DESTDIR)/usr/libexec/olpc-os-builder/crcimg
clean:
- rm -f crcimg zhashfs
+ rm -f zhashfs
diff --git a/bin/crcimg.c b/bin/crcimg.c
deleted file mode 100644
index 46a918e..0000000
--- a/bin/crcimg.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * crcimg - calculates a CRC32 for each 0x20000 block of the input file
- * Used for checking JFFS2 NAND FLASH installation images.
- * Copyright 2007, Mitch Bradley
- * License: GPL v2
- * Tip 'o the hat to Richard Smith
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <getopt.h>
-
-#include "crc32.h"
-
-#define VER_MAJOR 0
-#define VER_MINOR 1
-#define VER_RELEASE 0
-
-#define EBSIZE 0x20000
-
-static unsigned char buf[EBSIZE];
-static FILE *imagefile;
-static FILE *crcfile;
-char outfilename[FILENAME_MAX];
-
-void usage(const char *name)
-{
- printf("%s Ver: %d.%d.%d\n",name,VER_MAJOR,VER_MINOR,VER_RELEASE);
- printf("usage: %s [file.img]\n", name);
- printf("Creates file.crc containing CRCs for each 0x20000 byte block in file.img\n");
- printf("With no arguments, filters standard input, writing CRC list to standard output\n");
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- int opt=0;
- int option_index = 0;
- size_t bytes_read=0;
-
- static struct option long_options[]= {
- { "help", 0, 0, 'h' },
- { 0, 0, 0, 0 }
- };
-
- setbuf(stdout, NULL);
- while ((opt = getopt_long(argc, argv, "h", long_options,
- &option_index)) != EOF) {
- switch (opt) {
- case 'h':
- default:
- usage(argv[0]);
- break;
- }
- }
-
- char *filename = NULL;
-
- if (optind < argc) {
- /* Filename supplied */
- filename = argv[optind++];
- if ((strlen(filename) >= 4) && (strcmp(filename + strlen(filename) - 4, ".img") == 0)) {
- strncpy(outfilename, filename, FILENAME_MAX);
- strcpy(outfilename + strlen(filename) - 4, ".crc");
- } else {
- strncpy(outfilename, filename, FILENAME_MAX);
- strncat(outfilename, ".crc", FILENAME_MAX - strlen(outfilename));
- }
- if ((imagefile = fopen(filename, "r+")) == NULL) {
- perror(filename);
- exit(1);
- }
- if ((crcfile = fopen(outfilename, "w+")) == NULL) {
- perror(outfilename);
- exit(1);
- }
- } else {
- /* Use standard in/out */
- imagefile = stdin;
- crcfile = stdout;
- }
-
- while ((bytes_read = fread(buf, sizeof(char), EBSIZE, imagefile)) == EBSIZE) {
- fprintf(crcfile, "%08lx\n", (unsigned long)~crc32(0xffffffff, buf, EBSIZE));
- }
-
- if (bytes_read != 0) {
- printf("Input file size is not a multiple of 0x%x - residue 0x%x\n", EBSIZE, bytes_read);
- fclose(crcfile);
- exit(1);
- }
-
- fclose(crcfile);
- return 0;
-}