+
+ seek_end = lseek(data->fds[plane], 0, SEEK_END);
+ if (seek_end == (off_t)(-1)) {
+ fprintf(stderr, "drv: lseek() failed with %s\n", strerror(errno));
+ goto destroy_bo;
+ }
+
+ lseek(data->fds[plane], 0, SEEK_SET);
+ if (plane == bo->num_planes - 1 || data->offsets[plane + 1] == 0)
+ bo->sizes[plane] = seek_end - data->offsets[plane];
+ else
+ bo->sizes[plane] = data->offsets[plane + 1] - data->offsets[plane];
+
+ if ((int64_t)bo->offsets[plane] + bo->sizes[plane] > seek_end) {
+ fprintf(stderr, "drv: buffer size is too large.\n");
+ goto destroy_bo;
+ }
+
+ bo->total_size += bo->sizes[plane];