diff --git a/src/connect.c b/src/connect.c index 6cf70da..f40fd76 100644 --- a/src/connect.c +++ b/src/connect.c @@ -643,7 +643,7 @@ static int func_search_entry(NW_PATH *nwpath, int attrib, okflag = ( ( ( (fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) || ( ( (fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); if (okflag){ - *kpath = ''; + *kpath = '\0'; remember_dos_alias_source(volume, (uint8*)xkpath, name, fs->statb.st_ino); xstrcpy(nwpath->fn, (char*)dosalias); @@ -737,7 +737,7 @@ static int get_dir_entry(NW_PATH *nwpath, if (soptions & VOL_OPTION_IS_PIPE) { statb->st_size = 0x70000000|(statb->st_mtime&0xfffffff); } - *kpath = ''; + *kpath = '\0'; remember_dos_alias_source(volume, (uint8*)xkpath, name, statb->st_ino); xstrcpy(nwpath->fn, (char*)dosalias); @@ -851,7 +851,7 @@ static int get_dh_entry(DIR_HANDLE *dh, if (okflag){ if (unixname) strmaxcpy(unixname, dh->unixname, size_unixname-1); - *(dh->kpath) = ''; + *(dh->kpath) = '\0'; remember_dos_alias_source(dh->volume, (uint8*)dh->unixname, name, statb->st_ino); strmaxcpy((char*)search, (char*)dosalias, size_search-1); @@ -2438,9 +2438,44 @@ static int s_nw_scan_dir_info(int dir_handle, XDPRINTF((5,0,"SCAN_DIR: von %s, found %s:", dh->unixname, dirname)); if (++aktsequence == dirsequence) { /* actual found */ + uint8 dosalias[14]; + char parent[300]; + char *slash; + uint8 *leaf = dirname; + U16_TO_BE16(aktsequence, subnr); - up_fn(dirname); - strncpy((char*)subname, (char*)dirname, 16); + + /* + * Do not trust dirname here. Some old DOS scan paths carry the + * raw 8 byte directory name only, which collapses colliding long + * directories to the same display name (LONG_DIR/LONG_DIR). + * Rebuild the final directory info name from the real full unixname + * returned by get_dh_entry(), where the long on-disk leaf is still + * available. + */ + if (unixname[0]) { + strmaxcpy(parent, unixname, sizeof(parent)-1); + slash = strrchr(parent, '/'); + if (slash) { + leaf = (uint8*)(slash+1); + *slash = '\0'; + if (!*parent) strcpy(parent, "/"); + build_dos_83_alias(dh->vol_options, (uint8*)parent, + leaf, stbuff.st_ino, + dosalias, sizeof(dosalias)); + } else { + build_dos_83_alias(dh->vol_options, NULL, + leaf, stbuff.st_ino, + dosalias, sizeof(dosalias)); + } + } else { + build_dos_83_alias(dh->vol_options, (uint8*)dh->unixname, + dirname, stbuff.st_ino, + dosalias, sizeof(dosalias)); + } + + up_fn(dosalias); + strncpy((char*)subname, (char*)dosalias, 16); U32_TO_BE32(get_file_owner(&stbuff), owner); un_date_2_nw(stbuff.st_mtime, subdatetime, 1); un_time_2_nw(stbuff.st_mtime, subdatetime+2, 1);