Compare commits

...

2 Commits

Author SHA1 Message Date
Devin AI
e3d73314c4 Link fa pf_fat32 + pf_sector + pf_volume_apiadd + pf_buffering
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 18:51:31 +00:00
Devin AI
83a321373f fa-pf1: match RefreshFSINFO else-return diamond; fix .sdata/.sdata2 literal-member widths
- PFFAT_RefreshFSINFO: if(error2!=0){return error2}else{body} reproduces
  orig's beq->body;b->epilogue bail form (ndiff 0)
- PFPATH sig locals: pf_s8 sig[2] = "\x01\x02" yields 4B {1,2,0,0}
  .sdata2 blobs (all 3 fns now ndiff-0)
- pf_entry_iterator/pf_volume empty literals: "\0\0\0"/"\x20\0\0"
  for orig's 4B member widths (.sdata byte-identical)
- pf_volume: named default_volume_label + deleted_entry_mark globals
  decode orig's .data/.sdata2 layout; p_setvol 100% via else-return

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 18:50:45 +00:00
5 changed files with 32 additions and 29 deletions

View File

@@ -1699,17 +1699,17 @@ config.libs = [
Object(NonMatching, "fa/pf_fat.c"),
Object(NonMatching, "fa/pf_fat12.c"),
Object(NonMatching, "fa/pf_fat16.c"),
Object(NonMatching, "fa/pf_fat32.c"),
Object(Matching, "fa/pf_fat32.c"),
Object(Matching, "fa/pf_fatfs.c"),
Object(NonMatching, "fa/pf_file.c"),
Object(NonMatching, "fa/pf_path.c"),
Object(NonMatching, "fa/pf_sector.c"),
Object(Matching, "fa/pf_sector.c"),
Object(NonMatching, "fa/pf_volume.c"),
Object(NonMatching, "fa/pf_volume_apiadd.c"),
Object(Matching, "fa/pf_volume_apiadd.c"),
Object(NonMatching, "fa/pf_cp932.c"),
Object(Matching, "fa/pf_api_util.c"),
Object(Matching, "fa/pf_attach.c"),
Object(NonMatching, "fa/pf_buffering.c"),
Object(Matching, "fa/pf_buffering.c"),
Object(NonMatching, "fa/pf_cdelete.c"),
Object(NonMatching, "fa/pf_chdir.c"),
Object(NonMatching, "fa/pf_chdmod.c"),

View File

@@ -347,7 +347,7 @@ pf_s32 PFENT_ITER_DoGetEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLU
if (err != 0) {
return err;
}
if (PFSTR_StrNumChar(p_path, 1) == 1 && (PFSTR_StrNCmp(p_path, (pf_s8*)"\0", 2, 0, 1) == 0)) {
if (PFSTR_StrNumChar(p_path, 1) == 1 && (PFSTR_StrNCmp(p_path, (pf_s8*)"\0\0\0", 2, 0, 1) == 0)) {
return 0;
}
} else {
@@ -366,7 +366,7 @@ pf_s32 PFENT_ITER_DoGetEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLU
if (err != 0) {
return err;
}
if (no_look_last_token != 0 && (PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) == 0)) {
if (no_look_last_token != 0 && (PFSTR_StrNCmp(&token, (pf_s8*)"\0\0\0", 2, 0, 1) == 0)) {
break;
}
@@ -424,7 +424,7 @@ pf_s32 PFENT_ITER_DoGetEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLU
}
if ((p_ent->attr & 0x10) == 0 || p_ent->short_name[0] != '.') {
p_ent->path_len = (PFSTR_StrNumChar(&token, 1) + 1) + p_ent->path_len;
if ((PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) != 0)) {
if ((PFSTR_StrNCmp(&token, (pf_s8*)"\0\0\0", 2, 0, 1) != 0)) {
p_ent->path_len -= PFSTR_StrNumChar(&token, 2);
}
}
@@ -689,7 +689,7 @@ pf_s32 PFENT_ITER_FindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR*
if (PFSTR_StrNCmp(p_pattern, (pf_s8*)"\\", 1, 0, 1) == 0 || PFSTR_StrNCmp(p_pattern, (pf_s8*)"/", 1, 0, 1) == 0) {
err = PFENT_GetRootDir(p_iter->p_vol, p_ent);
if (err != 0) return err;
if (PFSTR_StrNumChar(p_pattern, 1) == 1 && PFSTR_StrNCmp(p_pattern, (pf_s8*)"\0", 2, 0, 1) == 0) return 0;
if (PFSTR_StrNumChar(p_pattern, 1) == 1 && PFSTR_StrNCmp(p_pattern, (pf_s8*)"\0\0\0", 2, 0, 1) == 0) return 0;
} else {
err = PFVOL_GetCurrentDir(p_iter->p_vol, p_ent);
if (err != 0) return err;

View File

@@ -1852,13 +1852,15 @@ s32 PFFAT_RefreshFSINFO(PF_VOLUME* volume)
s32 alreadyAllocated;
u32 completedBytes;
s32 error;
s32 error2;
error = 0;
if ((volume->fsi_flag & 4) != 0) {
error = PFCACHE_AllocateDataPage(volume, -1, &page,
&alreadyAllocated);
if (error != 0) { goto finished; }
{
error2 = PFCACHE_AllocateDataPage(volume, -1, &page,
&alreadyAllocated);
if (error2 != 0) {
return error2;
} else {
error = PFSEC_ReadData(
volume, page->p_buf, volume->bpb.fs_info_sector, 0,
volume->bpb.bytes_per_sector, &completedBytes, 0);

View File

@@ -1014,7 +1014,7 @@ void PFPATH_SetSearchPattern(pf_s8* p_buf_local, pf_u16* p_buf_unicode, PF_STR*
pf_u32 PFPATH_CheckExtShortNameSignature(PF_STR* p_str) {
pf_u32 result = 0;
pf_s8 sig[2] = {1, 2};
pf_s8 sig[2] = "\x01\x02";
if (PFSTR_StrNCmp(p_str, sig, 1, 0, 2) == 0) {
result = 1;
@@ -1027,7 +1027,7 @@ pf_u32 PFPATH_CheckExtShortName(PF_STR* p_str, pf_u32 target, pf_bool wildcard)
pf_s16 i;
pf_s16 num;
pf_bool is_wildcard = PF_FALSE;
pf_s8 sig[2] = {1, 2};
pf_s8 sig[2] = "\x01\x02";
pf_s8* p_c;
pf_u16* p_wc;
@@ -1035,7 +1035,7 @@ pf_u32 PFPATH_CheckExtShortName(PF_STR* p_str, pf_u32 target, pf_bool wildcard)
(PFSTR_StrNCmp(p_str, (pf_s8*)"?", target, 0, 1) == 0 &&
(PFSTR_StrNCmp(p_str, (pf_s8*)"?", target, 1, 1) == 0 || PFSTR_StrNCmp(p_str, (pf_s8*)"*", target, 0, 1) == 0)) ||
PFSTR_StrNCmp(p_str, (pf_s8*)"*", target, 0, 1) == 0) {
for (i = 2; i < 8 && PF_IS_PATH_SEPERATOR(p_str, target, i) == PF_FALSE && PFSTR_StrNCmp(p_str, (pf_s8*)" ", target, i, 1) != 0 &&
for (i = 2; i < 8 && PF_IS_PATH_SEPERATOR(p_str, target, i) == PF_FALSE && PFSTR_StrNCmp(p_str, (pf_s8*)"\x20\0\0", target, i, 1) != 0 &&
PF_IS_PATH_NOT_NULL(p_str, target, i);
i++) {
if (PFSTR_GetCodeMode(p_str) == 1) {
@@ -1059,7 +1059,7 @@ pf_u32 PFPATH_CheckExtShortName(PF_STR* p_str, pf_u32 target, pf_bool wildcard)
}
}
if (i == 8 || is_wildcard == PF_TRUE) {
if (PFSTR_StrNCmp(p_str, (pf_s8*)" ", target, i, 1) == 0 || PF_IS_PATH_SEPERATOR(p_str, target, i) == 0 ||
if (PFSTR_StrNCmp(p_str, (pf_s8*)"\x20\0\0", target, i, 1) == 0 || PF_IS_PATH_SEPERATOR(p_str, target, i) == 0 ||
PF_IS_PATH_NULL(p_str, target, i)) {
result = i;
}
@@ -1073,7 +1073,7 @@ pf_u32 PFPATH_GetExtShortNameIndex(PF_STR* p_str, pf_u32* p_index) {
pf_s16 i;
pf_s16 num;
pf_u32 index;
pf_s8 sig[2] = {1, 2};
pf_s8 sig[2] = "\x01\x02";
pf_s8* p_c;
pf_u16* p_wc;

View File

@@ -224,6 +224,9 @@ typedef struct PFVOL_SET {
PFVOL_SET pf_vol_set;
static s8 default_volume_label[12] = "NO NAME ";
static const u8 deleted_entry_mark[8] = {0xE5};
extern s32 PFDRV_mount(PFVOL_VOLUME* volume);
extern s32 PFDRV_unmount(PFVOL_VOLUME* volume, u32 mode);
extern s32 PFDRV_format(PFVOL_VOLUME* volume, const u8* format_options);
@@ -370,12 +373,7 @@ static inline s32 finalize_volume(PFVOL_VOLUME* volume) {
return 0;
}
static inline s32 copy_codeset(const PFVOL_CHARCODE* code_set) {
pf_vol_set.codeset.oem2unicode = code_set->oem2unicode;
pf_vol_set.codeset.unicode2oem = code_set->unicode2oem;
pf_vol_set.codeset.oem_char_width = code_set->oem_char_width;
pf_vol_set.codeset.is_oem_mb_char = code_set->is_oem_mb_char;
pf_vol_set.codeset.unicode_char_width = code_set->unicode_char_width;
pf_vol_set.codeset.is_unicode_mb_char = code_set->is_unicode_mb_char;
pf_vol_set.codeset = *code_set;
return 0;
}
s32 PFVOL_DoMountVolume(PFVOL_VOLUME* volume) {
@@ -500,7 +498,9 @@ s32 PFVOL_p_setvol(PFVOL_VOLUME* volume, const s8* label) {
s32 error;
error = PFENT_GetRootDir(volume, &root_entry);
if (error == 0) {
if (error != 0) {
return error;
} else {
PFFAT_InitFFD(&ffd, &hint, volume, &root_entry.start_cluster);
PFSTR_InitStr(&path, "*", 1);
PFSTR_SetLocalStr(&path, 0);
@@ -514,7 +514,7 @@ s32 PFVOL_p_setvol(PFVOL_VOLUME* volume, const s8* label) {
entry.start_cluster = 0;
}
} else {
PFSTR_InitStr(&path, "", 1);
PFSTR_InitStr(&path, "\0\0\0", 1);
PFSTR_SetLocalStr(&path, 0);
error = PFENT_allocateEntry(&entry, 1, &ffd, previous_cluster, &path);
if (error != 0) {
@@ -584,7 +584,7 @@ s32 PFVOL_p_rmvvol(PFVOL_VOLUME* volume) {
u32 logical_position;
u32 entry_position;
u32 processed;
u8 deleted = (u8)"\xE5"[0];
u8 deleted = deleted_entry_mark[0];
s32 error;
error = PFENT_GetRootDir(volume, &root_entry);
@@ -913,7 +913,7 @@ s32 PFVOL_getvol(s8 drive, PFVOL_VOLUME_INFO* volume_info) {
} else {
volume = &pf_vol_set.volumes[volume_index];
}
if (pf_memcmp(volume->label, "NO NAME ", 11) == 0) {
if (pf_memcmp(volume->label, default_volume_label, 11) == 0) {
pf_vol_set.last_error = 3;
volume->last_error = 3;
return 3;
@@ -945,7 +945,7 @@ s32 PFVOL_rmvvol(s8 drive) {
} else {
volume = &pf_vol_set.volumes[volume_index];
}
if (pf_memcmp(volume->label, "NO NAME ", 11) == 0) {
if (pf_memcmp(volume->label, default_volume_label, 11) == 0) {
pf_vol_set.last_error = 3;
volume->last_error = 3;
return 3;
@@ -956,7 +956,7 @@ s32 PFVOL_rmvvol(s8 drive) {
volume->last_error = error;
return error;
}
error = PFDRV_StoreVolumeLabelToBPB(volume, (const s8*)"NO NAME ");
error = PFDRV_StoreVolumeLabelToBPB(volume, default_volume_label);
if (error != 0) {
pf_vol_set.last_error = error;
volume->last_error = error;
@@ -1536,3 +1536,4 @@ s32 PFVOL_setencode(u32 mode) {
pf_vol_set.setting = pf_vol_set.setting & ~3 | mode;
return 0;
}