forked from barebox/barebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbareboxcrc32.c
46 lines (36 loc) · 885 Bytes
/
bareboxcrc32.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: 2013 Michael Grzeschik <mgr@pengutronix.de>
/* bareboxcrc32.c - generate crc32 checksum in little endian */
#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[])
{
ulong 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);
}