summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acconfig.h2
-rw-r--r--glibtop-server-private.h12
-rw-r--r--glibtop.h38
-rw-r--r--include/glibtop/array.h8
-rw-r--r--kernel/sysctl/libgtop.c8
-rw-r--r--kernel/sysctl/libgtop.h2
-rw-r--r--kernel/sysctl/libgtop_syms.c2
-rw-r--r--kernel/sysctl/main.c2
-rw-r--r--lib/close.c34
-rw-r--r--lib/command.c64
-rw-r--r--lib/errors.c2
-rw-r--r--lib/glib-arrays.c2
-rw-r--r--lib/init.c310
-rw-r--r--lib/inodedb.c104
-rw-r--r--lib/open.c198
-rw-r--r--lib/parameter.c192
-rw-r--r--lib/read.c62
-rw-r--r--lib/read_data.c52
-rw-r--r--lib/sysdeps.c46
-rw-r--r--lib/write.c24
-rw-r--r--misc/README.indent8
-rw-r--r--misc/format.el5
-rw-r--r--src/daemon/daemon.h2
-rw-r--r--src/daemon/gnuserv.c2
-rw-r--r--src/daemon/io.c116
-rw-r--r--src/daemon/main.c2
-rw-r--r--src/daemon/server.c44
-rw-r--r--src/daemon/slave.c394
-rw-r--r--src/daemon/version.c54
-rw-r--r--src/inodedb/file_by_inode.c46
-rw-r--r--src/inodedb/mkinodedb.c154
-rw-r--r--sysdeps/common/error.c44
-rw-r--r--sysdeps/common/fsusage.c218
-rw-r--r--sysdeps/common/fsusage.h12
-rw-r--r--sysdeps/common/inodedb.c104
-rw-r--r--sysdeps/common/mountlist.c782
-rw-r--r--sysdeps/common/mountlist.h12
-rw-r--r--sysdeps/common/sysdeps_suid.c44
-rw-r--r--sysdeps/common/xmalloc.c42
-rw-r--r--sysdeps/common/xmalloc_suid.c32
-rw-r--r--sysdeps/freebsd/close.c2
-rw-r--r--sysdeps/freebsd/cpu.c106
-rw-r--r--sysdeps/freebsd/glibtop_machine.h14
-rw-r--r--sysdeps/freebsd/glibtop_server.h2
-rw-r--r--sysdeps/freebsd/glibtop_suid.h26
-rw-r--r--sysdeps/freebsd/init.c20
-rw-r--r--sysdeps/freebsd/interfaces.c2
-rw-r--r--sysdeps/freebsd/loadavg.c28
-rw-r--r--sysdeps/freebsd/mem.c180
-rw-r--r--sysdeps/freebsd/msg_limits.c58
-rw-r--r--sysdeps/freebsd/netinfo.c40
-rw-r--r--sysdeps/freebsd/netload.c8
-rw-r--r--sysdeps/freebsd/nosuid.c2
-rw-r--r--sysdeps/freebsd/open.c78
-rw-r--r--sysdeps/freebsd/ppp.c78
-rw-r--r--sysdeps/freebsd/procargs.c88
-rw-r--r--sysdeps/freebsd/procdata.c148
-rw-r--r--sysdeps/freebsd/prockernel.c176
-rw-r--r--sysdeps/freebsd/proclist.c78
-rw-r--r--sysdeps/freebsd/procmap.c256
-rw-r--r--sysdeps/freebsd/procmem.c238
-rw-r--r--sysdeps/freebsd/procsegment.c58
-rw-r--r--sysdeps/freebsd/procsignal.c78
-rw-r--r--sysdeps/freebsd/procstate.c132
-rw-r--r--sysdeps/freebsd/proctime.c214
-rw-r--r--sysdeps/freebsd/procuid.c116
-rw-r--r--sysdeps/freebsd/sem_limits.c66
-rw-r--r--sysdeps/freebsd/shm_limits.c58
-rw-r--r--sysdeps/freebsd/siglist.c2
-rw-r--r--sysdeps/freebsd/swap.c458
-rw-r--r--sysdeps/freebsd/uptime.c32
-rw-r--r--sysdeps/kernel/close.c2
-rw-r--r--sysdeps/kernel/cpu.c2
-rw-r--r--sysdeps/kernel/glibtop_private.h2
-rw-r--r--sysdeps/kernel/glibtop_server.h2
-rw-r--r--sysdeps/kernel/interfaces.c2
-rw-r--r--sysdeps/kernel/loadavg.c2
-rw-r--r--sysdeps/kernel/mem.c2
-rw-r--r--sysdeps/kernel/msg_limits.c2
-rw-r--r--sysdeps/kernel/netinfo.c2
-rw-r--r--sysdeps/kernel/netload.c2
-rw-r--r--sysdeps/kernel/open.c4
-rw-r--r--sysdeps/kernel/ppp.c228
-rw-r--r--sysdeps/kernel/procargs.c2
-rw-r--r--sysdeps/kernel/procdata.c2
-rw-r--r--sysdeps/kernel/prockernel.c2
-rw-r--r--sysdeps/kernel/proclist.c2
-rw-r--r--sysdeps/kernel/procmap.c2
-rw-r--r--sysdeps/kernel/procmem.c2
-rw-r--r--sysdeps/kernel/procsegment.c2
-rw-r--r--sysdeps/kernel/procsignal.c2
-rw-r--r--sysdeps/kernel/procstate.c2
-rw-r--r--sysdeps/kernel/proctime.c2
-rw-r--r--sysdeps/kernel/procuid.c2
-rw-r--r--sysdeps/kernel/sem_limits.c2
-rw-r--r--sysdeps/kernel/shm_limits.c2
-rw-r--r--sysdeps/kernel/siglist.c2
-rw-r--r--sysdeps/kernel/swap.c2
-rw-r--r--sysdeps/kernel/sysinfo.c72
-rw-r--r--sysdeps/kernel/uptime.c2
-rw-r--r--sysdeps/linux/close.c2
-rw-r--r--sysdeps/linux/cpu.c106
-rw-r--r--sysdeps/linux/glibtop_machine.h12
-rw-r--r--sysdeps/linux/glibtop_server.h54
-rw-r--r--sysdeps/linux/interfaces.c2
-rw-r--r--sysdeps/linux/loadavg.c78
-rw-r--r--sysdeps/linux/mem.c62
-rw-r--r--sysdeps/linux/msg_limits.c34
-rw-r--r--sysdeps/linux/netinfo.c2
-rw-r--r--sysdeps/linux/netload.c20
-rw-r--r--sysdeps/linux/open.c46
-rw-r--r--sysdeps/linux/ppp.c232
-rw-r--r--sysdeps/linux/procargs.c74
-rw-r--r--sysdeps/linux/prockernel.c46
-rw-r--r--sysdeps/linux/proclist.c292
-rw-r--r--sysdeps/linux/procmap.c124
-rw-r--r--sysdeps/linux/procmem.c72
-rw-r--r--sysdeps/linux/procsegment.c80
-rw-r--r--sysdeps/linux/procsignal.c34
-rw-r--r--sysdeps/linux/procstate.c134
-rw-r--r--sysdeps/linux/proctime.c80
-rw-r--r--sysdeps/linux/procuid.c116
-rw-r--r--sysdeps/linux/sem_limits.c52
-rw-r--r--sysdeps/linux/shm_limits.c28
-rw-r--r--sysdeps/linux/siglist.c2
-rw-r--r--sysdeps/linux/swap.c94
-rw-r--r--sysdeps/linux/sysinfo.c72
-rw-r--r--sysdeps/linux/uptime.c48
-rw-r--r--sysdeps/names/prockernel.c18
-rw-r--r--sysdeps/osf1/close.c2
-rw-r--r--sysdeps/osf1/close_suid.c2
-rw-r--r--sysdeps/osf1/cpu.c34
-rw-r--r--sysdeps/osf1/glibtop_machine.h8
-rw-r--r--sysdeps/osf1/glibtop_server.h2
-rw-r--r--sysdeps/osf1/glibtop_suid.h8
-rw-r--r--sysdeps/osf1/loadavg.c50
-rw-r--r--sysdeps/osf1/mem.c26
-rw-r--r--sysdeps/osf1/msg_limits.c50
-rw-r--r--sysdeps/osf1/netload.c6
-rw-r--r--sysdeps/osf1/open.c2
-rw-r--r--sysdeps/osf1/open_suid.c54
-rw-r--r--sysdeps/osf1/ppp.c6
-rw-r--r--sysdeps/osf1/procargs.c8
-rw-r--r--sysdeps/osf1/procdata.c126
-rw-r--r--sysdeps/osf1/prockernel.c8
-rw-r--r--sysdeps/osf1/proclist.c118
-rw-r--r--sysdeps/osf1/procmap.c8
-rw-r--r--sysdeps/osf1/procmem.c60
-rw-r--r--sysdeps/osf1/procsegment.c38
-rw-r--r--sysdeps/osf1/procsignal.c36
-rw-r--r--sysdeps/osf1/procstate.c164
-rw-r--r--sysdeps/osf1/proctime.c38
-rw-r--r--sysdeps/osf1/procuid.c94
-rw-r--r--sysdeps/osf1/sem_limits.c70
-rw-r--r--sysdeps/osf1/shm_limits.c50
-rw-r--r--sysdeps/osf1/siglist.c2
-rw-r--r--sysdeps/osf1/swap.c32
-rw-r--r--sysdeps/osf1/uptime.c22
-rw-r--r--sysdeps/solaris/close.c2
-rw-r--r--sysdeps/solaris/close_suid.c2
-rw-r--r--sysdeps/solaris/cpu.c58
-rw-r--r--sysdeps/solaris/glibtop_machine.h2
-rw-r--r--sysdeps/solaris/glibtop_private.h2
-rw-r--r--sysdeps/solaris/glibtop_server.h2
-rw-r--r--sysdeps/solaris/glibtop_suid.h8
-rw-r--r--sysdeps/solaris/interfaces.c2
-rw-r--r--sysdeps/solaris/loadavg.c2
-rw-r--r--sysdeps/solaris/mem.c54
-rw-r--r--sysdeps/solaris/msg_limits.c2
-rw-r--r--sysdeps/solaris/netinfo.c2
-rw-r--r--sysdeps/solaris/netload.c2
-rw-r--r--sysdeps/solaris/open.c182
-rw-r--r--sysdeps/solaris/open_suid.c56
-rw-r--r--sysdeps/solaris/ppp.c2
-rw-r--r--sysdeps/solaris/procargs.c2
-rw-r--r--sysdeps/solaris/procdata.c254
-rw-r--r--sysdeps/solaris/prockernel.c2
-rw-r--r--sysdeps/solaris/proclist.c2
-rw-r--r--sysdeps/solaris/procmap.c2
-rw-r--r--sysdeps/solaris/procmem.c2
-rw-r--r--sysdeps/solaris/procsegment.c2
-rw-r--r--sysdeps/solaris/procsignal.c2
-rw-r--r--sysdeps/solaris/procstate.c2
-rw-r--r--sysdeps/solaris/proctime.c2
-rw-r--r--sysdeps/solaris/procuid.c2
-rw-r--r--sysdeps/solaris/safeio.c2
-rw-r--r--sysdeps/solaris/sem_limits.c2
-rw-r--r--sysdeps/solaris/shm_limits.c2
-rw-r--r--sysdeps/solaris/siglist.c2
-rw-r--r--sysdeps/solaris/swap.c6
-rw-r--r--sysdeps/solaris/uptime.c2
-rw-r--r--sysdeps/stub/close.c2
-rw-r--r--sysdeps/stub/cpu.c10
-rw-r--r--sysdeps/stub/glibtop_server.h2
-rw-r--r--sysdeps/stub/interfaces.c2
-rw-r--r--sysdeps/stub/loadavg.c10
-rw-r--r--sysdeps/stub/mem.c10
-rw-r--r--sysdeps/stub/msg_limits.c10
-rw-r--r--sysdeps/stub/netload.c10
-rw-r--r--sysdeps/stub/open.c4
-rw-r--r--sysdeps/stub/ppp.c10
-rw-r--r--sysdeps/stub/procargs.c10
-rw-r--r--sysdeps/stub/prockernel.c10
-rw-r--r--sysdeps/stub/proclist.c10
-rw-r--r--sysdeps/stub/procmap.c12
-rw-r--r--sysdeps/stub/procmem.c10
-rw-r--r--sysdeps/stub/procsegment.c10
-rw-r--r--sysdeps/stub/procsignal.c10
-rw-r--r--sysdeps/stub/procstate.c10
-rw-r--r--sysdeps/stub/proctime.c10
-rw-r--r--sysdeps/stub/procuid.c10
-rw-r--r--sysdeps/stub/sem_limits.c10
-rw-r--r--sysdeps/stub/shm_limits.c10
-rw-r--r--sysdeps/stub/siglist.c2
-rw-r--r--sysdeps/stub/swap.c10
-rw-r--r--sysdeps/stub/uptime.c10
-rw-r--r--sysdeps/stub_suid/close.c2
-rw-r--r--sysdeps/stub_suid/cpu.c12
-rw-r--r--sysdeps/stub_suid/glibtop_machine.h6
-rw-r--r--sysdeps/stub_suid/glibtop_server.h2
-rw-r--r--sysdeps/stub_suid/glibtop_suid.h8
-rw-r--r--sysdeps/stub_suid/init.c20
-rw-r--r--sysdeps/stub_suid/interfaces.c2
-rw-r--r--sysdeps/stub_suid/loadavg.c12
-rw-r--r--sysdeps/stub_suid/mem.c12
-rw-r--r--sysdeps/stub_suid/msg_limits.c12
-rw-r--r--sysdeps/stub_suid/netload.c10
-rw-r--r--sysdeps/stub_suid/nosuid.c2
-rw-r--r--sysdeps/stub_suid/open.c48
-rw-r--r--sysdeps/stub_suid/ppp.c10
-rw-r--r--sysdeps/stub_suid/procargs.c10
-rw-r--r--sysdeps/stub_suid/procdata.c148
-rw-r--r--sysdeps/stub_suid/prockernel.c12
-rw-r--r--sysdeps/stub_suid/proclist.c12
-rw-r--r--sysdeps/stub_suid/procmap.c10
-rw-r--r--sysdeps/stub_suid/procmem.c12
-rw-r--r--sysdeps/stub_suid/procsegment.c12
-rw-r--r--sysdeps/stub_suid/procsignal.c12
-rw-r--r--sysdeps/stub_suid/procstate.c12
-rw-r--r--sysdeps/stub_suid/proctime.c12
-rw-r--r--sysdeps/stub_suid/procuid.c12
-rw-r--r--sysdeps/stub_suid/sem_limits.c12
-rw-r--r--sysdeps/stub_suid/shm_limits.c12
-rw-r--r--sysdeps/stub_suid/siglist.c2
-rw-r--r--sysdeps/stub_suid/swap.c12
-rw-r--r--sysdeps/stub_suid/uptime.c12
-rw-r--r--sysdeps/sun4/close.c2
-rw-r--r--sysdeps/sun4/cpu.c88
-rw-r--r--sysdeps/sun4/glibtop_machine.h28
-rw-r--r--sysdeps/sun4/glibtop_server.h2
-rw-r--r--sysdeps/sun4/glibtop_suid.h8
-rw-r--r--sysdeps/sun4/loadavg.c40
-rw-r--r--sysdeps/sun4/loadavg.h8
-rw-r--r--sysdeps/sun4/mem.c76
-rw-r--r--sysdeps/sun4/msg_limits.c42
-rw-r--r--sysdeps/sun4/nosuid.c2
-rw-r--r--sysdeps/sun4/open.c280
-rw-r--r--sysdeps/sun4/ppp.c6
-rw-r--r--sysdeps/sun4/procdata.c4
-rw-r--r--sysdeps/sun4/prockernel.c26
-rw-r--r--sysdeps/sun4/proclist.c72
-rw-r--r--sysdeps/sun4/procmem.c28
-rw-r--r--sysdeps/sun4/procsegment.c26
-rw-r--r--sysdeps/sun4/procsignal.c30
-rw-r--r--sysdeps/sun4/procstate.c26
-rw-r--r--sysdeps/sun4/proctime.c26
-rw-r--r--sysdeps/sun4/procuid.c40
-rw-r--r--sysdeps/sun4/sem_limits.c50
-rw-r--r--sysdeps/sun4/shm_limits.c38
-rw-r--r--sysdeps/sun4/siglist.c2
-rw-r--r--sysdeps/sun4/swap.c6
-rw-r--r--sysdeps/sun4/uptime.c32
272 files changed, 6256 insertions, 5707 deletions
diff --git a/acconfig.h b/acconfig.h
index e846f1a7..3764360a 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* Define if gethostname () must be declared. */
#undef NEED_DECLARATION_GETHOSTNAME
diff --git a/glibtop-server-private.h b/glibtop-server-private.h
index 129a6800..20fcb280 100644
--- a/glibtop-server-private.h
+++ b/glibtop-server-private.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,12 +33,12 @@
struct _glibtop_server_private
{
#ifdef HAVE_GLIBTOP_MACHINE_H
- glibtop_machine machine; /* Machine dependent data */
+ glibtop_machine machine; /* Machine dependent data */
#endif
- int input [2]; /* Pipe client <- server */
- int output [2]; /* Pipe client -> server */
- int socket; /* Accepted connection of a socket */
- pid_t pid; /* PID of the server */
+ int input [2]; /* Pipe client <- server */
+ int output [2]; /* Pipe client -> server */
+ int socket; /* Accepted connection of a socket */
+ pid_t pid; /* PID of the server */
};
#endif
diff --git a/glibtop.h b/glibtop.h
index 613bc16f..bfc848dc 100644
--- a/glibtop.h
+++ b/glibtop.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -48,24 +50,24 @@ typedef struct _glibtop_server_private glibtop_server_private;
struct _glibtop
{
- int refcount; /* Reference count */
- unsigned flags;
- unsigned method; /* Server Method */
- unsigned error_method; /* Error Method */
- int ncpu; /* Number of CPUs, zero if single-processor */
- unsigned long os_version_code; /* Version code of the operating system */
- const char *name; /* Program name for error messages */
- const char *server_command; /* Command used to invoke server */
- const char *server_host; /* Host the server should run on */
- const char *server_user; /* Name of the user on the target host */
- const char *server_rsh; /* Command used to connect to the target host */
- unsigned long features; /* Server is required for this features */
- unsigned long server_port; /* Port on which daemon is listening */
- glibtop_sysdeps sysdeps; /* Detailed feature list */
- glibtop_sysdeps required; /* Required feature list */
- glibtop_sysdeps wanted; /* We only want this features */
- glibtop_server_private *_priv; /* Private data */
- unsigned glibtop_errno;
+ int refcount; /* Reference count */
+ unsigned flags;
+ unsigned method; /* Server Method */
+ unsigned error_method; /* Error Method */
+ int ncpu; /* Number of CPUs, zero if single-processor */
+ unsigned long os_version_code; /* Version code of the operating system */
+ const char *name; /* Program name for error messages */
+ const char *server_command; /* Command used to invoke server */
+ const char *server_host; /* Host the server should run on */
+ const char *server_user; /* Name of the user on the target host */
+ const char *server_rsh; /* Command used to connect to the target host */
+ unsigned long features; /* Server is required for this features */
+ unsigned long server_port; /* Port on which daemon is listening */
+ glibtop_sysdeps sysdeps; /* Detailed feature list */
+ glibtop_sysdeps required; /* Required feature list */
+ glibtop_sysdeps wanted; /* We only want this features */
+ glibtop_server_private *_priv; /* Private data */
+ unsigned glibtop_errno;
};
extern glibtop *glibtop_global_server;
diff --git a/include/glibtop/array.h b/include/glibtop/array.h
index bb5b4c6d..35da36ed 100644
--- a/include/glibtop/array.h
+++ b/include/glibtop/array.h
@@ -41,10 +41,10 @@ typedef struct _glibtop_array glibtop_array;
struct _glibtop_array
{
- u_int64_t flags,
- number, /* GLIBTOP_ARRAY_NUMBER */
- size, /* GLIBTOP_ARRAY_SIZE */
- total; /* GLIBTOP_ARRAY_TOTAL */
+ u_int64_t flags,
+ number, /* GLIBTOP_ARRAY_NUMBER */
+ size, /* GLIBTOP_ARRAY_SIZE */
+ total; /* GLIBTOP_ARRAY_TOTAL */
};
#endif
diff --git a/kernel/sysctl/libgtop.c b/kernel/sysctl/libgtop.c
index 8c769644..866665db 100644
--- a/kernel/sysctl/libgtop.c
+++ b/kernel/sysctl/libgtop.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/*
* linux/libgtop/module.c
* Copyright (C) 1999 Martin Baulig
@@ -282,7 +284,7 @@ get_wchan (struct task_struct *p)
# define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
# define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
#elif defined(__alpha__)
- /*
+/*
* See arch/alpha/kernel/ptrace.c for details.
*/
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
@@ -426,8 +428,8 @@ statm_pgd_range (pgd_t * pgd, unsigned long address, unsigned long end,
statm_pmd_range (pgd, address, end - address, pages,
shared, dirty, total);
address = (address + PGDIR_SIZE) & PGDIR_MASK;
- pgd++;
- }
+ pgd++;
+ }
}
static void
diff --git a/kernel/sysctl/libgtop.h b/kernel/sysctl/libgtop.h
index f43a91c5..86a52ba8 100644
--- a/kernel/sysctl/libgtop.h
+++ b/kernel/sysctl/libgtop.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
#ifndef _LINUX_LIBGTOP_H
#define _LINUX_LIBGTOP_H 1
diff --git a/kernel/sysctl/libgtop_syms.c b/kernel/sysctl/libgtop_syms.c
index c11bc090..46efc162 100644
--- a/kernel/sysctl/libgtop_syms.c
+++ b/kernel/sysctl/libgtop_syms.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/*
* linux/libgtop/libgtop_syms.c
* Copyright (C) 1999 Martin Baulig
diff --git a/kernel/sysctl/main.c b/kernel/sysctl/main.c
index 6d391eb4..1b9a0392 100644
--- a/kernel/sysctl/main.c
+++ b/kernel/sysctl/main.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/*
* linux/libgtop/main.c
* Copyright (C) 1999 Martin Baulig
diff --git a/lib/close.c b/lib/close.c
index 4fe47088..618e27fd 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,20 +33,20 @@
void
glibtop_close_r (glibtop *server)
{
- switch (server->method) {
- case GLIBTOP_METHOD_UNIX:
- case GLIBTOP_METHOD_INET:
- glibtop_call_l (server, GLIBTOP_CMND_QUIT,
- 0, NULL, 0, NULL, NULL);
-
- if (close (server->_priv->socket))
- glibtop_warn_io ("close");
-
- break;
- case GLIBTOP_METHOD_PIPE:
- kill (server->_priv->pid, SIGKILL);
- close (server->_priv->input [0]);
- close (server->_priv->output [1]);
- break;
- }
+ switch (server->method) {
+ case GLIBTOP_METHOD_UNIX:
+ case GLIBTOP_METHOD_INET:
+ glibtop_call_l (server, GLIBTOP_CMND_QUIT,
+ 0, NULL, 0, NULL, NULL);
+
+ if (close (server->_priv->socket))
+ glibtop_warn_io ("close");
+
+ break;
+ case GLIBTOP_METHOD_PIPE:
+ kill (server->_priv->pid, SIGKILL);
+ close (server->_priv->input [0]);
+ close (server->_priv->output [1]);
+ break;
+ }
}
diff --git a/lib/command.c b/lib/command.c
index 11ceb722..5bbdc75f 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,51 +35,51 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
const void *send_buf, size_t recv_size, void *recv_buf,
int *retval_ptr)
{
- glibtop_command cmnd;
- glibtop_response response;
- int retval;
+ glibtop_command cmnd;
+ glibtop_response response;
+ int retval;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- memset (&cmnd, 0, sizeof (glibtop_command));
+ memset (&cmnd, 0, sizeof (glibtop_command));
- cmnd.command = command;
+ cmnd.command = command;
- /* If send_size is less than _GLIBTOP_PARAM_SIZE (normally 16 Bytes), we
- * send it together with command, so we only need one system call instead
- * of two. */
+ /* If send_size is less than _GLIBTOP_PARAM_SIZE (normally 16 Bytes), we
+ * send it together with command, so we only need one system call instead
+ * of two. */
- if (send_size <= _GLIBTOP_PARAM_SIZE) {
- memcpy (cmnd.parameter, send_buf, send_size);
- cmnd.size = send_size;
- } else {
- cmnd.data_size = send_size;
- }
+ if (send_size <= _GLIBTOP_PARAM_SIZE) {
+ memcpy (cmnd.parameter, send_buf, send_size);
+ cmnd.size = send_size;
+ } else {
+ cmnd.data_size = send_size;
+ }
- glibtop_write_l (server, sizeof (glibtop_command), &cmnd);
+ glibtop_write_l (server, sizeof (glibtop_command), &cmnd);
- glibtop_read_l (server, sizeof (glibtop_response), &response);
+ glibtop_read_l (server, sizeof (glibtop_response), &response);
#ifdef DEBUG
- fprintf (stderr, "RESPONSE: %lu - %d\n",
- response.offset, response.data_size);
+ fprintf (stderr, "RESPONSE: %lu - %d\n",
+ response.offset, response.data_size);
#endif
- glibtop_read_l (server, sizeof (int), &retval);
- if (retval_ptr)
- *retval_ptr = retval;
+ glibtop_read_l (server, sizeof (int), &retval);
+ if (retval_ptr)
+ *retval_ptr = retval;
- if (recv_buf)
- memcpy (recv_buf, ((char *) &response) + response.offset,
- recv_size);
+ if (recv_buf)
+ memcpy (recv_buf, ((char *) &response) + response.offset,
+ recv_size);
- if (response.data_size) {
- void *ptr = glibtop_malloc_r (server, response.data_size);
+ if (response.data_size) {
+ void *ptr = glibtop_malloc_r (server, response.data_size);
- glibtop_read_l (server, response.data_size, ptr);
+ glibtop_read_l (server, response.data_size, ptr);
- return ptr;
- }
+ return ptr;
+ }
- return NULL;
+ return NULL;
}
diff --git a/lib/errors.c b/lib/errors.c
index 2b5f518d..56205153 100644
--- a/lib/errors.c
+++ b/lib/errors.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/lib/glib-arrays.c b/lib/glib-arrays.c
index 1f3324c2..d0310eb6 100644
--- a/lib/glib-arrays.c
+++ b/lib/glib-arrays.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/lib/init.c b/lib/init.c
index 5864119c..ac7bc249 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,242 +38,242 @@ glibtop *glibtop_global_server = &_glibtop_global_server;
static void
_init_server (glibtop *server, const unsigned features)
{
- char *command, *temp;
+ char *command, *temp;
- /* Try to get server command, but don't override if already
- * set via glibtop_set_parameter () */
+ /* Try to get server command, but don't override if already
+ * set via glibtop_set_parameter () */
- if (server->server_command == NULL) {
- const char *temp = getenv ("LIBGTOP_SERVER") ?
- getenv ("LIBGTOP_SERVER") : LIBGTOP_SERVER;
+ if (server->server_command == NULL) {
+ const char *temp = getenv ("LIBGTOP_SERVER") ?
+ getenv ("LIBGTOP_SERVER") : LIBGTOP_SERVER;
- server->server_command = glibtop_strdup_r (server, temp);
- }
+ server->server_command = glibtop_strdup_r (server, temp);
+ }
- if (server->server_rsh == NULL) {
- const char *temp = getenv ("LIBGTOP_RSH") ?
- getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
+ if (server->server_rsh == NULL) {
+ const char *temp = getenv ("LIBGTOP_RSH") ?
+ getenv ("LIBGTOP_RSH") : "/usr/bin/ssh";
- server->server_rsh = glibtop_strdup_r (server, temp);
- }
+ server->server_rsh = glibtop_strdup_r (server, temp);
+ }
- /* Try to get server method, but don't override if already
- * set via glibtop_set_parameter () */
+ /* Try to get server method, but don't override if already
+ * set via glibtop_set_parameter () */
- if (server->method) return;
+ if (server->method) return;
- /* If server->command doesn't start with a colon, then it is
- * the full pathname of the server executable. */
+ /* If server->command doesn't start with a colon, then it is
+ * the full pathname of the server executable. */
- if (server->server_command [0] != ':') {
- if (features & glibtop_server_features) {
- /* We really need the server. */
- server->method = GLIBTOP_METHOD_PIPE;
- } else {
- /* Fine. No server is needed, so we call the
- * sysdeps functions directly. */
- server->method = GLIBTOP_METHOD_DIRECT;
- }
-
- return;
+ if (server->server_command [0] != ':') {
+ if (features & glibtop_server_features) {
+ /* We really need the server. */
+ server->method = GLIBTOP_METHOD_PIPE;
+ } else {
+ /* Fine. No server is needed, so we call the
+ * sysdeps functions directly. */
+ server->method = GLIBTOP_METHOD_DIRECT;
}
+ return;
+ }
+
- /* If the first character of 'server_command' is a colon,
- * the first field is the method to connect to the server. */
+ /* If the first character of 'server_command' is a colon,
+ * the first field is the method to connect to the server. */
- /* Everything up to the next colon is the method. */
+ /* Everything up to the next colon is the method. */
- command = glibtop_strdup_r (server, server->server_command+1);
- temp = strstr (command, ":");
- if (temp) *temp = 0;
+ command = glibtop_strdup_r (server, server->server_command+1);
+ temp = strstr (command, ":");
+ if (temp) *temp = 0;
- /* Dispatch method. */
+ /* Dispatch method. */
- if (!strcmp (command, "direct")) {
- /* Use sysdeps dir instead of connecting to server
- * even if using the server would be required on
- * the current system. */
- server->method = GLIBTOP_METHOD_DIRECT;
-
- } else if (!strcmp (command, "inet")) {
-
- server->method = GLIBTOP_METHOD_INET;
-
- /* Connect to internet server. */
-
- if (temp == NULL) {
- /* If no value was set, we use 'localhost'. */
- if (server->server_host == NULL)
- server->server_host = glibtop_strdup_r
- (server, "localhost");
- } else {
- char *temp2 = strstr (temp+1, ":");
- if (temp2) *temp2 = 0;
+ if (!strcmp (command, "direct")) {
+ /* Use sysdeps dir instead of connecting to server
+ * even if using the server would be required on
+ * the current system. */
+ server->method = GLIBTOP_METHOD_DIRECT;
+
+ } else if (!strcmp (command, "inet")) {
+
+ server->method = GLIBTOP_METHOD_INET;
+
+ /* Connect to internet server. */
+
+ if (temp == NULL) {
+ /* If no value was set, we use 'localhost'. */
+ if (server->server_host == NULL)
+ server->server_host = glibtop_strdup_r
+ (server, "localhost");
+ } else {
+ char *temp2 = strstr (temp+1, ":");
+ if (temp2) *temp2 = 0;
- /* Override default. */
- if (server->server_host)
- glibtop_free_r (server,
- (char *) server->server_host);
+ /* Override default. */
+ if (server->server_host)
+ glibtop_free_r (server,
+ (char *) server->server_host);
- server->server_host = glibtop_strdup_r
- (server, temp+1);
+ server->server_host = glibtop_strdup_r
+ (server, temp+1);
- temp = temp2;
- }
+ temp = temp2;
+ }
- if (temp == NULL) {
- /* If no value was set, we use DEFAULT_PORT. */
- if (server->server_port == 0)
- server->server_port = DEFAULT_PORT;
- } else {
- char *temp2 = strstr (temp+1, ":");
- if (temp2) *temp2 = 0;
+ if (temp == NULL) {
+ /* If no value was set, we use DEFAULT_PORT. */
+ if (server->server_port == 0)
+ server->server_port = DEFAULT_PORT;
+ } else {
+ char *temp2 = strstr (temp+1, ":");
+ if (temp2) *temp2 = 0;
- if (sscanf (temp+1, "%ld", &server->server_port) != 1)
- server->server_port = DEFAULT_PORT;
+ if (sscanf (temp+1, "%ld", &server->server_port) != 1)
+ server->server_port = DEFAULT_PORT;
- temp = temp2 ? temp2 + 1 : temp2;
- }
+ temp = temp2 ? temp2 + 1 : temp2;
+ }
- } else if (!strcmp (command, "unix")) {
+ } else if (!strcmp (command, "unix")) {
- /* Connect to unix domain socket. */
- server->method = GLIBTOP_METHOD_UNIX;
+ /* Connect to unix domain socket. */
+ server->method = GLIBTOP_METHOD_UNIX;
- } else if (!strcmp (command, "pipe")) {
+ } else if (!strcmp (command, "pipe")) {
- /* Open pipe to server. */
- server->method = GLIBTOP_METHOD_PIPE;
+ /* Open pipe to server. */
+ server->method = GLIBTOP_METHOD_PIPE;
- } else {
+ } else {
- glibtop_error_r (server, "Unknown server method '%s'",
- server->server_command+1);
+ glibtop_error_r (server, "Unknown server method '%s'",
+ server->server_command+1);
- }
+ }
- glibtop_free_r (server, command);
+ glibtop_free_r (server, command);
}
void
glibtop_server_ref (glibtop *server)
{
- if (server == NULL)
- return;
+ if (server == NULL)
+ return;
- server->refcount++;
+ server->refcount++;
}
void
glibtop_server_unref (glibtop *server)
{
- if (server == NULL)
- return;
+ if (server == NULL)
+ return;
- if (!server->refcount) {
- glibtop_warn_r (server, "Attempted to unref server "
- "which refcount == 0");
- return;
- }
+ if (!server->refcount) {
+ glibtop_warn_r (server, "Attempted to unref server "
+ "which refcount == 0");
+ return;
+ }
- server->refcount--;
+ server->refcount--;
}
glibtop *
glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
{
- glibtop *server;
+ glibtop *server;
- if (server_ptr == NULL)
- return NULL;
+ if (server_ptr == NULL)
+ return NULL;
- if (*server_ptr == NULL)
- *server_ptr = glibtop_global_server;
+ if (*server_ptr == NULL)
+ *server_ptr = glibtop_global_server;
- server = *server_ptr;
+ server = *server_ptr;
- /* Should we do the initialization? */
+ /* Should we do the initialization? */
- if (flags & GLIBTOP_INIT_NO_INIT)
- return server;
+ if (flags & GLIBTOP_INIT_NO_INIT)
+ return server;
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
- if (flags & GLIBTOP_FEATURES_EXCEPT)
- features = ~features & GLIBTOP_SYSDEPS_ALL;
+ if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
+ if (flags & GLIBTOP_FEATURES_EXCEPT)
+ features = ~features & GLIBTOP_SYSDEPS_ALL;
- if (features == 0)
- features = GLIBTOP_SYSDEPS_ALL;
+ if (features == 0)
+ features = GLIBTOP_SYSDEPS_ALL;
- if (flags & GLIBTOP_FEATURES_NO_SERVER) {
- server->method = GLIBTOP_METHOD_DIRECT;
- features = 0;
- }
+ if (flags & GLIBTOP_FEATURES_NO_SERVER) {
+ server->method = GLIBTOP_METHOD_DIRECT;
+ features = 0;
+ }
- server->features = features;
+ server->features = features;
- _init_server (server, features);
+ _init_server (server, features);
- server->flags |= _GLIBTOP_INIT_STATE_INIT;
+ server->flags |= _GLIBTOP_INIT_STATE_INIT;
- switch (server->method) {
- case GLIBTOP_METHOD_PIPE:
- case GLIBTOP_METHOD_UNIX:
- if (glibtop_server_features & features)
- break;
+ switch (server->method) {
+ case GLIBTOP_METHOD_PIPE:
+ case GLIBTOP_METHOD_UNIX:
+ if (glibtop_server_features & features)
+ break;
- server->method = GLIBTOP_METHOD_DIRECT;
- break;
- }
+ server->method = GLIBTOP_METHOD_DIRECT;
+ break;
}
+ }
- /* Should we open the server? */
+ /* Should we open the server? */
- if (flags & GLIBTOP_INIT_NO_OPEN)
- return server;
+ if (flags & GLIBTOP_INIT_NO_OPEN)
+ return server;
- /* Open server, but only if not already opened. */
+ /* Open server, but only if not already opened. */
- if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0)
- glibtop_open_l (glibtop_global_server, "glibtop",
- features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0)
+ glibtop_open_l (glibtop_global_server, "glibtop",
+ features, flags);
- return server;
+ return server;
}
glibtop *
glibtop_init_s (glibtop **server_ptr, unsigned long features, unsigned flags)
{
- glibtop *server;
- glibtop_init_func_t *init_fkt;
+ glibtop *server;
+ glibtop_init_func_t *init_fkt;
- if (server_ptr == NULL)
- return NULL;
+ if (server_ptr == NULL)
+ return NULL;
- if (*server_ptr == NULL)
- *server_ptr = glibtop_global_server;
+ if (*server_ptr == NULL)
+ *server_ptr = glibtop_global_server;
- server = *server_ptr;
+ server = *server_ptr;
- /* Should we do the initialization? */
+ /* Should we do the initialization? */
- if (flags & GLIBTOP_INIT_NO_INIT)
- return server;
+ if (flags & GLIBTOP_INIT_NO_INIT)
+ return server;
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
- glibtop_open_s (server, "glibtop", features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
+ glibtop_open_s (server, "glibtop", features, flags);
- for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
- (*init_fkt) (server);
+ for (init_fkt = _glibtop_init_hook_s; *init_fkt; init_fkt++)
+ (*init_fkt) (server);
- server->sysdeps.pointer_size = sizeof (void*)*8;
+ server->sysdeps.pointer_size = sizeof (void*)*8;
- server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
- }
+ server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
+ }
- return server;
+ return server;
}
diff --git a/lib/inodedb.c b/lib/inodedb.c
index d78d3905..2b0a4bf3 100644
--- a/lib/inodedb.c
+++ b/lib/inodedb.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -37,44 +39,44 @@ glibtop_inodedb *
glibtop_inodedb_open_s (glibtop *server, unsigned databases,
unsigned long cachesize)
{
- glibtop_inodedb *inodedb;
- char filename [BUFSIZ];
- struct passwd *pwd;
- struct stat statb;
+ glibtop_inodedb *inodedb;
+ char filename [BUFSIZ];
+ struct passwd *pwd;
+ struct stat statb;
- if (!databases)
- databases = GLIBTOP_INODEDB_ALL;
+ if (!databases)
+ databases = GLIBTOP_INODEDB_ALL;
- inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
+ inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
- if (stat (SYSTEM_INODEDB, &statb))
- databases &= ~GLIBTOP_INODEDB_SYSTEM;
+ if (stat (SYSTEM_INODEDB, &statb))
+ databases &= ~GLIBTOP_INODEDB_SYSTEM;
- if (databases & GLIBTOP_INODEDB_SYSTEM) {
- inodedb->system_dbf = gdbm_open
- (SYSTEM_INODEDB, 0, GDBM_READER, 0, 0);
- if (!inodedb->system_dbf)
- glibtop_error_io_r
- (server, "gdbm_open (%s)", SYSTEM_INODEDB);
- }
+ if (databases & GLIBTOP_INODEDB_SYSTEM) {
+ inodedb->system_dbf = gdbm_open
+ (SYSTEM_INODEDB, 0, GDBM_READER, 0, 0);
+ if (!inodedb->system_dbf)
+ glibtop_error_io_r
+ (server, "gdbm_open (%s)", SYSTEM_INODEDB);
+ }
- pwd = getpwuid (getuid ());
- if (!pwd) glibtop_error_io_r (server, "getpwuid");
+ pwd = getpwuid (getuid ());
+ if (!pwd) glibtop_error_io_r (server, "getpwuid");
- sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
+ sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
- if (stat (filename, &statb))
- databases &= ~GLIBTOP_INODEDB_USER;
-
- if (databases & GLIBTOP_INODEDB_USER) {
- inodedb->user_dbf = gdbm_open
- (filename, 0, GDBM_READER, 0, 0);
- if (!inodedb->user_dbf)
- glibtop_error_io_r
- (server, "gdbm_open (%s)", filename);
- }
-
- return inodedb;
+ if (stat (filename, &statb))
+ databases &= ~GLIBTOP_INODEDB_USER;
+
+ if (databases & GLIBTOP_INODEDB_USER) {
+ inodedb->user_dbf = gdbm_open
+ (filename, 0, GDBM_READER, 0, 0);
+ if (!inodedb->user_dbf)
+ glibtop_error_io_r
+ (server, "gdbm_open (%s)", filename);
+ }
+
+ return inodedb;
}
const char *
@@ -82,36 +84,36 @@ glibtop_inodedb_lookup_s (glibtop *server,
glibtop_inodedb *inodedb,
u_int64_t device, u_int64_t inode)
{
- glibtop_inodedb_key key;
- datum d_key, d_content;
+ glibtop_inodedb_key key;
+ datum d_key, d_content;
- d_key.dptr = (void *) &key;
- d_key.dsize = sizeof (key);
+ d_key.dptr = (void *) &key;
+ d_key.dsize = sizeof (key);
- key.device = device;
- key.inode = inode;
+ key.device = device;
+ key.inode = inode;
- if (inodedb->system_dbf) {
- d_content = gdbm_fetch (inodedb->system_dbf, d_key);
- if (d_content.dptr) return d_content.dptr;
- }
+ if (inodedb->system_dbf) {
+ d_content = gdbm_fetch (inodedb->system_dbf, d_key);
+ if (d_content.dptr) return d_content.dptr;
+ }
- if (inodedb->user_dbf) {
- d_content = gdbm_fetch (inodedb->user_dbf, d_key);
- if (d_content.dptr) return d_content.dptr;
- }
+ if (inodedb->user_dbf) {
+ d_content = gdbm_fetch (inodedb->user_dbf, d_key);
+ if (d_content.dptr) return d_content.dptr;
+ }
- return NULL;
+ return NULL;
}
void
glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
{
- if (inodedb->system_dbf)
- gdbm_close (inodedb->system_dbf);
+ if (inodedb->system_dbf)
+ gdbm_close (inodedb->system_dbf);
- if (inodedb->user_dbf)
- gdbm_close (inodedb->user_dbf);
+ if (inodedb->user_dbf)
+ gdbm_close (inodedb->user_dbf);
- glibtop_free_r (server, inodedb);
+ glibtop_free_r (server, inodedb);
}
diff --git a/lib/open.c b/lib/open.c
index e53c9be3..0b41063c 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,154 +38,154 @@ void
glibtop_open_l (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- int connect_type;
+ int connect_type;
- if (!server->_priv)
- server->_priv = glibtop_calloc_r
- (server, 1, sizeof (glibtop_server_private));
+ if (!server->_priv)
+ server->_priv = glibtop_calloc_r
+ (server, 1, sizeof (glibtop_server_private));
- server->name = program_name;
+ server->name = program_name;
- /* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we
- * do recursive calls to glibtop_init_r (). */
+ /* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we
+ * do recursive calls to glibtop_init_r (). */
- server->flags |= _GLIBTOP_INIT_STATE_OPEN;
+ server->flags |= _GLIBTOP_INIT_STATE_OPEN;
- server->error_method = GLIBTOP_ERROR_METHOD_DEFAULT;
+ server->error_method = GLIBTOP_ERROR_METHOD_DEFAULT;
#ifdef DEBUG
- fprintf (stderr, "SIZEOF: %u - %u - %u - %u - %u - %u\n",
- sizeof (glibtop_command), sizeof (glibtop_response),
- sizeof (glibtop_mountentry), sizeof (glibtop_union),
- sizeof (glibtop_sysdeps), sizeof (glibtop_response_union));
+ fprintf (stderr, "SIZEOF: %u - %u - %u - %u - %u - %u\n",
+ sizeof (glibtop_command), sizeof (glibtop_response),
+ sizeof (glibtop_mountentry), sizeof (glibtop_union),
+ sizeof (glibtop_sysdeps), sizeof (glibtop_response_union));
#endif
- switch (server->method) {
- case GLIBTOP_METHOD_DIRECT:
- server->features = 0;
- break;
- case GLIBTOP_METHOD_INET:
+ switch (server->method) {
+ case GLIBTOP_METHOD_DIRECT:
+ server->features = 0;
+ break;
+ case GLIBTOP_METHOD_INET:
#ifdef DEBUG
- fprintf (stderr, "Connecting to '%s' port %ld.\n",
- server->server_host, server->server_port);
+ fprintf (stderr, "Connecting to '%s' port %ld.\n",
+ server->server_host, server->server_port);
#endif
- connect_type = glibtop_make_connection
- (server->server_host, server->server_port,
- &server->_priv->socket);
+ connect_type = glibtop_make_connection
+ (server->server_host, server->server_port,
+ &server->_priv->socket);
#ifdef DEBUG
- fprintf (stderr, "Connect Type is %d.\n", connect_type);
+ fprintf (stderr, "Connect Type is %d.\n", connect_type);
#endif
- server->flags |= _GLIBTOP_INIT_STATE_SERVER;
+ server->flags |= _GLIBTOP_INIT_STATE_SERVER;
- server->features = -1;
- break;
- case GLIBTOP_METHOD_UNIX:
+ server->features = -1;
+ break;
+ case GLIBTOP_METHOD_UNIX:
#ifdef DEBUG
- fprintf (stderr, "Connecting to Unix Domain Socket.\n");
+ fprintf (stderr, "Connecting to Unix Domain Socket.\n");
#endif
- connect_type = glibtop_make_connection
- ("unix", 0, &server->_priv->socket);
+ connect_type = glibtop_make_connection
+ ("unix", 0, &server->_priv->socket);
#ifdef DEBUG
- fprintf (stderr, "Connect Type is %d.\n", connect_type);
+ fprintf (stderr, "Connect Type is %d.\n", connect_type);
#endif
- server->flags |= _GLIBTOP_INIT_STATE_SERVER;
+ server->flags |= _GLIBTOP_INIT_STATE_SERVER;
- server->features = -1;
- break;
- case GLIBTOP_METHOD_PIPE:
+ server->features = -1;
+ break;
+ case GLIBTOP_METHOD_PIPE:
#ifdef DEBUG
- fprintf (stderr, "Opening pipe to server (%s).\n",
- LIBGTOP_SERVER);
+ fprintf (stderr, "Opening pipe to server (%s).\n",
+ LIBGTOP_SERVER);
#endif
- if (pipe (server->_priv->input) ||
- pipe (server->_priv->output))
- glibtop_error_io_r (server, "cannot make a pipe");
+ if (pipe (server->_priv->input) ||
+ pipe (server->_priv->output))
+ glibtop_error_io_r (server, "cannot make a pipe");
- server->_priv->pid = fork ();
-
- if (server->_priv->pid < 0) {
- glibtop_error_io_r (server, "fork failed");
- } else if (server->_priv->pid == 0) {
- close (0); close (1);
- close (server->_priv->input [0]);
- close (server->_priv->output [1]);
- dup2 (server->_priv->input [1], 1);
- dup2 (server->_priv->output [0], 0);
- execl (LIBGTOP_SERVER, "libgtop-server", NULL);
- glibtop_error_io_r (server, "execl (%s)",
- LIBGTOP_SERVER);
- _exit (2);
- }
-
- close (server->_priv->input [1]);
- close (server->_priv->output [0]);
-
- server->flags |= _GLIBTOP_INIT_STATE_SERVER;
+ server->_priv->pid = fork ();
- server->features = -1;
- break;
+ if (server->_priv->pid < 0) {
+ glibtop_error_io_r (server, "fork failed");
+ } else if (server->_priv->pid == 0) {
+ close (0); close (1);
+ close (server->_priv->input [0]);
+ close (server->_priv->output [1]);
+ dup2 (server->_priv->input [1], 1);
+ dup2 (server->_priv->output [0], 0);
+ execl (LIBGTOP_SERVER, "libgtop-server", NULL);
+ glibtop_error_io_r (server, "execl (%s)",
+ LIBGTOP_SERVER);
+ _exit (2);
}
- /* If the server has been started, ask it for its features. */
+ close (server->_priv->input [1]);
+ close (server->_priv->output [0]);
+
+ server->flags |= _GLIBTOP_INIT_STATE_SERVER;
+
+ server->features = -1;
+ break;
+ }
+
+ /* If the server has been started, ask it for its features. */
- if (server->flags & _GLIBTOP_INIT_STATE_SERVER) {
- char version [BUFSIZ], buffer [BUFSIZ];
- glibtop_sysdeps sysdeps;
- size_t size, nbytes;
+ if (server->flags & _GLIBTOP_INIT_STATE_SERVER) {
+ char version [BUFSIZ], buffer [BUFSIZ];
+ glibtop_sysdeps sysdeps;
+ size_t size, nbytes;
- /* First check whether the server version is correct. */
+ /* First check whether the server version is correct. */
- sprintf (version, LIBGTOP_VERSION_STRING,
- LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
- sizeof (glibtop_command),
- sizeof (glibtop_response),
- sizeof (glibtop_union),
- sizeof (glibtop_sysdeps));
+ sprintf (version, LIBGTOP_VERSION_STRING,
+ LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
+ sizeof (glibtop_command),
+ sizeof (glibtop_response),
+ sizeof (glibtop_union),
+ sizeof (glibtop_sysdeps));
- size = strlen (version) + 1;
+ size = strlen (version) + 1;
- glibtop_read_l (server, sizeof (nbytes), &nbytes);
+ glibtop_read_l (server, sizeof (nbytes), &nbytes);
- if (nbytes != size)
- glibtop_error_r (server,
- "Requested %u bytes but got %u.",
- size, nbytes);
+ if (nbytes != size)
+ glibtop_error_r (server,
+ "Requested %u bytes but got %u.",
+ size, nbytes);
- glibtop_read_l (server, nbytes, buffer);
+ glibtop_read_l (server, nbytes, buffer);
- if (memcmp (version, buffer, size))
- glibtop_error_r (server, "server version is not %s",
- LIBGTOP_VERSION);
+ if (memcmp (version, buffer, size))
+ glibtop_error_r (server, "server version is not %s",
+ LIBGTOP_VERSION);
- /* Now ask it for its features. */
+ /* Now ask it for its features. */
- glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
- sizeof (glibtop_sysdeps), &sysdeps,
- NULL);
+ glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
+ sizeof (glibtop_sysdeps), &sysdeps,
+ NULL);
- server->features = sysdeps.features;
+ server->features = sysdeps.features;
- memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
+ memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps));
#ifdef DEBUG
- fprintf (stderr, "Server features are %lu.\n",
- server->features);
+ fprintf (stderr, "Server features are %lu.\n",
+ server->features);
#endif
- }
+ }
- /* In any case, we call the open functions of our own sysdeps
- * directory. */
+ /* In any case, we call the open functions of our own sysdeps
+ * directory. */
#ifdef DEBUG
- fprintf (stderr, "Calling sysdeps open function.\n");
+ fprintf (stderr, "Calling sysdeps open function.\n");
#endif
- glibtop_init_s (&server, features, flags);
+ glibtop_init_s (&server, features, flags);
}
diff --git a/lib/parameter.c b/lib/parameter.c
index bd3731b7..8da5d31a 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -46,113 +48,113 @@ ssize_t
glibtop_get_parameter_l (glibtop *server, const unsigned parameter,
void *data_ptr, size_t data_size)
{
- switch (parameter) {
- case GLIBTOP_PARAM_METHOD:
- _write_data (&server->method,
- sizeof (server->method));
- case GLIBTOP_PARAM_FEATURES:
- _write_data (&server->features,
- sizeof (server->features));
- case GLIBTOP_PARAM_COMMAND:
- _write_data (server->server_command,
- _strlen(server->server_command));
- case GLIBTOP_PARAM_HOST:
- _write_data (server->server_host,
- _strlen(server->server_host));
- case GLIBTOP_PARAM_PORT:
- _write_data (&server->server_port,
- sizeof (server->server_port));
- case GLIBTOP_PARAM_REMOTE_USER:
- _write_data (server->server_user,
- _strlen(server->server_user));
- case GLIBTOP_PARAM_PATH_RSH:
- _write_data (server->server_rsh,
- _strlen(server->server_rsh));
- case GLIBTOP_PARAM_ERROR_METHOD:
- _write_data (&server->error_method,
- sizeof (server->error_method));
- case GLIBTOP_PARAM_REQUIRED:
- _write_data (&server->required,
- sizeof (server->required));
- }
+ switch (parameter) {
+ case GLIBTOP_PARAM_METHOD:
+ _write_data (&server->method,
+ sizeof (server->method));
+ case GLIBTOP_PARAM_FEATURES:
+ _write_data (&server->features,
+ sizeof (server->features));
+ case GLIBTOP_PARAM_COMMAND:
+ _write_data (server->server_command,
+ _strlen(server->server_command));
+ case GLIBTOP_PARAM_HOST:
+ _write_data (server->server_host,
+ _strlen(server->server_host));
+ case GLIBTOP_PARAM_PORT:
+ _write_data (&server->server_port,
+ sizeof (server->server_port));
+ case GLIBTOP_PARAM_REMOTE_USER:
+ _write_data (server->server_user,
+ _strlen(server->server_user));
+ case GLIBTOP_PARAM_PATH_RSH:
+ _write_data (server->server_rsh,
+ _strlen(server->server_rsh));
+ case GLIBTOP_PARAM_ERROR_METHOD:
+ _write_data (&server->error_method,
+ sizeof (server->error_method));
+ case GLIBTOP_PARAM_REQUIRED:
+ _write_data (&server->required,
+ sizeof (server->required));
+ }
- return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
+ return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
}
int
glibtop_get_parameter_size_l (glibtop *server, const unsigned parameter)
{
- switch (parameter) {
- case GLIBTOP_PARAM_METHOD:
- return sizeof (server->method);
- case GLIBTOP_PARAM_FEATURES:
- return sizeof (server->features);
- case GLIBTOP_PARAM_COMMAND:
- return _strlen(server->server_command);
- case GLIBTOP_PARAM_HOST:
- return _strlen(server->server_host);
- case GLIBTOP_PARAM_PORT:
- return sizeof (server->server_port);
- case GLIBTOP_PARAM_REMOTE_USER:
- return _strlen(server->server_user);
- case GLIBTOP_PARAM_PATH_RSH:
- return _strlen(server->server_rsh);
- case GLIBTOP_PARAM_ERROR_METHOD:
- return sizeof (server->error_method);
- case GLIBTOP_PARAM_REQUIRED:
- return sizeof (server->required);
- }
+ switch (parameter) {
+ case GLIBTOP_PARAM_METHOD:
+ return sizeof (server->method);
+ case GLIBTOP_PARAM_FEATURES:
+ return sizeof (server->features);
+ case GLIBTOP_PARAM_COMMAND:
+ return _strlen(server->server_command);
+ case GLIBTOP_PARAM_HOST:
+ return _strlen(server->server_host);
+ case GLIBTOP_PARAM_PORT:
+ return sizeof (server->server_port);
+ case GLIBTOP_PARAM_REMOTE_USER:
+ return _strlen(server->server_user);
+ case GLIBTOP_PARAM_PATH_RSH:
+ return _strlen(server->server_rsh);
+ case GLIBTOP_PARAM_ERROR_METHOD:
+ return sizeof (server->error_method);
+ case GLIBTOP_PARAM_REQUIRED:
+ return sizeof (server->required);
+ }
- return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
+ return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
}
int
glibtop_set_parameter_l (glibtop *server, const unsigned parameter,
const void *data_ptr, size_t data_size)
{
- switch (parameter) {
- case GLIBTOP_PARAM_METHOD:
- _check_data (sizeof (server->method));
- memcpy (&server->method, data_ptr, data_size);
- break;
- case GLIBTOP_PARAM_FEATURES:
- return -GLIBTOP_ERROR_READONLY_VALUE;
- break;
- case GLIBTOP_PARAM_COMMAND:
- if (server->server_command)
- glibtop_free_r (server, server->server_command);
- server->server_command = glibtop_strdup_r (server, data_ptr);
- break;
- case GLIBTOP_PARAM_HOST:
- if (server->server_host)
- glibtop_free_r (server, server->server_host);
- server->server_host = glibtop_strdup_r (server, data_ptr);
- break;
- case GLIBTOP_PARAM_PORT:
- _check_data (sizeof (server->server_port));
- memcpy (&server->server_port, data_ptr, data_size);
- break;
- case GLIBTOP_PARAM_REMOTE_USER:
- if (server->server_user)
- glibtop_free_r (server, server->server_user);
- server->server_user = glibtop_strdup_r (server, data_ptr);
- break;
- case GLIBTOP_PARAM_PATH_RSH:
- if (server->server_rsh)
- glibtop_free_r (server, server->server_rsh);
- server->server_rsh = glibtop_strdup_r (server, data_ptr);
- break;
- case GLIBTOP_PARAM_ERROR_METHOD:
- _check_data (sizeof (server->error_method));
- memcpy (&server->error_method, data_ptr, data_size);
- break;
- case GLIBTOP_PARAM_REQUIRED:
- _check_data (sizeof (server->required));
- memcpy (&server->required, data_ptr, data_size);
- break;
- default:
- return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
- }
+ switch (parameter) {
+ case GLIBTOP_PARAM_METHOD:
+ _check_data (sizeof (server->method));
+ memcpy (&server->method, data_ptr, data_size);
+ break;
+ case GLIBTOP_PARAM_FEATURES:
+ return -GLIBTOP_ERROR_READONLY_VALUE;
+ break;
+ case GLIBTOP_PARAM_COMMAND:
+ if (server->server_command)
+ glibtop_free_r (server, server->server_command);
+ server->server_command = glibtop_strdup_r (server, data_ptr);
+ break;
+ case GLIBTOP_PARAM_HOST:
+ if (server->server_host)
+ glibtop_free_r (server, server->server_host);
+ server->server_host = glibtop_strdup_r (server, data_ptr);
+ break;
+ case GLIBTOP_PARAM_PORT:
+ _check_data (sizeof (server->server_port));
+ memcpy (&server->server_port, data_ptr, data_size);
+ break;
+ case GLIBTOP_PARAM_REMOTE_USER:
+ if (server->server_user)
+ glibtop_free_r (server, server->server_user);
+ server->server_user = glibtop_strdup_r (server, data_ptr);
+ break;
+ case GLIBTOP_PARAM_PATH_RSH:
+ if (server->server_rsh)
+ glibtop_free_r (server, server->server_rsh);
+ server->server_rsh = glibtop_strdup_r (server, data_ptr);
+ break;
+ case GLIBTOP_PARAM_ERROR_METHOD:
+ _check_data (sizeof (server->error_method));
+ memcpy (&server->error_method, data_ptr, data_size);
+ break;
+ case GLIBTOP_PARAM_REQUIRED:
+ _check_data (sizeof (server->required));
+ memcpy (&server->required, data_ptr, data_size);
+ break;
+ default:
+ return -GLIBTOP_ERROR_NO_SUCH_PARAMETER;
+ }
- return 0;
+ return 0;
}
diff --git a/lib/read.c b/lib/read.c
index 6e0a0094..722f2766 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,49 +30,49 @@
static void
do_read (int s, void *ptr, size_t total_size)
{
- int nread;
- size_t already_read = 0, remaining = total_size;
- char *tmp_ptr;
+ int nread;
+ size_t already_read = 0, remaining = total_size;
+ char *tmp_ptr;
- while (already_read < total_size) {
- nread = recv (s, ptr, remaining, 0);
+ while (already_read < total_size) {
+ nread = recv (s, ptr, remaining, 0);
- if (nread == 0) {
- close (s);
- continue;
- }
-
- if (nread <= 0) {
- glibtop_error_io ("recv");
- return;
- }
+ if (nread == 0) {
+ close (s);
+ continue;
+ }
- already_read += nread;
- remaining -= nread;
- /* (char *) ptr += nread; */
- tmp_ptr = ptr;
- tmp_ptr += nread;
- ptr = tmp_ptr;
+ if (nread <= 0) {
+ glibtop_error_io ("recv");
+ return;
}
+
+ already_read += nread;
+ remaining -= nread;
+ /* (char *) ptr += nread; */
+ tmp_ptr = ptr;
+ tmp_ptr += nread;
+ ptr = tmp_ptr;
+ }
}
void
glibtop_read_l (glibtop *server, size_t size, void *buf)
{
- int ret = 0;
+ int ret = 0;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
#ifdef DEBUG
- fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
+ fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
#endif
- if (server->_priv->socket) {
- do_read (server->_priv->socket, buf, size);
- } else {
- ret = read (server->_priv->input [0], buf, size);
- }
+ if (server->_priv->socket) {
+ do_read (server->_priv->socket, buf, size);
+ } else {
+ ret = read (server->_priv->input [0], buf, size);
+ }
- if (ret < 0)
- glibtop_error_io_r (server, _("read %d bytes"), size);
+ if (ret < 0)
+ glibtop_error_io_r (server, _("read %d bytes"), size);
}
diff --git a/lib/read_data.c b/lib/read_data.c
index 57e87729..cc9d6f99 100644
--- a/lib/read_data.c
+++ b/lib/read_data.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -29,43 +31,43 @@
void *
glibtop_read_data_l (glibtop *server)
{
- size_t size;
- void *ptr;
- int ret;
+ size_t size;
+ void *ptr;
+ int ret;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
#ifdef DEBUG
- fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
+ fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
#endif
- if (server->_priv->socket) {
- ret = recv (server->_priv->socket, (void *)&size,
- sizeof (size_t), 0);
- } else {
- ret = read (server->_priv->input [0], (void *)&size,
- sizeof (size_t));
- }
+ if (server->_priv->socket) {
+ ret = recv (server->_priv->socket, (void *)&size,
+ sizeof (size_t), 0);
+ } else {
+ ret = read (server->_priv->input [0], (void *)&size,
+ sizeof (size_t));
+ }
- if (ret < 0)
- glibtop_error_io_r (server, _("read data size"));
+ if (ret < 0)
+ glibtop_error_io_r (server, _("read data size"));
#ifdef DEBUG
- fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
+ fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
#endif
- if (!size) return NULL;
+ if (!size) return NULL;
- ptr = glibtop_malloc_r (server, size);
+ ptr = glibtop_malloc_r (server, size);
- if (server->_priv->socket) {
- ret = recv (server->_priv->socket, ptr, size, 0);
- } else {
- ret = read (server->_priv->input [0], ptr, size);
- }
+ if (server->_priv->socket) {
+ ret = recv (server->_priv->socket, ptr, size, 0);
+ } else {
+ ret = read (server->_priv->input [0], ptr, size);
+ }
- if (ret < 0)
- glibtop_error_io_r (server, _("read data %d bytes"));
+ if (ret < 0)
+ glibtop_error_io_r (server, _("read data %d bytes"));
- return ptr;
+ return ptr;
}
diff --git a/lib/sysdeps.c b/lib/sysdeps.c
index 94ab190d..a7a37bc7 100644
--- a/lib/sysdeps.c
+++ b/lib/sysdeps.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* Copyright (C) 1998-99 Martin Baulig
This file is part of LibGTop 1.0.
@@ -47,66 +49,66 @@ GLIBTOP_SUID_PPP;
glibtop_init_func_t _glibtop_init_hook_s [] = {
#if !GLIBTOP_SUID_CPU
- glibtop_init_cpu_s,
+ glibtop_init_cpu_s,
#endif
#if !GLIBTOP_SUID_MEM
- glibtop_init_mem_s,
+ glibtop_init_mem_s,
#endif
#if !GLIBTOP_SUID_SWAP
- glibtop_init_swap_s,
+ glibtop_init_swap_s,
#endif
#if !GLIBTOP_SUID_UPTIME
- glibtop_init_uptime_s,
+ glibtop_init_uptime_s,
#endif
#if !GLIBTOP_SUID_LOADAVG
- glibtop_init_loadavg_s,
+ glibtop_init_loadavg_s,
#endif
#if !GLIBTOP_SUID_SHM_LIMITS
- glibtop_init_shm_limits_s,
+ glibtop_init_shm_limits_s,
#endif
#if !GLIBTOP_SUID_MSG_LIMITS
- glibtop_init_msg_limits_s,
+ glibtop_init_msg_limits_s,
#endif
#if !GLIBTOP_SUID_SEM_LIMITS
- glibtop_init_sem_limits_s,
+ glibtop_init_sem_limits_s,
#endif
#if !GLIBTOP_SUID_PROCLIST
- glibtop_init_proclist_s,
+ glibtop_init_proclist_s,
#endif
#if !GLIBTOP_SUID_PROC_STATE
- glibtop_init_proc_state_s,
+ glibtop_init_proc_state_s,
#endif
#if !GLIBTOP_SUID_PROC_UID
- glibtop_init_proc_uid_s,
+ glibtop_init_proc_uid_s,
#endif
#if !GLIBTOP_SUID_PROC_MEM
- glibtop_init_proc_mem_s,
+ glibtop_init_proc_mem_s,
#endif
#if !GLIBTOP_SUID_PROC_TIME
- glibtop_init_proc_time_s,
+ glibtop_init_proc_time_s,
#endif
#if !GLIBTOP_SUID_PROC_SIGNAL
- glibtop_init_proc_signal_s,
+ glibtop_init_proc_signal_s,
#endif
#if !GLIBTOP_SUID_PROC_KERNEL
- glibtop_init_proc_kernel_s,
+ glibtop_init_proc_kernel_s,
#endif
#if !GLIBTOP_SUID_PROC_SEGMENT
- glibtop_init_proc_segment_s,
+ glibtop_init_proc_segment_s,
#endif
#if !GLIBTOP_SUID_PROC_ARGS
- glibtop_init_proc_args_s,
+ glibtop_init_proc_args_s,
#endif
#if !GLIBTOP_SUID_PROC_MAP
- glibtop_init_proc_map_s,
+ glibtop_init_proc_map_s,
#endif
#if !GLIBTOP_SUID_NETLOAD
- glibtop_init_netload_s,
+ glibtop_init_netload_s,
#endif
#if !GLIBTOP_SUID_PPP
- glibtop_init_ppp_s,
+ glibtop_init_ppp_s,
#endif
- NULL
+ NULL
};
/* Checks which features are implemented. */
@@ -114,5 +116,5 @@ glibtop_init_func_t _glibtop_init_hook_s [] = {
void
glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf)
{
- memcpy (buf, &server->sysdeps, sizeof (glibtop_sysdeps));
+ memcpy (buf, &server->sysdeps, sizeof (glibtop_sysdeps));
}
diff --git a/lib/write.c b/lib/write.c
index faa6ce2a..3316555b 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,22 +30,22 @@
void
glibtop_write_l (glibtop *server, size_t size, void *buf)
{
- int ret;
+ int ret;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- if (size == 0) return;
+ if (size == 0) return;
#ifdef DEBUG
- fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
+ fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
#endif
- if (server->_priv->socket) {
- ret = send (server->_priv->socket, buf, size, 0);
- } else {
- ret = write (server->_priv->output [1], buf, size);
- }
+ if (server->_priv->socket) {
+ ret = send (server->_priv->socket, buf, size, 0);
+ } else {
+ ret = write (server->_priv->output [1], buf, size);
+ }
- if (ret < 0)
- glibtop_error_io_r (server, _("write %d bytes"), size);
+ if (ret < 0)
+ glibtop_error_io_r (server, _("write %d bytes"), size);
}
diff --git a/misc/README.indent b/misc/README.indent
new file mode 100644
index 00000000..012bf8a1
--- /dev/null
+++ b/misc/README.indent
@@ -0,0 +1,8 @@
+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
+
diff --git a/misc/format.el b/misc/format.el
new file mode 100644
index 00000000..c0901142
--- /dev/null
+++ b/misc/format.el
@@ -0,0 +1,5 @@
+(setq c-basic-offset 4)
+(if (not (word-search-forward "Mode: C" nil t))
+ (insert-string "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */\n\n"))
+(mark-whole-buffer)
+(indent-region (region-beginning) (region-end) nil)
diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h
index 597f0055..6c8ffb7c 100644
--- a/src/daemon/daemon.h
+++ b/src/daemon/daemon.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c
index 551d2219..1fc498ea 100644
--- a/src/daemon/gnuserv.c
+++ b/src/daemon/gnuserv.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* -*-C-*-
* Server code for handling requests from clients and forwarding them
* on to the GNU Emacs process.
diff --git a/src/daemon/io.c b/src/daemon/io.c
index 1d6c56e0..9c51de27 100644
--- a/src/daemon/io.c
+++ b/src/daemon/io.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,80 +30,80 @@ do_output (int s, glibtop_response *resp, off_t offset,
size_t data_size, const void *data, int retval)
{
#ifdef REAL_DEBUG
- fprintf (stderr, "Really writing %d bytes at offset %lu.\n",
- sizeof (glibtop_response), offset);
+ fprintf (stderr, "Really writing %d bytes at offset %lu.\n",
+ sizeof (glibtop_response), offset);
#endif
- resp->offset = offset;
- resp->data_size = data_size;
+ resp->offset = offset;
+ resp->data_size = data_size;
- if (s == 0) {
- if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0)
- glibtop_warn_io ("write");
- } else {
- if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0)
- glibtop_warn_io ("send");
- }
+ if (s == 0) {
+ if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0)
+ glibtop_warn_io ("write");
+ } else {
+ if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0)
+ glibtop_warn_io ("send");
+ }
- if (s == 0) {
- if (write (1, &retval, sizeof (int)) < 0)
- glibtop_warn_io ("write retval");
- } else {
- if (send (s, &retval, sizeof (int), 0) < 0)
- glibtop_warn_io ("send retval");
- }
+ if (s == 0) {
+ if (write (1, &retval, sizeof (int)) < 0)
+ glibtop_warn_io ("write retval");
+ } else {
+ if (send (s, &retval, sizeof (int), 0) < 0)
+ glibtop_warn_io ("send retval");
+ }
- if (resp->data_size) {
+ if (resp->data_size) {
#ifdef REAL_DEBUG
- fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
+ fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
#endif
- if (s == 0) {
- if (write (1, data, resp->data_size) < 0)
- glibtop_warn_io ("write");
- } else {
- if (send (s, data, resp->data_size, 0) < 0)
- glibtop_warn_io ("send");
- }
+ if (s == 0) {
+ if (write (1, data, resp->data_size) < 0)
+ glibtop_warn_io ("write");
+ } else {
+ if (send (s, data, resp->data_size, 0) < 0)
+ glibtop_warn_io ("send");
}
+ }
}
int
do_read (int s, void *ptr, size_t total_size)
{
- int nread;
- char *tmp_ptr;
- size_t already_read = 0, remaining = total_size;
-
- while (already_read < total_size) {
- if (s)
- nread = recv (s, ptr, remaining, 0);
- else
- nread = read (0, ptr, remaining);
-
- if ((already_read == 0) && (nread == 0)) {
- glibtop_warn ("pid %d received eof.", getpid ());
- return 0;
- }
-
- if (nread <= 0) {
- glibtop_warn_io ("recv");
- return 0;
- }
-
- already_read += nread;
- remaining -= nread;
- /* (char *) ptr += nread; */
- tmp_ptr = ptr;
- tmp_ptr += nread;
- ptr = tmp_ptr;
+ int nread;
+ char *tmp_ptr;
+ size_t already_read = 0, remaining = total_size;
+
+ while (already_read < total_size) {
+ if (s)
+ nread = recv (s, ptr, remaining, 0);
+ else
+ nread = read (0, ptr, remaining);
+
+ if ((already_read == 0) && (nread == 0)) {
+ glibtop_warn ("pid %d received eof.", getpid ());
+ return 0;
+ }
+
+ if (nread <= 0) {
+ glibtop_warn_io ("recv");
+ return 0;
+ }
+
+ already_read += nread;
+ remaining -= nread;
+ /* (char *) ptr += nread; */
+ tmp_ptr = ptr;
+ tmp_ptr += nread;
+ ptr = tmp_ptr;
#ifdef REAL_DEBUG
- fprintf (stderr, "READ (%d): %d - %d - %d\n",
- nread, already_read, remaining, total_size);
+ fprintf (stderr, "READ (%d): %d - %d - %d\n",
+ nread, already_read, remaining, total_size);
#endif
- }
+ }
- return already_read;
+ return already_read;
}
diff --git a/src/daemon/main.c b/src/daemon/main.c
index c5f392a4..6fa2e7c9 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/src/daemon/server.c b/src/daemon/server.c
index 0ca46669..825e260b 100644
--- a/src/daemon/server.c
+++ b/src/daemon/server.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -62,35 +64,35 @@ GLIBTOP_SUID_PPP;
int
main(int argc, char *argv[])
{
- struct utsname uts;
- int uid, euid, gid, egid;
+ struct utsname uts;
+ int uid, euid, gid, egid;
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- uid = getuid (); euid = geteuid ();
- gid = getgid (); egid = getegid ();
+ uid = getuid (); euid = geteuid ();
+ gid = getgid (); egid = getegid ();
- if (uname (&uts) < 0) _exit (1);
+ if (uname (&uts) < 0) _exit (1);
- if (strcmp (uts.sysname, LIBGTOP_COMPILE_SYSTEM) ||
- strcmp (uts.release, LIBGTOP_COMPILE_RELEASE) ||
- strcmp (uts.machine, LIBGTOP_COMPILE_MACHINE)) {
- fprintf (stderr, "Can only run on %s %s %s\n",
- LIBGTOP_COMPILE_SYSTEM,
- LIBGTOP_COMPILE_RELEASE,
- LIBGTOP_COMPILE_MACHINE);
- _exit (1);
- }
+ if (strcmp (uts.sysname, LIBGTOP_COMPILE_SYSTEM) ||
+ strcmp (uts.release, LIBGTOP_COMPILE_RELEASE) ||
+ strcmp (uts.machine, LIBGTOP_COMPILE_MACHINE)) {
+ fprintf (stderr, "Can only run on %s %s %s\n",
+ LIBGTOP_COMPILE_SYSTEM,
+ LIBGTOP_COMPILE_RELEASE,
+ LIBGTOP_COMPILE_MACHINE);
+ _exit (1);
+ }
- glibtop_init_p (glibtop_global_server, 0, 0);
+ glibtop_init_p (glibtop_global_server, 0, 0);
- if (setreuid (euid, uid)) _exit (1);
+ if (setreuid (euid, uid)) _exit (1);
- if (setregid (egid, gid)) _exit (1);
+ if (setregid (egid, gid)) _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- handle_slave_connection (0, 0);
+ handle_slave_connection (0, 0);
- _exit (0);
+ _exit (0);
}
diff --git a/src/daemon/slave.c b/src/daemon/slave.c
index 9b471b7c..3f90f6f5 100644
--- a/src/daemon/slave.c
+++ b/src/daemon/slave.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -26,269 +28,269 @@
void
handle_slave_connection (int input, int output)
{
- glibtop *server G_GNUC_UNUSED = glibtop_global_server;
- int64_t *param_ptr G_GNUC_UNUSED;
- const void *ptr G_GNUC_UNUSED;
- int ret G_GNUC_UNUSED = -1;
+ glibtop *server G_GNUC_UNUSED = glibtop_global_server;
+ int64_t *param_ptr G_GNUC_UNUSED;
+ const void *ptr G_GNUC_UNUSED;
+ int ret G_GNUC_UNUSED = -1;
- u_int64_t interface G_GNUC_UNUSED;
- u_int64_t number G_GNUC_UNUSED;
- u_int64_t instance G_GNUC_UNUSED;
- u_int64_t strategy G_GNUC_UNUSED;
- u_int64_t transport G_GNUC_UNUSED;
- u_int64_t protocol G_GNUC_UNUSED;
+ u_int64_t interface G_GNUC_UNUSED;
+ u_int64_t number G_GNUC_UNUSED;
+ u_int64_t instance G_GNUC_UNUSED;
+ u_int64_t strategy G_GNUC_UNUSED;
+ u_int64_t transport G_GNUC_UNUSED;
+ u_int64_t protocol G_GNUC_UNUSED;
- unsigned short max_len G_GNUC_UNUSED;
- pid_t pid G_GNUC_UNUSED;
+ unsigned short max_len G_GNUC_UNUSED;
+ pid_t pid G_GNUC_UNUSED;
- glibtop_response _resp, *resp = &_resp;
- glibtop_command _cmnd, *cmnd = &_cmnd;
- char parameter [BUFSIZ];
+ glibtop_response _resp, *resp = &_resp;
+ glibtop_command _cmnd, *cmnd = &_cmnd;
+ char parameter [BUFSIZ];
- glibtop_send_version (glibtop_global_server, output);
+ glibtop_send_version (glibtop_global_server, output);
- while (do_read (input, cmnd, sizeof (glibtop_command))) {
+ while (do_read (input, cmnd, sizeof (glibtop_command))) {
#ifdef SLAVE_DEBUG
- fprintf (stderr, "Slave %d received command "
- "%d from client.\n", getpid (), cmnd->command);
+ fprintf (stderr, "Slave %d received command "
+ "%d from client.\n", getpid (), cmnd->command);
#endif
- if (cmnd->data_size >= BUFSIZ)
- glibtop_error ("Client sent %d bytes, "
- "but buffer is %d",
- cmnd->size, BUFSIZ);
+ if (cmnd->data_size >= BUFSIZ)
+ glibtop_error ("Client sent %d bytes, "
+ "but buffer is %d",
+ cmnd->size, BUFSIZ);
- memset (resp, 0, sizeof (glibtop_response));
+ memset (resp, 0, sizeof (glibtop_response));
- memset (parameter, 0, sizeof (parameter));
+ memset (parameter, 0, sizeof (parameter));
- if (cmnd->data_size) {
+ if (cmnd->data_size) {
#ifdef SLAVE_DEBUG
- fprintf (stderr, "Client has %d bytes of data.\n",
- cmnd->data_size);
+ fprintf (stderr, "Client has %d bytes of data.\n",
+ cmnd->data_size);
#endif
- do_read (input, parameter, cmnd->data_size);
+ do_read (input, parameter, cmnd->data_size);
- } else if (cmnd->size) {
- memcpy (parameter, cmnd->parameter, cmnd->size);
- }
+ } else if (cmnd->size) {
+ memcpy (parameter, cmnd->parameter, cmnd->size);
+ }
- switch (cmnd->command) {
- case GLIBTOP_CMND_QUIT:
- do_output (output, resp, 0, 0, NULL, 0);
- return;
+ switch (cmnd->command) {
+ case GLIBTOP_CMND_QUIT:
+ do_output (output, resp, 0, 0, NULL, 0);
+ return;
#if GLIBTOP_SUID_PROCLIST
- case GLIBTOP_CMND_PROCLIST:
- param_ptr = (int64_t *) parameter;
- ptr = glibtop_get_proclist_p
- (server, &resp->u.data.proclist,
- param_ptr [0], param_ptr [1]);
- do_output (output, resp, _offset_data (proclist),
- resp->u.data.proclist.total,
- ptr, (ptr != NULL) ? 0 : -1);
- glibtop_free_r (server, ptr);
- break;
+ case GLIBTOP_CMND_PROCLIST:
+ param_ptr = (int64_t *) parameter;
+ ptr = glibtop_get_proclist_p
+ (server, &resp->u.data.proclist,
+ param_ptr [0], param_ptr [1]);
+ do_output (output, resp, _offset_data (proclist),
+ resp->u.data.proclist.total,
+ ptr, (ptr != NULL) ? 0 : -1);
+ glibtop_free_r (server, ptr);
+ break;
#endif
#if GLIBTOP_SUID_PROC_ARGS
- case GLIBTOP_CMND_PROC_ARGS:
- memcpy (&pid, parameter, sizeof (pid_t));
- memcpy (&max_len, parameter + sizeof (pid_t),
- sizeof (max_len));
- ptr = glibtop_get_proc_args_p (server,
- &resp->u.data.proc_args,
- pid);
- do_output (output, resp, _offset_data (proc_args),
- ptr ? resp->u.data.proc_args.size+1 : 0,
- ptr, (ptr != NULL) ? 0 : -1);
- glibtop_free_r (server, ptr);
- break;
+ case GLIBTOP_CMND_PROC_ARGS:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ memcpy (&max_len, parameter + sizeof (pid_t),
+ sizeof (max_len));
+ ptr = glibtop_get_proc_args_p (server,
+ &resp->u.data.proc_args,
+ pid);
+ do_output (output, resp, _offset_data (proc_args),
+ ptr ? resp->u.data.proc_args.size+1 : 0,
+ ptr, (ptr != NULL) ? 0 : -1);
+ glibtop_free_r (server, ptr);
+ break;
#endif
#if GLIBTOP_SUID_PROC_MAP
- case GLIBTOP_CMND_PROC_MAP:
- memcpy (&pid, parameter, sizeof (pid_t));
- ptr = glibtop_get_proc_map_p (server,
- &resp->u.data.proc_map,
- pid);
- do_output (output, resp, _offset_data (proc_map),
- resp->u.data.proc_map.total,
- ptr, (ptr != NULL) ? 0 : -1);
- glibtop_free_r (server, ptr);
- break;
+ case GLIBTOP_CMND_PROC_MAP:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ ptr = glibtop_get_proc_map_p (server,
+ &resp->u.data.proc_map,
+ pid);
+ do_output (output, resp, _offset_data (proc_map),
+ resp->u.data.proc_map.total,
+ ptr, (ptr != NULL) ? 0 : -1);
+ glibtop_free_r (server, ptr);
+ break;
#endif
#if GLIBTOP_SUID_INTERFACE_NAMES
- case GLIBTOP_CMND_INTERFACE_NAMES:
- memcpy (&interface, parameter, sizeof (u_int64_t));
- memcpy (&number, parameter + sizeof (u_int64_t),
- sizeof (u_int64_t));
- memcpy (&instance, parameter + 2 * sizeof (u_int64_t),
- sizeof (u_int64_t));
- memcpy (&strategy, parameter + 3 * sizeof (u_int64_t),
- sizeof (u_int64_t));
- ptr = glibtop_get_interface_names_p
- (server, &resp->u.data.interface_names,
- interface, number, instance, strategy);
- do_output (output, resp, _offset_data (interface_names),
- ptr ? resp->u.data.interface_names.size+1 : 0,
- ptr, (ptr != NULL) ? 0 : -1);
- glibtop_free_r (server, ptr);
- break;
+ case GLIBTOP_CMND_INTERFACE_NAMES:
+ memcpy (&interface, parameter, sizeof (u_int64_t));
+ memcpy (&number, parameter + sizeof (u_int64_t),
+ sizeof (u_int64_t));
+ memcpy (&instance, parameter + 2 * sizeof (u_int64_t),
+ sizeof (u_int64_t));
+ memcpy (&strategy, parameter + 3 * sizeof (u_int64_t),
+ sizeof (u_int64_t));
+ ptr = glibtop_get_interface_names_p
+ (server, &resp->u.data.interface_names,
+ interface, number, instance, strategy);
+ do_output (output, resp, _offset_data (interface_names),
+ ptr ? resp->u.data.interface_names.size+1 : 0,
+ ptr, (ptr != NULL) ? 0 : -1);
+ glibtop_free_r (server, ptr);
+ break;
#endif
- default:
- ret = handle_slave_command (cmnd, resp, parameter);
- do_output (output, resp, resp->offset, 0, NULL, ret);
- break;
- }
+ default:
+ ret = handle_slave_command (cmnd, resp, parameter);
+ do_output (output, resp, resp->offset, 0, NULL, ret);
+ break;
}
+ }
}
int
handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
const void *parameter)
{
- glibtop *server = glibtop_global_server;
- unsigned device G_GNUC_UNUSED;
- pid_t pid G_GNUC_UNUSED;
- int retval G_GNUC_UNUSED = -1;
+ glibtop *server = glibtop_global_server;
+ unsigned device G_GNUC_UNUSED;
+ pid_t pid G_GNUC_UNUSED;
+ int retval G_GNUC_UNUSED = -1;
- switch (cmnd->command) {
- case GLIBTOP_CMND_SYSDEPS:
- memcpy (&resp->u.sysdeps, &server->sysdeps,
- sizeof (glibtop_sysdeps));
- resp->u.sysdeps.features = glibtop_server_features;
- resp->u.sysdeps.pointer_size = sizeof (void*)*8;
- resp->u.sysdeps.flags = glibtop_server_features;
- resp->offset = _offset_union (sysdeps);
- retval = 0;
- break;
+ switch (cmnd->command) {
+ case GLIBTOP_CMND_SYSDEPS:
+ memcpy (&resp->u.sysdeps, &server->sysdeps,
+ sizeof (glibtop_sysdeps));
+ resp->u.sysdeps.features = glibtop_server_features;
+ resp->u.sysdeps.pointer_size = sizeof (void*)*8;
+ resp->u.sysdeps.flags = glibtop_server_features;
+ resp->offset = _offset_union (sysdeps);
+ retval = 0;
+ break;
#if GLIBTOP_SUID_CPU
- case GLIBTOP_CMND_CPU:
- retval = glibtop_get_cpu_p (server, &resp->u.data.cpu);
- resp->offset = _offset_data (cpu);
- break;
+ case GLIBTOP_CMND_CPU:
+ retval = glibtop_get_cpu_p (server, &resp->u.data.cpu);
+ resp->offset = _offset_data (cpu);
+ break;
#endif
#if GLIBTOP_SUID_MEM
- case GLIBTOP_CMND_MEM:
- retval = glibtop_get_mem_p (server, &resp->u.data.mem);
- resp->offset = _offset_data (mem);
- break;
+ case GLIBTOP_CMND_MEM:
+ retval = glibtop_get_mem_p (server, &resp->u.data.mem);
+ resp->offset = _offset_data (mem);
+ break;
#endif
#if GLIBTOP_SUID_SWAP
- case GLIBTOP_CMND_SWAP:
- retval = glibtop_get_swap_p (server, &resp->u.data.swap);
- resp->offset = _offset_data (swap);
- break;
+ case GLIBTOP_CMND_SWAP:
+ retval = glibtop_get_swap_p (server, &resp->u.data.swap);
+ resp->offset = _offset_data (swap);
+ break;
#endif
#if GLIBTOP_SUID_UPTIME
- case GLIBTOP_CMND_UPTIME:
- retval = glibtop_get_uptime_p (server, &resp->u.data.uptime);
- resp->offset = _offset_data (uptime);
- break;
+ case GLIBTOP_CMND_UPTIME:
+ retval = glibtop_get_uptime_p (server, &resp->u.data.uptime);
+ resp->offset = _offset_data (uptime);
+ break;
#endif
#if GLIBTOP_SUID_LOADAVG
- case GLIBTOP_CMND_LOADAVG:
- retval = glibtop_get_loadavg_p (server, &resp->u.data.loadavg);
- resp->offset = _offset_data (loadavg);
- break;
+ case GLIBTOP_CMND_LOADAVG:
+ retval = glibtop_get_loadavg_p (server, &resp->u.data.loadavg);
+ resp->offset = _offset_data (loadavg);
+ break;
#endif
#if GLIBTOP_SUID_SHM_LIMITS
- case GLIBTOP_CMND_SHM_LIMITS:
- retval = glibtop_get_shm_limits_p (server, &resp->u.data.shm_limits);
- resp->offset = _offset_data (shm_limits);
- break;
+ case GLIBTOP_CMND_SHM_LIMITS:
+ retval = glibtop_get_shm_limits_p (server, &resp->u.data.shm_limits);
+ resp->offset = _offset_data (shm_limits);
+ break;
#endif
#if GLIBTOP_SUID_MSG_LIMITS
- case GLIBTOP_CMND_MSG_LIMITS:
- retval = glibtop_get_msg_limits_p (server, &resp->u.data.msg_limits);
- resp->offset = _offset_data (msg_limits);
- break;
+ case GLIBTOP_CMND_MSG_LIMITS:
+ retval = glibtop_get_msg_limits_p (server, &resp->u.data.msg_limits);
+ resp->offset = _offset_data (msg_limits);
+ break;
#endif
#if GLIBTOP_SUID_SEM_LIMITS
- case GLIBTOP_CMND_SEM_LIMITS:
- retval = glibtop_get_sem_limits_p (server, &resp->u.data.sem_limits);
- resp->offset = _offset_data (sem_limits);
- break;
+ case GLIBTOP_CMND_SEM_LIMITS:
+ retval = glibtop_get_sem_limits_p (server, &resp->u.data.sem_limits);
+ resp->offset = _offset_data (sem_limits);
+ break;
#endif
#if GLIBTOP_SUID_PROC_STATE
- case GLIBTOP_CMND_PROC_STATE:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_state_p
- (server, &resp->u.data.proc_state, pid);
- resp->offset = _offset_data (proc_state);
- break;
+ case GLIBTOP_CMND_PROC_STATE:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_state_p
+ (server, &resp->u.data.proc_state, pid);
+ resp->offset = _offset_data (proc_state);
+ break;
#endif
#if GLIBTOP_SUID_PROC_UID
- case GLIBTOP_CMND_PROC_UID:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_uid_p
- (server, &resp->u.data.proc_uid, pid);
- resp->offset = _offset_data (proc_uid);
- break;
+ case GLIBTOP_CMND_PROC_UID:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_uid_p
+ (server, &resp->u.data.proc_uid, pid);
+ resp->offset = _offset_data (proc_uid);
+ break;
#endif
#if GLIBTOP_SUID_PROC_MEM
- case GLIBTOP_CMND_PROC_MEM:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_mem_p
- (server, &resp->u.data.proc_mem, pid);
- resp->offset = _offset_data (proc_mem);
- break;
+ case GLIBTOP_CMND_PROC_MEM:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_mem_p
+ (server, &resp->u.data.proc_mem, pid);
+ resp->offset = _offset_data (proc_mem);
+ break;
#endif
#if GLIBTOP_SUID_PROC_TIME
- case GLIBTOP_CMND_PROC_TIME:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_time_p
- (server, &resp->u.data.proc_time, pid);
- resp->offset = _offset_data (proc_time);
- break;
+ case GLIBTOP_CMND_PROC_TIME:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_time_p
+ (server, &resp->u.data.proc_time, pid);
+ resp->offset = _offset_data (proc_time);
+ break;
#endif
#if GLIBTOP_SUID_PROC_SIGNAL
- case GLIBTOP_CMND_PROC_SIGNAL:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_signal_p
- (server, &resp->u.data.proc_signal, pid);
- resp->offset = _offset_data (proc_signal);
- break;
+ case GLIBTOP_CMND_PROC_SIGNAL:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_signal_p
+ (server, &resp->u.data.proc_signal, pid);
+ resp->offset = _offset_data (proc_signal);
+ break;
#endif
#if GLIBTOP_SUID_PROC_KERNEL
- case GLIBTOP_CMND_PROC_KERNEL:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_kernel_p
- (server, &resp->u.data.proc_kernel, pid);
- resp->offset = _offset_data (proc_kernel);
- break;
+ case GLIBTOP_CMND_PROC_KERNEL:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_kernel_p
+ (server, &resp->u.data.proc_kernel, pid);
+ resp->offset = _offset_data (proc_kernel);
+ break;
#endif
#if GLIBTOP_SUID_PROC_SEGMENT
- case GLIBTOP_CMND_PROC_SEGMENT:
- memcpy (&pid, parameter, sizeof (pid_t));
- retval = glibtop_get_proc_segment_p
- (server, &resp->u.data.proc_segment, pid);
- resp->offset = _offset_data (proc_segment);
- break;
+ case GLIBTOP_CMND_PROC_SEGMENT:
+ memcpy (&pid, parameter, sizeof (pid_t));
+ retval = glibtop_get_proc_segment_p
+ (server, &resp->u.data.proc_segment, pid);
+ resp->offset = _offset_data (proc_segment);
+ break;
#endif
#if GLIBTOP_SUID_NETINFO
- case GLIBTOP_CMND_NETINFO:
- retval = glibtop_get_netinfo_p (server, &resp->u.data.netinfo, parameter, 0);
- resp->offset = _offset_data (netload);
- break;
+ case GLIBTOP_CMND_NETINFO:
+ retval = glibtop_get_netinfo_p (server, &resp->u.data.netinfo, parameter, 0);
+ resp->offset = _offset_data (netload);
+ break;
#endif
#if GLIBTOP_SUID_NETLOAD
- case GLIBTOP_CMND_NETLOAD:
- retval = glibtop_get_netload_p (server, &resp->u.data.netload, parameter, 0, 0);
- resp->offset = _offset_data (netload);
- break;
+ case GLIBTOP_CMND_NETLOAD:
+ retval = glibtop_get_netload_p (server, &resp->u.data.netload, parameter, 0, 0);
+ resp->offset = _offset_data (netload);
+ break;
#endif
#if GLIBTOP_SUID_PPP
- case GLIBTOP_CMND_PPP:
- memcpy (&device, parameter, sizeof (unsigned short));
- retval = glibtop_get_ppp_p (server, &resp->u.data.ppp, device);
- resp->offset = _offset_data (ppp);
- break;
+ case GLIBTOP_CMND_PPP:
+ memcpy (&device, parameter, sizeof (unsigned short));
+ retval = glibtop_get_ppp_p (server, &resp->u.data.ppp, device);
+ resp->offset = _offset_data (ppp);
+ break;
#endif
- default:
- glibtop_error ("Child received unknown command %u",
- cmnd->command);
- break;
- }
+ default:
+ glibtop_error ("Child received unknown command %u",
+ cmnd->command);
+ break;
+ }
- return retval;
+ return retval;
}
diff --git a/src/daemon/version.c b/src/daemon/version.c
index d80d6412..73c9714d 100644
--- a/src/daemon/version.c
+++ b/src/daemon/version.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,35 +30,35 @@
void
glibtop_send_version (glibtop *server, int fd)
{
- char buffer [BUFSIZ];
- size_t size;
-
- sprintf (buffer, LIBGTOP_VERSION_STRING,
- LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
- sizeof (glibtop_command),
- sizeof (glibtop_response),
- sizeof (glibtop_union),
- sizeof (glibtop_sysdeps));
+ char buffer [BUFSIZ];
+ size_t size;
+
+ sprintf (buffer, LIBGTOP_VERSION_STRING,
+ LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
+ sizeof (glibtop_command),
+ sizeof (glibtop_response),
+ sizeof (glibtop_union),
+ sizeof (glibtop_sysdeps));
- size = strlen (buffer) + 1;
+ size = strlen (buffer) + 1;
#ifdef DEBUG
- fprintf (stderr, "SERVER ID: |%s|\n", buffer);
+ fprintf (stderr, "SERVER ID: |%s|\n", buffer);
#endif
- if (fd == 0) {
- if (write (1, (const void *) &size, sizeof (size)) < 0)
- glibtop_warn_io_r (server, "write");
- } else {
- if (send (fd, (const void *) &size, sizeof (size), 0) < 0)
- glibtop_warn_io_r (server, "send");
- }
-
- if (fd == 0) {
- if (write (1, (const void *) buffer, size) < 0)
- glibtop_warn_io_r (server, "write");
- } else {
- if (send (fd, (const void *) buffer, size, 0) < 0)
- glibtop_warn_io_r (server, "send");
- }
+ if (fd == 0) {
+ if (write (1, (const void *) &size, sizeof (size)) < 0)
+ glibtop_warn_io_r (server, "write");
+ } else {
+ if (send (fd, (const void *) &size, sizeof (size), 0) < 0)
+ glibtop_warn_io_r (server, "send");
+ }
+
+ if (fd == 0) {
+ if (write (1, (const void *) buffer, size) < 0)
+ glibtop_warn_io_r (server, "write");
+ } else {
+ if (send (fd, (const void *) buffer, size, 0) < 0)
+ glibtop_warn_io_r (server, "send");
+ }
}
diff --git a/src/inodedb/file_by_inode.c b/src/inodedb/file_by_inode.c
index 8e4370fe..5d87c7b1 100644
--- a/src/inodedb/file_by_inode.c
+++ b/src/inodedb/file_by_inode.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,33 +35,33 @@
int
main (int argc, const char *argv [])
{
- glibtop_inodedb *inodedb;
- const char *filename;
- unsigned device, inode;
+ glibtop_inodedb *inodedb;
+ const char *filename;
+ unsigned device, inode;
- if (argc != 3) {
- fprintf (stderr, "Usage: %s device inode\n", argv [0]);
- exit (1);
- }
+ if (argc != 3) {
+ fprintf (stderr, "Usage: %s device inode\n", argv [0]);
+ exit (1);
+ }
- if (sscanf (argv [1], "%d", &device) != 1) {
- fprintf (stderr, "Usage: %s device inode\n", argv [0]);
- exit (1);
- }
+ if (sscanf (argv [1], "%d", &device) != 1) {
+ fprintf (stderr, "Usage: %s device inode\n", argv [0]);
+ exit (1);
+ }
- if (sscanf (argv [2], "%d", &inode) != 1) {
- fprintf (stderr, "Usage: %s device inode\n", argv [0]);
- exit (1);
- }
+ if (sscanf (argv [2], "%d", &inode) != 1) {
+ fprintf (stderr, "Usage: %s device inode\n", argv [0]);
+ exit (1);
+ }
- inodedb = glibtop_inodedb_open (0, 0);
- if (!inodedb) exit (1);
+ inodedb = glibtop_inodedb_open (0, 0);
+ if (!inodedb) exit (1);
- filename = glibtop_inodedb_lookup (inodedb, device, inode);
- if (!filename) exit (2);
+ filename = glibtop_inodedb_lookup (inodedb, device, inode);
+ if (!filename) exit (2);
- fprintf (stderr, "FILENAME: %d - %d - '%s'\n",
- (int) device, (int) inode, filename);
+ fprintf (stderr, "FILENAME: %d - %d - '%s'\n",
+ (int) device, (int) inode, filename);
- exit (0);
+ exit (0);
}
diff --git a/src/inodedb/mkinodedb.c b/src/inodedb/mkinodedb.c
index a338d322..678b5ce7 100644
--- a/src/inodedb/mkinodedb.c
+++ b/src/inodedb/mkinodedb.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,103 +35,103 @@
int
main (int argc, char *argv [])
{
- GDBM_FILE dbf;
- char dirname [BUFSIZ];
- FILE *f;
-
- if (argc != 3) {
- fprintf (stderr, "Usage: %s database filename\n", argv [0]);
- exit (1);
- }
-
- f = fopen (argv [2], "rt");
- if (!f)
- glibtop_error_io ("fopen (%s)", argv [2]);
-
- dbf = gdbm_open (argv [1], 512, GDBM_WRCREAT, 0600, 0);
- if (!dbf)
- glibtop_error_io ("gdbm_open (%s)", argv [1]);
-
- while (fgets (dirname, BUFSIZ-1, f)) {
- struct dirent *entry;
- struct stat statb;
- DIR *directory;
- size_t len;
-
- len = strlen (dirname);
- if (!len) continue;
-
- if (dirname [len-1] == '\n')
- dirname [len-1] = 0;
+ GDBM_FILE dbf;
+ char dirname [BUFSIZ];
+ FILE *f;
+
+ if (argc != 3) {
+ fprintf (stderr, "Usage: %s database filename\n", argv [0]);
+ exit (1);
+ }
+
+ f = fopen (argv [2], "rt");
+ if (!f)
+ glibtop_error_io ("fopen (%s)", argv [2]);
+
+ dbf = gdbm_open (argv [1], 512, GDBM_WRCREAT, 0600, 0);
+ if (!dbf)
+ glibtop_error_io ("gdbm_open (%s)", argv [1]);
+
+ while (fgets (dirname, BUFSIZ-1, f)) {
+ struct dirent *entry;
+ struct stat statb;
+ DIR *directory;
+ size_t len;
+
+ len = strlen (dirname);
+ if (!len) continue;
+
+ if (dirname [len-1] == '\n')
+ dirname [len-1] = 0;
- if (stat (dirname, &statb))
- continue;
+ if (stat (dirname, &statb))
+ continue;
- if (S_ISREG (statb.st_mode)) {
- glibtop_inodedb_key key;
- datum d_key, d_content;
+ if (S_ISREG (statb.st_mode)) {
+ glibtop_inodedb_key key;
+ datum d_key, d_content;
- d_key.dptr = (void *) &key;
- d_key.dsize = sizeof (key);
+ d_key.dptr = (void *) &key;
+ d_key.dsize = sizeof (key);
- d_content.dptr = dirname;
- d_content.dsize = strlen (dirname) + 1;
+ d_content.dptr = dirname;
+ d_content.dsize = strlen (dirname) + 1;
- key.device = (u_int64_t) statb.st_dev;
- key.inode = (u_int64_t) statb.st_ino;
+ key.device = (u_int64_t) statb.st_dev;
+ key.inode = (u_int64_t) statb.st_ino;
- if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
- glibtop_error_io ("gdbm_store (%s)", dirname);
+ if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
+ glibtop_error_io ("gdbm_store (%s)", dirname);
- printf ("%-52s - %8lu - %8lu\n",
- dirname, (unsigned long) statb.st_dev,
- (unsigned long) statb.st_ino);
+ printf ("%-52s - %8lu - %8lu\n",
+ dirname, (unsigned long) statb.st_dev,
+ (unsigned long) statb.st_ino);
- continue;
- }
+ continue;
+ }
- if (!S_ISDIR (statb.st_mode))
- continue;
+ if (!S_ISDIR (statb.st_mode))
+ continue;
- directory = opendir (dirname);
- if (!directory) continue;
+ directory = opendir (dirname);
+ if (!directory) continue;
- while ((entry = readdir (directory))) {
- glibtop_inodedb_key key;
- char filename [BUFSIZ];
- datum d_key, d_content;
+ while ((entry = readdir (directory))) {
+ glibtop_inodedb_key key;
+ char filename [BUFSIZ];
+ datum d_key, d_content;
- sprintf (filename, "%s/%s", dirname, entry->d_name);
+ sprintf (filename, "%s/%s", dirname, entry->d_name);
- if (stat (filename, &statb))
- continue;
+ if (stat (filename, &statb))
+ continue;
- if (!S_ISREG (statb.st_mode))
- continue;
+ if (!S_ISREG (statb.st_mode))
+ continue;
- d_key.dptr = (void *) &key;
- d_key.dsize = sizeof (key);
+ d_key.dptr = (void *) &key;
+ d_key.dsize = sizeof (key);
- d_content.dptr = filename;
- d_content.dsize = strlen (filename) + 1;
+ d_content.dptr = filename;
+ d_content.dsize = strlen (filename) + 1;
- key.device = (u_int64_t) statb.st_dev;
- key.inode = (u_int64_t) statb.st_ino;
+ key.device = (u_int64_t) statb.st_dev;
+ key.inode = (u_int64_t) statb.st_ino;
- if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
- glibtop_error_io ("gdbm_store (%s)", filename);
+ if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
+ glibtop_error_io ("gdbm_store (%s)", filename);
- printf ("%-52s - %8lu - %8lu\n",
- filename, (unsigned long) statb.st_dev,
- (unsigned long) statb.st_ino);
- }
-
- closedir (directory);
+ printf ("%-52s - %8lu - %8lu\n",
+ filename, (unsigned long) statb.st_dev,
+ (unsigned long) statb.st_ino);
}
+
+ closedir (directory);
+ }
- gdbm_close (dbf);
+ gdbm_close (dbf);
- fclose (f);
+ fclose (f);
- exit (0);
+ exit (0);
}
diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c
index f334ec50..cf6719e8 100644
--- a/sysdeps/common/error.c
+++ b/sysdeps/common/error.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -30,59 +32,59 @@
static void
print_server_name (glibtop *server)
{
- fprintf (stderr, "%s: ", server ?
- (server->name ? server->name : DEFAULT_NAME)
- : DEFAULT_NAME);
+ fprintf (stderr, "%s: ", server ?
+ (server->name ? server->name : DEFAULT_NAME)
+ : DEFAULT_NAME);
}
void
glibtop_error_vr (glibtop *server, char *format, va_list args)
{
- print_server_name (server);
- vfprintf (stderr, format, args);
- fprintf (stderr, "\n");
+ print_server_name (server);
+ vfprintf (stderr, format, args);
+ fprintf (stderr, "\n");
#ifdef LIBGTOP_ENABLE_DEBUG
- abort ();
+ abort ();
#else
- exit (1);
+ exit (1);
#endif
}
void
glibtop_error_io_vr (glibtop *server, char *format, int error, va_list args)
{
- print_server_name (server);
- vfprintf (stderr, format, args);
- fprintf (stderr, ": %s\n", strerror (error));
+ print_server_name (server);
+ vfprintf (stderr, format, args);
+ fprintf (stderr, ": %s\n", strerror (error));
#ifdef LIBGTOP_ENABLE_DEBUG
- abort ();
+ abort ();
#else
- exit (1);
+ exit (1);
#endif
}
void
glibtop_warn_vr (glibtop *server, char *format, va_list args)
{
- print_server_name (server);
- vfprintf (stderr, format, args);
- fprintf (stderr, "\n");
+ print_server_name (server);
+ vfprintf (stderr, format, args);
+ fprintf (stderr, "\n");
#ifdef LIBGTOP_FATAL_WARNINGS
- abort ();
+ abort ();
#endif
}
void
glibtop_warn_io_vr (glibtop *server, char *format, int error, va_list args)
{
- print_server_name (server);
- vfprintf (stderr, format, args);
- fprintf (stderr, ": %s\n", strerror (error));
+ print_server_name (server);
+ vfprintf (stderr, format, args);
+ fprintf (stderr, ": %s\n", strerror (error));
#ifdef LIBGTOP_FATAL_WARNINGS
- abort ();
+ abort ();
#endif
}
diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c
index 58cffd38..516aae0f 100644
--- a/sysdeps/common/fsusage.c
+++ b/sysdeps/common/fsusage.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* fsusage.c -- return space usage of mounted filesystems
Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
@@ -85,17 +87,17 @@ adjust_blocks (blocks, fromsize, tosize)
long blocks;
int fromsize, tosize;
{
- if (tosize <= 0)
- abort ();
- if (fromsize <= 0)
- return -1;
-
- if (fromsize == tosize) /* e.g., from 512 to 512 */
- return blocks;
- else if (fromsize > tosize) /* e.g., from 2048 to 512 */
- return blocks * (fromsize / tosize);
- else /* e.g., from 256 to 512 */
- return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
+ if (tosize <= 0)
+ abort ();
+ if (fromsize <= 0)
+ return -1;
+
+ if (fromsize == tosize) /* e.g., from 512 to 512 */
+ return blocks;
+ else if (fromsize > tosize) /* e.g., from 2048 to 512 */
+ return blocks * (fromsize / tosize);
+ else /* e.g., from 256 to 512 */
+ return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
}
/* Fill in the fields of FSP with information about space usage for
@@ -114,25 +116,25 @@ get_fs_usage (path, disk, fsp)
#ifdef STAT_STATFS3_OSF1
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
- struct statfs fsd;
+ struct statfs fsd;
- if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
- return -1;
+ if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
+ return -1;
#endif /* STAT_STATFS3_OSF1 */
#ifdef STAT_STATFS2_FS_DATA /* Ultrix */
# define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512)
- struct fs_data fsd;
+ struct fs_data fsd;
- if (statfs (path, &fsd) != 1)
- return -1;
- fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot);
- fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree);
- fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen);
- fsp->fsu_files = fsd.fd_req.gtot;
- fsp->fsu_ffree = fsd.fd_req.gfree;
+ if (statfs (path, &fsd) != 1)
+ return -1;
+ fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot);
+ fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree);
+ fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen);
+ fsp->fsu_files = fsd.fd_req.gtot;
+ fsp->fsu_ffree = fsd.fd_req.gfree;
#endif /* STAT_STATFS2_FS_DATA */
@@ -143,54 +145,54 @@ get_fs_usage (path, disk, fsp)
# define CONVERT_BLOCKS(B) \
adjust_blocks ((B), (fsd.s_type == Fs2b ? 1024 : 512), 512)
- struct filsys fsd;
- int fd;
-
- if (! disk)
- {
- errno = 0;
- return -1;
- }
-
- fd = open (disk, O_RDONLY);
- if (fd < 0)
- return -1;
- lseek (fd, (long) SUPERBOFF, 0);
- if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
- {
- close (fd);
- return -1;
- }
- close (fd);
- fsp->fsu_blocks = CONVERT_BLOCKS (fsd.s_fsize);
- fsp->fsu_bfree = CONVERT_BLOCKS (fsd.s_tfree);
- fsp->fsu_bavail = CONVERT_BLOCKS (fsd.s_tfree);
- fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1);
- fsp->fsu_ffree = fsd.s_tinode;
+ struct filsys fsd;
+ int fd;
+
+ if (! disk)
+ {
+ errno = 0;
+ return -1;
+ }
+
+ fd = open (disk, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ lseek (fd, (long) SUPERBOFF, 0);
+ if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
+ {
+ close (fd);
+ return -1;
+ }
+ close (fd);
+ fsp->fsu_blocks = CONVERT_BLOCKS (fsd.s_fsize);
+ fsp->fsu_bfree = CONVERT_BLOCKS (fsd.s_tfree);
+ fsp->fsu_bavail = CONVERT_BLOCKS (fsd.s_tfree);
+ fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1);
+ fsp->fsu_ffree = fsd.s_tinode;
#endif /* STAT_READ_FILSYS */
#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512)
- struct statfs fsd;
+ struct statfs fsd;
- if (statfs (path, &fsd) < 0)
- return -1;
+ if (statfs (path, &fsd) < 0)
+ return -1;
# ifdef STATFS_TRUNCATES_BLOCK_COUNTS
- /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
- struct statfs are truncated to 2GB. These conditions detect that
- truncation, presumably without botching the 4.1.1 case, in which
- the values are not truncated. The correct counts are stored in
- undocumented spare fields. */
- if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0)
- {
- fsd.f_blocks = fsd.f_spare[0];
- fsd.f_bfree = fsd.f_spare[1];
- fsd.f_bavail = fsd.f_spare[2];
- }
+ /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the
+ struct statfs are truncated to 2GB. These conditions detect that
+ truncation, presumably without botching the 4.1.1 case, in which
+ the values are not truncated. The correct counts are stored in
+ undocumented spare fields. */
+ if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0)
+ {
+ fsd.f_blocks = fsd.f_spare[0];
+ fsd.f_bfree = fsd.f_spare[1];
+ fsd.f_bavail = fsd.f_spare[2];
+ }
# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
#endif /* STAT_STATFS2_BSIZE */
@@ -198,10 +200,10 @@ get_fs_usage (path, disk, fsp)
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
- struct statfs fsd;
+ struct statfs fsd;
- if (statfs (path, &fsd) < 0)
- return -1;
+ if (statfs (path, &fsd) < 0)
+ return -1;
#endif /* STAT_STATFS2_FSIZE */
@@ -220,13 +222,13 @@ get_fs_usage (path, disk, fsp)
# endif
# endif
- struct statfs fsd;
+ struct statfs fsd;
- if (statfs (path, &fsd, sizeof fsd, 0) < 0)
- return -1;
- /* Empirically, the block counts on most SVR3 and SVR3-derived
- systems seem to always be in terms of 512-byte blocks,
- no matter what value f_bsize has. */
+ if (statfs (path, &fsd, sizeof fsd, 0) < 0)
+ return -1;
+ /* Empirically, the block counts on most SVR3 and SVR3-derived
+ systems seem to always be in terms of 512-byte blocks,
+ no matter what value f_bsize has. */
#endif /* STAT_STATFS4 */
@@ -234,26 +236,26 @@ get_fs_usage (path, disk, fsp)
# define CONVERT_BLOCKS(B) \
adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
- struct statvfs fsd;
+ struct statvfs fsd;
- if (statvfs (path, &fsd) < 0)
- return -1;
- /* f_frsize isn't guaranteed to be supported. */
+ if (statvfs (path, &fsd) < 0)
+ return -1;
+ /* f_frsize isn't guaranteed to be supported. */
#endif /* STAT_STATVFS */
#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS)
/* !Ultrix && !SVR2 */
- fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks);
- fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree);
- fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail);
- fsp->fsu_files = fsd.f_files;
- fsp->fsu_ffree = fsd.f_ffree;
+ fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks);
+ fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree);
+ fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail);
+ fsp->fsu_files = fsd.f_files;
+ fsp->fsu_ffree = fsd.f_ffree;
#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */
- return 0;
+ return 0;
}
#if defined(_AIX) && defined(_I386)
@@ -264,23 +266,23 @@ statfs (path, fsb)
char *path;
struct statfs *fsb;
{
- struct stat stats;
- struct dustat fsd;
-
- if (stat (path, &stats))
- return -1;
- if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
- return -1;
- fsb->f_type = 0;
- fsb->f_bsize = fsd.du_bsize;
- fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
- fsb->f_bfree = fsd.du_tfree;
- fsb->f_bavail = fsd.du_tfree;
- fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
- fsb->f_ffree = fsd.du_tinode;
- fsb->f_fsid.val[0] = fsd.du_site;
- fsb->f_fsid.val[1] = fsd.du_pckno;
- return 0;
+ struct stat stats;
+ struct dustat fsd;
+
+ if (stat (path, &stats))
+ return -1;
+ if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
+ return -1;
+ fsb->f_type = 0;
+ fsb->f_bsize = fsd.du_bsize;
+ fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
+ fsb->f_bfree = fsd.du_tfree;
+ fsb->f_bavail = fsd.du_tfree;
+ fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
+ fsb->f_ffree = fsd.du_tinode;
+ fsb->f_fsid.val[0] = fsd.du_site;
+ fsb->f_fsid.val[1] = fsd.du_pckno;
+ return 0;
}
#endif /* _AIX && _I386 */
@@ -289,22 +291,22 @@ int
glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
const char *disk)
{
- struct fs_usage fsp;
+ struct fs_usage fsp;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_fsusage));
+ memset (buf, 0, sizeof (glibtop_fsusage));
- if (get_fs_usage (disk, disk, &fsp))
- return -1;
+ if (get_fs_usage (disk, disk, &fsp))
+ return -1;
- buf->blocks = fsp.fsu_blocks;
- buf->bfree = fsp.fsu_bfree;
- buf->bavail = fsp.fsu_bavail;
- buf->files = fsp.fsu_files;
- buf->ffree = fsp.fsu_ffree;
+ buf->blocks = fsp.fsu_blocks;
+ buf->bfree = fsp.fsu_bfree;
+ buf->bavail = fsp.fsu_bavail;
+ buf->files = fsp.fsu_files;
+ buf->ffree = fsp.fsu_ffree;
- buf->flags = _glibtop_sysdeps_fsusage;
+ buf->flags = _glibtop_sysdeps_fsusage;
- return 0;
+ return 0;
}
diff --git a/sysdeps/common/fsusage.h b/sysdeps/common/fsusage.h
index 0fb23efa..cc5c0ff6 100644
--- a/sysdeps/common/fsusage.h
+++ b/sysdeps/common/fsusage.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* fsusage.h -- declarations for filesystem space usage info
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
@@ -18,10 +20,10 @@
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
struct fs_usage
{
- long fsu_blocks; /* Total blocks. */
- long fsu_bfree; /* Free blocks available to superuser. */
- long fsu_bavail; /* Free blocks available to non-superuser. */
- long fsu_files; /* Total file nodes. */
- long fsu_ffree; /* Free file nodes. */
+ long fsu_blocks; /* Total blocks. */
+ long fsu_bfree; /* Free blocks available to superuser. */
+ long fsu_bavail; /* Free blocks available to non-superuser. */
+ long fsu_files; /* Total file nodes. */
+ long fsu_ffree; /* Free file nodes. */
};
diff --git a/sysdeps/common/inodedb.c b/sysdeps/common/inodedb.c
index d78d3905..2b0a4bf3 100644
--- a/sysdeps/common/inodedb.c
+++ b/sysdeps/common/inodedb.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -37,44 +39,44 @@ glibtop_inodedb *
glibtop_inodedb_open_s (glibtop *server, unsigned databases,
unsigned long cachesize)
{
- glibtop_inodedb *inodedb;
- char filename [BUFSIZ];
- struct passwd *pwd;
- struct stat statb;
+ glibtop_inodedb *inodedb;
+ char filename [BUFSIZ];
+ struct passwd *pwd;
+ struct stat statb;
- if (!databases)
- databases = GLIBTOP_INODEDB_ALL;
+ if (!databases)
+ databases = GLIBTOP_INODEDB_ALL;
- inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
+ inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb));
- if (stat (SYSTEM_INODEDB, &statb))
- databases &= ~GLIBTOP_INODEDB_SYSTEM;
+ if (stat (SYSTEM_INODEDB, &statb))
+ databases &= ~GLIBTOP_INODEDB_SYSTEM;
- if (databases & GLIBTOP_INODEDB_SYSTEM) {
- inodedb->system_dbf = gdbm_open
- (SYSTEM_INODEDB, 0, GDBM_READER, 0, 0);
- if (!inodedb->system_dbf)
- glibtop_error_io_r
- (server, "gdbm_open (%s)", SYSTEM_INODEDB);
- }
+ if (databases & GLIBTOP_INODEDB_SYSTEM) {
+ inodedb->system_dbf = gdbm_open
+ (SYSTEM_INODEDB, 0, GDBM_READER, 0, 0);
+ if (!inodedb->system_dbf)
+ glibtop_error_io_r
+ (server, "gdbm_open (%s)", SYSTEM_INODEDB);
+ }
- pwd = getpwuid (getuid ());
- if (!pwd) glibtop_error_io_r (server, "getpwuid");
+ pwd = getpwuid (getuid ());
+ if (!pwd) glibtop_error_io_r (server, "getpwuid");
- sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
+ sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir);
- if (stat (filename, &statb))
- databases &= ~GLIBTOP_INODEDB_USER;
-
- if (databases & GLIBTOP_INODEDB_USER) {
- inodedb->user_dbf = gdbm_open
- (filename, 0, GDBM_READER, 0, 0);
- if (!inodedb->user_dbf)
- glibtop_error_io_r
- (server, "gdbm_open (%s)", filename);
- }
-
- return inodedb;
+ if (stat (filename, &statb))
+ databases &= ~GLIBTOP_INODEDB_USER;
+
+ if (databases & GLIBTOP_INODEDB_USER) {
+ inodedb->user_dbf = gdbm_open
+ (filename, 0, GDBM_READER, 0, 0);
+ if (!inodedb->user_dbf)
+ glibtop_error_io_r
+ (server, "gdbm_open (%s)", filename);
+ }
+
+ return inodedb;
}
const char *
@@ -82,36 +84,36 @@ glibtop_inodedb_lookup_s (glibtop *server,
glibtop_inodedb *inodedb,
u_int64_t device, u_int64_t inode)
{
- glibtop_inodedb_key key;
- datum d_key, d_content;
+ glibtop_inodedb_key key;
+ datum d_key, d_content;
- d_key.dptr = (void *) &key;
- d_key.dsize = sizeof (key);
+ d_key.dptr = (void *) &key;
+ d_key.dsize = sizeof (key);
- key.device = device;
- key.inode = inode;
+ key.device = device;
+ key.inode = inode;
- if (inodedb->system_dbf) {
- d_content = gdbm_fetch (inodedb->system_dbf, d_key);
- if (d_content.dptr) return d_content.dptr;
- }
+ if (inodedb->system_dbf) {
+ d_content = gdbm_fetch (inodedb->system_dbf, d_key);
+ if (d_content.dptr) return d_content.dptr;
+ }
- if (inodedb->user_dbf) {
- d_content = gdbm_fetch (inodedb->user_dbf, d_key);
- if (d_content.dptr) return d_content.dptr;
- }
+ if (inodedb->user_dbf) {
+ d_content = gdbm_fetch (inodedb->user_dbf, d_key);
+ if (d_content.dptr) return d_content.dptr;
+ }
- return NULL;
+ return NULL;
}
void
glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb)
{
- if (inodedb->system_dbf)
- gdbm_close (inodedb->system_dbf);
+ if (inodedb->system_dbf)
+ gdbm_close (inodedb->system_dbf);
- if (inodedb->user_dbf)
- gdbm_close (inodedb->user_dbf);
+ if (inodedb->user_dbf)
+ gdbm_close (inodedb->user_dbf);
- glibtop_free_r (server, inodedb);
+ glibtop_free_r (server, inodedb);
}
diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c
index d8db10db..2127fbb8 100644
--- a/sysdeps/common/mountlist.c
+++ b/sysdeps/common/mountlist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* mountlist.c -- return a list of mounted filesystems
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
@@ -117,22 +119,22 @@ static int
xatoi (cp)
char *cp;
{
- int val;
+ int val;
- val = 0;
- while (*cp)
- {
- if (*cp >= 'a' && *cp <= 'f')
- val = val * 16 + *cp - 'a' + 10;
- else if (*cp >= 'A' && *cp <= 'F')
- val = val * 16 + *cp - 'A' + 10;
- else if (*cp >= '0' && *cp <= '9')
- val = val * 16 + *cp - '0';
- else
- break;
- cp++;
- }
- return val;
+ val = 0;
+ while (*cp)
+ {
+ if (*cp >= 'a' && *cp <= 'f')
+ val = val * 16 + *cp - 'a' + 10;
+ else if (*cp >= 'A' && *cp <= 'F')
+ val = val * 16 + *cp - 'A' + 10;
+ else if (*cp >= '0' && *cp <= '9')
+ val = val * 16 + *cp - '0';
+ else
+ break;
+ cp++;
+ }
+ return val;
}
#endif /* MOUNTED_GETMNTENT1. */
@@ -141,95 +143,95 @@ static char *
fstype_to_string (t)
short t;
{
- switch (t)
- {
+ switch (t)
+ {
#ifdef MOUNT_PC
- case MOUNT_PC:
- return "pc";
+ case MOUNT_PC:
+ return "pc";
#endif
#ifdef MOUNT_MFS
- case MOUNT_MFS:
- return "mfs";
+ case MOUNT_MFS:
+ return "mfs";
#endif
#ifdef MOUNT_LO
- case MOUNT_LO:
- return "lo";
+ case MOUNT_LO:
+ return "lo";
#endif
#ifdef MOUNT_TFS
- case MOUNT_TFS:
- return "tfs";
+ case MOUNT_TFS:
+ return "tfs";
#endif
#ifdef MOUNT_TMP
- case MOUNT_TMP:
- return "tmp";
+ case MOUNT_TMP:
+ return "tmp";
#endif
#ifdef MOUNT_UFS
- case MOUNT_UFS:
- return "ufs" ;
+ case MOUNT_UFS:
+ return "ufs" ;
#endif
#ifdef MOUNT_NFS
- case MOUNT_NFS:
- return "nfs" ;
+ case MOUNT_NFS:
+ return "nfs" ;
#endif
#ifdef MOUNT_MSDOS
- case MOUNT_MSDOS:
- return "msdos" ;
+ case MOUNT_MSDOS:
+ return "msdos" ;
#endif
#ifdef MOUNT_LFS
- case MOUNT_LFS:
- return "lfs" ;
+ case MOUNT_LFS:
+ return "lfs" ;
#endif
#ifdef MOUNT_LOFS
- case MOUNT_LOFS:
- return "lofs" ;
+ case MOUNT_LOFS:
+ return "lofs" ;
#endif
#ifdef MOUNT_FDESC
- case MOUNT_FDESC:
- return "fdesc" ;
+ case MOUNT_FDESC:
+ return "fdesc" ;
#endif
#ifdef MOUNT_PORTAL
- case MOUNT_PORTAL:
- return "portal" ;
+ case MOUNT_PORTAL:
+ return "portal" ;
#endif
#ifdef MOUNT_NULL
- case MOUNT_NULL:
- return "null" ;
+ case MOUNT_NULL:
+ return "null" ;
#endif
#ifdef MOUNT_UMAP
- case MOUNT_UMAP:
- return "umap" ;
+ case MOUNT_UMAP:
+ return "umap" ;
#endif
#ifdef MOUNT_KERNFS
- case MOUNT_KERNFS:
- return "kernfs" ;
+ case MOUNT_KERNFS:
+ return "kernfs" ;
#endif
#ifdef MOUNT_PROCFS
- case MOUNT_PROCFS:
- return "procfs" ;
+ case MOUNT_PROCFS:
+ return "procfs" ;
#endif
#ifdef MOUNT_AFS
- case MOUNT_AFS:
- return "afs" ;
+ case MOUNT_AFS:
+ return "afs" ;
#endif
#ifdef MOUNT_CD9660
- case MOUNT_CD9660:
- return "cd9660" ;
+ case MOUNT_CD9660:
+ return "cd9660" ;
#endif
#ifdef MOUNT_UNION
- case MOUNT_UNION:
- return "union" ;
+ case MOUNT_UNION:
+ return "union" ;
#endif
#ifdef MOUNT_DEVFS
- case MOUNT_DEVFS:
- return "devfs" ;
+ case MOUNT_DEVFS:
+ return "devfs" ;
#endif
#ifdef MOUNT_EXT2FS
- case MOUNT_EXT2FS:
- return "ext2fs" ;
+ case MOUNT_EXT2FS:
+ return "ext2fs" ;
#endif
- default:
- return "?";
- }
+ default:
+ return "?";
+ }
}
#endif /* MOUNTED_GETMNTINFO */
@@ -238,13 +240,13 @@ static char *
fstype_to_string (t)
int t;
{
- struct vfs_ent *e;
+ struct vfs_ent *e;
- e = getvfsbytype (t);
- if (!e || !e->vfsent_name)
- return "none";
- else
- return e->vfsent_name;
+ e = getvfsbytype (t);
+ if (!e || !e->vfsent_name)
+ return "none";
+ else
+ return e->vfsent_name;
}
#endif /* MOUNTED_VMOUNT */
@@ -259,386 +261,386 @@ static struct mount_entry *
read_filesystem_list (need_fs_type, all_fs)
int need_fs_type, all_fs;
{
- struct mount_entry *mount_list;
- struct mount_entry *me;
- struct mount_entry *mtail;
+ struct mount_entry *mount_list;
+ struct mount_entry *me;
+ struct mount_entry *mtail;
- /* Start the list off with a dummy entry. */
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_next = NULL;
- mount_list = mtail = me;
+ /* Start the list off with a dummy entry. */
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_next = NULL;
+ mount_list = mtail = me;
#ifdef MOUNTED_LISTMNTENT
- {
- struct tabmntent *mntlist, *p;
- struct mntent *mnt;
- struct mount_entry *me;
-
- /* the third and fourth arguments could be used to filter mounts,
- but Crays doesn't seem to have any mounts that we want to
- remove. Specifically, automount create normal NFS mounts.
- */
-
- if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
- return NULL;
- p = mntlist;
- while(p){
- mnt = p->ment;
- me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
- me->me_devname = xstrdup(mnt->mnt_fsname);
- me->me_mountdir = xstrdup(mnt->mnt_dir);
- me->me_type = xstrdup(mnt->mnt_type);
- me->me_dev = -1;
- me->me_next = NULL;
- mtail->me_next = me;
- mtail = me;
- p = p->next;
+ {
+ struct tabmntent *mntlist, *p;
+ struct mntent *mnt;
+ struct mount_entry *me;
+
+ /* the third and fourth arguments could be used to filter mounts,
+ but Crays doesn't seem to have any mounts that we want to
+ remove. Specifically, automount create normal NFS mounts.
+ */
+
+ if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
+ return NULL;
+ p = mntlist;
+ while(p){
+ mnt = p->ment;
+ me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry));
+ me->me_devname = xstrdup(mnt->mnt_fsname);
+ me->me_mountdir = xstrdup(mnt->mnt_dir);
+ me->me_type = xstrdup(mnt->mnt_type);
+ me->me_dev = -1;
+ me->me_next = NULL;
+ mtail->me_next = me;
+ mtail = me;
+ p = p->next;
+ }
+ freemntlist(mntlist);
}
- freemntlist(mntlist);
- }
#endif
#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */
- {
- struct mntent *mnt;
- char *table = MOUNTED;
- FILE *fp;
- char *devopt;
-
- fp = setmntent (table, "r");
- if (fp == NULL)
- return NULL;
-
- while ((mnt = getmntent (fp)))
- {
- if (!all_fs && (!strcmp (mnt->mnt_type, "ignore")
- || !strcmp (mnt->mnt_type, "auto")))
- continue;
-
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup (mnt->mnt_fsname);
- me->me_mountdir = xstrdup (mnt->mnt_dir);
- me->me_type = xstrdup (mnt->mnt_type);
- devopt = strstr (mnt->mnt_opts, "dev=");
- if (devopt)
- {
- if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X'))
- me->me_dev = xatoi (devopt + 6);
- else
- me->me_dev = xatoi (devopt + 4);
- }
- else
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
-
- if (endmntent (fp) == 0)
- return NULL;
- }
+ {
+ struct mntent *mnt;
+ char *table = MOUNTED;
+ FILE *fp;
+ char *devopt;
+
+ fp = setmntent (table, "r");
+ if (fp == NULL)
+ return NULL;
+
+ while ((mnt = getmntent (fp)))
+ {
+ if (!all_fs && (!strcmp (mnt->mnt_type, "ignore")
+ || !strcmp (mnt->mnt_type, "auto")))
+ continue;
+
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (mnt->mnt_fsname);
+ me->me_mountdir = xstrdup (mnt->mnt_dir);
+ me->me_type = xstrdup (mnt->mnt_type);
+ devopt = strstr (mnt->mnt_opts, "dev=");
+ if (devopt)
+ {
+ if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X'))
+ me->me_dev = xatoi (devopt + 6);
+ else
+ me->me_dev = xatoi (devopt + 4);
+ }
+ else
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+
+ if (endmntent (fp) == 0)
+ return NULL;
+ }
#endif /* MOUNTED_GETMNTENT1. */
#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */
- {
- struct statfs *fsp;
- int entries;
-
- entries = getmntinfo (&fsp, MNT_NOWAIT);
- if (entries < 0)
- return NULL;
- while (entries-- > 0)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup (fsp->f_mntfromname);
- me->me_mountdir = xstrdup (fsp->f_mntonname);
+ {
+ struct statfs *fsp;
+ int entries;
+
+ entries = getmntinfo (&fsp, MNT_NOWAIT);
+ if (entries < 0)
+ return NULL;
+ while (entries-- > 0)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (fsp->f_mntfromname);
+ me->me_mountdir = xstrdup (fsp->f_mntonname);
#if defined(__NetBSD__) || defined(__OpenBSD__)
- me->me_type = xstrdup (fsp->f_fstypename);
+ me->me_type = xstrdup (fsp->f_fstypename);
#else
- me->me_type = xstrdup (fstype_to_string (fsp->f_type));
+ me->me_type = xstrdup (fstype_to_string (fsp->f_type));
#endif
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_next = NULL;
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_next = NULL;
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- fsp++;
- }
- }
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ fsp++;
+ }
+ }
#endif /* MOUNTED_GETMNTINFO */
#ifdef MOUNTED_GETMNT /* Ultrix. */
- {
- int offset = 0;
- int val;
- struct fs_data fsd;
-
- while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
- (char *) 0)) > 0)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup (fsd.fd_req.devname);
- me->me_mountdir = xstrdup (fsd.fd_req.path);
- me->me_type = xstrdup (gt_names[fsd.fd_req.fstype]);
- me->me_dev = fsd.fd_req.dev;
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
- if (val < 0)
- return NULL;
- }
+ {
+ int offset = 0;
+ int val;
+ struct fs_data fsd;
+
+ while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
+ (char *) 0)) > 0)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (fsd.fd_req.devname);
+ me->me_mountdir = xstrdup (fsd.fd_req.path);
+ me->me_type = xstrdup (gt_names[fsd.fd_req.fstype]);
+ me->me_dev = fsd.fd_req.dev;
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+ if (val < 0)
+ return NULL;
+ }
#endif /* MOUNTED_GETMNT. */
#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */
- {
- int numsys, counter, bufsize;
- struct statfs *stats;
-
- numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
- if (numsys < 0)
- return (NULL);
-
- bufsize = (1 + numsys) * sizeof (struct statfs);
- stats = (struct statfs *)xmalloc (bufsize);
- numsys = getfsstat (stats, bufsize, MNT_WAIT);
+ {
+ int numsys, counter, bufsize;
+ struct statfs *stats;
+
+ numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
+ if (numsys < 0)
+ return (NULL);
+
+ bufsize = (1 + numsys) * sizeof (struct statfs);
+ stats = (struct statfs *)xmalloc (bufsize);
+ numsys = getfsstat (stats, bufsize, MNT_WAIT);
+
+ if (numsys < 0)
+ {
+ free (stats);
+ return (NULL);
+ }
+
+ for (counter = 0; counter < numsys; counter++)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (stats[counter].f_mntfromname);
+ me->me_mountdir = xstrdup (stats[counter].f_mntonname);
+ me->me_type = xstrdup (mnt_names[stats[counter].f_type]);
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
- if (numsys < 0)
- {
free (stats);
- return (NULL);
- }
-
- for (counter = 0; counter < numsys; counter++)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup (stats[counter].f_mntfromname);
- me->me_mountdir = xstrdup (stats[counter].f_mntonname);
- me->me_type = xstrdup (mnt_names[stats[counter].f_type]);
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
-
- free (stats);
- }
+ }
#endif /* MOUNTED_GETFSSTAT */
#if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */
- {
- struct mnttab mnt;
- char *table = "/etc/mnttab";
- FILE *fp;
-
- fp = fopen (table, "r");
- if (fp == NULL)
- return NULL;
-
- while (fread (&mnt, sizeof mnt, 1, fp) > 0)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ {
+ struct mnttab mnt;
+ char *table = "/etc/mnttab";
+ FILE *fp;
+
+ fp = fopen (table, "r");
+ if (fp == NULL)
+ return NULL;
+
+ while (fread (&mnt, sizeof mnt, 1, fp) > 0)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
#ifdef GETFSTYP /* SVR3. */
- me->me_devname = xstrdup (mnt.mt_dev);
+ me->me_devname = xstrdup (mnt.mt_dev);
#else
- me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
- strcpy (me->me_devname, "/dev/");
- strcpy (me->me_devname + 5, mnt.mt_dev);
+ me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
+ strcpy (me->me_devname, "/dev/");
+ strcpy (me->me_devname + 5, mnt.mt_dev);
#endif
- me->me_mountdir = xstrdup (mnt.mt_filsys);
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_type = xstrdup ("");
+ me->me_mountdir = xstrdup (mnt.mt_filsys);
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_type = xstrdup ("");
#ifdef GETFSTYP /* SVR3. */
- if (need_fs_type)
- {
- struct statfs fsd;
- char typebuf[FSTYPSZ];
-
- if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
- && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
- me->me_type = xstrdup (typebuf);
- }
-#endif
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
-
- if (fclose (fp) == EOF)
- return NULL;
- }
+ if (need_fs_type)
+ {
+ struct statfs fsd;
+ char typebuf[FSTYPSZ];
+
+ if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
+ && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
+ me->me_type = xstrdup (typebuf);
+ }
+#endif
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+
+ if (fclose (fp) == EOF)
+ return NULL;
+ }
#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */
#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */
- {
- struct mntent **mnttbl=getmnttbl(),**ent;
- for (ent=mnttbl;*ent;ent++)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup ( (*ent)->mt_resource);
- me->me_mountdir = xstrdup( (*ent)->mt_directory);
- me->me_type = xstrdup ((*ent)->mt_fstype);
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
- endmnttbl();
- }
+ {
+ struct mntent **mnttbl=getmnttbl(),**ent;
+ for (ent=mnttbl;*ent;ent++)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup ( (*ent)->mt_resource);
+ me->me_mountdir = xstrdup( (*ent)->mt_directory);
+ me->me_type = xstrdup ((*ent)->mt_fstype);
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+ endmnttbl();
+ }
#endif
#ifdef MOUNTED_GETMNTENT2 /* SVR4. */
- {
- struct mnttab mnt;
- char *table = MNTTAB;
- FILE *fp;
- int ret;
-
- fp = fopen (table, "r");
- if (fp == NULL)
- return NULL;
-
- while ((ret = getmntent (fp, &mnt)) == 0)
- {
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- me->me_devname = xstrdup (mnt.mnt_special);
- me->me_mountdir = xstrdup (mnt.mnt_mountp);
- me->me_type = xstrdup (mnt.mnt_fstype);
- me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
-
- if (ret > 0)
- return NULL;
- if (fclose (fp) == EOF)
- return NULL;
- }
+ {
+ struct mnttab mnt;
+ char *table = MNTTAB;
+ FILE *fp;
+ int ret;
+
+ fp = fopen (table, "r");
+ if (fp == NULL)
+ return NULL;
+
+ while ((ret = getmntent (fp, &mnt)) == 0)
+ {
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ me->me_devname = xstrdup (mnt.mnt_special);
+ me->me_mountdir = xstrdup (mnt.mnt_mountp);
+ me->me_type = xstrdup (mnt.mnt_fstype);
+ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+
+ if (ret > 0)
+ return NULL;
+ if (fclose (fp) == EOF)
+ return NULL;
+ }
#endif /* MOUNTED_GETMNTENT2. */
#ifdef MOUNTED_VMOUNT /* AIX. */
- {
- int bufsize;
- char *entries, *thisent;
- struct vmount *vmp;
-
- /* Ask how many bytes to allocate for the mounted filesystem info. */
- mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize);
- entries = xmalloc (bufsize);
-
- /* Get the list of mounted filesystems. */
- mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
-
- for (thisent = entries; thisent < entries + bufsize;
- thisent += vmp->vmt_length)
- {
- vmp = (struct vmount *) thisent;
- me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
- if (vmp->vmt_flags & MNT_REMOTE)
- {
- char *host, *path;
-
- /* Prepend the remote pathname. */
- host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
- path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
- me->me_devname = xmalloc (strlen (host) + strlen (path) + 2);
- strcpy (me->me_devname, host);
- strcat (me->me_devname, ":");
- strcat (me->me_devname, path);
- }
- else
- {
- me->me_devname = xstrdup (thisent +
- vmp->vmt_data[VMT_OBJECT].vmt_off);
- }
- me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
- me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
- me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
- me->me_next = NULL;
-
- /* Add to the linked list. */
- mtail->me_next = me;
- mtail = me;
- }
- free (entries);
- }
+ {
+ int bufsize;
+ char *entries, *thisent;
+ struct vmount *vmp;
+
+ /* Ask how many bytes to allocate for the mounted filesystem info. */
+ mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize);
+ entries = xmalloc (bufsize);
+
+ /* Get the list of mounted filesystems. */
+ mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
+
+ for (thisent = entries; thisent < entries + bufsize;
+ thisent += vmp->vmt_length)
+ {
+ vmp = (struct vmount *) thisent;
+ me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
+ if (vmp->vmt_flags & MNT_REMOTE)
+ {
+ char *host, *path;
+
+ /* Prepend the remote pathname. */
+ host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
+ path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
+ me->me_devname = xmalloc (strlen (host) + strlen (path) + 2);
+ strcpy (me->me_devname, host);
+ strcat (me->me_devname, ":");
+ strcat (me->me_devname, path);
+ }
+ else
+ {
+ me->me_devname = xstrdup (thisent +
+ vmp->vmt_data[VMT_OBJECT].vmt_off);
+ }
+ me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
+ me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
+ me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */
+ me->me_next = NULL;
+
+ /* Add to the linked list. */
+ mtail->me_next = me;
+ mtail = me;
+ }
+ free (entries);
+ }
#endif /* MOUNTED_VMOUNT. */
- /* Free the dummy head. */
- me = mount_list;
- mount_list = mount_list->me_next;
- free (me);
- return mount_list;
+ /* Free the dummy head. */
+ me = mount_list;
+ mount_list = mount_list->me_next;
+ free (me);
+ return mount_list;
}
glibtop_mountentry *
glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
{
- struct mount_entry *me, *tmp, *next;
- glibtop_mountentry *mount_list;
- int count;
+ struct mount_entry *me, *tmp, *next;
+ glibtop_mountentry *mount_list;
+ int count;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_mountlist));
+ memset (buf, 0, sizeof (glibtop_mountlist));
- /* Read filesystem list. */
+ /* Read filesystem list. */
- me = read_filesystem_list (1, all_fs);
+ me = read_filesystem_list (1, all_fs);
- if (me == NULL)
- return NULL;
+ if (me == NULL)
+ return NULL;
- /* Count entries. */
+ /* Count entries. */
- for (count = 0, tmp = me; tmp; count++, tmp = tmp->me_next)
- ;
+ for (count = 0, tmp = me; tmp; count++, tmp = tmp->me_next)
+ ;
- buf->size = sizeof (glibtop_mountentry);
- buf->number = count;
+ buf->size = sizeof (glibtop_mountentry);
+ buf->number = count;
- buf->total = buf->number * buf->size;
+ buf->total = buf->number * buf->size;
- mount_list = glibtop_malloc_r (server, buf->total);
+ mount_list = glibtop_malloc_r (server, buf->total);
- /* Write data into mount_list. */
+ /* Write data into mount_list. */
- for (count = 0, tmp = me; tmp; count++, tmp = tmp->me_next) {
- strncpy (mount_list [count].devname, tmp->me_devname,
- GLIBTOP_MOUNTENTRY_LEN);
- strncpy (mount_list [count].mountdir, tmp->me_mountdir,
- GLIBTOP_MOUNTENTRY_LEN);
- strncpy (mount_list [count].type, tmp->me_type,
- GLIBTOP_MOUNTENTRY_LEN);
- mount_list [count].devname [GLIBTOP_MOUNTENTRY_LEN] = 0;
- mount_list [count].mountdir [GLIBTOP_MOUNTENTRY_LEN] = 0;
- mount_list [count].type [GLIBTOP_MOUNTENTRY_LEN] = 0;
- mount_list [count].dev = tmp->me_dev;
- }
+ for (count = 0, tmp = me; tmp; count++, tmp = tmp->me_next) {
+ strncpy (mount_list [count].devname, tmp->me_devname,
+ GLIBTOP_MOUNTENTRY_LEN);
+ strncpy (mount_list [count].mountdir, tmp->me_mountdir,
+ GLIBTOP_MOUNTENTRY_LEN);
+ strncpy (mount_list [count].type, tmp->me_type,
+ GLIBTOP_MOUNTENTRY_LEN);
+ mount_list [count].devname [GLIBTOP_MOUNTENTRY_LEN] = 0;
+ mount_list [count].mountdir [GLIBTOP_MOUNTENTRY_LEN] = 0;
+ mount_list [count].type [GLIBTOP_MOUNTENTRY_LEN] = 0;
+ mount_list [count].dev = tmp->me_dev;
+ }
- /* Free memory. */
+ /* Free memory. */
- for (count = 0, tmp = me; tmp; count++, tmp = next) {
- next = tmp->me_next;
- xfree (tmp->me_devname);
- xfree (tmp->me_mountdir);
- xfree (tmp->me_type);
- xfree (tmp);
- }
+ for (count = 0, tmp = me; tmp; count++, tmp = next) {
+ next = tmp->me_next;
+ xfree (tmp->me_devname);
+ xfree (tmp->me_mountdir);
+ xfree (tmp->me_type);
+ xfree (tmp);
+ }
- return mount_list;
+ return mount_list;
}
diff --git a/sysdeps/common/mountlist.h b/sysdeps/common/mountlist.h
index 8bc38f6a..f9f8e434 100644
--- a/sysdeps/common/mountlist.h
+++ b/sysdeps/common/mountlist.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* mountlist.h -- declarations for list of mounted filesystems
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
@@ -18,10 +20,10 @@
/* A mount table entry. */
struct mount_entry
{
- char *me_devname; /* Device node pathname, including "/dev/". */
- char *me_mountdir; /* Mount point directory pathname. */
- char *me_type; /* "nfs", "4.2", etc. */
- dev_t me_dev; /* Device number of me_mountdir. */
- struct mount_entry *me_next;
+ char *me_devname; /* Device node pathname, including "/dev/". */
+ char *me_mountdir; /* Mount point directory pathname. */
+ char *me_type; /* "nfs", "4.2", etc. */
+ dev_t me_dev; /* Device number of me_mountdir. */
+ struct mount_entry *me_next;
};
diff --git a/sysdeps/common/sysdeps_suid.c b/sysdeps/common/sysdeps_suid.c
index 97731d9f..554fe355 100644
--- a/sysdeps/common/sysdeps_suid.c
+++ b/sysdeps/common/sysdeps_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,65 +30,65 @@
glibtop_init_func_t _glibtop_init_hook_p [] = {
#if GLIBTOP_SUID_CPU
- glibtop_init_cpu_p,
+ glibtop_init_cpu_p,
#endif
#if GLIBTOP_SUID_MEM
- glibtop_init_mem_p,
+ glibtop_init_mem_p,
#endif
#if GLIBTOP_SUID_SWAP
- glibtop_init_swap_p,
+ glibtop_init_swap_p,
#endif
#if GLIBTOP_SUID_UPTIME
- glibtop_init_uptime_p,
+ glibtop_init_uptime_p,
#endif
#if GLIBTOP_SUID_LOADAVG
- glibtop_init_loadavg_p,
+ glibtop_init_loadavg_p,
#endif
#if GLIBTOP_SUID_SHM_LIMITS
- glibtop_init_shm_limits_p,
+ glibtop_init_shm_limits_p,
#endif
#if GLIBTOP_SUID_MSG_LIMITS
- glibtop_init_msg_limits_p,
+ glibtop_init_msg_limits_p,
#endif
#if GLIBTOP_SUID_SEM_LIMITS
- glibtop_init_sem_limits_p,
+ glibtop_init_sem_limits_p,
#endif
#if GLIBTOP_SUID_PROCLIST
- glibtop_init_proclist_p,
+ glibtop_init_proclist_p,
#endif
#if GLIBTOP_SUID_PROC_STATE
- glibtop_init_proc_state_p,
+ glibtop_init_proc_state_p,
#endif
#if GLIBTOP_SUID_PROC_UID
- glibtop_init_proc_uid_p,
+ glibtop_init_proc_uid_p,
#endif
#if GLIBTOP_SUID_PROC_MEM
- glibtop_init_proc_mem_p,
+ glibtop_init_proc_mem_p,
#endif
#if GLIBTOP_SUID_PROC_TIME
- glibtop_init_proc_time_p,
+ glibtop_init_proc_time_p,
#endif
#if GLIBTOP_SUID_PROC_SIGNAL
- glibtop_init_proc_signal_p,
+ glibtop_init_proc_signal_p,
#endif
#if GLIBTOP_SUID_PROC_KERNEL
- glibtop_init_proc_kernel_p,
+ glibtop_init_proc_kernel_p,
#endif
#if GLIBTOP_SUID_PROC_SEGMENT
- glibtop_init_proc_segment_p,
+ glibtop_init_proc_segment_p,
#endif
#if GLIBTOP_SUID_PROC_ARGS
- glibtop_init_proc_args_p,
+ glibtop_init_proc_args_p,
#endif
#if GLIBTOP_SUID_PROC_MAP
- glibtop_init_proc_map_p,
+ glibtop_init_proc_map_p,
#endif
#if GLIBTOP_SUID_NETLOAD
- glibtop_init_netload_p,
+ glibtop_init_netload_p,
#endif
#if GLIBTOP_SUID_PPP
- glibtop_init_ppp_p,
+ glibtop_init_ppp_p,
#endif
- NULL
+ NULL
};
diff --git a/sysdeps/common/xmalloc.c b/sysdeps/common/xmalloc.c
index 45063c18..4c958a36 100644
--- a/sysdeps/common/xmalloc.c
+++ b/sysdeps/common/xmalloc.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,14 +35,14 @@ void *
glibtop_malloc_r (glibtop *server, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
- return g_malloc0 (size);
+ return g_malloc0 (size);
#else
- void *buf = malloc (size);
+ void *buf = malloc (size);
- if (!buf)
- glibtop_error_io_r (server, "malloc %d bytes", size);
+ if (!buf)
+ glibtop_error_io_r (server, "malloc %d bytes", size);
- return buf;
+ return buf;
#endif
}
@@ -48,15 +50,15 @@ void *
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
- return g_malloc0 (size * nmemb);
+ return g_malloc0 (size * nmemb);
#else
- void *buf = calloc (nmemb, size);
+ void *buf = calloc (nmemb, size);
- if (!buf)
- glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
- nmemb, size);
+ if (!buf)
+ glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
+ nmemb, size);
- return buf;
+ return buf;
#endif
}
@@ -64,14 +66,14 @@ void *
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
- return g_realloc (ptr, size);
+ return g_realloc (ptr, size);
#else
- void *buf = realloc (ptr, size);
+ void *buf = realloc (ptr, size);
- if (!buf)
- glibtop_error_io_r (server, "realloc %d bytes", size);
+ if (!buf)
+ glibtop_error_io_r (server, "realloc %d bytes", size);
- return buf;
+ return buf;
#endif
}
@@ -79,9 +81,9 @@ char *
glibtop_strdup_r (glibtop *server, const char *string)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
- return g_strdup (string);
+ return g_strdup (string);
#else
- return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
+ return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
#endif
}
@@ -89,8 +91,8 @@ void
glibtop_free_r (glibtop *server, const void *ptr)
{
#ifdef LIBGTOP_USE_GLIB_MALLOC
- g_free (ptr);
+ g_free (ptr);
#else
- if (ptr) free ((void *) ptr);
+ if (ptr) free ((void *) ptr);
#endif
}
diff --git a/sysdeps/common/xmalloc_suid.c b/sysdeps/common/xmalloc_suid.c
index d8d0080f..f8b7fe44 100644
--- a/sysdeps/common/xmalloc_suid.c
+++ b/sysdeps/common/xmalloc_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -28,45 +30,45 @@
void *
glibtop_malloc_r (glibtop *server, size_t size)
{
- void *buf = malloc (size);
+ void *buf = malloc (size);
- if (!buf)
- glibtop_error_io_r (server, "malloc %d bytes", size);
+ if (!buf)
+ glibtop_error_io_r (server, "malloc %d bytes", size);
- return buf;
+ return buf;
}
void *
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
{
- void *buf = calloc (nmemb, size);
+ void *buf = calloc (nmemb, size);
- if (!buf)
- glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
- nmemb, size);
+ if (!buf)
+ glibtop_error_io_r (server, "calloc %d blocks (%d bytes each)",
+ nmemb, size);
- return buf;
+ return buf;
}
void *
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
{
- void *buf = realloc (ptr, size);
+ void *buf = realloc (ptr, size);
- if (!buf)
- glibtop_error_io_r (server, "realloc %d bytes", size);
+ if (!buf)
+ glibtop_error_io_r (server, "realloc %d bytes", size);
- return buf;
+ return buf;
}
char *
glibtop_strdup_r (glibtop *server, const char *string)
{
- return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
+ return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string);
}
void
glibtop_free_r (glibtop *server, const void *ptr)
{
- if (ptr) free ((void *) ptr);
+ if (ptr) free ((void *) ptr);
}
diff --git a/sysdeps/freebsd/close.c b/sysdeps/freebsd/close.c
index b887a914..1006e29e 100644
--- a/sysdeps/freebsd/close.c
+++ b/sysdeps/freebsd/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
diff --git a/sysdeps/freebsd/cpu.c b/sysdeps/freebsd/cpu.c
index 619778c5..4d75166d 100644
--- a/sysdeps/freebsd/cpu.c
+++ b/sysdeps/freebsd/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -35,11 +37,11 @@ static const unsigned long _glibtop_sysdeps_cpu =
/* nlist structure for kernel access */
static struct nlist nlst [] = {
#ifdef __bsdi__
- { "_cpustats" },
+ { "_cpustats" },
#else
- { "_cp_time" },
+ { "_cp_time" },
#endif
- { 0 }
+ { 0 }
};
/* MIB array for sysctl */
@@ -51,15 +53,15 @@ static int mib [] = { CTL_KERN, KERN_CLOCKRATE };
int
glibtop_init_cpu_p (glibtop *server)
{
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (cpu)");
- return -1;
- }
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (cpu)");
+ return -1;
+ }
- /* Set this only if kvm_nlist () succeeded. */
- server->sysdeps.cpu = _glibtop_sysdeps_cpu;
+ /* Set this only if kvm_nlist () succeeded. */
+ server->sysdeps.cpu = _glibtop_sysdeps_cpu;
- return 0;
+ return 0;
}
/* Provides information about cpu usage. */
@@ -67,55 +69,55 @@ glibtop_init_cpu_p (glibtop *server)
int
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
{
- long cpts [CPUSTATES];
- /* sysctl vars*/
- struct clockinfo ci;
- size_t length;
+ long cpts [CPUSTATES];
+ /* sysctl vars*/
+ struct clockinfo ci;
+ size_t length;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
- memset (buf, 0, sizeof (glibtop_cpu));
+ memset (buf, 0, sizeof (glibtop_cpu));
- /* If this fails, the nlist may not be valid. */
- if (server->sysdeps.cpu == 0)
- return -1;
+ /* If this fails, the nlist may not be valid. */
+ if (server->sysdeps.cpu == 0)
+ return -1;
- if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
- &cpts, sizeof (cpts)) != sizeof (cpts)) {
- glibtop_warn_io_r (server, "kvm_read (cp_time)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
+ &cpts, sizeof (cpts)) != sizeof (cpts)) {
+ glibtop_warn_io_r (server, "kvm_read (cp_time)");
+ return -1;
+ }
- /* Get the clockrate data */
- length = sizeof (struct clockinfo);
- if (sysctl (mib, mib_length, &ci, &length, NULL, 0)) {
- glibtop_warn_io_r (server, "sysctl");
- return -1;
- }
-
- /* set user time */
- buf->user = cpts [CP_USER];
- /* set nice time */
- buf->nice = cpts [CP_NICE];
- /* set sys time */
- buf->sys = cpts [CP_SYS];
- /* set idle time */
- buf->idle = cpts [CP_IDLE];
+ /* Get the clockrate data */
+ length = sizeof (struct clockinfo);
+ if (sysctl (mib, mib_length, &ci, &length, NULL, 0)) {
+ glibtop_warn_io_r (server, "sysctl");
+ return -1;
+ }
+
+ /* set user time */
+ buf->user = cpts [CP_USER];
+ /* set nice time */
+ buf->nice = cpts [CP_NICE];
+ /* set sys time */
+ buf->sys = cpts [CP_SYS];
+ /* set idle time */
+ buf->idle = cpts [CP_IDLE];
- /* set frequency */
- /*
- FIXME -- is hz, tick, profhz or stathz wanted?
- buf->frequency = sysctl("kern.clockrate", ...);
+ /* set frequency */
+ /*
+ FIXME -- is hz, tick, profhz or stathz wanted?
+ buf->frequency = sysctl("kern.clockrate", ...);
- struct clockinfo
- */
- buf->frequency = ci.hz;
- /* set total */
- buf->total = cpts [CP_USER] + cpts [CP_NICE]
- + cpts [CP_SYS] + cpts [CP_IDLE];
+ struct clockinfo
+ */
+ buf->frequency = ci.hz;
+ /* set total */
+ buf->total = cpts [CP_USER] + cpts [CP_NICE]
+ + cpts [CP_SYS] + cpts [CP_IDLE];
- /* Set the flags last. */
- buf->flags = _glibtop_sysdeps_cpu;
+ /* Set the flags last. */
+ buf->flags = _glibtop_sysdeps_cpu;
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/glibtop_machine.h b/sysdeps/freebsd/glibtop_machine.h
index 347e9ff2..aba52ffc 100644
--- a/sysdeps/freebsd/glibtop_machine.h
+++ b/sysdeps/freebsd/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -45,13 +47,13 @@ typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
- uid_t uid, euid;
- gid_t gid, egid;
+ uid_t uid, euid;
+ gid_t gid, egid;
- /* The kernel descriptor, used by kvm_* calls. We keep and re-use
- * it rather than re-getting it for almost all function
- * invocations. */
- kvm_t *kd;
+ /* The kernel descriptor, used by kvm_* calls. We keep and re-use
+ * it rather than re-getting it for almost all function
+ * invocations. */
+ kvm_t *kd;
};
END_LIBGTOP_DECLS
diff --git a/sysdeps/freebsd/glibtop_server.h b/sysdeps/freebsd/glibtop_server.h
index a8e7166b..d7e032d9 100644
--- a/sysdeps/freebsd/glibtop_server.h
+++ b/sysdeps/freebsd/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/freebsd/glibtop_suid.h b/sysdeps/freebsd/glibtop_suid.h
index 067dcdf3..31a4e3d4 100644
--- a/sysdeps/freebsd/glibtop_suid.h
+++ b/sysdeps/freebsd/glibtop_suid.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -37,23 +39,23 @@ BEGIN_LIBGTOP_DECLS
#define UREADOK(ki) (FORCEUREAD || (KI_PROC(ki)->p_flag & P_INMEM))
static inline void glibtop_suid_enter (glibtop *server) {
- setregid (server->_priv->machine.gid,
- server->_priv->machine.egid);
+setregid (server->_priv->machine.gid,
+ server->_priv->machine.egid);
};
static inline void glibtop_suid_leave (glibtop *server) {
- if (setregid (server->_priv->machine.egid,
- server->_priv->machine.gid))
- _exit (1);
-};
-
-void
-glibtop_init_p (glibtop *server, const unsigned long features,
- const unsigned flags);
+if (setregid (server->_priv->machine.egid,
+ server->_priv->machine.gid))
+ _exit (1);
+ };
+
+ void
+ glibtop_init_p (glibtop *server, const unsigned long features,
+ const unsigned flags);
void
glibtop_open_p (glibtop *server, const char *program_name,
- const unsigned long features,
- const unsigned flags);
+ const unsigned long features,
+ const unsigned flags);
END_LIBGTOP_DECLS
diff --git a/sysdeps/freebsd/init.c b/sysdeps/freebsd/init.c
index 11d89342..48371f56 100644
--- a/sysdeps/freebsd/init.c
+++ b/sysdeps/freebsd/init.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -32,14 +34,14 @@ glibtop_init_r (glibtop **server,
const unsigned long features,
const unsigned flags)
{
- if (*server != NULL)
- return *server;
-
- if (glibtop_global_server == NULL) {
- glibtop_global_server = &_glibtop_global_server;
- glibtop_open (glibtop_global_server, "glibtop",
- features, flags);
- }
+ if (*server != NULL)
+ return *server;
+
+ if (glibtop_global_server == NULL) {
+ glibtop_global_server = &_glibtop_global_server;
+ glibtop_open (glibtop_global_server, "glibtop",
+ features, flags);
+ }
- return *server = glibtop_global_server;
+ return *server = glibtop_global_server;
}
diff --git a/sysdeps/freebsd/interfaces.c b/sysdeps/freebsd/interfaces.c
index 7f3e0d74..737c5c99 100644
--- a/sysdeps/freebsd/interfaces.c
+++ b/sysdeps/freebsd/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/freebsd/loadavg.c b/sysdeps/freebsd/loadavg.c
index 8acf4ffa..67e0e29f 100644
--- a/sysdeps/freebsd/loadavg.c
+++ b/sysdeps/freebsd/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -35,9 +37,9 @@ static const unsigned long _glibtop_sysdeps_loadavg =
int
glibtop_init_loadavg_p (glibtop *server)
{
- server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
+ server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
- return 0;
+ return 0;
}
/* Provides load averange. */
@@ -45,20 +47,20 @@ glibtop_init_loadavg_p (glibtop *server)
int
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
{
- double ldavg[3];
- int i;
+ double ldavg[3];
+ int i;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
- memset (buf, 0, sizeof (glibtop_loadavg));
+ memset (buf, 0, sizeof (glibtop_loadavg));
- getloadavg (ldavg, 3);
+ getloadavg (ldavg, 3);
- /* fill in the struct */
- buf->flags = _glibtop_sysdeps_loadavg;
- for (i = 0; i < 3; i++) {
- buf->loadavg [i] = ldavg [i];
- } /* end for */
+ /* fill in the struct */
+ buf->flags = _glibtop_sysdeps_loadavg;
+ for (i = 0; i < 3; i++) {
+ buf->loadavg [i] = ldavg [i];
+ } /* end for */
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/mem.c b/sysdeps/freebsd/mem.c
index 2d929c1f..0794b71b 100644
--- a/sysdeps/freebsd/mem.c
+++ b/sysdeps/freebsd/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -58,18 +60,18 @@ static int pageshift; /* log base 2 of the pagesize */
/* nlist structure for kernel access */
static struct nlist nlst [] = {
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- { "_bufpages" },
- { 0 }
+ { "_bufpages" },
+ { 0 }
#else
#if defined(__bsdi__)
- { "_bufcachemem" },
+ { "_bufcachemem" },
#elif defined(__FreeBSD__)
- { "_bufspace" },
+ { "_bufspace" },
#else
- { "_bufpages" },
+ { "_bufpages" },
#endif
- { "_cnt" },
- { 0 }
+ { "_cnt" },
+ { 0 }
#endif
};
@@ -90,137 +92,137 @@ static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP };
int
glibtop_init_mem_p (glibtop *server)
{
- register int pagesize;
+ register int pagesize;
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (mem)");
- return -1;
- }
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (mem)");
+ return -1;
+ }
- /* get the page size with "getpagesize" and calculate pageshift
- * from it */
- pagesize = getpagesize ();
- pageshift = 0;
- while (pagesize > 1) {
- pageshift++;
- pagesize >>= 1;
- }
+ /* get the page size with "getpagesize" and calculate pageshift
+ * from it */
+ pagesize = getpagesize ();
+ pageshift = 0;
+ while (pagesize > 1) {
+ pageshift++;
+ pagesize >>= 1;
+ }
- /* we only need the amount of log(2)1024 for our conversion */
- pageshift -= LOG1024;
+ /* we only need the amount of log(2)1024 for our conversion */
+ pageshift -= LOG1024;
- server->sysdeps.mem = _glibtop_sysdeps_mem;
+ server->sysdeps.mem = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
int
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
{
- struct vmtotal vmt;
- size_t length_vmt;
+ struct vmtotal vmt;
+ size_t length_vmt;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- struct uvmexp uvmexp;
- size_t length_uvmexp;
+ struct uvmexp uvmexp;
+ size_t length_uvmexp;
#else
- struct vmmeter vmm;
+ struct vmmeter vmm;
#endif
- u_int v_used_count;
- u_int v_total_count;
- u_int v_free_count;
- int bufspace;
+ u_int v_used_count;
+ u_int v_total_count;
+ u_int v_free_count;
+ int bufspace;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- if (server->sysdeps.mem == 0)
- return -1;
+ if (server->sysdeps.mem == 0)
+ return -1;
- /* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect
- * value for `vmt.vm'. We use some code from Unix top
- * here.] */
+ /* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect
+ * value for `vmt.vm'. We use some code from Unix top
+ * here.] */
- /* Get the data from sysctl */
- length_vmt = sizeof (vmt);
- if (sysctl (mib, 2, &vmt, &length_vmt, NULL, 0)) {
- glibtop_warn_io_r (server, "sysctl (vmt)");
- return -1;
- }
+ /* Get the data from sysctl */
+ length_vmt = sizeof (vmt);
+ if (sysctl (mib, 2, &vmt, &length_vmt, NULL, 0)) {
+ glibtop_warn_io_r (server, "sysctl (vmt)");
+ return -1;
+ }
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- length_uvmexp = sizeof (uvmexp);
- if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
- glibtop_warn_io_r (server, "sysctl (uvmexp)");
- return -1;
- }
+ length_uvmexp = sizeof (uvmexp);
+ if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
+ glibtop_warn_io_r (server, "sysctl (uvmexp)");
+ return -1;
+ }
#else
- /* Get the data from kvm_* */
- if (kvm_read (server->_priv->machine.kd, nlst[1].n_value,
- &vmm, sizeof (vmm)) != sizeof (vmm)) {
- glibtop_warn_io_r (server, "kvm_read (cnt)");
- return -1;
- }
+ /* Get the data from kvm_* */
+ if (kvm_read (server->_priv->machine.kd, nlst[1].n_value,
+ &vmm, sizeof (vmm)) != sizeof (vmm)) {
+ glibtop_warn_io_r (server, "kvm_read (cnt)");
+ return -1;
+ }
#endif
- if (kvm_read (server->_priv->machine.kd, nlst[0].n_value,
- &bufspace, sizeof (bufspace)) != sizeof (bufspace)) {
- glibtop_warn_io_r (server, "kvm_read (bufspace)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd, nlst[0].n_value,
+ &bufspace, sizeof (bufspace)) != sizeof (bufspace)) {
+ glibtop_warn_io_r (server, "kvm_read (bufspace)");
+ return -1;
+ }
- /* convert memory stats to Kbytes */
+ /* convert memory stats to Kbytes */
#if defined(__FreeBSD__)
- v_total_count = vmm.v_page_count;
+ v_total_count = vmm.v_page_count;
#else
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- v_total_count = uvmexp.reserve_kernel +
- uvmexp.reserve_pagedaemon +
- uvmexp.free + uvmexp.wired + uvmexp.active +
- uvmexp.inactive;
+ v_total_count = uvmexp.reserve_kernel +
+ uvmexp.reserve_pagedaemon +
+ uvmexp.free + uvmexp.wired + uvmexp.active +
+ uvmexp.inactive;
#else
- v_total_count = vmm.v_kernel_pages +
- vmm.v_free_count + vmm.v_wire_count +
- vmm.v_active_count + vmm.v_inactive_count;
+ v_total_count = vmm.v_kernel_pages +
+ vmm.v_free_count + vmm.v_wire_count +
+ vmm.v_active_count + vmm.v_inactive_count;
#endif
#endif
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- v_used_count = uvmexp.active + uvmexp.inactive;
- v_free_count = uvmexp.free;
+ v_used_count = uvmexp.active + uvmexp.inactive;
+ v_free_count = uvmexp.free;
#else
- v_used_count = vmm.v_active_count + vmm.v_inactive_count;
- v_free_count = vmm.v_free_count;
+ v_used_count = vmm.v_active_count + vmm.v_inactive_count;
+ v_free_count = vmm.v_free_count;
#endif
- buf->total = (u_int64_t) pagetok (v_total_count) << LOG1024;
- buf->used = (u_int64_t) pagetok (v_used_count) << LOG1024;
- buf->free = (u_int64_t) pagetok (v_free_count) << LOG1024;
+ buf->total = (u_int64_t) pagetok (v_total_count) << LOG1024;
+ buf->used = (u_int64_t) pagetok (v_used_count) << LOG1024;
+ buf->free = (u_int64_t) pagetok (v_free_count) << LOG1024;
#ifdef __FreeBSD__
- buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024;
+ buf->cached = (u_int64_t) pagetok (vmm.v_cache_count) << LOG1024;
#endif
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- buf->locked = (u_int64_t) pagetok (uvmexp.wired) << LOG1024;
+ buf->locked = (u_int64_t) pagetok (uvmexp.wired) << LOG1024;
#else
- buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024;
+ buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024;
#endif
- buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
+ buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
#if __FreeBSD__
- buf->buffer = (u_int64_t) bufspace;
+ buf->buffer = (u_int64_t) bufspace;
#else
- buf->buffer = (u_int64_t) pagetok (bufspace) << LOG1024;
+ buf->buffer = (u_int64_t) pagetok (bufspace) << LOG1024;
#endif
- /* user */
- buf->user = buf->total - buf->free - buf->shared - buf->buffer;
+ /* user */
+ buf->user = buf->total - buf->free - buf->shared - buf->buffer;
- /* Set the values to return */
- buf->flags = _glibtop_sysdeps_mem;
+ /* Set the values to return */
+ buf->flags = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/msg_limits.c b/sysdeps/freebsd/msg_limits.c
index cc90a7e1..a3675f2d 100644
--- a/sysdeps/freebsd/msg_limits.c
+++ b/sysdeps/freebsd/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,17 +35,17 @@
int
glibtop_init_msg_limits_p (glibtop *server)
{
- return 0;
+ return 0;
}
int
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- return 0;
+ return 0;
}
#else
@@ -71,8 +73,8 @@ static struct msginfo _msginfo;
/* nlist structure for kernel access */
static struct nlist nlst [] = {
- { "_msginfo" },
- { 0 }
+ { "_msginfo" },
+ { 0 }
};
/* Init function. */
@@ -80,20 +82,20 @@ static struct nlist nlst [] = {
int
glibtop_init_msg_limits_p (glibtop *server)
{
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
- return -1;
- }
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
+ return -1;
+ }
- if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
- &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
- glibtop_warn_io_r (server, "kvm_read (msginfo)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
+ &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
+ glibtop_warn_io_r (server, "kvm_read (msginfo)");
+ return -1;
+ }
- server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
+ server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -101,22 +103,22 @@ glibtop_init_msg_limits_p (glibtop *server)
int
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- if (server->sysdeps.msg_limits == 0)
- return -1;
+ if (server->sysdeps.msg_limits == 0)
+ return -1;
- buf->msgmax = _msginfo.msgmax;
- buf->msgmni = _msginfo.msgmni;
- buf->msgmnb = _msginfo.msgmnb;
- buf->msgtql = _msginfo.msgtql;
- buf->msgssz = _msginfo.msgtql;
+ buf->msgmax = _msginfo.msgmax;
+ buf->msgmni = _msginfo.msgmni;
+ buf->msgmnb = _msginfo.msgmnb;
+ buf->msgtql = _msginfo.msgtql;
+ buf->msgssz = _msginfo.msgtql;
- buf->flags = _glibtop_sysdeps_msg_limits;
+ buf->flags = _glibtop_sysdeps_msg_limits;
- return 0;
+ return 0;
}
#endif /* either a newer BSDI or no BSDI at all. */
diff --git a/sysdeps/freebsd/netinfo.c b/sysdeps/freebsd/netinfo.c
index 43094ed3..b2abe49e 100644
--- a/sysdeps/freebsd/netinfo.c
+++ b/sysdeps/freebsd/netinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -60,7 +62,7 @@ glibtop_init_netinfo_p (glibtop *server)
if (kvm_nlist (server->_priv->machine.kd, nlst) != 0)
glibtop_error_io_r (server, "kvm_nlist");
- return 0;
+ return 0;
}
/* Provides Network statistics. */
@@ -97,12 +99,12 @@ glibtop_get_netinfo_p (glibtop *server, glibtop_netinfo *buf,
if (kvm_read (server->_priv->machine.kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet))
- glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
+ glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
#if defined(__FreeBSD__) || defined(__bsdi__)
if (kvm_read (server->_priv->machine.kd, (u_long) ifnet.if_name,
tname, 16) != 16)
- glibtop_error_io_r (server, "kvm_read (if_name)");
+ glibtop_error_io_r (server, "kvm_read (if_name)");
#else
strncpy (tname, ifnet.if_xname, 16);
tname [15] = 0;
@@ -130,39 +132,39 @@ glibtop_get_netinfo_p (glibtop *server, glibtop_netinfo *buf,
sin = (struct sockaddr_in *)sa;
if (ifnet.if_flags & IFF_UP)
- buf->if_flags |= GLIBTOP_IF_FLAGS_UP;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_UP;
if (ifnet.if_flags & IFF_BROADCAST)
- buf->if_flags |= GLIBTOP_IF_FLAGS_BROADCAST;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_BROADCAST;
if (ifnet.if_flags & IFF_DEBUG)
- buf->if_flags |= GLIBTOP_IF_FLAGS_DEBUG;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_DEBUG;
if (ifnet.if_flags & IFF_LOOPBACK)
- buf->if_flags |= GLIBTOP_IF_FLAGS_LOOPBACK;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_LOOPBACK;
if (ifnet.if_flags & IFF_POINTOPOINT)
- buf->if_flags |= GLIBTOP_IF_FLAGS_POINTOPOINT;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_POINTOPOINT;
if (ifnet.if_flags & IFF_RUNNING)
- buf->if_flags |= GLIBTOP_IF_FLAGS_RUNNING;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_RUNNING;
if (ifnet.if_flags & IFF_NOARP)
- buf->if_flags |= GLIBTOP_IF_FLAGS_NOARP;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_NOARP;
if (ifnet.if_flags & IFF_PROMISC)
- buf->if_flags |= GLIBTOP_IF_FLAGS_PROMISC;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_PROMISC;
if (ifnet.if_flags & IFF_ALLMULTI)
- buf->if_flags |= GLIBTOP_IF_FLAGS_ALLMULTI;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_ALLMULTI;
if (ifnet.if_flags & IFF_OACTIVE)
- buf->if_flags |= GLIBTOP_IF_FLAGS_OACTIVE;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_OACTIVE;
if (ifnet.if_flags & IFF_SIMPLEX)
- buf->if_flags |= GLIBTOP_IF_FLAGS_SIMPLEX;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_SIMPLEX;
if (ifnet.if_flags & IFF_LINK0)
- buf->if_flags |= GLIBTOP_IF_FLAGS_LINK0;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_LINK0;
if (ifnet.if_flags & IFF_LINK1)
- buf->if_flags |= GLIBTOP_IF_FLAGS_LINK1;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_LINK1;
if (ifnet.if_flags & IFF_LINK2)
- buf->if_flags |= GLIBTOP_IF_FLAGS_LINK2;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_LINK2;
#ifdef __FreeBSD__
if (ifnet.if_flags & IFF_ALTPHYS)
- buf->if_flags |= GLIBTOP_IF_FLAGS_ALTPHYS;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_ALTPHYS;
#endif
if (ifnet.if_flags & IFF_MULTICAST)
- buf->if_flags |= GLIBTOP_IF_FLAGS_MULTICAST;
+ buf->if_flags |= GLIBTOP_IF_FLAGS_MULTICAST;
buf->subnet = htonl (ifaddr.in.ia_subnet);
buf->address = sin->sin_addr.s_addr;
diff --git a/sysdeps/freebsd/netload.c b/sysdeps/freebsd/netload.c
index 9d700f12..35a22cab 100644
--- a/sysdeps/freebsd/netload.c
+++ b/sysdeps/freebsd/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -66,7 +68,7 @@ glibtop_init_netload_p (glibtop *server)
if (kvm_nlist (server->_priv->machine.kd, nlst) != 0)
glibtop_error_io_r (server, "kvm_nlist");
- return 0;
+ return 0;
}
/* Provides Network statistics. */
@@ -104,12 +106,12 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
if (kvm_read (server->_priv->machine.kd, ifnetaddr, &ifnet,
sizeof (ifnet)) != sizeof (ifnet))
- glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
+ glibtop_error_io_r (server, "kvm_read (ifnetaddr)");
#if defined(__FreeBSD__) || defined(__bsdi__)
if (kvm_read (server->_priv->machine.kd, (u_long) ifnet.if_name,
tname, 16) != 16)
- glibtop_error_io_r (server, "kvm_read (if_name)");
+ glibtop_error_io_r (server, "kvm_read (if_name)");
#else
strncpy (tname, ifnet.if_xname, 16);
tname [15] = 0;
diff --git a/sysdeps/freebsd/nosuid.c b/sysdeps/freebsd/nosuid.c
index 15edf79a..42eca6c6 100644
--- a/sysdeps/freebsd/nosuid.c
+++ b/sysdeps/freebsd/nosuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/freebsd/open.c b/sysdeps/freebsd/open.c
index bb57a6cd..4b54f649 100644
--- a/sysdeps/freebsd/open.c
+++ b/sysdeps/freebsd/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -31,21 +33,21 @@ void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
- glibtop_init_func_t *init_fkt;
+ glibtop_init_func_t *init_fkt;
- if (server == NULL)
- glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
- glibtop_open_p (server, "glibtop", features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
+ glibtop_open_p (server, "glibtop", features, flags);
- for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
- (*init_fkt) (server);
+ for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
+ (*init_fkt) (server);
- server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
- }
+ server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
+ }
}
void
@@ -54,45 +56,45 @@ glibtop_open_p (glibtop *server, const char *program_name,
const unsigned flags)
{
#ifdef DEBUG
- fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
+ fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
#endif
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- server->_priv->machine.uid = getuid ();
- server->_priv->machine.euid = geteuid ();
- server->_priv->machine.gid = getgid ();
- server->_priv->machine.egid = getegid ();
+ server->_priv->machine.uid = getuid ();
+ server->_priv->machine.euid = geteuid ();
+ server->_priv->machine.gid = getgid ();
+ server->_priv->machine.egid = getegid ();
#ifdef __FreeBSD__
- server->os_version_code = __FreeBSD_version;
+ server->os_version_code = __FreeBSD_version;
#endif
- /* Setup machine-specific data */
- server->_priv->machine.kd = kvm_open
- (NULL, NULL, NULL, O_RDONLY, "kvm_open");
+ /* Setup machine-specific data */
+ server->_priv->machine.kd = kvm_open
+ (NULL, NULL, NULL, O_RDONLY, "kvm_open");
- if (server->_priv->machine.kd == NULL)
- glibtop_error_io_r (server, "kvm_open");
+ if (server->_priv->machine.kd == NULL)
+ glibtop_error_io_r (server, "kvm_open");
- /* Drop priviledges. */
+ /* Drop priviledges. */
- if (setreuid (server->_priv->machine.euid,
- server->_priv->machine.uid))
- _exit (1);
+ if (setreuid (server->_priv->machine.euid,
+ server->_priv->machine.uid))
+ _exit (1);
- if (setregid (server->_priv->machine.egid,
- server->_priv->machine.gid))
- _exit (1);
+ if (setregid (server->_priv->machine.egid,
+ server->_priv->machine.gid))
+ _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- /* Our effective uid is now those of the user invoking the server,
- * so we do no longer have any priviledges. */
-
- /* NOTE: On FreeBSD, we do not need to be suid root, we just need to
- * be sgid kmem.
- *
- * The server will only use setegid() to get back it's priviledges,
- * so it will fail if it is suid root and not sgid kmem. */
+ /* Our effective uid is now those of the user invoking the server,
+ * so we do no longer have any priviledges. */
+
+ /* NOTE: On FreeBSD, we do not need to be suid root, we just need to
+ * be sgid kmem.
+ *
+ * The server will only use setegid() to get back it's priviledges,
+ * so it will fail if it is suid root and not sgid kmem. */
}
diff --git a/sysdeps/freebsd/ppp.c b/sysdeps/freebsd/ppp.c
index cafc92f4..fef0c58d 100644
--- a/sysdeps/freebsd/ppp.c
+++ b/sysdeps/freebsd/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -63,9 +65,9 @@ static const unsigned long _glibtop_sysdeps_ppp_acct =
/* nlist structure for kernel access */
static struct nlist nlst [] = {
#ifdef HAVE_I4B
- { "_i4bisppp_softc" },
+ { "_i4bisppp_softc" },
#endif
- { 0 }
+ { 0 }
};
/* Init function. */
@@ -75,17 +77,17 @@ glibtop_init_ppp_p (glibtop *server)
{
#ifdef HAVE_I4B
#ifdef HAVE_I4B_ACCT
- server->sysdeps.ppp = _glibtop_sysdeps_ppp |
- _glibtop_sysdeps_ppp_acct;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp |
+ _glibtop_sysdeps_ppp_acct;
#else
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
#endif
#endif /* HAVE_I4B */
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0)
- glibtop_error_io_r (server, "kvm_nlist");
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0)
+ glibtop_error_io_r (server, "kvm_nlist");
- return 0;
+ return 0;
}
/* Provides information about ppp usage. */
@@ -95,54 +97,54 @@ glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
#ifdef HAVE_I4B
#ifdef HAVE_I4B_ACCT
- struct i4bisppp_softc data;
+ struct i4bisppp_softc data;
#else
- struct sppp data;
+ struct sppp data;
#endif
- int phase;
+ int phase;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PPP), 0);
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
- if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
- &data, sizeof (data)) != sizeof (data))
- glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");
+ if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
+ &data, sizeof (data)) != sizeof (data))
+ glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)");
#ifdef HAVE_I4B_ACCT
- phase = data.sc_if_un.scu_sp.pp_phase;
+ phase = data.sc_if_un.scu_sp.pp_phase;
#else
- /* FIXME: Which FreeBSD version have this field and
- * which not. */
+ /* FIXME: Which FreeBSD version have this field and
+ * which not. */
#if 0
- phase = data.pp_phase;
+ phase = data.pp_phase;
#endif
#endif
- switch (phase) {
+ switch (phase) {
#ifdef HAVE_I4B_ACCT
- case PHASE_DEAD:
- case PHASE_TERMINATE:
- buf->state = GLIBTOP_PPP_STATE_HANGUP;
- break;
- case PHASE_ESTABLISH:
- case PHASE_NETWORK:
- buf->state = GLIBTOP_PPP_STATE_ONLINE;
- break;
+ case PHASE_DEAD:
+ case PHASE_TERMINATE:
+ buf->state = GLIBTOP_PPP_STATE_HANGUP;
+ break;
+ case PHASE_ESTABLISH:
+ case PHASE_NETWORK:
+ buf->state = GLIBTOP_PPP_STATE_ONLINE;
+ break;
#endif
- default:
- buf->state = GLIBTOP_PPP_STATE_UNKNOWN;
- break;
- }
+ default:
+ buf->state = GLIBTOP_PPP_STATE_UNKNOWN;
+ break;
+ }
- buf->flags = _glibtop_sysdeps_ppp;
+ buf->flags = _glibtop_sysdeps_ppp;
#ifdef HAVE_I4B_ACCT
- buf->bytes_in = data.sc_inb;
- buf->bytes_out = data.sc_outb;
- buf->flags |= _glibtop_sysdeps_ppp_acct;
+ buf->bytes_in = data.sc_inb;
+ buf->bytes_out = data.sc_outb;
+ buf->flags |= _glibtop_sysdeps_ppp_acct;
#endif
#endif /* HAVE_I4B */
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/procargs.c b/sysdeps/freebsd/procargs.c
index 0e222b4d..92b3c580 100644
--- a/sysdeps/freebsd/procargs.c
+++ b/sysdeps/freebsd/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -40,9 +42,9 @@ static const unsigned long _glibtop_sysdeps_proc_args =
int
glibtop_init_proc_args_p (glibtop *server)
{
- server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
+ server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -50,64 +52,64 @@ glibtop_init_proc_args_p (glibtop *server)
char **
glibtop_get_proc_args_p (glibtop *server, glibtop_array *buf, pid_t pid)
{
- struct kinfo_proc *pinfo;
- char *retval, **args, **ptr;
- unsigned size = 0, pos = 0;
- int max_len = BUFSIZ, count;
+ struct kinfo_proc *pinfo;
+ char *retval, **args, **ptr;
+ unsigned size = 0, pos = 0;
+ int max_len = BUFSIZ, count;
#ifndef __bsdi__
- char filename [BUFSIZ];
- struct stat statb;
+ char filename [BUFSIZ];
+ struct stat statb;
#endif
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
- memset (buf, 0, sizeof (glibtop_proc_args));
+ memset (buf, 0, sizeof (glibtop_proc_args));
- /* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
- if (pid < 5) return NULL;
+ /* swapper, init, pagedaemon, vmdaemon, update - this doen't work. */
+ if (pid < 5) return NULL;
#ifndef __bsdi__
- sprintf (filename, "/proc/%d/mem", pid);
- if (stat (filename, &statb)) return NULL;
+ sprintf (filename, "/proc/%d/mem", pid);
+ if (stat (filename, &statb)) return NULL;
#endif
- glibtop_suid_enter (server);
-
- /* Get the process data */
- pinfo = kvm_getprocs (server->_priv->machine.kd,
- KERN_PROC_PID, pid, &count);
- if ((pinfo == NULL) || (count < 1)) {
- glibtop_suid_leave (server);
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
- return NULL;
- }
+ glibtop_suid_enter (server);
- args = kvm_getargv (server->_priv->machine.kd, pinfo, max_len);
- if (args == NULL) {
- glibtop_suid_leave (server);
- glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);
- return NULL;
- }
+ /* Get the process data */
+ pinfo = kvm_getprocs (server->_priv->machine.kd,
+ KERN_PROC_PID, pid, &count);
+ if ((pinfo == NULL) || (count < 1)) {
+ glibtop_suid_leave (server);
+ glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ return NULL;
+ }
+ args = kvm_getargv (server->_priv->machine.kd, pinfo, max_len);
+ if (args == NULL) {
glibtop_suid_leave (server);
+ glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);
+ return NULL;
+ }
+
+ glibtop_suid_leave (server);
- for (ptr = args; *ptr; ptr++)
- size += strlen (*ptr)+1;
+ for (ptr = args; *ptr; ptr++)
+ size += strlen (*ptr)+1;
- size += 2;
- retval = glibtop_malloc_r (server, size);
- memset (retval, 0, size);
+ size += 2;
+ retval = glibtop_malloc_r (server, size);
+ memset (retval, 0, size);
- for (ptr = args; *ptr; ptr++) {
- int len = strlen (*ptr)+1;
- memcpy (retval+pos, *ptr, len);
- pos += len;
- }
+ for (ptr = args; *ptr; ptr++) {
+ int len = strlen (*ptr)+1;
+ memcpy (retval+pos, *ptr, len);
+ pos += len;
+ }
- buf->size = pos ? pos-1 : 0;
+ buf->size = pos ? pos-1 : 0;
- buf->flags = _glibtop_sysdeps_proc_args;
+ buf->flags = _glibtop_sysdeps_proc_args;
- return retval;
+ return retval;
}
diff --git a/sysdeps/freebsd/procdata.c b/sysdeps/freebsd/procdata.c
index 65ec6822..4cd1626a 100644
--- a/sysdeps/freebsd/procdata.c
+++ b/sysdeps/freebsd/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -82,99 +84,99 @@ BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN);
void
glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
{
- char input [BUFSIZ], *tmp;
- struct stat statb;
- int nread;
- FILE *f;
+ char input [BUFSIZ], *tmp;
+ struct stat statb;
+ int nread;
+ FILE *f;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_procdata));
+ memset (buf, 0, sizeof (glibtop_procdata));
- if (pid == 0) {
- /* Client is only interested in the flags. */
- buf->flags [0] = _glibtop_sysdeps_procdata_0;
- buf->flags [1] = _glibtop_sysdeps_procdata_1;
- return;
- }
+ if (pid == 0) {
+ /* Client is only interested in the flags. */
+ buf->flags [0] = _glibtop_sysdeps_procdata_0;
+ buf->flags [1] = _glibtop_sysdeps_procdata_1;
+ return;
+ }
- sprintf (input, "/proc/%d/stat", pid);
+ sprintf (input, "/proc/%d/stat", pid);
- if (stat (input, &statb)) return;
+ if (stat (input, &statb)) return;
- buf->uid = statb.st_uid;
+ buf->uid = statb.st_uid;
- f = fopen (input, "r");
- if (!f) return;
+ f = fopen (input, "r");
+ if (!f) return;
- nread = fread (input, 1, BUFSIZ, f);
+ nread = fread (input, 1, BUFSIZ, f);
- if (nread < 0) {
- fclose (f);
- return;
- }
+ if (nread < 0) {
+ fclose (f);
+ return;
+ }
- input [nread] = 0;
+ input [nread] = 0;
- /* This is from guile-utils/gtop/proc/readproc.c */
+ /* This is from guile-utils/gtop/proc/readproc.c */
- /* split into "PID (cmd" and "<rest>" */
- tmp = strrchr (input, ')');
- *tmp = '\0'; /* replace trailing ')' with NUL */
- /* parse these two strings separately, skipping the leading "(". */
- memset (buf->cmd, 0, sizeof (buf->cmd));
- sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
- sscanf(tmp + 2, /* skip space after ')' too */
- "%c %d %d %d %d %d %lu %lu %lu %lu %lu "
- "%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
- "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
- &buf->state, &buf->ppid, &buf->pgrp, &buf->session,
- &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
- &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
- &buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
- &buf->priority, &buf->nice, &buf->timeout,
- &buf->it_real_value, &buf->start_time, &buf->vsize,
- &buf->rss, &buf->rss_rlim, &buf->start_code,
- &buf->end_code, &buf->start_stack, &buf->kstk_esp,
- &buf->kstk_eip, &buf->signal, &buf->blocked,
- &buf->sigignore, &buf->sigcatch, &buf->wchan);
-
- if (buf->tty == 0)
- /* the old notty val, update elsewhere bef. moving to 0 */
- buf->tty = -1;
-
- if (server->os_version_code < LINUX_VERSION(1,3,39)) {
- /* map old meanings to new */
- buf->priority = 2*15 - buf->priority;
- buf->nice = 15 - buf->nice;
- }
- if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
- /* when tty wasn't full devno */
- buf->tty = 4*0x100 + buf->tty;
+ /* split into "PID (cmd" and "<rest>" */
+ tmp = strrchr (input, ')');
+ *tmp = '\0'; /* replace trailing ')' with NUL */
+ /* parse these two strings separately, skipping the leading "(". */
+ memset (buf->cmd, 0, sizeof (buf->cmd));
+ sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
+ sscanf(tmp + 2, /* skip space after ')' too */
+ "%c %d %d %d %d %d %lu %lu %lu %lu %lu "
+ "%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
+ "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
+ &buf->state, &buf->ppid, &buf->pgrp, &buf->session,
+ &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
+ &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
+ &buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
+ &buf->priority, &buf->nice, &buf->timeout,
+ &buf->it_real_value, &buf->start_time, &buf->vsize,
+ &buf->rss, &buf->rss_rlim, &buf->start_code,
+ &buf->end_code, &buf->start_stack, &buf->kstk_esp,
+ &buf->kstk_eip, &buf->signal, &buf->blocked,
+ &buf->sigignore, &buf->sigcatch, &buf->wchan);
+
+ if (buf->tty == 0)
+ /* the old notty val, update elsewhere bef. moving to 0 */
+ buf->tty = -1;
+
+ if (server->os_version_code < LINUX_VERSION(1,3,39)) {
+ /* map old meanings to new */
+ buf->priority = 2*15 - buf->priority;
+ buf->nice = 15 - buf->nice;
+ }
+ if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
+ /* when tty wasn't full devno */
+ buf->tty = 4*0x100 + buf->tty;
- fclose (f);
+ fclose (f);
- sprintf (input, "/proc/%d/statm", pid);
+ sprintf (input, "/proc/%d/statm", pid);
- f = fopen (input, "r");
- if (!f) return;
+ f = fopen (input, "r");
+ if (!f) return;
- nread = fread (input, 1, BUFSIZ, f);
+ nread = fread (input, 1, BUFSIZ, f);
- if (nread < 0) {
- fclose (f);
- return;
- }
+ if (nread < 0) {
+ fclose (f);
+ return;
+ }
- input [nread] = 0;
+ input [nread] = 0;
- sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
- &buf->size, &buf->resident, &buf->share,
- &buf->trs, &buf->lrs, &buf->drs, &buf->dt);
+ sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
+ &buf->size, &buf->resident, &buf->share,
+ &buf->trs, &buf->lrs, &buf->drs, &buf->dt);
- fclose (f);
+ fclose (f);
- buf->flags [0] = _glibtop_sysdeps_procdata_0;
- buf->flags [1] = _glibtop_sysdeps_procdata_1;
+ buf->flags [0] = _glibtop_sysdeps_procdata_0;
+ buf->flags [1] = _glibtop_sysdeps_procdata_1;
}
diff --git a/sysdeps/freebsd/prockernel.c b/sysdeps/freebsd/prockernel.c
index 0890a4a5..832c81c4 100644
--- a/sysdeps/freebsd/prockernel.c
+++ b/sysdeps/freebsd/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -67,11 +69,11 @@ static const unsigned long _glibtop_sysdeps_proc_kernel_wchan =
int
glibtop_init_proc_kernel_p (glibtop *server)
{
- server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
- _glibtop_sysdeps_proc_kernel_pcb |
- _glibtop_sysdeps_proc_kernel_wchan;
+ server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
+ _glibtop_sysdeps_proc_kernel_pcb |
+ _glibtop_sysdeps_proc_kernel_wchan;
- return 0;
+ return 0;
}
int
@@ -79,111 +81,111 @@ glibtop_get_proc_kernel_p (glibtop *server,
glibtop_proc_kernel *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
- struct user *u_addr = (struct user *)USRSTACK;
- struct pstats pstats;
- struct pcb pcb;
- int count;
+ struct kinfo_proc *pinfo;
+ struct user *u_addr = (struct user *)USRSTACK;
+ struct pstats pstats;
+ struct pcb pcb;
+ int count;
- char filename [BUFSIZ];
- struct stat statb;
+ char filename [BUFSIZ];
+ struct stat statb;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
- if (server->sysdeps.proc_time == 0)
- return -1;
+ if (server->sysdeps.proc_time == 0)
+ return -1;
- /* 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_error_io_r (server, "kvm_getprocs (%d)", pid);
-
- buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
- buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
-
- if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
- strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
- sizeof (buf->wchan) - 1);
- buf->wchan [sizeof (buf->wchan) - 1] = 0;
- buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
- } else {
- buf->wchan [0] = 0;
+ /* Get the process information */
+ pinfo = kvm_getprocs (server->_priv->machine.kd,
+ KERN_PROC_PID, pid, &count);
+ if ((pinfo == NULL) || (count != 1))
+ glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+
+ buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
+ buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
+
+ if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
+ strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
+ sizeof (buf->wchan) - 1);
+ buf->wchan [sizeof (buf->wchan) - 1] = 0;
+ buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
+ } else {
+ buf->wchan [0] = 0;
+ }
+
+ /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */
+
+ /* [FIXME]: /usr/include/sys/user.h tells me that the user area
+ * may or may not be at the same kernel address in all
+ * processes, but I don't see any way to get that address.
+ * Since `ps' simply uses its own address, I think it's
+ * safe to do this here, too. */
+
+ /* NOTE: You need to mount the /proc filesystem to make
+ * `kvm_uread' work. */
+
+ sprintf (filename, "/proc/%d/mem", (int) pid);
+ if (stat (filename, &statb)) return -1;
+
+ glibtop_suid_enter (server);
+
+ if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+ kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
+ (unsigned long) &u_addr->u_stats,
+ (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
+ {
+ /*
+ * The u-area might be swapped out, and we can't get
+ * at it because we have a crashdump and no swap.
+ * If it's here fill in these fields, otherwise, just
+ * leave them 0.
+ */
+
+ buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt;
+ buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt;
+ buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt;
+ buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt;
+
+ buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
}
- /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */
-
- /* [FIXME]: /usr/include/sys/user.h tells me that the user area
- * may or may not be at the same kernel address in all
- * processes, but I don't see any way to get that address.
- * Since `ps' simply uses its own address, I think it's
- * safe to do this here, too. */
-
- /* NOTE: You need to mount the /proc filesystem to make
- * `kvm_uread' work. */
-
- sprintf (filename, "/proc/%d/mem", (int) pid);
- if (stat (filename, &statb)) return -1;
-
- glibtop_suid_enter (server);
-
- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
- kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
- (unsigned long) &u_addr->u_stats,
- (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
- {
- /*
- * The u-area might be swapped out, and we can't get
- * at it because we have a crashdump and no swap.
- * If it's here fill in these fields, otherwise, just
- * leave them 0.
- */
-
- buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt;
- buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt;
- buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt;
- buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt;
-
- buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
- }
-
- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
- kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
- (unsigned long) &u_addr->u_pcb,
- (char *) &pcb, sizeof (pcb)) == sizeof (pcb))
- {
+ if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+ kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
+ (unsigned long) &u_addr->u_pcb,
+ (char *) &pcb, sizeof (pcb)) == sizeof (pcb))
+ {
#ifdef __FreeBSD__
#ifndef __alpha__
#if (__FreeBSD_version >= 300003)
- buf->kstk_esp = (u_int64_t) pcb.pcb_esp;
- buf->kstk_eip = (u_int64_t) pcb.pcb_eip;
+ buf->kstk_esp = (u_int64_t) pcb.pcb_esp;
+ buf->kstk_eip = (u_int64_t) pcb.pcb_eip;
#else
- buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
- buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
+ buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
+ buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
#endif
#else
- /*xxx FreeBSD/Alpha? */
+ /*xxx FreeBSD/Alpha? */
#endif
#else
- buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
+ buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
#ifdef __bsdi__
- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
+ buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
#else
- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
+ buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
#endif
- buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
+ buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
#endif
- }
+ }
- /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
+ /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/proclist.c b/sysdeps/freebsd/proclist.c
index e1a59f83..bb4e0de8 100644
--- a/sysdeps/freebsd/proclist.c
+++ b/sysdeps/freebsd/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -55,51 +57,51 @@ static const unsigned long _glibtop_sysdeps_proclist =
int
glibtop_init_proclist_p (glibtop *server)
{
- server->sysdeps.proclist = _glibtop_sysdeps_proclist;
+ server->sysdeps.proclist = _glibtop_sysdeps_proclist;
- return 0;
+ return 0;
}
unsigned *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
int64_t real_which, int64_t arg)
{
- struct kinfo_proc *pinfo;
- unsigned *pids = NULL;
- int which, count;
- int i,j;
+ struct kinfo_proc *pinfo;
+ unsigned *pids = NULL;
+ int which, count;
+ int i,j;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
- memset (buf, 0, sizeof (glibtop_proclist));
-
- which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
-
- /* Get the process data */
- pinfo = kvm_getprocs (server->_priv->machine.kd, which, arg, &count);
- if ((pinfo == NULL) || (count < 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
- return NULL;
- }
- count--;
-
- /* Allocate count objects in the pids_chain array
- * Same as malloc is pids is NULL, which it is. */
- pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned));
- /* Copy the pids over to this chain */
- for (i=j=0; i < count; i++) {
- if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
- (pinfo[i].kp_proc.p_stat != SRUN))
- continue;
- else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) &&
- (pinfo[i].kp_eproc.e_pcred.p_ruid == 0))
- continue;
- pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid;
- } /* end for */
- /* Set the fields in buf */
- buf->number = j;
- buf->size = sizeof (unsigned);
- buf->total = j * sizeof (unsigned);
- buf->flags = _glibtop_sysdeps_proclist;
- return pids;
+ memset (buf, 0, sizeof (glibtop_proclist));
+
+ which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
+
+ /* Get the process data */
+ pinfo = kvm_getprocs (server->_priv->machine.kd, which, arg, &count);
+ if ((pinfo == NULL) || (count < 1)) {
+ glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
+ return NULL;
+ }
+ count--;
+
+ /* Allocate count objects in the pids_chain array
+ * Same as malloc is pids is NULL, which it is. */
+ pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned));
+ /* Copy the pids over to this chain */
+ for (i=j=0; i < count; i++) {
+ if ((real_which & GLIBTOP_EXCLUDE_IDLE) &&
+ (pinfo[i].kp_proc.p_stat != SRUN))
+ continue;
+ else if ((real_which & GLIBTOP_EXCLUDE_SYSTEM) &&
+ (pinfo[i].kp_eproc.e_pcred.p_ruid == 0))
+ continue;
+ pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid;
+ } /* end for */
+ /* Set the fields in buf */
+ buf->number = j;
+ buf->size = sizeof (unsigned);
+ buf->total = j * sizeof (unsigned);
+ buf->flags = _glibtop_sysdeps_proclist;
+ return pids;
}
diff --git a/sysdeps/freebsd/procmap.c b/sysdeps/freebsd/procmap.c
index da343083..686caebb 100644
--- a/sysdeps/freebsd/procmap.c
+++ b/sysdeps/freebsd/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -70,9 +72,9 @@ static const unsigned long _glibtop_sysdeps_map_entry =
int
glibtop_init_proc_map_p (glibtop *server)
{
- server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -81,189 +83,189 @@ glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
- struct vm_map_entry entry, *first;
- struct vmspace vmspace;
+ struct kinfo_proc *pinfo;
+ struct vm_map_entry entry, *first;
+ struct vmspace vmspace;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- struct vnode vnode;
- struct inode inode;
+ struct vnode vnode;
+ struct inode inode;
#else
- struct vm_object object;
+ struct vm_object object;
#endif
- glibtop_map_entry *maps;
+ glibtop_map_entry *maps;
#if defined __FreeBSD__
- struct vnode vnode;
- struct inode inode;
- struct mount mount;
+ struct vnode vnode;
+ struct inode inode;
+ struct mount mount;
#endif
- int count, i = 0;
- int update = 0;
+ int count, i = 0;
+ int update = 0;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MAP), 0);
- memset (buf, 0, sizeof (glibtop_proc_map));
+ memset (buf, 0, sizeof (glibtop_proc_map));
- /* It does not work for the swapper task. */
- if (pid == 0) return NULL;
+ /* It does not work for the swapper task. */
+ if (pid == 0) return NULL;
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- /* Get the process data */
- pinfo = kvm_getprocs (server->_priv->machine.kd,
- KERN_PROC_PID, pid, &count);
- if ((pinfo == NULL) || (count < 1))
- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+ /* Get the process data */
+ pinfo = kvm_getprocs (server->_priv->machine.kd,
+ KERN_PROC_PID, pid, &count);
+ if ((pinfo == NULL) || (count < 1))
+ glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
- /* Now we get the memory maps. */
+ /* Now we get the memory maps. */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) pinfo [0].kp_proc.p_vmspace,
- (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
- glibtop_error_io_r (server, "kvm_read (vmspace)");
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) pinfo [0].kp_proc.p_vmspace,
+ (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
+ glibtop_error_io_r (server, "kvm_read (vmspace)");
- first = vmspace.vm_map.header.next;
+ first = vmspace.vm_map.header.next;
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) vmspace.vm_map.header.next,
- (char *) &entry, sizeof (entry)) != sizeof (entry))
- glibtop_error_io_r (server, "kvm_read (entry)");
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) vmspace.vm_map.header.next,
+ (char *) &entry, sizeof (entry)) != sizeof (entry))
+ glibtop_error_io_r (server, "kvm_read (entry)");
- /* Allocate space. */
+ /* Allocate space. */
- buf->number = vmspace.vm_map.nentries;
- buf->size = sizeof (glibtop_map_entry);
+ buf->number = vmspace.vm_map.nentries;
+ buf->size = sizeof (glibtop_map_entry);
- buf->total = buf->number * buf->size;
+ buf->total = buf->number * buf->size;
- maps = glibtop_malloc_r (server, buf->total);
+ maps = glibtop_malloc_r (server, buf->total);
- memset (maps, 0, buf->total);
+ memset (maps, 0, buf->total);
- buf->flags = _glibtop_sysdeps_proc_map;
+ buf->flags = _glibtop_sysdeps_proc_map;
- /* Walk through the `vm_map_entry' list ... */
+ /* Walk through the `vm_map_entry' list ... */
- /* I tested this a few times with `mmap'; as soon as you write
- * to the mmap'ed area, the object type changes from OBJT_VNODE
- * to OBJT_DEFAULT so if seems this really works. */
+ /* I tested this a few times with `mmap'; as soon as you write
+ * to the mmap'ed area, the object type changes from OBJT_VNODE
+ * to OBJT_DEFAULT so if seems this really works. */
- do {
- if (update) {
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.next,
- &entry, sizeof (entry)) != sizeof (entry))
- glibtop_error_io_r (server, "kvm_read (entry)");
- } else {
- update = 1;
- }
+ do {
+ if (update) {
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.next,
+ &entry, sizeof (entry)) != sizeof (entry))
+ glibtop_error_io_r (server, "kvm_read (entry)");
+ } else {
+ update = 1;
+ }
#ifdef __FreeBSD__
#if __FreeBSD__ >= 4
- if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP))
- continue;
+ if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP))
+ continue;
#else
- if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
- continue;
+ if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
+ continue;
#endif
#else
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (UVM_ET_ISSUBMAP (&entry))
- continue;
+ if (UVM_ET_ISSUBMAP (&entry))
+ continue;
#else
- if (entry.is_a_map || entry.is_sub_map)
- continue;
+ if (entry.is_a_map || entry.is_sub_map)
+ continue;
#endif
#endif
- maps [i].flags = _glibtop_sysdeps_map_entry;
+ maps [i].flags = _glibtop_sysdeps_map_entry;
- maps [i].start = entry.start;
- maps [i].end = entry.end;
- maps [i].offset = entry.offset;
+ maps [i].start = entry.start;
+ maps [i].end = entry.end;
+ maps [i].offset = entry.offset;
- maps [i].perm = 0;
+ maps [i].perm = 0;
- if (entry.protection & VM_PROT_READ)
- maps [i].perm |= GLIBTOP_MAP_PERM_READ;
- if (entry.protection & VM_PROT_WRITE)
- maps [i].perm |= GLIBTOP_MAP_PERM_WRITE;
- if (entry.protection & VM_PROT_EXECUTE)
- maps [i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
+ if (entry.protection & VM_PROT_READ)
+ maps [i].perm |= GLIBTOP_MAP_PERM_READ;
+ if (entry.protection & VM_PROT_WRITE)
+ maps [i].perm |= GLIBTOP_MAP_PERM_WRITE;
+ if (entry.protection & VM_PROT_EXECUTE)
+ maps [i].perm |= GLIBTOP_MAP_PERM_EXECUTE;
- i++;
+ i++;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (!entry.object.uvm_obj)
- continue;
+ if (!entry.object.uvm_obj)
+ continue;
- /* We're only interested in vnodes */
+ /* We're only interested in vnodes */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.object.uvm_obj,
- &vnode, sizeof (vnode)) != sizeof (vnode)) {
- glibtop_warn_io_r (server, "kvm_read (vnode)");
- return NULL;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.object.uvm_obj,
+ &vnode, sizeof (vnode)) != sizeof (vnode)) {
+ glibtop_warn_io_r (server, "kvm_read (vnode)");
+ return NULL;
+ }
#else
- if (!entry.object.vm_object)
- continue;
+ if (!entry.object.vm_object)
+ continue;
- /* We're only interested in `vm_object's */
+ /* We're only interested in `vm_object's */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.object.vm_object,
- &object, sizeof (object)) != sizeof (object))
- glibtop_error_io_r (server, "kvm_read (object)");
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.object.vm_object,
+ &object, sizeof (object)) != sizeof (object))
+ glibtop_error_io_r (server, "kvm_read (object)");
#endif
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
- continue;
+ if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
+ continue;
- if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
- !vnode.v_data) continue;
+ if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
+ !vnode.v_data) continue;
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) vnode.v_data,
- &inode, sizeof (inode)) != sizeof (inode))
- glibtop_error_io_r (server, "kvm_read (inode)");
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) vnode.v_data,
+ &inode, sizeof (inode)) != sizeof (inode))
+ glibtop_error_io_r (server, "kvm_read (inode)");
- maps [i-1].inode = inode.i_number;
- maps [i-1].device = inode.i_dev;
+ maps [i-1].inode = inode.i_number;
+ maps [i-1].device = inode.i_dev;
#endif
#ifdef __FreeBSD__
- /* If the object is of type vnode, add its size */
+ /* If the object is of type vnode, add its size */
- if (object.type != OBJT_VNODE)
- continue;
+ if (object.type != OBJT_VNODE)
+ continue;
- if (!object.handle)
- continue;
+ if (!object.handle)
+ continue;
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) object.handle,
- &vnode, sizeof (vnode)) != sizeof (vnode))
- glibtop_error_io_r (server, "kvm_read (vnode)");
-
- if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
- !vnode.v_data) continue;
-
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) vnode.v_data,
- &inode, sizeof (inode)) != sizeof (inode))
- glibtop_error_io_r (server, "kvm_read (inode)");
-
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) vnode.v_mount,
- &mount, sizeof (mount)) != sizeof (mount))
- glibtop_error_io_r (server, "kvm_read (mount)");
-
- maps [i-1].inode = inode.i_number;
- maps [i-1].device = inode.i_dev;
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) object.handle,
+ &vnode, sizeof (vnode)) != sizeof (vnode))
+ glibtop_error_io_r (server, "kvm_read (vnode)");
+
+ if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
+ !vnode.v_data) continue;
+
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) vnode.v_data,
+ &inode, sizeof (inode)) != sizeof (inode))
+ glibtop_error_io_r (server, "kvm_read (inode)");
+
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) vnode.v_mount,
+ &mount, sizeof (mount)) != sizeof (mount))
+ glibtop_error_io_r (server, "kvm_read (mount)");
+
+ maps [i-1].inode = inode.i_number;
+ maps [i-1].device = inode.i_dev;
#endif
- } while (entry.next != first);
+ } while (entry.next != first);
- return maps;
+ return maps;
}
diff --git a/sysdeps/freebsd/procmem.c b/sysdeps/freebsd/procmem.c
index a1032081..8fb6b999 100644
--- a/sysdeps/freebsd/procmem.c
+++ b/sysdeps/freebsd/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -84,24 +86,24 @@ static int pageshift; /* log base 2 of the pagesize */
int
glibtop_init_proc_mem_p (glibtop *server)
{
- register int pagesize;
-
- /* get the page size with "getpagesize" and calculate pageshift
- * from it */
- pagesize = getpagesize ();
- pageshift = 0;
- while (pagesize > 1) {
- pageshift++;
- pagesize >>= 1;
- }
+ register int pagesize;
+
+ /* get the page size with "getpagesize" and calculate pageshift
+ * from it */
+ pagesize = getpagesize ();
+ pageshift = 0;
+ while (pagesize > 1) {
+ pageshift++;
+ pagesize >>= 1;
+ }
- /* we only need the amount of log(2)1024 for our conversion */
- pageshift -= LOG1024;
+ /* we only need the amount of log(2)1024 for our conversion */
+ pageshift -= LOG1024;
- server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
- _glibtop_sysdeps_proc_mem_share;
+ server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
+ _glibtop_sysdeps_proc_mem_share;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -110,155 +112,155 @@ int
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
- struct vm_map_entry entry, *first;
- struct vmspace *vms, vmspace;
+ struct kinfo_proc *pinfo;
+ struct vm_map_entry entry, *first;
+ struct vmspace *vms, vmspace;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- struct vnode vnode;
- struct inode inode;
+ struct vnode vnode;
+ struct inode inode;
#else
- struct vm_object object;
+ struct vm_object object;
#endif
- struct plimit plimit;
- int count;
+ struct plimit plimit;
+ int count;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- if (server->sysdeps.proc_mem == 0)
- return -1;
+ if (server->sysdeps.proc_mem == 0)
+ return -1;
- /* 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 data */
- 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;
- }
-
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) pinfo [0].kp_proc.p_limit,
- (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {
- glibtop_warn_io_r (server, "kvm_read (plimit)");
- return -1;
- }
-
- buf->rss_rlim = (u_int64_t)
- (plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);
+ /* Get the process data */
+ 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;
+ }
+
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) pinfo [0].kp_proc.p_limit,
+ (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {
+ glibtop_warn_io_r (server, "kvm_read (plimit)");
+ return -1;
+ }
+
+ buf->rss_rlim = (u_int64_t)
+ (plimit.pl_rlimit [RLIMIT_RSS].rlim_cur);
- vms = &pinfo [0].kp_eproc.e_vm;
+ vms = &pinfo [0].kp_eproc.e_vm;
- buf->vsize = buf->size = (u_int64_t) pagetok
- (vms->vm_tsize + vms->vm_dsize + vms->vm_ssize) << LOG1024;
+ buf->vsize = buf->size = (u_int64_t) pagetok
+ (vms->vm_tsize + vms->vm_dsize + vms->vm_ssize) << LOG1024;
- buf->resident = buf->rss = (u_int64_t) pagetok
- (vms->vm_rssize) << LOG1024;
+ buf->resident = buf->rss = (u_int64_t) pagetok
+ (vms->vm_rssize) << LOG1024;
- /* Now we get the shared memory. */
+ /* Now we get the shared memory. */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) pinfo [0].kp_proc.p_vmspace,
- (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
- glibtop_warn_io_r (server, "kvm_read (vmspace)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) pinfo [0].kp_proc.p_vmspace,
+ (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
+ glibtop_warn_io_r (server, "kvm_read (vmspace)");
+ return -1;
+ }
- first = vmspace.vm_map.header.next;
+ first = vmspace.vm_map.header.next;
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) vmspace.vm_map.header.next,
- (char *) &entry, sizeof (entry)) != sizeof (entry)) {
- glibtop_warn_io_r (server, "kvm_read (entry)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) vmspace.vm_map.header.next,
+ (char *) &entry, sizeof (entry)) != sizeof (entry)) {
+ glibtop_warn_io_r (server, "kvm_read (entry)");
+ return -1;
+ }
- /* Walk through the `vm_map_entry' list ... */
+ /* Walk through the `vm_map_entry' list ... */
- /* I tested this a few times with `mmap'; as soon as you write
- * to the mmap'ed area, the object type changes from OBJT_VNODE
- * to OBJT_DEFAULT so if seems this really works. */
+ /* I tested this a few times with `mmap'; as soon as you write
+ * to the mmap'ed area, the object type changes from OBJT_VNODE
+ * to OBJT_DEFAULT so if seems this really works. */
- while (entry.next != first) {
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.next,
- &entry, sizeof (entry)) != sizeof (entry)) {
- glibtop_warn_io_r (server, "kvm_read (entry)");
- return -1;
- }
+ while (entry.next != first) {
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.next,
+ &entry, sizeof (entry)) != sizeof (entry)) {
+ glibtop_warn_io_r (server, "kvm_read (entry)");
+ return -1;
+ }
#ifdef __FreeBSD__
#if __FreeBSD__ >= 4
- if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP))
- continue;
+ if (entry.eflags & (MAP_ENTRY_IS_SUB_MAP))
+ continue;
#else
- if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
- continue;
+ if (entry.eflags & (MAP_ENTRY_IS_A_MAP|MAP_ENTRY_IS_SUB_MAP))
+ continue;
#endif
#else
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (UVM_ET_ISSUBMAP (&entry))
- continue;
+ if (UVM_ET_ISSUBMAP (&entry))
+ continue;
#else
- if (entry.is_a_map || entry.is_sub_map)
- continue;
+ if (entry.is_a_map || entry.is_sub_map)
+ continue;
#endif
#endif
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (!entry.object.uvm_obj)
- continue;
+ if (!entry.object.uvm_obj)
+ continue;
- /* We're only interested in vnodes */
+ /* We're only interested in vnodes */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.object.uvm_obj,
- &vnode, sizeof (vnode)) != sizeof (vnode)) {
- glibtop_warn_io_r (server, "kvm_read (vnode)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.object.uvm_obj,
+ &vnode, sizeof (vnode)) != sizeof (vnode)) {
+ glibtop_warn_io_r (server, "kvm_read (vnode)");
+ return -1;
+ }
#else
- if (!entry.object.vm_object)
- continue;
+ if (!entry.object.vm_object)
+ continue;
- /* We're only interested in `vm_object's */
+ /* We're only interested in `vm_object's */
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) entry.object.vm_object,
- &object, sizeof (object)) != sizeof (object)) {
- glibtop_warn_io_r (server, "kvm_read (object)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) entry.object.vm_object,
+ &object, sizeof (object)) != sizeof (object)) {
+ glibtop_warn_io_r (server, "kvm_read (object)");
+ return -1;
+ }
#endif
- /* If the object is of type vnode, add its size */
+ /* If the object is of type vnode, add its size */
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
- continue;
+ if (!vnode.v_uvm.u_flags & UVM_VNODE_VALID)
+ continue;
- if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
- !vnode.v_data) continue;
+ if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
+ !vnode.v_data) continue;
- /* Reference count must be at least two. */
- if (vnode.v_uvm.u_obj.uo_refs <= 1)
- continue;
+ /* Reference count must be at least two. */
+ if (vnode.v_uvm.u_obj.uo_refs <= 1)
+ continue;
- buf->share += pagetok (vnode.v_uvm.u_obj.uo_npages) << LOG1024;
+ buf->share += pagetok (vnode.v_uvm.u_obj.uo_npages) << LOG1024;
#endif
#ifdef __FreeBSD__
- if (object.type != OBJT_VNODE)
- continue;
+ if (object.type != OBJT_VNODE)
+ continue;
- buf->share += object.un_pager.vnp.vnp_size;
+ buf->share += object.un_pager.vnp.vnp_size;
#endif
- }
+ }
- buf->flags = _glibtop_sysdeps_proc_mem |
- _glibtop_sysdeps_proc_mem_share;
+ buf->flags = _glibtop_sysdeps_proc_mem |
+ _glibtop_sysdeps_proc_mem_share;
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/procsegment.c b/sysdeps/freebsd/procsegment.c
index b458fa9c..b216561b 100644
--- a/sysdeps/freebsd/procsegment.c
+++ b/sysdeps/freebsd/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -38,9 +40,9 @@ static const unsigned long _glibtop_sysdeps_proc_segment = 0;
int
glibtop_init_proc_segment_p (glibtop *server)
{
- server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
+ server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -50,37 +52,37 @@ glibtop_get_proc_segment_p (glibtop *server,
glibtop_proc_segment *buf,
pid_t pid)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
#if 0
- /* Get the process info from the kernel */
- kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, count);
- if (*count != 1) {
- return -1; /* the zeroed-out buffer indicating no data */
- }
-
- /* trs: text resident set size
- pinfo[0]->kp_eproc.e_xrssize;
- */
- /* buf->trs = pinfo[0]->kp_eproc.e_xrssize; */
- /* lrs: shared-lib resident set size
- ? */
- /* drs: data resident set size
- pinfo[0]->kp_eproc.e_vm.vm_map.vm_dsize;
- */
- /* dt: dirty pages
- */
- /* start_code: address of beginning of code segment
+ /* Get the process info from the kernel */
+ kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, count);
+ if (*count != 1) {
+ return -1; /* the zeroed-out buffer indicating no data */
+ }
+
+ /* trs: text resident set size
+ pinfo[0]->kp_eproc.e_xrssize;
+ */
+ /* buf->trs = pinfo[0]->kp_eproc.e_xrssize; */
+ /* lrs: shared-lib resident set size
+ ? */
+ /* drs: data resident set size
+ pinfo[0]->kp_eproc.e_vm.vm_map.vm_dsize;
+ */
+ /* dt: dirty pages
+ */
+ /* start_code: address of beginning of code segment
- */
- /* end_code: address of end of code segment
- */
- /* start_stack: address of the bottom of stack segment
- */
+ */
+ /* end_code: address of end of code segment
+ */
+ /* start_stack: address of the bottom of stack segment
+ */
#endif
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/procsignal.c b/sysdeps/freebsd/procsignal.c
index 9858d47b..5bcd3f92 100644
--- a/sysdeps/freebsd/procsignal.c
+++ b/sysdeps/freebsd/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -42,9 +44,9 @@ static const unsigned long _glibtop_sysdeps_proc_signal =
int
glibtop_init_proc_signal_p (glibtop *server)
{
- server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
+ server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
int
@@ -52,61 +54,61 @@ glibtop_get_proc_signal_p (glibtop *server,
glibtop_proc_signal *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
- int count = 0;
+ struct kinfo_proc *pinfo;
+ int count = 0;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- /* 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;
- }
-
- /* signal: mask of pending signals.
- * pinfo [0].kp_proc.p_siglist
- */
+ /* 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;
+ }
+
+ /* signal: mask of pending signals.
+ * pinfo [0].kp_proc.p_siglist
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->signal [0] = pinfo [0].kp_proc.p_siglist.__bits[0];
+ buf->signal [0] = pinfo [0].kp_proc.p_siglist.__bits[0];
#else
- buf->signal [0] = pinfo [0].kp_proc.p_siglist;
+ buf->signal [0] = pinfo [0].kp_proc.p_siglist;
#endif
- /* blocked: mask of blocked signals.
- * pinfo [0].kp_proc.p_sigmask
- */
+ /* blocked: mask of blocked signals.
+ * pinfo [0].kp_proc.p_sigmask
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->blocked [0] = pinfo [0].kp_proc.p_sigmask.__bits[0];
+ buf->blocked [0] = pinfo [0].kp_proc.p_sigmask.__bits[0];
#else
- buf->blocked [0] = pinfo [0].kp_proc.p_sigmask;
+ buf->blocked [0] = pinfo [0].kp_proc.p_sigmask;
#endif
- /* sigignore: mask of ignored signals.
- * pinfo [0].kp_proc.p_sigignore
- */
+ /* sigignore: mask of ignored signals.
+ * pinfo [0].kp_proc.p_sigignore
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore.__bits[0];
+ buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore.__bits[0];
#else
- buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore;
+ buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore;
#endif
- /* sigcatch: mask of caught signals.
- * pinfo [0].kp_proc.p_sigcatch
- */
+ /* sigcatch: mask of caught signals.
+ * pinfo [0].kp_proc.p_sigcatch
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch.__bits[0];
+ buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch.__bits[0];
#else
- buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch;
+ buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch;
#endif
- buf->flags = _glibtop_sysdeps_proc_signal;
+ buf->flags = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/procstate.c b/sysdeps/freebsd/procstate.c
index c000838d..1839f2e7 100644
--- a/sysdeps/freebsd/procstate.c
+++ b/sysdeps/freebsd/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -48,10 +50,10 @@ static const unsigned long _glibtop_sysdeps_proc_state_new =
int
glibtop_init_proc_state_p (glibtop *server)
{
- server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
- _glibtop_sysdeps_proc_state_new;
+ server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
+ _glibtop_sysdeps_proc_state_new;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -61,82 +63,82 @@ glibtop_get_proc_state_p (glibtop *server,
glibtop_proc_state *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
- int count = 0;
+ struct kinfo_proc *pinfo;
+ int count = 0;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- /* 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;
+ }
- strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1);
- buf->cmd [sizeof (buf->cmd)-1] = 0;
+ strncpy (buf->cmd, pinfo [0].kp_proc.p_comm, sizeof (buf->cmd)-1);
+ buf->cmd [sizeof (buf->cmd)-1] = 0;
- buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
- buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
+ buf->uid = pinfo [0].kp_eproc.e_pcred.p_svuid;
+ buf->gid = pinfo [0].kp_eproc.e_pcred.p_svgid;
#if LIBGTOP_VERSION_CODE >= 1001000
- buf->ruid = pinfo [0].kp_eproc.e_pcred.p_ruid;
- buf->rgid = pinfo [0].kp_eproc.e_pcred.p_rgid;
+ buf->ruid = pinfo [0].kp_eproc.e_pcred.p_ruid;
+ buf->rgid = pinfo [0].kp_eproc.e_pcred.p_rgid;
#endif
- /* Set the flags for the data we're about to return*/
- buf->flags = _glibtop_sysdeps_proc_state |
- _glibtop_sysdeps_proc_state_new;
+ /* Set the flags for the data we're about to return*/
+ buf->flags = _glibtop_sysdeps_proc_state |
+ _glibtop_sysdeps_proc_state_new;
#if LIBGTOP_VERSION_CODE >= 1001000
- switch (pinfo [0].kp_proc.p_stat) {
- case SIDL:
- buf->state = 0;
- break;
- case SRUN:
- buf->state = GLIBTOP_PROCESS_RUNNING;
- break;
- case SSLEEP:
- buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
- break;
- case SSTOP:
- buf->state = GLIBTOP_PROCESS_STOPPED;
- break;
- case SZOMB:
- buf->state = GLIBTOP_PROCESS_ZOMBIE;
- break;
- default:
- return -1;
- }
+ switch (pinfo [0].kp_proc.p_stat) {
+ case SIDL:
+ buf->state = 0;
+ break;
+ case SRUN:
+ buf->state = GLIBTOP_PROCESS_RUNNING;
+ break;
+ case SSLEEP:
+ buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
+ break;
+ case SSTOP:
+ buf->state = GLIBTOP_PROCESS_STOPPED;
+ break;
+ case SZOMB:
+ buf->state = GLIBTOP_PROCESS_ZOMBIE;
+ break;
+ default:
+ return -1;
+ }
#else
- switch (pinfo [0].kp_proc.p_stat) {
- case SIDL:
- buf->state = 'S';
- break;
- case SRUN:
- buf->state = 'R';
- break;
- case SSLEEP:
- buf->state = 'S';
- break;
- case SSTOP:
- buf->state = 'T';
- break;
- case SZOMB:
- buf->state = 'Z';
- break;
- default:
- return -1;
- }
+ switch (pinfo [0].kp_proc.p_stat) {
+ case SIDL:
+ buf->state = 'S';
+ break;
+ case SRUN:
+ buf->state = 'R';
+ break;
+ case SSLEEP:
+ buf->state = 'S';
+ break;
+ case SSTOP:
+ buf->state = 'T';
+ break;
+ case SZOMB:
+ buf->state = 'Z';
+ break;
+ default:
+ return -1;
+ }
#endif
- buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
+ buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/proctime.c b/sysdeps/freebsd/proctime.c
index 36bbb998..e7b35b3e 100644
--- a/sysdeps/freebsd/proctime.c
+++ b/sysdeps/freebsd/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -46,10 +48,10 @@ static const unsigned long _glibtop_sysdeps_proc_time_user =
int
glibtop_init_proc_time_p (glibtop *server)
{
- server->sysdeps.proc_time = _glibtop_sysdeps_proc_time |
- _glibtop_sysdeps_proc_time_user;
+ server->sysdeps.proc_time = _glibtop_sysdeps_proc_time |
+ _glibtop_sysdeps_proc_time_user;
- return 0;
+ return 0;
}
/* Taken from /usr/src/sys/kern/kern_resource.c */
@@ -66,57 +68,57 @@ calcru(p, up, sp, ip)
struct timeval *sp;
struct timeval *ip;
{
- quad_t totusec;
- u_quad_t u, st, ut, it, tot;
+ quad_t totusec;
+ u_quad_t u, st, ut, it, tot;
#if (__FreeBSD_version < 300003)
- long sec, usec;
+ long sec, usec;
#endif
- struct timeval tv;
+ struct timeval tv;
- st = p->p_sticks;
- ut = p->p_uticks;
- it = p->p_iticks;
+ st = p->p_sticks;
+ ut = p->p_uticks;
+ it = p->p_iticks;
- tot = st + ut + it;
- if (tot == 0) {
- st = 1;
- tot = 1;
- }
+ tot = st + ut + it;
+ if (tot == 0) {
+ st = 1;
+ tot = 1;
+ }
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
- /* This was changed from a `struct timeval' into a `u_int64_t'
- * on FreeBSD 3.0 and renamed p_rtime -> p_runtime.
- */
+ /* This was changed from a `struct timeval' into a `u_int64_t'
+ * on FreeBSD 3.0 and renamed p_rtime -> p_runtime.
+ */
- totusec = (u_quad_t) p->p_runtime;
+ totusec = (u_quad_t) p->p_runtime;
#else
- sec = p->p_rtime.tv_sec;
- usec = p->p_rtime.tv_usec;
+ sec = p->p_rtime.tv_sec;
+ usec = p->p_rtime.tv_usec;
- totusec = (quad_t)sec * 1000000 + usec;
+ totusec = (quad_t)sec * 1000000 + usec;
#endif
- if (totusec < 0) {
- /* XXX no %qd in kernel. Truncate. */
- fprintf (stderr, "calcru: negative time: %ld usec\n",
- (long)totusec);
- totusec = 0;
- }
-
-
- u = totusec;
- st = (u * st) / tot;
- sp->tv_sec = st / 1000000;
- sp->tv_usec = st % 1000000;
- ut = (u * ut) / tot;
- up->tv_sec = ut / 1000000;
- up->tv_usec = ut % 1000000;
- if (ip != NULL) {
- it = (u * it) / tot;
- ip->tv_sec = it / 1000000;
- ip->tv_usec = it % 1000000;
- }
+ if (totusec < 0) {
+ /* XXX no %qd in kernel. Truncate. */
+ fprintf (stderr, "calcru: negative time: %ld usec\n",
+ (long)totusec);
+ totusec = 0;
+ }
+
+
+ u = totusec;
+ st = (u * st) / tot;
+ sp->tv_sec = st / 1000000;
+ sp->tv_usec = st % 1000000;
+ ut = (u * ut) / tot;
+ up->tv_sec = ut / 1000000;
+ up->tv_usec = ut % 1000000;
+ if (ip != NULL) {
+ it = (u * it) / tot;
+ ip->tv_sec = it / 1000000;
+ ip->tv_usec = it % 1000000;
+ }
}
/* Provides detailed information about a process. */
@@ -125,110 +127,110 @@ int
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- struct kinfo_proc *pinfo;
+ struct kinfo_proc *pinfo;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- register struct rusage *rup;
+ register struct rusage *rup;
#else
- struct user *u_addr = (struct user *)USRSTACK;
+ struct user *u_addr = (struct user *)USRSTACK;
#endif
- struct pstats pstats;
- int count;
+ struct pstats pstats;
+ int count;
- char filename [BUFSIZ];
- struct stat statb;
+ char filename [BUFSIZ];
+ struct stat statb;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- /* 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;
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
- if (server->sysdeps.proc_time == 0)
- return -1;
+ if (server->sysdeps.proc_time == 0)
+ return -1;
#ifndef __bsdi__
- sprintf (filename, "/proc/%d/mem", (int) pid);
- if (stat (filename, &statb)) return -1;
+ sprintf (filename, "/proc/%d/mem", (int) pid);
+ if (stat (filename, &statb)) return -1;
#endif
#endif
- /* Get the process information */
- pinfo = kvm_getprocs (server->_priv->machine.kd,
- KERN_PROC_PID, pid, &count);
- if ((pinfo == NULL) || (count != 1))
- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+ /* Get the process information */
+ pinfo = kvm_getprocs (server->_priv->machine.kd,
+ KERN_PROC_PID, pid, &count);
+ if ((pinfo == NULL) || (count != 1))
+ glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
- buf->rtime = pinfo [0].kp_proc.p_runtime;
+ buf->rtime = pinfo [0].kp_proc.p_runtime;
#else
- buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime);
+ buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime);
#endif
- buf->frequency = 1000000;
- buf->flags = _glibtop_sysdeps_proc_time;
+ buf->frequency = 1000000;
+ buf->flags = _glibtop_sysdeps_proc_time;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- if (kvm_read (server->_priv->machine.kd,
- (unsigned long) pinfo [0].kp_proc.p_stats,
- &pstats, sizeof (pstats)) != sizeof (pstats)) {
- glibtop_warn_io_r (server, "kvm_read (pstats)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd,
+ (unsigned long) pinfo [0].kp_proc.p_stats,
+ &pstats, sizeof (pstats)) != sizeof (pstats)) {
+ glibtop_warn_io_r (server, "kvm_read (pstats)");
+ return -1;
+ }
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- rup = &pstats.p_ru;
- calcru(&(pinfo [0]).kp_proc,
- &rup->ru_utime, &rup->ru_stime, NULL);
+ rup = &pstats.p_ru;
+ calcru(&(pinfo [0]).kp_proc,
+ &rup->ru_utime, &rup->ru_stime, NULL);
- buf->utime = tv2sec (pstats.p_ru.ru_utime);
- buf->stime = tv2sec (pstats.p_ru.ru_stime);
+ buf->utime = tv2sec (pstats.p_ru.ru_utime);
+ buf->stime = tv2sec (pstats.p_ru.ru_stime);
- buf->cutime = tv2sec (pstats.p_cru.ru_utime);
- buf->cstime = tv2sec (pstats.p_cru.ru_stime);
+ buf->cutime = tv2sec (pstats.p_cru.ru_utime);
+ buf->cstime = tv2sec (pstats.p_cru.ru_stime);
- buf->start_time = (u_int64_t) pstats.p_start.tv_sec;
+ buf->start_time = (u_int64_t) pstats.p_start.tv_sec;
- buf->flags |= _glibtop_sysdeps_proc_time_user;
+ buf->flags |= _glibtop_sysdeps_proc_time_user;
#else
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
- kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
- (unsigned long) &u_addr->u_stats,
- (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
- {
- /* This is taken form the kernel source code of
- * FreeBSD 2.2.6. */
+ if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+ kvm_uread (server->_priv->machine.kd, &(pinfo [0]).kp_proc,
+ (unsigned long) &u_addr->u_stats,
+ (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
+ {
+ /* This is taken form the kernel source code of
+ * FreeBSD 2.2.6. */
- /* Well, we just do the same getrusage () does ... */
+ /* Well, we just do the same getrusage () does ... */
- register struct rusage *rup;
+ register struct rusage *rup;
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- rup = &pstats.p_ru;
- calcru(&(pinfo [0]).kp_proc,
- &rup->ru_utime, &rup->ru_stime, NULL);
+ rup = &pstats.p_ru;
+ calcru(&(pinfo [0]).kp_proc,
+ &rup->ru_utime, &rup->ru_stime, NULL);
- buf->utime = tv2sec (pstats.p_ru.ru_utime);
- buf->stime = tv2sec (pstats.p_ru.ru_stime);
+ buf->utime = tv2sec (pstats.p_ru.ru_utime);
+ buf->stime = tv2sec (pstats.p_ru.ru_stime);
- buf->cutime = tv2sec (pstats.p_cru.ru_utime);
- buf->cstime = tv2sec (pstats.p_cru.ru_stime);
+ buf->cutime = tv2sec (pstats.p_cru.ru_utime);
+ buf->cstime = tv2sec (pstats.p_cru.ru_stime);
- buf->start_time = tv2sec (pstats.p_start);
+ buf->start_time = tv2sec (pstats.p_start);
- buf->flags = _glibtop_sysdeps_proc_time_user;
- }
+ buf->flags = _glibtop_sysdeps_proc_time_user;
+ }
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
#endif
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/procuid.c b/sysdeps/freebsd/procuid.c
index 2337b41e..956a3a73 100644
--- a/sysdeps/freebsd/procuid.c
+++ b/sysdeps/freebsd/procuid.c
@@ -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;
- }
-
- 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->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;
-
- /* Use LibGTop conditionals here so we can more easily merge this
- * code into the LIBGTOP_STABLE_1_0 branch. */
+ /* 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->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;
+
+ /* 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. */
#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;
-
- 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;
-
- buf->flags |= _glibtop_sysdeps_proc_uid_groups;
- }
+ 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;
+
+ for (i = 0; i < count; i++)
+ buf->groups [i] = ucred.cr_groups [i];
+ buf->ngroups = count;
+
+ buf->flags |= _glibtop_sysdeps_proc_uid_groups;
}
+ }
#endif
#endif
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/sem_limits.c b/sysdeps/freebsd/sem_limits.c
index d31e49cf..08b726e4 100644
--- a/sysdeps/freebsd/sem_limits.c
+++ b/sysdeps/freebsd/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,17 +36,17 @@ int
glibtop_init_sem_limits_p (glibtop *server)
{
- return 0;
+ return 0;
}
int
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- return 0;
+ return 0;
}
#else
@@ -74,8 +76,8 @@ static struct seminfo _seminfo;
/* nlist structure for kernel access */
static struct nlist nlst [] = {
- { "_seminfo" },
- { 0 }
+ { "_seminfo" },
+ { 0 }
};
/* Init function. */
@@ -83,20 +85,20 @@ static struct nlist nlst [] = {
int
glibtop_init_sem_limits_p (glibtop *server)
{
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
- return -1;
- }
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (sem_limits)");
+ return -1;
+ }
- if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
- &_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
- glibtop_warn_io_r (server, "kvm_read (seminfo)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
+ &_seminfo, sizeof (_seminfo)) != sizeof (_seminfo)) {
+ glibtop_warn_io_r (server, "kvm_read (seminfo)");
+ return -1;
+ }
- server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
+ server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv sem limits. */
@@ -104,25 +106,25 @@ glibtop_init_sem_limits_p (glibtop *server)
int
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- if (server->sysdeps.sem_limits == 0)
- return -1;
-
- buf->semmap = _seminfo.semmap;
- buf->semmni = _seminfo.semmni;
- buf->semmns = _seminfo.semmns;
- buf->semmnu = _seminfo.semmnu;
- buf->semmsl = _seminfo.semmsl;
- buf->semopm = _seminfo.semopm;
- buf->semvmx = _seminfo.semvmx;
- buf->semaem = _seminfo.semaem;
+ if (server->sysdeps.sem_limits == 0)
+ return -1;
+
+ buf->semmap = _seminfo.semmap;
+ buf->semmni = _seminfo.semmni;
+ buf->semmns = _seminfo.semmns;
+ buf->semmnu = _seminfo.semmnu;
+ buf->semmsl = _seminfo.semmsl;
+ buf->semopm = _seminfo.semopm;
+ buf->semvmx = _seminfo.semvmx;
+ buf->semaem = _seminfo.semaem;
- buf->flags = _glibtop_sysdeps_sem_limits;
+ buf->flags = _glibtop_sysdeps_sem_limits;
- return 0;
+ return 0;
}
#endif /* either a newer BSDI or no BSDI at all. */
diff --git a/sysdeps/freebsd/shm_limits.c b/sysdeps/freebsd/shm_limits.c
index f1264f6e..cf889391 100644
--- a/sysdeps/freebsd/shm_limits.c
+++ b/sysdeps/freebsd/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,17 +36,17 @@ int
glibtop_init_shm_limits_p (glibtop *server)
{
- return 0;
+ return 0;
}
int
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- return 0;
+ return 0;
}
#else
@@ -72,8 +74,8 @@ static struct shminfo _shminfo;
/* nlist structure for kernel access */
static struct nlist nlst [] = {
- { "_shminfo" },
- { 0 }
+ { "_shminfo" },
+ { 0 }
};
/* Init function. */
@@ -81,20 +83,20 @@ static struct nlist nlst [] = {
int
glibtop_init_shm_limits_p (glibtop *server)
{
- if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
- return -1;
- }
+ if (kvm_nlist (server->_priv->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
+ return -1;
+ }
- if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
- &_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
- glibtop_warn_io_r (server, "kvm_read (shminfo)");
- return -1;
- }
+ if (kvm_read (server->_priv->machine.kd, nlst [0].n_value,
+ &_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
+ glibtop_warn_io_r (server, "kvm_read (shminfo)");
+ return -1;
+ }
- server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
+ server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -102,22 +104,22 @@ glibtop_init_shm_limits_p (glibtop *server)
int
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- if (server->sysdeps.shm_limits == 0)
- return -1;
+ if (server->sysdeps.shm_limits == 0)
+ return -1;
- buf->shmmax = _shminfo.shmmax;
- buf->shmmin = _shminfo.shmmin;
- buf->shmmni = _shminfo.shmmni;
- buf->shmseg = _shminfo.shmseg;
- buf->shmall = _shminfo.shmall;
+ buf->shmmax = _shminfo.shmmax;
+ buf->shmmin = _shminfo.shmmin;
+ buf->shmmni = _shminfo.shmmni;
+ buf->shmseg = _shminfo.shmseg;
+ buf->shmall = _shminfo.shmall;
- buf->flags = _glibtop_sysdeps_shm_limits;
+ buf->flags = _glibtop_sysdeps_shm_limits;
- return 0;
+ return 0;
}
#endif /* either a newer BSDI or no BSDI at all. */
diff --git a/sysdeps/freebsd/siglist.c b/sysdeps/freebsd/siglist.c
index 94abfdc6..329b7ccc 100644
--- a/sysdeps/freebsd/siglist.c
+++ b/sysdeps/freebsd/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/freebsd/swap.c b/sysdeps/freebsd/swap.c
index a0583fe3..e19d45ee 100644
--- a/sysdeps/freebsd/swap.c
+++ b/sysdeps/freebsd/swap.c
@@ -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,22 +52,22 @@ static const unsigned long _glibtop_sysdeps_swap =
#if defined(__bsdi__)
static struct nlist nlst [] = {
- { "_swapstats" }, /* general swap info */
- { 0 }
+ { "_swapstats" }, /* general swap info */
+ { 0 }
};
#elif __FreeBSD__ < 4
static struct nlist nlst [] = {
#define VM_SWAPLIST 0
- { "_swaplist" },/* list of free swap areas */
+ { "_swaplist" },/* list of free swap areas */
#define VM_SWDEVT 1
- { "_swdevt" }, /* list of swap devices and sizes */
+ { "_swdevt" }, /* list of swap devices and sizes */
#define VM_NSWAP 2
- { "_nswap" }, /* size of largest swap device */
+ { "_nswap" }, /* size of largest swap device */
#define VM_NSWDEV 3
- { "_nswdev" }, /* number of swap devices */
+ { "_nswdev" }, /* number of swap devices */
#define VM_DMMAX 4
- { "_dmmax" }, /* maximum size of a swap block */
- { 0 }
+ { "_dmmax" }, /* maximum size of a swap block */
+ { 0 }
};
#endif
@@ -85,8 +87,8 @@ static int mib_uvmexp [] = { CTL_VM, VM_UVMEXP };
#else
/* nlist structure for kernel access */
static struct nlist nlst2 [] = {
- { "_cnt" },
- { 0 }
+ { "_cnt" },
+ { 0 }
};
#endif
@@ -97,30 +99,30 @@ glibtop_init_swap_p (glibtop *server)
{
#if defined(__FreeBSD__) || defined(__bsdi__)
#if __FreeBSD__ < 4 || defined(__bsdi__)
- if (kvm_nlist (server->machine.kd, nlst) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (swap)");
- return -1;
- }
+ if (kvm_nlist (server->machine.kd, nlst) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (swap)");
+ return -1;
+ }
#else
- struct kvm_swap dummy;
+ struct kvm_swap dummy;
- if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
- glibtop_warn_io_r (server, "kvm_swap (swap)");
- return -1;
- }
+ if (kvm_getswapinfo (server->machine.kd, &dummy, 1, 0) != 0) {
+ glibtop_warn_io_r (server, "kvm_swap (swap)");
+ return -1;
+ }
#endif
#endif
#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
- if (kvm_nlist (server->machine.kd, nlst2) != 0) {
- glibtop_warn_io_r (server, "kvm_nlist (cnt)");
- return -1;
- }
+ if (kvm_nlist (server->machine.kd, nlst2) != 0) {
+ glibtop_warn_io_r (server, "kvm_nlist (cnt)");
+ return -1;
+ }
#endif
- server->sysdeps.swap = _glibtop_sysdeps_swap;
+ server->sysdeps.swap = _glibtop_sysdeps_swap;
- return 0;
+ return 0;
}
/* Provides information about swap usage. */
@@ -136,91 +138,91 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
#if defined(__FreeBSD__)
# if __FreeBSD__ < 4
- char *header;
- int hlen, nswdev, dmmax;
- int div, nfree, npfree;
- struct swdevt *sw;
- long blocksize, *perdev;
- struct rlist head;
- struct rlisthdr swaplist;
- struct rlist *swapptr;
- size_t sw_size;
- u_long ptr;
+ char *header;
+ int hlen, nswdev, dmmax;
+ int div, nfree, npfree;
+ struct swdevt *sw;
+ long blocksize, *perdev;
+ struct rlist head;
+ struct rlisthdr swaplist;
+ struct rlist *swapptr;
+ size_t sw_size;
+ u_long ptr;
# else
- int nswdev;
- struct kvm_swap kvmsw[16];
+ int nswdev;
+ struct kvm_swap kvmsw[16];
# endif
#elif defined(__bsdi__)
- struct swapstats swap;
+ struct swapstats swap;
#elif defined(__NetBSD__)
- struct swapent *swaplist;
+ struct swapent *swaplist;
#endif
- int nswap, i;
- int avail = 0, inuse = 0;
+ int nswap, i;
+ int avail = 0, inuse = 0;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- struct uvmexp uvmexp;
- size_t length_uvmexp;
+ struct uvmexp uvmexp;
+ size_t length_uvmexp;
#else
- /* To get `pagein' and `pageout'. */
- struct vmmeter vmm;
+ /* To get `pagein' and `pageout'. */
+ struct vmmeter vmm;
#endif
- static int swappgsin = -1;
- static int swappgsout = -1;
+ static int swappgsin = -1;
+ static int swappgsout = -1;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
- memset (buf, 0, sizeof (glibtop_swap));
+ memset (buf, 0, sizeof (glibtop_swap));
- if (server->sysdeps.swap == 0)
- return -1;
+ if (server->sysdeps.swap == 0)
+ return -1;
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- length_uvmexp = sizeof (uvmexp);
- if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
- glibtop_warn_io_r (server, "sysctl (uvmexp)");
- return -1;
- }
+ length_uvmexp = sizeof (uvmexp);
+ if (sysctl (mib_uvmexp, 2, &uvmexp, &length_uvmexp, NULL, 0)) {
+ glibtop_warn_io_r (server, "sysctl (uvmexp)");
+ return -1;
+ }
#else
- /* This is used to get the `pagein' and `pageout' members. */
+ /* This is used to get the `pagein' and `pageout' members. */
- if (kvm_read (server->machine.kd, nlst2[0].n_value,
- &vmm, sizeof (vmm)) != sizeof (vmm)) {
- glibtop_warn_io_r (server, "kvm_read (cnt)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst2[0].n_value,
+ &vmm, sizeof (vmm)) != sizeof (vmm)) {
+ glibtop_warn_io_r (server, "kvm_read (cnt)");
+ return -1;
+ }
#endif
- if (swappgsin < 0) {
- buf->pagein = 0;
- buf->pageout = 0;
- } else {
+ if (swappgsin < 0) {
+ buf->pagein = 0;
+ buf->pageout = 0;
+ } else {
#ifdef __FreeBSD__
- buf->pagein = vmm.v_swappgsin - swappgsin;
- buf->pageout = vmm.v_swappgsout - swappgsout;
+ buf->pagein = vmm.v_swappgsin - swappgsin;
+ buf->pageout = vmm.v_swappgsout - swappgsout;
#else
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- buf->pagein = uvmexp.swapins - swappgsin;
- buf->pageout = uvmexp.swapouts - swappgsout;
+ buf->pagein = uvmexp.swapins - swappgsin;
+ buf->pageout = uvmexp.swapouts - swappgsout;
#else
- buf->pagein = vmm.v_swpin - swappgsin;
- buf->pageout = vmm.v_swpout - swappgsout;
+ buf->pagein = vmm.v_swpin - swappgsin;
+ buf->pageout = vmm.v_swpout - swappgsout;
#endif
#endif
- }
+ }
#ifdef __FreeBSD__
- swappgsin = vmm.v_swappgsin;
- swappgsout = vmm.v_swappgsout;
+ swappgsin = vmm.v_swappgsin;
+ swappgsout = vmm.v_swappgsout;
#else
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
- swappgsin = uvmexp.swapins;
- swappgsout = uvmexp.swapouts;
+ swappgsin = uvmexp.swapins;
+ swappgsout = uvmexp.swapouts;
#else
- swappgsin = vmm.v_swpin;
- swappgsout = vmm.v_swpout;
+ swappgsin = vmm.v_swpin;
+ swappgsout = vmm.v_swpout;
#endif
#endif
@@ -228,203 +230,203 @@ glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
#if __FreeBSD__ < 4
- /* Size of largest swap device. */
+ /* Size of largest swap device. */
- if (kvm_read (server->machine.kd, nlst[VM_NSWAP].n_value,
- &nswap, sizeof (nswap)) != sizeof (nswap)) {
- glibtop_warn_io_r (server, "kvm_read (nswap)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[VM_NSWAP].n_value,
+ &nswap, sizeof (nswap)) != sizeof (nswap)) {
+ glibtop_warn_io_r (server, "kvm_read (nswap)");
+ return -1;
+ }
- /* Number of swap devices. */
+ /* Number of swap devices. */
- if (kvm_read (server->machine.kd, nlst[VM_NSWDEV].n_value,
- &nswdev, sizeof (nswdev)) != sizeof (nswdev)) {
- glibtop_warn_io_r (server, "kvm_read (nswdev)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[VM_NSWDEV].n_value,
+ &nswdev, sizeof (nswdev)) != sizeof (nswdev)) {
+ glibtop_warn_io_r (server, "kvm_read (nswdev)");
+ return -1;
+ }
- /* Maximum size of a swap block. */
+ /* Maximum size of a swap block. */
- if (kvm_read (server->machine.kd, nlst[VM_DMMAX].n_value,
- &dmmax, sizeof (dmmax)) != sizeof (dmmax)) {
- glibtop_warn_io_r (server, "kvm_read (dmmax)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[VM_DMMAX].n_value,
+ &dmmax, sizeof (dmmax)) != sizeof (dmmax)) {
+ glibtop_warn_io_r (server, "kvm_read (dmmax)");
+ return -1;
+ }
- /* List of free swap areas. */
+ /* List of free swap areas. */
- if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value,
- &swaplist, sizeof (swaplist)) != sizeof (swaplist)) {
- glibtop_warn_io_r (server, "kvm_read (swaplist)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value,
+ &swaplist, sizeof (swaplist)) != sizeof (swaplist)) {
+ glibtop_warn_io_r (server, "kvm_read (swaplist)");
+ return -1;
+ }
- /* Kernel offset of list of swap devices and sizes. */
+ /* Kernel offset of list of swap devices and sizes. */
- if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
- &ptr, sizeof (ptr)) != sizeof (ptr)) {
- glibtop_warn_io_r (server, "kvm_read (swdevt)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value,
+ &ptr, sizeof (ptr)) != sizeof (ptr)) {
+ glibtop_warn_io_r (server, "kvm_read (swdevt)");
+ return -1;
+ }
- /* List of swap devices and sizes. */
+ /* List of swap devices and sizes. */
- sw_size = nswdev * sizeof (*sw);
- sw = glibtop_malloc_r (server, sw_size);
+ sw_size = nswdev * sizeof (*sw);
+ sw = glibtop_malloc_r (server, sw_size);
- if (kvm_read (server->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) {
- glibtop_warn_io_r (server, "kvm_read (*swdevt)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, ptr, sw, sw_size) != (ssize_t)sw_size) {
+ glibtop_warn_io_r (server, "kvm_read (*swdevt)");
+ return -1;
+ }
+
+ perdev = glibtop_malloc (nswdev * sizeof (*perdev));
+
+ /* Count up swap space. */
+
+ nfree = 0;
+ memset (perdev, 0, nswdev * sizeof(*perdev));
+
+ swapptr = swaplist.rlh_list;
- perdev = glibtop_malloc (nswdev * sizeof (*perdev));
-
- /* Count up swap space. */
-
- nfree = 0;
- memset (perdev, 0, nswdev * sizeof(*perdev));
-
- swapptr = swaplist.rlh_list;
-
- while (swapptr) {
- int top, bottom, next_block;
-
- if (kvm_read (server->machine.kd, (int) swapptr, &head,
- sizeof (struct rlist)) != sizeof (struct rlist)) {
- glibtop_warn_io_r (server, "kvm_read (swapptr)");
- return -1;
- }
-
- top = head.rl_end;
- bottom = head.rl_start;
-
- nfree += top - bottom + 1;
-
- /*
- * Swap space is split up among the configured disks.
- *
- * For interleaved swap devices, the first dmmax blocks
- * of swap space some from the first disk, the next dmmax
- * blocks from the next, and so on up to nswap blocks.
- *
- * The list of free space joins adjacent free blocks,
- * ignoring device boundries. If we want to keep track
- * of this information per device, we'll just have to
- * extract it ourselves.
- */
- while (top / dmmax != bottom / dmmax) {
- next_block = ((bottom + dmmax) / dmmax);
- perdev[(bottom / dmmax) % nswdev] +=
- next_block * dmmax - bottom;
- bottom = next_block * dmmax;
- }
- perdev[(bottom / dmmax) % nswdev] +=
- top - bottom + 1;
-
- swapptr = head.rl_next;
+ while (swapptr) {
+ int top, bottom, next_block;
+
+ if (kvm_read (server->machine.kd, (int) swapptr, &head,
+ sizeof (struct rlist)) != sizeof (struct rlist)) {
+ glibtop_warn_io_r (server, "kvm_read (swapptr)");
+ return -1;
}
- header = getbsize (&hlen, &blocksize);
-
- div = blocksize / 512;
- avail = npfree = 0;
- for (i = 0; i < nswdev; i++) {
- int xsize, xfree;
-
- /*
- * Don't report statistics for partitions which have not
- * yet been activated via swapon(8).
- */
- if (!(sw[i].sw_flags & SW_FREED))
- continue;
-
- /* The first dmmax is never allocated to avoid trashing of
- * disklabels
- */
- xsize = sw[i].sw_nblks - dmmax;
- xfree = perdev[i];
- inuse = xsize - xfree;
- npfree++;
- avail += xsize;
+ top = head.rl_end;
+ bottom = head.rl_start;
+
+ nfree += top - bottom + 1;
+
+ /*
+ * Swap space is split up among the configured disks.
+ *
+ * For interleaved swap devices, the first dmmax blocks
+ * of swap space some from the first disk, the next dmmax
+ * blocks from the next, and so on up to nswap blocks.
+ *
+ * The list of free space joins adjacent free blocks,
+ * ignoring device boundries. If we want to keep track
+ * of this information per device, we'll just have to
+ * extract it ourselves.
+ */
+ while (top / dmmax != bottom / dmmax) {
+ next_block = ((bottom + dmmax) / dmmax);
+ perdev[(bottom / dmmax) % nswdev] +=
+ next_block * dmmax - bottom;
+ bottom = next_block * dmmax;
}
+ perdev[(bottom / dmmax) % nswdev] +=
+ top - bottom + 1;
+
+ swapptr = head.rl_next;
+ }
+
+ header = getbsize (&hlen, &blocksize);
+
+ div = blocksize / 512;
+ avail = npfree = 0;
+ for (i = 0; i < nswdev; i++) {
+ int xsize, xfree;
/*
- * If only one partition has been set up via swapon(8), we don't
- * need to bother with totals.
+ * Don't report statistics for partitions which have not
+ * yet been activated via swapon(8).
*/
- inuse = avail - nfree;
+ if (!(sw[i].sw_flags & SW_FREED))
+ continue;
- glibtop_free_r (server, sw);
- glibtop_free_r (server, perdev);
+ /* The first dmmax is never allocated to avoid trashing of
+ * disklabels
+ */
+ xsize = sw[i].sw_nblks - dmmax;
+ xfree = perdev[i];
+ inuse = xsize - xfree;
+ npfree++;
+ avail += xsize;
+ }
- buf->flags = _glibtop_sysdeps_swap;
+ /*
+ * If only one partition has been set up via swapon(8), we don't
+ * need to bother with totals.
+ */
+ inuse = avail - nfree;
- buf->used = inuse;
- buf->free = avail;
+ glibtop_free_r (server, sw);
+ glibtop_free_r (server, perdev);
- buf->total = inuse + avail;
+ buf->flags = _glibtop_sysdeps_swap;
+
+ buf->used = inuse;
+ buf->free = avail;
+
+ buf->total = inuse + avail;
#else
- nswdev = kvm_getswapinfo(server->machine.kd, kvmsw, 16, 0);
+ nswdev = kvm_getswapinfo(server->machine.kd, kvmsw, 16, 0);
- buf->flags = _glibtop_sysdeps_swap;
+ buf->flags = _glibtop_sysdeps_swap;
- buf->used = kvmsw[nswdev].ksw_used;
- buf->total = kvmsw[nswdev].ksw_total;
+ buf->used = kvmsw[nswdev].ksw_used;
+ buf->total = kvmsw[nswdev].ksw_total;
- buf->free = buf->total - buf->used;
+ buf->free = buf->total - buf->used;
#endif
#elif defined(__bsdi__)
- /* General info about swap devices. */
+ /* General info about swap devices. */
- if (kvm_read (server->machine.kd, nlst[0].n_value,
- &swap, sizeof (swap)) != sizeof (swap)) {
- glibtop_warn_io_r (server, "kvm_read (swap)");
- return -1;
- }
+ if (kvm_read (server->machine.kd, nlst[0].n_value,
+ &swap, sizeof (swap)) != sizeof (swap)) {
+ glibtop_warn_io_r (server, "kvm_read (swap)");
+ return -1;
+ }
- buf->flags = _glibtop_sysdeps_swap;
+ buf->flags = _glibtop_sysdeps_swap;
- buf->used = swap.swap_total - swap.swap_free;
- buf->free = swap.swap_free;
+ buf->used = swap.swap_total - swap.swap_free;
+ buf->free = swap.swap_free;
- buf->total = swap.swap_total;
+ buf->total = swap.swap_total;
#elif defined(__NetBSD__)
- nswap = swapctl (SWAP_NSWAP, NULL, 0);
- if (nswap < 0) {
- glibtop_warn_io_r (server, "swapctl (SWAP_NSWAP)");
- return -1;
- }
+ nswap = swapctl (SWAP_NSWAP, NULL, 0);
+ if (nswap < 0) {
+ glibtop_warn_io_r (server, "swapctl (SWAP_NSWAP)");
+ return -1;
+ }
- swaplist = glibtop_calloc_r (server, nswap, sizeof (struct swapent));
+ swaplist = glibtop_calloc_r (server, nswap, sizeof (struct swapent));
- if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) {
- glibtop_warn_io_r (server, "swapctl (SWAP_STATS)");
- glibtop_free_r (server, swaplist);
- return -1;
- }
+ if (swapctl (SWAP_STATS, swaplist, nswap) != nswap) {
+ glibtop_warn_io_r (server, "swapctl (SWAP_STATS)");
+ glibtop_free_r (server, swaplist);
+ return -1;
+ }
- for (i = 0; i < nswap; i++) {
- avail += swaplist[i].se_nblks;
- inuse += swaplist[i].se_inuse;
- }
+ for (i = 0; i < nswap; i++) {
+ avail += swaplist[i].se_nblks;
+ inuse += swaplist[i].se_inuse;
+ }
- glibtop_free_r (server, swaplist);
+ glibtop_free_r (server, swaplist);
- buf->flags = _glibtop_sysdeps_swap;
+ buf->flags = _glibtop_sysdeps_swap;
- buf->used = inuse;
- buf->free = avail;
+ buf->used = inuse;
+ buf->free = avail;
- buf->total = inuse + avail;
+ buf->total = inuse + avail;
#endif
- return 0;
+ return 0;
}
diff --git a/sysdeps/freebsd/uptime.c b/sysdeps/freebsd/uptime.c
index ef6d93b9..1b8b1dd2 100644
--- a/sysdeps/freebsd/uptime.c
+++ b/sysdeps/freebsd/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -41,9 +43,9 @@ static const unsigned long _required_cpu_flags =
int
glibtop_init_uptime_p (glibtop *server)
{
- server->sysdeps.uptime = _glibtop_sysdeps_uptime;
+ server->sysdeps.uptime = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
/* Provides uptime and idle time. */
@@ -51,27 +53,27 @@ glibtop_init_uptime_p (glibtop *server)
int
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
{
- glibtop_cpu cpu;
+ glibtop_cpu cpu;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
- memset (buf, 0, sizeof (glibtop_uptime));
+ memset (buf, 0, sizeof (glibtop_uptime));
- /* We simply calculate it from the CPU usage. */
+ /* We simply calculate it from the CPU usage. */
- glibtop_get_cpu_p (server, &cpu);
+ glibtop_get_cpu_p (server, &cpu);
- /* Make sure all required fields are present. */
+ /* Make sure all required fields are present. */
- if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags)
- return -1;
+ if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags)
+ return -1;
- /* Calculate values. */
+ /* Calculate values. */
- buf->uptime = (double) cpu.total / (double) cpu.frequency;
- buf->idletime = (double) cpu.idle / (double) cpu.frequency;
+ buf->uptime = (double) cpu.total / (double) cpu.frequency;
+ buf->idletime = (double) cpu.idle / (double) cpu.frequency;
- buf->flags = _glibtop_sysdeps_uptime;
+ buf->flags = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
diff --git a/sysdeps/kernel/close.c b/sysdeps/kernel/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/kernel/close.c
+++ b/sysdeps/kernel/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/cpu.c b/sysdeps/kernel/cpu.c
index 1c68a1bc..1019a2a4 100644
--- a/sysdeps/kernel/cpu.c
+++ b/sysdeps/kernel/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/glibtop_private.h b/sysdeps/kernel/glibtop_private.h
index 0396d864..d007f781 100644
--- a/sysdeps/kernel/glibtop_private.h
+++ b/sysdeps/kernel/glibtop_private.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/glibtop_server.h b/sysdeps/kernel/glibtop_server.h
index b3822d47..ce0acf4f 100644
--- a/sysdeps/kernel/glibtop_server.h
+++ b/sysdeps/kernel/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/interfaces.c b/sysdeps/kernel/interfaces.c
index bf491632..ea4aa0e8 100644
--- a/sysdeps/kernel/interfaces.c
+++ b/sysdeps/kernel/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/loadavg.c b/sysdeps/kernel/loadavg.c
index 7566fe8c..dfacd050 100644
--- a/sysdeps/kernel/loadavg.c
+++ b/sysdeps/kernel/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/mem.c b/sysdeps/kernel/mem.c
index bc408fbe..5cba6976 100644
--- a/sysdeps/kernel/mem.c
+++ b/sysdeps/kernel/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/msg_limits.c b/sysdeps/kernel/msg_limits.c
index b3c8e9bd..0b5ec6ca 100644
--- a/sysdeps/kernel/msg_limits.c
+++ b/sysdeps/kernel/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/netinfo.c b/sysdeps/kernel/netinfo.c
index 1d93578f..223ab192 100644
--- a/sysdeps/kernel/netinfo.c
+++ b/sysdeps/kernel/netinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/netload.c b/sysdeps/kernel/netload.c
index 31077827..47f2a8b3 100644
--- a/sysdeps/kernel/netload.c
+++ b/sysdeps/kernel/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/open.c b/sysdeps/kernel/open.c
index eef22d71..6e4dc655 100644
--- a/sysdeps/kernel/open.c
+++ b/sysdeps/kernel/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -29,5 +31,5 @@ void
glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- server->name = program_name;
+ server->name = program_name;
}
diff --git a/sysdeps/kernel/ppp.c b/sysdeps/kernel/ppp.c
index b8e80dbb..6c1ced21 100644
--- a/sysdeps/kernel/ppp.c
+++ b/sysdeps/kernel/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -44,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_ppp =
int
glibtop_init_ppp_s (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
return 0;
}
@@ -52,129 +54,129 @@ glibtop_init_ppp_s (glibtop *server)
static int
get_ISDN_stats (glibtop *server, int *in, int *out)
{
- unsigned long *isdn_stats, *ptr;
- int fd, i;
+ unsigned long *isdn_stats, *ptr;
+ int fd, i;
- *in = *out = 0;
+ *in = *out = 0;
- isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
- sizeof (unsigned long));
+ isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
+ sizeof (unsigned long));
- fd = open ("/dev/isdninfo", O_RDONLY);
- if (fd < 0) {
- glibtop_free_r (server, isdn_stats);
- return FALSE;
- }
+ fd = open ("/dev/isdninfo", O_RDONLY);
+ if (fd < 0) {
+ glibtop_free_r (server, isdn_stats);
+ return FALSE;
+ }
- if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
- glibtop_free_r (server, isdn_stats);
- close (fd);
+ if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
+ glibtop_free_r (server, isdn_stats);
+ close (fd);
- return FALSE;
- }
+ return FALSE;
+ }
- for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) {
- *in += *ptr++; *out += *ptr++;
- }
+ for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) {
+ *in += *ptr++; *out += *ptr++;
+ }
- glibtop_free_r (server, isdn_stats);
- close (fd);
+ glibtop_free_r (server, isdn_stats);
+ close (fd);
- return TRUE;
+ return TRUE;
}
static int is_ISDN_on (glibtop *server, int *online)
{
- FILE *f = 0;
- char buffer [BUFSIZ], *p;
- int i;
-
- /* Perhaps I should try to explain this code a little bit.
- *
- * ------------------------------------------------------------
- * This is from the manpage of isdninfo(4):
- *
- * DESCRIPTION
- * /dev/isdninfo is a character device with major number 45
- * and minor number 255. It delivers status information from
- * the Linux ISDN subsystem to user level.
- *
- * DATA FORMAT
- * When reading from this device, the current status of the
- * Linux ISDN subsystem is delivered in 6 lines of text. Each
- * line starts with a tag string followed by a colon and
- * whitespace. After that the status values are appended sep-
- * arated by whitespace.
- *
- * flags is the tag of line 5. In this line for every driver
- * slot, it's B-Channel status is shown. If no driver
- * is registered in a slot, a ? is shown. For every
- * established B-Channel of the driver, a bit is set
- * in the shown value. The driver's first channel is
- * mapped to bit 0, the second channel to bit 1 and so
- * on.
- * ------------------------------------------------------------
- *
- * So we open /dev/isdninfo, discard the first four lines of text
- * and then check whether we have something that is not `0' or `?'
- * in one of the flags fields.
- *
- * Sounds complicated, but I don't see any other way to check whether
- * we are connected. Also, this is the method some other ISDN tools
- * for Linux use.
- *
- * Martin
- */
-
- f = fopen ("/dev/isdninfo", "r");
-
- if (!f) return FALSE;
-
- for (i = 0; i < 5; i++) {
- if (fgets (buffer, BUFSIZ, f) == NULL) {
- fclose (f);
- return FALSE;
- }
+ FILE *f = 0;
+ char buffer [BUFSIZ], *p;
+ int i;
+
+ /* Perhaps I should try to explain this code a little bit.
+ *
+ * ------------------------------------------------------------
+ * This is from the manpage of isdninfo(4):
+ *
+ * DESCRIPTION
+ * /dev/isdninfo is a character device with major number 45
+ * and minor number 255. It delivers status information from
+ * the Linux ISDN subsystem to user level.
+ *
+ * DATA FORMAT
+ * When reading from this device, the current status of the
+ * Linux ISDN subsystem is delivered in 6 lines of text. Each
+ * line starts with a tag string followed by a colon and
+ * whitespace. After that the status values are appended sep-
+ * arated by whitespace.
+ *
+ * flags is the tag of line 5. In this line for every driver
+ * slot, it's B-Channel status is shown. If no driver
+ * is registered in a slot, a ? is shown. For every
+ * established B-Channel of the driver, a bit is set
+ * in the shown value. The driver's first channel is
+ * mapped to bit 0, the second channel to bit 1 and so
+ * on.
+ * ------------------------------------------------------------
+ *
+ * So we open /dev/isdninfo, discard the first four lines of text
+ * and then check whether we have something that is not `0' or `?'
+ * in one of the flags fields.
+ *
+ * Sounds complicated, but I don't see any other way to check whether
+ * we are connected. Also, this is the method some other ISDN tools
+ * for Linux use.
+ *
+ * Martin
+ */
+
+ f = fopen ("/dev/isdninfo", "r");
+
+ if (!f) return FALSE;
+
+ for (i = 0; i < 5; i++) {
+ if (fgets (buffer, BUFSIZ, f) == NULL) {
+ fclose (f);
+ return FALSE;
}
+ }
- if (strncmp (buffer, "flags:", 6)) {
- fclose (f);
- return FALSE;
- }
-
- p = buffer+6;
-
- while (*p) {
- char *end = p;
+ if (strncmp (buffer, "flags:", 6)) {
+ fclose (f);
+ return FALSE;
+ }
- if (isspace (*p)) {
- p++;
- continue;
- }
+ p = buffer+6;
- for (end = p; *end && !isspace (*end); end++)
- ;
+ while (*p) {
+ char *end = p;
- if (*end == 0)
- break;
- else
- *end = 0;
+ if (isspace (*p)) {
+ p++;
+ continue;
+ }
- if (!strcmp (p, "?") || !strcmp (p, "0")) {
- p = end+1;
- continue;
- }
+ for (end = p; *end && !isspace (*end); end++)
+ ;
- fclose (f);
+ if (*end == 0)
+ break;
+ else
+ *end = 0;
- *online = TRUE;
- return TRUE;
+ if (!strcmp (p, "?") || !strcmp (p, "0")) {
+ p = end+1;
+ continue;
}
fclose (f);
- *online = FALSE;
+ *online = TRUE;
return TRUE;
+ }
+
+ fclose (f);
+
+ *online = FALSE;
+ return TRUE;
}
/* Provides PPP/ISDN information. */
@@ -182,24 +184,24 @@ static int is_ISDN_on (glibtop *server, int *online)
int
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- int in, out, online;
+ int in, out, online;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0);
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
- if (is_ISDN_on (server, &online)) {
- buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
- GLIBTOP_PPP_STATE_HANGUP;
- buf->flags |= (1L << GLIBTOP_PPP_STATE);
- }
+ if (is_ISDN_on (server, &online)) {
+ buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
+ GLIBTOP_PPP_STATE_HANGUP;
+ buf->flags |= (1L << GLIBTOP_PPP_STATE);
+ }
- if (get_ISDN_stats (server, &in, &out)) {
- buf->bytes_in = in;
- buf->bytes_out = out;
- buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
- (1L << GLIBTOP_PPP_BYTES_OUT);
- }
+ if (get_ISDN_stats (server, &in, &out)) {
+ buf->bytes_in = in;
+ buf->bytes_out = out;
+ buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
+ (1L << GLIBTOP_PPP_BYTES_OUT);
+ }
return 0;
}
diff --git a/sysdeps/kernel/procargs.c b/sysdeps/kernel/procargs.c
index 08fc6163..657d8565 100644
--- a/sysdeps/kernel/procargs.c
+++ b/sysdeps/kernel/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procdata.c b/sysdeps/kernel/procdata.c
index c278d992..27d822e8 100644
--- a/sysdeps/kernel/procdata.c
+++ b/sysdeps/kernel/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/prockernel.c b/sysdeps/kernel/prockernel.c
index 0e59a0dc..489d174c 100644
--- a/sysdeps/kernel/prockernel.c
+++ b/sysdeps/kernel/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c
index ec9be9ff..8404ed86 100644
--- a/sysdeps/kernel/proclist.c
+++ b/sysdeps/kernel/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procmap.c b/sysdeps/kernel/procmap.c
index 010fafa2..798461d0 100644
--- a/sysdeps/kernel/procmap.c
+++ b/sysdeps/kernel/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procmem.c b/sysdeps/kernel/procmem.c
index 8f9f54eb..0b48800f 100644
--- a/sysdeps/kernel/procmem.c
+++ b/sysdeps/kernel/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procsegment.c b/sysdeps/kernel/procsegment.c
index 2bdeb0f1..9e15ac37 100644
--- a/sysdeps/kernel/procsegment.c
+++ b/sysdeps/kernel/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procsignal.c b/sysdeps/kernel/procsignal.c
index 4626af5d..4fcc092e 100644
--- a/sysdeps/kernel/procsignal.c
+++ b/sysdeps/kernel/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procstate.c b/sysdeps/kernel/procstate.c
index 9a5b7483..a596c54a 100644
--- a/sysdeps/kernel/procstate.c
+++ b/sysdeps/kernel/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/proctime.c b/sysdeps/kernel/proctime.c
index 15e3cb83..b779e0aa 100644
--- a/sysdeps/kernel/proctime.c
+++ b/sysdeps/kernel/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/procuid.c b/sysdeps/kernel/procuid.c
index 8d00eec5..12ae619e 100644
--- a/sysdeps/kernel/procuid.c
+++ b/sysdeps/kernel/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/sem_limits.c b/sysdeps/kernel/sem_limits.c
index 0dfaa7ce..3f3be427 100644
--- a/sysdeps/kernel/sem_limits.c
+++ b/sysdeps/kernel/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/shm_limits.c b/sysdeps/kernel/shm_limits.c
index 4dcf3338..8eef4ac2 100644
--- a/sysdeps/kernel/shm_limits.c
+++ b/sysdeps/kernel/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/siglist.c b/sysdeps/kernel/siglist.c
index d00223c0..ef58e9c9 100644
--- a/sysdeps/kernel/siglist.c
+++ b/sysdeps/kernel/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/swap.c b/sysdeps/kernel/swap.c
index e5c64e4a..9a1099c3 100644
--- a/sysdeps/kernel/swap.c
+++ b/sysdeps/kernel/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/kernel/sysinfo.c b/sysdeps/kernel/sysinfo.c
index 08de5db2..33acac0d 100644
--- a/sysdeps/kernel/sysinfo.c
+++ b/sysdeps/kernel/sysinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,62 +37,62 @@ static glibtop_sysinfo sysinfo;
static void
init_sysinfo (glibtop *server)
{
- char buffer [BUFSIZ];
- static int init = 0;
- glibtop_entry *cpuinfo = NULL;
- FILE *f;
+ char buffer [BUFSIZ];
+ static int init = 0;
+ glibtop_entry *cpuinfo = NULL;
+ FILE *f;
- if (init) return;
+ if (init) return;
- init = TRUE;
+ init = TRUE;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
- memset (&sysinfo, 0, sizeof (glibtop_sysinfo));
+ memset (&sysinfo, 0, sizeof (glibtop_sysinfo));
- g_return_if_fail (f = fopen ("/proc/cpuinfo", "r"));
+ g_return_if_fail (f = fopen ("/proc/cpuinfo", "r"));
- while (fgets (buffer, BUFSIZ, f)) {
- char *p, *start, *key, *value;
+ while (fgets (buffer, BUFSIZ, f)) {
+ char *p, *start, *key, *value;
- if (cpuinfo == NULL) {
- cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++];
+ if (cpuinfo == NULL) {
+ cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++];
- cpuinfo->labels = g_ptr_array_new ();
+ cpuinfo->labels = g_ptr_array_new ();
- cpuinfo->values = g_hash_table_new (NULL, NULL);
+ cpuinfo->values = g_hash_table_new (NULL, NULL);
- if (sysinfo.ncpu > GLIBTOP_NCPU)
- sysinfo.ncpu = GLIBTOP_NCPU;
- }
+ if (sysinfo.ncpu > GLIBTOP_NCPU)
+ sysinfo.ncpu = GLIBTOP_NCPU;
+ }
- p = strchr (buffer, ':');
- if (!p) continue;
+ p = strchr (buffer, ':');
+ if (!p) continue;
- /* Remove leading spaces from `p'. */
- *p = '\0'; start = p; p++;
- while (isspace (*p)) p++;
+ /* Remove leading spaces from `p'. */
+ *p = '\0'; start = p; p++;
+ while (isspace (*p)) p++;
- /* Remove trailing spaces from `buffer'. */
- while ((start > buffer) && (*start) && isspace (*start))
- *start-- = '\0';
+ /* Remove trailing spaces from `buffer'. */
+ while ((start > buffer) && (*start) && isspace (*start))
+ *start-- = '\0';
- key = g_strdup (buffer);
- value = g_strdup (p);
+ key = g_strdup (buffer);
+ value = g_strdup (p);
- g_ptr_array_add (cpuinfo->labels, key);
+ g_ptr_array_add (cpuinfo->labels, key);
- g_hash_table_insert (cpuinfo->values, key, value);
- }
+ g_hash_table_insert (cpuinfo->values, key, value);
+ }
- fclose (f);
+ fclose (f);
- sysinfo.flags = _glibtop_sysdeps_sysinfo;
+ sysinfo.flags = _glibtop_sysdeps_sysinfo;
}
glibtop_sysinfo *
glibtop_get_sysinfo_s (glibtop *server)
{
- init_sysinfo (server);
- return &sysinfo;
+ init_sysinfo (server);
+ return &sysinfo;
}
diff --git a/sysdeps/kernel/uptime.c b/sysdeps/kernel/uptime.c
index 463afc48..985e28b3 100644
--- a/sysdeps/kernel/uptime.c
+++ b/sysdeps/kernel/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/linux/close.c b/sysdeps/linux/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/linux/close.c
+++ b/sysdeps/linux/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c
index 4d4cec00..f8918611 100644
--- a/sysdeps/linux/cpu.c
+++ b/sysdeps/linux/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -40,12 +42,12 @@ static const unsigned long _glibtop_sysdeps_cpu_smp =
int
glibtop_init_cpu_s (glibtop *server)
{
- server->sysdeps.cpu = _glibtop_sysdeps_cpu;
+ server->sysdeps.cpu = _glibtop_sysdeps_cpu;
- if (server->ncpu)
- server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp;
+ if (server->ncpu)
+ server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp;
- return 0;
+ return 0;
}
/* Provides information about cpu usage. */
@@ -55,69 +57,69 @@ glibtop_init_cpu_s (glibtop *server)
int
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
- char buffer [BUFSIZ], *p;
- int fd, len, i;
- u_int64_t total;
-
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
+ char buffer [BUFSIZ], *p;
+ int fd, len, i;
+ u_int64_t total;
- memset (buf, 0, sizeof (glibtop_cpu));
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
- fd = open (FILENAME, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", FILENAME);
- return -1;
- }
+ memset (buf, 0, sizeof (glibtop_cpu));
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", FILENAME);
- return -1;
- }
+ fd = open (FILENAME, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", FILENAME);
+ return -1;
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", FILENAME);
+ return -1;
+ }
+
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- p = skip_token (buffer); /* "cpu" */
+ p = skip_token (buffer); /* "cpu" */
- buf->user = strtoul (p, &p, 0);
- buf->nice = strtoul (p, &p, 0);
- buf->sys = strtoul (p, &p, 0);
- buf->idle = strtoul (p, &p, 0);
+ buf->user = strtoul (p, &p, 0);
+ buf->nice = strtoul (p, &p, 0);
+ buf->sys = strtoul (p, &p, 0);
+ buf->idle = strtoul (p, &p, 0);
- total = buf->user;
- total += buf->nice;
- total += buf->sys;
- total += buf->idle;
- buf->total = total;
+ total = buf->user;
+ total += buf->nice;
+ total += buf->sys;
+ total += buf->idle;
+ buf->total = total;
- buf->frequency = 100;
- buf->flags = _glibtop_sysdeps_cpu;
+ buf->frequency = 100;
+ buf->flags = _glibtop_sysdeps_cpu;
- for (i = 0; i < server->ncpu; i++) {
- if (strncmp (p+1, "cpu", 3) || !isdigit (p [4]))
- break;
+ for (i = 0; i < server->ncpu; i++) {
+ if (strncmp (p+1, "cpu", 3) || !isdigit (p [4]))
+ break;
- buf->xcpu_flags |= (1L << (u_int64_t) i);
+ buf->xcpu_flags |= (1L << (u_int64_t) i);
- p += 6;
- buf->xcpu_user [i] = strtoul (p, &p, 0);
- buf->xcpu_nice [i] = strtoul (p, &p, 0);
- buf->xcpu_sys [i] = strtoul (p, &p, 0);
- buf->xcpu_idle [i] = strtoul (p, &p, 0);
+ p += 6;
+ buf->xcpu_user [i] = strtoul (p, &p, 0);
+ buf->xcpu_nice [i] = strtoul (p, &p, 0);
+ buf->xcpu_sys [i] = strtoul (p, &p, 0);
+ buf->xcpu_idle [i] = strtoul (p, &p, 0);
- total = buf->xcpu_user [i];
- total += buf->xcpu_nice [i];
- total += buf->xcpu_sys [i];
- total += buf->xcpu_idle [i];
+ total = buf->xcpu_user [i];
+ total += buf->xcpu_nice [i];
+ total += buf->xcpu_sys [i];
+ total += buf->xcpu_idle [i];
- buf->xcpu_total [i] = total;
- }
+ buf->xcpu_total [i] = total;
+ }
- if (buf->xcpu_flags)
- buf->flags |= _glibtop_sysdeps_cpu_smp;
+ if (buf->xcpu_flags)
+ buf->flags |= _glibtop_sysdeps_cpu_smp;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/glibtop_machine.h b/sysdeps/linux/glibtop_machine.h
index 9386b1b4..dc0ee227 100644
--- a/sysdeps/linux/glibtop_machine.h
+++ b/sysdeps/linux/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -46,11 +48,11 @@ typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
- pid_t last_pid;
- int no_update;
- int fd_stat, fd_meminfo, fd_loadavg;
- char proc_stat [BUFSIZ], proc_statm [BUFSIZ];
- char proc_status [BUFSIZ];
+ pid_t last_pid;
+ int no_update;
+ int fd_stat, fd_meminfo, fd_loadavg;
+ char proc_stat [BUFSIZ], proc_statm [BUFSIZ];
+ char proc_status [BUFSIZ];
};
END_LIBGTOP_DECLS
diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h
index 7892a8da..4889d2df 100644
--- a/sysdeps/linux/glibtop_server.h
+++ b/sysdeps/linux/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,76 +36,76 @@ BEGIN_LIBGTOP_DECLS
static inline char *
skip_token (const char *p)
{
- while (isspace(*p)) p++;
- while (*p && !isspace(*p)) p++;
- return (char *)p;
+ while (isspace(*p)) p++;
+ while (*p && !isspace(*p)) p++;
+ return (char *)p;
}
static inline char *
skip_multiple_token (const char *p, int count)
{
- int i;
+ int i;
- for (i = 0; i < count; i++)
- p = skip_token (p);
+ for (i = 0; i < count; i++)
+ p = skip_token (p);
- return (char *)p;
+ return (char *)p;
}
static inline char *
skip_line (const char *p)
{
- while (*p != '\n') p++;
- return (char *) ++p;
+ while (*p != '\n') p++;
+ return (char *) ++p;
}
static inline int
proc_file_to_buffer (char *buffer, const char *fmt, pid_t pid)
{
- char filename [BUFSIZ];
- int fd, len;
+ char filename [BUFSIZ];
+ int fd, len;
- sprintf (filename, fmt, pid);
+ sprintf (filename, fmt, pid);
- fd = open (filename, O_RDONLY);
- if (fd < 0) return -1;
+ fd = open (filename, O_RDONLY);
+ if (fd < 0) return -1;
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) return -1;
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) return -1;
- close (fd);
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- return 0;
+ return 0;
}
static inline int
proc_stat_to_buffer (char *buffer, pid_t pid)
{
- return proc_file_to_buffer (buffer, "/proc/%d/stat", pid);
+ return proc_file_to_buffer (buffer, "/proc/%d/stat", pid);
}
static inline int
proc_status_to_buffer (char *buffer, pid_t pid)
{
- return proc_file_to_buffer (buffer, "/proc/%d/status", pid);
+ return proc_file_to_buffer (buffer, "/proc/%d/status", pid);
}
static inline int
proc_statm_to_buffer (char *buffer, pid_t pid)
{
- return proc_file_to_buffer (buffer, "/proc/%d/statm", pid);
+ return proc_file_to_buffer (buffer, "/proc/%d/statm", pid);
}
static inline char *
proc_stat_after_cmd (char *p)
{
- p = strrchr (p, ')');
- if (!p) return p;
+ p = strrchr (p, ')');
+ if (!p) return p;
- *p++ = '\0';
- return p;
+ *p++ = '\0';
+ return p;
}
#endif
diff --git a/sysdeps/linux/interfaces.c b/sysdeps/linux/interfaces.c
index bf491632..ea4aa0e8 100644
--- a/sysdeps/linux/interfaces.c
+++ b/sysdeps/linux/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c
index 55cc9284..9bd25a87 100644
--- a/sysdeps/linux/loadavg.c
+++ b/sysdeps/linux/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -38,9 +40,9 @@ static const unsigned long _glibtop_sysdeps_loadavg_tasks =
int
glibtop_init_loadavg_s (glibtop *server)
{
- server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
+ server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
- return 0;
+ return 0;
}
/* Provides load load averange. */
@@ -50,54 +52,54 @@ glibtop_init_loadavg_s (glibtop *server)
int
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{
- char buffer [BUFSIZ], *p, *old;
- int fd, len;
-
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
+ char buffer [BUFSIZ], *p, *old;
+ int fd, len;
- memset (buf, 0, sizeof (glibtop_loadavg));
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
- fd = open (FILENAME, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", FILENAME);
- return -1;
- }
+ memset (buf, 0, sizeof (glibtop_loadavg));
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", FILENAME);
- return -1;
- }
+ fd = open (FILENAME, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", FILENAME);
+ return -1;
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", FILENAME);
+ return -1;
+ }
+
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- buf->loadavg [0] = (float) strtod (buffer, &p);
- buf->loadavg [1] = (float) strtod (p, &p);
- buf->loadavg [2] = (float) strtod (p, &p);
+ buf->loadavg [0] = (float) strtod (buffer, &p);
+ buf->loadavg [1] = (float) strtod (p, &p);
+ buf->loadavg [2] = (float) strtod (p, &p);
- buf->flags = _glibtop_sysdeps_loadavg;
+ buf->flags = _glibtop_sysdeps_loadavg;
- while (isspace(*p)) p++;
+ while (isspace(*p)) p++;
- /* Older Linux versions don't have the nr_running/nr_tasks fields. */
+ /* Older Linux versions don't have the nr_running/nr_tasks fields. */
- old = p;
- while (*p) {
- if (*p == '/')
- break;
- if (!isdigit (*p))
- return 0;
- p++;
- }
+ old = p;
+ while (*p) {
+ if (*p == '/')
+ break;
+ if (!isdigit (*p))
+ return 0;
+ p++;
+ }
- buf->nr_running = strtoul (old, &p, 0); p++;
- buf->nr_tasks = strtoul (p, &p, 0);
- buf->last_pid = strtoul (p, &p, 0);
+ buf->nr_running = strtoul (old, &p, 0); p++;
+ buf->nr_tasks = strtoul (p, &p, 0);
+ buf->last_pid = strtoul (p, &p, 0);
- buf->flags |= _glibtop_sysdeps_loadavg_tasks;
+ buf->flags |= _glibtop_sysdeps_loadavg_tasks;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c
index 3ade560c..ae8770c8 100644
--- a/sysdeps/linux/mem.c
+++ b/sysdeps/linux/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,9 +38,9 @@ static const unsigned long _glibtop_sysdeps_mem =
int
glibtop_init_mem_s (glibtop *server)
{
- server->sysdeps.mem = _glibtop_sysdeps_mem;
+ server->sysdeps.mem = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
/* Provides information about memory usage. */
@@ -48,44 +50,44 @@ glibtop_init_mem_s (glibtop *server)
int
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{
- char buffer [BUFSIZ], *p;
- int fd, len;
+ char buffer [BUFSIZ], *p;
+ int fd, len;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- fd = open (FILENAME, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", FILENAME);
- return -1;
+ fd = open (FILENAME, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", FILENAME);
+ return -1;
- }
-
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", FILENAME);
- return -1;
- }
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", FILENAME);
+ return -1;
+ }
+
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- p = skip_line (buffer);
- p = skip_token (p); /* "Mem:" */
+ p = skip_line (buffer);
+ p = skip_token (p); /* "Mem:" */
- buf->total = strtoul (p, &p, 0);
- buf->used = strtoul (p, &p, 0);
- buf->free = strtoul (p, &p, 0);
- buf->shared = strtoul (p, &p, 0);
- buf->buffer = strtoul (p, &p, 0);
- buf->cached = strtoul (p, &p, 0);
+ buf->total = strtoul (p, &p, 0);
+ buf->used = strtoul (p, &p, 0);
+ buf->free = strtoul (p, &p, 0);
+ buf->shared = strtoul (p, &p, 0);
+ buf->buffer = strtoul (p, &p, 0);
+ buf->cached = strtoul (p, &p, 0);
- buf->user = buf->total - buf->free - buf->shared - buf->buffer;
+ buf->user = buf->total - buf->free - buf->shared - buf->buffer;
- buf->flags = _glibtop_sysdeps_mem;
+ buf->flags = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c
index 46d15b37..2fe1d46c 100644
--- a/sysdeps/linux/msg_limits.c
+++ b/sysdeps/linux/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -37,9 +39,9 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
int
glibtop_init_msg_limits_s (glibtop *server)
{
- server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
+ server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -47,23 +49,23 @@ glibtop_init_msg_limits_s (glibtop *server)
int
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
{
- struct msginfo msginfo;
+ struct msginfo msginfo;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- buf->flags = _glibtop_sysdeps_msg_limits;
+ buf->flags = _glibtop_sysdeps_msg_limits;
- msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
+ msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
- buf->msgpool = msginfo.msgpool;
- buf->msgmap = msginfo.msgmap;
- buf->msgmax = msginfo.msgmax;
- buf->msgmnb = msginfo.msgmnb;
- buf->msgmni = msginfo.msgmni;
- buf->msgssz = msginfo.msgssz;
- buf->msgtql = msginfo.msgtql;
-
- return 0;
+ buf->msgpool = msginfo.msgpool;
+ buf->msgmap = msginfo.msgmap;
+ buf->msgmax = msginfo.msgmax;
+ buf->msgmnb = msginfo.msgmnb;
+ buf->msgmni = msginfo.msgmni;
+ buf->msgssz = msginfo.msgssz;
+ buf->msgtql = msginfo.msgtql;
+
+ return 0;
}
diff --git a/sysdeps/linux/netinfo.c b/sysdeps/linux/netinfo.c
index 3cdafa2f..db7593ae 100644
--- a/sysdeps/linux/netinfo.c
+++ b/sysdeps/linux/netinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/linux/netload.c b/sysdeps/linux/netload.c
index d42c524e..2cd20d76 100644
--- a/sysdeps/linux/netload.c
+++ b/sysdeps/linux/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -90,7 +92,7 @@ glibtop_init_netload_s (glibtop *server)
_glibtop_sysdeps_netload_bytes |
_glibtop_sysdeps_netload_packets;
- return 0;
+ return 0;
}
/* Provides network statistics. */
@@ -107,9 +109,9 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
memset (buf, 0, sizeof (glibtop_netload));
/* Linux 2.1.114 - don't know where exactly this was added, but
- * recent kernels have byte count in /proc/net/dev so we don't
- * need IP accounting.
- */
+ * recent kernels have byte count in /proc/net/dev so we don't
+ * need IP accounting.
+ */
if (server->os_version_code < 131442) {
@@ -188,17 +190,17 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
}
/* Ok, either IP accounting is not enabled in the kernel or
- * it was not enabled for the requested interface. */
+ * it was not enabled for the requested interface. */
f = fopen ("/proc/net/dev", "r");
if (!f) return -1;
- /* Skip over the header line. */
+ /* Skip over the header line. */
fgets (buffer, BUFSIZ-1, f);
fgets (buffer, BUFSIZ-1, f);
- /* Starting with 2.1.xx (don't know exactly which version)
- * /proc/net/dev contains both byte and package counters. */
+ /* Starting with 2.1.xx (don't know exactly which version)
+ * /proc/net/dev contains both byte and package counters. */
p = strchr (buffer, '|');
if (!p) {
@@ -210,7 +212,7 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
have_bytes = strncmp (++p, "bytes", 5) == 0;
/* Count remaining 'Receive' fields so we know where
- * the first 'Transmit' field starts. */
+ * the first 'Transmit' field starts. */
fields = 0;
while (*p != '|') {
diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c
index f54a7e8d..ee311aa2 100644
--- a/sysdeps/linux/open.c
+++ b/sysdeps/linux/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -61,41 +63,41 @@ glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
- char buffer [BUFSIZ], *p;
- int fd, len, i;
+ char buffer [BUFSIZ], *p;
+ int fd, len, i;
- server->name = program_name;
+ server->name = program_name;
- set_linux_version ();
- server->os_version_code = (unsigned long) linux_version_code;
+ set_linux_version ();
+ server->os_version_code = (unsigned long) linux_version_code;
- server->ncpu = 0;
+ server->ncpu = 0;
- fd = open (FILENAME, O_RDONLY);
- if (fd < 0)
- glibtop_error_io_r (server, "open (%s)", FILENAME);
+ fd = open (FILENAME, O_RDONLY);
+ if (fd < 0)
+ glibtop_error_io_r (server, "open (%s)", FILENAME);
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0)
- glibtop_error_io_r (server, "read (%s)", FILENAME);
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0)
+ glibtop_error_io_r (server, "read (%s)", FILENAME);
- close (fd);
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- p = skip_multiple_token (buffer, 5) + 1;
+ p = skip_multiple_token (buffer, 5) + 1;
- for (i = 0; i < GLIBTOP_NCPU; i++) {
+ for (i = 0; i < GLIBTOP_NCPU; i++) {
- if (strncmp (p, "cpu", 3) || !isdigit (p [3]))
- break;
+ if (strncmp (p, "cpu", 3) || !isdigit (p [3]))
+ break;
- server->ncpu++;
+ server->ncpu++;
- p = skip_multiple_token (p, 5) + 1;
- }
+ p = skip_multiple_token (p, 5) + 1;
+ }
#if DEBUG
- printf ("\nThis machine has %d CPUs.\n\n", server->ncpu);
+ printf ("\nThis machine has %d CPUs.\n\n", server->ncpu);
#endif
}
diff --git a/sysdeps/linux/ppp.c b/sysdeps/linux/ppp.c
index 8830c84d..6c1ced21 100644
--- a/sysdeps/linux/ppp.c
+++ b/sysdeps/linux/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -44,137 +46,137 @@ static const unsigned long _glibtop_sysdeps_ppp =
int
glibtop_init_ppp_s (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
- return 0;
+ return 0;
}
static int
get_ISDN_stats (glibtop *server, int *in, int *out)
{
- unsigned long *isdn_stats, *ptr;
- int fd, i;
+ unsigned long *isdn_stats, *ptr;
+ int fd, i;
- *in = *out = 0;
+ *in = *out = 0;
- isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
- sizeof (unsigned long));
+ isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2,
+ sizeof (unsigned long));
- fd = open ("/dev/isdninfo", O_RDONLY);
- if (fd < 0) {
- glibtop_free_r (server, isdn_stats);
- return FALSE;
- }
+ fd = open ("/dev/isdninfo", O_RDONLY);
+ if (fd < 0) {
+ glibtop_free_r (server, isdn_stats);
+ return FALSE;
+ }
- if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
- glibtop_free_r (server, isdn_stats);
- close (fd);
+ if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) {
+ glibtop_free_r (server, isdn_stats);
+ close (fd);
- return FALSE;
- }
+ return FALSE;
+ }
- for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) {
- *in += *ptr++; *out += *ptr++;
- }
+ for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) {
+ *in += *ptr++; *out += *ptr++;
+ }
- glibtop_free_r (server, isdn_stats);
- close (fd);
+ glibtop_free_r (server, isdn_stats);
+ close (fd);
- return TRUE;
+ return TRUE;
}
static int is_ISDN_on (glibtop *server, int *online)
{
- FILE *f = 0;
- char buffer [BUFSIZ], *p;
- int i;
-
- /* Perhaps I should try to explain this code a little bit.
- *
- * ------------------------------------------------------------
- * This is from the manpage of isdninfo(4):
- *
- * DESCRIPTION
- * /dev/isdninfo is a character device with major number 45
- * and minor number 255. It delivers status information from
- * the Linux ISDN subsystem to user level.
- *
- * DATA FORMAT
- * When reading from this device, the current status of the
- * Linux ISDN subsystem is delivered in 6 lines of text. Each
- * line starts with a tag string followed by a colon and
- * whitespace. After that the status values are appended sep-
- * arated by whitespace.
- *
- * flags is the tag of line 5. In this line for every driver
- * slot, it's B-Channel status is shown. If no driver
- * is registered in a slot, a ? is shown. For every
- * established B-Channel of the driver, a bit is set
- * in the shown value. The driver's first channel is
- * mapped to bit 0, the second channel to bit 1 and so
- * on.
- * ------------------------------------------------------------
- *
- * So we open /dev/isdninfo, discard the first four lines of text
- * and then check whether we have something that is not `0' or `?'
- * in one of the flags fields.
- *
- * Sounds complicated, but I don't see any other way to check whether
- * we are connected. Also, this is the method some other ISDN tools
- * for Linux use.
- *
- * Martin
- */
-
- f = fopen ("/dev/isdninfo", "r");
-
- if (!f) return FALSE;
-
- for (i = 0; i < 5; i++) {
- if (fgets (buffer, BUFSIZ, f) == NULL) {
- fclose (f);
- return FALSE;
- }
+ FILE *f = 0;
+ char buffer [BUFSIZ], *p;
+ int i;
+
+ /* Perhaps I should try to explain this code a little bit.
+ *
+ * ------------------------------------------------------------
+ * This is from the manpage of isdninfo(4):
+ *
+ * DESCRIPTION
+ * /dev/isdninfo is a character device with major number 45
+ * and minor number 255. It delivers status information from
+ * the Linux ISDN subsystem to user level.
+ *
+ * DATA FORMAT
+ * When reading from this device, the current status of the
+ * Linux ISDN subsystem is delivered in 6 lines of text. Each
+ * line starts with a tag string followed by a colon and
+ * whitespace. After that the status values are appended sep-
+ * arated by whitespace.
+ *
+ * flags is the tag of line 5. In this line for every driver
+ * slot, it's B-Channel status is shown. If no driver
+ * is registered in a slot, a ? is shown. For every
+ * established B-Channel of the driver, a bit is set
+ * in the shown value. The driver's first channel is
+ * mapped to bit 0, the second channel to bit 1 and so
+ * on.
+ * ------------------------------------------------------------
+ *
+ * So we open /dev/isdninfo, discard the first four lines of text
+ * and then check whether we have something that is not `0' or `?'
+ * in one of the flags fields.
+ *
+ * Sounds complicated, but I don't see any other way to check whether
+ * we are connected. Also, this is the method some other ISDN tools
+ * for Linux use.
+ *
+ * Martin
+ */
+
+ f = fopen ("/dev/isdninfo", "r");
+
+ if (!f) return FALSE;
+
+ for (i = 0; i < 5; i++) {
+ if (fgets (buffer, BUFSIZ, f) == NULL) {
+ fclose (f);
+ return FALSE;
}
+ }
- if (strncmp (buffer, "flags:", 6)) {
- fclose (f);
- return FALSE;
- }
-
- p = buffer+6;
-
- while (*p) {
- char *end = p;
+ if (strncmp (buffer, "flags:", 6)) {
+ fclose (f);
+ return FALSE;
+ }
- if (isspace (*p)) {
- p++;
- continue;
- }
+ p = buffer+6;
- for (end = p; *end && !isspace (*end); end++)
- ;
+ while (*p) {
+ char *end = p;
- if (*end == 0)
- break;
- else
- *end = 0;
+ if (isspace (*p)) {
+ p++;
+ continue;
+ }
- if (!strcmp (p, "?") || !strcmp (p, "0")) {
- p = end+1;
- continue;
- }
+ for (end = p; *end && !isspace (*end); end++)
+ ;
- fclose (f);
+ if (*end == 0)
+ break;
+ else
+ *end = 0;
- *online = TRUE;
- return TRUE;
+ if (!strcmp (p, "?") || !strcmp (p, "0")) {
+ p = end+1;
+ continue;
}
fclose (f);
- *online = FALSE;
+ *online = TRUE;
return TRUE;
+ }
+
+ fclose (f);
+
+ *online = FALSE;
+ return TRUE;
}
/* Provides PPP/ISDN information. */
@@ -182,24 +184,24 @@ static int is_ISDN_on (glibtop *server, int *online)
int
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- int in, out, online;
+ int in, out, online;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0);
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
- if (is_ISDN_on (server, &online)) {
- buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
- GLIBTOP_PPP_STATE_HANGUP;
- buf->flags |= (1L << GLIBTOP_PPP_STATE);
- }
+ if (is_ISDN_on (server, &online)) {
+ buf->state = online ? GLIBTOP_PPP_STATE_ONLINE :
+ GLIBTOP_PPP_STATE_HANGUP;
+ buf->flags |= (1L << GLIBTOP_PPP_STATE);
+ }
- if (get_ISDN_stats (server, &in, &out)) {
- buf->bytes_in = in;
- buf->bytes_out = out;
- buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
- (1L << GLIBTOP_PPP_BYTES_OUT);
- }
+ if (get_ISDN_stats (server, &in, &out)) {
+ buf->bytes_in = in;
+ buf->bytes_out = out;
+ buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) |
+ (1L << GLIBTOP_PPP_BYTES_OUT);
+ }
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/procargs.c b/sysdeps/linux/procargs.c
index aa2019ee..8e889745 100644
--- a/sysdeps/linux/procargs.c
+++ b/sysdeps/linux/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_args =
int
glibtop_init_proc_args_s (glibtop *server)
{
- server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
+ server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,51 +47,51 @@ char *
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
- char fn [BUFSIZ], buffer [BUFSIZ];
- int cmdline, len, total = 0;
- char *retval = NULL;
+ char fn [BUFSIZ], buffer [BUFSIZ];
+ int cmdline, len, total = 0;
+ char *retval = NULL;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0);
- memset (buf, 0, sizeof (glibtop_proc_args));
+ memset (buf, 0, sizeof (glibtop_proc_args));
- sprintf (fn, "/proc/%d/cmdline", pid);
+ sprintf (fn, "/proc/%d/cmdline", pid);
- cmdline = open (fn, O_RDONLY);
- if (cmdline < 0) return NULL;
+ cmdline = open (fn, O_RDONLY);
+ if (cmdline < 0) return NULL;
- if (max_len) {
- retval = glibtop_malloc_r (server, max_len+1);
+ if (max_len) {
+ retval = glibtop_malloc_r (server, max_len+1);
- len = read (cmdline, retval, max_len);
- if (len < 0) {
- glibtop_free_r (server, retval);
- return NULL;
- }
-
- return retval;
+ len = read (cmdline, retval, max_len);
+ if (len < 0) {
+ glibtop_free_r (server, retval);
+ return NULL;
}
+
+ return retval;
+ }
- while (1) {
- len = read (cmdline, buffer, BUFSIZ-1);
- if (len < 0) {
- glibtop_free_r (server, retval);
- return NULL;
- }
+ while (1) {
+ len = read (cmdline, buffer, BUFSIZ-1);
+ if (len < 0) {
+ glibtop_free_r (server, retval);
+ return NULL;
+ }
- if (len == 0)
- break;
+ if (len == 0)
+ break;
- retval = glibtop_realloc_r (server, retval, total+len+1);
- memcpy (retval+total, buffer, len);
- *(retval+total+len) = 0;
- total += len;
- }
+ retval = glibtop_realloc_r (server, retval, total+len+1);
+ memcpy (retval+total, buffer, len);
+ *(retval+total+len) = 0;
+ total += len;
+ }
- close (cmdline);
+ close (cmdline);
- buf->size = total;
- buf->flags = _glibtop_sysdeps_proc_args;
+ buf->size = total;
+ buf->flags = _glibtop_sysdeps_proc_args;
- return retval;
+ return retval;
}
diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c
index 7908ab82..f0e180ae 100644
--- a/sysdeps/linux/prockernel.c
+++ b/sysdeps/linux/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,9 +38,9 @@ static const unsigned long _glibtop_sysdeps_proc_kernel =
int
glibtop_init_proc_kernel_s (glibtop *server)
{
- server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
+ server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -46,36 +48,36 @@ glibtop_init_proc_kernel_s (glibtop *server)
int
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid)
{
- char buffer [BUFSIZ], *p;
+ char buffer [BUFSIZ], *p;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 6);
+ p = skip_multiple_token (p, 6);
- buf->k_flags = strtoul (p, &p, 0);
- buf->min_flt = strtoul (p, &p, 0);
- buf->cmin_flt = strtoul (p, &p, 0);
- buf->maj_flt = strtoul (p, &p, 0);
- buf->cmaj_flt = strtoul (p, &p, 0);
+ buf->k_flags = strtoul (p, &p, 0);
+ buf->min_flt = strtoul (p, &p, 0);
+ buf->cmin_flt = strtoul (p, &p, 0);
+ buf->maj_flt = strtoul (p, &p, 0);
+ buf->cmaj_flt = strtoul (p, &p, 0);
- p = skip_multiple_token (p, 15);
+ p = skip_multiple_token (p, 15);
- buf->kstk_esp = strtoul (p, &p, 0);
- buf->kstk_eip = strtoul (p, &p, 0);
+ buf->kstk_esp = strtoul (p, &p, 0);
+ buf->kstk_eip = strtoul (p, &p, 0);
- p = skip_multiple_token (p, 4);
+ p = skip_multiple_token (p, 4);
- buf->nwchan = strtoul (p, &p, 0);
+ buf->nwchan = strtoul (p, &p, 0);
- buf->flags = _glibtop_sysdeps_proc_kernel;
+ buf->flags = _glibtop_sysdeps_proc_kernel;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c
index 329c0235..e7d47774 100644
--- a/sysdeps/linux/proclist.c
+++ b/sysdeps/linux/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -42,9 +44,9 @@ static const unsigned long _glibtop_sysdeps_proclist =
int
glibtop_init_proclist_s (glibtop *server)
{
- server->sysdeps.proclist = _glibtop_sysdeps_proclist;
+ server->sysdeps.proclist = _glibtop_sysdeps_proclist;
- return 0;
+ return 0;
}
#define BLOCK_COUNT 256
@@ -67,176 +69,176 @@ unsigned *
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
- DIR *proc;
- struct dirent *entry;
- char buffer [BUFSIZ];
- unsigned count, total, pid;
- unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
- unsigned pids_size = 0, pids_offset = 0, new_size;
- struct stat statb;
- int len, i, ok;
+ DIR *proc;
+ struct dirent *entry;
+ char buffer [BUFSIZ];
+ unsigned count, total, pid;
+ unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
+ unsigned pids_size = 0, pids_offset = 0, new_size;
+ struct stat statb;
+ int len, i, ok;
- glibtop_proc_uid procuid;
- glibtop_proc_state procstate;
+ glibtop_proc_uid procuid;
+ glibtop_proc_state procstate;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 0);
- memset (buf, 0, sizeof (glibtop_proclist));
+ memset (buf, 0, sizeof (glibtop_proclist));
- proc = opendir ("/proc");
- if (!proc) return NULL;
+ proc = opendir ("/proc");
+ if (!proc) return NULL;
- /* read every every entry in /proc */
+ /* read every every entry in /proc */
- for (count = total = 0, entry = readdir (proc);
- entry; entry = readdir (proc)) {
- ok = 1; len = strlen (entry->d_name);
+ for (count = total = 0, entry = readdir (proc);
+ entry; entry = readdir (proc)) {
+ ok = 1; len = strlen (entry->d_name);
- /* does it consist entirely of digits? */
+ /* does it consist entirely of digits? */
- for (i = 0; i < len; i++)
- if (!isdigit (entry->d_name [i])) ok = 0;
- if (!ok) continue;
+ for (i = 0; i < len; i++)
+ if (!isdigit (entry->d_name [i])) ok = 0;
+ if (!ok) continue;
- /* convert it in a number */
+ /* convert it in a number */
- if (sscanf (entry->d_name, "%u", &pid) != 1) continue;
+ if (sscanf (entry->d_name, "%u", &pid) != 1) continue;
- /* is it really a directory? */
+ /* is it really a directory? */
- sprintf (buffer, "/proc/%d", pid);
-
- if (stat (buffer, &statb)) continue;
-
- if (!S_ISDIR (statb.st_mode)) continue;
-
- switch (which & GLIBTOP_KERN_PROC_MASK) {
- case GLIBTOP_KERN_PROC_ALL:
- break;
- case GLIBTOP_KERN_PROC_PID:
- if ((unsigned) arg != pid)
- continue;
- break;
- case GLIBTOP_KERN_PROC_UID:
- if ((uid_t) arg != statb.st_uid)
- continue;
- break;
- case GLIBTOP_KERN_PROC_PGRP:
- /* Do you really, really need this ? */
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_PGRP))
- if ((int) arg != procuid.pgrp)
- continue;
- break;
- case GLIBTOP_KERN_PROC_PPID:
- /* Do you really, really need this ? */
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_PPID))
- if ((int) arg != procuid.ppid)
- continue;
- break;
- case GLIBTOP_KERN_PROC_SESSION:
- /* Do you really, really need this ? */
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_SESSION))
- if ((int) arg != procuid.session)
- continue;
- break;
- case GLIBTOP_KERN_PROC_TTY:
- /* Do you really, really need this ? */
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
- if ((int) arg != procuid.tty)
- continue;
- break;
- case GLIBTOP_KERN_PROC_RUID:
- /* Do you really, really need this ? */
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_EUID))
- if ((int) arg != procuid.euid)
- continue;
- break;
- }
-
- if (which & GLIBTOP_EXCLUDE_NOTTY) {
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
- if (procuid.tty == -1) continue;
- }
-
- if (which & GLIBTOP_EXCLUDE_IDLE) {
- glibtop_get_proc_state_s (server, &procstate, pid);
- if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE))
- if (!(procstate.state & GLIBTOP_PROCESS_RUNNING)) continue;
- }
-
- if (which & GLIBTOP_EXCLUDE_SYSTEM) {
- glibtop_get_proc_uid_s (server, &procuid, pid);
- if (procuid.flags & (1L << GLIBTOP_PROC_UID_UID))
- if (procuid.uid == 0) continue;
- }
-
- /* Fine. Now we first try to store it in pids. If this buffer is
- * full, we copy it to the pids_chain. */
-
- if (count >= BLOCK_COUNT) {
- /* The following call to glibtop_realloc will be
- * equivalent to glibtop_malloc () if `pids_chain' is
- * NULL. We just calculate the new size and copy `pids'
- * to the beginning of the newly allocated block. */
-
- new_size = pids_size + BLOCK_SIZE;
-
- pids_chain = glibtop_realloc_r
- (server, pids_chain, new_size);
-
- memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);
-
- pids_size = new_size;
-
- pids_offset += BLOCK_COUNT;
-
- count = 0;
- }
-
- /* pids is now big enough to hold at least one single pid. */
+ sprintf (buffer, "/proc/%d", pid);
- pids [count++] = pid;
+ if (stat (buffer, &statb)) continue;
+
+ if (!S_ISDIR (statb.st_mode)) continue;
+
+ switch (which & GLIBTOP_KERN_PROC_MASK) {
+ case GLIBTOP_KERN_PROC_ALL:
+ break;
+ case GLIBTOP_KERN_PROC_PID:
+ if ((unsigned) arg != pid)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_UID:
+ if ((uid_t) arg != statb.st_uid)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_PGRP:
+ /* Do you really, really need this ? */
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_PGRP))
+ if ((int) arg != procuid.pgrp)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_PPID:
+ /* Do you really, really need this ? */
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_PPID))
+ if ((int) arg != procuid.ppid)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_SESSION:
+ /* Do you really, really need this ? */
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_SESSION))
+ if ((int) arg != procuid.session)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_TTY:
+ /* Do you really, really need this ? */
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
+ if ((int) arg != procuid.tty)
+ continue;
+ break;
+ case GLIBTOP_KERN_PROC_RUID:
+ /* Do you really, really need this ? */
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_EUID))
+ if ((int) arg != procuid.euid)
+ continue;
+ break;
+ }
+
+ if (which & GLIBTOP_EXCLUDE_NOTTY) {
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY))
+ if (procuid.tty == -1) continue;
+ }
- total++;
+ if (which & GLIBTOP_EXCLUDE_IDLE) {
+ glibtop_get_proc_state_s (server, &procstate, pid);
+ if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE))
+ if (!(procstate.state & GLIBTOP_PROCESS_RUNNING)) continue;
}
+
+ if (which & GLIBTOP_EXCLUDE_SYSTEM) {
+ glibtop_get_proc_uid_s (server, &procuid, pid);
+ if (procuid.flags & (1L << GLIBTOP_PROC_UID_UID))
+ if (procuid.uid == 0) continue;
+ }
+
+ /* Fine. Now we first try to store it in pids. If this buffer is
+ * full, we copy it to the pids_chain. */
+
+ if (count >= BLOCK_COUNT) {
+ /* The following call to glibtop_realloc will be
+ * equivalent to glibtop_malloc () if `pids_chain' is
+ * NULL. We just calculate the new size and copy `pids'
+ * to the beginning of the newly allocated block. */
+
+ new_size = pids_size + BLOCK_SIZE;
+
+ pids_chain = glibtop_realloc_r
+ (server, pids_chain, new_size);
+
+ memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);
+
+ pids_size = new_size;
+
+ pids_offset += BLOCK_COUNT;
+
+ count = 0;
+ }
+
+ /* pids is now big enough to hold at least one single pid. */
+
+ pids [count++] = pid;
+
+ total++;
+ }
- closedir (proc);
+ closedir (proc);
- /* count is only zero if an error occured (one a running Linux system,
- * we have at least one single process). */
+ /* count is only zero if an error occured (one a running Linux system,
+ * we have at least one single process). */
- if (!count) return NULL;
+ if (!count) return NULL;
- /* The following call to glibtop_realloc will be equivalent to
- * glibtop_malloc if pids_chain is NULL. We just calculate the
- * new size and copy pids to the beginning of the newly allocated
- * block. */
+ /* The following call to glibtop_realloc will be equivalent to
+ * glibtop_malloc if pids_chain is NULL. We just calculate the
+ * new size and copy pids to the beginning of the newly allocated
+ * block. */
- new_size = pids_size + count * sizeof (unsigned);
+ new_size = pids_size + count * sizeof (unsigned);
- pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
+ pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
- memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
+ memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
- pids_size = new_size;
+ pids_size = new_size;
- pids_offset += BLOCK_COUNT;
+ pids_offset += BLOCK_COUNT;
- /* Since everything is ok now, we can set buf->flags, fill in the
- * remaining fields and return the `pids_chain'. */
+ /* Since everything is ok now, we can set buf->flags, fill in the
+ * remaining fields and return the `pids_chain'. */
- buf->flags = _glibtop_sysdeps_proclist;
+ buf->flags = _glibtop_sysdeps_proclist;
- buf->size = sizeof (unsigned);
- buf->number = total;
+ buf->size = sizeof (unsigned);
+ buf->number = total;
- buf->total = total * sizeof (unsigned);
+ buf->total = total * sizeof (unsigned);
- return pids_chain;
+ return pids_chain;
}
diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c
index 58150eca..23ca2675 100644
--- a/sysdeps/linux/procmap.c
+++ b/sysdeps/linux/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -41,9 +43,9 @@ static const unsigned long _glibtop_sysdeps_map_entry =
int
glibtop_init_proc_map_s (glibtop *server)
{
- server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -51,90 +53,90 @@ glibtop_init_proc_map_s (glibtop *server)
glibtop_map_entry *
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
{
- char fn [BUFSIZ];
- glibtop_map_entry *entry_list = NULL;
- int rv, n = 0;
- FILE *maps;
+ char fn [BUFSIZ];
+ glibtop_map_entry *entry_list = NULL;
+ int rv, n = 0;
+ FILE *maps;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
- memset (buf, 0, sizeof (glibtop_proc_map));
+ memset (buf, 0, sizeof (glibtop_proc_map));
- sprintf (fn, "/proc/%d/maps", pid);
+ sprintf (fn, "/proc/%d/maps", pid);
- maps = fopen (fn, "r");
- if (!maps) return NULL;
+ maps = fopen (fn, "r");
+ if (!maps) return NULL;
- do {
- short dev_major, dev_minor;
- unsigned long start, end, offset, inode, perm;
- char flags [5], *format;
- size_t size;
+ do {
+ short dev_major, dev_minor;
+ unsigned long start, end, offset, inode, perm;
+ char flags [5], *format;
+ size_t size;
- if (sizeof (void*) == 8)
- format = "%16lx-%16lx %4c\n %16lx %02hx:%02hx %ld";
- else
- format = "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld";
+ if (sizeof (void*) == 8)
+ format = "%16lx-%16lx %4c\n %16lx %02hx:%02hx %ld";
+ else
+ format = "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld";
- rv = fscanf (maps, format,
- &start, &end, flags, &offset,
- &dev_major, &dev_minor, &inode);
+ rv = fscanf (maps, format,
+ &start, &end, flags, &offset,
+ &dev_major, &dev_minor, &inode);
- flags [4] = 0;
+ flags [4] = 0;
- /* Compute access permissions. */
+ /* Compute access permissions. */
- perm = 0;
+ perm = 0;
- if (flags [0] == 'r')
- perm |= GLIBTOP_MAP_PERM_READ;
- if (flags [1] == 'w')
- perm |= GLIBTOP_MAP_PERM_WRITE;
- if (flags [2] == 'x')
- perm |= GLIBTOP_MAP_PERM_EXECUTE;
- if (flags [3] == 's')
- perm |= GLIBTOP_MAP_PERM_SHARED;
- if (flags [3] == 'p')
- perm |= GLIBTOP_MAP_PERM_PRIVATE;
+ if (flags [0] == 'r')
+ perm |= GLIBTOP_MAP_PERM_READ;
+ if (flags [1] == 'w')
+ perm |= GLIBTOP_MAP_PERM_WRITE;
+ if (flags [2] == 'x')
+ perm |= GLIBTOP_MAP_PERM_EXECUTE;
+ if (flags [3] == 's')
+ perm |= GLIBTOP_MAP_PERM_SHARED;
+ if (flags [3] == 'p')
+ perm |= GLIBTOP_MAP_PERM_PRIVATE;
- /* Read filename. */
+ /* Read filename. */
- fn [0] = fgetc (maps);
+ fn [0] = fgetc (maps);
- if (fn [0] != '\n' && fn [0] != EOF) {
+ if (fn [0] != '\n' && fn [0] != EOF) {
- fscanf (maps, "%*[ ]%[^\n]\n", fn);
+ fscanf (maps, "%*[ ]%[^\n]\n", fn);
- } else fn [0] = 0;
+ } else fn [0] = 0;
- size = (n+1) * sizeof (glibtop_map_entry);
+ size = (n+1) * sizeof (glibtop_map_entry);
- entry_list = glibtop_realloc_r (server, entry_list, size);
+ entry_list = glibtop_realloc_r (server, entry_list, size);
- memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry));
+ memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry));
- entry_list [n].flags = _glibtop_sysdeps_map_entry;
+ entry_list [n].flags = _glibtop_sysdeps_map_entry;
- entry_list [n].start = (u_int64_t) start;
- entry_list [n].end = (u_int64_t) end;
- entry_list [n].offset = (u_int64_t) offset;
- entry_list [n].perm = (u_int64_t) perm;
- entry_list [n].device = (u_int64_t) (dev_major << 8) +
- (u_int64_t) dev_minor;
- entry_list [n].inode = (u_int64_t) inode;
+ entry_list [n].start = (u_int64_t) start;
+ entry_list [n].end = (u_int64_t) end;
+ entry_list [n].offset = (u_int64_t) offset;
+ entry_list [n].perm = (u_int64_t) perm;
+ entry_list [n].device = (u_int64_t) (dev_major << 8) +
+ (u_int64_t) dev_minor;
+ entry_list [n].inode = (u_int64_t) inode;
- strncpy (entry_list [n].filename, fn, GLIBTOP_MAP_FILENAME_LEN);
- entry_list [n].filename [GLIBTOP_MAP_FILENAME_LEN] = 0;
+ strncpy (entry_list [n].filename, fn, GLIBTOP_MAP_FILENAME_LEN);
+ entry_list [n].filename [GLIBTOP_MAP_FILENAME_LEN] = 0;
- n++;
+ n++;
- } while (rv != EOF && rv && fn [0] != EOF);
+ } while (rv != EOF && rv && fn [0] != EOF);
- fclose (maps);
+ fclose (maps);
- buf->number = n;
- buf->size = sizeof (glibtop_map_entry);
- buf->total = n * sizeof (glibtop_map_entry);
+ buf->number = n;
+ buf->size = sizeof (glibtop_map_entry);
+ buf->total = n * sizeof (glibtop_map_entry);
- return entry_list;
+ return entry_list;
}
diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c
index ba27e8be..df052bf3 100644
--- a/sysdeps/linux/procmem.c
+++ b/sysdeps/linux/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -48,21 +50,21 @@ static int pageshift; /* log base 2 of the pagesize */
int
glibtop_init_proc_mem_s (glibtop *server)
{
- register int pagesize;
+ register int pagesize;
- server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
- _glibtop_sysdeps_proc_mem_statm;
+ server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem |
+ _glibtop_sysdeps_proc_mem_statm;
- /* get the page size with "getpagesize" and calculate pageshift
- * from it */
- pagesize = getpagesize ();
- pageshift = 0;
- while (pagesize > 1) {
- pageshift++;
- pagesize >>= 1;
- }
+ /* get the page size with "getpagesize" and calculate pageshift
+ * from it */
+ pagesize = getpagesize ();
+ pageshift = 0;
+ while (pagesize > 1) {
+ pageshift++;
+ pagesize >>= 1;
+ }
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -70,39 +72,39 @@ glibtop_init_proc_mem_s (glibtop *server)
int
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
{
- char buffer [BUFSIZ], *p;
+ char buffer [BUFSIZ], *p;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 20);
+ p = skip_multiple_token (p, 20);
- buf->vsize = strtoul (p, &p, 0);
- buf->rss = strtoul (p, &p, 0);
- buf->rss_rlim = strtoul (p, &p, 0);
+ buf->vsize = strtoul (p, &p, 0);
+ buf->rss = strtoul (p, &p, 0);
+ buf->rss_rlim = strtoul (p, &p, 0);
- buf->flags = _glibtop_sysdeps_proc_mem;
+ buf->flags = _glibtop_sysdeps_proc_mem;
- if (proc_statm_to_buffer (buffer, pid))
- return -1;
+ if (proc_statm_to_buffer (buffer, pid))
+ return -1;
- buf->size = strtoul (buffer, &p, 0);
- buf->resident = strtoul (p, &p, 0);
- buf->share = strtoul (p, &p, 0);
+ buf->size = strtoul (buffer, &p, 0);
+ buf->resident = strtoul (p, &p, 0);
+ buf->share = strtoul (p, &p, 0);
- buf->size <<= pageshift;
- buf->resident <<= pageshift;
- buf->share <<= pageshift;
- buf->rss <<= pageshift;
+ buf->size <<= pageshift;
+ buf->resident <<= pageshift;
+ buf->share <<= pageshift;
+ buf->rss <<= pageshift;
- buf->flags |= _glibtop_sysdeps_proc_mem_statm;
+ buf->flags |= _glibtop_sysdeps_proc_mem_statm;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c
index cba0afd3..3d476237 100644
--- a/sysdeps/linux/procsegment.c
+++ b/sysdeps/linux/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -52,21 +54,21 @@ static int pageshift; /* log base 2 of the pagesize */
int
glibtop_init_proc_segment_s (glibtop *server)
{
- register int pagesize;
+ register int pagesize;
- server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment |
- _glibtop_sysdeps_proc_segment_statm;
+ server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment |
+ _glibtop_sysdeps_proc_segment_statm;
- /* get the page size with "getpagesize" and calculate pageshift
- * from it */
- pagesize = getpagesize ();
- pageshift = 0;
- while (pagesize > 1) {
- pageshift++;
- pagesize >>= 1;
- }
+ /* get the page size with "getpagesize" and calculate pageshift
+ * from it */
+ pagesize = getpagesize ();
+ pageshift = 0;
+ while (pagesize > 1) {
+ pageshift++;
+ pagesize >>= 1;
+ }
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -75,45 +77,45 @@ int
glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
- char buffer [BUFSIZ], *p;
+ char buffer [BUFSIZ], *p;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 23);
+ p = skip_multiple_token (p, 23);
- buf->start_code = strtoul (p, &p, 0);
- buf->end_code = strtoul (p, &p, 0);
- buf->start_stack = strtoul (p, &p, 0);
+ buf->start_code = strtoul (p, &p, 0);
+ buf->end_code = strtoul (p, &p, 0);
+ buf->start_stack = strtoul (p, &p, 0);
- buf->flags = _glibtop_sysdeps_proc_segment;
+ buf->flags = _glibtop_sysdeps_proc_segment;
- if (proc_statm_to_buffer (buffer, pid))
- return 0;
+ if (proc_statm_to_buffer (buffer, pid))
+ return 0;
- p = skip_multiple_token (buffer, 3);
+ p = skip_multiple_token (buffer, 3);
- /* This doesn't work very well due to a bug in the Linux kernel.
- * I'll submit a patch to the kernel mailing list soon. */
+ /* This doesn't work very well due to a bug in the Linux kernel.
+ * I'll submit a patch to the kernel mailing list soon. */
- buf->text_rss = strtoul (p, &p, 0);
- buf->shlib_rss = strtoul (p, &p, 0);
- buf->data_rss = strtoul (p, &p, 0);
- buf->dirty_size = strtoul (p, &p, 0);
+ buf->text_rss = strtoul (p, &p, 0);
+ buf->shlib_rss = strtoul (p, &p, 0);
+ buf->data_rss = strtoul (p, &p, 0);
+ buf->dirty_size = strtoul (p, &p, 0);
- buf->text_rss <<= pageshift;
- buf->shlib_rss <<= pageshift;
- buf->data_rss <<= pageshift;
- buf->dirty_size <<= pageshift;
+ buf->text_rss <<= pageshift;
+ buf->shlib_rss <<= pageshift;
+ buf->data_rss <<= pageshift;
+ buf->dirty_size <<= pageshift;
- buf->flags |= _glibtop_sysdeps_proc_segment_statm;
+ buf->flags |= _glibtop_sysdeps_proc_segment_statm;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c
index 1052ef36..97a8970e 100644
--- a/sysdeps/linux/procsignal.c
+++ b/sysdeps/linux/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_signal =
int
glibtop_init_proc_signal_s (glibtop *server)
{
- server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
+ server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -44,26 +46,26 @@ glibtop_init_proc_signal_s (glibtop *server)
int
glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid)
{
- char buffer [BUFSIZ], *p;
+ char buffer [BUFSIZ], *p;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 28);
+ p = skip_multiple_token (p, 28);
- buf->signal [0] = strtoul (p, &p, 0);
- buf->blocked [0] = strtoul (p, &p, 0);
- buf->sigignore [0] = strtoul (p, &p, 0);
- buf->sigcatch [0] = strtoul (p, &p, 0);
+ buf->signal [0] = strtoul (p, &p, 0);
+ buf->blocked [0] = strtoul (p, &p, 0);
+ buf->sigignore [0] = strtoul (p, &p, 0);
+ buf->sigcatch [0] = strtoul (p, &p, 0);
- buf->flags = _glibtop_sysdeps_proc_signal;
+ buf->flags = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c
index fc8fe1c6..51354352 100644
--- a/sysdeps/linux/procstate.c
+++ b/sysdeps/linux/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -38,10 +40,10 @@ static const unsigned long _glibtop_sysdeps_proc_state_uid =
int
glibtop_init_proc_state_s (glibtop *server)
{
- server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
- _glibtop_sysdeps_proc_state_uid;
+ server->sysdeps.proc_state = _glibtop_sysdeps_proc_state |
+ _glibtop_sysdeps_proc_state_uid;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -49,74 +51,74 @@ glibtop_init_proc_state_s (glibtop *server)
int
glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
{
- char buffer [BUFSIZ], state, *p;
- struct stat statb;
+ char buffer [BUFSIZ], state, *p;
+ struct stat statb;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- /* IMPORTANT NOTICE: For security reasons it is extremely important
- * that the 'uid' and 'gid' fields have correct
- * values; NEVER set their flags values if this
- * is not the case !!! */
+ /* IMPORTANT NOTICE: For security reasons it is extremely important
+ * that the 'uid' and 'gid' fields have correct
+ * values; NEVER set their flags values if this
+ * is not the case !!! */
- sprintf (buffer, "/proc/%d", pid);
+ sprintf (buffer, "/proc/%d", pid);
- if (stat (buffer, &statb))
- return -1;
+ if (stat (buffer, &statb))
+ return -1;
- /* For security reasons we use stat () since it is
- * more failsafe than parsing the file. */
+ /* For security reasons we use stat () since it is
+ * more failsafe than parsing the file. */
- buf->uid = statb.st_uid;
- buf->gid = statb.st_gid;
-
- buf->flags = _glibtop_sysdeps_proc_state_uid;
-
- sprintf (buffer, "/proc/%d", pid);
-
- /* Now we read the remaining fields. */
-
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
-
- p = strrchr (buffer, ')'); *p = '\0';
- state = p [2];
-
- p = skip_token (buffer); p++; /* pid */
- if (*p++ != '(')
- glibtop_error_r (server, "Bad data in /proc/%d/stat", pid);
-
- strncpy (buf->cmd, p, sizeof (buf->cmd)-1);
- buf->cmd [sizeof (buf->cmd)-1] = 0;
-
- buf->flags |= _glibtop_sysdeps_proc_state;
-
- switch (state) {
- case 'R':
- buf->state = GLIBTOP_PROCESS_RUNNING;
- break;
- case 'S':
- buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
- break;
- case 'D':
- buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
- break;
- case 'Z':
- buf->state = GLIBTOP_PROCESS_ZOMBIE;
- break;
- case 'T':
- buf->state = GLIBTOP_PROCESS_STOPPED;
- break;
- case 'W':
- buf->state = GLIBTOP_PROCESS_SWAPPING;
- break;
- default:
- return -1;
- }
-
- buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
-
- return 0;
+ buf->uid = statb.st_uid;
+ buf->gid = statb.st_gid;
+
+ buf->flags = _glibtop_sysdeps_proc_state_uid;
+
+ sprintf (buffer, "/proc/%d", pid);
+
+ /* Now we read the remaining fields. */
+
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
+
+ p = strrchr (buffer, ')'); *p = '\0';
+ state = p [2];
+
+ p = skip_token (buffer); p++; /* pid */
+ if (*p++ != '(')
+ glibtop_error_r (server, "Bad data in /proc/%d/stat", pid);
+
+ strncpy (buf->cmd, p, sizeof (buf->cmd)-1);
+ buf->cmd [sizeof (buf->cmd)-1] = 0;
+
+ buf->flags |= _glibtop_sysdeps_proc_state;
+
+ switch (state) {
+ case 'R':
+ buf->state = GLIBTOP_PROCESS_RUNNING;
+ break;
+ case 'S':
+ buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
+ break;
+ case 'D':
+ buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
+ break;
+ case 'Z':
+ buf->state = GLIBTOP_PROCESS_ZOMBIE;
+ break;
+ case 'T':
+ buf->state = GLIBTOP_PROCESS_STOPPED;
+ break;
+ case 'W':
+ buf->state = GLIBTOP_PROCESS_SWAPPING;
+ break;
+ default:
+ return -1;
+ }
+
+ buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
+
+ return 0;
}
diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c
index f32750a4..9cd50fbd 100644
--- a/sysdeps/linux/proctime.c
+++ b/sysdeps/linux/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -39,12 +41,12 @@ static const unsigned long _glibtop_sysdeps_proc_time_smp =
int
glibtop_init_proc_time_s (glibtop *server)
{
- server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
+ server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
- if (server->ncpu)
- server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp;
+ if (server->ncpu)
+ server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -52,56 +54,56 @@ glibtop_init_proc_time_s (glibtop *server)
int
glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid)
{
- char buffer [BUFSIZ], *p;
- int i;
+ char buffer [BUFSIZ], *p;
+ int i;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 11);
+ p = skip_multiple_token (p, 11);
- buf->utime = strtoul (p, &p, 0);
- buf->stime = strtoul (p, &p, 0);
- buf->cutime = strtoul (p, &p, 0);
- buf->cstime = strtoul (p, &p, 0);
+ buf->utime = strtoul (p, &p, 0);
+ buf->stime = strtoul (p, &p, 0);
+ buf->cutime = strtoul (p, &p, 0);
+ buf->cstime = strtoul (p, &p, 0);
- p = skip_multiple_token (p, 2);
+ p = skip_multiple_token (p, 2);
- buf->timeout = strtoul (p, &p, 0);
- buf->it_real_value = strtoul (p, &p, 0);
- buf->start_time = strtoul (p, &p, 0);
+ buf->timeout = strtoul (p, &p, 0);
+ buf->it_real_value = strtoul (p, &p, 0);
+ buf->start_time = strtoul (p, &p, 0);
- buf->frequency = 100;
+ buf->frequency = 100;
- buf->flags = _glibtop_sysdeps_proc_time;
+ buf->flags = _glibtop_sysdeps_proc_time;
- if (!server->ncpu)
- return 0;
+ if (!server->ncpu)
+ return 0;
- if (proc_file_to_buffer (buffer, "/proc/%d/cpu", pid))
- return -1;
+ if (proc_file_to_buffer (buffer, "/proc/%d/cpu", pid))
+ return -1;
- p = skip_token (buffer);
- buf->utime = strtoul (p, &p, 0);
- buf->stime = strtoul (p, &p, 0);
+ p = skip_token (buffer);
+ buf->utime = strtoul (p, &p, 0);
+ buf->stime = strtoul (p, &p, 0);
- for (i = 0; i < GLIBTOP_NCPU; i++) {
- if (strncmp (p+1, "cpu", 3) || !isdigit (p [4]))
- break;
+ for (i = 0; i < GLIBTOP_NCPU; i++) {
+ if (strncmp (p+1, "cpu", 3) || !isdigit (p [4]))
+ break;
- p += 6;
- buf->xcpu_utime [i] = strtoul (p, &p, 0);
- buf->xcpu_stime [i] = strtoul (p, &p, 0);
- }
+ p += 6;
+ buf->xcpu_utime [i] = strtoul (p, &p, 0);
+ buf->xcpu_stime [i] = strtoul (p, &p, 0);
+ }
- buf->flags |= _glibtop_sysdeps_proc_time_smp;
+ buf->flags |= _glibtop_sysdeps_proc_time_smp;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c
index 7b0d6b45..0c996d03 100644
--- a/sysdeps/linux/procuid.c
+++ b/sysdeps/linux/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -42,10 +44,10 @@ static const unsigned long _glibtop_sysdeps_proc_uid_stat =
int
glibtop_init_proc_uid_s (glibtop *server)
{
- server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
- _glibtop_sysdeps_proc_uid_stat;
+ server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid |
+ _glibtop_sysdeps_proc_uid_stat;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -53,78 +55,78 @@ glibtop_init_proc_uid_s (glibtop *server)
int
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
{
- char buffer [BUFSIZ], *p;
+ char buffer [BUFSIZ], *p;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_UID, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_UID, 0);
- memset (buf, 0, sizeof (glibtop_proc_uid));
+ memset (buf, 0, sizeof (glibtop_proc_uid));
- if (proc_status_to_buffer (buffer, pid))
- return -1;
+ if (proc_status_to_buffer (buffer, pid))
+ return -1;
- /* Search substring 'Pid:' */
+ /* Search substring 'Pid:' */
- p = strstr (buffer, "\nPid:");
- if (!p) return -1;
+ p = strstr (buffer, "\nPid:");
+ if (!p) return -1;
- p = skip_token (p); /* "Pid:" */
- buf->pid = strtoul (p, &p, 0);
+ p = skip_token (p); /* "Pid:" */
+ buf->pid = strtoul (p, &p, 0);
- p = skip_token (p); /* "PPid:" */
- buf->ppid = strtoul (p, &p, 0);
+ p = skip_token (p); /* "PPid:" */
+ buf->ppid = strtoul (p, &p, 0);
- /* Maybe future Linux versions place something between
- * "PPid" and "Uid", so we catch this here. */
- p = strstr (p, "\nUid:");
- if (!p) return -1;
+ /* Maybe future Linux versions place something between
+ * "PPid" and "Uid", so we catch this here. */
+ p = strstr (p, "\nUid:");
+ if (!p) return -1;
- p = skip_token (p); /* "Uid:" */
- buf->uid = strtoul (p, &p, 0);
- buf->euid = strtoul (p, &p, 0);
+ p = skip_token (p); /* "Uid:" */
+ buf->uid = strtoul (p, &p, 0);
+ buf->euid = strtoul (p, &p, 0);
- /* We don't know how many entries on the "Uid:" line
- * future Linux version will have, so we catch this here. */
- p = strstr (p, "\nGid:");
- if (!p) return -1;
+ /* We don't know how many entries on the "Uid:" line
+ * future Linux version will have, so we catch this here. */
+ p = strstr (p, "\nGid:");
+ if (!p) return -1;
- p = skip_token (p); /* "Gid:" */
- buf->gid = strtoul (p, &p, 0);
- buf->egid = strtoul (p, &p, 0);
+ p = skip_token (p); /* "Gid:" */
+ buf->gid = strtoul (p, &p, 0);
+ buf->egid = strtoul (p, &p, 0);
- buf->flags = _glibtop_sysdeps_proc_uid;
+ buf->flags = _glibtop_sysdeps_proc_uid;
- if (proc_stat_to_buffer (buffer, pid))
- return -1;
+ if (proc_stat_to_buffer (buffer, pid))
+ return -1;
- p = proc_stat_after_cmd (buffer);
- if (!p) return -1;
+ p = proc_stat_after_cmd (buffer);
+ if (!p) return -1;
- p = skip_multiple_token (p, 2);
+ p = skip_multiple_token (p, 2);
- buf->pgrp = strtoul (p, &p, 0);
- buf->session = strtoul (p, &p, 0);
- buf->tty = strtoul (p, &p, 0);
- buf->tpgid = strtoul (p, &p, 0);
+ buf->pgrp = strtoul (p, &p, 0);
+ buf->session = strtoul (p, &p, 0);
+ buf->tty = strtoul (p, &p, 0);
+ buf->tpgid = strtoul (p, &p, 0);
- p = skip_multiple_token (p, 9);
+ p = skip_multiple_token (p, 9);
- buf->priority = strtoul (p, &p, 0);
- buf->nice = strtoul (p, &p, 0);
-
- if (buf->tty == 0)
- /* the old notty val, update elsewhere bef. moving to 0 */
- buf->tty = -1;
-
- if (server->os_version_code < LINUX_VERSION(1,3,39)) {
- /* map old meanings to new */
- buf->priority = 2*15 - buf->priority;
- buf->nice = 15 - buf->nice;
- }
- if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
- /* when tty wasn't full devno */
- buf->tty = 4*0x100 + buf->tty;
+ buf->priority = strtoul (p, &p, 0);
+ buf->nice = strtoul (p, &p, 0);
+
+ if (buf->tty == 0)
+ /* the old notty val, update elsewhere bef. moving to 0 */
+ buf->tty = -1;
+
+ if (server->os_version_code < LINUX_VERSION(1,3,39)) {
+ /* map old meanings to new */
+ buf->priority = 2*15 - buf->priority;
+ buf->nice = 15 - buf->nice;
+ }
+ if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
+ /* when tty wasn't full devno */
+ buf->tty = 4*0x100 + buf->tty;
- buf->flags |= _glibtop_sysdeps_proc_uid_stat;
+ buf->flags |= _glibtop_sysdeps_proc_uid_stat;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c
index ef093a23..33ae6b29 100644
--- a/sysdeps/linux/sem_limits.c
+++ b/sysdeps/linux/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,10 +36,10 @@
union semun
{
- int val;
- struct semid_ds *buf;
- unsigned short int *array;
- struct seminfo *__buf;
+ int val;
+ struct semid_ds *buf;
+ unsigned short int *array;
+ struct seminfo *__buf;
};
#endif
@@ -53,9 +55,9 @@ static unsigned long _glibtop_sysdeps_sem_limits =
int
glibtop_init_sem_limits_s (glibtop *server)
{
- server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
+ server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -63,28 +65,28 @@ glibtop_init_sem_limits_s (glibtop *server)
int
glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
{
- struct seminfo seminfo;
- union semun arg;
+ struct seminfo seminfo;
+ union semun arg;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- buf->flags = _glibtop_sysdeps_sem_limits;
+ buf->flags = _glibtop_sysdeps_sem_limits;
- arg.array = (ushort *) &seminfo;
- semctl (0, 0, IPC_INFO, arg);
+ arg.array = (ushort *) &seminfo;
+ semctl (0, 0, IPC_INFO, arg);
- buf->semmap = seminfo.semmap;
- buf->semmni = seminfo.semmni;
- buf->semmns = seminfo.semmns;
- buf->semmnu = seminfo.semmnu;
- buf->semmsl = seminfo.semmsl;
- buf->semopm = seminfo.semopm;
- buf->semume = seminfo.semume;
- buf->semusz = seminfo.semusz;
- buf->semvmx = seminfo.semvmx;
- buf->semaem = seminfo.semaem;
-
- return 0;
+ buf->semmap = seminfo.semmap;
+ buf->semmni = seminfo.semmni;
+ buf->semmns = seminfo.semmns;
+ buf->semmnu = seminfo.semmnu;
+ buf->semmsl = seminfo.semmsl;
+ buf->semopm = seminfo.semopm;
+ buf->semume = seminfo.semume;
+ buf->semusz = seminfo.semusz;
+ buf->semvmx = seminfo.semvmx;
+ buf->semaem = seminfo.semaem;
+
+ return 0;
}
diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c
index a59eadef..e4e218b4 100644
--- a/sysdeps/linux/shm_limits.c
+++ b/sysdeps/linux/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,9 +38,9 @@ static unsigned long _glibtop_sysdeps_shm_limits =
int
glibtop_init_shm_limits_s (glibtop *server)
{
- server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
+ server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -46,21 +48,21 @@ glibtop_init_shm_limits_s (glibtop *server)
int
glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
{
- struct shminfo shminfo;
+ struct shminfo shminfo;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- buf->flags = _glibtop_sysdeps_shm_limits;
+ buf->flags = _glibtop_sysdeps_shm_limits;
- shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo);
+ shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo);
- buf->shmmax = shminfo.shmmax;
- buf->shmmin = shminfo.shmmin;
- buf->shmmni = shminfo.shmmni;
- buf->shmseg = shminfo.shmseg;
- buf->shmall = shminfo.shmall;
+ buf->shmmax = shminfo.shmmax;
+ buf->shmmin = shminfo.shmmin;
+ buf->shmmni = shminfo.shmmni;
+ buf->shmseg = shminfo.shmseg;
+ buf->shmall = shminfo.shmall;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/siglist.c b/sysdeps/linux/siglist.c
index d00223c0..ef58e9c9 100644
--- a/sysdeps/linux/siglist.c
+++ b/sysdeps/linux/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c
index 76003f36..911d2a48 100644
--- a/sysdeps/linux/swap.c
+++ b/sysdeps/linux/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -39,10 +41,10 @@ static unsigned long _glibtop_sysdeps_swap_paging =
int
glibtop_init_swap_s (glibtop *server)
{
- server->sysdeps.swap = _glibtop_sysdeps_swap |
- _glibtop_sysdeps_swap_paging;
+ server->sysdeps.swap = _glibtop_sysdeps_swap |
+ _glibtop_sysdeps_swap_paging;
- return 0;
+ return 0;
}
/* Provides information about swap usage. */
@@ -53,66 +55,66 @@ glibtop_init_swap_s (glibtop *server)
int
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{
- char buffer [BUFSIZ], *p;
- int fd, len;
-
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0);
+ char buffer [BUFSIZ], *p;
+ int fd, len;
- memset (buf, 0, sizeof (glibtop_swap));
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0);
- fd = open (MEMINFO, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", MEMINFO);
- return -1;
- }
+ memset (buf, 0, sizeof (glibtop_swap));
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", MEMINFO);
- return -1;
- }
+ fd = open (MEMINFO, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", MEMINFO);
+ return -1;
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", MEMINFO);
+ return -1;
+ }
- buffer [len] = '\0';
+ close (fd);
- p = skip_line (buffer);
- p = skip_line (p);
- p = skip_token (p); /* "Swap:" */
+ buffer [len] = '\0';
- buf->total = strtoul (p, &p, 0);
- buf->used = strtoul (p, &p, 0);
- buf->free = strtoul (p, &p, 0);
+ p = skip_line (buffer);
+ p = skip_line (p);
+ p = skip_token (p); /* "Swap:" */
- buf->flags = _glibtop_sysdeps_swap;
+ buf->total = strtoul (p, &p, 0);
+ buf->used = strtoul (p, &p, 0);
+ buf->free = strtoul (p, &p, 0);
- fd = open (PROC_STAT, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", PROC_STAT);
- return -1;
- }
+ buf->flags = _glibtop_sysdeps_swap;
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", PROC_STAT);
- return -1;
- }
+ fd = open (PROC_STAT, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", PROC_STAT);
+ return -1;
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", PROC_STAT);
+ return -1;
+ }
+
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- p = strstr (buffer, "\nswap");
- if (p == NULL) return 0;
+ p = strstr (buffer, "\nswap");
+ if (p == NULL) return 0;
- p = skip_token (p);
+ p = skip_token (p);
- buf->pagein = strtoul (p, &p, 0);
- buf->pageout = strtoul (p, &p, 0);
+ buf->pagein = strtoul (p, &p, 0);
+ buf->pageout = strtoul (p, &p, 0);
- buf->flags |= _glibtop_sysdeps_swap_paging;
+ buf->flags |= _glibtop_sysdeps_swap_paging;
- return 0;
+ return 0;
}
diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c
index d4a19bf3..c24d3984 100644
--- a/sysdeps/linux/sysinfo.c
+++ b/sysdeps/linux/sysinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,62 +35,62 @@ static glibtop_sysinfo sysinfo;
static void
init_sysinfo (glibtop *server)
{
- char buffer [BUFSIZ];
- static int init = 0;
- glibtop_entry *cpuinfo = NULL;
- FILE *f;
+ char buffer [BUFSIZ];
+ static int init = 0;
+ glibtop_entry *cpuinfo = NULL;
+ FILE *f;
- if (init) return;
+ if (init) return;
- init = TRUE;
+ init = TRUE;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
- memset (&sysinfo, 0, sizeof (glibtop_sysinfo));
+ memset (&sysinfo, 0, sizeof (glibtop_sysinfo));
- g_return_if_fail (f = fopen ("/proc/cpuinfo", "r"));
+ g_return_if_fail (f = fopen ("/proc/cpuinfo", "r"));
- while (fgets (buffer, BUFSIZ, f)) {
- char *p, *start, *key, *value;
+ while (fgets (buffer, BUFSIZ, f)) {
+ char *p, *start, *key, *value;
- if (cpuinfo == NULL) {
- cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++];
+ if (cpuinfo == NULL) {
+ cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++];
- cpuinfo->labels = g_ptr_array_new ();
+ cpuinfo->labels = g_ptr_array_new ();
- cpuinfo->values = g_hash_table_new (NULL, NULL);
+ cpuinfo->values = g_hash_table_new (NULL, NULL);
- if (sysinfo.ncpu > GLIBTOP_NCPU)
- sysinfo.ncpu = GLIBTOP_NCPU;
- }
+ if (sysinfo.ncpu > GLIBTOP_NCPU)
+ sysinfo.ncpu = GLIBTOP_NCPU;
+ }
- p = strchr (buffer, ':');
- if (!p) continue;
+ p = strchr (buffer, ':');
+ if (!p) continue;
- /* Remove leading spaces from `p'. */
- *p = '\0'; start = p; p++;
- while (isspace (*p)) p++;
+ /* Remove leading spaces from `p'. */
+ *p = '\0'; start = p; p++;
+ while (isspace (*p)) p++;
- /* Remove trailing spaces from `buffer'. */
- while ((start > buffer) && (*start) && isspace (*start))
- *start-- = '\0';
+ /* Remove trailing spaces from `buffer'. */
+ while ((start > buffer) && (*start) && isspace (*start))
+ *start-- = '\0';
- key = g_strdup (buffer);
- value = g_strdup (p);
+ key = g_strdup (buffer);
+ value = g_strdup (p);
- g_ptr_array_add (cpuinfo->labels, key);
+ g_ptr_array_add (cpuinfo->labels, key);
- g_hash_table_insert (cpuinfo->values, key, value);
- }
+ g_hash_table_insert (cpuinfo->values, key, value);
+ }
- fclose (f);
+ fclose (f);
- sysinfo.flags = _glibtop_sysdeps_sysinfo;
+ sysinfo.flags = _glibtop_sysdeps_sysinfo;
}
glibtop_sysinfo *
glibtop_get_sysinfo_s (glibtop *server)
{
- init_sysinfo (server);
- return &sysinfo;
+ init_sysinfo (server);
+ return &sysinfo;
}
diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c
index fcae7513..6746fb89 100644
--- a/sysdeps/linux/uptime.c
+++ b/sysdeps/linux/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,9 +35,9 @@ static unsigned long _glibtop_sysdeps_uptime =
int
glibtop_init_uptime_s (glibtop *server)
{
- server->sysdeps.uptime = _glibtop_sysdeps_uptime;
+ server->sysdeps.uptime = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
/* Provides uptime and idle time. */
@@ -45,34 +47,34 @@ glibtop_init_uptime_s (glibtop *server)
int
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{
- char buffer [BUFSIZ], *p;
- int fd, len;
-
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
+ char buffer [BUFSIZ], *p;
+ int fd, len;
- memset (buf, 0, sizeof (glibtop_uptime));
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
- fd = open (FILENAME, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", FILENAME);
- return -1;
- }
+ memset (buf, 0, sizeof (glibtop_uptime));
- len = read (fd, buffer, BUFSIZ-1);
- if (len < 0) {
- close (fd);
- glibtop_warn_io_r (server, "read (%s)", FILENAME);
- return -1;
- }
+ fd = open (FILENAME, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", FILENAME);
+ return -1;
+ }
+ len = read (fd, buffer, BUFSIZ-1);
+ if (len < 0) {
close (fd);
+ glibtop_warn_io_r (server, "read (%s)", FILENAME);
+ return -1;
+ }
+
+ close (fd);
- buffer [len] = '\0';
+ buffer [len] = '\0';
- buf->uptime = strtod (buffer, &p);
- buf->idletime = strtod (p, &p);
+ buf->uptime = strtod (buffer, &p);
+ buf->idletime = strtod (p, &p);
- buf->flags = _glibtop_sysdeps_uptime;
+ buf->flags = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
diff --git a/sysdeps/names/prockernel.c b/sysdeps/names/prockernel.c
index 0cb7c8d9..dab50f75 100644
--- a/sysdeps/names/prockernel.c
+++ b/sysdeps/names/prockernel.c
@@ -48,7 +48,7 @@ const char *glibtop_labels_proc_kernel[GLIBTOP_MAX_PROC_KERNEL] =
const char *glibtop_descriptions_proc_kernel[GLIBTOP_MAX_PROC_KERNEL] =
{
- /* K_Flags */
+ /* K_Flags */
N_ ("Kernel flags of the process.\n\n"
"On Linux, currently every flag has the math bit set, because "
"crt0.s checks for math emulation, so this is not included in "
@@ -57,28 +57,28 @@ const char *glibtop_descriptions_proc_kernel[GLIBTOP_MAX_PROC_KERNEL] =
"program.\n\n"
"The math bit should be a decimal 4, and the traced bit is "
"decimal 10."),
- /* Min_Flt */
+ /* Min_Flt */
N_ ("The number of minor faults the process has made, those which "
"have not required loading a memory page from disk."),
- /* Maj_Flt */
+ /* Maj_Flt */
N_ ("The number of major faults the process has made, those which "
"have required loading a memory page from disk."),
- /* CMin_Flt */
+ /* CMin_Flt */
N_ ("The number of minor faults that the process and its children "
"have made."),
- /* CMaj_Flt */
+ /* CMaj_Flt */
N_ ("The number of major faults that the process and its children "
"have made."),
- /* KStk_ESP */
+ /* KStk_ESP */
N_ ("The current value of esp (32-bit stack pointer), as found in "
"the kernel stack page for the process."),
- /* KStk_EIP */
+ /* KStk_EIP */
N_ ("The current EIP (32-bit instruction pointer)."),
- /* NWChan */
+ /* NWChan */
N_ ("This is the \"channel\" in which the process is waiting. This "
"is the address of a system call, and can be looked up in a "
"namelist if you need a textual name. (If you have an up-to-date "
"/etc/psdatabase, then try ps -l to see the WCHAN field in action)"),
- /* WChan */
+ /* WChan */
N_ ("This is the textual name of the `nwchan' field.")
};
diff --git a/sysdeps/osf1/close.c b/sysdeps/osf1/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/osf1/close.c
+++ b/sysdeps/osf1/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/osf1/close_suid.c b/sysdeps/osf1/close_suid.c
index a8733f0f..95bffec1 100644
--- a/sysdeps/osf1/close_suid.c
+++ b/sysdeps/osf1/close_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/osf1/cpu.c b/sysdeps/osf1/cpu.c
index 26416228..70d3bdf6 100644
--- a/sysdeps/osf1/cpu.c
+++ b/sysdeps/osf1/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,7 +37,7 @@ static const unsigned long _glibtop_sysdeps_cpu =
int
glibtop_init_cpu_s (glibtop *server)
{
- server->sysdeps.cpu = _glibtop_sysdeps_cpu;
+ server->sysdeps.cpu = _glibtop_sysdeps_cpu;
}
/* Provides information about cpu usage. */
@@ -43,27 +45,27 @@ glibtop_init_cpu_s (glibtop *server)
int
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
- struct tbl_sysinfo sysinfo;
- int ret;
+ struct tbl_sysinfo sysinfo;
+ int ret;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0);
- memset (buf, 0, sizeof (glibtop_cpu));
+ memset (buf, 0, sizeof (glibtop_cpu));
- ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1,
- sizeof (struct tbl_sysinfo));
+ ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1,
+ sizeof (struct tbl_sysinfo));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags = _glibtop_sysdeps_cpu;
+ buf->flags = _glibtop_sysdeps_cpu;
- buf->user = sysinfo.si_user;
- buf->nice = sysinfo.si_nice;
- buf->sys = sysinfo.si_sys;
- buf->idle = sysinfo.si_idle;
+ buf->user = sysinfo.si_user;
+ buf->nice = sysinfo.si_nice;
+ buf->sys = sysinfo.si_sys;
+ buf->idle = sysinfo.si_idle;
- buf->total = sysinfo.si_user + sysinfo.si_nice +
- sysinfo.si_sys + sysinfo.si_idle;
+ buf->total = sysinfo.si_user + sysinfo.si_nice +
+ sysinfo.si_sys + sysinfo.si_idle;
- buf->frequency = sysinfo.si_hz;
+ buf->frequency = sysinfo.si_hz;
}
diff --git a/sysdeps/osf1/glibtop_machine.h b/sysdeps/osf1/glibtop_machine.h
index a4424818..901a5216 100644
--- a/sysdeps/osf1/glibtop_machine.h
+++ b/sysdeps/osf1/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -40,9 +42,9 @@ typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
- uid_t uid, euid; /* Real and effective user id */
- gid_t gid, egid; /* Real and effective group id */
- unsigned proctable_entries; /* Max entries in the proctable */
+ uid_t uid, euid; /* Real and effective user id */
+ gid_t gid, egid; /* Real and effective group id */
+ unsigned proctable_entries; /* Max entries in the proctable */
};
END_LIBGTOP_DECLS
diff --git a/sysdeps/osf1/glibtop_server.h b/sysdeps/osf1/glibtop_server.h
index 47d69199..eb499d72 100644
--- a/sysdeps/osf1/glibtop_server.h
+++ b/sysdeps/osf1/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/osf1/glibtop_suid.h b/sysdeps/osf1/glibtop_suid.h
index a83fd3cc..bd4e6862 100644
--- a/sysdeps/osf1/glibtop_suid.h
+++ b/sysdeps/osf1/glibtop_suid.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -29,12 +31,12 @@
BEGIN_LIBGTOP_DECLS
static inline void glibtop_suid_enter (glibtop *server) {
- setreuid (server->machine.uid, server->machine.euid);
+ setreuid (server->machine.uid, server->machine.euid);
};
static inline void glibtop_suid_leave (glibtop *server) {
- if (setreuid (server->machine.euid, server->machine.uid))
- _exit (1);
+ if (setreuid (server->machine.euid, server->machine.uid))
+ _exit (1);
};
void
diff --git a/sysdeps/osf1/loadavg.c b/sysdeps/osf1/loadavg.c
index 6f8f949c..c7c80ec5 100644
--- a/sysdeps/osf1/loadavg.c
+++ b/sysdeps/osf1/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_loadavg =
int
glibtop_init_loadavg_s (glibtop *server)
{
- server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
+ server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
}
/* Provides load averange. */
@@ -41,33 +43,33 @@ glibtop_init_loadavg_s (glibtop *server)
int
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{
- struct tbl_loadavg loadavg;
- int ret;
+ struct tbl_loadavg loadavg;
+ int ret;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
- memset (buf, 0, sizeof (glibtop_loadavg));
+ memset (buf, 0, sizeof (glibtop_loadavg));
- ret = table (TBL_LOADAVG, 0, (char *) &loadavg, 1,
- sizeof (struct tbl_loadavg));
+ ret = table (TBL_LOADAVG, 0, (char *) &loadavg, 1,
+ sizeof (struct tbl_loadavg));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags = _glibtop_sysdeps_loadavg;
+ buf->flags = _glibtop_sysdeps_loadavg;
- if (loadavg.tl_lscale == 0) {
- buf->loadavg [0] = loadavg.tl_avenrun.d [0];
- buf->loadavg [1] = loadavg.tl_avenrun.d [1];
- buf->loadavg [2] = loadavg.tl_avenrun.d [2];
- } else {
- buf->loadavg [0] =
- (double) loadavg.tl_avenrun.l [0] /
- (double) loadavg.tl_mach_factor [0];
- buf->loadavg [1] =
- (double) loadavg.tl_avenrun.l [1]
- / (double) loadavg.tl_mach_factor [1];
- buf->loadavg [2] =
- (double) loadavg.tl_avenrun.l [2] /
- (double) loadavg.tl_mach_factor [2];
- }
+ if (loadavg.tl_lscale == 0) {
+ buf->loadavg [0] = loadavg.tl_avenrun.d [0];
+ buf->loadavg [1] = loadavg.tl_avenrun.d [1];
+ buf->loadavg [2] = loadavg.tl_avenrun.d [2];
+ } else {
+ buf->loadavg [0] =
+ (double) loadavg.tl_avenrun.l [0] /
+ (double) loadavg.tl_mach_factor [0];
+ buf->loadavg [1] =
+ (double) loadavg.tl_avenrun.l [1]
+ / (double) loadavg.tl_mach_factor [1];
+ buf->loadavg [2] =
+ (double) loadavg.tl_avenrun.l [2] /
+ (double) loadavg.tl_mach_factor [2];
+ }
}
diff --git a/sysdeps/osf1/mem.c b/sysdeps/osf1/mem.c
index 03577a05..b3544db2 100644
--- a/sysdeps/osf1/mem.c
+++ b/sysdeps/osf1/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -40,7 +42,7 @@ static const unsigned long _glibtop_sysdeps_mem =
int
glibtop_init_mem_s (glibtop *server)
{
- server->sysdeps.mem = _glibtop_sysdeps_mem;
+ server->sysdeps.mem = _glibtop_sysdeps_mem;
}
/* Provides information about memory usage. */
@@ -48,22 +50,22 @@ glibtop_init_mem_s (glibtop *server)
int
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{
- vm_statistics_data_t vmstats;
+ vm_statistics_data_t vmstats;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- buf->flags = _glibtop_sysdeps_mem;
+ buf->flags = _glibtop_sysdeps_mem;
- (void) vm_statistics(task_self(), &vmstats);
+ (void) vm_statistics(task_self(), &vmstats);
- buf->free = vmstats.free_count * vmstats.pagesize;
- buf->used = vmstats.active_count * vmstats.pagesize;
+ buf->free = vmstats.free_count * vmstats.pagesize;
+ buf->used = vmstats.active_count * vmstats.pagesize;
- /* [FIXME]: Is this correct? */
+ /* [FIXME]: Is this correct? */
- buf->total = (vmstats.active_count + vmstats.inactive_count +
- vmstats.free_count + vmstats.wire_count) *
- vmstats.pagesize;
+ buf->total = (vmstats.active_count + vmstats.inactive_count +
+ vmstats.free_count + vmstats.wire_count) *
+ vmstats.pagesize;
}
diff --git a/sysdeps/osf1/msg_limits.c b/sysdeps/osf1/msg_limits.c
index 12dc9498..498ad4a1 100644
--- a/sysdeps/osf1/msg_limits.c
+++ b/sysdeps/osf1/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,7 +37,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
int
glibtop_init_msg_limits_s (glibtop *server)
{
- server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
+ server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
}
/* Provides information about sysv ipc limits. */
@@ -43,45 +45,45 @@ glibtop_init_msg_limits_s (glibtop *server)
int
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
{
- int ret, value;
+ int ret, value;
- glibtop_init_s (&server, 0, 0);
+ glibtop_init_s (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- ret = table (TBL_MSGINFO, MSGINFO_MAX, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_MSGINFO, MSGINFO_MAX, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMAX);
+ buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMAX);
- buf->msgmax = value;
+ buf->msgmax = value;
- ret = table (TBL_MSGINFO, MSGINFO_MNB, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_MSGINFO, MSGINFO_MNB, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNB);
+ buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNB);
- buf->msgmnb = value;
+ buf->msgmnb = value;
- ret = table (TBL_MSGINFO, MSGINFO_MNI, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_MSGINFO, MSGINFO_MNI, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNI);
+ buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGMNI);
- buf->msgmni = value;
+ buf->msgmni = value;
- ret = table (TBL_MSGINFO, MSGINFO_TQL, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_MSGINFO, MSGINFO_TQL, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGTQL);
+ buf->flags += (1L << GLIBTOP_MSG_LIMITS_MSGTQL);
- buf->msgtql = value;
+ buf->msgtql = value;
}
diff --git a/sysdeps/osf1/netload.c b/sysdeps/osf1/netload.c
index 573066be..308eb56a 100644
--- a/sysdeps/osf1/netload.c
+++ b/sysdeps/osf1/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_netload = 0;
int
glibtop_init_netload_p (glibtop *server)
{
- server->sysdeps.netload = _glibtop_sysdeps_netload;
+ server->sysdeps.netload = _glibtop_sysdeps_netload;
}
/* Provides Network statistics. */
@@ -41,5 +43,5 @@ int
glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
const char *interface)
{
- memset (buf, 0, sizeof (glibtop_netload));
+ memset (buf, 0, sizeof (glibtop_netload));
}
diff --git a/sysdeps/osf1/open.c b/sysdeps/osf1/open.c
index 645e22d8..d667a18f 100644
--- a/sysdeps/osf1/open.c
+++ b/sysdeps/osf1/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/osf1/open_suid.c b/sysdeps/osf1/open_suid.c
index d593556a..f9270916 100644
--- a/sysdeps/osf1/open_suid.c
+++ b/sysdeps/osf1/open_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,21 +37,21 @@ void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
- glibtop_init_func_t *init_fkt;
+ glibtop_init_func_t *init_fkt;
- if (server == NULL)
- glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
- glibtop_open_p (server, "glibtop", features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
+ glibtop_open_p (server, "glibtop", features, flags);
- for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
- (*init_fkt) (server);
+ for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
+ (*init_fkt) (server);
- server->flags |= _GLIBTOP_INIT_STATE_INIT;
- }
+ server->flags |= _GLIBTOP_INIT_STATE_INIT;
+ }
}
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
@@ -58,17 +60,17 @@ void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- server->name = program_name;
+ server->name = program_name;
- server->machine.uid = getuid ();
- server->machine.euid = geteuid ();
- server->machine.gid = getgid ();
- server->machine.egid = getegid ();
+ server->machine.uid = getuid ();
+ server->machine.euid = geteuid ();
+ server->machine.gid = getgid ();
+ server->machine.egid = getegid ();
- server->machine.proctable_entries = table
- (TBL_PROCINFO, 0, NULL, INT_MAX, 0);
+ server->machine.proctable_entries = table
+ (TBL_PROCINFO, 0, NULL, INT_MAX, 0);
/* Drop priviledges; we only become root when necessary.
@@ -77,15 +79,15 @@ glibtop_open_p (glibtop *server, const char *program_name,
*/
- if (setreuid (server->machine.euid, server->machine.uid))
- _exit (1);
+ if (setreuid (server->machine.euid, server->machine.uid))
+ _exit (1);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- /* Our effective uid is now those of the user invoking the server,
- so we do no longer have any priviledges.
- */
+ /* Our effective uid is now those of the user invoking the server,
+ so we do no longer have any priviledges.
+ */
}
diff --git a/sysdeps/osf1/ppp.c b/sysdeps/osf1/ppp.c
index 0d682830..4f738ff2 100644
--- a/sysdeps/osf1/ppp.c
+++ b/sysdeps/osf1/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_ppp = 0;
int
glibtop_init_ppp_s (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
}
/* Provides PPP/ISDN information. */
@@ -40,5 +42,5 @@ glibtop_init_ppp_s (glibtop *server)
int
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
}
diff --git a/sysdeps/osf1/procargs.c b/sysdeps/osf1/procargs.c
index 5576c556..ed69b89c 100644
--- a/sysdeps/osf1/procargs.c
+++ b/sysdeps/osf1/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_proc_args = 0;
int
glibtop_init_proc_args_p (glibtop *server)
{
- server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
+ server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
}
/* Provides detailed information about a process. */
@@ -42,6 +44,6 @@ char *
glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
- memset (buf, 0, sizeof (glibtop_proc_args));
- return NULL;
+ memset (buf, 0, sizeof (glibtop_proc_args));
+ return NULL;
}
diff --git a/sysdeps/osf1/procdata.c b/sysdeps/osf1/procdata.c
index 96bb1430..b4dea48a 100644
--- a/sysdeps/osf1/procdata.c
+++ b/sysdeps/osf1/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -57,94 +59,94 @@ static const unsigned long _glibtop_sysdeps_procdata_1 = 0;
void
glibtop_get_procdata_r (glibtop *server, glibtop_procdata *buf, pid_t pid)
{
- struct tbl_procinfo procinfo;
- task_basic_info_data_t taskinfo;
- struct user u;
- task_t thistask;
- int ret, info_count;
+ struct tbl_procinfo procinfo;
+ task_basic_info_data_t taskinfo;
+ struct user u;
+ task_t thistask;
+ int ret, info_count;
- memset (buf, 0, sizeof (glibtop_procdata));
+ memset (buf, 0, sizeof (glibtop_procdata));
- glibtop_init ();
+ glibtop_init ();
- memset (buf, 0, sizeof (glibtop_procdata));
+ memset (buf, 0, sizeof (glibtop_procdata));
- ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
- sizeof (struct tbl_procinfo));
+ ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
+ sizeof (struct tbl_procinfo));
- if (ret != 1) return;
+ if (ret != 1) return;
- strcpy (buf->cmd, procinfo.pi_comm);
+ strcpy (buf->cmd, procinfo.pi_comm);
- buf->uid = procinfo.pi_uid;
- buf->pid = procinfo.pi_pid;
- buf->ppid = procinfo.pi_ppid;
- buf->pgrp = procinfo.pi_pgrp;
- buf->tty = procinfo.pi_ttyd;
- buf->k_flags = procinfo.pi_flag;
- buf->session = procinfo.pi_session;
- buf->tpgid = procinfo.pi_tpgrp;
- buf->sigignore = procinfo.pi_sigignore;
- buf->sigcatch = procinfo.pi_sigcatch;
- buf->signal = procinfo.pi_sig;
+ buf->uid = procinfo.pi_uid;
+ buf->pid = procinfo.pi_pid;
+ buf->ppid = procinfo.pi_ppid;
+ buf->pgrp = procinfo.pi_pgrp;
+ buf->tty = procinfo.pi_ttyd;
+ buf->k_flags = procinfo.pi_flag;
+ buf->session = procinfo.pi_session;
+ buf->tpgid = procinfo.pi_tpgrp;
+ buf->sigignore = procinfo.pi_sigignore;
+ buf->sigcatch = procinfo.pi_sigcatch;
+ buf->signal = procinfo.pi_sig;
- buf->flags [0] += _glibtop_sysdeps_procdata_0;
+ buf->flags [0] += _glibtop_sysdeps_procdata_0;
- if (procinfo.pi_status != PI_ACTIVE) return;
+ if (procinfo.pi_status != PI_ACTIVE) return;
- /* From that point on, we are only interested in active processes. */
+ /* From that point on, we are only interested in active processes. */
- buf->nice = getpriority (PRIO_PROCESS, pid);
+ buf->nice = getpriority (PRIO_PROCESS, pid);
- /* Get task structure. */
+ /* Get task structure. */
- ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
+ ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
- if (ret != KERN_SUCCESS) return;
+ if (ret != KERN_SUCCESS) return;
- /* Get taskinfo about this task. */
+ /* Get taskinfo about this task. */
- info_count = TASK_BASIC_INFO_COUNT;
+ info_count = TASK_BASIC_INFO_COUNT;
- ret = task_info (thistask, TASK_BASIC_INFO, (task_info_t) &taskinfo, &info_count);
+ ret = task_info (thistask, TASK_BASIC_INFO, (task_info_t) &taskinfo, &info_count);
- if (ret != KERN_SUCCESS) return;
+ if (ret != KERN_SUCCESS) return;
- buf->priority = taskinfo.base_priority;
- buf->resident = taskinfo.resident_size;
- buf->rss = taskinfo.resident_size;
- buf->vsize = taskinfo.virtual_size;
+ buf->priority = taskinfo.base_priority;
+ buf->resident = taskinfo.resident_size;
+ buf->rss = taskinfo.resident_size;
+ buf->vsize = taskinfo.virtual_size;
- buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) +
- BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) +
- BIT_SHIFT(GLIBTOP_PROCDATA_RSS) +
- BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE);
+ buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_RSS) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE);
- ret = table (TBL_UAREA, pid, (char *) &u, 1,
- sizeof (struct user));
+ ret = table (TBL_UAREA, pid, (char *) &u, 1,
+ sizeof (struct user));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->start_code = (unsigned long) u.u_text_start;
- buf->end_code = (unsigned long) u.u_data_start;
- buf->start_stack = (unsigned long) u.u_stack_start;
+ buf->start_code = (unsigned long) u.u_text_start;
+ buf->end_code = (unsigned long) u.u_data_start;
+ buf->start_stack = (unsigned long) u.u_stack_start;
- buf->trs = u.u_tsize;
- buf->drs = u.u_dsize;
+ buf->trs = u.u_tsize;
+ buf->drs = u.u_dsize;
- buf->start_time = u.u_start.tv_sec;
+ buf->start_time = u.u_start.tv_sec;
- buf->utime = u.u_ru.ru_utime.tv_sec;
- buf->stime = u.u_ru.ru_stime.tv_sec;
- buf->cutime = u.u_cru.ru_utime.tv_sec;
- buf->cstime = u.u_cru.ru_stime.tv_sec;
+ buf->utime = u.u_ru.ru_utime.tv_sec;
+ buf->stime = u.u_ru.ru_stime.tv_sec;
+ buf->cutime = u.u_cru.ru_utime.tv_sec;
+ buf->cstime = u.u_cru.ru_stime.tv_sec;
- buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) +
- BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_STIME) +
- BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) +
- BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + BIT_SHIFT(GLIBTOP_PROCDATA_DRS);
+ buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_STIME) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + BIT_SHIFT(GLIBTOP_PROCDATA_DRS);
- buf->flags [1] += BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) +
- BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) +
- BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK);
+ buf->flags [1] += BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) +
+ BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK);
}
diff --git a/sysdeps/osf1/prockernel.c b/sysdeps/osf1/prockernel.c
index 6f81f537..838288ed 100644
--- a/sysdeps/osf1/prockernel.c
+++ b/sysdeps/osf1/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
int
glibtop_init_proc_kernel_p (glibtop *server)
{
- server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
+ server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
}
/* Provides detailed information about a process. */
@@ -43,7 +45,7 @@ int
glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
}
diff --git a/sysdeps/osf1/proclist.c b/sysdeps/osf1/proclist.c
index 36f57421..5bf1d475 100644
--- a/sysdeps/osf1/proclist.c
+++ b/sysdeps/osf1/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -37,7 +39,7 @@ static const unsigned long _glibtop_sysdeps_proclist =
int
glibtop_init_proclist_p (glibtop *server)
{
- server->sysdeps.proclist = _glibtop_sysdeps_proclist;
+ server->sysdeps.proclist = _glibtop_sysdeps_proclist;
}
/* How many elements are there per proctable entry? */
@@ -69,44 +71,44 @@ unsigned *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
- unsigned count = 0, total = 0;
- unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
- unsigned pids_size = 0, pids_offset = 0, new_size;
- struct tbl_procinfo procinfo [8];
- int entry, max_elements, k;
+ unsigned count = 0, total = 0;
+ unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
+ unsigned pids_size = 0, pids_offset = 0, new_size;
+ struct tbl_procinfo procinfo [8];
+ int entry, max_elements, k;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0);
- memset (buf, 0, sizeof (glibtop_proclist));
+ memset (buf, 0, sizeof (glibtop_proclist));
- for (entry = 0; entry < server->machine.proctable_entries;
- entry += ELEMENTS_PER_ENTRY)
+ for (entry = 0; entry < server->machine.proctable_entries;
+ entry += ELEMENTS_PER_ENTRY)
{
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT -
- * CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT -
+ * CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- max_elements = table
- (TBL_PROCINFO, entry, (char *) &procinfo,
- ELEMENTS_PER_ENTRY, sizeof (struct tbl_procinfo));
+ max_elements = table
+ (TBL_PROCINFO, entry, (char *) &procinfo,
+ ELEMENTS_PER_ENTRY, sizeof (struct tbl_procinfo));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- for (k = 0; k < max_elements; k++)
+ for (k = 0; k < max_elements; k++)
{
- /* Does this entry contain a real process? */
+ /* Does this entry contain a real process? */
- if (procinfo [k].pi_status == 0)
- continue;
+ if (procinfo [k].pi_status == 0)
+ continue;
- /* Fine. Now we first try to store it in pids.
- * If this buffer is full, we copy it to the
- * pids_chain. */
+ /* Fine. Now we first try to store it in pids.
+ * If this buffer is full, we copy it to the
+ * pids_chain. */
- if (count >= BLOCK_COUNT) {
+ if (count >= BLOCK_COUNT) {
/* The following call to glibtop_realloc ()
* will be equivalent to glibtop_malloc ()
@@ -114,59 +116,59 @@ glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
* the new size and copy `pids' to the
* beginning of the newly allocated block. */
- new_size = pids_size + BLOCK_SIZE;
+ new_size = pids_size + BLOCK_SIZE;
- pids_chain = glibtop_realloc_r
- (server, pids_chain, new_size);
+ pids_chain = glibtop_realloc_r
+ (server, pids_chain, new_size);
- memcpy (pids_chain + pids_offset,
- pids, BLOCK_SIZE);
+ memcpy (pids_chain + pids_offset,
+ pids, BLOCK_SIZE);
- pids_size = new_size;
+ pids_size = new_size;
- pids_offset += BLOCK_COUNT;
+ pids_offset += BLOCK_COUNT;
- count = 0;
- }
+ count = 0;
+ }
- /* pids is now big enough to hold at least
- * one single pid. */
+ /* pids is now big enough to hold at least
+ * one single pid. */
- pids [count++] = procinfo [k].pi_pid;
+ pids [count++] = procinfo [k].pi_pid;
- total++;
+ total++;
}
}
- /* count is only zero if an error occured
- * (eg. the server is not suid root). */
+ /* count is only zero if an error occured
+ * (eg. the server is not suid root). */
- if (!count) return NULL;
+ if (!count) return NULL;
- /* The following call to glibtop_realloc () will be equivalent to
- * glibtop_malloc () if `pids_chain' is NULL. We just calculate the
- * new size and copy `pids' to the beginning of the newly allocated
- * block. */
+ /* The following call to glibtop_realloc () will be equivalent to
+ * glibtop_malloc () if `pids_chain' is NULL. We just calculate the
+ * new size and copy `pids' to the beginning of the newly allocated
+ * block. */
- new_size = pids_size + count * sizeof (unsigned);
+ new_size = pids_size + count * sizeof (unsigned);
- pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
+ pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
- memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
+ memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
- pids_size = new_size;
+ pids_size = new_size;
- pids_offset += BLOCK_COUNT;
+ pids_offset += BLOCK_COUNT;
- /* Since everything is ok now, we can set buf->flags, fill in the
- * remaining fields and return `pids_chain'. */
+ /* Since everything is ok now, we can set buf->flags, fill in the
+ * remaining fields and return `pids_chain'. */
- buf->flags = _glibtop_sysdeps_proclist;
+ buf->flags = _glibtop_sysdeps_proclist;
- buf->size = sizeof (unsigned);
- buf->number = total;
+ buf->size = sizeof (unsigned);
+ buf->number = total;
- buf->total = total * sizeof (unsigned);
+ buf->total = total * sizeof (unsigned);
- return pids_chain;
+ return pids_chain;
}
diff --git a/sysdeps/osf1/procmap.c b/sysdeps/osf1/procmap.c
index a6a0c498..e6ef83c8 100644
--- a/sysdeps/osf1/procmap.c
+++ b/sysdeps/osf1/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_proc_map = 0;
int
glibtop_init_proc_map_p (glibtop *server)
{
- server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
}
/* Provides detailed information about a process. */
@@ -41,6 +43,6 @@ glibtop_init_proc_map_p (glibtop *server)
glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_map));
- return NULL;
+ memset (buf, 0, sizeof (glibtop_proc_map));
+ return NULL;
}
diff --git a/sysdeps/osf1/procmem.c b/sysdeps/osf1/procmem.c
index 81f089dd..ef9be865 100644
--- a/sysdeps/osf1/procmem.c
+++ b/sysdeps/osf1/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -44,7 +46,7 @@ static const unsigned long _glibtop_sysdeps_proc_mem =
int
glibtop_init_proc_mem_p (glibtop *server)
{
- server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
+ server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
}
/* Provides detailed information about a process. */
@@ -53,51 +55,51 @@ int
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- task_basic_info_data_t taskinfo;
- int ret, info_count;
- task_t thistask;
- struct user u;
+ task_basic_info_data_t taskinfo;
+ int ret, info_count;
+ task_t thistask;
+ struct user u;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- /* Get task structure. */
+ /* Get task structure. */
- ret = task_by_unix_pid (task_self(), pid, &thistask);
+ ret = task_by_unix_pid (task_self(), pid, &thistask);
- if (ret != KERN_SUCCESS) return;
+ if (ret != KERN_SUCCESS) return;
- /* Get taskinfo about this task. */
+ /* Get taskinfo about this task. */
- info_count = TASK_BASIC_INFO_COUNT;
+ info_count = TASK_BASIC_INFO_COUNT;
- ret = task_info (thistask, TASK_BASIC_INFO,
- (task_info_t) &taskinfo, &info_count);
+ ret = task_info (thistask, TASK_BASIC_INFO,
+ (task_info_t) &taskinfo, &info_count);
- if (ret != KERN_SUCCESS) return;
+ if (ret != KERN_SUCCESS) return;
- buf->resident = taskinfo.resident_size;
- buf->rss = taskinfo.resident_size;
- buf->vsize = taskinfo.virtual_size;
+ buf->resident = taskinfo.resident_size;
+ buf->rss = taskinfo.resident_size;
+ buf->vsize = taskinfo.virtual_size;
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_UAREA, pid, (char *) &u, 1,
- sizeof (struct user));
+ ret = table (TBL_UAREA, pid, (char *) &u, 1,
+ sizeof (struct user));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->rss_rlim = u.u_rlimit [RLIMIT_RSS].rlim_cur;
+ buf->rss_rlim = u.u_rlimit [RLIMIT_RSS].rlim_cur;
- buf->share = u.u_ru.ru_ixrss;
+ buf->share = u.u_ru.ru_ixrss;
- buf->flags |= (1L << GLIBTOP_PROC_MEM_RSS_RLIM) |
- (1L << GLIBTOP_PROC_MEM_SHARE);
+ buf->flags |= (1L << GLIBTOP_PROC_MEM_RSS_RLIM) |
+ (1L << GLIBTOP_PROC_MEM_SHARE);
}
diff --git a/sysdeps/osf1/procsegment.c b/sysdeps/osf1/procsegment.c
index cf553cef..0a37be84 100644
--- a/sysdeps/osf1/procsegment.c
+++ b/sysdeps/osf1/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -40,7 +42,7 @@ static const unsigned long _glibtop_sysdeps_proc_segment =
int
glibtop_init_proc_segment_p (glibtop *server)
{
- server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
+ server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
}
/* Provides detailed information about a process. */
@@ -49,32 +51,32 @@ int
glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
- int ret;
- struct user u;
+ int ret;
+ struct user u;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_UAREA, pid, (char *) &u, 1,
- sizeof (struct user));
+ ret = table (TBL_UAREA, pid, (char *) &u, 1,
+ sizeof (struct user));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->start_code = (unsigned long) u.u_text_start;
- buf->end_code = (unsigned long) u.u_data_start;
- buf->start_stack = (unsigned long) u.u_stack_start;
+ buf->start_code = (unsigned long) u.u_text_start;
+ buf->end_code = (unsigned long) u.u_data_start;
+ buf->start_stack = (unsigned long) u.u_stack_start;
- buf->text_rss = u.u_tsize;
- buf->data_rss = u.u_dsize;
+ buf->text_rss = u.u_tsize;
+ buf->data_rss = u.u_dsize;
- buf->flags = _glibtop_sysdeps_proc_segment;
+ buf->flags = _glibtop_sysdeps_proc_segment;
}
diff --git a/sysdeps/osf1/procsignal.c b/sysdeps/osf1/procsignal.c
index adeb91d2..713fa435 100644
--- a/sysdeps/osf1/procsignal.c
+++ b/sysdeps/osf1/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,7 +38,7 @@ static const unsigned long _glibtop_sysdeps_proc_signal =
int
glibtop_init_proc_signal_p (glibtop *server)
{
- server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
+ server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
}
/* Provides detailed information about a process. */
@@ -45,30 +47,30 @@ int
glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
pid_t pid)
{
- struct tbl_procinfo procinfo;
- int ret;
+ struct tbl_procinfo procinfo;
+ int ret;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
- sizeof (struct tbl_procinfo));
+ ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
+ sizeof (struct tbl_procinfo));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->signal [0] = procinfo.pi_sig;
- buf->blocked [0] = procinfo.pi_sigmask;
- buf->sigignore [0] = procinfo.pi_sigignore;
- buf->sigcatch [0] = procinfo.pi_sigcatch;
+ buf->signal [0] = procinfo.pi_sig;
+ buf->blocked [0] = procinfo.pi_sigmask;
+ buf->sigignore [0] = procinfo.pi_sigignore;
+ buf->sigcatch [0] = procinfo.pi_sigcatch;
- buf->flags = _glibtop_sysdeps_proc_signal;
+ buf->flags = _glibtop_sysdeps_proc_signal;
}
diff --git a/sysdeps/osf1/procstate.c b/sysdeps/osf1/procstate.c
index 698e5bf3..49be81ca 100644
--- a/sysdeps/osf1/procstate.c
+++ b/sysdeps/osf1/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -41,7 +43,7 @@ static const unsigned long _glibtop_sysdeps_proc_state =
int
glibtop_init_proc_state_p (glibtop *server)
{
- server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
+ server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
}
/* Provides detailed information about a process. */
@@ -50,106 +52,106 @@ int
glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
- struct tbl_procinfo procinfo;
- int minim_state = 99, ret;
- task_t thistask;
+ struct tbl_procinfo procinfo;
+ int minim_state = 99, ret;
+ task_t thistask;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
- sizeof (struct tbl_procinfo));
+ ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
+ sizeof (struct tbl_procinfo));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- /* Check whether the process actually exists. */
- if (procinfo.pi_status == PI_EMPTY) return;
+ /* Check whether the process actually exists. */
+ if (procinfo.pi_status == PI_EMPTY) return;
- /* Check whether it is not a zombie. */
- if (procinfo.pi_status == PI_ZOMBIE) {
- buf->state = GLIBTOP_PROCESS_ZOMBIE;
- buf->flags = (1L << GLIBTOP_PROC_STATE_STATE);
- return;
- }
+ /* Check whether it is not a zombie. */
+ if (procinfo.pi_status == PI_ZOMBIE) {
+ buf->state = GLIBTOP_PROCESS_ZOMBIE;
+ buf->flags = (1L << GLIBTOP_PROC_STATE_STATE);
+ return;
+ }
- strncpy (buf->cmd, procinfo.pi_comm, sizeof (buf->cmd)-1);
+ strncpy (buf->cmd, procinfo.pi_comm, sizeof (buf->cmd)-1);
- buf->cmd [sizeof (buf->cmd)-1] = 0;
+ buf->cmd [sizeof (buf->cmd)-1] = 0;
- buf->uid = procinfo.pi_svuid;
- buf->gid = procinfo.pi_svgid;
- buf->ruid = procinfo.pi_ruid;
- buf->rgid = procinfo.pi_rgid;
+ buf->uid = procinfo.pi_svuid;
+ buf->gid = procinfo.pi_svgid;
+ buf->ruid = procinfo.pi_ruid;
+ buf->rgid = procinfo.pi_rgid;
- buf->flags = _glibtop_sysdeps_proc_state;
+ buf->flags = _glibtop_sysdeps_proc_state;
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- /* Get task structure. */
- ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
+ /* Get task structure. */
+ ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
- if (ret == KERN_SUCCESS) {
- thread_array_t threadarr;
- unsigned int threadarr_l;
- thread_basic_info_t threadinfo;
- thread_basic_info_data_t threadinfodata;
- int j;
-
- /* Get thread array. */
- (void) task_threads (thistask, &threadarr, &threadarr_l);
-
- threadinfo = &threadinfodata;
- for (j = 0; j < threadarr_l; j++) {
- unsigned int threadinfo_l = THREAD_BASIC_INFO_COUNT;
- int tret;
-
- tret = thread_info (threadarr [j], THREAD_BASIC_INFO,
- (thread_info_t) threadinfo, &threadinfo_l);
-
- if (tret == KERN_SUCCESS) {
- if (minim_state > threadinfo->run_state)
- minim_state=threadinfo->run_state;
- }
- }
+ if (ret == KERN_SUCCESS) {
+ thread_array_t threadarr;
+ unsigned int threadarr_l;
+ thread_basic_info_t threadinfo;
+ thread_basic_info_data_t threadinfodata;
+ int j;
+
+ /* Get thread array. */
+ (void) task_threads (thistask, &threadarr, &threadarr_l);
+
+ threadinfo = &threadinfodata;
+ for (j = 0; j < threadarr_l; j++) {
+ unsigned int threadinfo_l = THREAD_BASIC_INFO_COUNT;
+ int tret;
+
+ tret = thread_info (threadarr [j], THREAD_BASIC_INFO,
+ (thread_info_t) threadinfo, &threadinfo_l);
+
+ if (tret == KERN_SUCCESS) {
+ if (minim_state > threadinfo->run_state)
+ minim_state=threadinfo->run_state;
+ }
}
+ }
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != KERN_SUCCESS) return;
-
- switch (minim_state) {
- case TH_STATE_RUNNING:
- buf->state = GLIBTOP_PROCESS_RUNNING;
- break;
- case TH_STATE_UNINTERRUPTIBLE:
- buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
- break;
- case TH_STATE_WAITING:
- buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
- break;
- case TH_STATE_STOPPED:
- case TH_STATE_HALTED:
- buf->state = GLIBTOP_PROCESS_STOPPED;
- break;
- default:
- if (ret != KERN_SUCCESS)
- buf->state = GLIBTOP_PROCESS_ZOMBIE;
- break;
- }
-
- if (buf->state)
- buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
+ if (ret != KERN_SUCCESS) return;
+
+ switch (minim_state) {
+ case TH_STATE_RUNNING:
+ buf->state = GLIBTOP_PROCESS_RUNNING;
+ break;
+ case TH_STATE_UNINTERRUPTIBLE:
+ buf->state = GLIBTOP_PROCESS_UNINTERRUPTIBLE;
+ break;
+ case TH_STATE_WAITING:
+ buf->state = GLIBTOP_PROCESS_INTERRUPTIBLE;
+ break;
+ case TH_STATE_STOPPED:
+ case TH_STATE_HALTED:
+ buf->state = GLIBTOP_PROCESS_STOPPED;
+ break;
+ default:
+ if (ret != KERN_SUCCESS)
+ buf->state = GLIBTOP_PROCESS_ZOMBIE;
+ break;
+ }
+
+ if (buf->state)
+ buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
}
diff --git a/sysdeps/osf1/proctime.c b/sysdeps/osf1/proctime.c
index fbed9547..ef28f5ea 100644
--- a/sysdeps/osf1/proctime.c
+++ b/sysdeps/osf1/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -39,7 +41,7 @@ static const unsigned long _glibtop_sysdeps_proc_time =
int
glibtop_init_proc_time_p (glibtop *server)
{
- server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
+ server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
}
/* Provides detailed information about a process. */
@@ -48,32 +50,32 @@ int
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- struct user u;
- int ret;
+ struct user u;
+ int ret;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_UAREA, pid, (char *) &u, 1,
- sizeof (struct user));
+ ret = table (TBL_UAREA, pid, (char *) &u, 1,
+ sizeof (struct user));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->start_time = u.u_start.tv_sec;
+ buf->start_time = u.u_start.tv_sec;
- buf->utime = u.u_ru.ru_utime.tv_sec;
- buf->stime = u.u_ru.ru_stime.tv_sec;
- buf->cutime = u.u_cru.ru_utime.tv_sec;
- buf->cstime = u.u_cru.ru_stime.tv_sec;
+ buf->utime = u.u_ru.ru_utime.tv_sec;
+ buf->stime = u.u_ru.ru_stime.tv_sec;
+ buf->cutime = u.u_cru.ru_utime.tv_sec;
+ buf->cstime = u.u_cru.ru_stime.tv_sec;
- buf->flags = _glibtop_sysdeps_proc_time;
+ buf->flags = _glibtop_sysdeps_proc_time;
}
diff --git a/sysdeps/osf1/procuid.c b/sysdeps/osf1/procuid.c
index acf58ade..68f240df 100644
--- a/sysdeps/osf1/procuid.c
+++ b/sysdeps/osf1/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -47,86 +49,86 @@ static const unsigned long _glibtop_sysdeps_proc_uid =
int
glibtop_init_proc_uid_p (glibtop *server)
{
- server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
+ server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
}
int
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
- struct tbl_procinfo procinfo;
- task_basic_info_data_t taskinfo;
- int ret, info_count;
- task_t thistask;
+ struct tbl_procinfo procinfo;
+ task_basic_info_data_t taskinfo;
+ int ret, info_count;
+ task_t thistask;
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0);
- memset (buf, 0, sizeof (glibtop_proc_uid));
+ memset (buf, 0, sizeof (glibtop_proc_uid));
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
- sizeof (struct tbl_procinfo));
+ ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1,
+ sizeof (struct tbl_procinfo));
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->uid = procinfo.pi_ruid;
- buf->euid = procinfo.pi_svuid;
- buf->gid = procinfo.pi_rgid;
- buf->egid = procinfo.pi_svgid;
+ buf->uid = procinfo.pi_ruid;
+ buf->euid = procinfo.pi_svuid;
+ buf->gid = procinfo.pi_rgid;
+ buf->egid = procinfo.pi_svgid;
- buf->pid = procinfo.pi_pid;
- buf->ppid = procinfo.pi_ppid;
- buf->pgrp = procinfo.pi_pgrp;
- buf->tty = procinfo.pi_ttyd;
- buf->session = procinfo.pi_session;
- buf->tpgid = procinfo.pi_tpgrp;
+ buf->pid = procinfo.pi_pid;
+ buf->ppid = procinfo.pi_ppid;
+ buf->pgrp = procinfo.pi_pgrp;
+ buf->tty = procinfo.pi_ttyd;
+ buf->session = procinfo.pi_session;
+ buf->tpgid = procinfo.pi_tpgrp;
- buf->flags = _glibtop_sysdeps_proc_uid;
+ buf->flags = _glibtop_sysdeps_proc_uid;
- /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- /* Get task structure. */
+ /* Get task structure. */
- ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
+ ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask);
- if (ret == KERN_SUCCESS) {
+ if (ret == KERN_SUCCESS) {
- /* Get taskinfo about this task. */
+ /* Get taskinfo about this task. */
- info_count = TASK_BASIC_INFO_COUNT;
+ info_count = TASK_BASIC_INFO_COUNT;
- ret = task_info (thistask, TASK_BASIC_INFO,
- (task_info_t) &taskinfo, &info_count);
+ ret = task_info (thistask, TASK_BASIC_INFO,
+ (task_info_t) &taskinfo, &info_count);
- /* `ret' is evaluated outside the `if' clause. */
- }
+ /* `ret' is evaluated outside the `if' clause. */
+ }
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- if (ret != KERN_SUCCESS) return;
+ if (ret != KERN_SUCCESS) return;
- buf->priority = taskinfo.base_priority;
+ buf->priority = taskinfo.base_priority;
- buf->flags += (1L << GLIBTOP_PROC_UID_PRIORITY);
+ buf->flags += (1L << GLIBTOP_PROC_UID_PRIORITY);
- errno = 0;
+ errno = 0;
- ret = getpriority (PRIO_PROCESS, pid);
+ ret = getpriority (PRIO_PROCESS, pid);
- if ((ret == -1) && (errno != 0)) return;
+ if ((ret == -1) && (errno != 0)) return;
- buf->nice = ret;
+ buf->nice = ret;
- buf->flags += (1L << GLIBTOP_PROC_UID_NICE);
+ buf->flags += (1L << GLIBTOP_PROC_UID_NICE);
}
diff --git a/sysdeps/osf1/sem_limits.c b/sysdeps/osf1/sem_limits.c
index c870e0a5..42a8a188 100644
--- a/sysdeps/osf1/sem_limits.c
+++ b/sysdeps/osf1/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,7 +37,7 @@ static unsigned long _glibtop_sysdeps_sem_limits =
int
glibtop_init_sem_limits_s (glibtop *server)
{
- server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
+ server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
}
/* Provides information about sysv sem limits. */
@@ -43,68 +45,68 @@ glibtop_init_sem_limits_s (glibtop *server)
int
glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
{
- int ret, value;
+ int ret, value;
- glibtop_init_s (&server, 0, 0);
+ glibtop_init_s (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- ret = table (TBL_SEMINFO, SEMINFO_MNI, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_MNI, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMNI);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMNI);
- buf->semmni = value;
+ buf->semmni = value;
- ret = table (TBL_SEMINFO, SEMINFO_MSL, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_MSL, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMSL);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMMSL);
- buf->semmsl = value;
+ buf->semmsl = value;
- ret = table (TBL_SEMINFO, SEMINFO_OPM, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_OPM, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMOPM);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMOPM);
- buf->semopm = value;
+ buf->semopm = value;
- ret = table (TBL_SEMINFO, SEMINFO_UME, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_UME, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMUME);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMUME);
- buf->semume = value;
+ buf->semume = value;
- ret = table (TBL_SEMINFO, SEMINFO_VMX, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_VMX, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMVMX);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMVMX);
- buf->semvmx = value;
+ buf->semvmx = value;
- ret = table (TBL_SEMINFO, SEMINFO_AEM, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SEMINFO, SEMINFO_AEM, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMAEM);
+ buf->flags += (1L << GLIBTOP_SEM_LIMITS_SEMAEM);
- buf->semaem = value;
+ buf->semaem = value;
}
diff --git a/sysdeps/osf1/shm_limits.c b/sysdeps/osf1/shm_limits.c
index af429da1..96db6c29 100644
--- a/sysdeps/osf1/shm_limits.c
+++ b/sysdeps/osf1/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,7 +36,7 @@ static unsigned long _glibtop_sysdeps_shm_limits =
int
glibtop_init_shm_limits_s (glibtop *server)
{
- server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
+ server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
}
/* Provides information about sysv ipc limits. */
@@ -42,48 +44,48 @@ glibtop_init_shm_limits_s (glibtop *server)
int
glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
{
- int ret, value;
+ int ret, value;
- glibtop_init_s (&server, 0, 0);
+ glibtop_init_s (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- ret = table (TBL_SHMINFO, SHMINFO_MAX, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SHMINFO, SHMINFO_MAX, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMAX);
+ buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMAX);
- buf->shmmax = value;
+ buf->shmmax = value;
- ret = table (TBL_SHMINFO, SHMINFO_MIN, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SHMINFO, SHMINFO_MIN, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMIN);
+ buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMIN);
- buf->shmmin = value;
+ buf->shmmin = value;
- ret = table (TBL_SHMINFO, SHMINFO_MNI, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SHMINFO, SHMINFO_MNI, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMNI);
+ buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMMNI);
- buf->shmmni = value;
+ buf->shmmni = value;
- ret = table (TBL_SHMINFO, SHMINFO_SEG, (char *) &value, 1,
- sizeof (value));
+ ret = table (TBL_SHMINFO, SHMINFO_SEG, (char *) &value, 1,
+ sizeof (value));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMSEG);
+ buf->flags += (1L << GLIBTOP_SHM_LIMITS_SHMSEG);
- buf->shmseg = value;
+ buf->shmseg = value;
}
diff --git a/sysdeps/osf1/siglist.c b/sysdeps/osf1/siglist.c
index c5bd59c0..e41267ae 100644
--- a/sysdeps/osf1/siglist.c
+++ b/sysdeps/osf1/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/osf1/swap.c b/sysdeps/osf1/swap.c
index e37aecab..dc39cbfe 100644
--- a/sysdeps/osf1/swap.c
+++ b/sysdeps/osf1/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,7 +36,7 @@ static unsigned long _glibtop_sysdeps_swap =
int
glibtop_init_swap_s (glibtop *server)
{
- server->sysdeps.swap = _glibtop_sysdeps_swap;
+ server->sysdeps.swap = _glibtop_sysdeps_swap;
}
/* Provides information about swap usage. */
@@ -42,23 +44,23 @@ glibtop_init_swap_s (glibtop *server)
int
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{
- struct tbl_swapinfo swapinfo;
- int i;
+ struct tbl_swapinfo swapinfo;
+ int i;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0);
- memset (buf, 0, sizeof (glibtop_swap));
+ memset (buf, 0, sizeof (glibtop_swap));
- i = 0;
+ i = 0;
- while (table (TBL_SWAPINFO, i, (char *) &swapinfo, 1,
- sizeof (struct tbl_swapinfo)) > 0) {
- buf->total += swapinfo.size * getpagesize ();
- buf->free += swapinfo.free * getpagesize ();
- i++;
- }
-
- buf->flags = _glibtop_sysdeps_swap;
+ while (table (TBL_SWAPINFO, i, (char *) &swapinfo, 1,
+ sizeof (struct tbl_swapinfo)) > 0) {
+ buf->total += swapinfo.size * getpagesize ();
+ buf->free += swapinfo.free * getpagesize ();
+ i++;
+ }
+
+ buf->flags = _glibtop_sysdeps_swap;
- buf->used = buf->total - buf->free;
+ buf->used = buf->total - buf->free;
}
diff --git a/sysdeps/osf1/uptime.c b/sysdeps/osf1/uptime.c
index 09ac41dc..8b4c5ad2 100644
--- a/sysdeps/osf1/uptime.c
+++ b/sysdeps/osf1/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,7 +37,7 @@ static unsigned long _glibtop_sysdeps_uptime =
int
glibtop_init_uptime_s (glibtop *server)
{
- server->sysdeps.uptime = _glibtop_sysdeps_uptime;
+ server->sysdeps.uptime = _glibtop_sysdeps_uptime;
}
/* Provides uptime and idle time. */
@@ -43,19 +45,19 @@ glibtop_init_uptime_s (glibtop *server)
int
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{
- struct tbl_sysinfo sysinfo;
- int ret;
+ struct tbl_sysinfo sysinfo;
+ int ret;
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0);
- memset (buf, 0, sizeof (glibtop_uptime));
+ memset (buf, 0, sizeof (glibtop_uptime));
- ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1,
- sizeof (struct tbl_sysinfo));
+ ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1,
+ sizeof (struct tbl_sysinfo));
- if (ret != 1) return;
+ if (ret != 1) return;
- buf->uptime = (double) (time (NULL) - sysinfo.si_boottime);
+ buf->uptime = (double) (time (NULL) - sysinfo.si_boottime);
- buf->flags = _glibtop_sysdeps_uptime;
+ buf->flags = _glibtop_sysdeps_uptime;
}
diff --git a/sysdeps/solaris/close.c b/sysdeps/solaris/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/solaris/close.c
+++ b/sysdeps/solaris/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/close_suid.c b/sysdeps/solaris/close_suid.c
index a8733f0f..95bffec1 100644
--- a/sysdeps/solaris/close_suid.c
+++ b/sysdeps/solaris/close_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/cpu.c b/sysdeps/solaris/cpu.c
index 74371800..08098183 100644
--- a/sysdeps/solaris/cpu.c
+++ b/sysdeps/solaris/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -63,44 +65,44 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
if(!kc)
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
switch(kstat_chain_update(kc))
- {
+ {
case -1: assert(0); /* Debugging purposes, shouldn't happen */
case 0: break;
default: glibtop_get_kstats(server);
- }
+ }
ncpu = server->ncpu;
if (ncpu > GLIBTOP_NCPU)
ncpu = GLIBTOP_NCPU;
for (cpu = 0, found = 0; cpu < GLIBTOP_NCPU && found != ncpu; cpu++)
- {
- kstat_t *ksp = server->_priv->machine.cpu_stat_kstat [cpu];
- if (!ksp) continue;
-
- ++found;
- if(p_online(cpu, P_STATUS) == P_ONLINE)
- buf->xcpu_flags |= (1L << cpu);
- else
- continue;
- ret = kstat_read (kc, ksp, &cpu_stat);
-
- if (ret == -1) {
- glibtop_warn_io_r (server, "kstat_read (cpu_stat%d)", cpu);
- continue;
+ {
+ kstat_t *ksp = server->_priv->machine.cpu_stat_kstat [cpu];
+ if (!ksp) continue;
+
+ ++found;
+ if(p_online(cpu, P_STATUS) == P_ONLINE)
+ buf->xcpu_flags |= (1L << cpu);
+ else
+ continue;
+ ret = kstat_read (kc, ksp, &cpu_stat);
+
+ if (ret == -1) {
+ glibtop_warn_io_r (server, "kstat_read (cpu_stat%d)", cpu);
+ continue;
+ }
+
+ buf->xcpu_idle [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
+ buf->xcpu_user [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_USER];
+ buf->xcpu_sys [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
+
+ buf->xcpu_total [cpu] = buf->xcpu_idle [cpu] + buf->xcpu_user [cpu] +
+ buf->xcpu_sys [cpu];
+
+ buf->idle += cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
+ buf->user += cpu_stat.cpu_sysinfo.cpu [CPU_USER];
+ buf->sys += cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
}
- buf->xcpu_idle [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
- buf->xcpu_user [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_USER];
- buf->xcpu_sys [cpu] = cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
-
- buf->xcpu_total [cpu] = buf->xcpu_idle [cpu] + buf->xcpu_user [cpu] +
- buf->xcpu_sys [cpu];
-
- buf->idle += cpu_stat.cpu_sysinfo.cpu [CPU_IDLE];
- buf->user += cpu_stat.cpu_sysinfo.cpu [CPU_USER];
- buf->sys += cpu_stat.cpu_sysinfo.cpu [CPU_KERNEL];
- }
-
buf->total = buf->idle + buf->user + buf->sys;
buf->frequency = server->_priv->machine.ticks;
diff --git a/sysdeps/solaris/glibtop_machine.h b/sysdeps/solaris/glibtop_machine.h
index bb14cf99..b3eb413c 100644
--- a/sysdeps/solaris/glibtop_machine.h
+++ b/sysdeps/solaris/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/glibtop_private.h b/sysdeps/solaris/glibtop_private.h
index ffe0f655..06790cce 100644
--- a/sysdeps/solaris/glibtop_private.h
+++ b/sysdeps/solaris/glibtop_private.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/glibtop_server.h b/sysdeps/solaris/glibtop_server.h
index 6c4d348d..d23ee540 100644
--- a/sysdeps/solaris/glibtop_server.h
+++ b/sysdeps/solaris/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/glibtop_suid.h b/sysdeps/solaris/glibtop_suid.h
index b1e8cb17..3923f034 100644
--- a/sysdeps/solaris/glibtop_suid.h
+++ b/sysdeps/solaris/glibtop_suid.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -27,12 +29,12 @@
BEGIN_LIBGTOP_DECLS
static inline void glibtop_suid_enter (glibtop *server) {
- setreuid (server->_priv->machine.uid, server->_priv->machine.euid);
+ setreuid (server->_priv->machine.uid, server->_priv->machine.euid);
};
static inline void glibtop_suid_leave (glibtop *server) {
- if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
- _exit (1);
+ if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
+ _exit (1);
};
void
diff --git a/sysdeps/solaris/interfaces.c b/sysdeps/solaris/interfaces.c
index bf491632..ea4aa0e8 100644
--- a/sysdeps/solaris/interfaces.c
+++ b/sysdeps/solaris/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/loadavg.c b/sysdeps/solaris/loadavg.c
index aadd5744..154685f5 100644
--- a/sysdeps/solaris/loadavg.c
+++ b/sysdeps/solaris/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/mem.c b/sysdeps/solaris/mem.c
index 8f0fbf53..08071ae4 100644
--- a/sysdeps/solaris/mem.c
+++ b/sysdeps/solaris/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -71,61 +73,61 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
if(!kc)
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
switch(kstat_chain_update(kc))
- {
+ {
case -1: assert(0); /* Debugging purposes, shouldn't happen */
case 0: break;
default: glibtop_get_kstats(server);
- }
+ }
if((ksp = server->_priv->machine.syspages) && kstat_read(kc, ksp, NULL) >= 0)
- {
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "pagesfree");
- if(kn)
{
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "pagesfree");
+ if(kn)
+ {
#ifdef _LP64
- buf->free = kn->value.ui64 << pagesize << 10;
+ buf->free = kn->value.ui64 << pagesize << 10;
#else
- buf->free = kn->value.ui32 << pagesize << 10;
+ buf->free = kn->value.ui32 << pagesize << 10;
#endif
- buf->used = buf->total - buf->free;
- }
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "pageslocked");
- if(kn)
+ buf->used = buf->total - buf->free;
+ }
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "pageslocked");
+ if(kn)
#ifdef _LP64
- buf->locked = kn->value.ui64 << pagesize;
+ buf->locked = kn->value.ui64 << pagesize;
#else
buf->locked = kn->value.ui32 << pagesize;
#endif
- buf->flags += _glibtop_sysdeps_mem_os_kstat;
- }
+ buf->flags += _glibtop_sysdeps_mem_os_kstat;
+ }
/* Bunyip module provides data in multiples of system page size */
if((ksp = server->_priv->machine.bunyip) && kstat_read(kc, ksp, NULL) >= 0)
- {
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_anon");
- if(kn)
+ {
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_anon");
+ if(kn)
#ifdef _LP64
- buf->user = kn->value.ui64 << pagesize << 10;
+ buf->user = kn->value.ui64 << pagesize << 10;
#else
buf->user = kn->value.ui32 << pagesize << 10;
#endif
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_exec");
- if(kn)
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_exec");
+ if(kn)
#ifdef _LP64
- buf->shared = kn->value.ui64 << pagesize << 10;
+ buf->shared = kn->value.ui64 << pagesize << 10;
#else
buf->shared = kn->value.ui32 << pagesize << 10;
#endif
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_vnode");
- if(kn)
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "pages_vnode");
+ if(kn)
#ifdef _LP64
- buf->buffer = kn->value.ui64 << pagesize << 10;
+ buf->buffer = kn->value.ui64 << pagesize << 10;
#else
buf->buffer = kn->value.ui32 << pagesize << 10;
#endif
- buf->flags += _glibtop_sysdeps_mem_bunyip;
- }
+ buf->flags += _glibtop_sysdeps_mem_bunyip;
+ }
return 0;
}
diff --git a/sysdeps/solaris/msg_limits.c b/sysdeps/solaris/msg_limits.c
index 0f008dcc..6542690f 100644
--- a/sysdeps/solaris/msg_limits.c
+++ b/sysdeps/solaris/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/netinfo.c b/sysdeps/solaris/netinfo.c
index 8006e015..21ed5860 100644
--- a/sysdeps/solaris/netinfo.c
+++ b/sysdeps/solaris/netinfo.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/netload.c b/sysdeps/solaris/netload.c
index 4f7800e3..8f34d41b 100644
--- a/sysdeps/solaris/netload.c
+++ b/sysdeps/solaris/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/open.c b/sysdeps/solaris/open.c
index c25ccb3b..5ee019ff 100644
--- a/sysdeps/solaris/open.c
+++ b/sysdeps/solaris/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -46,25 +48,25 @@ glibtop_get_kstats(glibtop *server)
new_ncpu = sysconf(_SC_NPROCESSORS_CONF);
if(!kc)
- {
- server->ncpu = new_ncpu;
- server->_priv->machine.vminfo_kstat = NULL;
- server->_priv->machine.system = NULL;
- server->_priv->machine.syspages = NULL;
- server->_priv->machine.bunyip = NULL;
- return;
- }
+ {
+ server->ncpu = new_ncpu;
+ server->_priv->machine.vminfo_kstat = NULL;
+ server->_priv->machine.system = NULL;
+ server->_priv->machine.syspages = NULL;
+ server->_priv->machine.bunyip = NULL;
+ return;
+ }
do {
ksp = kstat_lookup(kc, "unix", -1, "vminfo");
server->_priv->machine.vminfo_kstat = ksp;
if(ksp)
- {
- kstat_read(kc, ksp, &server->_priv->machine.vminfo);
- /* Don't change snaptime if we only need to reinitialize kstats */
- if(!(server->_priv->machine.vminfo_snaptime))
- server->_priv->machine.vminfo_snaptime = ksp->ks_snaptime;
- }
+ {
+ kstat_read(kc, ksp, &server->_priv->machine.vminfo);
+ /* Don't change snaptime if we only need to reinitialize kstats */
+ if(!(server->_priv->machine.vminfo_snaptime))
+ server->_priv->machine.vminfo_snaptime = ksp->ks_snaptime;
+ }
/* We don't know why was kstat chain invalidated. It could have
been because the number of processors changed. The sysconf()
@@ -73,45 +75,45 @@ glibtop_get_kstats(glibtop *server)
the documentation. */
if((nproc_same = new_ncpu) == server->ncpu)
- {
- int checked, i;
- char cpu[20];
-
- for(i = 0, checked = 0; i < GLIBTOP_NCPU || checked == new_ncpu; ++i)
- if(server->_priv->machine.cpu_stat_kstat[i])
- {
- sprintf(cpu, "cpu_stat%d", i);
- if(!(server->_priv->machine.cpu_stat_kstat[i] =
- kstat_lookup(kc, "cpu_stat", -1, cpu)))
- {
- nproc_same = 0;
- break;
- }
- ++checked;
- }
- }
+ {
+ int checked, i;
+ char cpu[20];
+
+ for(i = 0, checked = 0; i < GLIBTOP_NCPU || checked == new_ncpu; ++i)
+ if(server->_priv->machine.cpu_stat_kstat[i])
+ {
+ sprintf(cpu, "cpu_stat%d", i);
+ if(!(server->_priv->machine.cpu_stat_kstat[i] =
+ kstat_lookup(kc, "cpu_stat", -1, cpu)))
+ {
+ nproc_same = 0;
+ break;
+ }
+ ++checked;
+ }
+ }
if(!nproc_same)
- {
- processorid_t p;
- int found;
- char cpu[20];
-
- if(new_ncpu > GLIBTOP_NCPU)
- new_ncpu = GLIBTOP_NCPU;
- server->ncpu = new_ncpu;
- for(p = 0, found = 0; p < GLIBTOP_NCPU && found != new_ncpu; ++p)
{
- if(p_online(p, P_STATUS) < 0)
- {
- server->_priv->machine.cpu_stat_kstat[p] = NULL;
- continue;
- }
- sprintf(cpu, "cpu_stat%d", (int)p);
- server->_priv->machine.cpu_stat_kstat[p] =
- kstat_lookup(kc, "cpu_stat", -1, cpu);
- ++found;
+ processorid_t p;
+ int found;
+ char cpu[20];
+
+ if(new_ncpu > GLIBTOP_NCPU)
+ new_ncpu = GLIBTOP_NCPU;
+ server->ncpu = new_ncpu;
+ for(p = 0, found = 0; p < GLIBTOP_NCPU && found != new_ncpu; ++p)
+ {
+ if(p_online(p, P_STATUS) < 0)
+ {
+ server->_priv->machine.cpu_stat_kstat[p] = NULL;
+ continue;
+ }
+ sprintf(cpu, "cpu_stat%d", (int)p);
+ server->_priv->machine.cpu_stat_kstat[p] =
+ kstat_lookup(kc, "cpu_stat", -1, cpu);
+ ++found;
+ }
}
- }
server->_priv->machine.system = kstat_lookup(kc, "unix", -1, "system_misc");
server->_priv->machine.syspages = kstat_lookup(kc, "unix", -1, "system_pages");
@@ -176,32 +178,32 @@ glibtop_open_s (glibtop *server, const char *program_name,
server->_priv->machine.boot = 0;
if((ksp = server->_priv->machine.system) && kstat_read(kc, ksp, NULL) >= 0)
- {
- kn = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
- if(kn)
- switch(kn->data_type)
- {
+ {
+ kn = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
+ if(kn)
+ switch(kn->data_type)
+ {
#ifdef KSTAT_DATA_INT32
- case KSTAT_DATA_INT32: server->_priv->machine.boot = kn->value.i32;
- break;
- case KSTAT_DATA_UINT32: server->_priv->machine.boot = kn->value.ui32;
- break;
- case KSTAT_DATA_INT64: server->_priv->machine.boot = kn->value.i64;
- break;
- case KSTAT_DATA_UINT64: server->_priv->machine.boot = kn->value.ui64;
- break;
+ case KSTAT_DATA_INT32: server->_priv->machine.boot = kn->value.i32;
+ break;
+ case KSTAT_DATA_UINT32: server->_priv->machine.boot = kn->value.ui32;
+ break;
+ case KSTAT_DATA_INT64: server->_priv->machine.boot = kn->value.i64;
+ break;
+ case KSTAT_DATA_UINT64: server->_priv->machine.boot = kn->value.ui64;
+ break;
#else
- case KSTAT_DATA_LONG: server->_priv->machine.boot = kn->value.l;
- break;
- case KSTAT_DATA_ULONG: server->_priv->machine.boot = kn->value.ul;
- break;
- case KSTAT_DATA_LONGLONG: server->_priv->machine.boot = kn->value.ll;
- break;
- case KSTAT_DATA_ULONGLONG: server->_priv->machine.boot = kn->value.ull;
- break;
+ case KSTAT_DATA_LONG: server->_priv->machine.boot = kn->value.l;
+ break;
+ case KSTAT_DATA_ULONG: server->_priv->machine.boot = kn->value.ul;
+ break;
+ case KSTAT_DATA_LONGLONG: server->_priv->machine.boot = kn->value.ll;
+ break;
+ case KSTAT_DATA_ULONGLONG: server->_priv->machine.boot = kn->value.ull;
+ break;
#endif
- }
- }
+ }
+ }
/* Now let's have a bit of magic dust... */
@@ -210,24 +212,24 @@ glibtop_open_s (glibtop *server, const char *program_name,
dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
server->_priv->machine.libproc = dl;
if(dl)
- {
- void *func;
-
- func = dlsym(dl, "Pobjname"); /* Solaris 8 */
- if(!func)
- func = dlsym(dl, "proc_objname"); /* Solaris 7 */
- server->_priv->machine.objname = (void (*)
- (void *, uintptr_t, const char *, size_t))func;
- server->_priv->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
- dlsym(dl, "Pgrab");
- server->_priv->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
- }
+ {
+ void *func;
+
+ func = dlsym(dl, "Pobjname"); /* Solaris 8 */
+ if(!func)
+ func = dlsym(dl, "proc_objname"); /* Solaris 7 */
+ server->_priv->machine.objname = (void (*)
+ (void *, uintptr_t, const char *, size_t))func;
+ server->_priv->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
+ dlsym(dl, "Pgrab");
+ server->_priv->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
+ }
else
- {
- server->_priv->machine.objname = NULL;
- server->_priv->machine.pgrab = NULL;
- server->_priv->machine.pfree = NULL;
- }
+ {
+ server->_priv->machine.objname = NULL;
+ server->_priv->machine.pgrab = NULL;
+ server->_priv->machine.pfree = NULL;
+ }
#endif
server->_priv->machine.me = getpid();
}
diff --git a/sysdeps/solaris/open_suid.c b/sysdeps/solaris/open_suid.c
index 18f37e80..3107f667 100644
--- a/sysdeps/solaris/open_suid.c
+++ b/sysdeps/solaris/open_suid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,21 +37,21 @@ void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
- glibtop_init_func_t *init_fkt;
+ glibtop_init_func_t *init_fkt;
- if (server == NULL)
- glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
- glibtop_open_p (server, "glibtop", features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
+ glibtop_open_p (server, "glibtop", features, flags);
- for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
- (*init_fkt) (server);
+ for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
+ (*init_fkt) (server);
- server->flags |= _GLIBTOP_INIT_STATE_INIT;
- }
+ server->flags |= _GLIBTOP_INIT_STATE_INIT;
+ }
}
/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
@@ -58,18 +60,18 @@ void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- server->name = program_name;
+ server->name = program_name;
- server->_priv->machine.uid = getuid ();
- server->_priv->machine.euid = geteuid ();
- server->_priv->machine.gid = getgid ();
- server->_priv->machine.egid = getegid ();
+ server->_priv->machine.uid = getuid ();
+ server->_priv->machine.euid = geteuid ();
+ server->_priv->machine.gid = getgid ();
+ server->_priv->machine.egid = getegid ();
- server->_priv->machine.kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
- if(!server->_priv->machine.kd)
- glibtop_warn_io_r(server, "kvm_open()");
+ server->_priv->machine.kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
+ if(!server->_priv->machine.kd)
+ glibtop_warn_io_r(server, "kvm_open()");
/* Drop priviledges; we only become root when necessary.
@@ -78,15 +80,15 @@ glibtop_open_p (glibtop *server, const char *program_name,
*/
- if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
- _exit (1);
+ if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
+ _exit (1);
- if (setregid (server->_priv->machine.egid, server->_priv->machine.gid))
- _exit (1);
+ if (setregid (server->_priv->machine.egid, server->_priv->machine.gid))
+ _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- /* Our effective uid is now those of the user invoking the server,
- so we do no longer have any priviledges.
- */
+ /* Our effective uid is now those of the user invoking the server,
+ so we do no longer have any priviledges.
+ */
}
diff --git a/sysdeps/solaris/ppp.c b/sysdeps/solaris/ppp.c
index 85717ee8..c2599fb0 100644
--- a/sysdeps/solaris/ppp.c
+++ b/sysdeps/solaris/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procargs.c b/sysdeps/solaris/procargs.c
index 8dd11292..441d91ce 100644
--- a/sysdeps/solaris/procargs.c
+++ b/sysdeps/solaris/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procdata.c b/sysdeps/solaris/procdata.c
index d975a315..555c0737 100644
--- a/sysdeps/solaris/procdata.c
+++ b/sysdeps/solaris/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -49,51 +51,51 @@
int
glibtop_get_proc_data_psinfo_s (glibtop *server, struct psinfo *psinfo, pid_t pid)
{
- int fd;
- char buffer [BUFSIZ];
-
- sprintf (buffer, "/proc/%d/psinfo", (int) pid);
- fd = s_open (buffer, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", buffer);
- return -1;
- }
-
- if (s_pread (fd, psinfo, sizeof (struct psinfo), 0) !=
- sizeof (struct psinfo))
+ int fd;
+ char buffer [BUFSIZ];
+
+ sprintf (buffer, "/proc/%d/psinfo", (int) pid);
+ fd = s_open (buffer, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", buffer);
+ return -1;
+ }
+
+ if (s_pread (fd, psinfo, sizeof (struct psinfo), 0) !=
+ sizeof (struct psinfo))
{
- s_close (fd);
- glibtop_warn_io_r (server, "pread (%s)", buffer);
- return -1;
+ s_close (fd);
+ glibtop_warn_io_r (server, "pread (%s)", buffer);
+ return -1;
}
- s_close (fd);
- return 0;
+ s_close (fd);
+ return 0;
}
int
glibtop_get_proc_data_usage_s (glibtop *server, struct prusage *prusage, pid_t pid)
{
- int fd;
- char buffer [BUFSIZ];
-
- sprintf (buffer, "/proc/%d/usage", (int) pid);
- fd = s_open (buffer, O_RDONLY);
- if (fd < 0) {
- glibtop_warn_io_r (server, "open (%s)", buffer);
- return -1;
- }
-
- if (s_pread (fd, prusage, sizeof (struct prusage), 0) !=
- sizeof (struct prusage))
+ int fd;
+ char buffer [BUFSIZ];
+
+ sprintf (buffer, "/proc/%d/usage", (int) pid);
+ fd = s_open (buffer, O_RDONLY);
+ if (fd < 0) {
+ glibtop_warn_io_r (server, "open (%s)", buffer);
+ return -1;
+ }
+
+ if (s_pread (fd, prusage, sizeof (struct prusage), 0) !=
+ sizeof (struct prusage))
{
- s_close (fd);
- glibtop_warn_io_r (server, "pread (%s)", buffer);
- return -1;
+ s_close (fd);
+ glibtop_warn_io_r (server, "pread (%s)", buffer);
+ return -1;
}
- s_close (fd);
- return 0;
+ s_close (fd);
+ return 0;
}
int
@@ -102,25 +104,25 @@ glibtop_get_proc_credentials_s(glibtop *server,
gid_t *groups,
pid_t pid)
{
- int fd;
- size_t toread;
- char buffer[BUFSIZ];
+ int fd;
+ size_t toread;
+ char buffer[BUFSIZ];
- sprintf(buffer, "/proc/%d/cred", (int)pid);
- if((fd = s_open(buffer, O_RDONLY)) < 0)
+ sprintf(buffer, "/proc/%d/cred", (int)pid);
+ if((fd = s_open(buffer, O_RDONLY)) < 0)
{
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r(server, "open (%s)", buffer);
- return -1;
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r(server, "open (%s)", buffer);
+ return -1;
}
- if(s_pread(fd, prcred, sizeof(struct prcred), 0) !=
- sizeof(struct prcred))
+ if(s_pread(fd, prcred, sizeof(struct prcred), 0) !=
+ sizeof(struct prcred))
{
- s_close(fd);
- glibtop_warn_io_r(server, "pread (%s)", buffer);
- return -1;
+ s_close(fd);
+ glibtop_warn_io_r(server, "pread (%s)", buffer);
+ return -1;
}
- if(prcred->pr_ngroups >= 0)
+ if(prcred->pr_ngroups >= 0)
{
if(prcred->pr_ngroups <= GLIBTOP_MAX_GROUPS)
toread = prcred->pr_ngroups * sizeof(gid_t);
@@ -128,34 +130,34 @@ glibtop_get_proc_credentials_s(glibtop *server,
toread = GLIBTOP_MAX_GROUPS * sizeof(gid_t);
if(s_pread(fd, groups, toread,
(off_t)&(((struct prcred *)0)->pr_groups[0])) != toread)
- prcred->pr_ngroups = 0;
+ prcred->pr_ngroups = 0;
}
- s_close(fd);
- return 0;
+ s_close(fd);
+ return 0;
}
int
glibtop_get_proc_status_s(glibtop *server, struct pstatus *pstatus, pid_t pid)
{
- int fd;
- char buffer[BUFSIZ];
+ int fd;
+ char buffer[BUFSIZ];
- sprintf(buffer, "/proc/%d/status", (int)pid);
- if((fd = s_open(buffer, O_RDONLY)) < 0)
+ sprintf(buffer, "/proc/%d/status", (int)pid);
+ if((fd = s_open(buffer, O_RDONLY)) < 0)
{
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r(server, "open (%s)", buffer);
- return -1;
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r(server, "open (%s)", buffer);
+ return -1;
}
- if(s_pread(fd, pstatus, sizeof(struct pstatus), 0) !=
- sizeof(struct pstatus))
+ if(s_pread(fd, pstatus, sizeof(struct pstatus), 0) !=
+ sizeof(struct pstatus))
{
- s_close(fd);
- glibtop_warn_io_r(server, "pread (%s)", buffer);
- return -1;
+ s_close(fd);
+ glibtop_warn_io_r(server, "pread (%s)", buffer);
+ return -1;
}
- s_close(fd);
- return 0;
+ s_close(fd);
+ return 0;
}
#else /* old API */
@@ -165,26 +167,26 @@ glibtop_get_proc_data_psinfo_s (glibtop *server,
struct prpsinfo *psinfo,
pid_t pid)
{
- int fd;
- char buffer [BUFSIZ];
-
- sprintf (buffer, "/proc/%d", (int) pid);
- fd = s_open (buffer, O_RDONLY);
- if (fd < 0) {
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r (server, "open (%s)", buffer);
- return -1;
- }
-
- if(ioctl(fd, PIOCPSINFO, psinfo) < 0)
+ int fd;
+ char buffer [BUFSIZ];
+
+ sprintf (buffer, "/proc/%d", (int) pid);
+ fd = s_open (buffer, O_RDONLY);
+ if (fd < 0) {
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r (server, "open (%s)", buffer);
+ return -1;
+ }
+
+ if(ioctl(fd, PIOCPSINFO, psinfo) < 0)
{
- s_close (fd);
- glibtop_warn_io_r (server, "ioctl(%s, PIOCPSINFO)", buffer);
- return -1;
+ s_close (fd);
+ glibtop_warn_io_r (server, "ioctl(%s, PIOCPSINFO)", buffer);
+ return -1;
}
- s_close (fd);
- return 0;
+ s_close (fd);
+ return 0;
}
int
@@ -192,26 +194,26 @@ glibtop_get_proc_data_usage_s (glibtop *server,
struct prusage *prusage,
pid_t pid)
{
- int fd;
- char buffer [BUFSIZ];
-
- sprintf (buffer, "/proc/%d", (int) pid);
- fd = s_open (buffer, O_RDONLY);
- if (fd < 0) {
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r (server, "open (%s)", buffer);
- return -1;
- }
-
- if(ioctl(fd, PIOCUSAGE, prusage) < 0)
+ int fd;
+ char buffer [BUFSIZ];
+
+ sprintf (buffer, "/proc/%d", (int) pid);
+ fd = s_open (buffer, O_RDONLY);
+ if (fd < 0) {
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r (server, "open (%s)", buffer);
+ return -1;
+ }
+
+ if(ioctl(fd, PIOCUSAGE, prusage) < 0)
{
- s_close (fd);
- glibtop_warn_io_r (server, "ioctl(%s, PIOCUSAGE)", buffer);
- return -1;
+ s_close (fd);
+ glibtop_warn_io_r (server, "ioctl(%s, PIOCUSAGE)", buffer);
+ return -1;
}
- s_close (fd);
- return 0;
+ s_close (fd);
+ return 0;
}
int
@@ -220,47 +222,47 @@ glibtop_get_proc_credentials_s(glibtop *server,
gid_t *groups,
pid_t pid)
{
- int fd;
- size_t toread;
- char buffer[BUFSIZ];
+ int fd;
+ size_t toread;
+ char buffer[BUFSIZ];
- sprintf(buffer, "/proc/%d", (int)pid);
- if((fd = s_open(buffer, O_RDONLY)) < 0)
+ sprintf(buffer, "/proc/%d", (int)pid);
+ if((fd = s_open(buffer, O_RDONLY)) < 0)
{
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r(server, "open (%s)", buffer);
- return -1;
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r(server, "open (%s)", buffer);
+ return -1;
}
- if(ioctl(fd, PIOCCRED, prcred) < 0)
+ if(ioctl(fd, PIOCCRED, prcred) < 0)
{
- s_close(fd);
- glibtop_warn_io_r(server, "ioctl(%s, PIOCCRED)", buffer);
- return -1;
+ s_close(fd);
+ glibtop_warn_io_r(server, "ioctl(%s, PIOCCRED)", buffer);
+ return -1;
}
- s_close(fd);
- return 0;
+ s_close(fd);
+ return 0;
}
int
glibtop_get_proc_status_s(glibtop *server, struct prstatus *pstatus, pid_t pid)
{
- int fd;
- char buffer[BUFSIZ];
+ int fd;
+ char buffer[BUFSIZ];
- sprintf(buffer, "/proc/%d", (int)pid);
- if((fd = s_open(buffer, O_RDONLY)) < 0)
+ sprintf(buffer, "/proc/%d", (int)pid);
+ if((fd = s_open(buffer, O_RDONLY)) < 0)
{
- if(errno != EPERM && errno != EACCES)
- glibtop_warn_io_r(server, "open (%s)", buffer);
- return -1;
+ if(errno != EPERM && errno != EACCES)
+ glibtop_warn_io_r(server, "open (%s)", buffer);
+ return -1;
}
- if(ioctl(fd, PIOCSTATUS, pstatus) < 0)
+ if(ioctl(fd, PIOCSTATUS, pstatus) < 0)
{
- s_close(fd);
- glibtop_warn_io_r(server, "ioctl(%s, PIOCSTATUS)", buffer);
- return -1;
+ s_close(fd);
+ glibtop_warn_io_r(server, "ioctl(%s, PIOCSTATUS)", buffer);
+ return -1;
}
- s_close(fd);
- return 0;
+ s_close(fd);
+ return 0;
}
#endif
diff --git a/sysdeps/solaris/prockernel.c b/sysdeps/solaris/prockernel.c
index 1d9709ce..c596a532 100644
--- a/sysdeps/solaris/prockernel.c
+++ b/sysdeps/solaris/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/proclist.c b/sysdeps/solaris/proclist.c
index 50dce0af..5c89213e 100644
--- a/sysdeps/solaris/proclist.c
+++ b/sysdeps/solaris/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procmap.c b/sysdeps/solaris/procmap.c
index eada9b63..363e6171 100644
--- a/sysdeps/solaris/procmap.c
+++ b/sysdeps/solaris/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procmem.c b/sysdeps/solaris/procmem.c
index 61a52d3b..eabe3dca 100644
--- a/sysdeps/solaris/procmem.c
+++ b/sysdeps/solaris/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procsegment.c b/sysdeps/solaris/procsegment.c
index 93577fe6..aab29e9e 100644
--- a/sysdeps/solaris/procsegment.c
+++ b/sysdeps/solaris/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procsignal.c b/sysdeps/solaris/procsignal.c
index 5fdcd0c0..47754261 100644
--- a/sysdeps/solaris/procsignal.c
+++ b/sysdeps/solaris/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procstate.c b/sysdeps/solaris/procstate.c
index ae093981..faeae9cd 100644
--- a/sysdeps/solaris/procstate.c
+++ b/sysdeps/solaris/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/proctime.c b/sysdeps/solaris/proctime.c
index 491a1838..acbbb96e 100644
--- a/sysdeps/solaris/proctime.c
+++ b/sysdeps/solaris/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/procuid.c b/sysdeps/solaris/procuid.c
index 1e0eda61..7ae444cf 100644
--- a/sysdeps/solaris/procuid.c
+++ b/sysdeps/solaris/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/safeio.c b/sysdeps/solaris/safeio.c
index d109731a..6085f09c 100644
--- a/sysdeps/solaris/safeio.c
+++ b/sysdeps/solaris/safeio.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* Copyright (C) 1999 Drazen Kacar
This file is part of LibGTop 1.0.
diff --git a/sysdeps/solaris/sem_limits.c b/sysdeps/solaris/sem_limits.c
index 292f456e..1d747bc6 100644
--- a/sysdeps/solaris/sem_limits.c
+++ b/sysdeps/solaris/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/shm_limits.c b/sysdeps/solaris/shm_limits.c
index 2f16f1ac..b0792712 100644
--- a/sysdeps/solaris/shm_limits.c
+++ b/sysdeps/solaris/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/siglist.c b/sysdeps/solaris/siglist.c
index 292bb73e..c5e5073a 100644
--- a/sysdeps/solaris/siglist.c
+++ b/sysdeps/solaris/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/solaris/swap.c b/sysdeps/solaris/swap.c
index 49443e41..a8adf311 100644
--- a/sysdeps/solaris/swap.c
+++ b/sysdeps/solaris/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -62,11 +64,11 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
switch(kstat_chain_update(kc))
- {
+ {
case -1: assert(0); /* Debugging, shouldn't happen */
case 0: break;
default: glibtop_get_kstats(server);
- }
+ }
ret = kstat_read (kc, ksp, &vminfo);
if (ret == -1) {
diff --git a/sysdeps/solaris/uptime.c b/sysdeps/solaris/uptime.c
index 675aa465..79246ed2 100644
--- a/sysdeps/solaris/uptime.c
+++ b/sysdeps/solaris/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/stub/close.c
+++ b/sysdeps/stub/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c
index e395f278..2eefe798 100644
--- a/sysdeps/stub/cpu.c
+++ b/sysdeps/stub/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_cpu = 0;
int
glibtop_init_cpu_s (glibtop *server)
{
- server->sysdeps.cpu = _glibtop_sysdeps_cpu;
+ server->sysdeps.cpu = _glibtop_sysdeps_cpu;
- return 0;
+ return 0;
}
/* Provides information about cpu usage. */
@@ -41,7 +43,7 @@ glibtop_init_cpu_s (glibtop *server)
int
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
- memset (buf, 0, sizeof (glibtop_cpu));
+ memset (buf, 0, sizeof (glibtop_cpu));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/glibtop_server.h b/sysdeps/stub/glibtop_server.h
index b3822d47..ce0acf4f 100644
--- a/sysdeps/stub/glibtop_server.h
+++ b/sysdeps/stub/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub/interfaces.c b/sysdeps/stub/interfaces.c
index 3102e7a1..806fbf1d 100644
--- a/sysdeps/stub/interfaces.c
+++ b/sysdeps/stub/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c
index bc11f435..ca6ca730 100644
--- a/sysdeps/stub/loadavg.c
+++ b/sysdeps/stub/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_loadavg = 0;
int
glibtop_init_loadavg_s (glibtop *server)
{
- server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
+ server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
- return 0;
+ return 0;
}
/* Provides load averange. */
@@ -41,7 +43,7 @@ glibtop_init_loadavg_s (glibtop *server)
int
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{
- memset (buf, 0, sizeof (glibtop_loadavg));
+ memset (buf, 0, sizeof (glibtop_loadavg));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c
index ca65c73f..256b057b 100644
--- a/sysdeps/stub/mem.c
+++ b/sysdeps/stub/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_mem = 0;
int
glibtop_init_mem_s (glibtop *server)
{
- server->sysdeps.mem = _glibtop_sysdeps_mem;
+ server->sysdeps.mem = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
/* Provides information about memory usage. */
@@ -41,7 +43,7 @@ glibtop_init_mem_s (glibtop *server)
int
glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c
index 95dcb46b..7a2e30da 100644
--- a/sysdeps/stub/msg_limits.c
+++ b/sysdeps/stub/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_msg_limits = 0;
int
glibtop_init_msg_limits_s (glibtop *server)
{
- server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
+ server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -41,7 +43,7 @@ glibtop_init_msg_limits_s (glibtop *server)
int
glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
{
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/netload.c b/sysdeps/stub/netload.c
index 9f63de50..e600d2e1 100644
--- a/sysdeps/stub/netload.c
+++ b/sysdeps/stub/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,9 +34,9 @@ static const unsigned long _glibtop_sysdeps_netload = 0;
int
glibtop_init_netload_s (glibtop *server)
{
- server->sysdeps.netload = _glibtop_sysdeps_netload;
+ server->sysdeps.netload = _glibtop_sysdeps_netload;
- return 0;
+ return 0;
}
/* Provides network statistics. */
@@ -43,7 +45,7 @@ int
glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
const char *interface)
{
- memset (buf, 0, sizeof (glibtop_netload));
+ memset (buf, 0, sizeof (glibtop_netload));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c
index eef22d71..6e4dc655 100644
--- a/sysdeps/stub/open.c
+++ b/sysdeps/stub/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -29,5 +31,5 @@ void
glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- server->name = program_name;
+ server->name = program_name;
}
diff --git a/sysdeps/stub/ppp.c b/sysdeps/stub/ppp.c
index 484e1425..c2599fb0 100644
--- a/sysdeps/stub/ppp.c
+++ b/sysdeps/stub/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,9 +34,9 @@ static const unsigned long _glibtop_sysdeps_ppp = 0;
int
glibtop_init_ppp_s (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
- return 0;
+ return 0;
}
/* Provides PPP/ISDN information. */
@@ -42,7 +44,7 @@ glibtop_init_ppp_s (glibtop *server)
int
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/procargs.c b/sysdeps/stub/procargs.c
index e441df3f..8065bff2 100644
--- a/sysdeps/stub/procargs.c
+++ b/sysdeps/stub/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,9 +35,9 @@ static const unsigned long _glibtop_sysdeps_proc_args = 0;
int
glibtop_init_proc_args_s (glibtop *server)
{
- server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
+ server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -44,6 +46,6 @@ char *
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
- memset (buf, 0, sizeof (glibtop_proc_args));
- return NULL;
+ memset (buf, 0, sizeof (glibtop_proc_args));
+ return NULL;
}
diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c
index 87cf1e58..c596a532 100644
--- a/sysdeps/stub/prockernel.c
+++ b/sysdeps/stub/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
int
glibtop_init_proc_kernel_s (glibtop *server)
{
- server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
+ server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c
index 659c4939..49ecd987 100644
--- a/sysdeps/stub/proclist.c
+++ b/sysdeps/stub/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,9 +35,9 @@ static const unsigned long _glibtop_sysdeps_proclist = 0;
int
glibtop_init_proclist_s (glibtop *server)
{
- server->sysdeps.proclist = _glibtop_sysdeps_proclist;
+ server->sysdeps.proclist = _glibtop_sysdeps_proclist;
- return 0;
+ return 0;
}
/* Fetch list of currently running processes.
@@ -49,6 +51,6 @@ unsigned *
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
- memset (buf, 0, sizeof (glibtop_proclist));
- return NULL;
+ memset (buf, 0, sizeof (glibtop_proclist));
+ return NULL;
}
diff --git a/sysdeps/stub/procmap.c b/sysdeps/stub/procmap.c
index 727ba155..39968d0f 100644
--- a/sysdeps/stub/procmap.c
+++ b/sysdeps/stub/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_map = 0;
int
glibtop_init_proc_map_s (glibtop *server)
{
- server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -44,9 +46,9 @@ glibtop_init_proc_map_s (glibtop *server)
glibtop_map_entry *
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
{
- glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
+ glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
- memset (buf, 0, sizeof (glibtop_proc_map));
+ memset (buf, 0, sizeof (glibtop_proc_map));
- return NULL;
+ return NULL;
}
diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c
index 67e13db4..de2beaa7 100644
--- a/sysdeps/stub/procmem.c
+++ b/sysdeps/stub/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_mem = 0;
int
glibtop_init_proc_mem_s (glibtop *server)
{
- server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
+ server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c
index 39c42732..aab29e9e 100644
--- a/sysdeps/stub/procsegment.c
+++ b/sysdeps/stub/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_segment = 0;
int
glibtop_init_proc_segment_s (glibtop *server)
{
- server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
+ server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c
index d42dea94..48cd54a1 100644
--- a/sysdeps/stub/procsignal.c
+++ b/sysdeps/stub/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_signal = 0;
int
glibtop_init_proc_signal_s (glibtop *server)
{
- server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
+ server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c
index f517166f..c084017a 100644
--- a/sysdeps/stub/procstate.c
+++ b/sysdeps/stub/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_state = 0;
int
glibtop_init_proc_state_s (glibtop *server)
{
- server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
+ server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c
index 5e63d110..9e9cad05 100644
--- a/sysdeps/stub/proctime.c
+++ b/sysdeps/stub/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_time = 0;
int
glibtop_init_proc_time_s (glibtop *server)
{
- server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
+ server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c
index ecf859c9..50224d3a 100644
--- a/sysdeps/stub/procuid.c
+++ b/sysdeps/stub/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_uid = 0;
int
glibtop_init_proc_uid_s (glibtop *server)
{
- server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
+ server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -42,7 +44,7 @@ int
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_uid));
+ memset (buf, 0, sizeof (glibtop_proc_uid));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c
index 8bfb3cce..74d34345 100644
--- a/sysdeps/stub/sem_limits.c
+++ b/sysdeps/stub/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_sem_limits = 0;
int
glibtop_init_sem_limits_s (glibtop *server)
{
- server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
+ server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv sem limits. */
@@ -41,7 +43,7 @@ glibtop_init_sem_limits_s (glibtop *server)
int
glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
{
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c
index a427eaa5..2bd2b8d6 100644
--- a/sysdeps/stub/shm_limits.c
+++ b/sysdeps/stub/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_shm_limits = 0;
int
glibtop_init_shm_limits_s (glibtop *server)
{
- server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
+ server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -41,7 +43,7 @@ glibtop_init_shm_limits_s (glibtop *server)
int
glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
{
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/siglist.c b/sysdeps/stub/siglist.c
index 94abfdc6..329b7ccc 100644
--- a/sysdeps/stub/siglist.c
+++ b/sysdeps/stub/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c
index 0f0a7fd4..0d1b5b36 100644
--- a/sysdeps/stub/swap.c
+++ b/sysdeps/stub/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_swap = 0;
int
glibtop_init_swap_s (glibtop *server)
{
- server->sysdeps.swap = _glibtop_sysdeps_swap;
+ server->sysdeps.swap = _glibtop_sysdeps_swap;
- return 0;
+ return 0;
}
/* Provides information about swap usage. */
@@ -41,7 +43,7 @@ glibtop_init_swap_s (glibtop *server)
int
glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{
- memset (buf, 0, sizeof (glibtop_swap));
+ memset (buf, 0, sizeof (glibtop_swap));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c
index 0f993a02..d22ab49f 100644
--- a/sysdeps/stub/uptime.c
+++ b/sysdeps/stub/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_uptime = 0;
int
glibtop_init_uptime_s (glibtop *server)
{
- server->sysdeps.uptime = _glibtop_sysdeps_uptime;
+ server->sysdeps.uptime = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
/* Provides uptime and idle time. */
@@ -41,7 +43,7 @@ glibtop_init_uptime_s (glibtop *server)
int
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{
- memset (buf, 0, sizeof (glibtop_uptime));
+ memset (buf, 0, sizeof (glibtop_uptime));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/close.c b/sysdeps/stub_suid/close.c
index 4262d2f0..3378b817 100644
--- a/sysdeps/stub_suid/close.c
+++ b/sysdeps/stub_suid/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub_suid/cpu.c b/sysdeps/stub_suid/cpu.c
index 4b9909b7..6ec05b68 100644
--- a/sysdeps/stub_suid/cpu.c
+++ b/sysdeps/stub_suid/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_cpu = 0;
int
glibtop_init_cpu_p (glibtop *server)
{
- server->sysdeps.cpu = _glibtop_sysdeps_cpu;
+ server->sysdeps.cpu = _glibtop_sysdeps_cpu;
- return 0;
+ return 0;
}
/* Provides information about cpu usage. */
@@ -44,9 +46,9 @@ glibtop_init_cpu_p (glibtop *server)
int
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_CPU, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_CPU, 0);
- memset (buf, 0, sizeof (glibtop_cpu));
+ memset (buf, 0, sizeof (glibtop_cpu));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/glibtop_machine.h b/sysdeps/stub_suid/glibtop_machine.h
index 835f177f..a0faf8b8 100644
--- a/sysdeps/stub_suid/glibtop_machine.h
+++ b/sysdeps/stub_suid/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -30,8 +32,8 @@ typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
- uid_t uid, euid; /* Real and effective user id */
- gid_t gid, egid; /* Real and effective group id */
+ uid_t uid, euid; /* Real and effective user id */
+ gid_t gid, egid; /* Real and effective group id */
};
END_LIBGTOP_DECLS
diff --git a/sysdeps/stub_suid/glibtop_server.h b/sysdeps/stub_suid/glibtop_server.h
index 689f781c..b96cf67e 100644
--- a/sysdeps/stub_suid/glibtop_server.h
+++ b/sysdeps/stub_suid/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub_suid/glibtop_suid.h b/sysdeps/stub_suid/glibtop_suid.h
index b1e8cb17..3923f034 100644
--- a/sysdeps/stub_suid/glibtop_suid.h
+++ b/sysdeps/stub_suid/glibtop_suid.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -27,12 +29,12 @@
BEGIN_LIBGTOP_DECLS
static inline void glibtop_suid_enter (glibtop *server) {
- setreuid (server->_priv->machine.uid, server->_priv->machine.euid);
+ setreuid (server->_priv->machine.uid, server->_priv->machine.euid);
};
static inline void glibtop_suid_leave (glibtop *server) {
- if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
- _exit (1);
+ if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
+ _exit (1);
};
void
diff --git a/sysdeps/stub_suid/init.c b/sysdeps/stub_suid/init.c
index 0f643bd0..53e2453a 100644
--- a/sysdeps/stub_suid/init.c
+++ b/sysdeps/stub_suid/init.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,14 +34,14 @@ glibtop_init_r (glibtop **server,
const unsigned long features,
const unsigned flags)
{
- if (*server != NULL)
- return *server;
-
- if (glibtop_global_server == NULL) {
- glibtop_global_server = &_glibtop_global_server;
- glibtop_open (glibtop_global_server, "glibtop",
- features, flags);
- }
+ if (*server != NULL)
+ return *server;
+
+ if (glibtop_global_server == NULL) {
+ glibtop_global_server = &_glibtop_global_server;
+ glibtop_open (glibtop_global_server, "glibtop",
+ features, flags);
+ }
- return *server = glibtop_global_server;
+ return *server = glibtop_global_server;
}
diff --git a/sysdeps/stub_suid/interfaces.c b/sysdeps/stub_suid/interfaces.c
index bda553cc..0add40c6 100644
--- a/sysdeps/stub_suid/interfaces.c
+++ b/sysdeps/stub_suid/interfaces.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub_suid/loadavg.c b/sysdeps/stub_suid/loadavg.c
index 10a3ae1b..f713d5db 100644
--- a/sysdeps/stub_suid/loadavg.c
+++ b/sysdeps/stub_suid/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_loadavg = 0;
int
glibtop_init_loadavg_p (glibtop *server)
{
- server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
+ server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
- return 0;
+ return 0;
}
/* Provides load averange. */
@@ -44,9 +46,9 @@ glibtop_init_loadavg_p (glibtop *server)
int
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_LOADAVG, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_LOADAVG, 0);
- memset (buf, 0, sizeof (glibtop_loadavg));
+ memset (buf, 0, sizeof (glibtop_loadavg));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/mem.c b/sysdeps/stub_suid/mem.c
index 33a467c3..430e5062 100644
--- a/sysdeps/stub_suid/mem.c
+++ b/sysdeps/stub_suid/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_mem = 0;
int
glibtop_init_mem_p (glibtop *server)
{
- server->sysdeps.mem = _glibtop_sysdeps_mem;
+ server->sysdeps.mem = _glibtop_sysdeps_mem;
- return 0;
+ return 0;
}
/* Provides information about memory usage. */
@@ -44,9 +46,9 @@ glibtop_init_mem_p (glibtop *server)
int
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_MEM, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_MEM, 0);
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/msg_limits.c b/sysdeps/stub_suid/msg_limits.c
index 88f79ddb..efb0f958 100644
--- a/sysdeps/stub_suid/msg_limits.c
+++ b/sysdeps/stub_suid/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_msg_limits = 0;
int
glibtop_init_msg_limits_p (glibtop *server)
{
- server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
+ server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -44,9 +46,9 @@ glibtop_init_msg_limits_p (glibtop *server)
int
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/netload.c b/sysdeps/stub_suid/netload.c
index 6910fe0e..1e2f7ec7 100644
--- a/sysdeps/stub_suid/netload.c
+++ b/sysdeps/stub_suid/netload.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,9 +34,9 @@ static const unsigned long _glibtop_sysdeps_netload = 0;
int
glibtop_init_netload_p (glibtop *server)
{
- server->sysdeps.netload = _glibtop_sysdeps_netload;
+ server->sysdeps.netload = _glibtop_sysdeps_netload;
- return 0;
+ return 0;
}
/* Provides Network statistics. */
@@ -44,7 +46,7 @@ glibtop_get_netload_p (glibtop *server, glibtop_netload *buf,
const char *interface, unsigned transport,
unsigned protocol)
{
- memset (buf, 0, sizeof (glibtop_netload));
+ memset (buf, 0, sizeof (glibtop_netload));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/nosuid.c b/sysdeps/stub_suid/nosuid.c
index cd52852c..0ee13dc4 100644
--- a/sysdeps/stub_suid/nosuid.c
+++ b/sysdeps/stub_suid/nosuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub_suid/open.c b/sysdeps/stub_suid/open.c
index e734f62c..2d20b2bd 100644
--- a/sysdeps/stub_suid/open.c
+++ b/sysdeps/stub_suid/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,47 +33,47 @@ void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
- glibtop_init_func_t *init_fkt;
+ glibtop_init_func_t *init_fkt;
- if (server == NULL)
- glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
- /* Do the initialization, but only if not already initialized. */
+ /* Do the initialization, but only if not already initialized. */
- if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
- glibtop_open_p (server, "glibtop", features, flags);
+ if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) {
+ glibtop_open_p (server, "glibtop", features, flags);
- for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
- (*init_fkt) (server);
+ for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
+ (*init_fkt) (server);
- server->flags |= _GLIBTOP_INIT_STATE_INIT;
- }
+ server->flags |= _GLIBTOP_INIT_STATE_INIT;
+ }
}
void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- server->name = program_name;
+ server->name = program_name;
- server->_priv->machine.uid = getuid ();
- server->_priv->machine.euid = geteuid ();
- server->_priv->machine.gid = getgid ();
- server->_priv->machine.egid = getegid ();
+ server->_priv->machine.uid = getuid ();
+ server->_priv->machine.euid = geteuid ();
+ server->_priv->machine.gid = getgid ();
+ server->_priv->machine.egid = getegid ();
/* Drop priviledges. */
- if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
- _exit (1);
+ if (setreuid (server->_priv->machine.euid, server->_priv->machine.uid))
+ _exit (1);
- if (setregid (server->_priv->machine.egid, server->_priv->machine.gid))
- _exit (1);
+ if (setregid (server->_priv->machine.egid, server->_priv->machine.gid))
+ _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- /* Our effective uid is now those of the user invoking the server,
- * so we do no longer have any priviledges. */
+ /* Our effective uid is now those of the user invoking the server,
+ * so we do no longer have any priviledges. */
}
diff --git a/sysdeps/stub_suid/ppp.c b/sysdeps/stub_suid/ppp.c
index 8c16ca2f..efb27973 100644
--- a/sysdeps/stub_suid/ppp.c
+++ b/sysdeps/stub_suid/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,9 +34,9 @@ static const unsigned long _glibtop_sysdeps_ppp = 0;
int
glibtop_init_ppp_p (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
- return 0;
+ return 0;
}
/* Provides PPP/ISDN information. */
@@ -42,7 +44,7 @@ glibtop_init_ppp_p (glibtop *server)
int
glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/procargs.c b/sysdeps/stub_suid/procargs.c
index cde5192d..980b0ba3 100644
--- a/sysdeps/stub_suid/procargs.c
+++ b/sysdeps/stub_suid/procargs.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,9 +35,9 @@ static const unsigned long _glibtop_sysdeps_proc_args = 0;
int
glibtop_init_proc_args_p (glibtop *server)
{
- server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
+ server->sysdeps.proc_args = _glibtop_sysdeps_proc_args;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -43,6 +45,6 @@ glibtop_init_proc_args_p (glibtop *server)
char **
glibtop_get_proc_args_p (glibtop *server, glibtop_array *array, pid_t pid)
{
- memset (array, 0, sizeof (glibtop_array));
- return NULL;
+ memset (array, 0, sizeof (glibtop_array));
+ return NULL;
}
diff --git a/sysdeps/stub_suid/procdata.c b/sysdeps/stub_suid/procdata.c
index 1bd5696d..1d22e8ee 100644
--- a/sysdeps/stub_suid/procdata.c
+++ b/sysdeps/stub_suid/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -82,99 +84,99 @@ BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN);
void
glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
{
- char input [BUFSIZ], *tmp;
- struct stat statb;
- int nread;
- FILE *f;
+ char input [BUFSIZ], *tmp;
+ struct stat statb;
+ int nread;
+ FILE *f;
- glibtop_init_r (&server, 0, 0);
+ glibtop_init_r (&server, 0, 0);
- memset (buf, 0, sizeof (glibtop_procdata));
+ memset (buf, 0, sizeof (glibtop_procdata));
- if (pid == 0) {
- /* Client is only interested in the flags. */
- buf->flags [0] = _glibtop_sysdeps_procdata_0;
- buf->flags [1] = _glibtop_sysdeps_procdata_1;
- return;
- }
+ if (pid == 0) {
+ /* Client is only interested in the flags. */
+ buf->flags [0] = _glibtop_sysdeps_procdata_0;
+ buf->flags [1] = _glibtop_sysdeps_procdata_1;
+ return;
+ }
- sprintf (input, "/proc/%d/stat", pid);
+ sprintf (input, "/proc/%d/stat", pid);
- if (stat (input, &statb)) return;
+ if (stat (input, &statb)) return;
- buf->uid = statb.st_uid;
+ buf->uid = statb.st_uid;
- f = fopen (input, "r");
- if (!f) return;
+ f = fopen (input, "r");
+ if (!f) return;
- nread = fread (input, 1, BUFSIZ, f);
+ nread = fread (input, 1, BUFSIZ, f);
- if (nread < 0) {
- fclose (f);
- return;
- }
+ if (nread < 0) {
+ fclose (f);
+ return;
+ }
- input [nread] = 0;
+ input [nread] = 0;
- /* This is from guile-utils/gtop/proc/readproc.c */
+ /* This is from guile-utils/gtop/proc/readproc.c */
- /* split into "PID (cmd" and "<rest>" */
- tmp = strrchr (input, ')');
- *tmp = '\0'; /* replace trailing ')' with NUL */
- /* parse these two strings separately, skipping the leading "(". */
- memset (buf->cmd, 0, sizeof (buf->cmd));
- sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
- sscanf(tmp + 2, /* skip space after ')' too */
- "%c %d %d %d %d %d %lu %lu %lu %lu %lu "
- "%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
- "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
- &buf->state, &buf->ppid, &buf->pgrp, &buf->session,
- &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
- &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
- &buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
- &buf->priority, &buf->nice, &buf->timeout,
- &buf->it_real_value, &buf->start_time, &buf->vsize,
- &buf->rss, &buf->rss_rlim, &buf->start_code,
- &buf->end_code, &buf->start_stack, &buf->kstk_esp,
- &buf->kstk_eip, &buf->signal, &buf->blocked,
- &buf->sigignore, &buf->sigcatch, &buf->wchan);
-
- if (buf->tty == 0)
- /* the old notty val, update elsewhere bef. moving to 0 */
- buf->tty = -1;
-
- if (server->os_version_code < LINUX_VERSION(1,3,39)) {
- /* map old meanings to new */
- buf->priority = 2*15 - buf->priority;
- buf->nice = 15 - buf->nice;
- }
- if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
- /* when tty wasn't full devno */
- buf->tty = 4*0x100 + buf->tty;
+ /* split into "PID (cmd" and "<rest>" */
+ tmp = strrchr (input, ')');
+ *tmp = '\0'; /* replace trailing ')' with NUL */
+ /* parse these two strings separately, skipping the leading "(". */
+ memset (buf->cmd, 0, sizeof (buf->cmd));
+ sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
+ sscanf(tmp + 2, /* skip space after ')' too */
+ "%c %d %d %d %d %d %lu %lu %lu %lu %lu "
+ "%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
+ "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
+ &buf->state, &buf->ppid, &buf->pgrp, &buf->session,
+ &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
+ &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
+ &buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
+ &buf->priority, &buf->nice, &buf->timeout,
+ &buf->it_real_value, &buf->start_time, &buf->vsize,
+ &buf->rss, &buf->rss_rlim, &buf->start_code,
+ &buf->end_code, &buf->start_stack, &buf->kstk_esp,
+ &buf->kstk_eip, &buf->signal, &buf->blocked,
+ &buf->sigignore, &buf->sigcatch, &buf->wchan);
+
+ if (buf->tty == 0)
+ /* the old notty val, update elsewhere bef. moving to 0 */
+ buf->tty = -1;
+
+ if (server->os_version_code < LINUX_VERSION(1,3,39)) {
+ /* map old meanings to new */
+ buf->priority = 2*15 - buf->priority;
+ buf->nice = 15 - buf->nice;
+ }
+ if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
+ /* when tty wasn't full devno */
+ buf->tty = 4*0x100 + buf->tty;
- fclose (f);
+ fclose (f);
- sprintf (input, "/proc/%d/statm", pid);
+ sprintf (input, "/proc/%d/statm", pid);
- f = fopen (input, "r");
- if (!f) return;
+ f = fopen (input, "r");
+ if (!f) return;
- nread = fread (input, 1, BUFSIZ, f);
+ nread = fread (input, 1, BUFSIZ, f);
- if (nread < 0) {
- fclose (f);
- return;
- }
+ if (nread < 0) {
+ fclose (f);
+ return;
+ }
- input [nread] = 0;
+ input [nread] = 0;
- sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
- &buf->size, &buf->resident, &buf->share,
- &buf->trs, &buf->lrs, &buf->drs, &buf->dt);
+ sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
+ &buf->size, &buf->resident, &buf->share,
+ &buf->trs, &buf->lrs, &buf->drs, &buf->dt);
- fclose (f);
+ fclose (f);
- buf->flags [0] = _glibtop_sysdeps_procdata_0;
- buf->flags [1] = _glibtop_sysdeps_procdata_1;
+ buf->flags [0] = _glibtop_sysdeps_procdata_0;
+ buf->flags [1] = _glibtop_sysdeps_procdata_1;
}
diff --git a/sysdeps/stub_suid/prockernel.c b/sysdeps/stub_suid/prockernel.c
index 97ba58cb..135dbad0 100644
--- a/sysdeps/stub_suid/prockernel.c
+++ b/sysdeps/stub_suid/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = 0;
int
glibtop_init_proc_kernel_p (glibtop *server)
{
- server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
+ server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/proclist.c b/sysdeps/stub_suid/proclist.c
index e1cf2472..cb025248 100644
--- a/sysdeps/stub_suid/proclist.c
+++ b/sysdeps/stub_suid/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,18 +36,18 @@ static const unsigned long _glibtop_sysdeps_proclist = 0;
int
glibtop_init_proclist_p (glibtop *server)
{
- server->sysdeps.proclist = _glibtop_sysdeps_proclist;
+ server->sysdeps.proclist = _glibtop_sysdeps_proclist;
- return 0;
+ return 0;
}
unsigned *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROCLIST, 0);
- memset (buf, 0, sizeof (glibtop_proclist));
+ memset (buf, 0, sizeof (glibtop_proclist));
- return NULL;
+ return NULL;
}
diff --git a/sysdeps/stub_suid/procmap.c b/sysdeps/stub_suid/procmap.c
index 167a4038..34aafda3 100644
--- a/sysdeps/stub_suid/procmap.c
+++ b/sysdeps/stub_suid/procmap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -33,9 +35,9 @@ static const unsigned long _glibtop_sysdeps_proc_map = 0;
int
glibtop_init_proc_map_p (glibtop *server)
{
- server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
+ server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -43,6 +45,6 @@ glibtop_init_proc_map_p (glibtop *server)
glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf, pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_proc_map));
- return NULL;
+ memset (buf, 0, sizeof (glibtop_proc_map));
+ return NULL;
}
diff --git a/sysdeps/stub_suid/procmem.c b/sysdeps/stub_suid/procmem.c
index 1798b706..ad99456e 100644
--- a/sysdeps/stub_suid/procmem.c
+++ b/sysdeps/stub_suid/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_mem = 0;
int
glibtop_init_proc_mem_p (glibtop *server)
{
- server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
+ server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_MEM, 0);
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/procsegment.c b/sysdeps/stub_suid/procsegment.c
index 4af7926a..7ef6cf94 100644
--- a/sysdeps/stub_suid/procsegment.c
+++ b/sysdeps/stub_suid/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_segment = 0;
int
glibtop_init_proc_segment_p (glibtop *server)
{
- server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
+ server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/procsignal.c b/sysdeps/stub_suid/procsignal.c
index 41bdb3e9..4cf8722a 100644
--- a/sysdeps/stub_suid/procsignal.c
+++ b/sysdeps/stub_suid/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_signal = 0;
int
glibtop_init_proc_signal_p (glibtop *server)
{
- server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
+ server->sysdeps.proc_signal = _glibtop_sysdeps_proc_signal;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0);
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/procstate.c b/sysdeps/stub_suid/procstate.c
index c6099b05..6fb412f1 100644
--- a/sysdeps/stub_suid/procstate.c
+++ b/sysdeps/stub_suid/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_state = 0;
int
glibtop_init_proc_state_p (glibtop *server)
{
- server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
+ server->sysdeps.proc_state = _glibtop_sysdeps_proc_state;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/proctime.c b/sysdeps/stub_suid/proctime.c
index 26a544a2..39151d21 100644
--- a/sysdeps/stub_suid/proctime.c
+++ b/sysdeps/stub_suid/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_time = 0;
int
glibtop_init_proc_time_p (glibtop *server)
{
- server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
+ server->sysdeps.proc_time = _glibtop_sysdeps_proc_time;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_TIME, 0);
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/procuid.c b/sysdeps/stub_suid/procuid.c
index e13f77cb..38f36afc 100644
--- a/sysdeps/stub_suid/procuid.c
+++ b/sysdeps/stub_suid/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_proc_uid = 0;
int
glibtop_init_proc_uid_p (glibtop *server)
{
- server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
+ server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid;
- return 0;
+ return 0;
}
/* Provides detailed information about a process. */
@@ -45,9 +47,9 @@ int
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_PROC_UID, 0);
- memset (buf, 0, sizeof (glibtop_proc_uid));
+ memset (buf, 0, sizeof (glibtop_proc_uid));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/sem_limits.c b/sysdeps/stub_suid/sem_limits.c
index d4ca6ab9..d574052b 100644
--- a/sysdeps/stub_suid/sem_limits.c
+++ b/sysdeps/stub_suid/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_sem_limits = 0;
int
glibtop_init_sem_limits_p (glibtop *server)
{
- server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
+ server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv sem limits. */
@@ -44,9 +46,9 @@ glibtop_init_sem_limits_p (glibtop *server)
int
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/shm_limits.c b/sysdeps/stub_suid/shm_limits.c
index cfa05dde..7246a592 100644
--- a/sysdeps/stub_suid/shm_limits.c
+++ b/sysdeps/stub_suid/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_shm_limits = 0;
int
glibtop_init_shm_limits_p (glibtop *server)
{
- server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
+ server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
- return 0;
+ return 0;
}
/* Provides information about sysv ipc limits. */
@@ -44,9 +46,9 @@ glibtop_init_shm_limits_p (glibtop *server)
int
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/siglist.c b/sysdeps/stub_suid/siglist.c
index 94abfdc6..329b7ccc 100644
--- a/sysdeps/stub_suid/siglist.c
+++ b/sysdeps/stub_suid/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/stub_suid/swap.c b/sysdeps/stub_suid/swap.c
index b7257572..e5fe5d0d 100644
--- a/sysdeps/stub_suid/swap.c
+++ b/sysdeps/stub_suid/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_swap = 0;
int
glibtop_init_swap_p (glibtop *server)
{
- server->sysdeps.swap = _glibtop_sysdeps_swap;
+ server->sysdeps.swap = _glibtop_sysdeps_swap;
- return 0;
+ return 0;
}
/* Provides information about swap usage. */
@@ -44,9 +46,9 @@ glibtop_init_swap_p (glibtop *server)
int
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_SWAP, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_SWAP, 0);
- memset (buf, 0, sizeof (glibtop_swap));
+ memset (buf, 0, sizeof (glibtop_swap));
- return 0;
+ return 0;
}
diff --git a/sysdeps/stub_suid/uptime.c b/sysdeps/stub_suid/uptime.c
index dec522ee..b627ccdd 100644
--- a/sysdeps/stub_suid/uptime.c
+++ b/sysdeps/stub_suid/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,9 +36,9 @@ static const unsigned long _glibtop_sysdeps_uptime = 0;
int
glibtop_init_uptime_p (glibtop *server)
{
- server->sysdeps.uptime = _glibtop_sysdeps_uptime;
+ server->sysdeps.uptime = _glibtop_sysdeps_uptime;
- return 0;
+ return 0;
}
/* Provides uptime and idle time. */
@@ -44,9 +46,9 @@ glibtop_init_uptime_p (glibtop *server)
int
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0);
+ glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0);
- memset (buf, 0, sizeof (glibtop_uptime));
+ memset (buf, 0, sizeof (glibtop_uptime));
- return 0;
+ return 0;
}
diff --git a/sysdeps/sun4/close.c b/sysdeps/sun4/close.c
index a8733f0f..95bffec1 100644
--- a/sysdeps/sun4/close.c
+++ b/sysdeps/sun4/close.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c
index 8621f0fd..fbf599cb 100644
--- a/sysdeps/sun4/cpu.c
+++ b/sysdeps/sun4/cpu.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,72 +38,72 @@ static const unsigned long _glibtop_sysdeps_cpu =
int
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
{
- long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES];
- int i;
+ long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES];
+ int i;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
- memset (buf, 0, sizeof (glibtop_cpu));
+ memset (buf, 0, sizeof (glibtop_cpu));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- /* get the cp_time array */
+ /* get the cp_time array */
- (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value,
- (int *) cp_time, sizeof (cp_time),
- _glibtop_nlist [X_CP_TIME].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value,
+ (int *) cp_time, sizeof (cp_time),
+ _glibtop_nlist [X_CP_TIME].n_name);
#ifdef MULTIPROCESSOR
- /* get the mp_time array as well */
+ /* get the mp_time array as well */
- if (server->machine.ncpu > 1) {
- (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value,
- (int *) mp_time, sizeof (mp_time),
- _glibtop_nlist [X_MP_TIME].n_name);
- }
+ if (server->machine.ncpu > 1) {
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value,
+ (int *) mp_time, sizeof (mp_time),
+ _glibtop_nlist [X_MP_TIME].n_name);
+ }
#endif
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
#ifdef MULTIPROCESSOR
- /* If we have multiple processors, we add the times for each of them
- * and set frequency to 100 times the number of the processors. */
-
- /* [FIXME]: I had no machine with more than one processor to test
- * this code !!! */
-
- if (server->machine.ncpu > 1) {
- for (i = 0; i < server->machine.ncpu; i++) {
- buf->user += mp_time [i][CP_USER];
- buf->nice += mp_time [i][CP_NICE];
- buf->sys += mp_time [i][CP_SYS];
- buf->idle += mp_time [i][CP_IDLE];
- buf->frequency += 100;
- }
- } else {
- buf->user = cp_time [CP_USER];
- buf->nice = cp_time [CP_NICE];
- buf->sys = cp_time [CP_SYS];
- buf->idle = cp_time [CP_IDLE];
- buf->frequency = 100;
+ /* If we have multiple processors, we add the times for each of them
+ * and set frequency to 100 times the number of the processors. */
+
+ /* [FIXME]: I had no machine with more than one processor to test
+ * this code !!! */
+
+ if (server->machine.ncpu > 1) {
+ for (i = 0; i < server->machine.ncpu; i++) {
+ buf->user += mp_time [i][CP_USER];
+ buf->nice += mp_time [i][CP_NICE];
+ buf->sys += mp_time [i][CP_SYS];
+ buf->idle += mp_time [i][CP_IDLE];
+ buf->frequency += 100;
}
-#else
+ } else {
buf->user = cp_time [CP_USER];
buf->nice = cp_time [CP_NICE];
buf->sys = cp_time [CP_SYS];
buf->idle = cp_time [CP_IDLE];
buf->frequency = 100;
+ }
+#else
+ buf->user = cp_time [CP_USER];
+ buf->nice = cp_time [CP_NICE];
+ buf->sys = cp_time [CP_SYS];
+ buf->idle = cp_time [CP_IDLE];
+ buf->frequency = 100;
#endif
- /* Calculate total time. */
+ /* Calculate total time. */
- buf->total = buf->user + buf->nice + buf->sys + buf->idle;
+ buf->total = buf->user + buf->nice + buf->sys + buf->idle;
- /* Now we can set the flags. */
+ /* Now we can set the flags. */
- buf->flags = _glibtop_sysdeps_cpu;
+ buf->flags = _glibtop_sysdeps_cpu;
}
diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h
index 8ab56840..8a1f645b 100644
--- a/sysdeps/sun4/glibtop_machine.h
+++ b/sysdeps/sun4/glibtop_machine.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -83,19 +85,19 @@ typedef struct _glibtop_machine glibtop_machine;
struct _glibtop_machine
{
- uid_t uid, euid; /* Real and effective user id */
- gid_t gid, egid; /* Real and effective group id */
- int nlist_count; /* Number of symbols in the nlist */
- int ncpu; /* Number of CPUs we have */
- int nproc; /* Number of entries in the process array */
- size_t ptable_size; /* Size of process array. */
- unsigned long ptable_offset; /* Offset of process array in kernel. */
- struct proc *proc_table; /* Process array. */
- unsigned long pages, epages;
- struct page *physpage;
- int bytesize, count;
- int pageshift; /* log base 2 of the pagesize */
- kvm_t *kd;
+ uid_t uid, euid; /* Real and effective user id */
+ gid_t gid, egid; /* Real and effective group id */
+ int nlist_count; /* Number of symbols in the nlist */
+ int ncpu; /* Number of CPUs we have */
+ int nproc; /* Number of entries in the process array */
+ size_t ptable_size; /* Size of process array. */
+ unsigned long ptable_offset; /* Offset of process array in kernel. */
+ struct proc *proc_table; /* Process array. */
+ unsigned long pages, epages;
+ struct page *physpage;
+ int bytesize, count;
+ int pageshift; /* log base 2 of the pagesize */
+ kvm_t *kd;
};
/* Those functions are used internally in libgtop */
diff --git a/sysdeps/sun4/glibtop_server.h b/sysdeps/sun4/glibtop_server.h
index e631e43e..e98bf898 100644
--- a/sysdeps/sun4/glibtop_server.h
+++ b/sysdeps/sun4/glibtop_server.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/sun4/glibtop_suid.h b/sysdeps/sun4/glibtop_suid.h
index 18d3b1d3..a11e5ea6 100644
--- a/sysdeps/sun4/glibtop_suid.h
+++ b/sysdeps/sun4/glibtop_suid.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -27,12 +29,12 @@
BEGIN_LIBGTOP_DECLS
static inline void glibtop_suid_enter (glibtop *server) {
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
};
static inline void glibtop_suid_leave (glibtop *server) {
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
};
void
diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c
index 3ae42100..66a88d3a 100644
--- a/sysdeps/sun4/loadavg.c
+++ b/sysdeps/sun4/loadavg.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -34,34 +36,34 @@ static const unsigned long _glibtop_sysdeps_loadavg =
int
glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
{
- load_avg avenrun [3];
- int i;
+ load_avg avenrun [3];
+ int i;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_LOADAVG), 0);
- memset (buf, 0, sizeof (glibtop_loadavg));
+ memset (buf, 0, sizeof (glibtop_loadavg));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
- /* get the load average array */
+ /* get the load average array */
- (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value,
- (int *) avenrun, sizeof (avenrun),
- _glibtop_nlist [X_AVENRUN].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value,
+ (int *) avenrun, sizeof (avenrun),
+ _glibtop_nlist [X_AVENRUN].n_name);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
- for (i = 0; i < 3; i++) {
- /* Calculate loadavg values from avenrun. */
- buf->loadavg [i] = loaddouble (avenrun [i]);
- }
+ for (i = 0; i < 3; i++) {
+ /* Calculate loadavg values from avenrun. */
+ buf->loadavg [i] = loaddouble (avenrun [i]);
+ }
- /* Now we can set the flags. */
+ /* Now we can set the flags. */
- buf->flags = _glibtop_sysdeps_loadavg;
+ buf->flags = _glibtop_sysdeps_loadavg;
}
diff --git a/sysdeps/sun4/loadavg.h b/sysdeps/sun4/loadavg.h
index f49541e7..f2c20d81 100644
--- a/sysdeps/sun4/loadavg.h
+++ b/sysdeps/sun4/loadavg.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/*
* Top - a top users display for Berkeley Unix
*
@@ -39,7 +41,7 @@
#ifdef FIXED_PCTCPU
- typedef long pctcpu;
+typedef long pctcpu;
# define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
#else
typedef double pctcpu;
@@ -47,11 +49,11 @@ typedef double pctcpu;
#endif
#ifdef FIXED_LOADAVG
- typedef long load_avg;
+typedef long load_avg;
# define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
# define intload(i) ((int)((i) * FIXED_LOADAVG))
#else
- typedef double load_avg;
+typedef double load_avg;
# define loaddouble(la) (la)
# define intload(i) ((double)(i))
#endif
diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c
index 9362eaa2..6bc327e2 100644
--- a/sysdeps/sun4/mem.c
+++ b/sysdeps/sun4/mem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -39,53 +41,53 @@ static const unsigned long _glibtop_sysdeps_mem =
int
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MEM), 0);
- memset (buf, 0, sizeof (glibtop_mem));
+ memset (buf, 0, sizeof (glibtop_mem));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- glibtop_suid_enter (server);
+ glibtop_suid_enter (server);
- /* get the array of physpage descriptors */
+ /* get the array of physpage descriptors */
- (void) _glibtop_getkval (server, server->machine.pages,
- (int *) server->machine.physpage,
- server->machine.bytesize,
- "array _page");
+ (void) _glibtop_getkval (server, server->machine.pages,
+ (int *) server->machine.physpage,
+ server->machine.bytesize,
+ "array _page");
- glibtop_suid_leave (server);
+ glibtop_suid_leave (server);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
- { /* sum memory statistics */
- register struct page *pp;
- register int cnt;
- register int inuse;
- register int free;
- register int locked;
+ { /* sum memory statistics */
+ register struct page *pp;
+ register int cnt;
+ register int inuse;
+ register int free;
+ register int locked;
- /* bop thru the array counting page types */
-
- pp = server->machine.physpage;
- inuse = free = locked = 0;
- for (cnt = server->machine.count; --cnt >= 0; pp++) {
- if (pp->p_free)
- free++;
- else if (pp->p_lock || pp->p_keepcnt > 0)
- locked++;
- else
- inuse++;
- }
-
- /* convert memory stats to Kbytes */
+ /* bop thru the array counting page types */
+
+ pp = server->machine.physpage;
+ inuse = free = locked = 0;
+ for (cnt = server->machine.count; --cnt >= 0; pp++) {
+ if (pp->p_free)
+ free++;
+ else if (pp->p_lock || pp->p_keepcnt > 0)
+ locked++;
+ else
+ inuse++;
+ }
+
+ /* convert memory stats to Kbytes */
- buf->total = pagetok (inuse + free);
- buf->used = pagetok (inuse);
- buf->free = pagetok (free);
- buf->locked = pagetok (locked);
+ buf->total = pagetok (inuse + free);
+ buf->used = pagetok (inuse);
+ buf->free = pagetok (free);
+ buf->locked = pagetok (locked);
- buf->flags = _glibtop_sysdeps_mem;
- }
+ buf->flags = _glibtop_sysdeps_mem;
+ }
}
diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c
index 6e11f917..7b997f5c 100644
--- a/sysdeps/sun4/msg_limits.c
+++ b/sysdeps/sun4/msg_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -43,33 +45,33 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
int
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{
- struct msginfo msginfo;
+ struct msginfo msginfo;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_msg_limits));
+ memset (buf, 0, sizeof (glibtop_msg_limits));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
- /* get the load average array */
+ /* get the load average array */
- (void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value,
- (int *) &msginfo, sizeof (msginfo),
- _glibtop_nlist [X_MSGINFO].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value,
+ (int *) &msginfo, sizeof (msginfo),
+ _glibtop_nlist [X_MSGINFO].n_name);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
- buf->msgmap = msginfo.msgmap;
- buf->msgmax = msginfo.msgmax;
- buf->msgmnb = msginfo.msgmnb;
- buf->msgmni = msginfo.msgmni;
- buf->msgssz = msginfo.msgssz;
- buf->msgtql = msginfo.msgtql;
-
- buf->flags = _glibtop_sysdeps_msg_limits;
+ buf->msgmap = msginfo.msgmap;
+ buf->msgmax = msginfo.msgmax;
+ buf->msgmnb = msginfo.msgmnb;
+ buf->msgmni = msginfo.msgmni;
+ buf->msgssz = msginfo.msgssz;
+ buf->msgtql = msginfo.msgtql;
+
+ buf->flags = _glibtop_sysdeps_msg_limits;
}
diff --git a/sysdeps/sun4/nosuid.c b/sysdeps/sun4/nosuid.c
index cd52852c..0ee13dc4 100644
--- a/sysdeps/sun4/nosuid.c
+++ b/sysdeps/sun4/nosuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c
index 30fd3e1e..e5f4d315 100644
--- a/sysdeps/sun4/open.c
+++ b/sysdeps/sun4/open.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -68,144 +70,144 @@ void
glibtop_init_p (glibtop *server, const unsigned long features,
const unsigned flags)
{
- if (server == NULL)
- glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
- glibtop_open_p (server, "glibtop", features, flags);
+ glibtop_open_p (server, "glibtop", features, flags);
}
void
glibtop_open_p (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
- register int pagesize;
+ register int pagesize;
- /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
- server->name = program_name;
+ server->name = program_name;
- server->machine.uid = getuid ();
- server->machine.euid = geteuid ();
- server->machine.gid = getgid ();
- server->machine.egid = getegid ();
+ server->machine.uid = getuid ();
+ server->machine.euid = geteuid ();
+ server->machine.gid = getgid ();
+ server->machine.egid = getegid ();
- /* initialize the kernel interface */
+ /* initialize the kernel interface */
- server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop");
+ server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop");
- if (server->machine.kd == NULL)
- glibtop_error_io_r (server, "kvm_open");
+ if (server->machine.kd == NULL)
+ glibtop_error_io_r (server, "kvm_open");
- /* get the list of symbols we want to access in the kernel */
+ /* get the list of symbols we want to access in the kernel */
- server->machine.nlist_count = kvm_nlist
- (server->machine.kd, _glibtop_nlist);
+ server->machine.nlist_count = kvm_nlist
+ (server->machine.kd, _glibtop_nlist);
- if (server->machine.nlist_count < 0)
- glibtop_error_io_r (server, "nlist");
+ if (server->machine.nlist_count < 0)
+ glibtop_error_io_r (server, "nlist");
#ifdef MULTIPROCESSOR
- /* were ncpu and xp_time not found in the nlist? */
+ /* were ncpu and xp_time not found in the nlist? */
- if ((server->machine.nlist_count > 0) &&
- (_glibtop_nlist[X_NCPU].n_type == 0) &&
- (_glibtop_nlist[X_MP_TIME].n_type == 0)) {
- /* we were compiled on an MP system but we are not running
- * on one, so we will pretend this didn't happen and set
- * ncpu = 1 */
- server->machine.nlist_count -= 2;
- server->machine.ncpu = 1;
- }
+ if ((server->machine.nlist_count > 0) &&
+ (_glibtop_nlist[X_NCPU].n_type == 0) &&
+ (_glibtop_nlist[X_MP_TIME].n_type == 0)) {
+ /* we were compiled on an MP system but we are not running
+ * on one, so we will pretend this didn't happen and set
+ * ncpu = 1 */
+ server->machine.nlist_count -= 2;
+ server->machine.ncpu = 1;
+ }
#endif
#ifdef solbourne
- {
- unsigned int status, type;
+ {
+ unsigned int status, type;
- /* Get the number of CPUs on this system. */
- syscall(SYS_getcpustatus, &status,
- &server->machine.ncpu, &type);
- }
+ /* Get the number of CPUs on this system. */
+ syscall(SYS_getcpustatus, &status,
+ &server->machine.ncpu, &type);
+ }
#endif
- /* Make sure all of the symbols were found. */
+ /* Make sure all of the symbols were found. */
- if ((server->machine.nlist_count > 0) &&
- (_glibtop_check_nlist (server, _glibtop_nlist) > 0))
- _exit (1);
+ if ((server->machine.nlist_count > 0) &&
+ (_glibtop_check_nlist (server, _glibtop_nlist) > 0))
+ _exit (1);
- /* Get process array stuff. */
+ /* Get process array stuff. */
- (void) _glibtop_getkval (server, _glibtop_nlist[X_NPROC].n_value,
- (int *)(&server->machine.nproc),
- sizeof (server->machine.nproc),
- _glibtop_nlist[X_NPROC].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_NPROC].n_value,
+ (int *)(&server->machine.nproc),
+ sizeof (server->machine.nproc),
+ _glibtop_nlist[X_NPROC].n_name);
- (void) _glibtop_getkval (server, _glibtop_nlist[X_PROC].n_value,
- (int *)(&server->machine.ptable_offset),
- sizeof (server->machine.ptable_offset),
- _glibtop_nlist[X_PROC].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_PROC].n_value,
+ (int *)(&server->machine.ptable_offset),
+ sizeof (server->machine.ptable_offset),
+ _glibtop_nlist[X_PROC].n_name);
- server->machine.ptable_size = (unsigned long) server->machine.nproc *
- (unsigned long) sizeof (struct proc);
+ server->machine.ptable_size = (unsigned long) server->machine.nproc *
+ (unsigned long) sizeof (struct proc);
- server->machine.proc_table = glibtop_malloc_r
- (server, server->machine.ptable_size);
+ server->machine.proc_table = glibtop_malloc_r
+ (server, server->machine.ptable_size);
- /* This are for the memory statistics. */
+ /* This are for the memory statistics. */
- (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value,
- (int *)(&server->machine.pages),
- sizeof (server->machine.pages),
- _glibtop_nlist[X_PAGES].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value,
+ (int *)(&server->machine.pages),
+ sizeof (server->machine.pages),
+ _glibtop_nlist[X_PAGES].n_name);
- (void) _glibtop_getkval (server, _glibtop_nlist[X_EPAGES].n_value,
- (int *)(&server->machine.epages),
- sizeof (server->machine.epages),
- _glibtop_nlist[X_EPAGES].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_EPAGES].n_value,
+ (int *)(&server->machine.epages),
+ sizeof (server->machine.epages),
+ _glibtop_nlist[X_EPAGES].n_name);
- server->machine.bytesize = server->machine.epages -
- server->machine.pages;
- server->machine.count = server->machine.bytesize /
- sizeof (struct page);
+ server->machine.bytesize = server->machine.epages -
+ server->machine.pages;
+ server->machine.count = server->machine.bytesize /
+ sizeof (struct page);
- server->machine.physpage = (struct page *)
- glibtop_malloc_r (server, server->machine.bytesize);
+ server->machine.physpage = (struct page *)
+ glibtop_malloc_r (server, server->machine.bytesize);
- /* get the page size with "getpagesize" and
- * calculate pageshift from it */
+ /* get the page size with "getpagesize" and
+ * calculate pageshift from it */
- pagesize = getpagesize();
+ pagesize = getpagesize();
- server->machine.pageshift = 0;
+ server->machine.pageshift = 0;
- while (pagesize > 1) {
- server->machine.pageshift++;
- pagesize >>= 1;
- }
+ while (pagesize > 1) {
+ server->machine.pageshift++;
+ pagesize >>= 1;
+ }
- /* we only need the amount of log(2)1024 for our conversion */
+ /* we only need the amount of log(2)1024 for our conversion */
- server->machine.pageshift -= LOG1024;
+ server->machine.pageshift -= LOG1024;
- /* Drop priviledges. */
+ /* Drop priviledges. */
- if (setreuid (server->machine.euid, server->machine.uid))
- _exit (1);
+ if (setreuid (server->machine.euid, server->machine.uid))
+ _exit (1);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SUID ROOT PART !!! */
+ /* !!! END OF SUID ROOT PART !!! */
- /* Our effective uid is now those of the user invoking the server,
- * so we do no longer have any priviledges. */
-
- /* NOTE: On SunOS, we do not need to be suid root, we just need to
- * be sgid kmem.
- *
- * The server will only use setegid() to get back it's priviledges,
- * so it will fail if it is suid root and not sgid kmem. */
+ /* Our effective uid is now those of the user invoking the server,
+ * so we do no longer have any priviledges. */
+
+ /* NOTE: On SunOS, we do not need to be suid root, we just need to
+ * be sgid kmem.
+ *
+ * The server will only use setegid() to get back it's priviledges,
+ * so it will fail if it is suid root and not sgid kmem. */
}
/* Used internally. Returns number of symbols that cannot be found in
@@ -214,35 +216,35 @@ glibtop_open_p (glibtop *server, const char *program_name,
int
_glibtop_check_nlist (void *server, register struct nlist *nlst)
{
- register int not_found;
+ register int not_found;
- /* check to see if we got ALL the symbols we requested */
- /* this will write one line to stderr for every symbol not found */
+ /* check to see if we got ALL the symbols we requested */
+ /* this will write one line to stderr for every symbol not found */
- not_found = 0;
+ not_found = 0;
- while (nlst->n_name != NULL) {
+ while (nlst->n_name != NULL) {
#ifdef i386
- if (nlst->n_value == 0) {
- glibtop_error_r (server,
- "kernel: no symbol named `%s'",
- nlst->n_name);
- not_found++;
- }
+ if (nlst->n_value == 0) {
+ glibtop_error_r (server,
+ "kernel: no symbol named `%s'",
+ nlst->n_name);
+ not_found++;
+ }
#else
- if (nlst->n_type == 0) {
- glibtop_error_r (server,
- "kernel: no symbol named `%s'",
- nlst->n_name);
- not_found++;
- }
+ if (nlst->n_type == 0) {
+ glibtop_error_r (server,
+ "kernel: no symbol named `%s'",
+ nlst->n_name);
+ not_found++;
+ }
#endif
- nlst++;
- }
+ nlst++;
+ }
- return not_found;
+ return not_found;
}
/* Used internally. Fetches value from kernel. */
@@ -251,17 +253,17 @@ int
_glibtop_getkval (void *void_server, unsigned long offset, int *ptr,
int size, char *refstr)
{
- glibtop *server = (glibtop *) void_server;
+ glibtop *server = (glibtop *) void_server;
- if (kvm_read (server->machine.kd, offset, ptr, size) != size)
- {
- if (*refstr == '!') return 0;
+ if (kvm_read (server->machine.kd, offset, ptr, size) != size)
+ {
+ if (*refstr == '!') return 0;
- glibtop_error_r (server, "kvm_read(%s): %s",
- refstr, strerror (errno));
- }
+ glibtop_error_r (server, "kvm_read(%s): %s",
+ refstr, strerror (errno));
+ }
- return 1;
+ return 1;
}
/* Used internally. Reads process table from kernel. */
@@ -269,23 +271,23 @@ _glibtop_getkval (void *void_server, unsigned long offset, int *ptr,
void
_glibtop_read_proc_table (void *void_server)
{
- glibtop *server = (glibtop *) void_server;
+ glibtop *server = (glibtop *) void_server;
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- (void) _glibtop_getkval (server, server->machine.ptable_offset,
- (int *) server->machine.proc_table,
- (size_t) server->machine.ptable_size,
- _glibtop_nlist[X_PROC].n_name);
+ (void) _glibtop_getkval (server, server->machine.ptable_offset,
+ (int *) server->machine.proc_table,
+ (size_t) server->machine.ptable_size,
+ _glibtop_nlist[X_PROC].n_name);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
}
/* Used internally. Finds pid in process table. */
@@ -293,16 +295,16 @@ _glibtop_read_proc_table (void *void_server)
struct proc *
_glibtop_find_pid (void *void_server, pid_t pid)
{
- register struct proc *pp;
- register int i;
+ register struct proc *pp;
+ register int i;
- glibtop *server = (glibtop *) void_server;
+ glibtop *server = (glibtop *) void_server;
- for (pp = server->machine.proc_table, i = 0;
- i < server->machine.nproc; pp++, i++) {
- if ((pp->p_stat != 0) && (pp->p_pid == pid))
- return pp;
- }
+ for (pp = server->machine.proc_table, i = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if ((pp->p_stat != 0) && (pp->p_pid == pid))
+ return pp;
+ }
- return NULL;
+ return NULL;
}
diff --git a/sysdeps/sun4/ppp.c b/sysdeps/sun4/ppp.c
index 0d682830..4f738ff2 100644
--- a/sysdeps/sun4/ppp.c
+++ b/sysdeps/sun4/ppp.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -32,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_ppp = 0;
int
glibtop_init_ppp_s (glibtop *server)
{
- server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
}
/* Provides PPP/ISDN information. */
@@ -40,5 +42,5 @@ glibtop_init_ppp_s (glibtop *server)
int
glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
{
- memset (buf, 0, sizeof (glibtop_ppp));
+ memset (buf, 0, sizeof (glibtop_ppp));
}
diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c
index 50756730..fdeb4db5 100644
--- a/sysdeps/sun4/procdata.c
+++ b/sysdeps/sun4/procdata.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -29,5 +31,5 @@
void
glibtop_get_procdata_p (glibtop *server, glibtop_procdata *buf, pid_t pid)
{
- memset (buf, 0, sizeof (glibtop_procdata));
+ memset (buf, 0, sizeof (glibtop_procdata));
}
diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c
index 378d8d12..8011469c 100644
--- a/sysdeps/sun4/prockernel.c
+++ b/sysdeps/sun4/prockernel.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,26 +37,26 @@ int
glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
- memset (buf, 0, sizeof (glibtop_proc_kernel));
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->k_flags = pp->p_flag;
- buf->nwchan = (unsigned long) pp->p_wchan;
+ buf->k_flags = pp->p_flag;
+ buf->nwchan = (unsigned long) pp->p_wchan;
- buf->flags = _glibtop_sysdeps_proc_kernel;
+ buf->flags = _glibtop_sysdeps_proc_kernel;
}
diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c
index cca310ec..1239c57a 100644
--- a/sysdeps/sun4/proclist.c
+++ b/sysdeps/sun4/proclist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -42,56 +44,56 @@ unsigned *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
int64_t which, int64_t arg)
{
- register struct proc *pp;
- register int i, nproc = 0;
- unsigned *proc_list = NULL;
- size_t proc_size;
+ register struct proc *pp;
+ register int i, nproc = 0;
+ unsigned *proc_list = NULL;
+ size_t proc_size;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROCLIST), 0);
- memset (buf, 0, sizeof (glibtop_proclist));
+ memset (buf, 0, sizeof (glibtop_proclist));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Count number of processes. */
+ /* Count number of processes. */
- for (pp = server->machine.proc_table, i = 0;
- i < server->machine.nproc; pp++, i++) {
- if (pp->p_stat == 0)
- continue;
- else
- nproc++;
- }
+ for (pp = server->machine.proc_table, i = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if (pp->p_stat == 0)
+ continue;
+ else
+ nproc++;
+ }
- if (nproc == 0) /* Should never happen. */
- return NULL;
+ if (nproc == 0) /* Should never happen. */
+ return NULL;
- /* Allocate space for process list. */
+ /* Allocate space for process list. */
- proc_size = nproc * sizeof (unsigned);
+ proc_size = nproc * sizeof (unsigned);
- proc_list = glibtop_malloc_r (server, proc_size);
+ proc_list = glibtop_malloc_r (server, proc_size);
- /* Write process list. */
+ /* Write process list. */
- for (pp = server->machine.proc_table, i = 0, nproc = 0;
- i < server->machine.nproc; pp++, i++) {
- if (pp->p_stat == 0)
- continue;
- proc_list [nproc++] = pp->p_pid;
- }
+ for (pp = server->machine.proc_table, i = 0, nproc = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if (pp->p_stat == 0)
+ continue;
+ proc_list [nproc++] = pp->p_pid;
+ }
- /* Since everything is ok now, we can set buf->flags, fill in the remaining fields
- and return proc_list. */
+ /* Since everything is ok now, we can set buf->flags, fill in the remaining fields
+ and return proc_list. */
- buf->flags = _glibtop_sysdeps_proclist;
+ buf->flags = _glibtop_sysdeps_proclist;
- buf->size = sizeof (unsigned);
- buf->number = nproc;
+ buf->size = sizeof (unsigned);
+ buf->number = nproc;
- buf->total = nproc * sizeof (unsigned);
+ buf->total = nproc * sizeof (unsigned);
- return proc_list;
+ return proc_list;
}
diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c
index 86e22123..5bbf8852 100644
--- a/sysdeps/sun4/procmem.c
+++ b/sysdeps/sun4/procmem.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,28 +38,28 @@ int
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_MEM), 0);
- memset (buf, 0, sizeof (glibtop_proc_mem));
+ memset (buf, 0, sizeof (glibtop_proc_mem));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->size = (pp)->p_tsize + (pp)->p_dsize + (pp)->p_ssize;
+ buf->size = (pp)->p_tsize + (pp)->p_dsize + (pp)->p_ssize;
- buf->rss = pp->p_rssize;
- buf->rss_rlim = pp->p_maxrss;
+ buf->rss = pp->p_rssize;
+ buf->rss_rlim = pp->p_maxrss;
- buf->flags = _glibtop_sysdeps_proc_mem;
+ buf->flags = _glibtop_sysdeps_proc_mem;
}
diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c
index b0a4cc32..7c09ee6b 100644
--- a/sysdeps/sun4/procsegment.c
+++ b/sysdeps/sun4/procsegment.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,26 +38,26 @@ int
glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
- memset (buf, 0, sizeof (glibtop_proc_segment));
+ memset (buf, 0, sizeof (glibtop_proc_segment));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->text_rss = pp->p_tsize;
- buf->data_rss = pp->p_dsize;
+ buf->text_rss = pp->p_tsize;
+ buf->data_rss = pp->p_dsize;
- buf->flags = _glibtop_sysdeps_proc_segment;
+ buf->flags = _glibtop_sysdeps_proc_segment;
}
diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c
index c09166cb..216c420d 100644
--- a/sysdeps/sun4/procsignal.c
+++ b/sysdeps/sun4/procsignal.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -36,28 +38,28 @@ int
glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
- memset (buf, 0, sizeof (glibtop_proc_signal));
+ memset (buf, 0, sizeof (glibtop_proc_signal));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->signal [0] = pp->p_sig;
- buf->blocked [0] = pp->p_sigmask;
- buf->sigignore [0] = pp->p_sigignore;
- buf->sigcatch [0] = pp->p_sigcatch;
+ buf->signal [0] = pp->p_sig;
+ buf->blocked [0] = pp->p_sigmask;
+ buf->sigignore [0] = pp->p_sigignore;
+ buf->sigcatch [0] = pp->p_sigcatch;
- buf->flags = _glibtop_sysdeps_proc_signal;
+ buf->flags = _glibtop_sysdeps_proc_signal;
}
diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c
index e6635bd1..4fffd8bd 100644
--- a/sysdeps/sun4/procstate.c
+++ b/sysdeps/sun4/procstate.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,26 +37,26 @@ int
glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
- memset (buf, 0, sizeof (glibtop_proc_state));
+ memset (buf, 0, sizeof (glibtop_proc_state));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->state = pp->p_stat;
- buf->uid = pp->p_uid;
+ buf->state = pp->p_stat;
+ buf->uid = pp->p_uid;
- buf->flags = _glibtop_sysdeps_proc_state;
+ buf->flags = _glibtop_sysdeps_proc_state;
}
diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c
index 9f44a878..c18376c2 100644
--- a/sysdeps/sun4/proctime.c
+++ b/sysdeps/sun4/proctime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,26 +37,26 @@ int
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
- memset (buf, 0, sizeof (glibtop_proc_time));
+ memset (buf, 0, sizeof (glibtop_proc_time));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->start_time = pp->p_time;
- buf->utime = pp->p_cpticks;
+ buf->start_time = pp->p_time;
+ buf->utime = pp->p_cpticks;
- buf->flags = _glibtop_sysdeps_proc_time;
+ buf->flags = _glibtop_sysdeps_proc_time;
}
diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c
index f8a8dec8..c1b52ebc 100644
--- a/sysdeps/sun4/procuid.c
+++ b/sysdeps/sun4/procuid.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -39,33 +41,33 @@ int
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
- struct proc *pp;
+ struct proc *pp;
- 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));
- /* Read process table from kernel. */
+ /* Read process table from kernel. */
- _glibtop_read_proc_table (server);
+ _glibtop_read_proc_table (server);
- /* Find the pid in the process table. */
+ /* Find the pid in the process table. */
- pp = _glibtop_find_pid (server, pid);
+ pp = _glibtop_find_pid (server, pid);
- if (pp == NULL) return;
+ if (pp == NULL) return;
- /* Fill in data fields. */
+ /* Fill in data fields. */
- buf->uid = pp->p_uid;
- buf->euid = pp->p_suid;
- buf->egid = pp->p_sgid;
- buf->pid = pp->p_pid;
- buf->ppid = pp->p_ppid;
- buf->pgrp = pp->p_pgrp;
- buf->tpgid = pp->p_pgrp;
- buf->priority = pp->p_pri;
- buf->nice = pp->p_nice;
+ buf->uid = pp->p_uid;
+ buf->euid = pp->p_suid;
+ buf->egid = pp->p_sgid;
+ buf->pid = pp->p_pid;
+ buf->ppid = pp->p_ppid;
+ buf->pgrp = pp->p_pgrp;
+ buf->tpgid = pp->p_pgrp;
+ buf->priority = pp->p_pri;
+ buf->nice = pp->p_nice;
- buf->flags = _glibtop_sysdeps_proc_uid;
+ buf->flags = _glibtop_sysdeps_proc_uid;
}
diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c
index 359c2aa1..df29ba5f 100644
--- a/sysdeps/sun4/sem_limits.c
+++ b/sysdeps/sun4/sem_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -45,37 +47,37 @@ static unsigned long _glibtop_sysdeps_sem_limits =
int
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{
- struct seminfo seminfo;
+ struct seminfo seminfo;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_sem_limits));
+ memset (buf, 0, sizeof (glibtop_sem_limits));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
- /* get the load average array */
+ /* get the load average array */
- (void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value,
- (int *) &seminfo, sizeof (seminfo),
- _glibtop_nlist [X_SEMINFO].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value,
+ (int *) &seminfo, sizeof (seminfo),
+ _glibtop_nlist [X_SEMINFO].n_name);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
- buf->semmap = seminfo.semmap;
- buf->semmni = seminfo.semmni;
- buf->semmns = seminfo.semmns;
- buf->semmnu = seminfo.semmnu;
- buf->semmsl = seminfo.semmsl;
- buf->semopm = seminfo.semopm;
- buf->semume = seminfo.semume;
- buf->semusz = seminfo.semusz;
- buf->semvmx = seminfo.semvmx;
- buf->semaem = seminfo.semaem;
-
- buf->flags = _glibtop_sysdeps_sem_limits;
+ buf->semmap = seminfo.semmap;
+ buf->semmni = seminfo.semmni;
+ buf->semmns = seminfo.semmns;
+ buf->semmnu = seminfo.semmnu;
+ buf->semmsl = seminfo.semmsl;
+ buf->semopm = seminfo.semopm;
+ buf->semume = seminfo.semume;
+ buf->semusz = seminfo.semusz;
+ buf->semvmx = seminfo.semvmx;
+ buf->semaem = seminfo.semaem;
+
+ buf->flags = _glibtop_sysdeps_sem_limits;
}
diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c
index 56c40042..842d843e 100644
--- a/sysdeps/sun4/shm_limits.c
+++ b/sysdeps/sun4/shm_limits.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -43,32 +45,32 @@ static unsigned long _glibtop_sysdeps_shm_limits =
int
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{
- struct shminfo shminfo;
+ struct shminfo shminfo;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
- memset (buf, 0, sizeof (glibtop_shm_limits));
+ memset (buf, 0, sizeof (glibtop_shm_limits));
- /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
- setregid (server->machine.gid, server->machine.egid);
+ setregid (server->machine.gid, server->machine.egid);
- /* get the load average array */
+ /* get the load average array */
- (void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value,
- (int *) &shminfo, sizeof (shminfo),
- _glibtop_nlist [X_SHMINFO].n_name);
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value,
+ (int *) &shminfo, sizeof (shminfo),
+ _glibtop_nlist [X_SHMINFO].n_name);
- if (setregid (server->machine.egid, server->machine.gid))
- _exit (1);
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
- /* !!! END OF SGID KMEM PART !!! */
+ /* !!! END OF SGID KMEM PART !!! */
- buf->shmmax = shminfo.shmmax;
- buf->shmmin = shminfo.shmmin;
- buf->shmmni = shminfo.shmmni;
- buf->shmseg = shminfo.shmseg;
- buf->shmall = shminfo.shmall;
+ buf->shmmax = shminfo.shmmax;
+ buf->shmmin = shminfo.shmmin;
+ buf->shmmni = shminfo.shmmni;
+ buf->shmseg = shminfo.shmseg;
+ buf->shmall = shminfo.shmall;
- buf->flags = _glibtop_sysdeps_shm_limits;
+ buf->flags = _glibtop_sysdeps_shm_limits;
}
diff --git a/sysdeps/sun4/siglist.c b/sysdeps/sun4/siglist.c
index c5bd59c0..e41267ae 100644
--- a/sysdeps/sun4/siglist.c
+++ b/sysdeps/sun4/siglist.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c
index d15202d6..ac6bfa39 100644
--- a/sysdeps/sun4/swap.c
+++ b/sysdeps/sun4/swap.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -31,7 +33,7 @@
int
glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
{
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_SWAP), 0);
- memset (buf, 0, sizeof (glibtop_swap));
+ memset (buf, 0, sizeof (glibtop_swap));
}
diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c
index 7148f935..35db26f1 100644
--- a/sysdeps/sun4/uptime.c
+++ b/sysdeps/sun4/uptime.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
/* $Id$ */
/* Copyright (C) 1998-99 Martin Baulig
@@ -35,27 +37,27 @@ static const unsigned long _glibtop_sysdeps_uptime =
int
glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
{
- glibtop_cpu cpu;
+ glibtop_cpu cpu;
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_UPTIME), 0);
- /* Get currect cpu usage. */
+ /* Get currect cpu usage. */
- glibtop_get_cpu_p (server, &cpu);
+ glibtop_get_cpu_p (server, &cpu);
- /* Make sure all required fields are present. */
+ /* Make sure all required fields are present. */
- if (((cpu.flags & (1L << GLIBTOP_CPU_TOTAL)) == 0) ||
- ((cpu.flags & (1L << GLIBTOP_CPU_IDLE)) == 0) ||
- ((cpu.flags & (1L << GLIBTOP_CPU_FREQUENCY)) == 0) ||
- (cpu.frequency == 0))
- return;
+ if (((cpu.flags & (1L << GLIBTOP_CPU_TOTAL)) == 0) ||
+ ((cpu.flags & (1L << GLIBTOP_CPU_IDLE)) == 0) ||
+ ((cpu.flags & (1L << GLIBTOP_CPU_FREQUENCY)) == 0) ||
+ (cpu.frequency == 0))
+ return;
- /* Simply calculate uptime and idle time from
- * cpu usage. */
+ /* Simply calculate uptime and idle time from
+ * cpu usage. */
- buf->uptime = (double) cpu.total / (double) cpu.frequency;
- buf->idletime = (double) cpu.idle / (double) cpu.frequency;
+ buf->uptime = (double) cpu.total / (double) cpu.frequency;
+ buf->idletime = (double) cpu.idle / (double) cpu.frequency;
- buf->flags = _glibtop_sysdeps_uptime;
+ buf->flags = _glibtop_sysdeps_uptime;
}