This still does not work. I get a freeze on reboot command: root@zamhurd:~# reboot INIT: Switching to runlevel: 6 INIT: Sending processes configured via /etc/inittab the TERM signal root@zamhurd:~# Broadcast message from root@zamhurd (console) (Sun Jul 25 16:32:28 1999):
The system is going down for reboot NOW! INIT: Sending processes configured via /etc/inittab the KILL signal Using makefile-style concurrent boot in runlevel 6. Stopping deferred execution scheduler: atd. Asking all remaining processes to terminate... <HANG> --- libmachdev/Makefile | 6 ++-- libmachdev/startup-ops.c | 36 +++++++++++++++++++++++ libmachdev/startup.c | 58 ++++++++++++++++++++++++++++++++++++++ libmachdev/startup.h | 28 ++++++++++++++++++ libmachdev/trivfs_server.c | 8 ++++-- libmachdev/trivfs_server.h | 30 ++++++++++++++++++++ 6 files changed, 161 insertions(+), 5 deletions(-) create mode 100644 libmachdev/startup-ops.c create mode 100644 libmachdev/startup.c create mode 100644 libmachdev/startup.h create mode 100644 libmachdev/trivfs_server.h diff --git a/libmachdev/Makefile b/libmachdev/Makefile index 15b98cf1..a111a2eb 100644 --- a/libmachdev/Makefile +++ b/libmachdev/Makefile @@ -19,10 +19,10 @@ dir := libmachdev makemode := library libname = libmachdev -SRCS = ds_routines.c trivfs_server.c \ - deviceServer.c notifyServer.c mach_i386Server.c +SRCS = ds_routines.c trivfs_server.c startup_notifyServer.c \ + deviceServer.c notifyServer.c mach_i386Server.c startup.c startup-ops.c -LCLHDRS = machdev.h machdev-device_emul.h machdev-dev_hdr.h mach_device.h +LCLHDRS = machdev.h machdev-device_emul.h machdev-dev_hdr.h mach_device.h startup.h installhdrs = machdev.h machdev-device_emul.h machdev-dev_hdr.h HURDLIBS = ports trivfs LDLIBS += -lpthread -lmachuser diff --git a/libmachdev/startup-ops.c b/libmachdev/startup-ops.c new file mode 100644 index 00000000..5d46c217 --- /dev/null +++ b/libmachdev/startup-ops.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 2020 Free Software Foundation, Inc. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <startup_notify_S.h> +#include <hurd/trivfs.h> +#include "startup.h" +#include "trivfs_server.h" + +/* The system is going down. Call trivfs_goaway() */ +error_t +S_startup_dosync (mach_port_t handle) +{ + struct port_info *inpi = ports_lookup_port (port_bucket, handle, + machdev_shutdown_notify_class); + + if (!inpi) + return EOPNOTSUPP; + + ports_port_deref (inpi); + + return trivfs_goaway (NULL, FSYS_GOAWAY_FORCE); +} diff --git a/libmachdev/startup.c b/libmachdev/startup.c new file mode 100644 index 00000000..fee5a665 --- /dev/null +++ b/libmachdev/startup.c @@ -0,0 +1,58 @@ +/* + Copyright (C) 2020 Free Software Foundation, Inc. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. +*/ + +/* Startup and shutdown notifications management */ + +#include "startup.h" +#include "trivfs_server.h" + +#include <unistd.h> +#include <hurd/paths.h> +#include <hurd/startup.h> +#include <hurd/trivfs.h> + +struct port_class *machdev_shutdown_notify_class; + +void +arrange_shutdown_notification () +{ + error_t err; + mach_port_t initport, notify; + struct port_info *pi; + + machdev_shutdown_notify_class = ports_create_class (0, 0); + + /* Arrange to get notified when the system goes down, + but if we fail for some reason, just silently give up. No big deal. */ + + err = ports_create_port (machdev_shutdown_notify_class, port_bucket, + sizeof (struct port_info), &pi); + if (err) + return; + + initport = file_name_lookup (_SERVERS_STARTUP, 0, 0); + if (initport == MACH_PORT_NULL) + return; + + notify = ports_get_send_right (pi); + ports_port_deref (pi); + startup_request_notification (initport, notify, + MACH_MSG_TYPE_MAKE_SEND, + program_invocation_short_name); + mach_port_deallocate (mach_task_self (), notify); + mach_port_deallocate (mach_task_self (), initport); +} diff --git a/libmachdev/startup.h b/libmachdev/startup.h new file mode 100644 index 00000000..2bc6b1d7 --- /dev/null +++ b/libmachdev/startup.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2020 Free Software Foundation, Inc. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef STARTUP_H +#define STARTUP_H + +/* Startup and shutdown notifications management */ + +/* Port class for startup requests */ +extern struct port_class *machdev_shutdown_notify_class; + +void arrange_shutdown_notification (void); + +#endif /* STARTUP_H */ diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c index 93d498ad..64f447b9 100644 --- a/libmachdev/trivfs_server.c +++ b/libmachdev/trivfs_server.c @@ -30,12 +30,14 @@ #include <device/device.h> /* mach console */ #include "libdiskfs/diskfs.h" +#include "startup.h" +#include "startup_notify_S.h" #include "device_S.h" #include "notify_S.h" #include "fsys_S.h" #include "mach_i386_S.h" -static struct port_bucket *port_bucket; +struct port_bucket *port_bucket; /* Trivfs hooks. */ int trivfs_fstype = FSTYPE_MISC; @@ -194,7 +196,6 @@ S_i386_io_perm_create (mach_port_t master_port, return i386_io_perm_create (_hurd_device_master, from, to, io_perm); } -/* This is fraud */ kern_return_t trivfs_S_fsys_startup (mach_port_t bootport, mach_port_t reply, @@ -204,6 +205,8 @@ trivfs_S_fsys_startup (mach_port_t bootport, mach_port_t *realnode, mach_msg_type_name_t *realnodetype) { + arrange_shutdown_notification (); + *realnode = MACH_PORT_NULL; *realnodetype = MACH_MSG_TYPE_MOVE_SEND; return 0; @@ -327,6 +330,7 @@ demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) if ((routine = device_server_routine (inp)) || (routine = notify_server_routine (inp)) || (routine = mach_i386_server_routine (inp)) || + (routine = startup_notify_server_routine (inp)) || (routine = NULL, trivfs_demuxer (inp, outp))) { if (routine) diff --git a/libmachdev/trivfs_server.h b/libmachdev/trivfs_server.h new file mode 100644 index 00000000..908feaf6 --- /dev/null +++ b/libmachdev/trivfs_server.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2020 Free Software Foundation, Inc. + + The GNU Hurd is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The GNU Hurd is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _TRIVFS_SERVER_H +#define _TRIVFS_SERVER_H + +#include <hurd/ports.h> +#include <hurd/trivfs.h> +#include <hurd.h> + +extern struct port_bucket *port_bucket; +extern struct port_class *trivfs_protid_class; +extern struct port_class *trivfs_cntl_class; + +#endif + -- 2.25.1
