Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change int32 pids to uint32 #154

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class VfsWriteConfig(val entries: Map<UInt, ULong>)

data class SysSendmsgConfig(val entries: Map<UInt, ULong>)

data class UprobeConfig(val fnName: String, val offset: ULong, var target: String, val pid: Int?)
data class UprobeConfig(val fnName: String, val offset: ULong, var target: String, val pid: UInt?)

data class JniReferencesConfig(val pids: List<UInt>)

Expand Down Expand Up @@ -54,7 +54,7 @@ sealed class Event {
}
}

data class Process(val pid: Int, val ppid: Int, val state: String, val cmd: Command?)
data class Process(val pid: UInt, val ppid: UInt, val state: String, val cmd: Command?)

data class StringResponse(val name: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ object RustClient : Client {
private val processes =
alphabet.indices.map {
Process(
pid = Random.nextUInt(1000u).toInt(),
ppid = Random.nextUInt(1000u).toInt(),
pid = Random.nextUInt(1000u),
ppid = Random.nextUInt(1000u),
state = "R",
cmd = Command.Comm("/bin/sh/${alphabet.substring(it, it + 1)}"),
)
Expand Down
8 changes: 4 additions & 4 deletions rust/backend/daemon/src/procfs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ pub fn list_processes() -> Result<ProcessList, ProcError> {
let cmdline = process.cmdline();
match cmdline {
Ok(c) if !c.is_empty() => Some(ziofa::Process {
pid: stat.pid,
ppid: stat.ppid,
pid: u32::try_from(stat.pid).unwrap(),
ppid: u32::try_from(stat.ppid).unwrap(),
cmd: Some(Cmd::Cmdline(CmdlineData { args: c })),
state: stat.state.to_string(),
}),
// fallback to stat.comm if cmdline is empty
_ => Some(ziofa::Process {
pid: stat.pid,
ppid: stat.ppid,
pid: u32::try_from(stat.pid).unwrap(),
ppid: u32::try_from(stat.ppid).unwrap(),
cmd: Some(Cmd::Comm(stat.comm)),
state: stat.state.to_string(),
}),
Expand Down
2 changes: 1 addition & 1 deletion rust/shared/proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message UprobeConfig {
string fn_name = 1;
uint64 offset = 2; // offset of the aya attach function
string target = 3; // target of the aya attach function
optional int32 pid = 4; // pid of the aya attach function
optional uint32 pid = 4; // pid of the aya attach function
}

message Configuration {
Expand Down
4 changes: 2 additions & 2 deletions rust/shared/proto/ziofa.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ message ProcessList {
}

message Process {
int32 pid = 1;
int32 ppid = 2;
uint32 pid = 1;
uint32 ppid = 2;
oneof cmd {
CmdlineData cmdline = 3;
string comm = 4;
Expand Down