code wiki / (root) / nx_fsops_write.nx

nx_fsops_write.nx

buildroot/runtime/nx_fsops_write.nx

13890 B233 linesdepth 4pulls 7 transitivereach 0 importersview sourcekind tooltopic fsops
docsdependenciesstructsconstsfunctions

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

nx_fsops_lib.nx nx_fsops_write.nx

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

main fsw_usage fsx_puts sys_write fsx_seq fsw_cur_size fsw_argval fsw_expect_val fsw_hex_val fsw_content_hash sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close fsw_atoi fsx_puts ↻ fsx_putn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap fsw_print_hash fsw_hex_of fsw_content_hash ↻ fsx_puts ↻ fsx_write fsx_write_denied fsx_denied sys_mmap ↻ fsx_lower fsx_ends_with vw_slen fsx_basename_is vw_slen ↻ fsx_ends_with ↻ fsx_deny_hit

structs

none

consts

13const FSW_USAGE_RC: i64 = 2
14const FSW_ARG_VERB: i64 = 1 // argv slot of the verb
15const FSW_ARG_PATH: i64 = 2 // argv slot of the path
16const FSW_ARG_A: i64 = 3 // write: content | edit: old-string
17const FSW_ARG_B: i64 = 4 // edit: new-string
18const FSW_ARG_ALL: i64 = 5 // edit: optional literal "all"
19const FSW_ARGC_WRITE: i64 = 4 // write path content
20const FSW_ARGC_EDIT: i64 = 5 // edit path old new
21const FSW_ARGC_EDITALL: i64 = 6 // edit path old new all
33const FSW_RC_CLOBBER: i64 = 8 // distinct from ABSENT/DENIED/IO/NOMATCH/AMBIG so callers can branch on it
34const FSW_ARG_EXPECT: i64 = 4 // write: optional expect token
35const FSW_ARGC_WRITE_EXPECT: i64 = 5
78const FSW_FNV_OFF: i64 = 0xcbf29ce484222325
79const FSW_FNV_PRIME: i64 = 0x100000001b3

functions

51func fsw_argval(s: *u8) -> *u8
called by 1: main
61func fsw_cur_size(path: *u8) -> i64
called by 1: main
80func fsw_content_hash(path: *u8) -> i64
90func fsw_hex_of(v: i64, out: *u8) -> i64
called by 1: fsw_print_hash
97func fsw_hex_val(s: *u8) -> i64
called by 1: fsw_expect_val
117func fsw_print_hash(path: *u8) -> i64
123func fsw_expect_val(ex: *u8, path: *u8, cur: i64) -> i64
130func fsw_atoi(s: *u8) -> i64
called by 1: fsw_expect_val
138func fsw_usage() -> i64
called by 1: main calls 1: fsx_puts
143func fsw_rc(r: i64) -> i64
called by 1: main
153func main(argc: i64, argv: *i64) -> i64