mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 11:00:25 +00:00
transfused: add trace logging error checking
This commit is contained in:
parent
71fa8711ec
commit
c830c22335
@ -118,11 +118,22 @@ void copy(copy_thread_state * copy_state) {
|
|||||||
int trace_fd;
|
int trace_fd;
|
||||||
char * trace_path;
|
char * trace_path;
|
||||||
|
|
||||||
// TODO: check for errors
|
if (asprintf(&trace_path, "/tmp/transfused.%ld.%s.%llu",
|
||||||
asprintf(&trace_path, "/tmp/transfused.%ld.%s.%llu",
|
connection, tag, message_id(buf)) == -1)
|
||||||
connection, tag, message_id(buf));
|
die(1, "", "Couldn't allocate trace packet path");
|
||||||
|
|
||||||
trace_fd = open(trace_path, O_WRONLY | O_CREAT, 0600);
|
trace_fd = open(trace_path, O_WRONLY | O_CREAT, 0600);
|
||||||
write(trace_fd, buf, read_count);
|
if (read_fd == -1)
|
||||||
|
die(1, "couldn't open trace packet path", "For %s, ", descr);
|
||||||
|
|
||||||
|
write_count = write(trace_fd, buf, read_count);
|
||||||
|
if (write_count == -1)
|
||||||
|
die(1, "", "copy %s trace: error writing %s: ", descr, trace_path);
|
||||||
|
|
||||||
|
if (write_count != read_count)
|
||||||
|
die(1, NULL, "copy %s trace: read %d but only write %d\n",
|
||||||
|
descr, read_count, write_count);
|
||||||
|
|
||||||
close(trace_fd);
|
close(trace_fd);
|
||||||
free(trace_path);
|
free(trace_path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user