+ index_file->file = fs_handle;
+ index_file->major = index_major;
+ index_file->minor = index_minor;
+ urcu_ref_init(&index_file->ref);
+
+ *file = index_file;
+ return LTTNG_TRACE_CHUNK_STATUS_OK;
+
+error:
+ if (fs_handle) {
+ ret = fs_handle_close(fs_handle);
+ if (ret < 0) {
+ PERROR("Failed to close file descriptor of index file");
+ }
+ }
+ lttng_trace_chunk_put(chunk);
+ free(index_file);
+ return chunk_status;
+}
+
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
+ struct lttng_trace_chunk *chunk,
+ const char *channel_path, const char *stream_name,
+ uint64_t stream_file_size, uint64_t stream_file_index,
+ uint32_t index_major, uint32_t index_minor,
+ bool unlink_existing_file, struct lttng_index_file **file)
+{
+ return _lttng_index_file_create_from_trace_chunk(chunk, channel_path,
+ stream_name, stream_file_size, stream_file_index,
+ index_major, index_minor, unlink_existing_file,
+ WRITE_FILE_FLAGS, false, file);
+}
+
+enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
+ struct lttng_trace_chunk *chunk,
+ const char *channel_path, const char *stream_name,
+ uint64_t stream_file_size, uint64_t stream_file_index,
+ uint32_t index_major, uint32_t index_minor,
+ bool expect_no_file, struct lttng_index_file **file)
+{
+ return _lttng_index_file_create_from_trace_chunk(chunk, channel_path,
+ stream_name, stream_file_size, stream_file_index,
+ index_major, index_minor, false,
+ READ_ONLY_FILE_FLAGS, expect_no_file, file);