+
+enum bt_cb_ret handle_sys_open(struct bt_ctf_event *call_data,
+ void *private_data)
+{
+
+ struct processtop *tmp;
+ struct definition *scope;
+ unsigned long timestamp;
+ uint64_t cpu_id;
+ char *comm;
+ int64_t tid;
+ char *file;
+
+ timestamp = bt_ctf_get_timestamp(call_data);
+ if (timestamp == -1ULL)
+ goto error;
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_STREAM_EVENT_CONTEXT);
+ comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
+ scope, "_procname"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing procname context info\n");
+ goto error;
+ }
+
+ tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_tid"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing tid context info\n");
+ goto error;
+ }
+
+ cpu_id = get_cpu_id(call_data);
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ file = bt_ctf_get_string(bt_ctf_get_field(call_data,
+ scope, "_filename"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing fd context info\n");
+ goto error;
+ }
+
+ tmp = get_proc(<tngtop, tid, comm, timestamp);
+ tmp->syscall_info = create_syscall_info(__NR_open, cpu_id, tid, -1);
+
+ tmp->files_history = create_file(tmp->files_history, file);
+
+ return BT_CB_OK;
+
+error:
+ return BT_CB_ERROR_STOP;
+}
+
+
+enum bt_cb_ret handle_sys_close(struct bt_ctf_event *call_data,
+ void *private_data)
+{
+ struct definition *scope;
+ unsigned long timestamp;
+ int64_t tid;
+ struct processtop *tmp;
+ char *comm;
+ int fd;
+
+ timestamp = bt_ctf_get_timestamp(call_data);
+ if (timestamp == -1ULL)
+ goto error;
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_STREAM_EVENT_CONTEXT);
+ comm = bt_ctf_get_char_array(bt_ctf_get_field(call_data,
+ scope, "_procname"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing procname context info\n");
+ goto error;
+ }
+
+ tid = bt_ctf_get_int64(bt_ctf_get_field(call_data,
+ scope, "_tid"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing tid context info\n");
+ goto error;
+ }
+
+ scope = bt_ctf_get_top_level_scope(call_data,
+ BT_EVENT_FIELDS);
+ fd = bt_ctf_get_uint64(bt_ctf_get_field(call_data,
+ scope, "_fd"));
+ if (bt_ctf_field_get_error()) {
+ fprintf(stderr, "Missing fd context info\n");
+ goto error;
+ }
+
+ tmp = get_proc(<tngtop, tid, comm, timestamp);
+ close_file(tmp, fd);
+
+ return BT_CB_OK;
+
+error:
+ return BT_CB_ERROR_STOP;
+}