Add proc_info structs and methods to macOS SystemB#1723
Open
dbwiddis wants to merge 1 commit into
Open
Conversation
- Add ProcFdInfo, InSockInfo, TcpSockInfo structs to c.s.j.p.mac.SystemB - Add proc_pidfdinfo(), statfs64(), vm_deallocate() methods - Add PROC_PIDLISTFDS, PROC_PIDFDSOCKETINFO, PROX_FDTYPE_SOCKET, SOCKINFO_IN, SOCKINFO_TCP, TSI_T_NTIMERS, AF_INET, AF_INET6 constants - Add SystemBTest additions (testProcPidFdInfo, testStatfs64) All struct mappings verified against Apple XNU headers: - sys/proc_info.h (struct proc_fdinfo, struct in_sockinfo, struct tcp_sockinfo)
fd3e4e7 to
4cd4d97
Compare
| */ | ||
| @Structure.FieldOrder({ "insi_fport", "insi_lport", "insi_gencnt", "insi_flags", "insi_flow", "insi_vflag", | ||
| "insi_ip_ttl", "rfu_1", "insi_faddr", "insi_laddr", "insi_v4", "insi_v6" }) | ||
| class InSockInfo extends Structure { |
Member
There was a problem hiding this comment.
The first members match. Are the latter members intentionally not mapped as struct but instead as byte arrays?
Comment on lines
+380
to
+388
| int bufferSize = SystemB.INSTANCE.proc_pidinfo(pid, SystemB.PROC_PIDLISTFDS, 0, null, 0); | ||
| assertTrue(bufferSize > 0); | ||
|
|
||
| int numFds = bufferSize / new ProcFdInfo().size(); | ||
| assertTrue(numFds > 0); | ||
|
|
||
| ProcFdInfo[] fdInfoArray = (ProcFdInfo[]) new ProcFdInfo().toArray(numFds); | ||
| int ret = SystemB.INSTANCE.proc_pidinfo(pid, SystemB.PROC_PIDLISTFDS, 0, fdInfoArray[0], | ||
| bufferSize); |
Member
There was a problem hiding this comment.
Something is fishy here. I'd expect proc_pidfdinfo not proc_pidinfo to be called here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds macOS process/socket information structs and methods to
c.s.j.p.mac.SystemB.Most mappings have been in use by OSHI since 2020, finally catching up on my upstream contributions.
vm_deallocate(yes I had a memory leak for a decade) andstatfs64are recent additions.Changes
c.s.j.p.mac.SystemB:ProcFdInfoInSockInfoTcpSockInfoproc_pidfdinfo(),statfs64(),vm_deallocate()methodsPROC_PIDLISTFDS,PROC_PIDFDSOCKETINFO,PROX_FDTYPE_SOCKET,SOCKINFO_IN,SOCKINFO_TCP,TSI_T_NTIMERS,AF_INET,AF_INET6Reference headers
sys/proc_info.h:struct proc_fdinfo,struct in_sockinfo,struct tcp_sockinfo,PROC_PIDLISTFDS,PROC_PIDFDSOCKETINFO,PROX_FDTYPE_SOCKET,TSI_T_NTIMERS