aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit via Bug reports for the GNU Hurd <bug-hurd@gnu.org>2024-11-10 08:42:08 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-11-10 11:03:39 +0100
commit53351d0e35568ad4c0a908942b483c85479a3fba (patch)
tree759390b2b531c1dc26aa8dc17bf8e39216e54f31
parente936af86df5ab09b1dead81a31d5ceb7c01576dd (diff)
downloadhurd-53351d0e35568ad4c0a908942b483c85479a3fba.tar.gz
hurd-53351d0e35568ad4c0a908942b483c85479a3fba.tar.bz2
hurd-53351d0e35568ad4c0a908942b483c85479a3fba.zip
shutdown: Try mach device acpi before /servers/acpi
Since libmachdev cannot currently serve netfs as well as trivfs on a path, we need to allow connecting to the bootstrapped acpi server to shut down the machine. Message-ID: <20241110084135.3859485-3-damien@zamaudio.com>
-rw-r--r--shutdown/shutdown.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/shutdown/shutdown.c b/shutdown/shutdown.c
index e4247397..4a2b1a41 100644
--- a/shutdown/shutdown.c
+++ b/shutdown/shutdown.c
@@ -32,6 +32,7 @@
#include <hurd/ports.h>
#include <hurd/trivfs.h>
#include <hurd/paths.h>
+#include <device/device.h>
#include <sys/file.h>
#include <version.h>
@@ -55,13 +56,32 @@ int trivfs_allow_open = O_READ | O_WRITE;
struct port_class *trivfs_protid_class;
struct port_class *trivfs_control_class;
+static mach_port_t
+get_acpi(void)
+{
+ kern_return_t err;
+ mach_port_t tryacpi, device_master;
+
+ err = get_privileged_ports (0, &device_master);
+ if (!err)
+ {
+ err = device_open (device_master, D_READ | D_WRITE, "acpi", &tryacpi);
+ mach_port_deallocate (mach_task_self (), device_master);
+ if (!err)
+ return tryacpi;
+ }
+
+ tryacpi = file_name_lookup (_SERVERS_ACPI, O_RDWR, 0);
+ return tryacpi;
+}
+
kern_return_t
S_shutdown_shutdown(trivfs_protid_t server)
{
kern_return_t err;
mach_port_t acpi;
- acpi = file_name_lookup (_SERVERS_ACPI, O_RDWR, 0);
+ acpi = get_acpi();
if (acpi == MACH_PORT_NULL)
return EIO;