From 8ac26c40eb80835d624f7e142cc368d17c256599 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Thu, 2 Jul 2020 02:31:27 +0200 Subject: [PATCH] Fix fat32 bug --- qloader2-install.c | 2 +- qloader2.bin | Bin 32768 -> 32768 bytes src/fs/fat32.c | 12 +----------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/qloader2-install.c b/qloader2-install.c index bc686797..98d7af39 100644 --- a/qloader2-install.c +++ b/qloader2-install.c @@ -6,7 +6,7 @@ int main(int argc, char *argv[]) { if (argc < 3) { - printf("Usage: %s [qloader2 start sector]\n", argv[0]); + printf("Usage: %s [stage2 start sector]\n", argv[0]); return 1; } diff --git a/qloader2.bin b/qloader2.bin index c5bbae0d3ef6d0915a35991ac0326a1e8e906379..e3e6e250d869f060ed96b02fa7b9f9159d538941 100644 GIT binary patch delta 6540 zcmZ`-3tUv?w%>chzyO1Ld<-Ch4DXjO5=252g+UCc4ah_AQRgPV9h%vdse4KeW5XER z-I%{VE${J>M0U;W9*a~|^o*j6ogR{Te+R_}Am+xg4n~ogweMQrfO)IC`OUZ20uTEjAS1Jdzd4DMA{lTgopTe=Wfvo1YUfHz+9}63J%Ga_@NvZBBj7E2U2JFgn-q2W_{0R#gGs zU*lUWN64~NhN)c2AF>UA3}WODZTSW$wnGq~M*SSnFDnN<^UH|-mtp;js1E~uc?IY_ z@9R0B(0&W*)ftegMU?>1-UoOM1NI@{>I`z;tCs7ZNs7Ifj(38{r7bKH#35APPN8`@ z-f)5Z!@Go?K#bZn?yna}rFLq-iVFZ(77Rld_(L9o7>fKDvP&E7U4Z0`Wb&ytIpARk zFv($G{$1tLWlP!`H$kp87(^1_6CNW1-SXzEeoTYDJySJW6)r>F=*O4`+N>EXLC4hS z08f_q1g20ZWAS6!8DoRMS{+=*E-*9?I5p@IpO0OKoEkJ^fpNVDGxaCHE2-}Kc}V~ z+QsnepARr=#^XRTHNH+w0}vRq?2lm_-36p{Ch6P{gXvUNt7$?+ad9GLT{*usP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@kez%%7C^jiU$_2%NDczf$X5D9bG$| zJ9>6VJ37jQq%AFFV$!yjvb|-?%2t#uFDofqT2@-N1c+N&?w+9rhD2T@N3$bGY-wTX z@P{H=+tPSFyM@+^?Y_lTUxF?2;{Y5`D~kEii1Y#C@=r)bxEEkZPulr~3yu8BOQbs| zY2Ne5c-zPD6k~zxM9MCpEGaP-OI|pe?}M9A<|}|PBeyx8@`odVuY{tIPF|L&*`{$B{pMi{7s^yUe-bo2s=`7U z<*%Xs0iS-Z$7#E5mIJ?m@WoT&VvK)>) zoTao^b_#bUa}xjBFSr(8NWfLrqj)=bxq1vftPycnQm`j)sEpE`9$1b0K>rm7Gkgv# z|Br_;zx049u7^;hyzd7+!9Nz|s5wr`y9lmU4TS(n9BMak0rKrqen04z>&hv+`9!gF z6hZ?jD{0Er&f(}w$${)(*0OQlbdm-3Pqe?I8ZD7_6;=c`-!q?Lf-nJ(w36dVdJs2I$e zwCOy0bc>K??W|Z;MrS z2Y$sZEnUo8NlX4Zx`Cw3jijB#Fn0oc=Wm!>0^jl<%^j^803CM>^kF{iD*0~iEH?2f z5IW(w#7t*iC9@x!r}_wHZl9+cxOY9;CHJAJF4FYaBT5Mtn&uzBO8Op499;^Em|3G# zfa${ZxgK=zD5#D&NtK;RqJ1dhBPu7`m)TqDMUy6iQeCmsGb2BPwQxK8HdfzMYW zqYfA@MF->oAD5zY5Q6Fds|#R$Kbi7)tPTZet48Lc|6L#~-RZ<-wy#(7{~)Hvb+9y1A-xK@b^yPbCL4-5Cw=z zzVu6SeZgqU3GnPvoE{8IG$O2bRV~3o2yP=ws ztne)+R#XdF2SLcC_y9(H8V<M0r>m>%0UeMx9%8D@B1^j-sWzvxr@I*{EJdT z?{-ksgf%d5{F)AuS)`-O8cU0=sShidden_sectors = bpb.hidden_sectors_count; context->sectors_per_fat = bpb.sectors_per_fat_32; context->root_directory_cluster = bpb.root_directory_cluster; - context->fat_start_lba = bpb.reserved_sectors + bpb.hidden_sectors_count; + context->fat_start_lba = bpb.reserved_sectors; context->data_start_lba = context->fat_start_lba + bpb.fats_count * bpb.sectors_per_fat_32; return 0; @@ -148,13 +148,11 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e uint32_t current_cluster_number = directory->cluster_num_high << 16 | directory->cluster_num_low; char current_lfn[FAT32_LFN_MAX_FILENAME_LENGTH] = {0}; - bool has_lfn = false; do { for (size_t sector_in_cluster = 0; sector_in_cluster < context->sectors_per_cluster; sector_in_cluster++) { struct fat32_directory_entry directory_entries[FAT32_SECTOR_SIZE / sizeof(struct fat32_directory_entry)]; error = fat32_load_fat_cluster_to_memory(context, current_cluster_number, directory_entries, sector_in_cluster * FAT32_SECTOR_SIZE, sizeof(directory_entries)); - if (error != 0) { return error; } @@ -166,8 +164,6 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e } if (directory_entries[i].attribute == FAT32_LFN_ATTRIBUTE) { - has_lfn = true; - struct fat32_lfn_entry* lfn = (struct fat32_lfn_entry*) &directory_entries[i]; if (lfn->sequence_number & 0b01000000) { @@ -184,9 +180,7 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e fat32_lfncpy(current_lfn + lfn_index + 05, lfn->name2, 6); fat32_lfncpy(current_lfn + lfn_index + 11, lfn->name3, 2); continue; - } - if (has_lfn) { // remove trailing spaces for (int j = SIZEOF_ARRAY(current_lfn) - 2; j >= -1; j--) { if (j == -1 || current_lfn[j] != ' ') { @@ -194,9 +188,7 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e break; } } - } - if (has_lfn) { if (!strcmp(current_lfn, name)) { *file = directory_entries[i]; return 0; @@ -209,8 +201,6 @@ static int fat32_open_in(struct fat32_context* context, struct fat32_directory_e return 0; } } - - has_lfn = false; } }