Files
mars-nwe/tests/salvage

Salvage smoke tests

This directory contains the shared mars_nwe NetWare salvage/deleted-entry tests. The backend is shared by NetWare NCP salvage calls and the later AFP 0x13 Get Macintosh Info On Deleted Files adapter; AFP must not grow a parallel local deleted-file scanner.

Configuration covered by the tests

The active salvage configuration block is intentionally in a low nwserv.conf / nw.ini range:

51 1
52 .recycle .salvage
53 kv
54 0700 0700
55 0 0
56 -
57 -
58 -
59 -

Section meanings:

  • 51 enables/disables salvage.
  • 52 names the recycle payload repository and the .salvage metadata repository.
  • 53 is a compact Samba-vfs_recycle-style behaviour flag string:
    • k = keeptree,
    • v = versions,
    • t = touch,
    • m = touch_mtime.
  • 54 reserves directory/subdirectory modes for generated repositories.
  • 55 is minsize maxsize. Values may be raw bytes or case-insensitive kb, mb, or gb units, for example 55 1kb 100MB.
  • 56 is the exclude pattern list. Matching files are deleted directly.
  • 57 is the exclude_dir pattern list. Matching directories bypass salvage.
  • 58 is the noversions pattern list. Matching files are recycled, but old recycle names are replaced instead of getting Copy #x of NAME history.
  • 59 is reserved for cleanup/history policy.

Repository layout

With k/keeptree enabled, a deleted SYS:PUBLIC/PMDFLTS.INI owned by SUPERVISOR is expected to produce:

SYS/.recycle/SUPERVISOR/PUBLIC/PMDFLTS.INI
SYS/.salvage/SUPERVISOR/PUBLIC/PMDFLTS.INI.json

The .recycle tree contains deleted payload files. The .salvage tree contains one JSON sidecar per deleted object. There is no large per-directory index file.

The sidecar JSON must preserve mars_nwe server metadata needed for exact recover, including:

  • NetWare archive/fileinfo xattrs from nwarchive,
  • AFP metadata from nwatalk when present,
  • inherited rights mask and explicit trustee object/right pairs,
  • selected recycle/salvage relative paths.

finder_info_hex is serialized as a fixed 32-byte AFP FinderInfo block encoded as 64 hex characters. If mars_nwe has no FinderInfo xattr for the deleted object, the JSON stores the all-zero 32-byte FinderInfo value.

Samba-compatible version naming

With the v flag enabled, mars_nwe follows Samba vfs_recycle naming on collision:

SYS/.recycle/SUPERVISOR/PUBLIC/SLVGCHK.TXT
SYS/.recycle/SUPERVISOR/PUBLIC/Copy #1 of SLVGCHK.TXT
SYS/.recycle/SUPERVISOR/PUBLIC/Copy #2 of SLVGCHK.TXT

The .salvage sidecar uses the same selected payload name plus .json:

SYS/.salvage/SUPERVISOR/PUBLIC/SLVGCHK.TXT.json
SYS/.salvage/SUPERVISOR/PUBLIC/Copy #1 of SLVGCHK.TXT.json

If v is not enabled, or a file matches the noversions list, the old recycle payload/metadata is replaced instead of creating a Copy #x of ... history entry. The Copy #n of ... prefix is intentionally not localized; it follows Samba vfs_recycle literally and should be stable across server locales.

Layout smoke

salvage_layout_smoke.sh is a local filesystem-only contract test. It does not require a running mars_nwe server and does not use NCP.

./tests/salvage/salvage_layout_smoke.sh

It verifies the basic .recycle/.salvage directory contract and stale JSON detection. Runtime scans also treat .salvage JSON as a sidecar for the matching .recycle payload: if the payload is removed externally, the entry must disappear from 87/16 scan results and the stale JSON should be cleaned. The combined smoke suite includes a manual pause that asks the tester to remove the backend .recycle payload, then scans again and greps the server log for WARN SALVAGE 87/16 STALE.

NCP path visibility

.recycle and .salvage are backend repository directories. They are not ordinary user-visible NetWare paths. The classic mars_nwe path resolver treats leading-dot path components as special ./.. syntax and rejects names such as .recycle or .salvage with invalid path (0x899c). Dot files/directories are also hidden by default in the NetWare attribute layer.

Smoke tests therefore must not validate backend payloads by opening SYS:.recycle/... or metadata by opening SYS:.salvage/... through normal NCP file calls. The correct NCP-level checks are:

  • create/write/read the live file through NCP,
  • delete the live file through NCP,
  • use salvage scan 87/16 to confirm that a salvageable entry exists,
  • use recover 87/17 or purge 87/18 on the scan sequence,
  • read the restored live file through NCP to verify payload content.

Local filesystem layout tests may still inspect .recycle and .salvage directly when they intentionally test backend layout and run with suitable Unix permissions.

NCP smoke suite

salvage_smoke_suite.sh is the single integration check for the server-side delete hook and Samba-compatible history behaviour. It uses ncp_delete_smoke, a small libncp client, to create and delete the same NetWare path twice through classic NetWare NCP file functions.

The suite appends all current integration checks into one report:

  • first delete: verifies normal .recycle payload and .salvage JSON capture,
  • second delete: verifies version naming with Copy #1 of NAME when option 53 contains the v flag,
  • NCP 0x2222 / 87 / 16: scans the same directory through the official ncpfs salvage scan API. The NCP reply reports the original deleted file name, so the suite expects at least two entries named SLVGCHK.TXT; the Copy #1 of ... history name is verified through the .salvage JSON path above.

The script does not call local rm/unlink for the tested live path; local filesystem access is used only after the NCP delete to inspect the expected recycle payloads and JSON sidecars.

Example:

./tests/salvage/salvage_smoke_suite.sh \
  -S MARS -U SUPERVISOR -P secret \
  --path SYS:PUBLIC/SLVGCHK.TXT \
  --unix-path /var/mars_nwe/SYS/public/SLVGCHK.TXT \
  --volume-root /var/mars_nwe/SYS \
  --out /tmp/mars-salvage-report.txt

The script can run as a normal user. Best-effort pre-clean of stale test artifacts may warn when existing .recycle/.salvage files are owned by the server user or root; those warnings do not fail the smoke by themselves. For cleanest results, use a fresh test filename or run cleanup with the same Unix account that owns the mars_nwe volume files.

The old split scripts salvage_ncp_delete_smoke.sh and salvage_ncp_history_smoke.sh were replaced by this single suite so the salvage flow is exercised like the AFP smoke suite: one entry point, one report, and one summary. New salvage checks should be appended to this suite instead of growing separate top-level smoke scripts.

Still to implement

Runtime endpoint tests should be appended as the NCP salvage calls are implemented. The suite already covers the initial NCP 0x2222 / 87 / 16 scan endpoint after the delete/history phases have created salvageable entries. For duplicate original names, the scan endpoint exposes multiple sequence entries with the same original name; the server-side .salvage metadata keeps the selected recycle/history path.

  • optional NCP 0x2222 / 22 / 27 Scan Salvageable Files (old),
  • NCP 0x2222 / 87 / 17 Recover Salvageable File,
  • NCP 0x2222 / 87 / 18 Purge Salvageable File,
  • AFP 0x13 as a thin adapter over the shared salvage backend.