From f2fb0a39894bf2f34d56e40de530d99f89605389 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Wed, 20 May 2026 12:58:50 +0200 Subject: [PATCH] namespace hex57 detial debug sub 6 detail --- src/namspace.c | 200 ++++++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 87 deletions(-) diff --git a/src/namspace.c b/src/namspace.c index a6a0191..625c476 100644 --- a/src/namspace.c +++ b/src/namspace.c @@ -45,7 +45,6 @@ #include "unxfile.h" #include "namspace.h" #include "nameos2.h" -#include "namedos.h" #if WITH_NAME_SPACE_CALLS @@ -907,48 +906,48 @@ static int build_base(int namespace, return(result); } -/* - * Build the DOS-visible short name for one namespace directory entry. - * - * This wrapper delegates all DOS short-name generation to dosmangle.c so - * that DOS namespace listings use the same naming rules as DOS path lookup - * and DOS wildcard matching. - */ static int build_dos_name(DIR_BASE_ENTRY *e, uint8 *fname, int size_fname) { - char dir_unix[1024]; - char *slash; - uint8 *unixname; - int options; - - if (!e || !fname || size_fname <= 0) - return 0; - - options = get_volume_options(e->nwpath.volume); - - /* - * Convert the full entry path to Unix form, then strip the last component. - * dosmangle.c uses the containing directory to check for alias collisions. - */ - unixname = alloc_nwpath2unix(&(e->nwpath), 2); - if (!unixname) - return 0; - - strncpy(dir_unix, (char *)unixname, sizeof(dir_unix) - 1); - dir_unix[sizeof(dir_unix) - 1] = '\0'; - xfree(unixname); - - slash = strrchr(dir_unix, '/'); - if (slash) - *slash = '\0'; - else - strcpy(dir_unix, "."); - - return dos83_build_name_in_dir(dir_unix, - e->nwpath.fn, - fname, - size_fname, - options); + uint8 *ss=e->nwpath.fn; + int len=0; + int pf=0; + int is_ok=1; + int options=get_volume_options(e->nwpath.volume); + for (; *ss; ss++){ + if (*ss == '.') { + if (pf++) { /* no 2. point */ + is_ok=0; + break; + } + len=0; + } else { + ++len; + if ((pf && len > 3) || len > 8) { + is_ok=0; + break; + } + if (!(options & VOL_OPTION_IGNCASE)){ + if (options & VOL_OPTION_DOWNSHIFT){ /* only downshift chars */ + if (*ss >= 'A' && *ss <= 'Z') { + is_ok=0; + break; + } + } else { /* only upshift chars */ + if (*ss >= 'a' && *ss <= 'z') { + is_ok=0; + break; + } + } + } + } + } + if (is_ok) { + strmaxcpy(fname, e->nwpath.fn, size_fname-1); + up_fn(fname); + return(strlen(fname)); + } else { + return(sprintf(fname, "%ld.___", (long)e->nwpath.statb.st_ino)); + } } #if 0 @@ -1031,7 +1030,7 @@ int nw_generate_dir_path(int namespace, DIR_BASE_ENTRY *dbe=dir_base[result]; U32_TO_32(dbe->basehandle, ns_dir_base); /* LOW - HIGH */ if (namespace != NAME_DOS) { - U32_TO_32(dbe->basehandle, dos_dir_base); + U32_TO_32(name_2_base(&(dbe->nwpath), NAME_DOS, 1), dos_dir_base); } else { U32_TO_32(dbe->basehandle, dos_dir_base); } @@ -1132,7 +1131,7 @@ static int build_dir_info(DIR_BASE_ENTRY *dbe, #if 0 U32_TO_32(dbe->basehandle, p); #else - U32_TO_32(dbe->basehandle, p); + U32_TO_32(name_2_base(nwpath, NAME_DOS, 1), p); #endif p +=4; U32_TO_32(nwpath->volume, p); @@ -1185,13 +1184,59 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp, */ { int result = build_base(namespace, nwp, nwp->pathes, 0, NULL, 0); + if (result > -1) { DIR_BASE_ENTRY *dbe=dir_base[result]; char *unixname = alloc_nwpath2unix(&(dbe->nwpath), 2); nwp_stat(&(dbe->nwpath), "nw_optain_file_dir_info"); result = build_dir_info(dbe, unixname, destnamspace, infomask, responsedata); xfree(unixname); - } + } else if ((result == -0xff || result == -0x9c) && + (namespace == NAME_DOS || namespace == NAME_OS2) && + nwp && nwp->components > 0) { + uint8 search_entry[258]; + int parent_result; + OBTAIN_INFO_SEARCH ois; + + memset(&ois, 0, sizeof(ois)); + ois.base.ubuf = responsedata; + ois.destnamspace = destnamspace; + ois.infomask = infomask; + ois.responsedata = responsedata; + ois.build_result = -0xff; + + parent_result = build_base(namespace, + nwp, + nwp->pathes, + 1, + search_entry, + sizeof(search_entry)); + + XDPRINTF((2, 0, + "NS06 FALLBACK namespace=%d parent_result=0x%x search='%s'", + namespace, + parent_result, + search_entry)); + + if (parent_result > -1) { + DIR_BASE_ENTRY *parent_dbe = dir_base[parent_result]; + int search_res = func_search_entry(parent_dbe, + namespace, + search_entry, + strlen((char *)search_entry), + searchattrib, + obtain_file_dir_info_cb, + (FUNC_SEARCH *)&ois); + XDPRINTF((2, 0, + "NS06 FALLBACK SEARCH search_res=0x%x build_result=0x%x search='%s'", + search_res, + ois.build_result, + search_entry)); + if (search_res == 0 && ois.build_result > -1) + result = ois.build_result; + } + } + if (result < 0) { XDPRINTF((3, 0, "nw_optain_file_dir_info NOT OK result=-0x%x", -result)); } @@ -1518,49 +1563,7 @@ static int search_match(struct dirent *dirbuff, XDPRINTF((8,0,"search_match, Name='%s' dname='%s'", name, dname)); if (!inode_search) { if (namespace == NAME_DOS) { - char saved_dir[1024]; - char *slash; - uint8 dos_alias[DOS83_NAME_MAX + 1]; - - if (*name == '.') { - flag = 0; - } else { - /* - * Keep dname as the real name used later by get_add_new_entry(). - * Build the DOS-visible alias only for matching against the DOS - * namespace wildcard pattern. - */ - strncpy(saved_dir, (char *)ds->unixname, sizeof(saved_dir) - 1); - saved_dir[sizeof(saved_dir) - 1] = '\0'; - - slash = strrchr(saved_dir, '/'); - if (slash) - *slash = '\0'; - else - strcpy(saved_dir, "."); - - dos83_build_name_in_dir(saved_dir, - name, - dos_alias, - sizeof(dos_alias), - vol_options); - - XDPRINTF((2,0, - "NS search_match DOS alias entry='%s' raw='%s' alias='%s' namespace=%d", - entry, - name, - dos_alias, - namespace)); - - flag = fn_dos_match_old(dos_alias, entry, vol_options); - - XDPRINTF((2,0, - "NS search_match DOS alias result=%d entry='%s' raw='%s' alias='%s'", - flag, - entry, - name, - dos_alias)); - } + flag = (*name != '.' && fn_dos_match_old(dname, entry, vol_options)); } else if (namespace == NAME_OS2) { flag = (*name != '.' || (*(name+1) != '.' && *(name+1) != '\0' )) && fn_os2_match(dname, entry, vol_options); @@ -1958,6 +1961,29 @@ typedef struct { uint8 *ubuf; /* userbuff */ } FUNC_SEARCH; +typedef struct { + FUNC_SEARCH base; + int destnamspace; + uint32 infomask; + uint8 *responsedata; + int build_result; +} OBTAIN_INFO_SEARCH; + +static int obtain_file_dir_info_cb(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs) +{ + OBTAIN_INFO_SEARCH *ois = (OBTAIN_INFO_SEARCH *)fs; + char *unixname = alloc_nwpath2unix(&(dbe->nwpath), 2); + + nwp_stat(&(dbe->nwpath), "obtain_file_dir_info_cb"); + ois->build_result = build_dir_info(dbe, + unixname, + ois->destnamspace, + ois->infomask, + ois->responsedata); + xfree(unixname); + return ois->build_result; +} + static int func_search_entry(DIR_BASE_ENTRY *dbe, int namespace, uint8 *path, int len, int searchattrib, int (*fs_func)(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs), FUNC_SEARCH *fs)