tests: allocate AFP smoke handles through libncp
All checks were successful
Source release / source-package (push) Successful in 51s

Use libncp\047s namespace-aware short directory handle helper in the AFP Entry ID smoke test instead of hand-building the old Allocate Temporary Directory Handle request.\n\nThe smoke test accepts NetWare-style VOL:PATH arguments, but NCP 0x23/0x0c AFP Get Entry ID From Path Name expects a directory handle plus a relative path. The previous test tried to allocate a temporary handle by issuing the old NCP 0x16/0x13 request directly, which failed with Invalid Path before the AFP endpoint was reached.\n\nMirror the ncpfs tools and call ncp_ns_alloc_short_dir_handle() for the volume root in the DOS namespace, then pass only the relative path to the AFP request. Keep deallocating the temporary handle after the request.\n\nThis changes only the Linux smoke test; server AFP protocol behavior is unchanged.
This commit is contained in:
Mario Fetka
2026-05-30 00:56:16 +00:00
parent 069bbba88c
commit cc98d22144

View File

@@ -14,6 +14,7 @@
#include <ncp/nwcalls.h>
#include <ncp/ncplib.h>
#include <ncp/kernel/ncp.h>
#ifndef NCPC_SUBFUNCTION
#define NCPC_SUBFUNCTION 0x10000
@@ -90,34 +91,38 @@ static int split_volume_path(const char *path, char *volume, size_t volume_size,
static NWCCODE allocate_temp_dir_handle(NWCONN_HANDLE conn, const char *volume,
unsigned int *dir_handle)
{
uint8_t rq[1 + 1 + 1 + 32];
uint8_t rpbuf[2];
NW_FRAGMENT rp;
char root_path[64];
size_t volume_len = strlen(volume);
NWDIR_HANDLE handle = 0;
NWCCODE err;
if (volume_len + 1 > 32)
if (!volume_len || volume_len + 1 >= sizeof(root_path))
return NWE_INVALID_PATH;
rq[0] = 0; /* source directory handle */
rq[1] = 0; /* drive letter, unused by the test */
rq[2] = (uint8_t)(volume_len + 1);
memcpy(rq + 3, volume, volume_len);
rq[3 + volume_len] = ':';
memcpy(root_path, volume, volume_len);
root_path[volume_len] = ':';
root_path[volume_len + 1] = '\0';
memset(rpbuf, 0, sizeof(rpbuf));
rp.fragAddr.rw = rpbuf;
rp.fragSize = sizeof(rpbuf);
err = NWRequestSimple(conn, NCPC_SFN(0x16, 0x13), rq,
3 + volume_len + 1, &rp);
/*
* Use libncp's namespace-aware helper instead of hand-building the old
* Allocate Temporary Directory Handle request. This matches the way the
* ncpfs tools allocate short directory handles and lets libncp choose the
* correct request encoding for the connected server.
*/
err = ncp_ns_alloc_short_dir_handle(conn,
NW_NS_DOS,
NCP_DIRSTYLE_NOHANDLE,
0,
0,
(const unsigned char *)root_path,
volume_len + 1,
NCP_ALLOC_TEMPORARY,
&handle,
NULL);
if (err)
return err;
if (rp.fragSize < 1)
return NWE_INVALID_NCP_PACKET_LENGTH;
*dir_handle = rpbuf[0];
*dir_handle = (unsigned int)handle;
return 0;
}