diff options
author | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2013-12-04 00:06:38 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-04 17:17:06 +0100 |
commit | 1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e (patch) | |
tree | c9e17a96d29046e033c37e0341570cc9501012da /scripts/bareboxcrc32.c | |
parent | a83f635fb2a069c91693ebd15f336fa04e1b7204 (diff) | |
download | barebox-1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e.tar.gz barebox-1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e.tar.xz |
scripts: bareboxcrc32 as host and target userspacetool
This patch adds the crc32 command to be build
as host and optionally as target tool.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/bareboxcrc32.c')
-rw-r--r-- | scripts/bareboxcrc32.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/bareboxcrc32.c b/scripts/bareboxcrc32.c new file mode 100644 index 0000000000..e00ffafeb7 --- /dev/null +++ b/scripts/bareboxcrc32.c @@ -0,0 +1,60 @@ +/* + * bareboxcrc32.c - generate crc32 checksum in little endian + * + * Copyright (c) 2013 Michael Grzeschik <mgr@pengutronix.de> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <stdint.h> +#include <limits.h> +#include <errno.h> +#include <dirent.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> +#include <libgen.h> + +#include "compiler.h" + +#define debug(...) + +#include "../crypto/crc32.c" + +int main(int argc, char *argv[]) +{ + loff_t start = 0, size = ~0; + ulong crc = 0, total = 0; + char *filename = NULL; + int i; + + if (!filename && argc < 2) { + printf("usage: %s filename\n", argv[0]); + exit(1); + } + + for (i = 1; i < argc; i++) { + filename = argv[i]; + if (file_crc(filename, start, size, &crc, &total) < 0) + exit(1); + printf("%08lx\t%s\n", crc, filename); + } + + exit(0); + +} |