From 9c1787345d8e2b1fd2ffedbe37e19a0a70e5ca79 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 30 May 2026 21:12:58 +0000 Subject: [PATCH] tests: add AFP open file fork write smoke --- tests/linux/README.md | 33 ++++++++++++++------------ tests/linux/afp_open_file_fork_smoke.c | 7 +++--- tests/linux/afp_smoke_suite.sh | 20 ++++++++++++---- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/tests/linux/README.md b/tests/linux/README.md index 1171c39..0a8d6f9 100644 --- a/tests/linux/README.md +++ b/tests/linux/README.md @@ -501,11 +501,13 @@ request: NCP 0x2222/35/08 AFP Open File Fork ``` -The first mars_nwe implementation is deliberately conservative. It supports -raw `VOL:`-style path requests such as `SYS:` or `HOME:` with base Entry ID -zero, opens only the AFP data fork, and only for read access. For path-backed -requests, mars_nwe resolves the effective NetWare volume from the raw path -prefix instead of assuming volume 0. On success the server returns the +mars_nwe supports raw `VOL:`-style path requests such as `SYS:` or +`HOME:` with base Entry ID zero and opens only the AFP data fork. Read and +write data-fork opens are routed through the existing NetWare file open/share +path (`nw_creat_open_file()`/`file_creat_open()`), so trustee rights, read-only +attributes, and share-deny checks stay shared with regular NCP file opens. For +path-backed requests, mars_nwe resolves the effective NetWare volume from the +raw path prefix instead of assuming volume 0. On success the server returns the normal six-byte NetWare file handle shape used by AFP handle APIs plus the current data-fork length. The smoke helper immediately closes the returned NetWare file handle in the same connection. @@ -522,7 +524,7 @@ A file on another exported volume should be tested with its raw volume prefix volume number, while still showing the request volume byte separately. A successful reply prints the returned NetWare handle, the requested fork, the -read access mode, and the data-fork length. A verified runtime smoke run +requested access mode, and the data-fork length. A verified runtime smoke run against the standard DOS utility files produced: ```text @@ -540,20 +542,21 @@ AFP Open File Fork: vol=0 request_vol=0 entry=0x00000000 fork=0 access=0x01 path The exact handle number is connection-local and must not be reused across processes. The exact `fork_len` depends on the backing file contents. -Resource-fork opens (`--fork 1`), write access (`--access 2`), and -Entry-ID-only open remain unsupported until persistent CNID/base-ID lookup, -AppleDouble/resource-fork, and AFP write-open semantics are available. The -smoke helper can assert those conservative rejections explicitly: +Write access is tested on a temporary file created through AFP Create File and +then removed with AFP Delete: ```sh -./tests/linux/afp_open_file_fork_smoke --expect-completion 0x84 --access 0x02 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini -./tests/linux/afp_open_file_fork_smoke --expect-completion 0x9c --fork 1 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini +./tests/linux/afp_create_file_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/afpwrit +./tests/linux/afp_open_file_fork_smoke --access 0x02 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/afpwrit +./tests/linux/afp_delete_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/afpwrit ``` -A rejected write-open probe should print: +Resource-fork opens (`--fork 1`) and Entry-ID-only open remain unsupported until +AppleDouble/resource-fork support and persistent CNID/base-ID lookup exist. The +smoke helper can assert the resource-fork rejection explicitly: -```text -AFP Open File Fork returned expected completion 0x84: path=SYS:PUBLIC/pmdflts.ini fork=0 access=0x02 +```sh +./tests/linux/afp_open_file_fork_smoke --expect-completion 0x9c --fork 1 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini ``` A rejected resource-fork probe should print: diff --git a/tests/linux/afp_open_file_fork_smoke.c b/tests/linux/afp_open_file_fork_smoke.c index 48218e1..481faa5 100644 --- a/tests/linux/afp_open_file_fork_smoke.c +++ b/tests/linux/afp_open_file_fork_smoke.c @@ -2,8 +2,8 @@ * Linux smoke test for NetWare AFP Open File Fork. * * This uses ncpfs/libncp so the request travels through the same NCP path as a - * normal Linux requester. The first mars_nwe implementation deliberately - * exercises the conservative path-backed data-fork subset and returns a normal + * normal Linux requester. mars_nwe routes path-backed AFP data-fork read and + * write opens through the normal NetWare open/share path and returns a normal * NetWare file handle, which this helper closes before exiting. */ @@ -29,6 +29,7 @@ #define NWE_INVALID_PATH 0x9c #define AFP_DATA_FORK 0x00 #define AFP_ACCESS_READ 0x01 +#define AFP_ACCESS_WRITE 0x02 static void usage(const char *prog) { @@ -45,7 +46,7 @@ static void usage(const char *prog) " %s -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini\n" " %s --allow-invalid-namespace -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini\n" " %s --allow-invalid-path -S MARS -U SUPERVISOR -P secret SYS:NO_SUCH_FILE\n" - " %s --expect-completion 0x84 --access 0x02 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini\n" + " %s --access 0x02 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/testfile.dat\n" " %s --expect-completion 0x9c --fork 1 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini\n", prog, prog, prog, prog, prog, prog); } diff --git a/tests/linux/afp_smoke_suite.sh b/tests/linux/afp_smoke_suite.sh index ee70007..c75a0ef 100755 --- a/tests/linux/afp_smoke_suite.sh +++ b/tests/linux/afp_smoke_suite.sh @@ -577,11 +577,23 @@ run_cmd \ "./afp_open_file_fork_smoke $COMMON_PRINT '$NETWARE_PATH'" \ "$SCRIPT_DIR/afp_open_file_fork_smoke" -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$NETWARE_PATH" +run_optional_cmd \ + "Prepare AFP Open File Fork write cleanup" \ + "./afp_delete_smoke $COMMON_PRINT '$CREATE_FILE_PATH'" \ + "$SCRIPT_DIR/afp_delete_smoke" -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$CREATE_FILE_PATH" || true run_cmd \ - "AFP Open File Fork write access rejected" \ - "./afp_open_file_fork_smoke --expect-completion 0x84 --access 0x02 $COMMON_PRINT '$NETWARE_PATH'" \ - "$SCRIPT_DIR/afp_open_file_fork_smoke" --expect-completion 0x84 --access 0x02 \ - -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$NETWARE_PATH" + "AFP Open File Fork write create file" \ + "./afp_create_file_smoke $COMMON_PRINT '$CREATE_FILE_PATH'" \ + "$SCRIPT_DIR/afp_create_file_smoke" -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$CREATE_FILE_PATH" +run_cmd \ + "AFP Open File Fork write access" \ + "./afp_open_file_fork_smoke --access 0x02 $COMMON_PRINT '$CREATE_FILE_PATH'" \ + "$SCRIPT_DIR/afp_open_file_fork_smoke" --access 0x02 \ + -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$CREATE_FILE_PATH" +run_cmd \ + "AFP Open File Fork write cleanup" \ + "./afp_delete_smoke $COMMON_PRINT '$CREATE_FILE_PATH'" \ + "$SCRIPT_DIR/afp_delete_smoke" -S "$SERVER" -U "$USER_NAME" -P "$PASSWORD" "$CREATE_FILE_PATH" run_cmd \ "AFP Open File Fork resource fork rejected" \