[PATCH mig] Provide default implementations for server functions
By providing default implementations, servers can provide partial implementations of protocols without having to stub out functions. * server.c (WriteDefaultRoutine): New function. (WriteRoutine): Call WriteDefaultRoutine. --- server.c | 24 1 file changed, 24 insertions(+) diff --git a/server.c b/server.c index ae5977f..bcdeb0b 100644 --- a/server.c +++ b/server.c @@ -1279,6 +1279,28 @@ WriteFieldDecl(FILE *file, const argument_t *arg) } static void +WriteDefaultRoutine(FILE *file, const routine_t *rt) +{ +fprintf(file, "\n/* Default implementation of %s */\n", + rt->rtServerName); + +fprintf(file, "#ifdef\tMIG_EOPNOTSUPP\n"); + +fprintf(file, "%s __attribute__ ((weak))\n%s\n", + ReturnTypeStr(rt), rt->rtServerName); +fprintf(file, "(\n"); +WriteList(file, rt->rtArgs, WriteServerVarDecl, + akbServerArg, ",\n", "\n"); + +if (rt->rtReturn == argNULL) + fprintf(file, ") {}\n"); +else + fprintf(file, ") { return MIG_EOPNOTSUPP; }\n"); + +fprintf(file, "#endif\t/* MIG_EOPNOTSUPP */\n"); +} + +static void WriteRoutine(FILE *file, const routine_t *rt) { fprintf(file, "\n"); @@ -1346,6 +1368,8 @@ WriteRoutine(FILE *file, const routine_t *rt) } fprintf(file, "}\n"); + +WriteDefaultRoutine(file, rt); } void -- 2.1.1
Re: [PATCH mig] Provide default implementations for server functions
Justus Winter, le Fri 07 Nov 2014 15:04:17 +0100, a écrit : > By providing default implementations, servers can provide partial > implementations of protocols without having to stub out functions. I'm not sure whether we want that. When somebody has added something to a protocol, in my own servers I'd probably prefer to get a link failure rather that programs starting to get ENOTSUP errors. Samuel
Re: [PATCH mig] Provide default implementations for server functions
Quoting Samuel Thibault (2014-11-07 15:07:12) > Justus Winter, le Fri 07 Nov 2014 15:04:17 +0100, a écrit : > > By providing default implementations, servers can provide partial > > implementations of protocols without having to stub out functions. > > I'm not sure whether we want that. When somebody has added something to > a protocol, in my own servers I'd probably prefer to get a link failure > rather that programs starting to get ENOTSUP errors. For me that's a feature. If someone adds a method to a protocol, and my server doesn't implement it yet, it returns EOPNOTSUPP. However, since EOPNOTSUPP is a libc thingie, and we don't have that in the kernel, I went for a compromise. I create default implementations returning MIG_EOPNOTSUPP guarded by #ifdef MIG_EOPNOTSUPP. So one only gets default implementations if one defines an appropriate MIG_EOPNOTSUPP. The reason why I want it is: % git grep EOPNOTSUPP|wc --lines 1071 Also, I'm hacking on `boot', trying to get unprivileged subhurds running, and that means stubbing out some kernel interfaces. So it was either adding tons of stub functions to `boot' or doing a quick MIG enhancement. Justus
Re: [PATCH mig] Provide default implementations for server functions
Justus Winter, le Fri 07 Nov 2014 15:41:43 +0100, a écrit : > So one only gets default implementations if one defines an appropriate > MIG_EOPNOTSUPP. Ah, I missed that part. It sounds good to me then. Other opinions? Samuel
Re: [PATCH mig] Provide default implementations for server functions
Quoting Justus Winter (2014-11-07 15:41:43) > The reason why I want it is: > > % git grep EOPNOTSUPP|wc --lines > 1071 Better: % spatch --smpl-spacing --sp-file refactor/eopnotsupp.cocci --dir . | grep EOPNOTSUPP | wc --lines 269 So 269 functions matching the following ad-hoc coccinelle patch: @@ type T; identifier F; @@ -T F(...) -{ - return EOPNOTSUPP; -} Justus
Re: [PATCH mig] Provide default implementations for server functions
On Fri, Nov 07, 2014 at 03:45:11PM +0100, Samuel Thibault wrote: > Justus Winter, le Fri 07 Nov 2014 15:41:43 +0100, a écrit : > > So one only gets default implementations if one defines an appropriate > > MIG_EOPNOTSUPP. > > Ah, I missed that part. It sounds good to me then. Other opinions? It looks good to me too. -- Richard Braun
Re: [PATCH mig] Provide default implementations for server functions
Richard Braun, le Fri 07 Nov 2014 16:53:31 +0100, a écrit : > On Fri, Nov 07, 2014 at 03:45:11PM +0100, Samuel Thibault wrote: > > Justus Winter, le Fri 07 Nov 2014 15:41:43 +0100, a écrit : > > > So one only gets default implementations if one defines an appropriate > > > MIG_EOPNOTSUPP. > > > > Ah, I missed that part. It sounds good to me then. Other opinions? > > It looks good to me too. Ok, let's do this then, please commit. Samuel
[PATCH hurd 1/9] Makeconf: handle the gnumach protocol
* Makeconf (mach_defs_names): Add `gnumach'. --- Makeconf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makeconf b/Makeconf index 32eec13..f0d3fe3 100644 --- a/Makeconf +++ b/Makeconf @@ -575,7 +575,9 @@ vpath %.defs $(top_srcdir)/hurd # These we want to find in the libc include directory... mach_defs_names = bootstrap exc mach mach4 \ mach_host mach_port mach_timer_reply memory_object \ - memory_object_default notify + memory_object_default notify \ + gnumach \ + mach_debug_defs_names = mach_debug device_defs_names = dev_forward device device_reply device_request -- 2.1.1
[PATCH hurd 4/9] boot: drop bootstrap compat code
GNU Mach never sent old-style bootstrap messages. Drop the unused compatibility code. * boot/boot.c (request_server): Drop unused code. (bootstrap_compat): Drop unused function. --- boot/boot.c | 78 - 1 file changed, 78 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index 03617f5..d5b8096 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -179,21 +179,7 @@ request_server (mach_msg_header_t *inp, extern int term_server (mach_msg_header_t *, mach_msg_header_t *); /* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); - extern void bootstrap_compat (); -#if 0 - if (inp->msgh_local_port == bootport && boot_like_cmudef) -{ - if (inp->msgh_id == 99) - { - bootstrap_compat (inp, outp); - return 1; - } - else - return bootstrap_server (inp, outp); -} - else -#endif return (io_server (inp, outp) || device_server (inp, outp) || notify_server (inp, outp) @@ -914,8 +900,6 @@ unlock_readlock () /* * Handle bootstrap requests. */ -/* These two functions from .../mk/bootstrap/default_pager.c. */ - kern_return_t do_bootstrap_privileged_ports(bootstrap, hostp, devicep) mach_port_t bootstrap; @@ -925,68 +909,6 @@ do_bootstrap_privileged_ports(bootstrap, hostp, devicep) *devicep = pseudo_master_device_port; return KERN_SUCCESS; } - -void -bootstrap_compat(in, out) - mach_msg_header_t *in, *out; -{ - mig_reply_header_t *reply = (mig_reply_header_t *) out; - mach_msg_return_t mr; - - struct imsg { - mach_msg_header_t hdr; - mach_msg_type_t port_desc_1; - mach_port_t port_1; - mach_msg_type_t port_desc_2; - mach_port_t port_2; - } imsg; - - /* -* Send back the host and device ports. -*/ - - imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | - MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); - /* msgh_size doesn't need to be initialized */ - imsg.hdr.msgh_remote_port = in->msgh_remote_port; - imsg.hdr.msgh_local_port = MACH_PORT_NULL; - /* msgh_seqno doesn't need to be initialized */ - imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ - - imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; - imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); - imsg.port_desc_1.msgt_number = 1; - imsg.port_desc_1.msgt_inline = TRUE; - imsg.port_desc_1.msgt_longform = FALSE; - imsg.port_desc_1.msgt_deallocate = FALSE; - imsg.port_desc_1.msgt_unused = 0; - - imsg.port_1 = privileged_host_port; - - imsg.port_desc_2 = imsg.port_desc_1; - - imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND; - imsg.port_2 = pseudo_master_device_port; - - /* -* Send the reply message. -* (mach_msg_server can not do this, because the reply -* is not in standard format.) -*/ - - mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, - sizeof imsg, 0, MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - if (mr != MACH_MSG_SUCCESS) - (void) mach_port_deallocate(mach_task_self (), - imsg.hdr.msgh_remote_port); - - /* -* Tell mach_msg_server to do nothing. -*/ - - reply->RetCode = MIG_NO_REPLY; -} /* Implementation of device interface */ -- 2.1.1
[PATCH hurd 2/9] proc: gracefully handle failure to increase priority
* proc/main.c (increase_priority): New function. (main): Move code increasing the proc servers priority to a new function and handle errors gracefully. --- proc/main.c | 44 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/proc/main.c b/proc/main.c index f1f4e1b..3419d44 100644 --- a/proc/main.c +++ b/proc/main.c @@ -60,12 +60,40 @@ message_demuxer (mach_msg_header_t *inp, pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; +error_t +increase_priority (void) +{ + mach_port_t pset = MACH_PORT_NULL, psetcntl = MACH_PORT_NULL; + error_t err; + + err = thread_get_assignment (mach_thread_self (), &pset); + if (err) +goto out; + + err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl); + if (err) +goto out; + + err = thread_max_priority (mach_thread_self (), psetcntl, 0); + if (err) +goto out; + + err = task_priority (mach_task_self (), 2, 1); + + out: + if (MACH_PORT_VALID (pset)) +mach_port_deallocate (mach_task_self (), pset); + if (MACH_PORT_VALID (psetcntl)) +mach_port_deallocate (mach_task_self (), psetcntl); + + return err; +} + int main (int argc, char **argv, char **envp) { mach_port_t boot; error_t err; - mach_port_t pset, psetcntl; void *genport; process_t startup_port; struct argp argp = { 0, 0, 0, "Hurd process server" }; @@ -120,17 +148,9 @@ main (int argc, char **argv, char **envp) /* Give ourselves good scheduling performance, because we are so important. */ - err = thread_get_assignment (mach_thread_self (), &pset); - assert_perror (err); - err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl); - assert_perror (err); - thread_max_priority (mach_thread_self (), psetcntl, 0); - assert_perror (err); - err = task_priority (mach_task_self (), 2, 1); - assert_perror (err); - - mach_port_deallocate (mach_task_self (), pset); - mach_port_deallocate (mach_task_self (), psetcntl); + err = increase_priority (); + if (err) +error (0, err, "Increasing priority failed"); { /* Get our stderr set up to print on the console, in case we have -- 2.1.1
[PATCH hurd 5/9] 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
[PATCH hurd 3/9] startup: also open `console' for reading
* startup/startup.c (main): Also open `console' for reading. --- startup/startup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup/startup.c b/startup/startup.c index ff58270..e177075 100644 --- a/startup/startup.c +++ b/startup/startup.c @@ -557,7 +557,7 @@ main (int argc, char **argv, char **envp) master device ports, and the console. */ if (task_get_bootstrap_port (mach_task_self (), &bootport) || fsys_getpriv (bootport, &host_priv, &device_master, &fstask) - || device_open (device_master, D_WRITE, "console", &consdev)) + || device_open (device_master, D_READ|D_WRITE, "console", &consdev)) crash_mach (); wire_task_self (); -- 2.1.1
[PATCH hurd 7/9] boot: support ds_device_get_status with flavor DEV_GET_RECORDS
* boot/boot.c (ds_device_get_status): Support flavor DEV_GET_RECORDS. --- boot/boot.c | 33 + 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index a655107..d35ce50 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -1150,18 +1150,27 @@ ds_device_get_status (device_t device, if (device == pseudo_console) return D_INVALID_OPERATION; else if (device == pseudo_root) -if (flavor == DEV_GET_SIZE) - if (*statuslen < DEV_GET_SIZE_COUNT) - return D_INVALID_SIZE; - else - { - status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; - status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; - *statuslen = DEV_GET_SIZE_COUNT; - return D_SUCCESS; - } -else - return D_INVALID_OPERATION; +switch (flavor) + { + case DEV_GET_SIZE: +if (*statuslen < DEV_GET_SIZE_COUNT) + return D_INVALID_SIZE; +status[DEV_GET_SIZE_DEVICE_SIZE] = root_store->size; +status[DEV_GET_SIZE_RECORD_SIZE] = root_store->block_size; +*statuslen = DEV_GET_SIZE_COUNT; +return D_SUCCESS; + + case DEV_GET_RECORDS: +if (*statuslen < DEV_GET_RECORDS_COUNT) + return D_INVALID_SIZE; +status[DEV_GET_RECORDS_DEVICE_RECORDS] = root_store->blocks; +status[DEV_GET_RECORDS_RECORD_SIZE] = root_store->block_size; +*statuslen = DEV_GET_RECORDS_COUNT; +return D_SUCCESS; + + default: +return D_INVALID_OPERATION; + } else return D_NO_SUCH_DEVICE; } -- 2.1.1
[PATCH hurd 8/9] boot: implement pseudo-time device
* boot/boot.c (pseudo_time): New variable. (main): Allocate port `pseudo_time'. (ds_device_open): Give out `pseudo_time'. (ds_device_map): Emulate Mach-style `Mapped Time'. --- boot/boot.c | 38 +++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index d35ce50..747ab73 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -112,7 +112,7 @@ typedef struct stat host_stat_t; 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; +mach_port_t pseudo_console, pseudo_root, pseudo_time; auth_t authserver; struct store *root_store; @@ -534,6 +534,15 @@ main (int argc, char **argv, char **envp) if (foo != MACH_PORT_NULL) mach_port_deallocate (mach_task_self (), foo); + mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &pseudo_time); + mach_port_move_member (mach_task_self (), pseudo_time, receive_set); + mach_port_request_notification (mach_task_self (), pseudo_time, + MACH_NOTIFY_NO_SENDERS, 1, pseudo_time, + MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); + if (foo != MACH_PORT_NULL) +mach_port_deallocate (mach_task_self (), foo); + if (kernel_command_line == 0) asprintf (&kernel_command_line, "%s %s root=%s", argv[0], bootstrap_args, bootdevice); @@ -894,6 +903,12 @@ ds_device_open (mach_port_t master_port, *devicetype = MACH_MSG_TYPE_MAKE_SEND; return 0; } + else if (!strcmp (name, "time")) +{ + *device = pseudo_time; + *devicetype = MACH_MSG_TYPE_MAKE_SEND; + return 0; +} else if (strcmp (name, "pseudo-root") == 0) /* Magic root device. */ { @@ -1125,9 +1140,26 @@ ds_device_map (device_t device, memory_object_t *pager, int unmap) { - if (device != pseudo_console && device != pseudo_root) + if (device == pseudo_console || device == pseudo_root) +return D_INVALID_OPERATION; + else if (device == pseudo_time) +{ + error_t err; + mach_port_t wr_memobj; + file_t node = file_name_lookup ("/dev/time", O_RDONLY, 0); + + if (node == MACH_PORT_NULL) + return D_IO_ERROR; + + err = io_map (node, pager, &wr_memobj); + if (!err && MACH_PORT_VALID (wr_memobj)) + mach_port_deallocate (mach_task_self (), wr_memobj); + + mach_port_deallocate (mach_task_self (), node); + return D_SUCCESS; +} + else return D_NO_SUCH_DEVICE; - return D_INVALID_OPERATION; } kern_return_t -- 2.1.1
[PATCH hurd 9/9] boot: improve the demuxer
Handle multiple request types as recommended by the Mach Server Writer's Guide section 4, subsection "Handling Multiple Request Types". This avoids initializing the reply message in every X_server function. * boot/boot.c (mig_reply_setup): Provide local version. (request_server): Rename to `boot_demuxer', and improve the dispatch. --- boot/boot.c | 67 - 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index 747ab73..e2cb907 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -169,22 +169,55 @@ useropen (const char *name, int flags, int mode) return open (name, flags, mode); } -int -request_server (mach_msg_header_t *inp, - mach_msg_header_t *outp) -{ - extern int io_server (mach_msg_header_t *, mach_msg_header_t *); - extern int device_server (mach_msg_header_t *, mach_msg_header_t *); - extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); - extern int term_server (mach_msg_header_t *, mach_msg_header_t *); -/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ - extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); +/* XXX: glibc should provide mig_reply_setup but does not. */ +/* Fill in default response. */ +void +mig_reply_setup ( + const mach_msg_header_t *in, + mach_msg_header_t *out) +{ + static const mach_msg_type_t RetCodeType = { + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, + /* msgt_size = */ 32, + /* msgt_number = */ 1, + /* msgt_inline = */ TRUE, + /* msgt_longform = */ FALSE, + /* msgt_deallocate = */ FALSE, + /* msgt_unused = */ 0 + }; + +#defineInP (in) +#defineOutP((mig_reply_header_t *) out) + OutP->Head.msgh_bits = + MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0); + OutP->Head.msgh_size = sizeof *OutP; + OutP->Head.msgh_remote_port = InP->msgh_remote_port; + OutP->Head.msgh_local_port = MACH_PORT_NULL; + OutP->Head.msgh_seqno = 0; + OutP->Head.msgh_id = InP->msgh_id + 100; + OutP->RetCodeType = RetCodeType; + OutP->RetCode = MIG_BAD_ID; +#undef InP +#undef OutP +} - return (io_server (inp, outp) - || device_server (inp, outp) - || notify_server (inp, outp) - || term_server (inp, outp) - /* || tioctl_server (inp, outp) */); +int +boot_demuxer (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + mig_routine_t routine; + mig_reply_setup (inp, outp); + if ((routine = io_server_routine (inp)) || + (routine = device_server_routine (inp)) || + (routine = notify_server_routine (inp)) || + (routine = term_server_routine (inp)) + /* (routine = tioctl_server_routine (inp)) */) +{ + (*routine) (inp, outp); + return TRUE; +} + else +return FALSE; } vm_address_t @@ -710,15 +743,13 @@ main (int argc, char **argv, char **envp) else /* We hosed */ error (5, errno, "select"); } - -/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ } void * msg_thread (void *arg) { while (1) -mach_msg_server (request_server, 0, receive_set); +mach_msg_server (boot_demuxer, 0, receive_set); } -- 2.1.1
[PATCH hurd 6/9] boot: drop obsolete device procedures
* boot/boot.c (ds_xxx_device_set_status): Remove function. (ds_xxx_device_get_status): Likewise. (ds_xxx_device_set_filter): Likewise. --- boot/boot.c | 34 -- 1 file changed, 34 deletions(-) diff --git a/boot/boot.c b/boot/boot.c index 250018e..a655107 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -1118,40 +1118,6 @@ ds_device_read_inband (device_t device, } kern_return_t -ds_xxx_device_set_status (device_t device, - dev_flavor_t flavor, - dev_status_t status, - size_t statu_cnt) -{ - if (device != pseudo_console) -return D_NO_SUCH_DEVICE; - return D_INVALID_OPERATION; -} - -kern_return_t -ds_xxx_device_get_status (device_t device, - dev_flavor_t flavor, - dev_status_t status, - size_t *statuscnt) -{ - if (device != pseudo_console && device != pseudo_root) -return D_NO_SUCH_DEVICE; - return D_INVALID_OPERATION; -} - -kern_return_t -ds_xxx_device_set_filter (device_t device, - mach_port_t rec, - int pri, - filter_array_t filt, - size_t len) -{ - if (device != pseudo_console && device != pseudo_root) -return D_NO_SUCH_DEVICE; - return D_INVALID_OPERATION; -} - -kern_return_t ds_device_map (device_t device, vm_prot_t prot, vm_offset_t offset, -- 2.1.1
Re: [PATCH hurd 4/9] boot: drop bootstrap compat code
Justus Winter, le Fri 07 Nov 2014 17:31:57 +0100, a écrit : > GNU Mach never sent old-style bootstrap messages. Drop the unused > compatibility code. > > * boot/boot.c (request_server): Drop unused code. > (bootstrap_compat): Drop unused function. Ack. > --- > boot/boot.c | 78 > - > 1 file changed, 78 deletions(-) > > diff --git a/boot/boot.c b/boot/boot.c > index 03617f5..d5b8096 100644 > --- a/boot/boot.c > +++ b/boot/boot.c > @@ -179,21 +179,7 @@ request_server (mach_msg_header_t *inp, >extern int term_server (mach_msg_header_t *, mach_msg_header_t *); > /* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ >extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); > - extern void bootstrap_compat (); > > -#if 0 > - if (inp->msgh_local_port == bootport && boot_like_cmudef) > -{ > - if (inp->msgh_id == 99) > - { > - bootstrap_compat (inp, outp); > - return 1; > - } > - else > - return bootstrap_server (inp, outp); > -} > - else > -#endif > return (io_server (inp, outp) > || device_server (inp, outp) > || notify_server (inp, outp) > @@ -914,8 +900,6 @@ unlock_readlock () > /* > * Handle bootstrap requests. > */ > -/* These two functions from .../mk/bootstrap/default_pager.c. */ > - > kern_return_t > do_bootstrap_privileged_ports(bootstrap, hostp, devicep) > mach_port_t bootstrap; > @@ -925,68 +909,6 @@ do_bootstrap_privileged_ports(bootstrap, hostp, devicep) > *devicep = pseudo_master_device_port; > return KERN_SUCCESS; > } > - > -void > -bootstrap_compat(in, out) > - mach_msg_header_t *in, *out; > -{ > - mig_reply_header_t *reply = (mig_reply_header_t *) out; > - mach_msg_return_t mr; > - > - struct imsg { > - mach_msg_header_t hdr; > - mach_msg_type_t port_desc_1; > - mach_port_t port_1; > - mach_msg_type_t port_desc_2; > - mach_port_t port_2; > - } imsg; > - > - /* > - * Send back the host and device ports. > - */ > - > - imsg.hdr.msgh_bits = MACH_MSGH_BITS_COMPLEX | > - MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(in->msgh_bits), 0); > - /* msgh_size doesn't need to be initialized */ > - imsg.hdr.msgh_remote_port = in->msgh_remote_port; > - imsg.hdr.msgh_local_port = MACH_PORT_NULL; > - /* msgh_seqno doesn't need to be initialized */ > - imsg.hdr.msgh_id = in->msgh_id + 100; /* this is a reply msg */ > - > - imsg.port_desc_1.msgt_name = MACH_MSG_TYPE_COPY_SEND; > - imsg.port_desc_1.msgt_size = (sizeof(mach_port_t) * 8); > - imsg.port_desc_1.msgt_number = 1; > - imsg.port_desc_1.msgt_inline = TRUE; > - imsg.port_desc_1.msgt_longform = FALSE; > - imsg.port_desc_1.msgt_deallocate = FALSE; > - imsg.port_desc_1.msgt_unused = 0; > - > - imsg.port_1 = privileged_host_port; > - > - imsg.port_desc_2 = imsg.port_desc_1; > - > - imsg.port_desc_2.msgt_name = MACH_MSG_TYPE_MAKE_SEND; > - imsg.port_2 = pseudo_master_device_port; > - > - /* > - * Send the reply message. > - * (mach_msg_server can not do this, because the reply > - * is not in standard format.) > - */ > - > - mr = mach_msg(&imsg.hdr, MACH_SEND_MSG, > - sizeof imsg, 0, MACH_PORT_NULL, > - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); > - if (mr != MACH_MSG_SUCCESS) > - (void) mach_port_deallocate(mach_task_self (), > - imsg.hdr.msgh_remote_port); > - > - /* > - * Tell mach_msg_server to do nothing. > - */ > - > - reply->RetCode = MIG_NO_REPLY; > -} > > /* Implementation of device interface */ > > -- > 2.1.1 > -- Samuel --- christ gives channel operator status to Dieu -+- #ens-mim and hell -+-
Re: [PATCH hurd 6/9] boot: drop obsolete device procedures
Justus Winter, le Fri 07 Nov 2014 17:31:59 +0100, a écrit : > * boot/boot.c (ds_xxx_device_set_status): Remove function. > (ds_xxx_device_get_status): Likewise. > (ds_xxx_device_set_filter): Likewise. Ack. > --- > boot/boot.c | 34 -- > 1 file changed, 34 deletions(-) > > diff --git a/boot/boot.c b/boot/boot.c > index 250018e..a655107 100644 > --- a/boot/boot.c > +++ b/boot/boot.c > @@ -1118,40 +1118,6 @@ ds_device_read_inband (device_t device, > } > > kern_return_t > -ds_xxx_device_set_status (device_t device, > - dev_flavor_t flavor, > - dev_status_t status, > - size_t statu_cnt) > -{ > - if (device != pseudo_console) > -return D_NO_SUCH_DEVICE; > - return D_INVALID_OPERATION; > -} > - > -kern_return_t > -ds_xxx_device_get_status (device_t device, > - dev_flavor_t flavor, > - dev_status_t status, > - size_t *statuscnt) > -{ > - if (device != pseudo_console && device != pseudo_root) > -return D_NO_SUCH_DEVICE; > - return D_INVALID_OPERATION; > -} > - > -kern_return_t > -ds_xxx_device_set_filter (device_t device, > - mach_port_t rec, > - int pri, > - filter_array_t filt, > - size_t len) > -{ > - if (device != pseudo_console && device != pseudo_root) > -return D_NO_SUCH_DEVICE; > - return D_INVALID_OPERATION; > -} > - > -kern_return_t > ds_device_map (device_t device, > vm_prot_t prot, > vm_offset_t offset, > -- > 2.1.1 > -- Samuel "c'est pas nous qui sommes à la rue, c'est la rue qui est à nous"
Re: [PATCH hurd 9/9] boot: improve the demuxer
Justus Winter, le Fri 07 Nov 2014 17:32:02 +0100, a écrit : > Handle multiple request types as recommended by the Mach Server > Writer's Guide section 4, subsection "Handling Multiple Request > Types". This avoids initializing the reply message in every X_server > function. > > * boot/boot.c (mig_reply_setup): Provide local version. > (request_server): Rename to `boot_demuxer', and improve the dispatch. Ack. > --- > boot/boot.c | 67 > - > 1 file changed, 49 insertions(+), 18 deletions(-) > > diff --git a/boot/boot.c b/boot/boot.c > index 747ab73..e2cb907 100644 > --- a/boot/boot.c > +++ b/boot/boot.c > @@ -169,22 +169,55 @@ useropen (const char *name, int flags, int mode) >return open (name, flags, mode); > } > > -int > -request_server (mach_msg_header_t *inp, > - mach_msg_header_t *outp) > -{ > - extern int io_server (mach_msg_header_t *, mach_msg_header_t *); > - extern int device_server (mach_msg_header_t *, mach_msg_header_t *); > - extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); > - extern int term_server (mach_msg_header_t *, mach_msg_header_t *); > -/* extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *); */ > - extern int bootstrap_server (mach_msg_header_t *, mach_msg_header_t *); > +/* XXX: glibc should provide mig_reply_setup but does not. */ > +/* Fill in default response. */ > +void > +mig_reply_setup ( > + const mach_msg_header_t *in, > + mach_msg_header_t *out) > +{ > + static const mach_msg_type_t RetCodeType = { > + /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, > + /* msgt_size = */ 32, > + /* msgt_number = */ 1, > + /* msgt_inline = */ TRUE, > + /* msgt_longform = */ FALSE, > + /* msgt_deallocate = */ FALSE, > + /* msgt_unused = */ 0 > + }; > + > +#define InP (in) > +#define OutP((mig_reply_header_t *) out) > + OutP->Head.msgh_bits = > + MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0); > + OutP->Head.msgh_size = sizeof *OutP; > + OutP->Head.msgh_remote_port = InP->msgh_remote_port; > + OutP->Head.msgh_local_port = MACH_PORT_NULL; > + OutP->Head.msgh_seqno = 0; > + OutP->Head.msgh_id = InP->msgh_id + 100; > + OutP->RetCodeType = RetCodeType; > + OutP->RetCode = MIG_BAD_ID; > +#undef InP > +#undef OutP > +} > > - return (io_server (inp, outp) > -|| device_server (inp, outp) > -|| notify_server (inp, outp) > -|| term_server (inp, outp) > -/* || tioctl_server (inp, outp) */); > +int > +boot_demuxer (mach_msg_header_t *inp, > + mach_msg_header_t *outp) > +{ > + mig_routine_t routine; > + mig_reply_setup (inp, outp); > + if ((routine = io_server_routine (inp)) || > + (routine = device_server_routine (inp)) || > + (routine = notify_server_routine (inp)) || > + (routine = term_server_routine (inp)) > + /* (routine = tioctl_server_routine (inp)) */) > +{ > + (*routine) (inp, outp); > + return TRUE; > +} > + else > +return FALSE; > } > > vm_address_t > @@ -710,15 +743,13 @@ main (int argc, char **argv, char **envp) >else /* We hosed */ > error (5, errno, "select"); > } > - > -/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ > } > > void * > msg_thread (void *arg) > { >while (1) > -mach_msg_server (request_server, 0, receive_set); > +mach_msg_server (boot_demuxer, 0, receive_set); > } > > > -- > 2.1.1 > -- Samuel $ du temp.iso 2,0Ttemp.iso $ ls temp.iso -l -r-xr-xr-x1 samy thibault 16E 2003-03-22 14:44 temp.iso* -+- je vous dirai pas la marque de mon disque dur, na :p -+-