- off_t offset_in_mapping, file_size = ds_file->file->size;
-
- if (whence != CTF_MSG_ITER_SEEK_WHENCE_SET ||
- offset < 0 || offset > file_size) {
- BT_COMP_LOGE("Invalid medium seek request: whence=%d, offset=%jd, "
- "file-size=%jd", (int) whence, (intmax_t) offset,
- (intmax_t) file_size);
- ret = CTF_MSG_ITER_MEDIUM_STATUS_INVAL;
- goto end;
- }
-
- /* 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 ||
- offset >= ds_file->mmap_offset + ds_file->mmap_len) {
- int unmap_ret;
- 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,
- ds_file->mmap_len);
- unmap_ret = ds_file_munmap(ds_file);
- if (unmap_ret) {
- ret = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
- goto end;
- }
- goto map_requested_offset;
- } else {
- ds_file->request_offset = offset - ds_file->mmap_offset;
- goto test_end;
- }