From: Erik van der Kouwe Date: Thu, 24 Jun 2010 07:37:26 +0000 (+0000) Subject: Don't use kernel responses in servers X-Git-Tag: v3.1.8~368 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/expt.png?a=commitdiff_plain;h=498d7d8a4c67886492d1c575555520b152735618;p=minix.git Don't use kernel responses in servers --- diff --git a/include/errno.h b/include/errno.h index 9903f8639..d39dba519 100644 --- a/include/errno.h +++ b/include/errno.h @@ -114,7 +114,6 @@ extern int errno; /* place where the error numbers go */ */ #define ELOCKED (_SIGN 101) /* can't send message due to deadlock */ #define EBADCALL (_SIGN 102) /* illegal system call number */ -#define EBADSRCDST (_SIGN 103) /* bad source or destination process */ #define ECALLDENIED (_SIGN 104) /* no permission for system call */ #define EDEADSRCDST (_SIGN 105) /* source or destination is not alive */ #define ENOTREADY (_SIGN 106) /* source or destination is not ready */ @@ -122,4 +121,8 @@ extern int errno; /* place where the error numbers go */ #define ETRAPDENIED (_SIGN 110) /* IPC trap not allowed */ #define EDONTREPLY (_SIGN 201) /* pseudo-code: don't send a reply */ +/* The following are non-POSIX server responses */ +#define EBADEPT (_SIGN 301) /* specified endpoint is bad */ +#define EDEADEPT (_SIGN 302) /* specified endpoint is not alive */ + #endif /* _ERRNO_H */ diff --git a/servers/iso9660fs/device.c b/servers/iso9660fs/device.c index 057970fbb..c35fc6e42 100644 --- a/servers/iso9660fs/device.c +++ b/servers/iso9660fs/device.c @@ -184,7 +184,7 @@ PUBLIC int block_dev_io( driver_e = driver_endpoints[(dev >> MAJOR) & BYTE].driver_e; /* See if driver is roughly valid. */ - if (driver_e == NONE) return(EDEADSRCDST); + if (driver_e == NONE) return(EDEADEPT); /* The io vector copying relies on this I/O being for FS itself. */ if(proc_e != SELF_E) { @@ -214,7 +214,7 @@ PUBLIC int block_dev_io( /* Call the task. */ r = sendrec(driver_e, &m); - if(r == OK && m.REP_STATUS == ERESTART) r = EDEADSRCDST; + if(r == OK && m.REP_STATUS == ERESTART) r = EDEADEPT; /* As block I/O never SUSPENDs, safe cleanup must be done whether * the I/O succeeded or not. */ @@ -226,7 +226,7 @@ PUBLIC int block_dev_io( * - VFS sends the new driver endp for the FS proc and the request again */ if (r != OK) { - if (r == EDEADSRCDST) { + if (r == EDEADSRCDST || r == EDEADEPT) { printf("ISOFS(%d) dead driver %d\n", SELF_E, driver_e); driver_endpoints[(dev >> MAJOR) & BYTE].driver_e = NONE; return(r); @@ -299,9 +299,9 @@ message *mess_ptr; /* pointer to message for task */ proc_e = mess_ptr->IO_ENDPT; r = sendrec(task_nr, mess_ptr); - if(r == OK && mess_ptr->REP_STATUS == ERESTART) r = EDEADSRCDST; + if(r == OK && mess_ptr->REP_STATUS == ERESTART) r = EDEADEPT; if (r != OK) { - if (r == EDEADSRCDST) { + if (r == EDEADSRCDST || r == EDEADEPT) { printf("fs: dead driver %d\n", task_nr); panic("should handle crashed drivers"); /* dmap_unmap_by_endpt(task_nr); */ diff --git a/servers/mfs/device.c b/servers/mfs/device.c index 1d8506b6f..5c38db7b0 100644 --- a/servers/mfs/device.c +++ b/servers/mfs/device.c @@ -175,7 +175,7 @@ PUBLIC int block_dev_io( /* See if driver is roughly valid. */ if (driver_e == NONE) { printf("MFS(%d) block_dev_io: no driver for dev %x\n", SELF_E, dev); - return(EDEADSRCDST); + return(EDEADEPT); } /* The io vector copying relies on this I/O being for FS itself. */ @@ -205,7 +205,7 @@ PUBLIC int block_dev_io( /* Call the task. */ r = sendrec(driver_e, &m); - if(r == OK && m.REP_STATUS == ERESTART) r = EDEADSRCDST; + if(r == OK && m.REP_STATUS == ERESTART) r = EDEADEPT; /* As block I/O never SUSPENDs, safe cleanup must be done whether * the I/O succeeded or not. */ @@ -217,7 +217,7 @@ PUBLIC int block_dev_io( * - VFS sends the new driver endp for the FS proc and the request again */ if (r != OK) { - if (r == EDEADSRCDST) { + if (r == EDEADSRCDST || r == EDEADEPT) { printf("MFS(%d) dead driver %d\n", SELF_E, driver_e); driver_endpoints[major(dev)].driver_e = NONE; return(r); @@ -331,10 +331,10 @@ PRIVATE int gen_io( r = sendrec(task_nr, mess_ptr); if(r == OK && mess_ptr->REP_STATUS == ERESTART) - r = EDEADSRCDST; + r = EDEADEPT; if (r != OK) { - if (r == EDEADSRCDST) { + if (r == EDEADSRCDST || r == EDEADEPT) { printf("fs: dead driver %d\n", task_nr); panic("should handle crashed drivers"); return(r); diff --git a/servers/pm/signal.c b/servers/pm/signal.c index 3925f885a..f097ce838 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -222,14 +222,14 @@ PUBLIC int process_ksig(endpoint_t proc_nr_e, int signo) if(pm_isokendpt(proc_nr_e, &proc_nr) != OK || proc_nr < 0) { printf("PM: process_ksig: %d?? not ok\n", proc_nr_e); - return EDEADSRCDST; /* process is gone. */ + return EDEADEPT; /* process is gone. */ } rmp = &mproc[proc_nr]; if ((rmp->mp_flags & (IN_USE | EXITING)) != IN_USE) { #if 0 printf("PM: process_ksig: %d?? exiting / not in use\n", proc_nr_e); #endif - return EDEADSRCDST; /* process is gone. */ + return EDEADEPT; /* process is gone. */ } proc_id = rmp->mp_pid; mp = &mproc[0]; /* pretend signals are from PM */ @@ -287,7 +287,7 @@ PUBLIC int process_ksig(endpoint_t proc_nr_e, int signo) return OK; /* signal has been delivered */ } else { - return EDEADSRCDST; /* process is gone */ + return EDEADEPT; /* process is gone */ } } diff --git a/servers/pm/utility.c b/servers/pm/utility.c index b299dc51c..2dd6e73f3 100644 --- a/servers/pm/utility.c +++ b/servers/pm/utility.c @@ -111,9 +111,9 @@ PUBLIC int pm_isokendpt(int endpoint, int *proc) if(*proc < -NR_TASKS || *proc >= NR_PROCS) return EINVAL; if(*proc >= 0 && endpoint != mproc[*proc].mp_endpoint) - return EDEADSRCDST; + return EDEADEPT; if(*proc >= 0 && !(mproc[*proc].mp_flags & IN_USE)) - return EDEADSRCDST; + return EDEADEPT; return OK; } diff --git a/servers/rs/main.c b/servers/rs/main.c index 58f5af3be..02214e0eb 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -526,7 +526,7 @@ PRIVATE int sef_cb_signal_manager(endpoint_t target, int signo) /* Don't bother if a termination signal has already been processed. */ if((rp->r_flags & RS_TERMINATED) && !(rp->r_flags & RS_EXITING)) { - return EDEADSRCDST; /* process is gone */ + return EDEADEPT; /* process is gone */ } /* Ignore external signals for inactive service instances. */ @@ -551,7 +551,7 @@ PRIVATE int sef_cb_signal_manager(endpoint_t target, int signo) rp->r_flags |= RS_TERMINATED; terminate_service(rp); - return EDEADSRCDST; /* process is now gone */ + return EDEADEPT; /* process is now gone */ } /* Translate every non-termination signal into a message. */ diff --git a/servers/rs/manager.c b/servers/rs/manager.c index efb02be17..423a1232d 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -857,7 +857,7 @@ PUBLIC void terminate_service(struct rproc *rp) } /* See if a late reply has to be sent. */ - r = (rp->r_caller_request == RS_DOWN ? OK : EDEADSRCDST); + r = (rp->r_caller_request == RS_DOWN ? OK : EDEADEPT); late_reply(rp, r); /* Unpublish the service. */ diff --git a/servers/sched/schedule.c b/servers/sched/schedule.c index 247c3e1dc..ddaafff48 100644 --- a/servers/sched/schedule.c +++ b/servers/sched/schedule.c @@ -35,7 +35,7 @@ PUBLIC int do_noquantum(message *m_ptr) if (sched_isokendpt(m_ptr->m_source, &proc_nr_n) != OK) { printf("SCHED: WARNING: got an invalid endpoint in OOQ msg %u.\n", m_ptr->m_source); - return EBADSRCDST; + return EBADEPT; } rmp = &schedproc[proc_nr_n]; @@ -64,7 +64,7 @@ PUBLIC int do_stop_scheduling(message *m_ptr) if (sched_isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr_n) != OK) { printf("SCHED: WARNING: got an invalid endpoint in OOQ msg %u.\n", m_ptr->SCHEDULING_ENDPOINT); - return EBADSRCDST; + return EBADEPT; } rmp = &schedproc[proc_nr_n]; @@ -168,7 +168,7 @@ PUBLIC int do_nice(message *m_ptr) if (sched_isokendpt(m_ptr->SCHEDULING_ENDPOINT, &proc_nr_n) != OK) { printf("SCHED: WARNING: got an invalid endpoint in OOQ msg %u.\n", m_ptr->SCHEDULING_ENDPOINT); - return EBADSRCDST; + return EBADEPT; } rmp = &schedproc[proc_nr_n]; diff --git a/servers/sched/utility.c b/servers/sched/utility.c index 58615a9e9..db0ca27e4 100644 --- a/servers/sched/utility.c +++ b/servers/sched/utility.c @@ -32,13 +32,13 @@ PUBLIC int sched_isokendpt(int endpoint, int *proc) { *proc = _ENDPOINT_P(endpoint); if (*proc < 0) - return (EBADSRCDST); /* Don't schedule tasks */ + return (EBADEPT); /* Don't schedule tasks */ if(*proc >= NR_PROCS) return (EINVAL); if(endpoint != schedproc[*proc].endpoint) - return (EDEADSRCDST); + return (EDEADEPT); if(!(schedproc[*proc].flags & IN_USE)) - return (EDEADSRCDST); + return (EDEADEPT); return (OK); } @@ -49,11 +49,11 @@ PUBLIC int sched_isemtyendpt(int endpoint, int *proc) { *proc = _ENDPOINT_P(endpoint); if (*proc < 0) - return (EBADSRCDST); /* Don't schedule tasks */ + return (EBADEPT); /* Don't schedule tasks */ if(*proc >= NR_PROCS) return (EINVAL); if(schedproc[*proc].flags & IN_USE) - return (EDEADSRCDST); + return (EDEADEPT); return (OK); } diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 49f8ee715..2ceba6d66 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -159,10 +159,10 @@ PUBLIC void dev_status(message *m) int r; st.m_type = DEV_STATUS; r = sendrec(m->m_source, &st); - if(r == OK && st.REP_STATUS == ERESTART) r = EDEADSRCDST; + if(r == OK && st.REP_STATUS == ERESTART) r = EDEADEPT; if (r != OK) { printf("DEV_STATUS failed to %d: %d\n", m->m_source, r); - if (r == EDEADSRCDST) return; + if (r == EDEADSRCDST || r == EDEADEPT) return; panic("couldn't sendrec for DEV_STATUS: %d", r); } @@ -625,9 +625,9 @@ message *mess_ptr; /* pointer to message for task */ proc_e = mess_ptr->IO_ENDPT; r = sendrec(task_nr, mess_ptr); - if(r == OK && mess_ptr->REP_STATUS == ERESTART) r = EDEADSRCDST; + if(r == OK && mess_ptr->REP_STATUS == ERESTART) r = EDEADEPT; if (r != OK) { - if (r == EDEADSRCDST) { + if (r == EDEADSRCDST || r == EDEADEPT) { printf("fs: dead driver %d\n", task_nr); dmap_unmap_by_endpt(task_nr); return(r); diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index 54ae18d86..296fe1bee 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -115,7 +115,7 @@ PUBLIC int isokendpt_f(char *file, int line, endpoint_t endpoint, int *proc, int if(failed && fatal) panic("isokendpt_f failed"); - return(failed ? EDEADSRCDST : OK); + return(failed ? EDEADEPT : OK); } diff --git a/servers/vm/utility.c b/servers/vm/utility.c index 2ca3e13c5..9aacae714 100644 --- a/servers/vm/utility.c +++ b/servers/vm/utility.c @@ -127,9 +127,9 @@ PUBLIC int vm_isokendpt(endpoint_t endpoint, int *proc) if(*proc < 0 || *proc >= NR_PROCS) return EINVAL; if(*proc >= 0 && endpoint != vmproc[*proc].vm_endpoint) - return EDEADSRCDST; + return EDEADEPT; if(*proc >= 0 && !(vmproc[*proc].vm_flags & VMF_INUSE)) - return EDEADSRCDST; + return EDEADEPT; return OK; }