From 8fc9c9e8e6522371512213696386d8d4cc8fafb0 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Wed, 20 May 2026 07:54:51 +0200 Subject: [PATCH] next dos83 fixes --- src/connect.c | 82 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/src/connect.c b/src/connect.c index c69085d..03c1813 100644 --- a/src/connect.c +++ b/src/connect.c @@ -596,27 +596,41 @@ static int func_search_entry(NW_PATH *nwpath, int attrib, while ((dirbuff = readdir(f)) != (struct dirent*)NULL){ okflag = 0; if (dirbuff->d_ino) { - uint8 *name=(uint8*)(dirbuff->d_name); - uint8 dname[256]; - xstrcpy(dname, name); - unix2doscharset(dname); - okflag = (name[0] != '.' && - ( (!strcmp((char*)dname, (char*)entry)) - || fn_dos_match(dname, entry, soptions))); + uint8 *name = (uint8 *)(dirbuff->d_name); + uint8 dosname[DOS83_NAME_MAX + 1]; + + okflag = 0; + + if (name[0] != '.') { + okflag = dos83_match_name_in_dir(xkpath, + name, + entry, + soptions, + dosname, + sizeof(dosname)); + } + if (okflag) { *kpath = '\0'; - strmaxcpy(kpath, (char*)name, sizeof(xkpath) - (int)(kpath-xkpath) -1 ); + strmaxcpy(kpath, (char *)name, sizeof(xkpath) - (int)(kpath - xkpath) - 1); + if (!s_stat(xkpath, &(fs->statb), NULL)) { - okflag = ( ( ( (fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || ( ( (fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); - if (okflag){ - xstrcpy(nwpath->fn, (char*)dname); - XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); + okflag = ((((fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || (((fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); + + if (okflag) { + /* Return the DOS-visible alias instead of the raw long name. */ + xstrcpy(nwpath->fn, (char *)dosname); + XDPRINTF((5,0,"FOUND DOS alias=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); result = (*fs_func)(nwpath, fs); - if (result < 0) break; - else result=1; + if (result < 0) + break; + else + result = 1; } - } else okflag = 0; + } else { + okflag = 0; + } } XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); } /* if */ @@ -677,29 +691,37 @@ static int get_dir_entry(NW_PATH *nwpath, okflag = -0xff; (*sequence)++; if (dirbuff->d_ino) { - uint8 *name=(uint8*)(dirbuff->d_name); - uint8 dname[256]; - xstrcpy(dname, name); - unix2doscharset(dname); - okflag = ((name[0] != '.' && - ( (!strcmp((char*)dname, (char*)entry)) - || fn_dos_match(dname, entry, soptions)))) ? 0 : -0xff; + uint8 *name = (uint8 *)(dirbuff->d_name); + uint8 dosname[DOS83_NAME_MAX + 1]; + + okflag = -0xff; + + if (name[0] != '.') { + okflag = dos83_match_name_in_dir(xkpath, + name, + entry, + soptions, + dosname, + sizeof(dosname)) ? 0 : -0xff; + } + if (!okflag) { *kpath = '\0'; - strmaxcpy(kpath, (char*)name, sizeof(xkpath) - (int)(kpath-xkpath) -1); + strmaxcpy(kpath, (char *)name, sizeof(xkpath) - (int)(kpath - xkpath) - 1); if (!s_stat(xkpath, statb, NULL)) { - okflag = (( ( ( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || ( ( (statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10)))) + okflag = ((((statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || (((statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))) ? 0 : -0xff; if (!okflag){ - if ( (!no_search_trustee) || + if ((!no_search_trustee) || !tru_eff_rights_exists(volume, xkpath, statb, TRUSTEE_T)) { if (soptions & VOL_OPTION_IS_PIPE) { - statb->st_size = 0x70000000|(statb->st_mtime&0xfffffff); + statb->st_size = 0x70000000 | (statb->st_mtime & 0xfffffff); } - xstrcpy(nwpath->fn, (char*)dname); - XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); + /* Return the generated DOS-visible short name. */ + xstrcpy(nwpath->fn, (char *)dosname); + XDPRINTF((5,0,"FOUND DOS alias=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); break; /* ready */ } else okflag = -0xff;