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 should only be present when FinderInfo metadata actually exists. Missing FinderInfo must not be represented as synthetic all-zero data.

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.

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.

NCP delete capture smoke

salvage_ncp_delete_smoke.sh is the integration check for the server-side delete hook. It uses ncp_delete_smoke, a small libncp client, to create and delete a file through classic NetWare NCP file functions. 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 payload and JSON sidecar.

Example:

./tests/salvage/salvage_ncp_delete_smoke.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.

NCP history/version smoke

salvage_ncp_history_smoke.sh deletes the same NetWare path twice through NCP and verifies Samba-compatible version naming. With the v flag enabled, the first recycled payload keeps its original name and the second is written as Copy #1 of NAME in the same recycle directory. The .salvage sidecar uses the same selected payload name with a .json suffix.

Example:

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

Like the delete smoke, stale artifact cleanup is best-effort and warning-only. This matters when the script is run as a normal user while .recycle and .salvage entries are owned by the mars_nwe server account.

Still to implement

Runtime endpoint tests should be added as the NCP salvage calls are implemented:

  • NCP 0x2222 / 22 / 27 Scan Salvageable Files (old),
  • NCP 0x2222 / 87 / 16 Scan Salvageable Files,
  • 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.