nwconn: implement AFP 2.0 Get File Information
All checks were successful
Source release / source-package (push) Successful in 46s

Route NCP 0x23/0x0f AFP 2.0 Get File Information through the existing read-only AFP file-information helper.

The WebSDK and nwafp.h list both AFP Get File Information and AFP 2.0 Get File Information as path/file-information queries that return the AFP file-information record used by Mac namespace clients. The already implemented 0x05 path handles SYS:-style path requests and fills the safe read-only fields from Unix stat data plus the optional libatalk Finder Info and resource-fork helpers.

Use the same conservative path-backed reply for 0x0f for now. This gives Linux smoke-test coverage for the AFP 2.0 subfunction without adding entry-id-only lookup, persistent CNID mapping, write-side metadata updates, or fuller resource-fork semantics.

Extend afp_file_info_smoke with --afp20 so the same SYS:, SYS:PUBLIC, SYS:SYSTEM, and SYS:BURST cases can exercise the AFP 2.0 subfunction. Update the Linux test README and TODO tracking to record that AFP 2.0 file information is covered by the same temporary fallback model.

This implements only the read-only path-based subset; richer AFP 2.0 behavior remains future Mac-namespace work.
This commit is contained in:
Mario Fetka
2026-05-30 06:03:52 +00:00
parent b3d06fbf3f
commit 8e885bb16d
4 changed files with 56 additions and 33 deletions

View File

@@ -66,10 +66,12 @@ expected `0x9c` Invalid Path completion.
## AFP File Information smoke test
`afp_file_info_smoke` sends the WebSDK-documented NetWare AFP request:
`afp_file_info_smoke` sends the WebSDK-documented NetWare AFP file
information requests:
```text
NCP 0x2222/35/05 AFP Get File Information
NCP 0x2222/35/15 AFP 2.0 Get File Information
```
It uses the same libncp `NWRequestSimple()` transport path as the Entry ID
@@ -85,10 +87,15 @@ Useful smoke cases for a standard MARS-NWE `SYS` volume are:
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:BURST
# AFP 2.0 variant using the same path-backed read-only reply
./tests/linux/afp_file_info_smoke --afp20 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
```
The current implementation fills fields that can be derived from Unix `stat(2)`
and the optional libatalk helper wrappers. Server-side diagnostics mark
The AFP 2.0 mode is selected with `--afp20` and currently exercises the same
path-backed read-only reply as the older call. The current implementation
fills fields that can be derived from Unix `stat(2)` and the optional libatalk
helper wrappers. Server-side diagnostics mark
stat-derived temporary Entry IDs with `fallback`; Parent ID, persistent
CNID/AppleDouble IDs, and fuller Finder Info/resource-fork semantics remain
future Mac-namespace work.

View File

@@ -19,7 +19,8 @@
#define NCPC_SFN(FN, SFN) ((FN) | ((SFN) << 8) | NCPC_SUBFUNCTION)
#endif
#define AFP_GET_FILE_INFORMATION 0x05
#define AFP_GET_FILE_INFORMATION 0x05
#define AFP20_GET_FILE_INFORMATION 0x0f
#define NWE_INVALID_NAMESPACE 0xbf
#define NWE_INVALID_PATH 0x9c
#define AFP_REPLY_LEN 120
@@ -28,7 +29,7 @@
static void usage(const char *prog)
{
fprintf(stderr,
"Usage: %s [--allow-invalid-namespace] [--allow-invalid-path] "
"Usage: %s [--afp20] [--allow-invalid-namespace] [--allow-invalid-path] "
"[--volume N] [--entry-id ID] [--request-mask MASK] [ncpfs options] PATH\n"
"\n"
"ncpfs options are parsed by ncp_initialize(), for example:\n"
@@ -36,9 +37,10 @@ static void usage(const char *prog)
"\n"
"Examples:\n"
" %s -S MARS -U SUPERVISOR -P secret SYS:PUBLIC\n"
" %s --afp20 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC\n"
" %s --allow-invalid-namespace -S MARS SYS:PUBLIC\n"
" %s --allow-invalid-path -S MARS SYS:NO_SUCH_PATH\n",
prog, prog, prog, prog);
prog, prog, prog, prog, prog);
}
static int parse_u32(const char *text, uint32_t *value)
@@ -104,6 +106,7 @@ int main(int argc, char **argv)
uint32_t volume_number = 0;
uint32_t entry_id = 0;
uint32_t request_mask = AFP_GET_ALL;
uint32_t afp_subfunction = AFP_GET_FILE_INFORMATION;
int i;
size_t path_len;
uint8_t request[1 + 4 + 2 + 1 + 255];
@@ -125,7 +128,9 @@ int main(int argc, char **argv)
}
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--allow-invalid-namespace")) {
if (!strcmp(argv[i], "--afp20")) {
afp_subfunction = AFP20_GET_FILE_INFORMATION;
} else if (!strcmp(argv[i], "--allow-invalid-namespace")) {
allow_invalid_namespace = 1;
} else if (!strcmp(argv[i], "--allow-invalid-path")) {
allow_invalid_path = 1;
@@ -187,23 +192,26 @@ int main(int argc, char **argv)
reply.fragSize = sizeof(reply_buf);
err = NWRequestSimple(conn,
NCPC_SFN(0x23, AFP_GET_FILE_INFORMATION),
NCPC_SFN(0x23, afp_subfunction),
request,
8 + path_len,
&reply);
if (err == NWE_INVALID_NAMESPACE && allow_invalid_namespace) {
printf("AFP Get File Information returned invalid namespace as expected for path=%s\n", path);
printf("AFP Get File Information subfunction=0x%02x returned invalid namespace as expected for path=%s\n",
(unsigned int)afp_subfunction, path);
ncp_close(conn);
return 0;
}
if (err == NWE_INVALID_PATH && allow_invalid_path) {
printf("AFP Get File Information returned invalid path as expected for path=%s\n", path);
printf("AFP Get File Information subfunction=0x%02x returned invalid path as expected for path=%s\n",
(unsigned int)afp_subfunction, path);
ncp_close(conn);
return 0;
}
if (err) {
fprintf(stderr,
"AFP Get File Information failed: completion=0x%02x (%u) path=%s\n",
"AFP Get File Information subfunction=0x%02x failed: completion=0x%02x (%u) path=%s\n",
(unsigned int)afp_subfunction,
(unsigned int)err & 0xff, (unsigned int)err, path);
ncp_close(conn);
return 1;
@@ -218,8 +226,9 @@ int main(int argc, char **argv)
copy_fixed_string(long_name, sizeof(long_name), reply_buf + 64, 32);
copy_fixed_string(short_name, sizeof(short_name), reply_buf + 100, 12);
printf("AFP File Info path=%s entry_id=0x%08x parent_id=0x%08x attrs=0x%04x "
printf("AFP File Info subfunction=0x%02x path=%s entry_id=0x%08x parent_id=0x%08x attrs=0x%04x "
"data_len=%u resource_len=%u offspring=%u long_name=%s short_name=%s rights=0x%04x\n",
(unsigned int)afp_subfunction,
path,
be32_to_cpu(reply_buf + 0),
be32_to_cpu(reply_buf + 4),