aboutsummaryrefslogtreecommitdiffstats
path: root/trace-output.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-output.c')
-rw-r--r--trace-output.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/trace-output.c b/trace-output.c
index a59099d..a45265d 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -520,8 +520,8 @@ static int read_ftrace_printk(struct tracecmd_output *handle)
520 return 0; 520 return 0;
521} 521}
522 522
523static struct tracecmd_output *create_file(const char *output_file, int cpus, 523static struct tracecmd_output *
524 struct tracecmd_input *ihandle) 524create_file_fd(int fd, int cpus, struct tracecmd_input *ihandle)
525{ 525{
526 struct tracecmd_output *handle; 526 struct tracecmd_output *handle;
527 unsigned long long endian8; 527 unsigned long long endian8;
@@ -539,9 +539,7 @@ static struct tracecmd_output *create_file(const char *output_file, int cpus,
539 return NULL; 539 return NULL;
540 memset(handle, 0, sizeof(*handle)); 540 memset(handle, 0, sizeof(*handle));
541 541
542 handle->fd = open(output_file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); 542 handle->fd = fd;
543 if (handle->fd < 0)
544 goto out_free;
545 543
546 buf[0] = 23; 544 buf[0] = 23;
547 buf[1] = 8; 545 buf[1] = 8;
@@ -631,6 +629,25 @@ static struct tracecmd_output *create_file(const char *output_file, int cpus,
631 return NULL; 629 return NULL;
632} 630}
633 631
632static struct tracecmd_output *create_file(const char *output_file, int cpus,
633 struct tracecmd_input *ihandle)
634{
635 struct tracecmd_output *handle;
636 int fd;
637
638 fd = open(output_file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
639 if (fd < 0)
640 return NULL;
641
642 handle = create_file_fd(fd, cpus, ihandle);
643 if (!handle) {
644 close(fd);
645 unlink(output_file);
646 }
647
648 return handle;
649}
650
634struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus) 651struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus)
635{ 652{
636 struct tracecmd_output *handle; 653 struct tracecmd_output *handle;
@@ -760,6 +777,18 @@ struct tracecmd_output *tracecmd_create_file(const char *output_file,
760 return handle; 777 return handle;
761} 778}
762 779
780struct tracecmd_output *
781tracecmd_create_init_fd(int fd, int cpus)
782{
783 struct tracecmd_output *handle;
784
785 handle = create_file_fd(fd, cpus, NULL);
786 if (!handle)
787 return NULL;
788
789 return handle;
790}
791
763/** 792/**
764 * tracecmd_copy - copy the headers of one trace.dat file for another 793 * tracecmd_copy - copy the headers of one trace.dat file for another
765 * @ihandle: input handle of the trace.dat file to copy 794 * @ihandle: input handle of the trace.dat file to copy