From e66cda17f9d1f766cf031e73abc1ad9b92ade209 Mon Sep 17 00:00:00 2001 From: NathanNeurotic <109461996+NathanNeurotic@users.noreply.github.com> Date: Tue, 1 Dec 2026 07:39:04 -0800 Subject: [PATCH 1/3] Bundle the new Neutrino release and launch NFS ISOs --- .github/workflows/compile.yml | 7 +- .github/workflows/neutrino-watch.yml | 18 +++-- README.md | 2 +- docs-site/content/neutrino.html | 14 ++-- docs-site/content/nfs.html | 2 +- docs-site/content/smb.html | 2 +- include/neutrino_smb.h | 7 +- include/smb_shares.h | 1 + scripts/neutrino_release.sh | 32 +++++++++ src/dash_games.c | 22 +++--- src/neutrino_iso.c | 77 +++++++++++--------- src/neutrino_smb.c | 69 ++++++++++++------ src/smb_cnf.c | 12 +++- src/smb_shares.c | 2 +- tests/test_neutrino_menu_audio.py | 34 +++++++-- tests/test_neutrino_smb.py | 104 +++++++++++++++++++-------- 16 files changed, 276 insertions(+), 129 deletions(-) create mode 100644 scripts/neutrino_release.sh diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 1c292a72e..822f42187 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -536,17 +536,14 @@ jobs: set -euo pipefail sudo apt-get update -qq sudo apt-get install -y -qq p7zip-full - mkdir -p build/companion for attempt in 1 2 3 4; do - if gh release download latest --repo ps2max32/neutrino --dir build/companion --pattern '*.7z' --clobber; then + if archive="$(timeout 120s bash scripts/neutrino_release.sh build/companion)"; then break fi test "${attempt}" -lt 4 || { echo "::warning::Could not download the Neutrino release; the full kit is skipped" >&2; exit 1; } sleep $((attempt * 15)) done - mapfile -t cores < <(find build/companion -maxdepth 1 -name 'neutrino_*.7z' -type f) - test "${#cores[@]}" -eq 1 || { echo "::warning::Expected one neutrino_*.7z, found ${#cores[@]}; the full kit is skipped" >&2; exit 1; } - echo "NEUTRINO_ARCHIVE=${cores[0]}" >> "$GITHUB_ENV" + echo "NEUTRINO_ARCHIVE=$archive" >> "$GITHUB_ENV" - name: Stage the pinned POPS and EMBER externals id: kit_externals diff --git a/.github/workflows/neutrino-watch.yml b/.github/workflows/neutrino-watch.yml index adbbc90ab..79de082de 100644 --- a/.github/workflows/neutrino-watch.yml +++ b/.github/workflows/neutrino-watch.yml @@ -1,9 +1,8 @@ name: Neutrino Watch -# Keeps the full kit (LAUNCHSTATION-.zip) level with the upstream Neutrino development build. +# Keeps the full kit (LAUNCHSTATION-.zip) level with the newest published Neutrino build. # -# Automated-Build already downloads the newest build of the ps2max32/neutrino "latest" pre-release (the -# development build, not the stable v1.x tag) every time it runs, but it only runs on a push to master. This +# Automated-Build selects the newest published upstream archive on each push to master. This # watch covers the other half: when upstream publishes a newer Neutrino than the one inside the kit on our # "latest" release, it starts Automated-Build on master so the kit is rebuilt without waiting for a commit. # @@ -32,18 +31,17 @@ jobs: runs-on: ubuntu-latest env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NEUTRINO_REPO: ps2max32/neutrino steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + persist-credentials: false - name: Compare upstream Neutrino against the kit; rebuild if newer run: | set -eu R="$GITHUB_REPOSITORY" - # Upstream: the .7z of Neutrino's "latest" development pre-release. - UP="$(gh api "repos/$NEUTRINO_REPO/releases/tags/latest" \ - --jq '[.assets[] | select(.name | test("^neutrino_.*[.]7z$"))][0] | [.name, (.digest // "")] | @tsv' 2>/dev/null || true)" - UP_NAME="$(printf '%s' "$UP" | cut -f1)" - UP_SHA="$(printf '%s' "$UP" | cut -f2)" - UP_SHA="${UP_SHA#sha256:}" + UP="$(timeout 120s bash scripts/neutrino_release.sh || true)" + UP_NAME="$(printf '%s' "$UP" | cut -f2)" + UP_SHA="$(printf '%s' "$UP" | cut -f3)" echo "upstream Neutrino = [$UP_NAME] [$UP_SHA]" if [ -z "$UP_NAME" ] || [ -z "$UP_SHA" ]; then echo "Could not read upstream Neutrino's build and SHA-256 (transient?); nothing to do." diff --git a/README.md b/README.md index 00a979b64..2a7707259 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Storage drivers generally start when needed. **Not checked** means a device has - Launch **PS1 VCDs through [POPStarter](https://www.psx-place.com/threads/popstarter.19139/)**, or **CUE/BIN/EXE images through [Ember](https://github.com/Gageformer/Ember)** under a save-safe `/games//` layout. The selected file format chooses the PS1 loader. - Configure or discover external loader paths, independently disable each image loader, and optionally send game IDs to [RetroGem](https://www.pixelfx.co/hdmi-retro-gem) or supported MMCE card-selection paths. -The app packages contain Launchstation; game loaders must be installed separately or supplied by the full kit. Launch support depends on the device and loader. SMB ISO launching uses Neutrino's own SMB backend and needs its complete SMB-capable installation on a local device; the full kit's Neutrino (upstream's latest development build, v1.8.0-61-g7be8de2 of 2026-08-31) predates that backend, so it cannot launch SMB ISOs yet. Direct executable/game launching from PC CARD CF is unsupported. See [Game launching](https://nathanneurotic.github.io/Launchstation/game-launching.html) for each loader's files, layouts and limitations. +The app packages contain Launchstation; game loaders must be installed separately or supplied by the full kit. Launch support depends on the device and loader. SMB and NFS ISO launching use the backends in [Neutrino v1.9.0-beta](https://github.com/ps2max32/neutrino/releases/tag/v1.9.0-beta), selected by the full-kit build. Install the complete Neutrino folder on a local device. Direct executable/game launching from PC CARD CF is unsupported. See [Game launching](https://nathanneurotic.github.io/Launchstation/game-launching.html) for each loader's files, layouts and limitations. ### Files, saves and card images diff --git a/docs-site/content/neutrino.html b/docs-site/content/neutrino.html index 5c53c5c3a..3ae9a3d07 100644 --- a/docs-site/content/neutrino.html +++ b/docs-site/content/neutrino.html @@ -38,7 +38,7 @@

Launch arguments

-qb -cwd=<neutrino install directory> [-gc=…] [-gsm=…] [-dbc] [-logo] -

-qb is omitted for SMB so Neutrino resets the IOP into its own network stack. For the other supported devices, -qb is Neutrino’s quick-boot. The numeric unit suffix of a path, where present, is accepted by Neutrino’s backend detection. Argument text is limited, and an over-long path is refused with “Neutrino launch arguments are too long”.

+

-qb is omitted for SMB and NFS so Neutrino resets the IOP into its own network stack. For the other supported devices, -qb is Neutrino’s quick-boot. The numeric unit suffix of a path, where present, is accepted by Neutrino’s backend detection. Argument text is limited, and an over-long path is refused with “Neutrino launch arguments are too long”.

Supported sources

@@ -49,6 +49,7 @@

Supported sources

+
Launchstation sourceNeutrino BSD
exFAT HDD (ata0:)ata
UDPFSudpfs
SMB / SMB1 browser sharesmb; SMB 3.0 on port 445 after an IOP reset (see below)
NFS exportnfs, NFSv4.0 on port 2049 after an IOP reset
APA HDD, memory card, PC CARD CF, disc, hostNot supported: “Neutrino ISO launching is not supported from this device”
@@ -65,7 +66,7 @@

