diff options
Diffstat (limited to 'usr.bin/procstat/procstat_auxv.c')
-rw-r--r-- | usr.bin/procstat/procstat_auxv.c | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/usr.bin/procstat/procstat_auxv.c b/usr.bin/procstat/procstat_auxv.c index c34b9bc..866434a 100644 --- a/usr.bin/procstat/procstat_auxv.c +++ b/usr.bin/procstat/procstat_auxv.c @@ -42,14 +42,13 @@ #include "procstat.h" -static char auxv[sizeof(Elf_Auxinfo) * 256]; +static Elf_Auxinfo auxv[256]; void procstat_auxv(struct kinfo_proc *kipp) { - Elf_Auxinfo *aux; - int i, error, name[4]; - size_t len; + int error, name[4]; + size_t len, i; if (!hflag) printf("%5s %-16s %-53s\n", "PID", "COMM", "AUXV"); @@ -58,7 +57,7 @@ procstat_auxv(struct kinfo_proc *kipp) name[1] = KERN_PROC; name[2] = KERN_PROC_AUXV; name[3] = kipp->ki_pid; - len = sizeof(auxv); + len = sizeof(auxv) * sizeof(*auxv); error = sysctl(name, 4, auxv, &len, NULL, 0); if (error < 0 && errno != ESRCH) { warn("sysctl: kern.proc.auxv: %d: %d", kipp->ki_pid, errno); @@ -72,106 +71,116 @@ procstat_auxv(struct kinfo_proc *kipp) printf(" -\n"); return; } - for (aux = (Elf_Auxinfo *)auxv, i = 0; i < 256; i++, aux++) { - switch(aux->a_type) { + for (i = 0; i < len; i++) { + switch(auxv[i].a_type) { case AT_NULL: - printf(" (%d)\n", i + 1); + printf(" (%zu)\n", i + 1); return; case AT_IGNORE: printf(" AT_IGNORE=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_EXECFD: printf(" AT_EXECFD=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PHDR: printf(" AT_PHDR=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PHENT: printf(" AT_PHENT=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PHNUM: printf(" AT_PHNUM=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PAGESZ: printf(" AT_PAGESZ=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_BASE: printf(" AT_BASE=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_FLAGS: printf(" AT_FLAGS=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_ENTRY: printf(" AT_ENTRY=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#ifdef AT_NOTELF case AT_NOTELF: printf(" AT_NOTELF=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#endif +#ifdef AT_UID case AT_UID: printf(" AT_UID=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#endif +#ifdef AT_EUID case AT_EUID: printf(" AT_EUID=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#endif +#ifdef AT_GID case AT_GID: printf(" AT_GID=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#endif +#ifdef AT_EGID case AT_EGID: printf(" AT_EGID=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; +#endif case AT_EXECPATH: printf(" AT_EXECPATH=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_CANARY: printf(" AT_CANARY=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_CANARYLEN: printf(" AT_CANARYLEN=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_OSRELDATE: printf(" AT_OSRELDATE=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_NCPUS: printf(" AT_NCPUS=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PAGESIZES: printf(" AT_PAGESIZES=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_PAGESIZESLEN: printf(" AT_PAGESIZESLEN=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_STACKPROT: printf(" AT_STACKPROT=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; case AT_COUNT: printf(" AT_COUNT=0x%lu", - (unsigned long)aux->a_un.a_val); + (unsigned long)auxv[i].a_un.a_val); break; default: - printf(" %ld=0x%lu", (long)aux->a_type, - (unsigned long)aux->a_un.a_val); + printf(" %ld=0x%lu", (long)auxv[i].a_type, + (unsigned long)auxv[i].a_un.a_val); break; } } |