2005-10-12 17:07:38 +02:00
|
|
|
/*
|
2005-07-26 15:08:57 +02:00
|
|
|
* Changes:
|
|
|
|
* Jul 22, 2005: Created (Jorrit N. Herder)
|
|
|
|
*/
|
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
#include "inc.h"
|
2005-07-26 15:08:57 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2005-08-02 17:29:17 +02:00
|
|
|
#include <minix/dmap.h>
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
#include <minix/endpoint.h>
|
2005-07-26 15:08:57 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Allocate variables. */
|
|
|
|
struct rproc rproc[NR_SYS_PROCS]; /* system process table */
|
|
|
|
struct rproc *rproc_ptr[NR_PROCS]; /* mapping for fast access */
|
|
|
|
int nr_in_use; /* number of services */
|
|
|
|
extern int errno; /* error status */
|
2005-07-26 15:08:57 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Prototypes for internal functions that do the hard work. */
|
|
|
|
FORWARD _PROTOTYPE( int start_service, (struct rproc *rp) );
|
2005-10-20 22:31:18 +02:00
|
|
|
FORWARD _PROTOTYPE( int stop_service, (struct rproc *rp,int how) );
|
2005-08-02 17:29:17 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
PRIVATE int shutting_down = FALSE;
|
|
|
|
|
|
|
|
#define EXEC_FAILED 49 /* recognizable status */
|
2005-07-26 15:08:57 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
2005-10-20 22:31:18 +02:00
|
|
|
* do_up *
|
2005-07-26 15:08:57 +02:00
|
|
|
*===========================================================================*/
|
2005-10-20 22:31:18 +02:00
|
|
|
PUBLIC int do_up(m_ptr)
|
2005-10-12 17:07:38 +02:00
|
|
|
message *m_ptr; /* request message pointer */
|
2005-07-26 15:08:57 +02:00
|
|
|
{
|
2005-10-12 17:07:38 +02:00
|
|
|
/* A request was made to start a new system service. Dismember the request
|
|
|
|
* message and gather all information needed to start the service. Starting
|
|
|
|
* is done by a helper routine.
|
|
|
|
*/
|
|
|
|
register struct rproc *rp; /* system process table */
|
|
|
|
int slot_nr; /* local table entry */
|
|
|
|
int arg_count; /* number of arguments */
|
|
|
|
char *cmd_ptr; /* parse command string */
|
|
|
|
enum dev_style dev_style; /* device style */
|
|
|
|
int s; /* status variable */
|
2005-07-26 15:08:57 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* See if there is a free entry in the table with system processes. */
|
|
|
|
if (nr_in_use >= NR_SYS_PROCS) return(EAGAIN);
|
|
|
|
for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
|
|
|
|
rp = &rproc[slot_nr]; /* get pointer to slot */
|
2005-10-20 22:31:18 +02:00
|
|
|
if (! rp->r_flags & RS_IN_USE) /* check if available */
|
2005-10-12 17:07:38 +02:00
|
|
|
break;
|
2005-08-02 17:29:17 +02:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
nr_in_use ++; /* update administration */
|
|
|
|
|
|
|
|
/* Obtain command name and parameters. This is a space-separated string
|
|
|
|
* that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
|
2005-08-02 17:29:17 +02:00
|
|
|
*/
|
2005-10-20 22:31:18 +02:00
|
|
|
if (m_ptr->RS_CMD_LEN > MAX_COMMAND_LEN) return(E2BIG);
|
|
|
|
if (OK!=(s=sys_datacopy(m_ptr->m_source, (vir_bytes) m_ptr->RS_CMD_ADDR,
|
|
|
|
SELF, (vir_bytes) rp->r_cmd, m_ptr->RS_CMD_LEN))) return(s);
|
|
|
|
rp->r_cmd[m_ptr->RS_CMD_LEN] = '\0'; /* ensure it is terminated */
|
2005-10-12 17:07:38 +02:00
|
|
|
if (rp->r_cmd[0] != '/') return(EINVAL); /* insist on absolute path */
|
2005-07-26 15:08:57 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Build argument vector to be passed to execute call. The format of the
|
|
|
|
* arguments vector is: path, arguments, NULL.
|
|
|
|
*/
|
|
|
|
arg_count = 0; /* initialize arg count */
|
|
|
|
rp->r_argv[arg_count++] = rp->r_cmd; /* start with path */
|
|
|
|
cmd_ptr = rp->r_cmd; /* do some parsing */
|
|
|
|
while(*cmd_ptr != '\0') { /* stop at end of string */
|
|
|
|
if (*cmd_ptr == ' ') { /* next argument */
|
|
|
|
*cmd_ptr = '\0'; /* terminate previous */
|
|
|
|
while (*++cmd_ptr == ' ') ; /* skip spaces */
|
|
|
|
if (*cmd_ptr == '\0') break; /* no arg following */
|
|
|
|
if (arg_count>MAX_NR_ARGS+1) break; /* arg vector full */
|
|
|
|
rp->r_argv[arg_count++] = cmd_ptr; /* add to arg vector */
|
2005-08-02 17:29:17 +02:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
cmd_ptr ++; /* continue parsing */
|
2005-07-26 15:08:57 +02:00
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
rp->r_argv[arg_count] = NULL; /* end with NULL pointer */
|
|
|
|
rp->r_argc = arg_count;
|
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
/* Initialize some fields. */
|
|
|
|
rp->r_period = m_ptr->RS_PERIOD;
|
|
|
|
rp->r_dev_nr = m_ptr->RS_DEV_MAJOR;
|
2005-10-12 17:07:38 +02:00
|
|
|
rp->r_dev_style = STYLE_DEV;
|
2005-10-20 22:31:18 +02:00
|
|
|
rp->r_restarts = -1; /* will be incremented */
|
2005-10-12 17:07:38 +02:00
|
|
|
|
|
|
|
/* All information was gathered. Now try to start the system service. */
|
|
|
|
return(start_service(rp));
|
2005-07-26 15:08:57 +02:00
|
|
|
}
|
|
|
|
|
2005-08-23 13:31:32 +02:00
|
|
|
|
2005-07-26 15:08:57 +02:00
|
|
|
/*===========================================================================*
|
2005-10-20 22:31:18 +02:00
|
|
|
* do_down *
|
2005-07-26 15:08:57 +02:00
|
|
|
*===========================================================================*/
|
2005-10-20 22:31:18 +02:00
|
|
|
PUBLIC int do_down(message *m_ptr)
|
2005-07-26 15:08:57 +02:00
|
|
|
{
|
2005-10-12 17:07:38 +02:00
|
|
|
register struct rproc *rp;
|
2005-10-20 22:31:18 +02:00
|
|
|
pid_t pid = (pid_t) m_ptr->RS_PID;
|
2005-10-12 17:07:38 +02:00
|
|
|
|
|
|
|
for (rp=BEG_RPROC_ADDR; rp<END_RPROC_ADDR; rp++) {
|
2005-10-20 22:31:18 +02:00
|
|
|
if (rp->r_flags & RS_IN_USE && rp->r_pid == pid) {
|
|
|
|
#if VERBOSE
|
|
|
|
printf("stopping %d (%d)\n", pid, m_ptr->RS_PID);
|
|
|
|
#endif
|
|
|
|
stop_service(rp,RS_EXITING);
|
2005-10-12 17:07:38 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
}
|
2005-10-20 22:31:18 +02:00
|
|
|
#if VERBOSE
|
|
|
|
printf("not found %d (%d)\n", pid, m_ptr->RS_PID);
|
|
|
|
#endif
|
|
|
|
return(ESRCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_refresh *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_refresh(message *m_ptr)
|
|
|
|
{
|
|
|
|
register struct rproc *rp;
|
|
|
|
pid_t pid = (pid_t) m_ptr->RS_PID;
|
|
|
|
|
|
|
|
for (rp=BEG_RPROC_ADDR; rp<END_RPROC_ADDR; rp++) {
|
|
|
|
if (rp->r_flags & RS_IN_USE && rp->r_pid == pid) {
|
|
|
|
#if VERBOSE
|
|
|
|
printf("refreshing %d (%d)\n", pid, m_ptr->RS_PID);
|
|
|
|
#endif
|
|
|
|
stop_service(rp,RS_REFRESHING);
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if VERBOSE
|
|
|
|
printf("not found %d (%d)\n", pid, m_ptr->RS_PID);
|
|
|
|
#endif
|
2005-10-12 17:07:38 +02:00
|
|
|
return(ESRCH);
|
|
|
|
}
|
|
|
|
|
2005-10-21 15:28:26 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_rescue *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_rescue(message *m_ptr)
|
|
|
|
{
|
|
|
|
char rescue_dir[MAX_RESCUE_DIR_LEN];
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* Copy rescue directory from user. */
|
|
|
|
if (m_ptr->RS_CMD_LEN > MAX_RESCUE_DIR_LEN) return(E2BIG);
|
|
|
|
if (OK!=(s=sys_datacopy(m_ptr->m_source, (vir_bytes) m_ptr->RS_CMD_ADDR,
|
|
|
|
SELF, (vir_bytes) rescue_dir, m_ptr->RS_CMD_LEN))) return(s);
|
|
|
|
rescue_dir[m_ptr->RS_CMD_LEN] = '\0'; /* ensure it is terminated */
|
|
|
|
if (rescue_dir[0] != '/') return(EINVAL); /* insist on absolute path */
|
|
|
|
|
|
|
|
/* Change RS' directory to the rescue directory. Provided that the needed
|
|
|
|
* binaries are in the rescue dir, this makes recovery possible even if the
|
|
|
|
* (root) file system is no longer available, because no directory lookups
|
|
|
|
* are required. Thus if an absolute path fails, we can try to strip the
|
|
|
|
* path an see if the command is in the rescue dir.
|
|
|
|
*/
|
|
|
|
if (chdir(rescue_dir) != 0) return(errno);
|
|
|
|
return(OK);
|
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_shutdown *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_shutdown(message *m_ptr)
|
|
|
|
{
|
|
|
|
/* Set flag so that RS server knows services shouldn't be restarted. */
|
|
|
|
shutting_down = TRUE;
|
|
|
|
return(OK);
|
2005-07-26 15:08:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2005-09-11 18:45:46 +02:00
|
|
|
* do_exit *
|
2005-07-26 15:08:57 +02:00
|
|
|
*===========================================================================*/
|
2005-10-12 17:07:38 +02:00
|
|
|
PUBLIC void do_exit(message *m_ptr)
|
2005-07-26 15:08:57 +02:00
|
|
|
{
|
2005-10-12 17:07:38 +02:00
|
|
|
register struct rproc *rp;
|
2005-07-26 15:08:57 +02:00
|
|
|
pid_t exit_pid;
|
|
|
|
int exit_status;
|
|
|
|
|
2005-08-03 18:58:22 +02:00
|
|
|
#if VERBOSE
|
2005-10-12 17:07:38 +02:00
|
|
|
printf("RS: got SIGCHLD signal, doing wait to get exited child.\n");
|
2005-08-03 18:58:22 +02:00
|
|
|
#endif
|
2005-07-26 15:08:57 +02:00
|
|
|
|
|
|
|
/* See which child exited and what the exit status is. This is done in a
|
|
|
|
* loop because multiple childs may have exited, all reported by one
|
|
|
|
* SIGCHLD signal. The WNOHANG options is used to prevent blocking if,
|
|
|
|
* somehow, no exited child can be found.
|
|
|
|
*/
|
|
|
|
while ( (exit_pid = waitpid(-1, &exit_status, WNOHANG)) != 0 ) {
|
|
|
|
|
2005-08-03 18:58:22 +02:00
|
|
|
#if VERBOSE
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("RS: proc %d, pid %d, ", rp->r_proc_nr_e, exit_pid);
|
2005-10-12 17:07:38 +02:00
|
|
|
if (WIFSIGNALED(exit_status)) {
|
|
|
|
printf("killed, signal number %d\n", WTERMSIG(exit_status));
|
|
|
|
}
|
|
|
|
else if (WIFEXITED(exit_status)) {
|
|
|
|
printf("normal exit, status %d\n", WEXITSTATUS(exit_status));
|
|
|
|
}
|
2005-08-03 18:58:22 +02:00
|
|
|
#endif
|
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/* Search the system process table to see who exited.
|
|
|
|
* This should always succeed.
|
|
|
|
*/
|
|
|
|
for (rp=BEG_RPROC_ADDR; rp<END_RPROC_ADDR; rp++) {
|
2005-10-20 22:31:18 +02:00
|
|
|
if ((rp->r_flags & RS_IN_USE) && rp->r_pid == exit_pid) {
|
2006-03-08 15:38:35 +01:00
|
|
|
int proc;
|
|
|
|
proc = _ENDPOINT_P(rp->r_proc_nr_e);
|
2005-10-12 17:07:38 +02:00
|
|
|
|
2006-03-08 15:38:35 +01:00
|
|
|
rproc_ptr[proc] = NULL; /* invalidate */
|
2005-10-12 17:07:38 +02:00
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
if ((rp->r_flags & RS_EXITING) || shutting_down) {
|
2005-10-12 17:07:38 +02:00
|
|
|
rp->r_flags = 0; /* release slot */
|
2006-03-08 15:38:35 +01:00
|
|
|
rproc_ptr[proc] = NULL;
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
2005-10-20 22:31:18 +02:00
|
|
|
else if(rp->r_flags & RS_REFRESHING) {
|
|
|
|
rp->r_restarts = -1; /* reset counter */
|
|
|
|
start_service(rp); /* direct restart */
|
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
else if (WIFEXITED(exit_status) &&
|
|
|
|
WEXITSTATUS(exit_status) == EXEC_FAILED) {
|
|
|
|
rp->r_flags = 0; /* release slot */
|
|
|
|
}
|
|
|
|
else {
|
2005-10-20 22:31:18 +02:00
|
|
|
#if VERBOSE
|
2005-10-12 17:07:38 +02:00
|
|
|
printf("Unexpected exit. Restarting %s\n", rp->r_cmd);
|
2005-10-20 22:31:18 +02:00
|
|
|
#endif
|
|
|
|
/* Determine what to do. If this is the first unexpected
|
|
|
|
* exit, immediately restart this service. Otherwise use
|
|
|
|
* a binary exponetial backoff.
|
|
|
|
*/
|
|
|
|
if (rp->r_restarts > 0) {
|
|
|
|
rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-1));
|
|
|
|
rp->r_backoff = MIN(rp->r_backoff,MAX_BACKOFF);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
start_service(rp); /* direct restart */
|
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-07-26 15:08:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_period *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void do_period(m_ptr)
|
|
|
|
message *m_ptr;
|
|
|
|
{
|
|
|
|
register struct rproc *rp;
|
|
|
|
clock_t now = m_ptr->NOTIFY_TIMESTAMP;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* Search system services table. Only check slots that are in use. */
|
|
|
|
for (rp=BEG_RPROC_ADDR; rp<END_RPROC_ADDR; rp++) {
|
2005-10-20 22:31:18 +02:00
|
|
|
if (rp->r_flags & RS_IN_USE) {
|
|
|
|
|
|
|
|
/* If the service is to be revived (because it repeatedly exited,
|
|
|
|
* and was not directly restarted), the binary backoff field is
|
|
|
|
* greater than zero.
|
|
|
|
*/
|
|
|
|
if (rp->r_backoff > 0) {
|
|
|
|
rp->r_backoff -= 1;
|
|
|
|
if (rp->r_backoff == 0) {
|
|
|
|
start_service(rp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the service was signaled with a SIGTERM and fails to respond,
|
|
|
|
* kill the system service with a SIGKILL signal.
|
|
|
|
*/
|
2005-10-21 13:13:17 +02:00
|
|
|
else if (rp->r_stop_tm > 0 && now - rp->r_stop_tm > 2*RS_DELTA_T
|
|
|
|
&& rp->r_pid > 0) {
|
2005-10-20 22:31:18 +02:00
|
|
|
kill(rp->r_pid, SIGKILL); /* terminate */
|
|
|
|
}
|
2005-10-12 17:07:38 +02:00
|
|
|
|
2005-10-20 22:31:18 +02:00
|
|
|
/* There seems to be no special conditions. If the service has a
|
|
|
|
* period assigned check its status.
|
|
|
|
*/
|
|
|
|
else if (rp->r_period > 0) {
|
2005-10-12 17:07:38 +02:00
|
|
|
|
|
|
|
/* Check if an answer to a status request is still pending. If
|
|
|
|
* the driver didn't respond within time, kill it to simulate
|
|
|
|
* a crash. The failure will be detected and the service will
|
|
|
|
* be restarted automatically.
|
|
|
|
*/
|
|
|
|
if (rp->r_alive_tm < rp->r_check_tm) {
|
2005-10-21 13:13:17 +02:00
|
|
|
if (now - rp->r_alive_tm > 2*rp->r_period &&
|
|
|
|
rp->r_pid > 0) {
|
2005-10-12 17:07:38 +02:00
|
|
|
#if VERBOSE
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("RS: service %d reported late\n", rp->r_proc_nr_e);
|
2005-10-12 17:07:38 +02:00
|
|
|
#endif
|
|
|
|
kill(rp->r_pid, SIGKILL); /* simulate crash */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No answer pending. Check if a period expired since the last
|
|
|
|
* check and, if so request the system service's status.
|
|
|
|
*/
|
|
|
|
else if (now - rp->r_check_tm > rp->r_period) {
|
|
|
|
#if VERBOSE
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("RS: status request sent to %d\n", rp->r_proc_nr_e);
|
2005-10-12 17:07:38 +02:00
|
|
|
#endif
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
notify(rp->r_proc_nr_e); /* request status */
|
2005-10-12 17:07:38 +02:00
|
|
|
rp->r_check_tm = now; /* mark time */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reschedule a synchronous alarm for the next period. */
|
2005-10-20 22:31:18 +02:00
|
|
|
if (OK != (s=sys_setalarm(RS_DELTA_T, 0)))
|
2005-10-12 17:07:38 +02:00
|
|
|
panic("RS", "couldn't set alarm", s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* start_service *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE int start_service(rp)
|
|
|
|
struct rproc *rp;
|
|
|
|
{
|
|
|
|
/* Try to execute the given system service. Fork a new process. The child
|
|
|
|
* process will be inhibited from running by the NO_PRIV flag. Only let the
|
|
|
|
* child run once its privileges have been set by the parent.
|
|
|
|
*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
int child_proc_nr_e, child_proc_nr_n; /* child process slot */
|
2005-10-12 17:07:38 +02:00
|
|
|
pid_t child_pid; /* child's process id */
|
2005-10-21 15:28:26 +02:00
|
|
|
char *file_only;
|
2005-10-12 17:07:38 +02:00
|
|
|
int s;
|
|
|
|
message m;
|
|
|
|
|
|
|
|
/* Now fork and branch for parent and child process (and check for error). */
|
|
|
|
child_pid = fork();
|
|
|
|
switch(child_pid) { /* see fork(2) */
|
|
|
|
case -1: /* fork failed */
|
|
|
|
report("RS", "warning, fork() failed", errno); /* shouldn't happen */
|
|
|
|
return(errno); /* return error */
|
|
|
|
|
|
|
|
case 0: /* child process */
|
2005-10-21 15:28:26 +02:00
|
|
|
/* Try to execute the binary that has an absolute path. If this fails,
|
|
|
|
* e.g., because the root file system cannot be read, try to strip of
|
|
|
|
* the path, and see if the command is in RS' current working dir.
|
|
|
|
*/
|
2005-10-12 17:07:38 +02:00
|
|
|
execve(rp->r_argv[0], rp->r_argv, NULL); /* POSIX execute */
|
2005-10-21 15:28:26 +02:00
|
|
|
file_only = strrchr(rp->r_argv[0], '/') + 1;
|
|
|
|
execve(file_only, rp->r_argv, NULL); /* POSIX execute */
|
|
|
|
printf("RS: exec failed for %s: %d\n", rp->r_argv[0], errno);
|
2005-10-12 17:07:38 +02:00
|
|
|
exit(EXEC_FAILED); /* terminate child */
|
|
|
|
|
|
|
|
default: /* parent process */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
child_proc_nr_e = getnprocnr(child_pid); /* get child slot */
|
2005-10-12 17:07:38 +02:00
|
|
|
break; /* continue below */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only the parent process (the RS server) gets to this point. The child
|
|
|
|
* is still inhibited from running because it's privilege structure is
|
|
|
|
* not yet set. First try to set the device driver mapping at the FS.
|
|
|
|
*/
|
|
|
|
if (rp->r_dev_nr > 0) { /* set driver map */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if ((s=mapdriver(child_proc_nr_e, rp->r_dev_nr, rp->r_dev_style)) < 0) {
|
2005-10-12 17:07:38 +02:00
|
|
|
report("RS", "couldn't map driver", errno);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rp->r_flags |= RS_EXITING; /* expect exit */
|
2005-10-21 13:13:17 +02:00
|
|
|
if(child_pid > 0) kill(child_pid, SIGKILL); /* kill driver */
|
|
|
|
else report("RS", "didn't kill pid", child_pid);
|
2005-10-12 17:07:38 +02:00
|
|
|
return(s); /* return error */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The device driver mapping has been set, or the service was not a driver.
|
|
|
|
* Now, set the privilege structure for the child process to let is run.
|
|
|
|
* This should succeed: we tested number in use above.
|
|
|
|
*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if ((s = sys_privctl(child_proc_nr_e, SYS_PRIV_INIT, 0, NULL)) < 0) {
|
2005-10-12 17:07:38 +02:00
|
|
|
report("RS","call to SYSTEM failed", s); /* to let child run */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rp->r_flags |= RS_EXITING; /* expect exit */
|
2005-10-21 13:13:17 +02:00
|
|
|
if(child_pid > 0) kill(child_pid, SIGKILL); /* kill driver */
|
|
|
|
else report("RS", "didn't kill pid", child_pid);
|
2005-10-12 17:07:38 +02:00
|
|
|
return(s); /* return error */
|
|
|
|
}
|
|
|
|
|
|
|
|
#if VERBOSE
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("RS: started '%s', major %d, pid %d, endpoint %d, proc %d\n",
|
|
|
|
rp->r_cmd, rp->r_dev_nr, child_pid,
|
|
|
|
child_proc_nr_e, child_proc_nr_n);
|
2005-10-12 17:07:38 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The system service now has been successfully started. Update the rest
|
|
|
|
* of the system process table that is maintain by the RS server. The only
|
|
|
|
* thing that can go wrong now, is that execution fails at the child. If
|
|
|
|
* that's the case, the child will exit.
|
|
|
|
*/
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
child_proc_nr_n = _ENDPOINT_P(child_proc_nr_e);
|
2005-10-20 22:31:18 +02:00
|
|
|
rp->r_flags = RS_IN_USE; /* mark slot in use */
|
|
|
|
rp->r_restarts += 1; /* raise nr of restarts */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rp->r_proc_nr_e = child_proc_nr_e; /* set child details */
|
2005-10-12 17:07:38 +02:00
|
|
|
rp->r_pid = child_pid;
|
|
|
|
rp->r_check_tm = 0; /* not check yet */
|
|
|
|
getuptime(&rp->r_alive_tm); /* currently alive */
|
|
|
|
rp->r_stop_tm = 0; /* not exiting yet */
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
rproc_ptr[child_proc_nr_n] = rp; /* mapping for fast access */
|
2005-10-12 17:07:38 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
2005-08-23 13:31:32 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* stop_service *
|
|
|
|
*===========================================================================*/
|
2005-10-20 22:31:18 +02:00
|
|
|
PRIVATE int stop_service(rp,how)
|
2005-10-12 17:07:38 +02:00
|
|
|
struct rproc *rp;
|
2005-10-20 22:31:18 +02:00
|
|
|
int how;
|
2005-10-12 17:07:38 +02:00
|
|
|
{
|
|
|
|
/* Try to stop the system service. First send a SIGTERM signal to ask the
|
|
|
|
* system service to terminate. If the service didn't install a signal
|
|
|
|
* handler, it will be killed. If it did and ignores the signal, we'll
|
|
|
|
* find out because we record the time here and send a SIGKILL.
|
|
|
|
*/
|
2005-10-20 22:31:18 +02:00
|
|
|
#if VERBOSE
|
|
|
|
printf("RS tries to stop %s (pid %d)\n", rp->r_cmd, rp->r_pid);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rp->r_flags |= how; /* what to on exit? */
|
2005-10-21 13:13:17 +02:00
|
|
|
if(rp->r_pid > 0) kill(rp->r_pid, SIGTERM); /* first try friendly */
|
|
|
|
else report("RS", "didn't kill pid", rp->r_pid);
|
2005-10-12 17:07:38 +02:00
|
|
|
getuptime(&rp->r_stop_tm); /* record current time */
|
|
|
|
}
|
2005-10-20 22:31:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* do_getsysinfo *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_getsysinfo(m_ptr)
|
|
|
|
message *m_ptr;
|
|
|
|
{
|
|
|
|
vir_bytes src_addr, dst_addr;
|
|
|
|
int dst_proc;
|
|
|
|
size_t len;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
switch(m_ptr->m1_i1) {
|
|
|
|
case SI_PROC_TAB:
|
|
|
|
src_addr = (vir_bytes) rproc;
|
|
|
|
len = sizeof(struct rproc) * NR_SYS_PROCS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
dst_proc = m_ptr->m_source;
|
|
|
|
dst_addr = (vir_bytes) m_ptr->m1_p1;
|
|
|
|
if (OK != (s=sys_datacopy(SELF, src_addr, dst_proc, dst_addr, len)))
|
|
|
|
return(s);
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|