Files
mars-nwe/doc/NSS_NAMESPACE_AUDIT.md
Mario Fetka a9d17d85af
All checks were successful
Source release / source-package (push) Successful in 1m35s
0493 core: route NSS production debug output through WIO
2026-06-13 22:58:04 +02:00

17 KiB

NSS namespace and storage import audit

This note records the namespace follow-up after the Unicode/codepage/GUID import series. The goal is to replace the old MARS namedos/nameos2 logic with the more complete NSS namespace implementation. Do not add a permanent wrapper around the old MARS namespace code; import/adapt NSS namespace sources directly and then retire the duplicate MARS implementation in controlled steps.

Source tree

Primary NSS namespace source locations in the supplied reference archives:

public_core/comn/namespace/nameSpace.c
public_core/comn/namespace/dosNSpace.c
public_core/comn/namespace/dosNSWild.c
public_core/comn/namespace/longNSpace.c
public_core/comn/namespace/macNSpace.c
public_core/comn/namespace/unixNSpace.c
public_core/comn/namespace/dataStreamNSpace.c
public_core/comn/namespace/extAttrNSpace.c
public_core/comn/namespace/*NSpace.h
public_core/comn/namespace/nspaceStartup.h
shared/sdk/include/nameSpace.h
shared/sdk/internal/macNSpace.h
shared/sdk/internal/unixNSpace.h

The imported mars-nwe namespace model now lives directly under src/nwfs/ and include/nwfs/. The duplicate src/nwfs/nss/namespace/ staging tree was removed after adding nwfs.namespace.model; future concrete function imports should come from the supplied NSS archives and land directly in normal libnwfs paths.

The NSS namespace set covers the target replacement area:

  • DOS namespace
  • LONG namespace
  • MAC namespace
  • UNIX namespace
  • Data Stream namespace
  • Extended Attribute namespace

Why this is not a small helper import

The namespace implementation is not just string parsing. The real NSS files use common-layer/file-system state:

comnPublics.h
comnParams.h
comnBeasts.h
comnVariableData.h
adminVolume.h
comnBeastClass.h
pssStartup.h
name.h
msgName.h
msgGen.h
zParams.h
sysimp.h

Important runtime hooks include:

  • namespace registration through COMN_RegisterNameSpace()
  • AdminVolume namespace beasts
  • root variable-data registration for MAC/UNIX metadata
  • name-beast/cache structures
  • unique-name generation against directories
  • message/error plumbing

So the namespace block should not be treated like the earlier pure helper libs (crc, unicode, utc, guid, xString). It is closer to an NSS common-layer subsystem and belongs on the path toward libnwfs.

Import direction

libnwcore

libnwcore should receive only stable reusable primitives needed by several other imports:

  • public NSS namespace IDs/flags/types
  • component scan/compare/convert helpers once their common-layer dependencies are adapted
  • wildcard helpers
  • DOS/LONG/MAC/UNIX legal-character logic
  • Data Stream / Extended Attribute namespace constants and parser helpers

libnwfs

libnwfs is the target for direct NSS namespace runtime integration:

  • namespace registration
  • DOS/LONG/MAC/UNIX namespace objects
  • Data Stream namespace objects
  • Extended Attribute namespace objects
  • volume/pool namespace exposure
  • metadata/salvage/stream integration
  • future _ADMIN virtual management volume

The old MARS files are replacement targets, not extension points:

include/namedos.h
include/nameos2.h
src/namedos.c
src/nameos2.c
src/namspace.c

namedos/nameos2 should be retired after NSS DOS/LONG/MAC/UNIX namespace code is imported and tests show identical or better NetWare 3.x DOS behavior.

libnwnds

NDS/eDirectory helpers stay out of libnwcore:

public_core/library/eDir/getDSGuid.c
public_core/library/eDir/parseDSObjectName.c

getDSGuid.c depends on DDC/DS read APIs and belongs in a future libnwnds. A simple DS object-name parser can be imported there later if 4.x guarded endpoints need it.

libnwbind

Bindery/auth/object-ID bridging remains separate:

public_core/comn/authsys/*

That code references bindery/auth/common-layer internals and should become a future libnwbind or libnwauth block, not a core namespace import.

Bottom-up namespace dependency order

The namespace import is now intentionally ordered from the lowest reusable NSS state upward. Do not make dosNSpace.c compile by adding local shim functions or reduced replacement headers. If an imported file needs another NSS symbol, find the source/header that owns that symbol, check whether the corresponding primitive already exists in include/core, and import the missing layer first.

Current dependency walk from the imported DOS namespace source:

dosNSpace.c
  -> DOSNS_Startup()
  -> COMN_RegisterNameSpace()
  -> public_core/comn/namespace/nameSpace.c
  -> comnBeastClass.h / comnBeasts.h / adminVolume.h / pssStartup.h
  -> latch.h + xCache.h + NSS MPK/OS abstraction headers

comnBeasts.h is the first blocker, not the DOS namespace code itself. It includes latch.h and xCache.h; xCache.h then pulls the scheduler/FSM/cache header family (alarm.h, control.h, fsm.h, asyncio.h), and latch.h pulls pssmpk.h, pssDebug.h, fsm.h and parse.h. These are NSS runtime abstractions, so the next import must start below beast/namespace with the smallest real buildable support layer rather than with nameSpace.c.

Core-owned headers must not be duplicated under include/nwfs. The following are already supplied by the existing core layer and should be found through the mars_nwe::core dependency or the explicit core include path:

include/core/bit.h
include/core/guid.h
include/core/omni.h
include/core/que.h
include/core/utc.h
include/core/xError.h
include/core/xUnicode.h
include/core/zOmni.h

Headers that are genuinely NSS/NWFS-specific are imported flat as include/nwfs/<header>.h; do not keep them under include/nwfs/nss/..., and do not add private copies under src/nwfs/.

The planned code order is therefore:

  1. nwcore-nss-spinlock: Linux-userspace spinlock primitive backed by POSIX pthread_spinlock_t. This is core-owned because the NSS latch/MPK/runtime layer is shared infrastructure, not a filesystem object. mars-nwe is Linux userspace only for this path; do not add BSD portability scaffolding here.
  2. nwcore-nss-mpk-lock: direct NSS pssmpk.h plus public_core/library/os/pssmpk.c import for the global MPKNSS_LOCK API, ported to the core Linux-userspace spinlock backend. The companion NSS histogram base from shared/sdk/include/histogram.h and public_core/library/misc/histogram.c is also present so the MPK MeasureSpinLock instrumentation path keeps its original shape. This is now present in libnwcore and covered by nwcore.pssmpk.
  3. nwcore-nss-runtime-base: the next smallest real subset of NSS scheduler/FSM headers and sources needed by latch.h/xCache.h, with Linux-kernel-only or NDPS/DDS-only includes removed or guarded only when the filesystem path does not use them.
  4. nwfs-latch-cache-base: direct imports for latch/cache types required by beast structures once the generic runtime primitives are in core.
  5. nwfs-beast-base: beast class and root-beast structure support.
  6. nwfs-admin-volume: build the _ADMIN virtual volume model, but do not expose it through NCP until the runtime path is ready.
  7. nwfs-namespace-registry: nameSpace.c and registration state.
  8. DOS namespace activation: build dosNSpace.c only after the registry and its real dependencies are present.

The _ADMIN volume ID policy for that later import is fixed even while the volume is hidden from NCP:

SYS     => volume ID 0
_ADMIN  => volume ID 1
other volumes start at ID 2

_ADMIN virtual volume

NSS also carries the _ADMIN management volume model. It is storage/filesystem management state, not a primitive core helper and not an eDirectory library by itself.

Known NSS/OES shape to preserve later:

SYS     => reserved volume ID 0
_ADMIN  => reserved volume ID 1

_ADMIN is a virtual system/management NCP volume. It should not be treated as a normal exported data volume and should not be enabled by default for NetWare 3.x behavior. Later libnwfs work can model it as hidden/admin-only and expose NSS management trees such as:

_ADMIN:/Pools
_ADMIN:/Volumes
_ADMIN:/NameSpaces
_ADMIN:/BeastClasses
_ADMIN:/AuthModels
_ADMIN:/Manage_NSS/...

Use libnwnds only for the eDirectory backend portions behind this virtual filesystem when those are imported. The virtual volume/runtime belongs to libnwfs.

Compression follow-up

NSS compression is another libnwfs candidate, not libnwcore.

Lowlevel algorithm sources found under public_core/comn/compression/:

cdcomp.c
cdcompa.c
cduncomp.c
cduncompa.c
copyAlgo.c
nwAlgo.c
nwAlgo.h
cdcommon.h
cdcomp.h
cduncomp.h

Larger compression manager/runtime sources also exist there:

cmActivity.c
cmAlgoMan.c
cmBgCompress.c
cmCompDecomp.c
cmCompFile.c
cmControl.c
cmRuntime.c
comnCompress.c

Import order should be:

  1. Data stream / namespace / volume metadata basis.
  2. Lowlevel NetWare/NSS compression algorithm.
  3. Compression metadata/accounting and active compression/decompression state.
  4. NCP providers.

Relevant NCP endpoints already audited in decimal and wire/code notation:

decimal 90/12  == wire/code 0x5a/0x0c  Set Compressed File Size
decimal 123/70 == wire/code 0x7b/0x46  Get Current Compressing File
decimal 123/71 == wire/code 0x7b/0x47  Get Current DeCompressing File Info List
decimal 123/72 == wire/code 0x7b/0x48  Get Compression and Decompression Time and Counts
decimal 22/51  == wire/code 0x16/0x33  Extended Volume Info compression counters

Do not synthesize fake compression state. Those endpoints should remain stubbed/guarded until libnwfs has real stream/volume compression state.

Host-created files and namespace reconciliation

The namespace replacement must cover files that appear without a MARS/NCP create path. Samba, rsync, backup restore, local mv/cp, and administrator edits can all create visible directory entries under a volume root before MARS-NWE has a DOS/LONG/MAC/UNIX namespace record for them.

The future libnwfs namespace layer should therefore pair the NSS namespace engine with a host-side reconcile path:

watcher path:
  inotify/fanotify for CREATE, MOVED_TO, DELETE, RENAME and ATTRIB
  update or create netware.metadata where the event is unambiguous
  invalidate namespace lookup/search/namecache state

startup/full scan path:
  walk the visible Linux tree after volume mount/startup
  allocate missing stable file IDs in netware.metadata
  create DOS/LONG/MAC/UNIX namespace records for normal files
  report orphaned .nwfs_streams and invalid .recycle metadata

For an ordinary host-created file, use conservative initial names: UNIX/backend name is the current Linux name, LONG/OS2 name is the current Linux name, DOS name is generated by the DOS namespace engine, and MAC name is derived only through the future MAC namespace rules. Do not create a private side database for this state; netware.metadata remains authoritative.

MAC namespace state is not transport state. Classic Mac clients may later arrive through TCP/IP NCP, but the namespace engine sees namespace IDs and file requests, not TCP-specific session data. Resource forks and Finder info belong to libnwfs streams/metadata.

Patch plan

Recommended next patches:

  1. Continue replacing namespace-model stubs with the smallest buildable NSS namespace primitives directly under src/nwfs/.
  2. Import/adapt DOS and LONG namespace scan/compare/convert functions.
  3. Import/adapt MAC and UNIX namespace functions, with metadata hooks tied to NSS-shaped metadata rather than private parallel state.
  4. Import/adapt Data Stream and Extended Attribute namespace helpers.
  5. Add regression tests against current MARS DOS/OS2 behavior.
  6. Switch namspace.c callsites from old MARS namedos/nameos2 logic to the imported NSS namespace code.
  7. Remove old namedos/nameos2 after behavior is covered.
  8. Add libnwfs follow-ups for _ADMIN, namespace registration visibility, and compression after the namespace/storage basis is present.

Endpoint relevance

The namespace replacement primarily supports NCP namespace/file endpoints, especially decimal 87 == wire/code 0x57. Data stream and extended attribute namespace support also feeds NSS-shaped metadata and future 4.x guarded work.

This does not change the NetWare 3.x priority: DOS behavior must remain correct, and 4.x/MAC/UNIX/DataStream/EA pieces can stay guarded until callsites are ready.

0488 core: import NSS mailbox runtime

Imported the real NSS mailbox runtime before FSM/latch:

  • shared/sdk/include/mailbox.h -> include/core/mailbox.h
  • public_core/library/os/mailbox.c -> src/core/mailbox.c

This is a bottom-up dependency for public_core/library/fsm/fsmnw.c and the latch runtime. No scheduler wrapper is introduced in this step.

0489 core: import NSS production debug header base

Imported the real NSS production-debug interface before FSM/latch:

  • shared/sdk/include/pssDebug.h -> include/core/pssDebug.h
  • shared/sdk/include/schedule.h -> include/core/schedule.h
  • shared/sdk/library/xStdio.h -> include/core/xStdio.h
  • shared/sdk/library/inlines.h -> include/core/inlines.h
  • public_core/library/debug/pssDebug.c -> src/core/pssDebug.c

This is intentionally the production/no-debug path: NSS_DEBUG is disabled by include/core/omni.h, so DEBUG_PRINTF, ENTER, RTN_*, and related macros compile to the same inert form as the original header's #else /* NSS_DEBUG */ branch. The Linux userspace port keeps the original header/source shape but moves the scheduler/xStdio/inlines includes behind NSS_DEBUG IS_ENABLED, so the inactive debug branch does not pull the full scheduler/console stack before FSM and alarm are imported.

