code wiki / (root) / nx_portcheck.nx

nx_portcheck.nx

buildroot/runtime/nx_portcheck.nx

19770 B365 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_portcheck.nx -- R1 of the sovereign-:443 arc: a SOVEREIGN "what owns this port" inspector. The deploy team (nx_hostctl/nx_aw_hostctl) can start/stop/swap named daemons but has NO way to answer "what process is bound to :443" -- the never-brick prerequisite before a sovereign terminator can take :443 from DSM (operator: "build them up if they lack the capability, rung by rung; dont use shell"). This reads /proc sovereignly (syscalls only, no ss/lsof/netstat): /proc/net/tcp{,6} for a LISTEN socket on the target port -> its inode; then /proc/<pid>/fd via getdents64 + readlinkat(__syscall 267) to find the owning pid; then /proc/<pid>/comm for the process name. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_os_introspect.nx nx_portcheck.nx

imports: nx_syscalls.nxnx_os_introspect.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main pc_legacy_gate pc_w sys_write sys_socket sys_exit sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_setsockopt sys_bind sys_listen pc_listener_inode pc_scan_file sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close pc_field pc_is_space pc_hex pc_dec pc_row pc_w ↻

structs

none

consts

10const PC_MAGIC_32768: i64 = 32768
11const PC_MAGIC_53991: i64 = 53991
13const PC_TCP_LISTEN: i64 = 0x0A
14const PC_AT_FDCWD: i64 = 0 - 100
15const PC_SYS_READLINKAT: i64 = 267 // x86_64 readlinkat(dirfd, path, buf, bufsiz)
245const PCL_EXIT_USAGE: i64 = 3
246const PCL_EXIT_OUTPUT: i64 = 4
247const PCL_INTEGER_BYTES: i64 = 21
248const PCL_I64_MIN: i64 = 0-9223372036854775807-1

functions

17func pc_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: pc_rowpc_legacy_gate calls 1: sys_write
18func pc_row(name: *u8, ok: i64) -> i64 { if ok == 1 { pc_w(" PASS " as *u8) } else { pc_w(" FAIL " as *u8) } pc_w(name); pc_w("\n" as *u8); return ok }
called by 1: pc_legacy_gate calls 1: pc_w
19func pc_is_space(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 }
called by 1: pc_field
20func pc_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
21func pc_puti(v: i64) -> i64 { var t: i64=v; if t<0 { sys_write(1,"-" as *u8,1); t=0-t } let tm: *u8=sys_mmap(24); var k: i64=0; if t==0 {tm[0]=48 as u8;k=1} while t>0 {tm[k]=(48+(t%10)) as u8;t=t/10;k=k+1} let b: *u8=sys_mmap(24); var j: i64=0; while j<k {b[j]=tm[k-1-j];j=j+1} sys_write(1,b,k); return 0 }
24func pc_hex(buf: *u8, s: i64, e: i64) -> i64
called by 1: pc_scan_file
37func pc_dec(buf: *u8, s: i64, e: i64) -> i64
44func pc_field(buf: *u8, lstart: i64, lend: i64, idx: i64, fs: *i64, fe: *i64) -> i64
called by 1: pc_scan_file calls 1: pc_is_space
58func pc_scan_file(path: *u8, port: i64) -> i64
89func pc_listener_inode(port: i64) -> i64
called by 1: pc_legacy_gate calls 1: pc_scan_file
101func pc_str_all_digits(s: *u8) -> i64 { var i: i64 = 0; if s[0] == (0 as u8) { return 0 } while s[i] != (0 as u8) { let c: i64 = s[i] & 0xff; if c < 48 { return 0 } if c > 57 { return 0 } i = i + 1 } return 1 }
102func pc_join(a: *u8, b: *u8, c: *u8, d: *u8, out: *u8) -> i64
called by 1: pc_pid_has_inode
110func pc_join3(a: *u8, b: *u8, c: *u8, out: *u8) -> i64
118func pc_pid_has_inode(piddir: *u8, inode: i64) -> i64
149func pc_inode_to_pid(inode: i64) -> i64
170func pc_pid_comm(pid: i64, out: *u8, cap: i64) -> i64
185func pc_legacy_gate() -> i64
251func pcl_raw(s: *u8, n: i64) -> i64
260func pcl_text(s: *u8) -> i64 { return pcl_raw(s,pc_strlen(s)) }
261func pcl_number(value: i64) -> i64
270func pcl_equal(a: *u8, b: *u8) -> i64
called by 1: main
274func pcl_status(status: i64) -> *u8
called by 1: pcl_emit
280func pcl_stage(stage: i64) -> *u8
called by 1: pcl_emit
290func pcl_refuse(code: *u8) -> i64
called by 2: pcl_listenersmain calls 1: pcl_text
297func pcl_emit(port: i64, row_capacity: i64, read_capacity: i64, rows: *i64, addresses: *u8, st: *i64, begin: i64, end: i64) -> i64
332func pcl_listeners(argc: i64, argv: *i64) -> i64
360func main(argc: i64, argv: *i64) -> i64