summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-25 05:07:06 +0000
committerRoland McGrath <roland@gnu.org>2002-06-25 05:07:06 +0000
commit2c8af6fdfe8d713bb714a981c490543aeb61100b (patch)
tree7a178158d495d59ad1bfa8fb62abb7f331c59266 /utils
parent5f42652415968654b7046ee4549614afc008f16f (diff)
2002-06-14 Roland McGrath <roland@frob.com>
* vmstat.c (ensure_def_pager_info): If get_privileged_ports fails with EPERM, try to open /servers/default-pager instead. * Makefile (INSTALL-vmstat-ops): Variable removed (no setuid).
Diffstat (limited to 'utils')
-rw-r--r--utils/vmstat.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/utils/vmstat.c b/utils/vmstat.c
index c674bd4f..29b7c45b 100644
--- a/utils/vmstat.c
+++ b/utils/vmstat.c
@@ -24,12 +24,14 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <version.h>
#include <mach.h>
#include <mach/vm_statistics.h>
#include <mach/default_pager.h>
#include <hurd.h>
+#include <hurd/paths.h>
const char *argp_program_version = STANDARD_HURD_VERSION (vmstat);
@@ -245,19 +247,32 @@ ensure_def_pager_info (struct vm_state *state)
mach_port_t host;
err = get_privileged_ports (&host, 0);
- if (err)
+ if (err == EPERM)
{
- error (0, err, "get_privileged_ports");
- return 0;
+ /* We are not root, so try opening the /servers file. */
+ state->def_pager = file_name_lookup (_SERVERS_DEFPAGER, O_READ, 0);
+ if (state->def_pager == MACH_PORT_NULL)
+ {
+ error (0, errno, _SERVERS_DEFPAGER);
+ return 0;
+ }
}
+ if (state->def_pager == MACH_PORT_NULL)
+ {
+ if (err)
+ {
+ error (0, err, "get_privileged_ports");
+ return 0;
+ }
- err = vm_set_default_memory_manager (host, &state->def_pager);
- mach_port_deallocate (mach_task_self (), host);
+ err = vm_set_default_memory_manager (host, &state->def_pager);
+ mach_port_deallocate (mach_task_self (), host);
- if (err)
- {
- error (0, err, "vm_set_default_memory_manager");
- return 0;
+ if (err)
+ {
+ error (0, err, "vm_set_default_memory_manager");
+ return 0;
+ }
}
}