code wiki / (root) / nx_os_introspect.nx

nx_os_introspect.nx

buildroot/runtime/nx_os_introspect.nx

28400 B548 linesdepth 2pulls 2 transitivereach 37 importersview sourcekind librarytopic os
docsdependenciesstructsconstsfunctions

about

nx_os_introspect.nx -- OS "OBSERVE THE RUNNING SYSTEM" library (CAP-OS-INTROSPECT / CAP-PORT-OWNER). The sovereign /proc perception rung (axis=os, owner=CONDUCTOR, parent VAR-OS-NISHI): read the process + socket tables via SYSCALLS ONLY (no ps/ss/lsof/netstat) to answer "what process really holds this port?". EXTRACTED (un-trapped) from nx_portcheck.nx's GREEN 5/5 chain so it is IMPORTABLE -- the shared substrate BOTH the live mgmt plane (nx_hostctl snapshot -> /api/services -> /health) AND the hardware-up digital twin (a twin must introspect the running system it models) compose, instead of each re-implementing the /proc walk (the sprawl this retires: nx_socket_list stubbed the very inode->PID step this finishes). NO main() -> pure library. Chain: /proc/net/tcp{,6} LISTEN(0x0A) -> inode ; /proc/<pid>/fd socket:[inode] -> PID ; /proc/<pid>/{comm,cmdline}. license_tier: ORIGINAL

dependencies 1 imports · 12 importers

nx_syscalls.nx nx_os_introspect.nx nx_hostctl.nx nx_listener_census_gate.nx nx_mgmt_api.nx nx_mgmt_api.pre-toolchain-20260910 nx_mgmt_api_search_candidate_t330. nx_mgmt_api_toolchain_session_2026 nx_mgmt_cap_candidate_t186.nx nx_mgmt_deploy_candidate_t185.nx nx_os_introspect_gate.nx nx_portcheck.nx

diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nx_hostctl.nxnx_listener_census_gate.nxnx_mgmt_api.nxnx_mgmt_api.pre-toolchain-20260910.nxnx_mgmt_api_search_candidate_t330.nxnx_mgmt_api_toolchain_session_20260910.nxnx_mgmt_cap_candidate_t186.nxnx_mgmt_deploy_candidate_t185.nxnx_os_introspect_gate.nxnx_portcheck.nxnx_portcheck_staged_cli_gate.nxnx_socket_holder_observation_gate.nx

structs

none

consts

11const PON_MAGIC_32768: i64 = 32768
13const PON_TCP_LISTEN: i64 = 0x0A
14const PON_AT_FDCWD: i64 = 0 - 100
15const PON_SYS_READLINKAT: i64 = 267 // x86_64 readlinkat(dirfd, path, buf, bufsiz)
209const PON_OBS_COMPLETE: i64 = 0
210const PON_OBS_UNKNOWN: i64 = 1
211const PON_OBS_CAPACITY: i64 = 2
212const PON_OBS_BAD_INPUT: i64 = 3
213const PON_OBS_STATE_SLOTS: i64 = 6
214const PON_OBS_STATUS: i64 = 0
215const PON_OBS_FIRST_ERROR: i64 = 1
216const PON_OBS_STORED: i64 = 2
217const PON_OBS_PIDS: i64 = 3
218const PON_OBS_ERRORS: i64 = 4
219const PON_OBS_MATCHES: i64 = 5
220const PON_OBS_ROW_SLOTS: i64 = 3
221const PON_OBS_PID: i64 = 0
222const PON_OBS_FD: i64 = 1
223const PON_OBS_INODE: i64 = 2
224const PON_OBS_I64_MAX: i64 = 9223372036854775807
225const PON_OBS_DIRENT_NAME: i64 = 19
226const PON_OBS_E_FORMAT: i64 = 0-74
227const PON_OBS_E_ALLOC: i64 = 0-12
228const PON_OBS_E_SATURATED: i64 = 0-75
229const PON_OBS_I64_BYTES: i64 = 8
230const PON_OBS_I64_TEXT: i64 = 20
380const PON_L_STATE_SLOTS: i64 = 9
381const PON_L_STATUS: i64 = 0
382const PON_L_FIRST_ERROR: i64 = 1
383const PON_L_STORED: i64 = 2
384const PON_L_MATCHES: i64 = 3
385const PON_L_ROWS: i64 = 4
386const PON_L_ERRORS: i64 = 5
387const PON_L_FILES_COMPLETE: i64 = 6
388const PON_L_BYTES: i64 = 7
389const PON_L_FIRST_STAGE: i64 = 8
390const PON_L_STAGE_INPUT: i64 = 1
391const PON_L_STAGE_OPEN: i64 = 2
392const PON_L_STAGE_READ: i64 = 3
393const PON_L_STAGE_PARSE: i64 = 4
394const PON_L_STAGE_ROWS: i64 = 5
395const PON_L_STAGE_CLOSE: i64 = 6
396const PON_L_STAGE_ALLOC: i64 = 7
397const PON_L_ROW_SLOTS: i64 = 4
398const PON_L_FAMILY: i64 = 0
399const PON_L_PORT: i64 = 1
400const PON_L_INODE: i64 = 2
401const PON_L_ADDRESS_N: i64 = 3
402const PON_L_ADDRESS_STRIDE: i64 = 33
403const PON_L_V4_HEX: i64 = 8
404const PON_L_V6_HEX: i64 = 32
405const PON_L_PORT_HEX: i64 = 4
406const PON_L_STATE_HEX: i64 = 2
407const PON_L_PORT_MAX: i64 = 65535
408const PON_L_F_LOCAL: i64 = 1
409const PON_L_F_STATE: i64 = 3
410const PON_L_F_INODE: i64 = 9
411const PON_L_FAMILY4: i64 = 4
412const PON_L_FAMILY6: i64 = 6
413const PON_L_HEADER_FIELDS: i64 = 12

functions

17func pon_is_space(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 }
called by 1: pon_field
18func pon_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
21func pon_hex(buf: *u8, s: i64, e: i64) -> i64
called by 1: pon_scan_file
34func pon_dec(buf: *u8, s: i64, e: i64) -> i64
40func pon_field(buf: *u8, lstart: i64, lend: i64, idx: i64, fs: *i64, fe: *i64) -> i64
53func pon_scan_file(path: *u8, port: i64) -> i64
84func pon_listener_inode(port: i64) -> i64
96func pon_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 }
97func pon_join3(a: *u8, b: *u8, c: *u8, out: *u8) -> i64
104func pon_join(a: *u8, b: *u8, c: *u8, d: *u8, out: *u8) -> i64
113func pon_pid_has_inode(piddir: *u8, inode: i64) -> i64
143func pon_inode_to_pid(inode: i64) -> i64
165func pon_pid_path(pid: i64, leaf: *u8, path: *u8) -> i64
173func pon_pid_comm(pid: i64, out: *u8, cap: i64) -> i64
184func pon_pid_cmdline(pid: i64, out: *u8, cap: i64) -> i64
199func pon_port_owner_pid(port: i64) -> i64
232func pon_obs_init(st: *i64) -> i64
235func pon_obs_error(st: *i64, error: i64) -> i64
241func pon_obs_uint(b: *u8, a: i64, e: i64) -> i64
252func pon_obs_socket_inode(b: *u8, n: i64) -> i64
263func pon_obs_dirent(b: *u8, off: i64, n: i64) -> i64
272func pon_obs_number(out: *u8, at: i64, n: i64) -> i64
281func pon_observe_pid_inode(pid: i64, inode: i64, rows: *i64, capacity: i64, st: *i64) -> i64
346func pon_observe_inode(inode: i64, rows: *i64, capacity: i64, st: *i64) -> i64
415func pon_listener_init(st: *i64) -> i64
418func pon_listener_error(st: *i64, stage: i64, error: i64, capacity: i64) -> i64
424func pon_listener_hex_digit(c: i64) -> i64
430func pon_listener_hex(b: *u8, a: i64, e: i64) -> i64
439func pon_listener_args(port: i64, rows: *i64, addresses: *u8, capacity: i64) -> i64
448func pon_listener_header(buf: *u8, a: i64, e: i64, family: i64, fields: *i64) -> i64
466func pon_listener_row(buf: *u8, a: i64, e: i64, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, st: *i64, fields: *i64) -> i64
499func pon_listener_parse(buf: *u8, n: i64, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, st: *i64) -> i64
517func pon_listener_file(path: *u8, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, read_capacity: i64, st: *i64) -> i64
541func pon_observe_listeners(port: i64, rows: *i64, addresses: *u8, capacity: i64, read_capacity: i64, st: *i64) -> i64