Commit 09cd0468 authored by topjohnwu's avatar topjohnwu

Stop after reading TRAILER!!!

parent 529aa754
...@@ -84,10 +84,14 @@ static void parse_cpio(const char *filename, vector *v) { ...@@ -84,10 +84,14 @@ static void parse_cpio(const char *filename, vector *v) {
f->filename = malloc(f->namesize); f->filename = malloc(f->namesize);
read(fd, f->filename, f->namesize); read(fd, f->filename, f->namesize);
file_align(fd, 4, 0); file_align(fd, 4, 0);
if (strcmp(f->filename, "TRAILER!!!") == 0 || strcmp(f->filename, ".") == 0) { if (strcmp(f->filename, ".") == 0 || strcmp(f->filename, "..") == 0) {
cpio_free(f); cpio_free(f);
continue; continue;
} }
if (strcmp(f->filename, "TRAILER!!!") == 0) {
cpio_free(f);
break;
}
if (f->filesize) { if (f->filesize) {
f->data = malloc(f->filesize); f->data = malloc(f->filesize);
read(fd, f->data, f->filesize); read(fd, f->data, f->filesize);
...@@ -326,15 +330,12 @@ static void cpio_backup(const char *orig, vector *v) { ...@@ -326,15 +330,12 @@ static void cpio_backup(const char *orig, vector *v) {
doBak = 1; doBak = 1;
printf("Entry [%s] is missing\n", m->filename); printf("Entry [%s] is missing\n", m->filename);
} else if (res == 0) { } else if (res == 0) {
// Do SHA1 checksum to check if file is identical
++i; ++j; ++i; ++j;
SHA1(chk1, m->data, m->filesize); if (m->filesize == n->filesize && memcmp(m->data, n->data, m->filesize) == 0)
SHA1(chk2, n->data, n->filesize); continue;
if (strcmp(chk1, chk2) != 0) { // Not the same!
// Not the same! doBak = 1;
doBak = 1; printf("Entry [%s] missmatch\n", m->filename);
printf("Entry [%s] checksum missmatch\n", m->filename);
}
} else { } else {
// Someting new in ramdisk, record in rem // Someting new in ramdisk, record in rem
++j; ++j;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment