Kernel, libc: Expose processes' UID and GID in pstat()

This commit is contained in:
apio 2022-10-28 17:31:34 +02:00
parent acdc2d3ad7
commit 09a615bd99
3 changed files with 8 additions and 2 deletions

View File

@ -17,8 +17,8 @@ pid_t get_current_max_threads()
void display_process(struct pstat* pstatbuf) void display_process(struct pstat* pstatbuf)
{ {
printf("%ld %ld %s %s (%ld ms)\n", pstatbuf->pt_pid, pstatbuf->pt_ppid, pstatbuf->pt_name, pstatname(pstatbuf), printf("%d %d %ld %ld %s %s (%ld ms)\n", pstatbuf->pt_uid, pstatbuf->pt_gid, pstatbuf->pt_pid, pstatbuf->pt_ppid,
pstatbuf->pt_time); pstatbuf->pt_name, pstatname(pstatbuf), pstatbuf->pt_time);
} }
int try_pstat(pid_t pid, struct pstat* pstatbuf) int try_pstat(pid_t pid, struct pstat* pstatbuf)

View File

@ -615,6 +615,8 @@ struct pstat
char pt_name[128]; char pt_name[128];
int pt_state; int pt_state;
long pt_time; long pt_time;
uid_t pt_uid;
gid_t pt_gid;
}; };
void sys_pstat(Context* context, long pid, struct pstat* buf) void sys_pstat(Context* context, long pid, struct pstat* buf)
@ -647,6 +649,8 @@ void sys_pstat(Context* context, long pid, struct pstat* buf)
kpstat->pt_ppid = task->ppid; kpstat->pt_ppid = task->ppid;
kpstat->pt_state = (int)task->state; kpstat->pt_state = (int)task->state;
kpstat->pt_time = (long)task->cpu_time; kpstat->pt_time = (long)task->cpu_time;
kpstat->pt_uid = task->uid;
kpstat->pt_gid = task->gid;
strlcpy(kpstat->pt_name, task->name, sizeof(kpstat->pt_name)); strlcpy(kpstat->pt_name, task->name, sizeof(kpstat->pt_name));
release_user_ref(kpstat); release_user_ref(kpstat);
} }

View File

@ -10,6 +10,8 @@ struct pstat
char pt_name[128]; char pt_name[128];
int pt_state; int pt_state;
long pt_time; long pt_time;
uid_t pt_uid;
gid_t pt_gid;
}; };
#define PT_IDLE 0 #define PT_IDLE 0