Stop after reading TRAILER!!!

This commit is contained in:
topjohnwu 2017-03-16 06:46:19 +08:00
parent 529aa754f5
commit 09cd0468cf

View File

@ -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) {
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;