diff --git a/src/namspace.c b/src/namspace.c index a6a0191..35be2fc 100644 --- a/src/namspace.c +++ b/src/namspace.c @@ -51,6 +51,11 @@ #define NW_PATH /* */ +extern void mangle_dos_name(NW_VOL *vol, uint8 *unixname, uint8 *pp); +static int ns06_fallback_obtain_info(int namespace, NW_HPATH *nwp, + int destnamspace, int searchattrib, + uint32 infomask, uint8 *responsedata); + typedef struct { int volume; /* Volume Number */ int has_wild; /* fn has wildcards */ @@ -1191,7 +1196,11 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp, 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)) { + result = ns06_fallback_obtain_info(namespace, nwp, destnamspace, + searchattrib, infomask, responsedata); + } if (result < 0) { XDPRINTF((3, 0, "nw_optain_file_dir_info NOT OK result=-0x%x", -result)); } @@ -1957,6 +1966,74 @@ typedef struct { int searchattrib; uint8 *ubuf; /* userbuff */ } FUNC_SEARCH; +typedef struct { + FUNC_SEARCH base; + int destnamspace; + uint32 infomask; + uint8 *responsedata; + int build_result; +} NS06_OBTAIN_INFO_SEARCH; + +static int ns06_obtain_info_cb(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs) +{ + NS06_OBTAIN_INFO_SEARCH *ois = (NS06_OBTAIN_INFO_SEARCH *)fs; + char *unixname = alloc_nwpath2unix(&(dbe->nwpath), 2); + + nwp_stat(&(dbe->nwpath), "ns06_obtain_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); + +static int ns06_fallback_obtain_info(int namespace, NW_HPATH *nwp, + int destnamspace, int searchattrib, + uint32 infomask, uint8 *responsedata) +{ + uint8 search_entry[258]; + int parent_result; + NS06_OBTAIN_INFO_SEARCH ois; + + if (!nwp || nwp->components <= 0) + return(-0xff); + + 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, + ns06_obtain_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) + return(ois.build_result); + } + return(-0xff); +} + static int func_search_entry(DIR_BASE_ENTRY *dbe, int namespace, uint8 *path, int len, int searchattrib,