The next runtime import can now use <pssDebug.h> without local stubs. FSM still comes later from public_core/library/fsm/fsmnw.c; do not reintroduce a scheduler wrapper.

0490 core: import NSS stdio formatter runtime

Imported the NSS bounded formatter as another bottom-up core dependency before parse/FSM/latch code:

  • public_core/library/stdio/snprintf.c -> src/core/snprintf.c
  • public_core/library/stdio/snprintf.h -> include/core/snprintf.h

This is not an .imp reconstruction and not a libc replacement. The port keeps the formatter implementation and makes only Linux-userspace compile changes: remove the kernel module include, use existing core Unicode declarations, and keep the two formatter-local Stack_s allocations on automatic storage until the real NSS private stack/MPK allocator layer is imported.

Existing core UTC remains authoritative; no NSS UTC duplicate was imported.

0491 stdio formatter prerequisite

Imported public_core/library/stdio/sprintf.c and public_core/library/stdio/vsprintf.c into src/core/ with only Linux userspace include adjustment from <stdio.h>/<linux/limits.h> to the existing Core NSS stdio header and standard <limits.h>. This keeps parse/wio work bottom-up without inventing wrappers.

0492 core: import NSS Linux WIO output base

The parse dependency chain now has the real NSS WIO output base instead of a local wrapper:

  • shared/sdk/include/wio.h is imported as include/core/wio.h.
  • public_core/library/wio/wio.c is imported as src/core/wio.c; its Linux LB__wioOutput() path is used.
  • public_core/library/wio/nssUI.c is imported as src/core/nssUI.c; the kernel /proc transport is ported to Linux userspace stdout while retaining the NSS NSS_UI_vprintf() formatter/colour path.
  • The small WIO stdio forwarding files are imported from NSS rather than recreated: printf.c, vprintf.c, aprintf.c, vaprintf.c, wprintf.c, wvprintf.c, and waprintf.c.

This still does not import full interactive window/input handling. Parser help paths that require cursor movement and wrapping will need the next real WIO functions (wGetPos, wSetPos, wWrapString) or the parser must be imported only after those NSS sources are available and ported.

0493 Core production-debug/WIO cleanup

After importing the Linux WIO output path, the production pssDebug.h path no longer needs to hide the NSS stdio declarations behind NSS_DEBUG. Keep the heavy scheduler include gated until the real scheduler/FSM runtime is imported, but expose the real xStdio.h and inlines.h includes unconditionally so PRINT() resolves through the imported WIO/stdio stack instead of relying on implicit declarations or placeholder output assumptions.

This audit also rechecked the earlier runtime patches for placeholders. The remaining known non-final item is procdefs.h, which is still a small Core port header rather than the full Linux-kernel NSS lnxmbINC/procdefs.h; keep it tracked until the real scheduler/OS layer decides which declarations are needed. Do not expand it by copying .imp files or inventing missing APIs.