Game ID, RetroGem and MMCE cards

This conservative policy intentionally differs from upstream R3Z, which initialises MMCE unconditionally.

Keep-IOP hand-off

-

Neutrino consumes the already-mounted backing store. ISO launches therefore drain Launchstation’s background I/O, release the controller library and jump to Neutrino on a live IOP. They do not obey Reset IOP before launch. For SMB, Neutrino then resets the IOP itself and reconnects with usmb2; the browser session is not reused.

+

Neutrino consumes the already-mounted backing store. ISO launches therefore drain Launchstation’s background I/O, release the controller library and jump to Neutrino on a live IOP. They do not obey Reset IOP before launch. For SMB and NFS, Neutrino then resets the IOP and opens a new connection through its own network driver.

If a game does not boot

    @@ -79,8 +80,11 @@

    If a game does not boot

SMB games through Neutrino

-

Neutrino's SMB backend, by Ronnie Sahlberg, was merged on 2026-10-31. It uses his usmb2 client. It needs a whole Neutrino folder built after that merge, including modules/smb_ioman.irx, modules/smb_fhi.irx and the stock config/bsd-smb.toml. Keep that folder on a local device (for example mc0:/neutrino/ or USB), and select its ELF in Launching settings. A core stored on SMB or UDPFS is refused for this handoff.

-
The full kit's Neutrino is older
The full kit bundles upstream's latest development build, which is still v1.8.0-61-g7be8de2 from 2026-08-31 (checked 2026-11-13). It predates the SMB backend and has no SMB modules, so with the kit as shipped an SMB ISO launch stops with “Install the complete latest Neutrino nightly with SMB modules”. Use a Neutrino built from upstream's master until upstream publishes a newer build. Neutrino's NFS backend (PR #240, merged 2026-11-12) is not used by Launchstation yet: ISOs on nfs: are not handed to Neutrino.
+

Neutrino's SMB backend, by Ronnie Sahlberg, was merged on 2026-10-31. It uses his usmb2 client. It needs a whole Neutrino folder built after that merge, including modules/smb_ioman.irx, modules/smb_fhi.irx and the stock config/bsd-smb.toml. The full-kit build includes both SMB and NFS through Neutrino v1.9.0-beta. Keep the complete folder on a local device, such as a memory card or USB, and select its ELF in Launching settings.

Add and connect the share in Settings > Network > SMB shares (see Network shares (SMB)), then open a plain ISO from smb:/<NAME>/... or smbold:/.... The server URL must use a dotted IPv4 address and port 445, and the server must offer SMB 3.0 without required signing or encryption. The SMB1 browser route can be used only when that same server also offers SMB 3.0: Neutrino always makes a new SMB 3.0 connection. With PS2-Servers, use its SMBv3 card on 445, not SMBv1 or the SMBv2 card.

After Run game, Launchstation writes the console's static IPCONFIG address, mask and gateway, and the selected share's server, credentials and share name into the three stock module argument lists. The ISO path is relative to the share; select subfolders in the browser. It preserves the other configuration lines, escapes TOML strings, skips an unchanged file, verifies a changed file, and attempts to restore the original after a failed write. It refuses missing modules, an unrecognised or unwritable config, non-445 ports, DNS server names and overlong values before cleanup. Cancel writes no Neutrino files.

-

Limits: username/password up to 31 characters each, share name up to 63 bytes, and ISO path within the share up to 127 bytes; all four must be printable ASCII (accented or other non-ASCII characters are refused before launch). If rewriting bsd-smb.toml fails and the original cannot be put back, the launch is refused with a message to copy that file from the nightly again. The backend is read-only; there are no SMB VMCs or compressed/split image support. The password is stored in plain text in bsd-smb.toml. Host checks cover mapping, configuration and refusal behavior; PS2 gameplay, reconnect after game IOP resets and a second launch remain untested on hardware.

+

Limits: username/password up to 31 characters each, share name up to 63 bytes, and ISO path within the share up to 127 bytes; all four must be printable ASCII (accented or other non-ASCII characters are refused before launch). If rewriting bsd-smb.toml fails and the original cannot be put back, the launch is refused with a message to replace that file from the release. The backend is read-only; there are no SMB VMCs or compressed/split image support. The password is stored in plain text in bsd-smb.toml. Host checks cover mapping, configuration and refusal behavior; PS2 gameplay, reconnect after game IOP resets and a second launch remain untested on hardware.

+ +

NFS games through Neutrino

+

Connect an NFSv4.0 export on TCP port 2049, then open a plain ISO in Files or place it under CD/ or DVD/ on the export for the Games tab. Keep the complete Neutrino folder on a local device. This path uses the NFS backend by Ronnie Sahlberg, included in v1.9.0-beta.

+

Launchstation writes the network settings, export path and the share’s UID/GID into config/bsd-nfs.toml. Neutrino starts with -bsd=nfs -dvd=nfs:<path within the export> and reconnects after resetting the IOP. The export path and the ISO path within it may each be up to 127 bytes. The backend is read-only, so use a physical memory card for saves. Hardware validation is pending.

diff --git a/docs-site/content/nfs.html b/docs-site/content/nfs.html index 5f0a7a9fc..fa4cd66b3 100644 --- a/docs-site/content/nfs.html +++ b/docs-site/content/nfs.html @@ -39,7 +39,7 @@

