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

@@ -622,7 +622,7 @@ static uint16 afp_count_offspring(const char *unixname, const struct stat *stb)
}
static int afp_get_file_information(uint8 *afp_req, int afp_len,
uint8 *response)
uint8 *response, const char *call_name)
{
uint8 volume_number;
uint32 request_entry_id;
@@ -639,8 +639,8 @@ static int afp_get_file_information(uint8 *afp_req, int afp_len,
int result;
if (afp_len < 9) {
XDPRINTF((2,0, "AFP Get File Information rejected: short request len=%d",
afp_len));
XDPRINTF((2,0, "%s rejected: short request len=%d",
call_name, afp_len));
return(-0x7e); /* NCP Boundary Check Failed */
}
@@ -649,19 +649,19 @@ static int afp_get_file_information(uint8 *afp_req, int afp_len,
request_mask = GET_BE16(afp_req + 6);
path_len = (int)afp_req[8];
if (path_len < 0 || afp_len < 9 + path_len) {
XDPRINTF((2,0, "AFP Get File Information rejected: boundary check len=%d path_len=%d",
afp_len, path_len));
XDPRINTF((2,0, "%s rejected: boundary check len=%d path_len=%d",
call_name, afp_len, path_len));
return(-0x7e);
}
if (!nwatalk_backend_available()) {
XDPRINTF((3,0, "AFP Get File Information rejected: libatalk backend unavailable"));
XDPRINTF((3,0, "%s rejected: libatalk backend unavailable", call_name));
return(-0xbf); /* invalid namespace */
}
if (!path_len) {
XDPRINTF((2,0, "AFP Get File Information rejected: entry-id-only lookup unsupported vol=%d entry=0x%08x mask=0x%04x",
(int)volume_number, request_entry_id, request_mask));
XDPRINTF((2,0, "%s rejected: entry-id-only lookup unsupported vol=%d entry=0x%08x mask=0x%04x",
call_name, (int)volume_number, request_entry_id, request_mask));
return(-0x9c); /* Invalid Path until persistent entry-id lookup exists */
}
@@ -669,15 +669,15 @@ static int afp_get_file_information(uint8 *afp_req, int afp_len,
path_len ? afp_req + 9 : &empty_path,
path_len);
if (volume < 0) {
XDPRINTF((2,0, "AFP Get File Information path resolve failed: vol=%d entry=0x%08x path='%s' result=-0x%x",
(int)volume_number, request_entry_id,
XDPRINTF((2,0, "%s path resolve failed: vol=%d entry=0x%08x path='%s' result=-0x%x",
call_name, (int)volume_number, request_entry_id,
visable_data(afp_req + 9, path_len), -volume));
return(volume);
}
if (stat(unixname, &stbuff)) {
XDPRINTF((2,0, "AFP Get File Information stat failed: vol=%d entry=0x%08x path='%s' unix='%s' errno=%d",
(int)volume_number, request_entry_id,
XDPRINTF((2,0, "%s stat failed: vol=%d entry=0x%08x path='%s' unix='%s' errno=%d",
call_name, (int)volume_number, request_entry_id,
visable_data(afp_req + 9, path_len), unixname, errno));
return(-0x9c); /* Invalid Path */
}
@@ -714,8 +714,8 @@ static int afp_get_file_information(uint8 *afp_req, int afp_len,
U16_TO_BE16(afp_basic_access_privileges(&stbuff), response + 112);
/* ProDOS info at offset 114 stays zero until a real Mac namespace maps it. */
XDPRINTF((3,0, "AFP Get File Information: vol=%d entry=0x%08x mask=0x%04x path='%s' reply_entry=0x%08x%s",
(int)volume_number, request_entry_id, request_mask,
XDPRINTF((3,0, "%s: vol=%d entry=0x%08x mask=0x%04x path='%s' reply_entry=0x%08x%s",
call_name, (int)volume_number, request_entry_id, request_mask,
visable_data(afp_req + 9, path_len), entry_id,
(result < 0) ? " fallback" : ""));
return(120);
@@ -2672,7 +2672,11 @@ static int handle_ncp_serv(void)
* Implement the path-name entry-id probe first because the
* SDK helpers use it to test AFP support, then expose the
* read-only AFP Get File Information query for the same
* SYS:-style path inputs. Both still require
* SYS:-style path inputs. AFP 2.0 Get File Information
* uses the same request/reply layout for this read-only
* path-backed subset, so route it through the same helper
* until persistent entry-id lookup and richer AFP 2.0
* metadata are implemented. These calls still require
* the optional libatalk backend to be present; without a Mac
* namespace backend, keep returning invalid namespace.
*/
@@ -2681,9 +2685,10 @@ static int handle_ncp_serv(void)
afp_len, responsedata);
if (result > -1) data_len = result;
else completition = (uint8)-result;
} else if (ufunc == 0x05) {
} else if (ufunc == 0x05 || ufunc == 0x0f) {
int result = afp_get_file_information(afp_req,
afp_len, responsedata);
afp_len, responsedata,
afp_call_name(ufunc));
if (result > -1) data_len = result;
else completition = (uint8)-result;
} else {