aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-cmd.h4
-rw-r--r--trace-input.c26
-rw-r--r--trace-read.c6
3 files changed, 30 insertions, 6 deletions
diff --git a/trace-cmd.h b/trace-cmd.h
index 371d616..c5a3163 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -44,7 +44,9 @@ char *tracecmd_find_tracing_dir(void);
44 44
45/* --- Opening and Reading the trace.dat file --- */ 45/* --- Opening and Reading the trace.dat file --- */
46 46
47struct tracecmd_input *tracecmd_open(int fd); 47struct tracecmd_input *tracecmd_open(const char *file);
48struct tracecmd_input *tracecmd_open_fd(int fd);
49void tracecmd_close(struct tracecmd_input *handle);
48int tracecmd_read_headers(struct tracecmd_input *handle); 50int tracecmd_read_headers(struct tracecmd_input *handle);
49int tracecmd_long_size(struct tracecmd_input *handle); 51int tracecmd_long_size(struct tracecmd_input *handle);
50int tracecmd_page_size(struct tracecmd_input *handle); 52int tracecmd_page_size(struct tracecmd_input *handle);
diff --git a/trace-input.c b/trace-input.c
index 80de3cf..ee9177f 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -1316,10 +1316,10 @@ void tracecmd_print_events(struct tracecmd_input *handle)
1316} 1316}
1317 1317
1318/** 1318/**
1319 * tracecmd_open - create a tracecmd_handle from the trace.dat file descriptor 1319 * tracecmd_open_fd - create a tracecmd_handle from the trace.dat file descriptor
1320 * @fd: the file descriptor for the trace.dat file 1320 * @fd: the file descriptor for the trace.dat file
1321 */ 1321 */
1322struct tracecmd_input *tracecmd_open(int fd) 1322struct tracecmd_input *tracecmd_open_fd(int fd)
1323{ 1323{
1324 struct tracecmd_input *handle; 1324 struct tracecmd_input *handle;
1325 char test[] = { 23, 8, 68 }; 1325 char test[] = { 23, 8, 68 };
@@ -1377,6 +1377,28 @@ struct tracecmd_input *tracecmd_open(int fd)
1377} 1377}
1378 1378
1379/** 1379/**
1380 * tracecmd_open - create a tracecmd_handle from a given file
1381 * @file: the file name of the file that is of tracecmd data type.
1382 */
1383struct tracecmd_input *tracecmd_open(const char *file)
1384{
1385 int fd;
1386
1387 fd = open(file, O_RDONLY);
1388 if (fd < 0)
1389 return NULL;
1390
1391 return tracecmd_open_fd(fd);
1392}
1393
1394void tracecmd_close(struct tracecmd_input *handle)
1395{
1396 /* TODO FREE EVERYTHING!!! %%%% MEMORY LEAK!!! %%%% */
1397 close(handle->fd);
1398 free(handle);
1399}
1400
1401/**
1380 * tracecmd_long_size - return the size of "long" for the arch 1402 * tracecmd_long_size - return the size of "long" for the arch
1381 * @handle: input handle for the trace.dat file 1403 * @handle: input handle for the trace.dat file
1382 */ 1404 */
diff --git a/trace-read.c b/trace-read.c
index b6b233c..e875189 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -38,8 +38,8 @@
38 38
39#include "trace-local.h" 39#include "trace-local.h"
40 40
41unsigned int page_size; 41static unsigned int page_size;
42int input_fd; 42static int input_fd;
43const char *input_file = "trace.dat"; 43const char *input_file = "trace.dat";
44 44
45static int filter_cpu = -1; 45static int filter_cpu = -1;
@@ -276,7 +276,7 @@ struct tracecmd_input *read_trace_header(void)
276 if (input_fd < 0) 276 if (input_fd < 0)
277 die("opening '%s'\n", input_file); 277 die("opening '%s'\n", input_file);
278 278
279 return tracecmd_open(input_fd); 279 return tracecmd_open_fd(input_fd);
280} 280}
281 281
282void trace_report (int argc, char **argv) 282void trace_report (int argc, char **argv)