aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sharp <dhsharp@google.com>2010-09-13 16:54:26 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-09-13 17:12:35 -0400
commit6c0133decc950e6d499260567f0a8482384a8df0 (patch)
tree93daae82640d59bdb36e27589f96e14d27f4fdc2
parentd2c4c0df03ec152ff76ab6870ca709119627150c (diff)
trace-cmd: Use lseek64 and off64_t in tracecmd_append_cpu_data().
lseek64 returns 64-bit, but was being truncated to int. Large offsets would cause the subsequent error checking to fail spuriously, leaving behind a bad trace.dat and a collection of trace.dat.cpuX files. Signed-off-by: David Sharp <dhsharp@google.com> LKML-Reference: <1284411266-30442-1-git-send-email-dhsharp@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-output.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/trace-output.c b/trace-output.c
index 89b3954..0730a1e 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -705,9 +705,9 @@ out_free:
705int tracecmd_append_cpu_data(struct tracecmd_output *handle, 705int tracecmd_append_cpu_data(struct tracecmd_output *handle,
706 int cpus, char * const *cpu_data_files) 706 int cpus, char * const *cpu_data_files)
707{ 707{
708 unsigned long long *offsets = NULL; 708 off64_t *offsets = NULL;
709 unsigned long long *sizes = NULL; 709 unsigned long long *sizes = NULL;
710 unsigned long long offset; 710 off64_t offset;
711 unsigned long long endian8; 711 unsigned long long endian8;
712 off64_t check_size; 712 off64_t check_size;
713 char *file; 713 char *file;
@@ -733,7 +733,7 @@ int tracecmd_append_cpu_data(struct tracecmd_output *handle,
733 if (!sizes) 733 if (!sizes)
734 goto out_free; 734 goto out_free;
735 735
736 offset = lseek(handle->fd, 0, SEEK_CUR); 736 offset = lseek64(handle->fd, 0, SEEK_CUR);
737 737
738 /* hold any extra data for data */ 738 /* hold any extra data for data */
739 offset += cpus * (16); 739 offset += cpus * (16);
@@ -761,8 +761,8 @@ int tracecmd_append_cpu_data(struct tracecmd_output *handle,
761 761
762 for (i = 0; i < cpus; i++) { 762 for (i = 0; i < cpus; i++) {
763 fprintf(stderr, "offset=%llx\n", offsets[i]); 763 fprintf(stderr, "offset=%llx\n", offsets[i]);
764 ret = lseek64(handle->fd, offsets[i], SEEK_SET); 764 offset = lseek64(handle->fd, offsets[i], SEEK_SET);
765 if (ret < 0) { 765 if (offset == (off64_t)-1) {
766 warning("could not seek to %lld\n", offsets[i]); 766 warning("could not seek to %lld\n", offsets[i]);
767 goto out_free; 767 goto out_free;
768 } 768 }