File src/fs/fat.cpp changed (mode: 100644) (index 9b2ff57..73d5fce) |
... |
... |
FAT::printFileContents(const DirectoryEntryFat32 &ent) const |
61 |
61 |
+ bpb.sectorsPerCluster*(currentCluster - 2); |
+ bpb.sectorsPerCluster*(currentCluster - 2); |
62 |
62 |
int sectorOffset = 0; |
int sectorOffset = 0; |
63 |
63 |
|
|
64 |
|
for (; size > 0; size -= 512) { |
|
|
64 |
|
while (size > 0) { |
65 |
65 |
hd.read28(sector + sectorOffset, buffer, 512); |
hd.read28(sector + sectorOffset, buffer, 512); |
66 |
66 |
|
|
67 |
67 |
buffer[size > 512 ? 512 : size] = '\0'; |
buffer[size > 512 ? 512 : size] = '\0'; |
68 |
68 |
kprint(reinterpret_cast<const char *>(buffer)); |
kprint(reinterpret_cast<const char *>(buffer)); |
69 |
69 |
|
|
70 |
|
if (++sectorOffset > bpb.sectorsPerCluster) { |
|
|
70 |
|
size -= 512; |
|
71 |
|
|
|
72 |
|
if (++sectorOffset == bpb.sectorsPerCluster) { |
71 |
73 |
break; |
break; |
72 |
74 |
} |
} |
73 |
75 |
} |
} |
74 |
76 |
|
|
75 |
|
std::uint8_t fat[513]; |
|
|
77 |
|
if (size <= 0) { |
|
78 |
|
break; |
|
79 |
|
} |
|
80 |
|
|
|
81 |
|
std::uint8_t fat[512]; |
76 |
82 |
std::uint32_t fatSector = currentCluster/(512/sizeof(std::uint32_t)); |
std::uint32_t fatSector = currentCluster/(512/sizeof(std::uint32_t)); |
77 |
83 |
hd.read28(fatStart + fatSector, fat, 512); |
hd.read28(fatStart + fatSector, fat, 512); |
78 |
|
std::uint32_t fatOffset = currentCluster%(512/sizeof(std::uint32_t)); |
|
|
84 |
|
std::uint32_t fatOffset = currentCluster%(512/sizeof(std::uint32_t))*4; |
79 |
85 |
|
|
80 |
86 |
currentCluster = fat[fatOffset + 3] & 0x0f; |
currentCluster = fat[fatOffset + 3] & 0x0f; |
81 |
87 |
currentCluster = (currentCluster << 8) | fat[fatOffset + 2]; |
currentCluster = (currentCluster << 8) | fat[fatOffset + 2]; |