From 55494c933fb8f4089ff82d9542e9b394e7beb3da Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 25 Jun 2002 05:07:34 +0000 Subject: 2002-06-14 Roland McGrath * swapon.c (swaponoff): If get_privileged_ports fails with EPERM, try to open /servers/default-pager instead. --- sutils/swapon.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sutils') 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 #include #include +#include #include #include #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); -- cgit v1.2.3