From cd2673431ca4d96696cb7ec89a9b56de03f0038a Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 6 Nov 2014 13:59:59 +0100 Subject: [PATCH hurd 05/14] boot: remove unused function `boot_script_read_file' The unused function `boot_script_read_file' requires access to the default pager, which is privileged. * boot/boot.c (defpager): Remove now unused variable. (boot_script_read_file): Remove unused function. (main): Do not acquire port to the default pager. * boot/boot_script.h (boot_script_read_file): Remove declaration. --- boot/boot.c | 46 +--------------------------------------------- boot/boot_script.h | 4 ---- 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index d5b8096..250018e 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -109,7 +109,7 @@ typedef struct stat host_stat_t; #endif /* UX */ -mach_port_t privileged_host_port, master_device_port, defpager; +mach_port_t privileged_host_port, master_device_port; mach_port_t pseudo_master_device_port; mach_port_t receive_set; mach_port_t pseudo_console, pseudo_root; @@ -281,47 +281,6 @@ void read_reply (); void * msg_thread (void *); /* Callbacks for boot_script.c; see boot_script.h. */ - -mach_port_t -boot_script_read_file (const char *filename) -{ - static const char msg[] = ": cannot open\n"; - int fd = useropen (filename, O_RDONLY, 0); - host_stat_t st; - error_t err; - mach_port_t memobj; - vm_address_t region; - - write (2, filename, strlen (filename)); - if (fd < 0) - { - write (2, msg, sizeof msg - 1); - host_exit (1); - } - else - write (2, msg + sizeof msg - 2, 1); - - host_fstat (fd, &st); - - err = default_pager_object_create (defpager, &memobj, - round_page (st.st_size)); - if (err) - { - static const char msg[] = "cannot create default-pager object\n"; - write (2, msg, sizeof msg - 1); - host_exit (1); - } - - region = 0; - vm_map (mach_task_self (), ®ion, round_page (st.st_size), - 0, 1, memobj, 0, 0, VM_PROT_ALL, VM_PROT_ALL, VM_INHERIT_NONE); - read (fd, (char *) region, st.st_size); - munmap ((caddr_t) region, round_page (st.st_size)); - - close (fd); - return memobj; -} - int boot_script_exec_cmd (void *hook, mach_port_t task, char *path, int argc, @@ -532,9 +491,6 @@ main (int argc, char **argv, char **envp) get_privileged_ports (&privileged_host_port, &master_device_port); - defpager = MACH_PORT_NULL; - vm_set_default_memory_manager (privileged_host_port, &defpager); - strcat (bootstrap_args, "f"); mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_PORT_SET, diff --git a/boot/boot_script.h b/boot/boot_script.h index 6245869..da52e6f 100644 --- a/boot/boot_script.h +++ b/boot/boot_script.h @@ -69,10 +69,6 @@ int boot_script_exec_cmd (void *hook, task_t task, char *path, int argc, char **argv, char *strings, int stringlen); -/* The user must define this function. Load the contents of FILE - into a fresh anonymous memory object and return the memory object port. */ -mach_port_t boot_script_read_file (const char *file); - /* The user must define this functions to perform the corresponding Mach task manipulations. */ int boot_script_task_create (struct cmd *); /* task_create + task_suspend */ -- 2.1.1