nx_os_introspect.nx
buildroot/runtime/nx_os_introspect.nx
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
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
| 11 | const PON_MAGIC_32768: i64 = 32768 |
| 13 | const PON_TCP_LISTEN: i64 = 0x0A |
| 14 | const PON_AT_FDCWD: i64 = 0 - 100 |
| 15 | const PON_SYS_READLINKAT: i64 = 267 // x86_64 readlinkat(dirfd, path, buf, bufsiz) |
| 209 | const PON_OBS_COMPLETE: i64 = 0 |
| 210 | const PON_OBS_UNKNOWN: i64 = 1 |
| 211 | const PON_OBS_CAPACITY: i64 = 2 |
| 212 | const PON_OBS_BAD_INPUT: i64 = 3 |
| 213 | const PON_OBS_STATE_SLOTS: i64 = 6 |
| 214 | const PON_OBS_STATUS: i64 = 0 |
| 215 | const PON_OBS_FIRST_ERROR: i64 = 1 |
| 216 | const PON_OBS_STORED: i64 = 2 |
| 217 | const PON_OBS_PIDS: i64 = 3 |
| 218 | const PON_OBS_ERRORS: i64 = 4 |
| 219 | const PON_OBS_MATCHES: i64 = 5 |
| 220 | const PON_OBS_ROW_SLOTS: i64 = 3 |
| 221 | const PON_OBS_PID: i64 = 0 |
| 222 | const PON_OBS_FD: i64 = 1 |
| 223 | const PON_OBS_INODE: i64 = 2 |
| 224 | const PON_OBS_I64_MAX: i64 = 9223372036854775807 |
| 225 | const PON_OBS_DIRENT_NAME: i64 = 19 |
| 226 | const PON_OBS_E_FORMAT: i64 = 0-74 |
| 227 | const PON_OBS_E_ALLOC: i64 = 0-12 |
| 228 | const PON_OBS_E_SATURATED: i64 = 0-75 |
| 229 | const PON_OBS_I64_BYTES: i64 = 8 |
| 230 | const PON_OBS_I64_TEXT: i64 = 20 |
| 380 | const PON_L_STATE_SLOTS: i64 = 9 |
| 381 | const PON_L_STATUS: i64 = 0 |
| 382 | const PON_L_FIRST_ERROR: i64 = 1 |
| 383 | const PON_L_STORED: i64 = 2 |
| 384 | const PON_L_MATCHES: i64 = 3 |
| 385 | const PON_L_ROWS: i64 = 4 |
| 386 | const PON_L_ERRORS: i64 = 5 |
| 387 | const PON_L_FILES_COMPLETE: i64 = 6 |
| 388 | const PON_L_BYTES: i64 = 7 |
| 389 | const PON_L_FIRST_STAGE: i64 = 8 |
| 390 | const PON_L_STAGE_INPUT: i64 = 1 |
| 391 | const PON_L_STAGE_OPEN: i64 = 2 |
| 392 | const PON_L_STAGE_READ: i64 = 3 |
| 393 | const PON_L_STAGE_PARSE: i64 = 4 |
| 394 | const PON_L_STAGE_ROWS: i64 = 5 |
| 395 | const PON_L_STAGE_CLOSE: i64 = 6 |
| 396 | const PON_L_STAGE_ALLOC: i64 = 7 |
| 397 | const PON_L_ROW_SLOTS: i64 = 4 |
| 398 | const PON_L_FAMILY: i64 = 0 |
| 399 | const PON_L_PORT: i64 = 1 |
| 400 | const PON_L_INODE: i64 = 2 |
| 401 | const PON_L_ADDRESS_N: i64 = 3 |
| 402 | const PON_L_ADDRESS_STRIDE: i64 = 33 |
| 403 | const PON_L_V4_HEX: i64 = 8 |
| 404 | const PON_L_V6_HEX: i64 = 32 |
| 405 | const PON_L_PORT_HEX: i64 = 4 |
| 406 | const PON_L_STATE_HEX: i64 = 2 |
| 407 | const PON_L_PORT_MAX: i64 = 65535 |
| 408 | const PON_L_F_LOCAL: i64 = 1 |
| 409 | const PON_L_F_STATE: i64 = 3 |
| 410 | const PON_L_F_INODE: i64 = 9 |
| 411 | const PON_L_FAMILY4: i64 = 4 |
| 412 | const PON_L_FAMILY6: i64 = 6 |
| 413 | const PON_L_HEADER_FIELDS: i64 = 12 |
functions
| 17 | func pon_is_space(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 } called by 1: pon_field |
| 18 | func pon_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 21 | func pon_hex(buf: *u8, s: i64, e: i64) -> i64 called by 1: pon_scan_file |
| 34 | func pon_dec(buf: *u8, s: i64, e: i64) -> i64 |
| 40 | func pon_field(buf: *u8, lstart: i64, lend: i64, idx: i64, fs: *i64, fe: *i64) -> i64 |
| 53 | func pon_scan_file(path: *u8, port: i64) -> i64 |
| 84 | func pon_listener_inode(port: i64) -> i64 |
| 90 | func pon_readlink(path: *u8, out: *u8, cap: i64) -> i64 |
| 96 | func 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 } |
| 97 | func pon_join3(a: *u8, b: *u8, c: *u8, out: *u8) -> i64 |
| 104 | func pon_join(a: *u8, b: *u8, c: *u8, d: *u8, out: *u8) -> i64 |
| 113 | func pon_pid_has_inode(piddir: *u8, inode: i64) -> i64 called by 1: pon_inode_to_pid calls 11: sys_mmappon_join3sys_openat_rdsys_getdents64dirent_namepon_str_all_digits+5 |
| 143 | func pon_inode_to_pid(inode: i64) -> i64 called by 2: pon_port_owner_pidmain calls 10: sys_openat_rdsys_mmapsys_getdents64dirent_namepon_str_all_digitspon_pid_has_inode+4 |
| 165 | func pon_pid_path(pid: i64, leaf: *u8, path: *u8) -> i64 |
| 173 | func pon_pid_comm(pid: i64, out: *u8, cap: i64) -> i64 |
| 184 | func pon_pid_cmdline(pid: i64, out: *u8, cap: i64) -> i64 |
| 199 | func pon_port_owner_pid(port: i64) -> i64 |
| 232 | func pon_obs_init(st: *i64) -> i64 |
| 235 | func pon_obs_error(st: *i64, error: i64) -> i64 |
| 241 | func pon_obs_uint(b: *u8, a: i64, e: i64) -> i64 |
| 252 | func pon_obs_socket_inode(b: *u8, n: i64) -> i64 |
| 263 | func pon_obs_dirent(b: *u8, off: i64, n: i64) -> i64 |
| 272 | func pon_obs_number(out: *u8, at: i64, n: i64) -> i64 |
| 281 | func pon_observe_pid_inode(pid: i64, inode: i64, rows: *i64, capacity: i64, st: *i64) -> i64 called by 2: pon_observe_inodemain calls 16: sys_mmapsys_munmappon_obs_errorpon_obs_numberpon_join3sys_openat_rd+10 |
| 346 | func pon_observe_inode(inode: i64, rows: *i64, capacity: i64, st: *i64) -> i64 |
| 415 | func pon_listener_init(st: *i64) -> i64 |
| 418 | func pon_listener_error(st: *i64, stage: i64, error: i64, capacity: i64) -> i64 |
| 424 | func pon_listener_hex_digit(c: i64) -> i64 |
| 430 | func pon_listener_hex(b: *u8, a: i64, e: i64) -> i64 |
| 439 | func pon_listener_args(port: i64, rows: *i64, addresses: *u8, capacity: i64) -> i64 |
| 448 | func pon_listener_header(buf: *u8, a: i64, e: i64, family: i64, fields: *i64) -> i64 |
| 466 | func pon_listener_row(buf: *u8, a: i64, e: i64, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, st: *i64, fields: *i64) -> i64 |
| 499 | func pon_listener_parse(buf: *u8, n: i64, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, st: *i64) -> i64 |
| 517 | func pon_listener_file(path: *u8, family: i64, port: i64, rows: *i64, addresses: *u8, capacity: i64, read_capacity: i64, st: *i64) -> i64 called by 2: mainpon_observe_listeners calls 8: pon_listener_argssys_openat_rdpon_listener_errorsys_mmapsys_closesys_read+2 |
| 541 | func pon_observe_listeners(port: i64, rows: *i64, addresses: *u8, capacity: i64, read_capacity: i64, st: *i64) -> i64 |