summaryrefslogtreecommitdiff
path: root/sutils
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-06-25 05:07:34 +0000
committerRoland McGrath <roland@gnu.org>2002-06-25 05:07:34 +0000
commit55494c933fb8f4089ff82d9542e9b394e7beb3da (patch)
tree4e8311aff3cd30fd9915a872d4ce17c08fc0ca36 /sutils
parent645e15a460f41b9ff7271588fecfaf60fe9446a2 (diff)
2002-06-14 Roland McGrath <roland@frob.com>
* swapon.c (swaponoff): If get_privileged_ports fails with EPERM, try to open /servers/default-pager instead.
Diffstat (limited to 'sutils')
-rw-r--r--sutils/swapon.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sutils/swapon.c b/sutils/swapon.c
index 5e44854e..a50cd41d 100644
--- a/sutils/swapon.c
+++ b/sutils/swapon.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <sys/mman.h>
#include <hurd/store.h>
+#include <hurd/paths.h>
#include <version.h>
#include <mntent.h>
#include "default_pager_U.h"
@@ -372,8 +373,18 @@ swaponoff (const char *file, int add)
mach_port_t host;
err = get_privileged_ports (&host, &dev_master);
+ if (err == EPERM)
+ {
+ /* We are not root, so try opening the /servers node. */
+ def_pager = file_name_lookup (_SERVERS_DEFPAGER, O_WRITE, 0);
+ if (def_pager == MACH_PORT_NULL)
+ {
+ error (11, errno, _SERVERS_DEFPAGER);
+ return 0;
+ }
+ }
if (err)
- error (12, err, "Cannot get host port");
+ error (12, err, "Cannot get privileged ports");
err = vm_set_default_memory_manager (host, &def_pager);
mach_port_deallocate (mach_task_self (), host);