2 * BabelTrace - Common Trace Format (CTF)
6 * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/format.h>
20 #include <babeltrace/ctf/types.h>
21 #include <babeltrace/ctf/metadata.h>
24 #include <sys/types.h>
29 struct trace_descriptor
{
30 struct ctf_trace ctf_trace
;
33 struct trace_descriptor
*ctf_open_trace(const char *path
, int flags
);
34 void ctf_close_trace(struct trace_descriptor
*descriptor
);
36 static struct format ctf_format
= {
37 .uint_read
= ctf_uint_read
,
38 .int_read
= ctf_int_read
,
39 .uint_write
= ctf_uint_write
,
40 .int_write
= ctf_int_write
,
41 .double_read
= ctf_double_read
,
42 .double_write
= ctf_double_write
,
43 .float_copy
= ctf_float_copy
,
44 .string_copy
= ctf_string_copy
,
45 .string_read
= ctf_string_read
,
46 .string_write
= ctf_string_write
,
47 .string_free_temp
= ctf_string_free_temp
,
48 .enum_read
= ctf_enum_read
,
49 .enum_write
= ctf_enum_write
,
50 .struct_begin
= ctf_struct_begin
,
51 .struct_end
= ctf_struct_end
,
52 .variant_begin
= ctf_variant_begin
,
53 .variant_end
= ctf_variant_end
,
54 .array_begin
= ctf_array_begin
,
55 .array_end
= ctf_array_end
,
56 .sequence_begin
= ctf_sequence_begin
,
57 .sequence_end
= ctf_sequence_end
,
58 .open_trace
= ctf_open_trace
,
59 .close_trace
= ctf_close_trace
,
63 int ctf_open_trace_read(struct trace_descriptor
*td
, const char *path
, int flags
)
67 td
->ctf_trace
.flags
= flags
;
69 /* Open trace directory */
70 td
->ctf_trace
.dir
= opendir(path
);
71 if (!td
->ctf_trace
.dir
) {
72 fprintf(stdout
, "Unable to open trace directory.\n");
80 * Open each stream: for each file, try to open, check magic
81 * number, and get the stream ID to add to the right location in
84 * Keep the metadata file separate.
90 * Use the metadata file to populate the trace metadata.
100 int ctf_open_trace_write(struct trace_descriptor
*td
, const char *path
, int flags
)
104 ret
= mkdir(path
, S_IRWXU
|S_IRWXG
);
111 struct trace_descriptor
*ctf_open_trace(const char *path
, int flags
)
113 struct trace_descriptor
*td
;
116 td
= g_new(struct trace_descriptor
, 1);
120 ret
= ctf_open_trace_read(td
, path
, flags
);
125 ret
= ctf_open_trace_write(td
, path
, flags
);
130 fprintf(stdout
, "Incorrect open flags.\n");
140 void ctf_close_trace(struct trace_descriptor
*td
)
142 closedir(td
->ctf_trace
.dir
);
146 void __attribute__((constructor
)) ctf_init(void)
150 ctf_format
.name
= g_quark_from_static_string("ctf");
151 ret
= bt_register_format(&ctf_format
);
This page took 0.04752 seconds and 5 git commands to generate.