What you can do

  • Browse, copy, rename, make and delete folders inside a share. File dates and attributes are not set on the server. Rename works inside one share, and replaces a file of the new name.
  • Nothing can be made in nfs:/ itself: it only lists the connected shares.
  • Launch an ELF from a share. Not yet tested.
  • -
  • PS2 ISO games through Neutrino are not supported from nfs: yet: Neutrino needs an NFS backing store first.
  • +
  • PS2 ISO games through Neutrino: connect the export on port 2049 and open a plain ISO. Use the complete Neutrino v1.9.0-beta or newer folder on a local device. See NFS games through Neutrino for limits and the Games tab layout.
  • Stack rules

    diff --git a/docs-site/content/smb.html b/docs-site/content/smb.html index a247a5779..b039f4a98 100644 --- a/docs-site/content/smb.html +++ b/docs-site/content/smb.html @@ -62,7 +62,7 @@

    What you can do

  • Browse, copy, rename, make and delete folders inside a share. A listing that fails part-way is an error, not a partial list. File dates and attributes are not set on the server (the SMB2 driver has no way to).
  • Nothing can be made in smb:/ itself: it only lists the connected shares. Rename works inside one share.
  • Launch an ELF from a share, as from udpfs:. Not yet tested.
  • -
  • PS2 ISO games through Neutrino: install a complete Neutrino built after its SMB backend was merged (2026-10-31) on a local device, then open the ISO. The full kit's Neutrino is older and has no SMB modules yet (see Neutrino SMB). Launchstation maps the selected share and credentials into config/bsd-smb.toml and launches -bsd=smb -dvd=smb:<path within the share>. Neutrino resets the IOP and opens its own session. See Neutrino SMB.
  • +
  • PS2 ISO games through Neutrino: install Neutrino v1.9.0-beta or later on a local device, then open the ISO. Launchstation maps the selected share and credentials into config/bsd-smb.toml and launches -bsd=smb -dvd=smb:<path within the share>. Neutrino resets the IOP and opens its own session. See Neutrino SMB.
  • POPStarter VCDs and Ember images: Launchstation has no SMB handoff for these cores.
  • diff --git a/include/neutrino_smb.h b/include/neutrino_smb.h index 3e23324ac..9a440d00d 100644 --- a/include/neutrino_smb.h +++ b/include/neutrino_smb.h @@ -3,11 +3,10 @@ #include #include "smb_shares.h" -/* Pure, bounded conversion of a configured browser share into Neutrino's - * SMB 3.0 backend. No network activity and no credentials in errors. */ -int neutrinoSmbResolve(const SmbConfig *cfg, const char *path, SmbShare *share, +/* Convert a connected browser share into a path for Neutrino's own backend. */ +int neutrinoShareResolve(const SmbConfig *cfg, const char *path, SmbShare *share, char *dvd, size_t dvd_size, const char **problem); -int neutrinoSmbConfig(const char *original, const SmbShare *share, +int neutrinoShareConfig(const char *original, const SmbShare *share, const char *ip, const char *mask, const char *gw, char *output, size_t output_size); #ifdef SMB diff --git a/include/smb_shares.h b/include/smb_shares.h index ea2f8a2db..2a2ba7498 100644 --- a/include/smb_shares.h +++ b/include/smb_shares.h @@ -60,6 +60,7 @@ typedef struct char server[SMB_SERVER_LEN]; int port; char share[SMB_URL_LEN]; + unsigned int nfs_uid, nfs_gid; /* AUTH_SYS IDs, zero when omitted */ /* Where it stands; problem says why when INVALID or FAILED. */ int state; int error; diff --git a/scripts/neutrino_release.sh b/scripts/neutrino_release.sh new file mode 100644 index 000000000..4833fd6f6 --- /dev/null +++ b/scripts/neutrino_release.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo=ps2max32/neutrino +# The development build uses a moving `latest` tag. Tagged betas and stable +# releases can be published independently, and moving tags can replace their asset in place. +release=$(gh api --paginate "repos/$repo/releases?per_page=100" | jq -ser ' + add + | map(select(.draft == false and .published_at != null)) + | [ .[] | .tag_name as $tag | .published_at as $published + | select($tag == "latest" or ($tag | test("^v[0-9]+[.][0-9]+[.][0-9]+(-[A-Za-z0-9.-]+)?$"))) + | .assets[] + | select(if $tag == "latest" then (.name | test("^neutrino_v[0-9][A-Za-z0-9.-]*[.]7z$")) + else .name == "neutrino_\($tag).7z" end) + | [([$published, .updated_at] | max), $tag, .name, (.digest // "")] ] + | max_by(.[0]) // error("no published Neutrino archive") + | .[1:] + | @tsv') +IFS=$'\t' read -r tag asset digest <<< "$release" +if [[ ! "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "GitHub did not provide a SHA-256 for $asset" >&2 + exit 1 +fi + +if [[ $# == 0 ]]; then + printf '%s\t%s\t%s\n' "$tag" "$asset" "${digest#sha256:}" +else + mkdir -p "$1" + gh release download "$tag" --repo "$repo" --dir "$1" --pattern "$asset" --clobber >&2 + printf '%s %s\n' "${digest#sha256:}" "$1/$asset" | sha256sum --check >&2 + printf '%s\n' "$1/$asset" +fi diff --git a/src/dash_games.c b/src/dash_games.c index 910f4de39..a88a4e6b8 100644 --- a/src/dash_games.c +++ b/src/dash_games.c @@ -195,19 +195,23 @@ static int scanEmber(GameScan *s, const char *root) static void scanRoot(GameScan *s, const char *root, int shares) { char dir[DASH_PATH_MAX], names[GAME_SHARES][MAX_NAME]; - int found, n, i, k = 0, more = 0; - - snprintf(dir, sizeof(dir), "%sDVD/", root); - found = scanFolder(s, dir); - snprintf(dir, sizeof(dir), "%sCD/", root); - found |= scanFolder(s, dir); - if (!shares) { /* smb:/ itself lists shares: an EMBER share must not stop that */ + int nfs = !strncmp(root, "nfs:", 4); + int found = 0, n, i, k = 0, more = 0; + + /* NFS puts every game folder under a named export. */ + if (!shares || !nfs) { + snprintf(dir, sizeof(dir), "%sDVD/", root); + found = scanFolder(s, dir); + snprintf(dir, sizeof(dir), "%sCD/", root); + found |= scanFolder(s, dir); + } + if (!shares && !nfs) { found |= scanPops(s, root); found |= scanEmber(s, root); } if (found || !shares) return; - /* smb:/ lists the shares; each one is an OPL root. */ + /* SMB and NFS give each share its own OPL root. */ n = getDirComplete(root, s->files, &more); for (i = 0; i < n && i < MAX_ENTRY - 2 && k < GAME_SHARES; i++) if ((s->files[i].stats.AttrFile & sceMcFileAttrSubdir) && s->files[i].name[0] != '.') @@ -224,7 +228,7 @@ static void scanRun(void *arg) for (i = 0; i < s->nroots; i++) if (isPathDeviceStackLoaded(s->roots[i])) - scanRoot(s, s->roots[i], !strncmp(s->roots[i], "smb", 3)); + scanRoot(s, s->roots[i], !strncmp(s->roots[i], "smb", 3) || !strncmp(s->roots[i], "nfs:", 4)); if (s->n > 1) qsort(s->games, s->n, sizeof(DashApp), titleCmp); } diff --git a/src/neutrino_iso.c b/src/neutrino_iso.c index 41e3079c9..36c62bca4 100644 --- a/src/neutrino_iso.c +++ b/src/neutrino_iso.c @@ -128,8 +128,10 @@ static const char *neutrinoBsdForPath(const char *path) if (!strncmp(path, "udpfs", 5)) return "udpfs"; #ifdef SMB - /* nfs: is not handed to Neutrino (yet): it reads as not supported */ - if (smbPathKind(path) == SMB_PATH_V1 || smbPathKind(path) == SMB_PATH_V2) + int kind = smbPathKind(path); + if (kind == SMB_PATH_NFS) + return "nfs"; + if (kind == SMB_PATH_V1 || kind == SMB_PATH_V2) return "smb"; #endif return NULL; @@ -141,17 +143,22 @@ int IsNeutrinoGameDevice(const char *path) return neutrinoBsdForPath(path) != NULL; } +static int neutrinoShareBsd(const char *bsd) +{ + return !strcmp(bsd, "smb") || !strcmp(bsd, "nfs"); +} + #ifdef SMB -static int smbCoreLocal(const char *path) +static int shareCoreLocal(const char *path) { const char *bsd = neutrinoBsdForPath(path); return !strncmp(path,"mc0:",4) || !strncmp(path,"mc1:",4) || - (bsd != NULL && strcmp(bsd,"smb") && strcmp(bsd,"udpfs")); + (bsd != NULL && !neutrinoShareBsd(bsd) && strcmp(bsd, "udpfs")); } /* 1: written in full; 0: the file was opened (and truncated) but the write * came up short; -1: the file could not be opened, so it is untouched. */ -static int smbConfigWrite(const char *path, char *data, int size) +static int shareConfigWrite(const char *path, char *data, int size) { int fd = genOpen(path, FIO_O_WRONLY | FIO_O_CREAT | FIO_O_TRUNC); int written, closed; @@ -161,21 +168,25 @@ static int smbConfigWrite(const char *path, char *data, int size) return written == size && closed >= 0; } -static int prepareSmbConfig(const char *core, const SmbShare *share, char *message, size_t size) +static int prepareShareConfig(const char *core, const char *bsd, const SmbShare *share, + char *message, size_t size) { static char original[4096], updated[4608], verify[4608]; - static const char *files[] = {"modules/smb_ioman.irx","modules/smb_fhi.irx","config/bsd-smb.toml"}; + static const char *const modules[] = {"ioman", "fhi"}; char path[MAX_PATH]; const char *slash = strrchr(core,'/'); int prefix, i, fd, length, next, ok = 0; - if (!smbCoreLocal(core) || !slash) { - setMessage(message,size,"Keep the Neutrino installation on a local device for SMB",NULL); + if (!shareCoreLocal(core) || !slash) { + setMessage(message, size, "Keep the Neutrino installation on a local device for SMB or NFS", NULL); return 0; } prefix = (int)(slash-core)+1; for (i = 0; i < 3; i++) { - if (snprintf(path,sizeof(path),"%.*s%s",prefix,core,files[i]) >= (int)sizeof(path) || !fileExists(path)) { - setMessage(message,size,"Install the complete latest Neutrino nightly with SMB modules",NULL); + int length = i < 2 ? snprintf(path, sizeof(path), "%.*smodules/%s_%s.irx", prefix, core, bsd, modules[i]) : + snprintf(path, sizeof(path), "%.*sconfig/bsd-%s.toml", prefix, core, bsd); + if (length < 0 || length >= (int)sizeof(path) || !fileExists(path)) { + setMessage(message, size, "Install the complete Neutrino release with the required modules", + !strcmp(bsd, "nfs") ? "NFS" : "SMB"); return 0; } } @@ -191,10 +202,10 @@ static int prepareSmbConfig(const char *core, const SmbShare *share, char *messa original[length] = 0; if (memchr(original,0,length) != NULL) goto failed; /* IPCONFIG.DAT is the static configuration used by the live browser stack. */ - next = neutrinoSmbConfig(original,share,ip,netmask,gw,updated,sizeof(updated)); + next = neutrinoShareConfig(original, share, ip, netmask, gw, updated, sizeof(updated)); if (next < 0) goto failed; if (next == length && !memcmp(original,updated,length)) { ok = 1; goto done; } - i = smbConfigWrite(path,updated,next); + i = shareConfigWrite(path, updated, next); if (i > 0) { fd = genOpen(path,FIO_O_RDONLY); if (fd >= 0) { @@ -208,12 +219,12 @@ static int prepareSmbConfig(const char *core, const SmbShare *share, char *messa /* A short write aborts the launch and attempts to restore the original. * The file was truncated before the write, so a failed restore leaves it * empty or partial: say so, instead of the generic message. */ - if (smbConfigWrite(path,original,length) <= 0) { - setMessage(message,size,"Neutrino SMB config could not be restored: copy config/bsd-smb.toml from the nightly again",NULL); + if (shareConfigWrite(path, original, length) <= 0) { + setMessage(message, size, "Neutrino config could not be restored. Replace this file from the release", path); goto done; } failed: - setMessage(message,size,"Neutrino SMB config must be writable and use the stock module args",NULL); + setMessage(message, size, "Neutrino config must be writable and use the stock module args", path); done: memset(original,0,sizeof(original)); memset(updated,0,sizeof(updated)); memset(verify,0,sizeof(verify)); return ok; @@ -322,7 +333,7 @@ static int buildArgs(const char *bsd, const char *dvd_path, const char *neutrino slash[1] = '\0'; n = snprintf(buffer, buffer_size, "-bsd=%s\n-dvd=%s\n%s-cwd=%s\n", bsd, dvd_path, - !strcmp(bsd,"smb") ? "" : "-qb\n", cwd); + neutrinoShareBsd(bsd) ? "" : "-qb\n", cwd); if (n <= 0 || n >= (int)buffer_size) { setMessage(message, message_size, "Neutrino launch arguments are too long", dvd_path); return 0; @@ -353,7 +364,7 @@ static int buildArgs(const char *bsd, const char *dvd_path, const char *neutrino if (!options->vmc[i][0]) continue; colon = strstr(dvd_path, ":/"); - if (!strcmp(bsd, "smb") || colon == NULL) { + if (neutrinoShareBsd(bsd) || colon == NULL) { setMessage(message, message_size, "A VMC card needs a game on USB, MX4SIO, MMCE, iLink, exFAT HDD or UDPFS", options->vmc[i]); return 0; } @@ -386,9 +397,9 @@ int LaunchNeutrinoIso(const char *path, char *message, size_t message_size) char selected[MAX_PATH], fullpath[MAX_PATH], party[MAX_PATH]; char opened_iso[MAX_PATH], args[1400]; #ifdef SMB - SmbShare smb_share; - char smb_dvd[132], active_path[MAX_PATH]; - const char *smb_problem; + SmbShare share; + char share_dvd[132], active_path[MAX_PATH]; + const char *share_problem; #endif const char *bsd; int exec_kind, ret; @@ -423,9 +434,11 @@ int LaunchNeutrinoIso(const char *path, char *message, size_t message_size) return 0; } #ifdef SMB - if (!strcmp(bsd,"smb") && !smbSharesNeutrino(path,&smb_share,smb_dvd,sizeof(smb_dvd),&smb_problem)) { - setMessage(message,message_size,smb_problem,NULL); - return 0; + if (neutrinoShareBsd(bsd)) { + if (!smbSharesNeutrino(path, &share, share_dvd, sizeof(share_dvd), &share_problem)) { + setMessage(message, message_size, share_problem, NULL); + return 0; + } } #endif @@ -459,11 +472,11 @@ int LaunchNeutrinoIso(const char *path, char *message, size_t message_size) * then the two memory-card slots. Only complete Neutrino installs qualify. */ if (setting != NULL && setting->neutrino_file[0] != '\0' #ifdef SMB - && (strcmp(bsd,"smb") || smbCoreLocal(setting->neutrino_file)) + && (!neutrinoShareBsd(bsd) || shareCoreLocal(setting->neutrino_file)) #endif ) addCompleteCandidate(&candidates, setting->neutrino_file); - if (strcmp(bsd,"smb") && deviceRootCandidate(path, candidate, sizeof(candidate))) + if (!neutrinoShareBsd(bsd) && deviceRootCandidate(path, candidate, sizeof(candidate))) addPopstarterCandidate(&candidates, candidate); if (findCompleteOnRoot("mc0:", candidate, sizeof(candidate))) addPopstarterCandidate(&candidates, candidate); @@ -486,20 +499,20 @@ int LaunchNeutrinoIso(const char *path, char *message, size_t message_size) } if (!buildArgs(bsd, #ifdef SMB - !strcmp(bsd,"smb") ? smb_dvd : + neutrinoShareBsd(bsd) ? share_dvd : #endif opened_iso, fullpath, &options, args, sizeof(args), message, message_size)) return 0; #ifdef SMB - if (!strcmp(bsd,"smb")) { - ret = prepareSmbConfig(fullpath,&smb_share,message,message_size); - memset(&smb_share,0,sizeof(smb_share)); + if (neutrinoShareBsd(bsd)) { + ret = prepareShareConfig(fullpath, bsd, &share, message, message_size); + memset(&share, 0, sizeof(share)); if (!ret) { LaunchArgsClear(); return 0; } } #endif - /* Keep the core's device mounted for ELF loading. For SMB, omit -qb so - * Neutrino resets the IOP and starts its own ministack/usmb2 session. */ + /* Keep the core's device mounted for ELF loading. SMB and NFS launches + * omit -qb so Neutrino resets the IOP and opens its own network session. */ #ifdef MMCE /* Manager-only control preserves mounts and protects source slots. */ if (have_gameid) diff --git a/src/neutrino_smb.c b/src/neutrino_smb.c index fdae42446..a6947b2f0 100644 --- a/src/neutrino_smb.c +++ b/src/neutrino_smb.c @@ -1,6 +1,5 @@ -/* Neutrino SMB handoff, targeting ps2max32/neutrino #236 (1bff25b), - * by Ronnie Sahlberg, using his usmb2 client. The browser's smb2man session - * is not inherited: Neutrino reconnects after its own IOP reset. */ +/* Neutrino reconnects after resetting the IOP, using Ronnie Sahlberg's + * SMB (ps2max32/neutrino #236) or NFS (#240) backend. */ #include #include #include "neutrino_smb.h" @@ -27,13 +26,14 @@ static int ascii(const char *s) return 1; } -int neutrinoSmbResolve(const SmbConfig *cfg, const char *path, SmbShare *share, +int neutrinoShareResolve(const SmbConfig *cfg, const char *path, SmbShare *share, char *dvd, size_t dvd_size, const char **problem) { const char *name, *relative, *host, *slash, *colon, *sub; size_t length; int i, kind = smbPathKind(path); - *problem = "SMB share is not configured or connected"; + *problem = kind == SMB_PATH_NFS ? "NFS export is not configured or connected" : + "SMB share is not configured or connected"; if (!cfg || !share || !dvd || !kind) return 0; name = path + (kind == SMB_PATH_V1 ? sizeof(SMB_DEVICE_V1) - 1 : 4); while (*name == '/') name++; @@ -42,7 +42,7 @@ int neutrinoSmbResolve(const SmbConfig *cfg, const char *path, SmbShare *share, const SmbShare *s = &cfg->share[i]; int active = s->active_version ? s->active_version : s->version; if (s->state != SMB_STATE_CONNECTED || (s->version != kind && active != kind)) continue; - if (kind == SMB_PATH_V2 && (!relative || strlen(s->name) != (size_t)(relative-name) || + if (kind != SMB_PATH_V1 && (!relative || strlen(s->name) != (size_t)(relative-name) || strncmp(s->name, name, relative-name))) continue; *share = *s; break; @@ -50,6 +50,16 @@ int neutrinoSmbResolve(const SmbConfig *cfg, const char *path, SmbShare *share, if (i == cfg->count) return 0; if (kind == SMB_PATH_V1) relative = name; else relative++; + if (kind == SMB_PATH_NFS) { + *problem = "Neutrino NFS needs an IPv4 server and TCP port 2049"; + if (share->port != 2049 || !ipv4(share->server)) return 0; + *problem = "Neutrino NFS export or ISO path exceeds the driver limits"; + i = snprintf(dvd, dvd_size, "nfs:%s", relative); + if (i < 5 || i >= (int)dvd_size || i - 4 > 127 || strpbrk(relative, "\r\n") || + share->share[0] != '/' || strlen(share->share) > 127) return 0; + *problem = NULL; + return 1; + } *problem = "Neutrino SMB needs an IPv4 server and TCP port 445"; /* Parse independently of the browser driver: its URLs can contain ports * and a subdirectory, whereas usmb2 takes a dotted IP and share separately. */ @@ -80,12 +90,12 @@ int neutrinoSmbResolve(const SmbConfig *cfg, const char *path, SmbShare *share, return 1; } -/* Only accept the stock single-line basic-string args layout for the three - * SMB modules. Preserve every other line, including comments and env values. +/* Accept the single-line basic-string args layout for the network modules. + * Preserve every other line, including comments and env values. * Unknown, duplicate, missing or multiline args are refused before any write. */ -static int argsShape(const char *p, size_t length, int module, const char **tail) +static int argsShape(const char *p, size_t length, const char *const *keys, int count, + unsigned required, const char **tail) { - static const char *keys[] = {"ip=", "mask=", "gw=", "srv=", "user=", "pass=", "share="}; const char *end = p + length; unsigned seen = 0; int k; @@ -101,9 +111,9 @@ static int argsShape(const char *p, size_t length, int module, const char **tail if (p == end) return 0; if (*p == ']') { p++; break; } if (*p++ != '"') return 0; - for (k = 0; k < 7; k++) + for (k = 0; k < count; k++) if ((size_t)(end-p) >= strlen(keys[k]) && !strncmp(p, keys[k], strlen(keys[k]))) break; - if (k == 7 || (module == 1 && k != 0) || (seen & (1u< 126) return 0; + if ((unsigned char)*value < 32 || (unsigned char)*value == 127) return 0; if ((*value == '"' || *value == '\\') && !append(out,size,used,"\\",1)) return 0; if (!append(out,size,used,value,1)) return 0; } return append(out,size,used,"\"",1); } -int neutrinoSmbConfig(const char *original, const SmbShare *share, +int neutrinoShareConfig(const char *original, const SmbShare *share, const char *ip, const char *mask, const char *gw, char *out, size_t size) { - static const char *files[] = {"ministack.irx", "smb_ioman.irx", "smb_fhi.irx"}; - static const char *keys[] = {"ip=", "mask=", "gw=", "srv=", "user=", "pass=", "share="}; - const char *values[] = {ip,mask,gw,share->server,share->username,share->password,share->share}; + static const char *const smb_files[] = {"ministack.irx", "smb_ioman.irx", "smb_fhi.irx"}; + static const char *const nfs_files[] = {"ministack.irx", "nfs_ioman.irx", "nfs_fhi.irx"}; + static const char *const smb_keys[] = {"ip=", "mask=", "gw=", "srv=", "user=", "pass=", "share="}; + static const char *const nfs_keys[] = {"ip=", "mask=", "gw=", "srv=", "export=", "uid=", "gid="}; + int nfs = share->version == SMB_PATH_NFS; + const char *const *files = nfs ? nfs_files : smb_files; + const char *const *keys = nfs ? nfs_keys : smb_keys; + char uid[11], gid[11]; + const char *values[] = {ip, mask, gw, share->server, nfs ? share->share : share->username, + nfs ? uid : share->password, nfs ? gid : share->share}; const char *line = original; size_t used = 0; unsigned seen = 0; int module = 0, k; if (!size || !ipv4(ip) || !strcmp(ip,"0.0.0.0") || !ipv4(mask) || !ipv4(gw) || - !ipv4(share->server) || strlen(share->username) > 31 || strlen(share->password) > 31 || - !share->share[0] || strlen(share->share) > 63) return -1; + !ipv4(share->server)) return -1; + if (nfs) { + if (share->share[0] != '/' || strlen(share->share) > 127) return -1; + snprintf(uid, sizeof(uid), "%u", share->nfs_uid); + snprintf(gid, sizeof(gid), "%u", share->nfs_gid); + } else if (strlen(share->username) > 31 || strlen(share->password) > 31 || + !share->share[0] || strlen(share->share) > 63 || !ascii(share->username) || + !ascii(share->password) || !ascii(share->share)) return -1; out[0] = 0; while (*line) { const char *end = strchr(line,'\n'), *p = line; @@ -170,10 +193,12 @@ int neutrinoSmbConfig(const char *original, const SmbShare *share, } if (module && !strncmp(p,"args",4)) { const char *tail; - if ((seen & (1u<= '0' && *p <= '9'; p++) + for (p += 4; *p >= '0' && *p <= '9'; p++) { if (++digits > 9) return "URL uid or gid is too large"; + value = value * 10 + (*p - '0'); + } if (digits == 0) return "URL uid or gid is not a number"; if (*p != '\0' && *p != '&') return "URL uid or gid is not a number"; + *id = value; } return NULL; } diff --git a/src/smb_shares.c b/src/smb_shares.c index b9b66a563..93af351df 100644 --- a/src/smb_shares.c +++ b/src/smb_shares.c @@ -42,7 +42,7 @@ int smbSharesNeutrino(const char *path, SmbShare *share, char *dvd, { if (!smb_cfg_loaded || smb_cfg_mc1_pending) smbReadConfig(); - return neutrinoSmbResolve(&smb_cfg, path, share, dvd, dvd_size, problem); + return neutrinoShareResolve(&smb_cfg, path, share, dvd, dvd_size, problem); } static char *smb_blocks; /* LAUNCHSTATION.CNF's share blocks; NULL: none */ diff --git a/tests/test_neutrino_menu_audio.py b/tests/test_neutrino_menu_audio.py index e92becb04..637a75e0b 100644 --- a/tests/test_neutrino_menu_audio.py +++ b/tests/test_neutrino_menu_audio.py @@ -57,6 +57,7 @@ def extract_func(text, sig): static int muted, suspended, restored, bgm, calls, commit; static int shutdown_calls, pad_ended; static char opened_path[MAX_PATH]; +static char received_args[1400], neutrino_config_path[MAX_PATH]; static int active_path_calls, neutrino_smb_calls; static jmp_buf launched; static void dashLaunchHook(const char *p) { (void)p; } @@ -64,7 +65,11 @@ def extract_func(text, sig): static void dashStrCopy(char *d, const char *s, size_t n) { snprintf(d,n,"%s",s); } static void LaunchArgsClear(void) {} static int LaunchArgsLoadFromBuffer(const char *p, char *a, size_t n, char *m, size_t s) { - (void)p; (void)a; (void)n; (void)m; (void)s; return 1; + (void)p; (void)m; (void)s; + assert(n < sizeof(received_args)); + memcpy(received_args, a, n); + received_args[n] = '\0'; + return 1; } static void dashModalMessage(int i, const char *t, const char *b, const char *d) { (void)i; (void)t; (void)b; (void)d; @@ -99,13 +104,22 @@ def extract_func(text, sig): static void closeKeyboardIfOpened(void) {} static void dashGfxRestoreLegacyState(void) {} static void dashClassicUiInstall(int n) { (void)n; } -int smbPathKind(const char *p) { return !strncmp(p, "smbold:", 7) ? SMB_PATH_V1 : !strncmp(p, "smb:", 4) ? SMB_PATH_V2 : SMB_PATH_NONE; } +int smbPathKind(const char *p) { + if (!strncmp(p, "nfs:", 4)) return SMB_PATH_NFS; + if (!strncmp(p, "smbold:", 7)) return SMB_PATH_V1; + return !strncmp(p, "smb:", 4) ? SMB_PATH_V2 : SMB_PATH_NONE; +} int smbSharesActivePath(const char *p, char *out, int size) { active_path_calls++; return !strncmp(p, "smb:/AUTO/", 10) ? snprintf(out, size, "smbold:/%s", p + 10) < size : snprintf(out, size, "%s", p) < size; } int smbSharesNeutrino(const char *p, SmbShare *share, char *dvd, size_t size, const char **problem) { - (void)p; memset(share, 0, sizeof(*share)); snprintf(dvd, size, "smb:game.iso"); *problem = NULL; neutrino_smb_calls++; return 1; + memset(share, 0, sizeof(*share)); + share->version = smbPathKind(p); + snprintf(dvd, size, "%s", share->version == SMB_PATH_NFS ? "nfs:DVD/game.iso" : "smb:game.iso"); + *problem = NULL; + neutrino_smb_calls++; + return 1; } static int openPathForRead(const char *p, char *o, size_t n) { snprintf(opened_path, sizeof(opened_path), "%s", p); @@ -126,10 +140,14 @@ def extract_func(text, sig): #define FIO_O_WRONLY 2 #define FIO_O_CREAT 4 #define FIO_O_TRUNC 8 -static int genOpen(const char *p, int f) { (void)p; (void)f; return -1; } +static int genOpen(const char *p, int f) { + (void)f; + snprintf(neutrino_config_path, sizeof(neutrino_config_path), "%s", p); + return -1; +} static int genWrite(int fd, const void *data, size_t size) { (void)fd; (void)data; return (int)size; } static char ip[16], netmask[16], gw[16]; -int neutrinoSmbConfig(const char *original, const SmbShare *share, const char *address, const char *mask, const char *gateway, char *out, size_t size) { +int neutrinoShareConfig(const char *original, const SmbShare *share, const char *address, const char *mask, const char *gateway, char *out, size_t size) { (void)original; (void)share; (void)address; (void)mask; (void)gateway; (void)out; (void)size; return -1; } static int addPopstarterCandidate(POPSTARTER_CANDIDATE_LIST *c, const char *p) { (void)p; c->count++; return 1; } @@ -209,6 +227,12 @@ def extract_func(text, sig): LaunchNeutrinoIso("smb:/AUTO/game.iso", exec_ctx.main_msg, MAX_PATH); assert(active_path_calls == 1 && neutrino_smb_calls == 1); assert(!strcmp(opened_path, "smbold:/game.iso")); + commit = 1; + assert(!LaunchNeutrinoIso("nfs:/NAS/DVD/game.iso", exec_ctx.main_msg, MAX_PATH)); + assert(active_path_calls == 1 && neutrino_smb_calls == 2); + assert(!strcmp(received_args, "-bsd=nfs\n-dvd=nfs:DVD/game.iso\n-cwd=usb0:/NEUTRINO/\n")); + assert(!strcmp(neutrino_config_path, "usb0:/NEUTRINO/config/bsd-nfs.toml")); + assert(!muted && shutdown_calls == 0); free(setting); puts("PASS: ISO menu audio, cancellation/failure recovery, committed launch and ordinary ELF muting"); } diff --git a/tests/test_neutrino_smb.py b/tests/test_neutrino_smb.py index 043366451..4676d2d65 100644 --- a/tests/test_neutrino_smb.py +++ b/tests/test_neutrino_smb.py @@ -1,4 +1,4 @@ -"""Run the real SMB path/config conversion and config IO preflight on the host.""" +"""Exercise the SMB and NFS launch configuration and its on-disk preflight.""" from pathlib import Path import json import subprocess @@ -21,6 +21,21 @@ args = ["ip=192.168.1.10", "mask=255.255.255.0", "gw=192.168.1.1", "srv=192.168.1.2", "user=guest", "pass=", "share=PS2SMB"] env = ["EE"] ''' +NFS = '''name = "NFS driver" +depends = ["i_dev9_hidden"] +[[module]] +file = "ministack.irx" +args = ["ip=192.168.1.10"] +env = ["LE", "EE"] +[[module]] +file = "nfs_ioman.irx" +args = ["ip=192.168.1.10", "mask=255.255.255.0", "gw=192.168.1.1", "srv=192.168.1.2", "export=/srv/ps2"] +env = ["LE"] +[[module]] +file = "nfs_fhi.irx" +args = ["ip=192.168.1.10", "mask=255.255.255.0", "gw=192.168.1.1", "srv=192.168.1.2", "export=/srv/ps2"] +env = ["EE"] +''' def function(name): start = ISO.index(name) @@ -38,10 +53,11 @@ def function(name): #define FIO_O_CREAT 2 #define FIO_O_TRUNC 4 static const char *stock = @STOCK@; +static const char *nfs = @NFS@; static char disk[8192], ip[16]="10.0.0.7", netmask[16]="255.255.0.0", gw[16]="10.0.0.1"; static int pos, writes, write_opens, fail_write, missing, readonly; static int genOpen(const char *path, int flags) { - if (missing && strstr(path,"smb_fhi.irx")) return -1; + if (missing && strstr(path,"_fhi.irx")) return -1; if (flags) write_opens++; if (flags && readonly) return -1; pos=0; @@ -62,7 +78,7 @@ def function(name): memcpy(disk,buf,size); disk[size]=0; return size; } static void setMessage(char *msg,size_t size,const char *text,const char *path) { - (void)path; snprintf(msg,size,"%s",text); + snprintf(msg,size,"%s%s%s",text,path ? ": " : "",path ? path : ""); } @FUNCTIONS@ static void parse(SmbConfig *cfg,const char *text) { @@ -74,62 +90,88 @@ def function(name): char dvd[132], out[8192], second[8192], msg[256], path[256]; const char *why; parse(&cfg,"NAME=PC\nUSERNAME=player\nPASSWORD=pa\"ss\\word\nURL=smb://10.0.0.2/games/sub\n"); - assert(neutrinoSmbResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); /* smb2man's pinned driver ignores URL subdirectories; match its browser view. */ assert(!strcmp(dvd,"smb:DVD/game.iso") && !strcmp(sh.share,"games") && !strcmp(sh.server,"10.0.0.2")); - assert(!neutrinoSmbResolve(&cfg,"smb:/OTHER/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(!neutrinoShareResolve(&cfg,"smb:/OTHER/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); strcpy(cfg.share[0].url,"smb://nas/games"); - assert(!neutrinoSmbResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(!neutrinoShareResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); strcpy(cfg.share[0].url,"smb://10.0.0.2:1445/games"); - assert(!neutrinoSmbResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(!neutrinoShareResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); strcpy(cfg.share[0].url,"smb://10.0.0.2:445/games"); - assert(neutrinoSmbResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); memset(path,'a',sizeof(path)); memcpy(path,"smb:/PC/",8); path[200]=0; - assert(!neutrinoSmbResolve(&cfg,path,&sh,dvd,sizeof(dvd),&why)); - assert(neutrinoSmbResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); - assert(neutrinoSmbConfig(stock,&sh,ip,netmask,gw,out,sizeof(out))>0); + assert(!neutrinoShareResolve(&cfg,path,&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smb:/PC/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareConfig(stock,&sh,ip,netmask,gw,out,sizeof(out))>0); assert(strstr(out,"pass=pa\\\"ss\\\\word") && strstr(out,"# keep this comment")); assert(strstr(out,"depends = [\"i_dev9_hidden\"]") && strstr(out,"srv=10.0.0.2")); - assert(neutrinoSmbConfig(out,&sh,ip,netmask,gw,second,sizeof(second))>0 && !strcmp(out,second)); - assert(neutrinoSmbConfig(stock,&sh,"999.0.0.1",netmask,gw,out,sizeof(out))<0); - assert(neutrinoSmbConfig(stock,&sh,ip,netmask,gw,out,20)<0); + assert(neutrinoShareConfig(out,&sh,ip,netmask,gw,second,sizeof(second))>0 && !strcmp(out,second)); + assert(neutrinoShareConfig(stock,&sh,"999.0.0.1",netmask,gw,out,sizeof(out))<0); + assert(neutrinoShareConfig(stock,&sh,ip,netmask,gw,out,20)<0); strcpy(second,stock); *strstr(second,"pass=")='X'; - assert(neutrinoSmbConfig(second,&sh,ip,netmask,gw,out,sizeof(out))<0); + assert(neutrinoShareConfig(second,&sh,ip,netmask,gw,out,sizeof(out))<0); strcpy(disk,stock); writes=0; - assert(prepareSmbConfig("mass:/neutrino/neutrino.elf",&sh,msg,sizeof(msg)) && writes==1); - assert(prepareSmbConfig("mass:/neutrino/neutrino.elf",&sh,msg,sizeof(msg)) && writes==1); + assert(prepareShareConfig("mass:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg)) && writes==1); + assert(prepareShareConfig("mass:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg)) && writes==1); strcpy(disk,stock); fail_write=1; - assert(!prepareSmbConfig("mc0:/neutrino/neutrino.elf",&sh,msg,sizeof(msg)) && !strcmp(disk,stock)); + assert(!prepareShareConfig("mc0:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg)) && !strcmp(disk,stock)); assert(!strstr(msg,"restored")); /* Both the update and the restore come up short: the file is damaged * and the message must say so rather than blame the module args. */ strcpy(disk,stock); fail_write=2; - assert(!prepareSmbConfig("mc0:/neutrino/neutrino.elf",&sh,msg,sizeof(msg)) && strcmp(disk,stock)); + assert(!prepareShareConfig("mc0:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg)) && strcmp(disk,stock)); assert(strstr(msg,"could not be restored") && strstr(msg,"bsd-smb.toml")); missing=1; writes=0; - assert(!prepareSmbConfig("mass:/neutrino/neutrino.elf",&sh,msg,sizeof(msg)) && !writes); missing=0; + assert(!prepareShareConfig("mass:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg)) && !writes); missing=0; /* Read-only media: the write open fails before anything is truncated, so * the file is intact and the generic message applies, not the restore one. */ strcpy(disk,stock); readonly=1; write_opens=0; - assert(!prepareSmbConfig("mass:/neutrino/neutrino.elf",&sh,msg,sizeof(msg))); readonly=0; + assert(!prepareShareConfig("mass:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg))); readonly=0; assert(write_opens==1 && !strcmp(disk,stock) && strstr(msg,"writable") && !strstr(msg,"restored")); - assert(!prepareSmbConfig("smb:/PC/neutrino/neutrino.elf",&sh,msg,sizeof(msg))); - assert(!prepareSmbConfig("udpfs:/neutrino/neutrino.elf",&sh,msg,sizeof(msg))); + assert(!prepareShareConfig("smb:/PC/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg))); + assert(!prepareShareConfig("udpfs:/neutrino/neutrino.elf","smb",&sh,msg,sizeof(msg))); parse(&cfg,"NAME=OLD\nVERSION=1\nURL=smb://10.0.0.2/games\n"); - assert(neutrinoSmbResolve(&cfg,"smbold:/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smbold:/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); assert(!strcmp(dvd,"smb:DVD/game.iso")); parse(&cfg,"NAME=AUTO\nURL=smb://10.0.0.2/games\n"); cfg.share[0].active_version=1; - assert(neutrinoSmbResolve(&cfg,"smbold:/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smbold:/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); assert(!strcmp(dvd,"smb:DVD/game.iso")); - assert(neutrinoSmbResolve(&cfg,"smb:/AUTO/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"smb:/AUTO/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + parse(&cfg,"NAME=NAS\nURL=nfs://10.0.0.2:3049/srv/PS2?uid=1000&gid=1001\n"); + assert(!neutrinoShareResolve(&cfg,"nfs:/NAS/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(strstr(why,"2049")); + parse(&cfg,"NAME=NAS\nURL=nfs://10.0.0.2/srv/PS2?uid=1000&gid=1001\n"); + assert(!neutrinoShareResolve(&cfg,"nfs:/OTHER/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(!neutrinoShareResolve(&cfg,"nfs:/NAS/DVD/game\nname.iso",&sh,dvd,sizeof(dvd),&why)); + assert(neutrinoShareResolve(&cfg,"nfs:/NAS/DVD/game with spaces.iso",&sh,dvd,sizeof(dvd),&why)); + assert(!strcmp(dvd,"nfs:DVD/game with spaces.iso")); + assert(!strcmp(neutrinoBsdForPath("nfs:/"),"nfs") && neutrinoShareBsd("nfs")); + assert(neutrinoShareConfig(nfs,&sh,ip,netmask,gw,out,sizeof(out)) > 0); + const char *args = "\"export=/srv/PS2\", \"uid=1000\", \"gid=1001\""; + const char *first = strstr(out,args); + assert(first && strstr(first + strlen(args),args)); + assert(neutrinoShareConfig(out,&sh,ip,netmask,gw,second,sizeof(second)) > 0 && !strcmp(out,second)); + strcpy(disk,nfs); writes=0; + assert(!prepareShareConfig("nfs:/NAS/neutrino/neutrino.elf","nfs",&sh,msg,sizeof(msg)) && !writes); + missing=1; + assert(!prepareShareConfig("mc0:/neutrino/neutrino.elf","nfs",&sh,msg,sizeof(msg)) && !writes); + assert(strstr(msg,"NFS")); + missing=0; + assert(prepareShareConfig("mc0:/neutrino/neutrino.elf","nfs",&sh,msg,sizeof(msg)) && writes==1); + assert(!strcmp(disk,out)); + parse(&cfg,"NAME=NAS\nURL=nfs://10.0.0.2/srv/Public\n"); + assert(neutrinoShareResolve(&cfg,"nfs:/NAS/DVD/game.iso",&sh,dvd,sizeof(dvd),&why)); + assert(prepareShareConfig("mc0:/neutrino/neutrino.elf","nfs",&sh,msg,sizeof(msg)) && writes==2); + assert(strstr(disk,"\"export=/srv/Public\", \"uid=0\", \"gid=0\"") && !strstr(disk,"uid=1000")); return 0; } ''' functions = '\n'.join(function(name) for name in ( 'static int fileExists(', 'static const char *neutrinoBsdForPath(', - 'static int smbCoreLocal(', 'static int smbConfigWrite(', 'static int prepareSmbConfig(')) -code = code.replace('@STOCK@',json.dumps(STOCK)).replace('@FUNCTIONS@',functions) + 'static int neutrinoShareBsd(', 'static int shareCoreLocal(', 'static int shareConfigWrite(', 'static int prepareShareConfig(')) +code = code.replace('@STOCK@',json.dumps(STOCK)).replace('@NFS@',json.dumps(NFS)).replace('@FUNCTIONS@',functions) with tempfile.TemporaryDirectory() as tmp: src,exe = Path(tmp)/'test.c',Path(tmp)/'test.exe' src.write_text(code,encoding='utf-8') @@ -137,7 +179,7 @@ def function(name): str(src),str(ROOT/'src/neutrino_smb.c'),str(ROOT/'src/smb_cnf.c'),'-o',str(exe)],check=True) subprocess.run([str(exe)],check=True) -assert '!strcmp(bsd,"smb") ? "" : "-qb\\n"' in ISO -assert ISO.index('prepareSmbConfig(fullpath') < ISO.index('CleanUpForKeepIopExec(') +assert 'neutrinoShareBsd(bsd) ? "" : "-qb\\n"' in ISO +assert ISO.index('prepareShareConfig(fullpath') < ISO.index('CleanUpForKeepIopExec(') assert 'smbSharesNeutrino(path' in ISO -print('Neutrino SMB: share mapping, limits, TOML rewrite, no-op, rollback and handoff passed') +print('Neutrino SMB/NFS: path mapping, limits, identity, TOML rewrite, no-op, rollback and handoff passed') From da739fe7f09ce8797a0180f0c1b392724498459d Mon Sep 17 00:00:00 2001 From: NathanNeurotic <109461996+NathanNeurotic@users.noreply.github.com> Date: Tue, 1 Dec 2026 07:51:27 -0800 Subject: [PATCH 2/3] Remove stale SMB-only Neutrino test assertion --- tests/test_nfs_shares.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/test_nfs_shares.py b/tests/test_nfs_shares.py index da9fce26f..bfb707852 100644 --- a/tests/test_nfs_shares.py +++ b/tests/test_nfs_shares.py @@ -160,10 +160,6 @@ def text(path): browser = text("src/filer_browser.c") assert "smbPathKind(path) == SMB_PATH_NFS && smbIsRootPath(path))\n\t\twrite_disabled = 1;" in browser -# Neutrino is handed SMB paths only: nfs: reads as not supported there -neutrino = text("src/neutrino_iso.c") -assert "smbPathKind(path) == SMB_PATH_V1 || smbPathKind(path) == SMB_PATH_V2)\n\t\treturn \"smb\";" in neutrino - # the share editor writes an NFS share with nfsCnfBuildBlock, and loads one as kind NFS settings = text("src/dash_settings.c") save = settings[settings.index("static void smbedSave(void)"):] From cdaa9c3a6cbe704bfbd96e0bcd3a6876d267ef0d Mon Sep 17 00:00:00 2001 From: NathanNeurotic <109461996+NathanNeurotic@users.noreply.github.com> Date: Tue, 1 Dec 2026 12:06:41 -0800 Subject: [PATCH 3/3] Verify Neutrino release selection in the rolling workflow test --- tests/test_rolling_release_workflow.py | 59 +++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/tests/test_rolling_release_workflow.py b/tests/test_rolling_release_workflow.py index 0bd192ffa..89405fd83 100644 --- a/tests/test_rolling_release_workflow.py +++ b/tests/test_rolling_release_workflow.py @@ -2,8 +2,12 @@ This is a host-side workflow test. It does not publish anything. """ +import hashlib +import json +import os from pathlib import Path import subprocess +import tempfile root = Path(__file__).resolve().parents[1] workflow = (root / ".github/workflows/compile.yml").read_text() @@ -76,7 +80,60 @@ assert "scripts/package_kit.py fetch --cache build/kit-externals" in workflow assert "scripts/package_kit.py package" in workflow and "--output artifacts/LAUNCHSTATION.zip" in workflow assert workflow.index("--output artifacts/LAUNCHSTATION.zip") < workflow.index(marker) -assert "gh release download latest --repo ps2max32/neutrino" in workflow +assert "bash scripts/neutrino_release.sh build/companion" in workflow +assert '--neutrino "$NEUTRINO_ARCHIVE"' in workflow +watcher = (root / ".github/workflows/neutrino-watch.yml").read_text() +assert "bash scripts/neutrino_release.sh" in watcher + +# Test release selection and checksum verification without contacting GitHub. +selector = ["bash", str(root / "scripts/neutrino_release.sh")] +asset_name = "neutrino_v1.9.0-beta.7z" +payload = b"fixture Neutrino archive" +digest = hashlib.sha256(payload).hexdigest() + + +def release(tag, name, published_at, **asset_fields): + return { + "tag_name": tag, + "draft": False, + "published_at": published_at, + "assets": [{"name": name, "digest": f"sha256:{digest}", **asset_fields}], + } + + +with tempfile.TemporaryDirectory() as folder: + directory = Path(folder) + gh = directory / "gh" + gh.write_text("""#!/usr/bin/env bash +set -euo pipefail +if [[ "$*" == "api --paginate repos/ps2max32/neutrino/releases?per_page=100" ]]; then + cat "$TEST_RELEASES" +else + [[ $# == 10 && "$1 $2 $3 $4 $5 $6" == "release download v1.9.0-beta --repo ps2max32/neutrino --dir" ]] + [[ "$8 $9 ${10}" == "--pattern neutrino_v1.9.0-beta.7z --clobber" ]] + cp "$TEST_ASSET" "$7/$9" +fi +""") + gh.chmod(0o755) + payload_file = directory / "asset" + payload_file.write_bytes(payload) + metadata_file = directory / "releases.json" + moving_name = "neutrino_v1.8.0-61-g7be8de2.7z" + moving = release("latest", moving_name, "2026-08-31T10:38:50Z") + beta = release("v1.9.0-beta", asset_name, "2026-12-01T10:40:56Z") + draft = {**release("v1.9.0", "neutrino_v1.9.0.7z", "2026-12-02T00:00:00Z"), "draft": True} + metadata_file.write_text(json.dumps([moving, draft]) + "\n" + json.dumps([beta]) + "\n") + env = dict(os.environ, PATH=f"{directory}{os.pathsep}{os.environ['PATH']}", + TEST_RELEASES=str(metadata_file), TEST_ASSET=str(payload_file)) + assert subprocess.check_output(selector, env=env, text=True).strip() == f"v1.9.0-beta\t{asset_name}\t{digest}" + destination = directory / "companion" + archive = subprocess.check_output([*selector, str(destination)], env=env, text=True, stderr=subprocess.PIPE).strip() + assert Path(archive) == destination / asset_name and Path(archive).read_bytes() == payload + payload_file.write_bytes(b"corrupted archive") + assert subprocess.run([*selector, str(destination)], env=env, capture_output=True).returncode != 0 + moving["assets"][0]["updated_at"] = "2026-12-03T00:00:00Z" + metadata_file.write_text(json.dumps([beta, moving])) + assert subprocess.check_output(selector, env=env, text=True).strip() == f"latest\t{moving_name}\t{digest}" # The kit is optional for publication (CodeRabbit #257): an upstream Neutrino outage # or a failed kit check must not block the app ZIPs, PSUs and ELFs. Its steps # continue on error, the kit joins the assets only when it exists, and older kits