diff --git a/map.c b/map.c index 1ef4c1f..5726c58 100644 --- a/map.c +++ b/map.c @@ -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); } diff --git a/netcall.c b/netcall.c index 4f5b888..70667d2 100644 --- a/netcall.c +++ b/netcall.c @@ -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;