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 · 3 importers
imports: nx_syscalls.nx
imported by: nx_hostctl.nxnx_mgmt_api.nxnx_os_introspect_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) |
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 called by 1: pon_pid_has_inode |
| 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 |