diff --git a/tests/linux/afp_entry_id_smoke.c b/tests/linux/afp_entry_id_smoke.c index de5f8a7..9553738 100644 --- a/tests/linux/afp_entry_id_smoke.c +++ b/tests/linux/afp_entry_id_smoke.c @@ -14,6 +14,7 @@ #include #include +#include #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; }