|
Packit |
d37888 |
/* Copyright (C) 1998-99 Martin Baulig
|
|
Packit |
d37888 |
This file is part of LibGTop 1.0.
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
LibGTop is free software; you can redistribute it and/or modify it
|
|
Packit |
d37888 |
under the terms of the GNU General Public License as published by
|
|
Packit |
d37888 |
the Free Software Foundation; either version 2 of the License,
|
|
Packit |
d37888 |
or (at your option) any later version.
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
LibGTop is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
d37888 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit |
d37888 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
d37888 |
for more details.
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
You should have received a copy of the GNU General Public License
|
|
Packit |
d37888 |
along with LibGTop; see the file COPYING. If not, write to the
|
|
Packit |
d37888 |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit |
d37888 |
Boston, MA 02110-1301, USA.
|
|
Packit |
d37888 |
*/
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
#include <config.h>
|
|
Packit |
d37888 |
#include <glibtop.h>
|
|
Packit |
d37888 |
#include <glibtop/msg_limits.h>
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
#include <kvm.h>
|
|
Packit |
d37888 |
#include <rctl.h>
|
|
Packit |
d37888 |
#include <sys/msg.h>
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
static const struct nlist nlst[] = { {"glibtop_msg_limits"}, {NULL} };
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE < 51000
|
|
Packit |
d37888 |
static const unsigned long _glibtop_sysdeps_msg_limits =
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE <= 50700
|
|
Packit |
d37888 |
(1L << GLIBTOP_IPC_MSGMAP) + (1L << GLIBTOP_IPC_MSGSSZ) +
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
(1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAX) +
|
|
Packit |
d37888 |
(1L << GLIBTOP_IPC_MSGMNB) + (1L << GLIBTOP_IPC_MSGMNI) +
|
|
Packit |
d37888 |
(1L << GLIBTOP_IPC_MSGTQL);
|
|
Packit |
d37888 |
#else
|
|
Packit |
d37888 |
static const unsigned long _glibtop_sysdeps_msg_limits = 0;
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
/* Init function. */
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
void
|
|
Packit |
d37888 |
_glibtop_init_msg_limits_p (glibtop *server)
|
|
Packit |
d37888 |
{
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE < 51000
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
kvm_t *kd = server->machine->kd;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
if(kd && !kvm_nlist(kd, nlst))
|
|
Packit |
d37888 |
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
|
|
Packit |
d37888 |
else
|
|
Packit |
d37888 |
server->sysdeps.msg_limits = 0;
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
}
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
/* Provides information about sysv ipc limits. */
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
void
|
|
Packit |
d37888 |
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
|
|
Packit |
d37888 |
{
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE < 51000
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
kvm_t *kd = server->machine->kd;
|
|
Packit |
d37888 |
glibtop_msg_limits minfo;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
memset (buf, 0, sizeof (glibtop_msg_limits));
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
if(!(server->sysdeps.msg_limits))
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
if(kvm_read(kd, nlst[0].n_value, (void *)&minfo,
|
|
Packit |
d37888 |
sizeof(glibtop_msg_limits)) != sizeof(glibtop_msg_limits))
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE <= 50700
|
|
Packit |
d37888 |
/* These fields don't exist anymore in Solaris 8.
|
|
Packit |
d37888 |
* Thanks to Laszlo PETER <Laszlo.Peter@ireland.sun.com>. */
|
|
Packit |
d37888 |
buf->msgmap = minfo.msgmap;
|
|
Packit |
d37888 |
buf->msgssz = minfo.msgssz;
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
buf->msgmax = minfo.msgmax;
|
|
Packit |
d37888 |
buf->msgmnb = minfo.msgmnb;
|
|
Packit |
d37888 |
buf->msgmni = minfo.msgmni;
|
|
Packit |
d37888 |
buf->msgtql = minfo.msgtql;
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
#if GLIBTOP_SOLARIS_RELEASE >= 51000
|
|
Packit |
d37888 |
rctlblk_t *rblk;
|
|
Packit |
d37888 |
if ((rblk = malloc(rctlblk_size())) == NULL)
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
if (getrctl("project.max-msg-qbytes", NULL, rblk, RCTL_FIRST) == -1)
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
else
|
|
Packit |
d37888 |
buf->msgmnb = rctlblk_get_value(rblk);
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
if (getrctl("project.max-msg-ids", NULL, rblk, RCTL_FIRST) == -1)
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
else
|
|
Packit |
d37888 |
buf->msgmni = rctlblk_get_value(rblk);
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
if (getrctl("project.max-msg-messages", NULL, rblk, RCTL_FIRST) == -1)
|
|
Packit |
d37888 |
return;
|
|
Packit |
d37888 |
else
|
|
Packit |
d37888 |
buf->msgtql = rctlblk_get_value(rblk);
|
|
Packit |
d37888 |
/* this is the maximum size of a system V message, which has been obsoleted as a kernel tunable value now */
|
|
Packit |
d37888 |
/* and it should always be 65535 instead, so I list it here, if needed, can be removed */
|
|
Packit |
d37888 |
buf->msgmax = 65535;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
#endif
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
buf->msgpool = buf->msgmni * buf->msgmnb >> 10;
|
|
Packit |
d37888 |
buf->flags = _glibtop_sysdeps_msg_limits;
|
|
Packit |
d37888 |
|
|
Packit |
d37888 |
}
|