From 218ac523b8667e5b36521fd69bbd97b70c86cbe8 Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 5 Jun 2026 08:48:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=BD=E5=BF=AB=E6=8E=A8=E8=BF=9B=EF=BC=9A?= =?UTF-8?q?=E6=94=B6=E7=B4=A7OPFS=E7=A8=8B=E5=BA=8F=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E9=94=9A=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-linuxcnc-opfs-source-map.sh | 19 +++++++++++++++++++ docs/linuxcnc-opfs-source-map.md | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/check-linuxcnc-opfs-source-map.sh b/check-linuxcnc-opfs-source-map.sh index a171d6d..e83e199 100755 --- a/check-linuxcnc-opfs-source-map.sh +++ b/check-linuxcnc-opfs-source-map.sh @@ -16,6 +16,12 @@ grep -F '#define RS274NGC_PARAMETER_FILE_BACKUP_SUFFIX ".bak"' \ "$linuxcnc_root/src/emc/rs274ngc/interp_internal.hh" >/dev/null grep -F 'int Interp::restore_parameters(const char *filename)' \ "$linuxcnc_root/src/emc/rs274ngc/rs274ngc_pre.cc" >/dev/null +grep -F 'int Interp::open(const char *filename)' \ + "$linuxcnc_root/src/emc/rs274ngc/rs274ngc_pre.cc" >/dev/null +grep -F '_setup.file_pointer = fopen(filename, "r");' \ + "$linuxcnc_root/src/emc/rs274ngc/rs274ngc_pre.cc" >/dev/null +grep -F 'read_text(command, _setup.file_pointer, _setup.linetext,' \ + "$linuxcnc_root/src/emc/rs274ngc/rs274ngc_pre.cc" >/dev/null grep -F 'int Interp::save_parameters(const char *filename,' \ "$linuxcnc_root/src/emc/rs274ngc/rs274ngc_pre.cc" >/dev/null grep -F 'std::string tempfile = std::string(filename) + ".new";' \ @@ -35,6 +41,11 @@ grep -F 'RS274NGC_PARAMETER_FILE_BACKUP_SUFFIX` as `.bak`' \ docs/linuxcnc-opfs-source-map.md >/dev/null grep -F '`Interp::restore_parameters()` for parameter-file reads' \ docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '`Interp::open()` by opening' \ + docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '`fopen(filename, "r")`, then `Interp::_read()`' \ + docs/linuxcnc-opfs-source-map.md >/dev/null +grep -F '`read_text()`' docs/linuxcnc-opfs-source-map.md >/dev/null grep -F '`Interp::save_parameters()` for `filename + ".new"`' \ docs/linuxcnc-opfs-source-map.md >/dev/null grep -F 'unlinks `filename + ".bak"`, links the' \ @@ -55,6 +66,12 @@ grep -F '| `web/test-browser-wasm-smoke-opfs-policy-sections.js` |' docs/linuxcn grep -F '| `web/test-browser-wasm-smoke-app-sections.js` |' docs/linuxcnc-opfs-source-map.md >/dev/null grep -F 'const LINUXCNC_DEFAULT_PARAMETER_FILE = "rs274ngc.var";' web/src/wasm-core.js >/dev/null +grep -F 'async parseFile(path, dialect = "linuxcnc", options = {})' web/src/wasm-core.js >/dev/null +grep -F 'OPFS workspace is not available for program file parsing' web/src/wasm-core.js >/dev/null +grep -F 'const program = new TextDecoder().decode(await opfs.readFile(path));' web/src/wasm-core.js >/dev/null +grep -F 'async parseFileWithParameterFile(path, parameterPath, dialect = "linuxcnc", options = {})' \ + web/src/wasm-core.js >/dev/null +grep -F 'OPFS workspace is not available for program and parameter file parsing' web/src/wasm-core.js >/dev/null grep -F '`${LINUXCNC_DEFAULT_PARAMETER_FILE}.new`' web/src/wasm-core.js >/dev/null grep -F '`${LINUXCNC_DEFAULT_PARAMETER_FILE}.bak`' web/src/wasm-core.js >/dev/null grep -F 'LinuxCNC source basis: rs274ngc_pre.cc restore_parameters() reads the' web/src/wasm-core.js >/dev/null @@ -133,7 +150,9 @@ for entry in coverage_entries: required_phrases = [ "programs/current.ngc", "parameters/rs274ngc.var", + 'fopen(filename, "r")', "LinuxCNC `read_text()`", + "program reads and parameter restore/save bridge files under the OPFS workspace", "`.new`, `.bak`, failure, and stale-state semantics", 'unlinks `filename + ".bak"`', "OPFS/WASM mirror persistence", diff --git a/docs/linuxcnc-opfs-source-map.md b/docs/linuxcnc-opfs-source-map.md index b81d202..bb37b0a 100644 --- a/docs/linuxcnc-opfs-source-map.md +++ b/docs/linuxcnc-opfs-source-map.md @@ -11,6 +11,9 @@ persistence. It is a policy and bridge map only; it must not add independent fil `RS274NGC_PARAMETER_FILE_BACKUP_SUFFIX` as `.bak`. - `src/emc/rs274ngc/rs274ngc_pre.cc` implements `Interp::restore_parameters()` for parameter-file reads. +- `src/emc/rs274ngc/rs274ngc_pre.cc` implements `Interp::open()` by opening + the NC program file with `fopen(filename, "r")`, then `Interp::_read()` + feeds `_setup.file_pointer` into `read_text()`. - `src/emc/rs274ngc/rs274ngc_pre.cc` implements `Interp::save_parameters()` for `filename + ".new"`, backup, and replacement writes. @@ -22,7 +25,7 @@ persistence. It is a policy and bridge map only; it must not add independent fil | Entry | Boundary | | --- | --- | -| `web/src/wasm-core.js` | Keeps LinuxCNC parameter restore/save bridge files under the OPFS workspace and cleans WASM scratch files. | +| `web/src/wasm-core.js` | Keeps LinuxCNC program reads and parameter restore/save bridge files under the OPFS workspace and cleans WASM scratch files. | | `web/src/wasm-core.d.ts` | Exposes only the OPFS-backed workspace, directory, parameter-file, and mount/workspace option types used by the bridge. | | `web/src/app.js` | Persists browser programs at `programs/current.ngc` and LinuxCNC parameters at `parameters/rs274ngc.var`. | | `web/test-browser-wasm-smoke-opfs-basic-sections.js` | Verifies OPFS program file reads through LinuxCNC `read_text()` and rejects unsafe paths. |