code wiki / (root) / nx_os_introspect.nx

nx_os_introspect.nx

buildroot/runtime/nx_os_introspect.nx

9957 B203 linesdepth 2pulls 2 transitivereach 11 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 · 3 importers

nx_syscalls.nx nx_os_introspect.nx nx_hostctl.nx nx_mgmt_api.nx nx_os_introspect_gate.nx

imports: nx_syscalls.nx

imported by: nx_hostctl.nxnx_mgmt_api.nxnx_os_introspect_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)

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
called by 1: pon_scan_file calls 1: pon_is_space
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
called by 1: pon_pid_has_inode
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