diff options
Diffstat (limited to 'exec/main.c')
-rw-r--r-- | exec/main.c | 153 |
1 files changed, 64 insertions, 89 deletions
diff --git a/exec/main.c b/exec/main.c index 809b99a8..efad85aa 100644 --- a/exec/main.c +++ b/exec/main.c @@ -1,46 +1,48 @@ /* GNU Hurd standard exec server, main program and server mechanics. - Copyright (C) 1992, 1993, 19941996 Free Software Foundation, Inc. - Written by Roland McGrath. -This file is part of the GNU Hurd. + Copyright (C) 1992,93,94,95,96,97,98,99,2000,01,02 + Free Software Foundation, Inc. + Written by Roland McGrath. + This file is part of the GNU Hurd. -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 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. + 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. */ + 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. */ #include "priv.h" #include <error.h> #include <hurd/paths.h> #include <hurd/startup.h> +#include <argp.h> +#include <version.h> +const char *argp_program_version = STANDARD_HURD_VERSION (exec); +#ifdef BFD bfd_arch_info_type host_bfd_arch_info; bfd host_bfd = { arch_info: &host_bfd_arch_info }; -Elf32_Half elf_machine; /* ELF e_machine for the host. */ - extern error_t bfd_mach_host_arch_mach (host_t host, enum bfd_architecture *bfd_arch, long int *bfd_machine, - Elf32_Half *elf_machine); - + ElfW(Half) *elf_machine); +#endif /* Trivfs hooks. */ int trivfs_fstype = FSTYPE_MISC; int trivfs_fsid = 0; -int trivfs_support_read = 1; -int trivfs_support_write = 1; -int trivfs_support_exec = 1; -int trivfs_allow_open = O_READ|O_WRITE|O_EXEC; +int trivfs_support_read = 0; +int trivfs_support_write = 0; +int trivfs_allow_open = 0; struct port_class *trivfs_protid_portclasses[1]; struct port_class *trivfs_cntl_portclasses[1]; @@ -49,7 +51,6 @@ int trivfs_cntl_nportclasses = 1; struct trivfs_control *fsys; -char *exec_version = "0.0"; char **save_argv; @@ -72,21 +73,15 @@ deadboot (void *p) struct bootinfo *boot = p; size_t i; - vm_deallocate (mach_task_self (), - (vm_address_t) boot->argv, boot->argvlen); - vm_deallocate (mach_task_self (), - (vm_address_t) boot->envp, boot->envplen); + munmap (boot->argv, boot->argvlen); + munmap (boot->envp, boot->envplen); for (i = 0; i < boot->dtablesize; ++i) mach_port_deallocate (mach_task_self (), boot->dtable[i]); for (i = 0; i < boot->nports; ++i) mach_port_deallocate (mach_task_self (), boot->portarray[i]); - vm_deallocate (mach_task_self (), - (vm_address_t) boot->portarray, - boot->nports * sizeof (mach_port_t)); - vm_deallocate (mach_task_self (), - (vm_address_t) boot->intarray, - boot->nints * sizeof (int)); + munmap (boot->portarray, boot->nports * sizeof (mach_port_t)); + munmap (boot->intarray, boot->nints * sizeof (int)); /* See if we are going away and this was the last thing keeping us up. */ if (ports_count_class (trivfs_cntl_portclasses[0]) == 0) @@ -113,17 +108,21 @@ main (int argc, char **argv) { error_t err; mach_port_t bootstrap; + struct argp argp = { 0, 0, 0, "Hurd standard exec server." }; + + argp_parse (&argp, argc, argv, 0, 0, 0); save_argv = argv; +#ifdef BFD /* Put the Mach kernel's idea of what flavor of machine this is into the fake BFD against which architecture compatibility checks are made. */ err = bfd_mach_host_arch_mach (mach_host_self (), &host_bfd.arch_info->arch, - &host_bfd.arch_info->mach, - &elf_machine); + &host_bfd.arch_info->mach); if (err) error (1, err, "Getting host architecture from Mach"); +#endif task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap == MACH_PORT_NULL) @@ -150,8 +149,7 @@ main (int argc, char **argv) /* Launch. */ ports_manage_port_operations_multithread (port_bucket, exec_demuxer, - 2 * 60 * 1000, 0, - 0, MACH_PORT_NULL); + 2 * 60 * 1000, 0, 0); return 0; } @@ -204,24 +202,6 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) } } -/* Attempt to set the active translator for the exec server so that - filesystems other than the bootstrap can find it. */ -void -set_active_trans () -{ - file_t execnode; - - execnode = file_name_lookup (_SERVERS_EXEC, O_NOTRANS | O_CREAT, 0666); - if (execnode == MACH_PORT_NULL) - return; - - file_set_translator (execnode, 0, FS_TRANS_SET, 0, 0, 0, - ports_get_right (fsys), MACH_MSG_TYPE_MAKE_SEND); - /* Don't deallocate EXECNODE here. If we drop the last reference, - a bug in ufs might throw away the active translator. XXX */ -} - - /* Sent by the bootstrap filesystem after the other essential servers have been started up. */ @@ -229,7 +209,7 @@ kern_return_t S_exec_init (struct trivfs_protid *protid, auth_t auth, process_t proc) { - mach_port_t host_priv, dev_master, startup; + mach_port_t host_priv, startup; error_t err; if (! protid || ! protid->isroot) @@ -239,50 +219,45 @@ S_exec_init (struct trivfs_protid *protid, _hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], auth); /* Consume. */ /* Do initial setup with the proc server. */ - _hurd_proc_init (save_argv); - - /* Set the active translator on /servers/exec. */ - set_active_trans (); + _hurd_proc_init (save_argv, NULL, 0); procserver = getproc (); - err = get_privileged_ports (&host_priv, &dev_master); - if (!err) - { - proc_register_version (procserver, host_priv, "exec", HURD_RELEASE, - exec_version); - mach_port_deallocate (mach_task_self (), dev_master); - err = proc_getmsgport (procserver, 1, &startup); - if (err) - { - mach_port_deallocate (mach_task_self (), host_priv); - host_priv = MACH_PORT_NULL; - } - } - else - host_priv = MACH_PORT_NULL; - + /* Have the proc server notify us when the canonical ints and ports + change. This will generate an immediate callback giving us the + initial boot-time canonical sets. */ { - /* Have the proc server notify us when the canonical ints and ports - change. */ - + struct iouser *user; struct trivfs_protid *cred; - err = trivfs_open (fsys, 0, 0, 0, 0, 0, MACH_PORT_NULL, &cred); + mach_port_t right; + + err = iohelp_create_empty_iouser (&user); + assert_perror (err); + err = trivfs_open (fsys, user, 0, MACH_PORT_NULL, &cred); assert_perror (err); - proc_execdata_notify (procserver, ports_get_right (cred), - MACH_MSG_TYPE_MAKE_SEND); + right = ports_get_send_right (cred); + proc_execdata_notify (procserver, right, MACH_MSG_TYPE_COPY_SEND); + mach_port_deallocate (mach_task_self (), right); } + err = get_privileged_ports (&host_priv, NULL); + assert_perror (err); + + proc_register_version (procserver, host_priv, "exec", "", HURD_VERSION); + + err = proc_getmsgport (procserver, 1, &startup); + assert_perror (err); + mach_port_deallocate (mach_task_self (), procserver); + /* Call startup_essential task last; init assumes we are ready to run once we call it. */ - if (host_priv != MACH_PORT_NULL) - { - startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL, - "exec", host_priv); - mach_port_deallocate (mach_task_self (), startup); - mach_port_deallocate (mach_task_self (), host_priv); - } + err = startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL, + "exec", host_priv); + assert_perror (err); + mach_port_deallocate (mach_task_self (), startup); + + mach_port_deallocate (mach_task_self (), host_priv); return 0; } |