|
|
int total_compressed = 0, total_uncompressed = 0; | int total_compressed = 0, total_uncompressed = 0; |
| |
int fd; | int fd; |
|
unsigned char* read_buffer_base; |
| |
/* superblock attributes */ | /* superblock attributes */ |
int noI = 0, noD = 0, check_data = 0, block_size = SQUASHFS_FILE_SIZE, block_log; | int noI = 0, noD = 0, check_data = 0, block_size = SQUASHFS_FILE_SIZE, block_log; |
|
|
return start_bytes; | return start_bytes; |
} | } |
| |
|
void setup_read_buffer(void* p) |
|
{ |
|
read_buffer_base = (unsigned char*) p; |
|
} |
| |
unsigned char *read_from_buffer(unsigned int *start, unsigned int avail_bytes) | unsigned char *read_from_buffer(unsigned int *start, unsigned int avail_bytes) |
{ | { |
unsigned char *v = (unsigned char *) *start; |
unsigned char *v = read_buffer_base + *start; |
*start += avail_bytes; | *start += avail_bytes; |
return v; | return v; |
} | } |
|
|
struct file_info *duplicate(unsigned char *(get_next_file_block)(unsigned int *, unsigned int), unsigned int file_start, int bytes, unsigned int **block_list, int *start, int blocks, struct fragment **fragment, char *frag_data, int frag_bytes) | struct file_info *duplicate(unsigned char *(get_next_file_block)(unsigned int *, unsigned int), unsigned int file_start, int bytes, unsigned int **block_list, int *start, int blocks, struct fragment **fragment, char *frag_data, int frag_bytes) |
{ | { |
unsigned short checksum = get_checksum(get_next_file_block, file_start, bytes); | unsigned short checksum = get_checksum(get_next_file_block, file_start, bytes); |
unsigned short fragment_checksum = get_checksum(read_from_buffer, (unsigned int) frag_data, frag_bytes); |
setup_read_buffer(frag_data); |
|
unsigned short fragment_checksum = get_checksum(read_from_buffer, 0, frag_bytes); |
struct file_info *dupl_ptr = bytes ? dupl[checksum] : frag_dups[fragment_checksum]; | struct file_info *dupl_ptr = bytes ? dupl[checksum] : frag_dups[fragment_checksum]; |
| |
| |
|
|
| |
close(file); | close(file); |
if(whole_file) { | if(whole_file) { |
if(duplicate_checking && (dupl_ptr = duplicate(read_from_buffer, (unsigned int) c_buffer, file_bytes, &block_listp, &start, blocks, &fragment, buff, frag_bytes)) == NULL) { |
setup_read_buffer(c_buffer); |
|
if(duplicate_checking && (dupl_ptr = duplicate(read_from_buffer, 0, file_bytes, &block_listp, &start, blocks, &fragment, buff, frag_bytes)) == NULL) { |
*duplicate_file = TRUE; | *duplicate_file = TRUE; |
goto wr_inode; | goto wr_inode; |
} | } |