nx_fsops_write.nx
buildroot/runtime/nx_fsops_write.nx
about
nx_fsops_write.nx -- WRITE-CLASS CLI of the consolidated fs tool (tools-api name: nx_fs_write).
2026-07-30: `write` is now COMPARE-AND-SWAP gated (seq1379) -- see the block above fsw_usage.
Deliberately a SEPARATE binary from the read-only `nx_fs`: the exposure policy (knowledge/mcp/
exposure_policy.txt) grades reads broad and writes cap-gated, so the two live under different
capability grants. One shared library (nx_fsops_lib) -- no logic duplicated.
write <path> <content> -> ATOMIC full-file write (tmp+fsync+rename)
edit <path> <old> <new> [all] -> exact-string replace, UNIQUENESS contract (Claude-Edit semantic)
exit: 0 ok | 2 usage | 3 absent | 4 io | 5 DENIED | 6 NOMATCH | 7 AMBIGUOUS (surfaced in MCP _meta)
DENY BY CONSTRUCTION (rule 26 + 12): secret material, OS device/firmware namespace (nx_os_fs seam),
the tool allowlist, + fs_write_deny.conf extras. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_fsops_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 13 | const FSW_USAGE_RC: i64 = 2 |
| 14 | const FSW_ARG_VERB: i64 = 1 // argv slot of the verb |
| 15 | const FSW_ARG_PATH: i64 = 2 // argv slot of the path |
| 16 | const FSW_ARG_A: i64 = 3 // write: content | edit: old-string |
| 17 | const FSW_ARG_B: i64 = 4 // edit: new-string |
| 18 | const FSW_ARG_ALL: i64 = 5 // edit: optional literal "all" |
| 19 | const FSW_ARGC_WRITE: i64 = 4 // write path content |
| 20 | const FSW_ARGC_EDIT: i64 = 5 // edit path old new |
| 21 | const FSW_ARGC_EDITALL: i64 = 6 // edit path old new all |
| 33 | const FSW_RC_CLOBBER: i64 = 8 // distinct from ABSENT/DENIED/IO/NOMATCH/AMBIG so callers can branch on it |
| 34 | const FSW_ARG_EXPECT: i64 = 4 // write: optional expect token |
| 35 | const FSW_ARGC_WRITE_EXPECT: i64 = 5 |
| 78 | const FSW_FNV_OFF: i64 = 0xcbf29ce484222325 |
| 79 | const FSW_FNV_PRIME: i64 = 0x100000001b3 |
functions
| 51 | func fsw_argval(s: *u8) -> *u8 called by 1: main |
| 61 | func fsw_cur_size(path: *u8) -> i64 called by 1: main |
| 80 | func fsw_content_hash(path: *u8) -> i64 |
| 90 | func fsw_hex_of(v: i64, out: *u8) -> i64 called by 1: fsw_print_hash |
| 97 | func fsw_hex_val(s: *u8) -> i64 called by 1: fsw_expect_val |
| 117 | func fsw_print_hash(path: *u8) -> i64 |
| 123 | func fsw_expect_val(ex: *u8, path: *u8, cur: i64) -> i64 |
| 130 | func fsw_atoi(s: *u8) -> i64 called by 1: fsw_expect_val |
| 138 | func fsw_usage() -> i64 |
| 143 | func fsw_rc(r: i64) -> i64 called by 1: main |
| 153 | func main(argc: i64, argv: *i64) -> i64 |