diff options
Diffstat (limited to 'trace-record.c')
-rw-r--r-- | trace-record.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/trace-record.c b/trace-record.c index 8317320..cdfc857 100644 --- a/trace-record.c +++ b/trace-record.c | |||
@@ -56,7 +56,7 @@ void tracecmd_free_recorder(struct tracecmd_recorder *recorder) | |||
56 | free(recorder); | 56 | free(recorder); |
57 | } | 57 | } |
58 | 58 | ||
59 | struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu) | 59 | struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu) |
60 | { | 60 | { |
61 | struct tracecmd_recorder *recorder; | 61 | struct tracecmd_recorder *recorder; |
62 | char *tracing = NULL; | 62 | char *tracing = NULL; |
@@ -76,9 +76,7 @@ struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu) | |||
76 | 76 | ||
77 | recorder->page_size = getpagesize(); | 77 | recorder->page_size = getpagesize(); |
78 | 78 | ||
79 | recorder->fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); | 79 | recorder->fd = fd; |
80 | if (recorder->fd < 0) | ||
81 | goto out_free; | ||
82 | 80 | ||
83 | tracing = tracecmd_find_tracing_dir(); | 81 | tracing = tracecmd_find_tracing_dir(); |
84 | if (!tracing) { | 82 | if (!tracing) { |
@@ -112,6 +110,24 @@ struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu) | |||
112 | return NULL; | 110 | return NULL; |
113 | } | 111 | } |
114 | 112 | ||
113 | struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu) | ||
114 | { | ||
115 | struct tracecmd_recorder *recorder; | ||
116 | int fd; | ||
117 | |||
118 | fd = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); | ||
119 | if (recorder->fd < 0) | ||
120 | return NULL; | ||
121 | |||
122 | recorder = tracecmd_create_recorder_fd(fd, cpu); | ||
123 | if (!recorder) { | ||
124 | close(fd); | ||
125 | unlink(file); | ||
126 | } | ||
127 | |||
128 | return recorder; | ||
129 | } | ||
130 | |||
115 | int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long sleep) | 131 | int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long sleep) |
116 | { | 132 | { |
117 | struct timespec req; | 133 | struct timespec req; |