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:
@@ -47,28 +47,34 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
|
||||
* since `msginfo' is already declared external in <sys/msg.h>. */
|
||||
static struct msginfo _msginfo;
|
||||
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_msginfo" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Init function. */
|
||||
|
||||
void
|
||||
_glibtop_init_msg_limits_p (glibtop *server)
|
||||
{
|
||||
if (kvm_nlist (server->machine->kd, nlst) < 0) {
|
||||
glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
|
||||
int mib[3];
|
||||
struct msg_sysctl_info *msgsi;
|
||||
|
||||
size_t len = sizeof(struct msginfo);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_SYSVIPC_INFO;
|
||||
mib[2] = KERN_SYSVIPC_MSG_INFO;
|
||||
|
||||
if ((msgsi = malloc(len)) == NULL) {
|
||||
glibtop_warn_io_r (server, "malloc (shm_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kvm_read (server->machine->kd, nlst [0].n_value,
|
||||
&_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (msginfo)");
|
||||
if (sysctl(mib, 3, msgsi, &len, NULL, 0) < 0) {
|
||||
glibtop_warn_io_r (server, "sysctl (shm_limits)");
|
||||
return;
|
||||
}
|
||||
|
||||
_msginfo = msgsi->msginfo;
|
||||
|
||||
free (msgsi);
|
||||
|
||||
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user