- /* If there is no current mapping, map the right file directly. */
- if (!ds_file->mmap_addr) {
- goto map_requested_offset;
- }
-
- /*
- * Determine whether or not the destination is contained within the
- * current mapping.
- */
- if (offset < ds_file->mmap_offset_in_file ||
- offset >= ds_file->mmap_offset_in_file + ds_file->mmap_len) {
- BT_COMP_LOGD("Medium seek request cannot be accomodated by the current "
- "file mapping: offset=%jd, mmap-offset=%jd, "
- "mmap-len=%zu", (intmax_t) offset, (intmax_t) ds_file->mmap_offset_in_file,
- ds_file->mmap_len);
- status = ds_file_munmap(ds_file);
- if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
- goto end;
- }
- goto map_requested_offset;
- } else {
- ds_file->request_offset_in_mapping = offset - ds_file->mmap_offset_in_file;
- status = CTF_MSG_ITER_MEDIUM_STATUS_OK;
- goto end;
- }
-
-map_requested_offset:
- offset_in_mapping = offset %
- bt_mmap_get_offset_align_size(ds_file->log_level);
-
- ds_file->mmap_offset_in_file = offset - offset_in_mapping;
- ds_file->request_offset_in_mapping = offset_in_mapping;
- status = ds_file_mmap_next(ds_file);
- if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
- goto end;
- }
-
- status = CTF_MSG_ITER_MEDIUM_STATUS_OK;
-end:
- return status;