feat: improve MAP redirection handling

This commit is contained in:
Mario Fetka
2026-05-22 13:04:50 +02:00
parent b8a701b8fe
commit e4d67917bd
2 changed files with 32 additions and 11 deletions

42
map.c
View File

@@ -80,19 +80,41 @@ static void do_map(int drive, NWPATH *nwp)
static int do_map(int drive, NWPATH *nwp, int delete)
{
int result = -1;
if (drive > -1 && drive < 32) {
uint8 connid;
uint8 dhandle;
uint8 flags;
if (!delete ||
(!get_drive_info(drive, &connid, &dhandle, &flags) && flags && connid)){
uint8 nmdrive[3];
nmdrive[0] = drive+'A';
nmdrive[1] = ':';
nmdrive[2] = '\0';
result = redir_device_drive(delete ? -1 : 0x4, nmdrive, nwp->path);
uint8 connid = 0;
uint8 dhandle = 0;
uint8 flags = 0;
if (delete) {
if (!get_drive_info(drive, &connid, &dhandle, &flags)
&& flags && !(flags & 0x80) && connid) {
result = dealloc_dir_handle(dhandle);
}
} else {
/*
* The old mars-dosutils MAP used DOS redirector INT 21h AX=5F03h.
* NetWare Client32 returns AX=0001 for that call, while Novell MAP
* works. Use the NetWare shell/NCP "Allocate Permanent Directory
* Handle" path instead; this is what the surrounding code already
* provides via alloc_permanent_dir_handle().
*/
if (!get_drive_info(drive, &connid, &dhandle, &flags)
&& flags && !(flags & 0x80) && connid) {
(void)dealloc_dir_handle(dhandle);
}
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'A', NULL);
/*
* Some requesters historically accepted lowercase drive letters in
* this call. Keep this only as compatibility fallback.
*/
if (result < 0)
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'a', NULL);
}
}
return(result);
}

View File

@@ -241,7 +241,6 @@ int alloc_dir_handle(int func,
printf("alloc_dir_handle, path=%s, len=%d, disk=%c\n", path, pathlen, driveletter);
*/
neterrno = Net_Call(0xE200, &req, &repl);
fprintf(stderr, "neterrno=%d\n", neterrno);
if (neterrno && neterrno != 0xff) return(-1);
if (effrights) *effrights = repl.effrights;