Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/ota_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,24 @@ void launch_apply(char *partition) {
jobs[job_count++].out = out;
total_operations += part.operations_size();


if (partition != NULL) {
return;
}
}
}
}

int ret_code = 0;

void* run_apply(void *a) {
section *queue = (section*)a;

FILE *f = fopen(args.update_file, "rb");

while (queue->part != NULL) {
apply_section(&update, queue, f);
while (queue->part != NULL && !ret_code) {
if (apply_section(&update, queue, f))
ret_code = 1;

queue++;
}
Expand Down Expand Up @@ -203,7 +208,7 @@ INIT_FUNC(apply) {
int ops_in_part = update.manifest.partitions(jobs[job].part_number).operations_size();
int ops_left = ops_in_part - used;
if (ops_left <= ops_needed) {
thread_queue[section_i].end = ops_in_part - 1;
thread_queue[section_i].end = ops_in_part;
job++;
used = 0;
ops_needed -= ops_left;
Expand Down Expand Up @@ -241,7 +246,7 @@ INIT_FUNC(apply) {
close(jobs[job].out);
}

return 0;
return ret_code;
}

INIT_FUNC(main) {
Expand Down
10 changes: 6 additions & 4 deletions src/payload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ char* get_src(int in, unsigned int *size,
return src;
}

void apply_section(payload *update, section *section, FILE *data_file) {
int apply_section(payload *update, section *section, FILE *data_file) {
int ret = 1;
const char* part_name = update->manifest.partitions(section->part->part_number).partition_name().data();
while (section->start < section->end) {
chromeos_update_engine::InstallOperation op = update->manifest.partitions(section->part->part_number).operations(section->start++);
Expand Down Expand Up @@ -180,14 +181,16 @@ void apply_section(payload *update, section *section, FILE *data_file) {
break;
default:
log_err(part_name, "Unknown Operation Type");
return;
goto end;
}

write_out(section->part->out, &op, output);

if (output != src && output != data) {
free(output);
}

ret = 0;
end:
if (data != 0) {
free(data);
Expand All @@ -196,6 +199,5 @@ void apply_section(payload *update, section *section, FILE *data_file) {
free(src);
}
}
return ret;
}


2 changes: 1 addition & 1 deletion src/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ char* output_buffer(const chromeos_update_engine::InstallOperation *op, unsigned
char* get_src(int in, unsigned int *size,
const chromeos_update_engine::InstallOperation *op);

void apply_section(payload *update, section *section, FILE *data_file);
int apply_section(payload *update, section *section, FILE *data_file);


#endif /* ifndef _H_PAYLOAD */