+static int st_write_event_mapping(void)
+{
+ uint64_t type = TRACE_RECORD_TYPE_MAPPING;
+ TraceEventIter iter;
+ TraceEvent *ev;
+
+ trace_event_iter_init(&iter, NULL);
+ while ((ev = trace_event_iter_next(&iter)) != NULL) {
+ uint64_t id = trace_event_get_id(ev);
+ const char *name = trace_event_get_name(ev);
+ uint32_t len = strlen(name);
+ if (fwrite(&type, sizeof(type), 1, trace_fp) != 1 ||
+ fwrite(&id, sizeof(id), 1, trace_fp) != 1 ||
+ fwrite(&len, sizeof(len), 1, trace_fp) != 1 ||
+ fwrite(name, len, 1, trace_fp) != 1) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+