diff --git a/src/namspace.c b/src/namspace.c index 625c476..96b3dc7 100644 --- a/src/namspace.c +++ b/src/namspace.c @@ -50,6 +50,13 @@ #define NW_PATH /* */ +/* visible here because some trees do not expose it through included headers */ +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 */ @@ -1184,7 +1191,6 @@ 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); @@ -1192,51 +1198,10 @@ int nw_optain_file_dir_info(int namespace, NW_HPATH *nwp, 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; - } + (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)); } @@ -1961,29 +1926,6 @@ 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) @@ -2094,6 +2036,71 @@ static int func_search_entry(DIR_BASE_ENTRY *dbe, int namespace, return(result); } + +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 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 delete_file_dir(DIR_BASE_ENTRY *dbe, FUNC_SEARCH *fs) /* callbackroutine */ {