Fix shm_limits.c, sem_limits.c, and msg_limits.c
by using sysctl instead of kvm_nlist Co-authored-by: jasper <jasper@openbsd.org>
This commit is contained in:
@@ -39,28 +39,33 @@ static unsigned long _glibtop_sysdeps_shm_limits =
|
||||
* since `shminfo' is already declared external in <sys/shm.h>. */
|
||||
static struct shminfo _shminfo;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_shminfo" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_shm_limits_p (glibtop *server)
|
||||
{
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
|
||||
int mib[3];
|
||||
struct shm_sysctl_info *shmsi;
|
||||
size_t len = sizeof(struct shminfo);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_SYSVIPC_INFO;
|
||||
mib[2] = KERN_SYSVIPC_SHM_INFO;
|
||||
|
||||
if ((shmsi = malloc(len)) == NULL) {
|
||||
glibtop_warn_io_r (server, "malloc (shm_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (shminfo)");
|
||||
if (sysctl(mib, 3, shmsi, &len, NULL, 0) < 0) {
|
||||
glibtop_warn_io_r (server, "sysctl (shm_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
_shminfo = shmsi->shminfo;
|
||||
|
||||
free (shmsi);
|
||||
|
||||
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user