4#include "module_debug.h"
9 u64 sector_start = sector;
10 u16 count_left =
count;
12 while (count_left > 0) {
19 for (i=0; (u32)i<fragcount; i++) {
21 if (offset <= sector_start && (offset + f->
count) > sector_start) {
28 if ((u32)i == fragcount) {
29 M_PRINTF(
"%s: ERROR: fragment not found!\n", __FUNCTION__);
34 count_read = count_left;
35 if ((sector_start + count_read) > (offset + f->
count)) {
36 count_read = (offset + f->
count) - sector_start;
37 M_DEBUG(
"%s: clipping sectors %d -> %d\n", __FUNCTION__, count_left, count_read);
41 if (bd->read(bd, f->sector + (sector_start - offset), buffer, count_read) != count_read) {
42 M_PRINTF(
"%s: ERROR: read failed!\n", __FUNCTION__);
47 sector_start += count_read;
48 count_left -= count_read;
49 buffer = (u8*)buffer + (count_read * bd->sectorSize);
57 u64 sector_start = sector;
58 u16 count_left =
count;
60 while (count_left > 0) {
67 for (i=0; (u32)i<fragcount; i++) {
69 if (offset <= sector_start && (offset + f->
count) > sector_start) {
76 if ((u32)i == fragcount) {
77 M_PRINTF(
"%s: ERROR: fragment not found!\n", __FUNCTION__);
82 count_write = count_left;
83 if ((sector_start + count_write) > (offset + f->
count)) {
84 count_write = (offset + f->
count) - sector_start;
85 M_DEBUG(
"%s: clipping sectors %d -> %d\n", __FUNCTION__, count_left, count_write);
89 if (bd->write(bd, f->sector + (sector_start - offset), buffer, count_write) != count_write) {
90 M_PRINTF(
"%s: ERROR: write failed!\n", __FUNCTION__);
95 sector_start += count_write;
96 count_left -= count_write;
97 buffer = (u8*)buffer + (count_write * bd->sectorSize);
u32 count
start sector of fragmented bd/file
u32 count
start sector of fragmented bd/file