connect: use DOS alias names in legacy directory attributes

Route legacy DOS file and directory attribute responses through the
shared DOS alias logic so old DOS scan calls report the same names as
namespace-aware directory listings.
This commit is contained in:
Mario Fetka
2026-05-20 16:28:22 +02:00
parent aa4c21242d
commit 14112a4565

View File

@@ -58,6 +58,7 @@ static int act_umode_file=0;
#include "nwfile.h"
#include "nwconn.h"
#include "namspace.h"
#include "namedos.h"
#include "connect.h"
/* connect.h may already be include-guarded through another header before
@@ -2446,6 +2447,34 @@ int nw_scan_dir_info(int dir_handle, uint8 *data, int len, uint8 *subnr,
static void build_dos_attr_name(int volume, uint8 *path, char *unixname,
struct stat *stb, uint8 *out, int out_len)
{
char parent[300];
char *slash;
uint8 *leaf = path;
if (!out || out_len < 2) return;
*out = '\0';
if (unixname && *unixname) {
strmaxcpy(parent, unixname, sizeof(parent)-1);
slash = strrchr(parent, '/');
if (slash) {
*slash = '\0';
if (*(slash+1)) leaf = (uint8*)(slash+1);
if (!*parent) strcpy(parent, "/");
build_dos_83_alias(get_volume_options(volume), (uint8*)parent,
leaf, stb ? stb->st_ino : 0, out, out_len);
return;
}
}
build_dos_83_alias(get_volume_options(volume), NULL,
leaf, stb ? stb->st_ino : 0, out, out_len);
}
void get_dos_file_attrib(NW_DOS_FILE_INFO *f,
struct stat *stb,
int volume,
@@ -2454,9 +2483,8 @@ void get_dos_file_attrib(NW_DOS_FILE_INFO *f,
{
uint8 spath[14];
uint32 nw_owner=get_file_owner(stb);
f->namlen=min(strlen((char*)path), 12);
strmaxcpy(spath, path, 12);
up_fn(spath);
build_dos_attr_name(volume, path, unixname, stb, spath, sizeof(spath));
f->namlen=min(strlen((char*)spath), 12);
strncpy((char*)f->name, (char*)spath, f->namlen);
U32_TO_32(get_nw_attrib_dword(volume, unixname, stb), f->attributes);
U16_TO_16(tru_get_inherited_mask(volume, unixname, stb),
@@ -2481,9 +2509,8 @@ void get_dos_dir_attrib(NW_DOS_DIR_INFO *f,
char *unixname)
{
uint8 spath[14];
f->namlen=min(strlen((char*)path), 12);
strmaxcpy(spath, path, 12);
up_fn(spath);
build_dos_attr_name(volume, path, unixname, stb, spath, sizeof(spath));
f->namlen=min(strlen((char*)spath), 12);
strncpy((char*)f->name, (char*)spath, f->namlen);
U32_TO_32(get_nw_attrib_dword(volume, unixname, stb),
f->attributes);