Skip to content

Commit

Permalink
Merge pull request #154 from amosproj/149-pids-to-uint32
Browse files Browse the repository at this point in the history
Change int32 pids to uint32
  • Loading branch information
fhilgers authored Dec 10, 2024
2 parents 959808b + dcf2dd8 commit f8bcf97
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
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

0 comments on commit f8bcf97

Please sign in to comment.