The indentation in LibGTop was done with the following command:
find . -name \*.[ch] | xargs -i emacs -batch {} \ -l /gnome/compile/libgtop/misc/format.el -f save-buffer December 26, 1999 Martin
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
@@ -50,10 +52,10 @@ static const unsigned long _glibtop_sysdeps_proc_uid_groups =
|
||||
int
|
||||
glibtop_init_proc_uid_p (glibtop *server)
|
||||
{
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
|
||||
_glibtop_sysdeps_proc_uid_groups;
|
||||
server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
|
||||
_glibtop_sysdeps_proc_uid_groups;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
@@ -62,73 +64,73 @@ int
|
||||
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
|
||||
pid_t pid)
|
||||
{
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
struct kinfo_proc *pinfo;
|
||||
int count = 0;
|
||||
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
struct ucred ucred;
|
||||
void *ucred_ptr;
|
||||
struct ucred ucred;
|
||||
void *ucred_ptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
memset (buf, 0, sizeof (glibtop_proc_uid));
|
||||
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return -1;
|
||||
/* It does not work for the swapper task. */
|
||||
if (pid == 0) return -1;
|
||||
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->_priv->machine.kd,
|
||||
KERN_PROC_PID, pid, &count);
|
||||
if ((pinfo == NULL) || (count != 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return -1;
|
||||
}
|
||||
/* Get the process information */
|
||||
pinfo = kvm_getprocs (server->_priv->machine.kd,
|
||||
KERN_PROC_PID, pid, &count);
|
||||
if ((pinfo == NULL) || (count != 1)) {
|
||||
glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf->uid = pinfo [0].kp_eproc.e_pcred.p_ruid;
|
||||
buf->euid = pinfo [0].kp_eproc.e_pcred.p_svuid;
|
||||
buf->gid = pinfo [0].kp_eproc.e_pcred.p_rgid;
|
||||
buf->egid = pinfo [0].kp_eproc.e_pcred.p_svgid;
|
||||
buf->uid = pinfo [0].kp_eproc.e_pcred.p_ruid;
|
||||
buf->euid = pinfo [0].kp_eproc.e_pcred.p_svuid;
|
||||
buf->gid = pinfo [0].kp_eproc.e_pcred.p_rgid;
|
||||
buf->egid = pinfo [0].kp_eproc.e_pcred.p_svgid;
|
||||
|
||||
buf->ppid = pinfo [0].kp_eproc.e_ppid;
|
||||
buf->pgrp = pinfo [0].kp_eproc.e_pgid;
|
||||
buf->tpgid = pinfo [0].kp_eproc.e_tpgid;
|
||||
buf->ppid = pinfo [0].kp_eproc.e_ppid;
|
||||
buf->pgrp = pinfo [0].kp_eproc.e_pgid;
|
||||
buf->tpgid = pinfo [0].kp_eproc.e_tpgid;
|
||||
|
||||
buf->nice = pinfo [0].kp_proc.p_nice;
|
||||
buf->priority = pinfo [0].kp_proc.p_priority;
|
||||
buf->nice = pinfo [0].kp_proc.p_nice;
|
||||
buf->priority = pinfo [0].kp_proc.p_priority;
|
||||
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_uid;
|
||||
/* Set the flags for the data we're about to return*/
|
||||
buf->flags = _glibtop_sysdeps_proc_uid;
|
||||
|
||||
/* Use LibGTop conditionals here so we can more easily merge this
|
||||
* code into the LIBGTOP_STABLE_1_0 branch. */
|
||||
/* Use LibGTop conditionals here so we can more easily merge this
|
||||
* code into the LIBGTOP_STABLE_1_0 branch. */
|
||||
#if LIBGTOP_VERSION_CODE >= 1001000
|
||||
/* This probably also works with other versions, but not yet
|
||||
* tested. Please remove the conditional if this is true. */
|
||||
/* This probably also works with other versions, but not yet
|
||||
* tested. Please remove the conditional if this is true. */
|
||||
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
|
||||
ucred_ptr = (void *) pinfo [0].kp_eproc.e_pcred.pc_ucred;
|
||||
ucred_ptr = (void *) pinfo [0].kp_eproc.e_pcred.pc_ucred;
|
||||
|
||||
if (ucred_ptr) {
|
||||
if (kvm_read (server->_priv->machine.kd,
|
||||
(unsigned long) ucred_ptr,
|
||||
&ucred, sizeof (ucred)) != sizeof (ucred)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (ucred)");
|
||||
} else {
|
||||
int count = (ucred.cr_ngroups < GLIBTOP_MAX_GROUPS) ?
|
||||
ucred.cr_ngroups : GLIBTOP_MAX_GROUPS;
|
||||
int i;
|
||||
if (ucred_ptr) {
|
||||
if (kvm_read (server->_priv->machine.kd,
|
||||
(unsigned long) ucred_ptr,
|
||||
&ucred, sizeof (ucred)) != sizeof (ucred)) {
|
||||
glibtop_warn_io_r (server, "kvm_read (ucred)");
|
||||
} else {
|
||||
int count = (ucred.cr_ngroups < GLIBTOP_MAX_GROUPS) ?
|
||||
ucred.cr_ngroups : GLIBTOP_MAX_GROUPS;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
buf->groups [i] = ucred.cr_groups [i];
|
||||
buf->ngroups = count;
|
||||
for (i = 0; i < count; i++)
|
||||
buf->groups [i] = ucred.cr_groups [i];
|
||||
buf->ngroups = count;
|
||||
|
||||
buf->flags |= _glibtop_sysdeps_proc_uid_groups;
|
||||
}
|
||||
buf->flags |= _glibtop_sysdeps_proc_uid_groups;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user