5#include "module_debug.h"
10 u64 sector_start = sector;
11 u16 count_left =
count;
13 while (count_left > 0) {
20 for (i=0; (u32)i<fragcount; i++) {
22 if (offset <= sector_start && (offset + f->
count) > sector_start) {
29 if ((u32)i == fragcount) {
30 M_PRINTF(
"%s: ERROR: fragment not found!\n", __FUNCTION__);
35 count_read = count_left;
36 if ((sector_start + count_read) > (offset + f->
count)) {
37 count_read = (offset + f->
count) - sector_start;
38 M_DEBUG(
"%s: clipping sectors %d -> %d\n", __FUNCTION__, count_left, count_read);
42 if (bd->read(bd, f->sector + (sector_start - offset), buffer, count_read) != count_read) {
43 M_PRINTF(
"%s: ERROR: read failed!\n", __FUNCTION__);
48 sector_start += count_read;
49 count_left -= count_read;
50 buffer = (u8*)buffer + (count_read * bd->sectorSize);
58 u64 sector_start = sector;
59 u16 count_left =
count;
61 while (count_left > 0) {
68 for (i=0; (u32)i<fragcount; i++) {
70 if (offset <= sector_start && (offset + f->
count) > sector_start) {
77 if ((u32)i == fragcount) {
78 M_PRINTF(
"%s: ERROR: fragment not found!\n", __FUNCTION__);
83 count_write = count_left;
84 if ((sector_start + count_write) > (offset + f->
count)) {
85 count_write = (offset + f->
count) - sector_start;
86 M_DEBUG(
"%s: clipping sectors %d -> %d\n", __FUNCTION__, count_left, count_write);
90 if (bd->write(bd, f->sector + (sector_start - offset), buffer, count_write) != count_write) {
91 M_PRINTF(
"%s: ERROR: write failed!\n", __FUNCTION__);
96 sector_start += count_write;
97 count_left -= count_write;
98 buffer = (u8*)buffer + (count_write * bd->sectorSize);
u32 count
start sector of fragmented bd/file
u32 count
start sector of fragmented bd/file