2005-05-03 17:35:52 +02:00
|
|
|
/* Miscellaneous system calls. Author: Kees J. Bot
|
|
|
|
* 31 Mar 2000
|
|
|
|
* The entry points into this file are:
|
|
|
|
* do_reboot: kill all processes, then reboot system
|
2006-03-10 17:10:05 +01:00
|
|
|
* do_procstat: request process status (Jorrit N. Herder)
|
2005-06-02 14:43:21 +02:00
|
|
|
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
|
|
|
|
* do_getprocnr: lookup process slot number (Jorrit N. Herder)
|
2007-04-27 14:21:06 +02:00
|
|
|
* do_getpuid: get the uid/euid of a process given it's endpoint
|
2006-03-04 23:51:52 +01:00
|
|
|
* do_allocmem: allocate a chunk of memory (Jorrit N. Herder)
|
|
|
|
* do_freemem: deallocate a chunk of memory (Jorrit N. Herder)
|
2005-07-01 19:58:29 +02:00
|
|
|
* do_getsetpriority: get/set process priority
|
2006-03-10 17:10:05 +01:00
|
|
|
* do_svrctl: process manager control
|
2005-05-03 17:35:52 +02:00
|
|
|
*/
|
|
|
|
|
2006-06-30 16:36:11 +02:00
|
|
|
#define brk _brk
|
|
|
|
|
2005-05-13 10:57:08 +02:00
|
|
|
#include "pm.h"
|
2005-05-03 17:35:52 +02:00
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/svrctl.h>
|
2005-07-01 19:58:29 +02:00
|
|
|
#include <sys/resource.h>
|
2006-05-19 14:19:37 +02:00
|
|
|
#include <sys/utsname.h>
|
2005-05-03 17:35:52 +02:00
|
|
|
#include <minix/com.h>
|
2005-10-13 14:48:43 +02:00
|
|
|
#include <minix/config.h>
|
2006-07-27 18:23:01 +02:00
|
|
|
#include <minix/sysinfo.h>
|
2005-10-13 14:48:43 +02:00
|
|
|
#include <minix/type.h>
|
2008-11-19 13:26:10 +01:00
|
|
|
#include <minix/vm.h>
|
2005-05-03 17:35:52 +02:00
|
|
|
#include <string.h>
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
#include <archconst.h>
|
|
|
|
#include <archtypes.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 <lib.h>
|
2005-05-03 17:35:52 +02:00
|
|
|
#include "mproc.h"
|
|
|
|
#include "param.h"
|
2006-03-16 10:33:35 +01:00
|
|
|
#include "../../kernel/proc.h"
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2006-05-19 14:19:37 +02:00
|
|
|
PUBLIC struct utsname uts_val = {
|
|
|
|
"Minix", /* system name */
|
|
|
|
"noname", /* node/network name */
|
|
|
|
OS_RELEASE, /* O.S. release (e.g. 1.5) */
|
|
|
|
OS_VERSION, /* O.S. version (e.g. 10) */
|
|
|
|
"xyzzy", /* machine (cpu) type (filled in later) */
|
|
|
|
#if __i386
|
|
|
|
"i386", /* architecture */
|
|
|
|
#else
|
|
|
|
#error /* oops, no 'uname -mk' */
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRIVATE char *uts_tbl[] = {
|
|
|
|
uts_val.arch,
|
|
|
|
NULL, /* No kernel architecture */
|
|
|
|
uts_val.machine,
|
|
|
|
NULL, /* No hostname */
|
|
|
|
uts_val.nodename,
|
|
|
|
uts_val.release,
|
|
|
|
uts_val.version,
|
|
|
|
uts_val.sysname,
|
|
|
|
NULL, /* No bus */ /* No bus */
|
|
|
|
};
|
|
|
|
|
2006-07-10 14:44:43 +02:00
|
|
|
#if ENABLE_SYSCALL_STATS
|
|
|
|
PUBLIC unsigned long calls_stats[NCALLS];
|
|
|
|
#endif
|
|
|
|
|
2005-06-03 15:55:06 +02:00
|
|
|
/*===========================================================================*
|
2005-09-11 18:45:46 +02:00
|
|
|
* do_allocmem *
|
2005-06-03 15:55:06 +02:00
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_allocmem()
|
2005-06-02 14:43:21 +02:00
|
|
|
{
|
2008-11-19 13:26:10 +01:00
|
|
|
int r;
|
|
|
|
phys_bytes retmembase;
|
|
|
|
r = vm_allocmem(m_in.memsize, &retmembase);
|
|
|
|
if(r == OK)
|
|
|
|
mp->mp_reply.membase = retmembase;
|
|
|
|
return r;
|
2005-06-02 14:43:21 +02:00
|
|
|
}
|
|
|
|
|
2005-06-03 15:55:06 +02:00
|
|
|
/*===========================================================================*
|
2005-09-11 18:45:46 +02:00
|
|
|
* do_freemem *
|
2005-06-03 15:55:06 +02:00
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_freemem()
|
2005-06-02 14:43:21 +02:00
|
|
|
{
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 1
|
|
|
|
return ENOSYS;
|
|
|
|
#else
|
2005-06-03 15:55:06 +02:00
|
|
|
vir_clicks mem_clicks;
|
|
|
|
phys_clicks mem_base;
|
|
|
|
|
2006-05-19 14:19:37 +02:00
|
|
|
/* This call is dangerous. Even memory belonging to other processes can
|
|
|
|
* be freed.
|
|
|
|
*/
|
|
|
|
if (mp->mp_effuid != 0)
|
|
|
|
{
|
|
|
|
printf("PM: unauthorized call of do_freemem by proc %d\n",
|
|
|
|
mp->mp_endpoint);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
|
2005-06-03 15:55:06 +02:00
|
|
|
mem_clicks = (m_in.memsize + CLICK_SIZE -1 ) >> CLICK_SHIFT;
|
|
|
|
mem_base = (m_in.membase + CLICK_SIZE -1 ) >> CLICK_SHIFT;
|
|
|
|
free_mem(mem_base, mem_clicks);
|
2005-06-02 14:43:21 +02:00
|
|
|
return(OK);
|
2008-11-19 13:26:10 +01:00
|
|
|
#endif
|
2005-06-02 14:43:21 +02:00
|
|
|
}
|
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_procstat *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_procstat()
|
|
|
|
{
|
|
|
|
/* For the moment, this is only used to return pending signals to
|
|
|
|
* system processes that request the PM for their own status.
|
|
|
|
*
|
|
|
|
* Future use might include the FS requesting for process status of
|
|
|
|
* any user process.
|
|
|
|
*/
|
2006-05-19 14:19:37 +02:00
|
|
|
|
|
|
|
/* This call should be removed, or made more general. */
|
|
|
|
if (mp->mp_effuid != 0)
|
|
|
|
{
|
|
|
|
printf("PM: unauthorized call of do_procstat by proc %d\n",
|
|
|
|
mp->mp_endpoint);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
if (m_in.stat_nr == SELF) {
|
|
|
|
mp->mp_reply.sig_set = mp->mp_sigpending;
|
|
|
|
sigemptyset(&mp->mp_sigpending);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return(ENOSYS);
|
|
|
|
}
|
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2006-05-19 14:19:37 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_sysuname *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_sysuname()
|
|
|
|
{
|
|
|
|
/* Set or get uname strings. */
|
|
|
|
|
|
|
|
int r;
|
2007-02-16 16:55:20 +01:00
|
|
|
size_t n;
|
|
|
|
char *string;
|
2006-05-19 14:19:37 +02:00
|
|
|
#if 0 /* for updates */
|
|
|
|
char tmp[sizeof(uts_val.nodename)];
|
|
|
|
static short sizes[] = {
|
|
|
|
0, /* arch, (0 = read-only) */
|
|
|
|
0, /* kernel */
|
|
|
|
0, /* machine */
|
|
|
|
0, /* sizeof(uts_val.hostname), */
|
|
|
|
sizeof(uts_val.nodename),
|
|
|
|
0, /* release */
|
|
|
|
0, /* version */
|
|
|
|
0, /* sysname */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((unsigned) m_in.sysuname_field >= _UTS_MAX) return(EINVAL);
|
|
|
|
|
|
|
|
string = uts_tbl[m_in.sysuname_field];
|
|
|
|
if (string == NULL)
|
|
|
|
return EINVAL; /* Unsupported field */
|
|
|
|
|
|
|
|
switch (m_in.sysuname_req) {
|
|
|
|
case _UTS_GET:
|
|
|
|
/* Copy an uname string to the user. */
|
|
|
|
n = strlen(string) + 1;
|
|
|
|
if (n > m_in.sysuname_len) n = m_in.sysuname_len;
|
|
|
|
r = sys_vircopy(SELF, D, (phys_bytes) string,
|
|
|
|
mp->mp_endpoint, D, (phys_bytes) m_in.sysuname_value,
|
|
|
|
(phys_bytes) n);
|
|
|
|
if (r < 0) return(r);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if 0 /* no updates yet */
|
|
|
|
case _UTS_SET:
|
|
|
|
/* Set an uname string, needs root power. */
|
|
|
|
len = sizes[m_in.sysuname_field];
|
|
|
|
if (mp->mp_effuid != 0 || len == 0) return(EPERM);
|
|
|
|
n = len < m_in.sysuname_len ? len : m_in.sysuname_len;
|
|
|
|
if (n <= 0) return(EINVAL);
|
|
|
|
r = sys_vircopy(mp->mp_endpoint, D, (phys_bytes) m_in.sysuname_value,
|
|
|
|
SELF, D, (phys_bytes) tmp, (phys_bytes) n);
|
|
|
|
if (r < 0) return(r);
|
|
|
|
tmp[n-1] = 0;
|
|
|
|
strcpy(string, tmp);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
/* Return the number of bytes moved. */
|
|
|
|
return(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-06 15:51:50 +02:00
|
|
|
/*===========================================================================*
|
2005-09-11 18:45:46 +02:00
|
|
|
* do_getsysinfo *
|
2005-06-06 15:51:50 +02:00
|
|
|
*===========================================================================*/
|
2005-05-03 17:35:52 +02:00
|
|
|
PUBLIC int do_getsysinfo()
|
|
|
|
{
|
2005-06-06 15:51:50 +02:00
|
|
|
struct mproc *proc_addr;
|
|
|
|
vir_bytes src_addr, dst_addr;
|
|
|
|
struct kinfo kinfo;
|
2005-11-14 16:50:46 +01:00
|
|
|
struct loadinfo loadinfo;
|
2006-03-16 10:33:35 +01:00
|
|
|
static struct proc proctab[NR_PROCS+NR_TASKS];
|
2005-06-06 15:51:50 +02:00
|
|
|
size_t len;
|
2005-10-13 14:48:43 +02:00
|
|
|
int s, r;
|
2005-06-06 15:51:50 +02:00
|
|
|
|
2006-05-19 14:19:37 +02:00
|
|
|
/* This call leaks important information (the contents of registers).
|
|
|
|
* harmless data (such as the load should get their own calls)
|
|
|
|
*/
|
|
|
|
if (mp->mp_effuid != 0)
|
|
|
|
{
|
|
|
|
printf("PM: unauthorized call of do_getsysinfo by proc %d '%s'\n",
|
|
|
|
mp->mp_endpoint, mp->mp_name);
|
|
|
|
sig_proc(mp, SIGEMT);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
|
2005-06-06 15:51:50 +02:00
|
|
|
switch(m_in.info_what) {
|
|
|
|
case SI_KINFO: /* kernel info is obtained via PM */
|
|
|
|
sys_getkinfo(&kinfo);
|
|
|
|
src_addr = (vir_bytes) &kinfo;
|
|
|
|
len = sizeof(struct kinfo);
|
|
|
|
break;
|
|
|
|
case SI_PROC_ADDR: /* get address of PM process table */
|
|
|
|
proc_addr = &mproc[0];
|
|
|
|
src_addr = (vir_bytes) &proc_addr;
|
|
|
|
len = sizeof(struct mproc *);
|
|
|
|
break;
|
2005-06-07 16:43:35 +02:00
|
|
|
case SI_PROC_TAB: /* copy entire process table */
|
|
|
|
src_addr = (vir_bytes) mproc;
|
|
|
|
len = sizeof(struct mproc) * NR_PROCS;
|
|
|
|
break;
|
2006-03-16 10:33:35 +01:00
|
|
|
case SI_KPROC_TAB: /* copy entire process table */
|
|
|
|
if((r=sys_getproctab(proctab)) != OK)
|
|
|
|
return r;
|
|
|
|
src_addr = (vir_bytes) proctab;
|
|
|
|
len = sizeof(proctab);
|
|
|
|
break;
|
2005-11-14 16:50:46 +01:00
|
|
|
case SI_LOADINFO: /* loadinfo is obtained via PM */
|
|
|
|
sys_getloadinfo(&loadinfo);
|
|
|
|
src_addr = (vir_bytes) &loadinfo;
|
|
|
|
len = sizeof(struct loadinfo);
|
|
|
|
break;
|
2006-07-10 14:44:43 +02:00
|
|
|
#if ENABLE_SYSCALL_STATS
|
|
|
|
case SI_CALL_STATS:
|
|
|
|
src_addr = (vir_bytes) calls_stats;
|
|
|
|
len = sizeof(calls_stats);
|
|
|
|
break;
|
|
|
|
#endif
|
2005-06-06 15:51:50 +02:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
dst_addr = (vir_bytes) m_in.info_where;
|
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 (OK != (s=sys_datacopy(SELF, src_addr, who_e, dst_addr, len)))
|
2005-06-06 15:51:50 +02:00
|
|
|
return(s);
|
2005-05-03 17:35:52 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2006-07-27 18:23:01 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_getsysinfo_up *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_getsysinfo_up()
|
|
|
|
{
|
|
|
|
vir_bytes src_addr, dst_addr;
|
|
|
|
struct loadinfo loadinfo;
|
|
|
|
size_t len, real_len;
|
2007-02-16 16:55:20 +01:00
|
|
|
int s;
|
2006-07-27 18:23:01 +02:00
|
|
|
|
|
|
|
switch(m_in.SIU_WHAT) {
|
|
|
|
case SIU_LOADINFO: /* loadinfo is obtained via PM */
|
|
|
|
sys_getloadinfo(&loadinfo);
|
|
|
|
src_addr = (vir_bytes) &loadinfo;
|
|
|
|
real_len = sizeof(struct loadinfo);
|
|
|
|
break;
|
2008-12-11 15:49:17 +01:00
|
|
|
case SIU_SYSTEMHZ:
|
|
|
|
src_addr = (vir_bytes) &system_hz;
|
|
|
|
real_len = sizeof(system_hz);
|
|
|
|
break;
|
2006-07-27 18:23:01 +02:00
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Let application know what the length was. */
|
|
|
|
len = real_len;
|
|
|
|
if(len > m_in.SIU_LEN)
|
|
|
|
len = m_in.SIU_LEN;
|
|
|
|
|
|
|
|
dst_addr = (vir_bytes) m_in.SIU_WHERE;
|
|
|
|
if (OK != (s=sys_datacopy(SELF, src_addr, who_e, dst_addr, len)))
|
|
|
|
return(s);
|
|
|
|
return(real_len);
|
|
|
|
}
|
|
|
|
|
2005-06-06 15:51:50 +02:00
|
|
|
/*===========================================================================*
|
2005-09-11 18:45:46 +02:00
|
|
|
* do_getprocnr *
|
2005-06-06 15:51:50 +02:00
|
|
|
*===========================================================================*/
|
2005-05-19 11:38:29 +02:00
|
|
|
PUBLIC int do_getprocnr()
|
|
|
|
{
|
2005-06-02 14:43:21 +02:00
|
|
|
register struct mproc *rmp;
|
2005-06-20 11:35:23 +02:00
|
|
|
static char search_key[PROC_NAME_LEN+1];
|
2005-06-02 14:43:21 +02:00
|
|
|
int key_len;
|
|
|
|
int s;
|
|
|
|
|
2006-05-19 14:19:37 +02:00
|
|
|
/* This call should be moved to DS. */
|
|
|
|
if (mp->mp_effuid != 0)
|
|
|
|
{
|
|
|
|
printf("PM: unauthorized call of do_procstat by proc %d\n",
|
|
|
|
mp->mp_endpoint);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
|
|
|
printf("PM: do_getprocnr(%d) call from endpoint %d, %s\n",
|
|
|
|
m_in.pid, mp->mp_endpoint, mp->mp_name);
|
|
|
|
#endif
|
2007-08-07 14:28:42 +02:00
|
|
|
|
2005-10-12 17:07:38 +02:00
|
|
|
if (m_in.pid >= 0) { /* lookup process by pid */
|
2005-08-02 17:29:17 +02:00
|
|
|
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
|
|
|
if ((rmp->mp_flags & IN_USE) && (rmp->mp_pid==m_in.pid)) {
|
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
|
|
|
mp->mp_reply.endpt = rmp->mp_endpoint;
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
|
|
|
printf("PM: pid result: %d\n", rmp->mp_endpoint);
|
|
|
|
#endif
|
2005-08-02 17:29:17 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(ESRCH);
|
2005-10-12 17:07:38 +02:00
|
|
|
} else if (m_in.namelen > 0) { /* lookup process by name */
|
2005-06-20 11:35:23 +02:00
|
|
|
key_len = MIN(m_in.namelen, PROC_NAME_LEN);
|
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 (OK != (s=sys_datacopy(who_e, (vir_bytes) m_in.addr,
|
2005-06-02 14:43:21 +02:00
|
|
|
SELF, (vir_bytes) search_key, key_len)))
|
|
|
|
return(s);
|
|
|
|
search_key[key_len] = '\0'; /* terminate for safety */
|
|
|
|
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
2005-10-17 15:20:07 +02:00
|
|
|
if (((rmp->mp_flags & (IN_USE | ZOMBIE)) == IN_USE) &&
|
2005-06-02 14:43:21 +02:00
|
|
|
strncmp(rmp->mp_name, search_key, key_len)==0) {
|
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
|
|
|
mp->mp_reply.endpt = rmp->mp_endpoint;
|
2008-11-19 13:26:10 +01:00
|
|
|
printf("PM: name %s result: %d\n", search_key,
|
|
|
|
rmp->mp_endpoint);
|
2005-06-02 14:43:21 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
printf("PM: name %s result: ESRCH\n", search_key);
|
2005-06-02 14:43:21 +02:00
|
|
|
return(ESRCH);
|
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
|
|
|
} else { /* return own/parent process number */
|
2008-11-19 13:26:10 +01:00
|
|
|
#if 0
|
|
|
|
printf("PM: endpt result: %d\n", mp->mp_reply.endpt);
|
|
|
|
#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
|
|
|
mp->mp_reply.endpt = who_e;
|
|
|
|
mp->mp_reply.pendpt = mproc[mp->mp_parent].mp_endpoint;
|
2005-06-02 14:43:21 +02:00
|
|
|
}
|
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
|
|
|
|
2005-05-19 11:38:29 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2007-04-27 14:21:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_getpuid *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int do_getpuid()
|
|
|
|
{
|
|
|
|
register struct mproc *rmp;
|
|
|
|
endpoint_t ep;
|
|
|
|
|
|
|
|
/* This call should be moved to DS. */
|
|
|
|
if (mp->mp_effuid != 0)
|
|
|
|
{
|
|
|
|
printf("PM: unauthorized call of do_getpuid by proc %d\n",
|
|
|
|
mp->mp_endpoint);
|
|
|
|
return EPERM;
|
|
|
|
}
|
|
|
|
|
|
|
|
ep= m_in.endpt;
|
|
|
|
|
|
|
|
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
|
|
|
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
|
|
|
|
mp->mp_reply.reply_res2 = rmp->mp_effuid;
|
|
|
|
return(rmp->mp_realuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process not found */
|
|
|
|
return(ESRCH);
|
|
|
|
}
|
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_reboot *
|
|
|
|
*===========================================================================*/
|
2005-05-03 17:35:52 +02:00
|
|
|
PUBLIC int do_reboot()
|
|
|
|
{
|
2006-05-11 16:57:23 +02:00
|
|
|
int r;
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
/* Check permission to abort the system. */
|
2005-06-24 18:21:21 +02:00
|
|
|
if (mp->mp_effuid != SUPER_USER) return(EPERM);
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
/* See how the system should be aborted. */
|
|
|
|
abort_flag = (unsigned) m_in.reboot_flag;
|
|
|
|
if (abort_flag >= RBT_INVALID) return(EINVAL);
|
2006-03-13 11:36:52 +01:00
|
|
|
if (RBT_MONITOR == abort_flag) {
|
2006-03-13 14:21:13 +01:00
|
|
|
int r;
|
|
|
|
if(m_in.reboot_strlen >= sizeof(monitor_code))
|
|
|
|
return EINVAL;
|
|
|
|
if((r = sys_datacopy(who_e, (vir_bytes) m_in.reboot_code,
|
|
|
|
SELF, (vir_bytes) monitor_code, m_in.reboot_strlen)) != OK)
|
|
|
|
return r;
|
|
|
|
monitor_code[m_in.reboot_strlen] = '\0';
|
2005-05-03 17:35:52 +02:00
|
|
|
}
|
2006-05-11 16:57:23 +02:00
|
|
|
else
|
|
|
|
monitor_code[0] = '\0';
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2005-10-21 13:10:16 +02:00
|
|
|
/* Order matters here. When FS is told to reboot, it exits all its
|
|
|
|
* processes, and then would be confused if they're exited again by
|
2006-03-10 17:10:05 +01:00
|
|
|
* SIGKILL. So first kill, then reboot.
|
2005-10-21 13:10:16 +02:00
|
|
|
*/
|
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
check_sig(-1, SIGKILL); /* kill all users except init */
|
|
|
|
sys_nice(INIT_PROC_NR, PRIO_STOP); /* stop init, but keep it around */
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
report_reboot= 1;
|
|
|
|
r= notify(FS_PROC_NR);
|
|
|
|
if (r != OK) panic("pm", "do_reboot: unable to notify FS", r);
|
|
|
|
|
2006-03-10 17:10:05 +01:00
|
|
|
return(SUSPEND); /* don't reply to caller */
|
2005-05-03 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_getsetpriority *
|
|
|
|
*===========================================================================*/
|
2005-07-01 19:58:29 +02:00
|
|
|
PUBLIC int do_getsetpriority()
|
|
|
|
{
|
|
|
|
int arg_which, arg_who, arg_pri;
|
|
|
|
int rmp_nr;
|
|
|
|
struct mproc *rmp;
|
|
|
|
|
|
|
|
arg_which = m_in.m1_i1;
|
|
|
|
arg_who = m_in.m1_i2;
|
|
|
|
arg_pri = m_in.m1_i3; /* for SETPRIORITY */
|
|
|
|
|
|
|
|
/* Code common to GETPRIORITY and SETPRIORITY. */
|
|
|
|
|
|
|
|
/* Only support PRIO_PROCESS for now. */
|
2005-09-11 18:45:46 +02:00
|
|
|
if (arg_which != PRIO_PROCESS)
|
2005-07-19 14:11:11 +02:00
|
|
|
return(EINVAL);
|
2005-07-01 19:58:29 +02:00
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
if (arg_who == 0)
|
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
|
|
|
rmp_nr = who_p;
|
2005-07-01 19:58:29 +02:00
|
|
|
else
|
2005-09-11 18:45:46 +02:00
|
|
|
if ((rmp_nr = proc_from_pid(arg_who)) < 0)
|
2005-07-19 14:11:11 +02:00
|
|
|
return(ESRCH);
|
2005-07-01 19:58:29 +02:00
|
|
|
|
|
|
|
rmp = &mproc[rmp_nr];
|
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
if (mp->mp_effuid != SUPER_USER &&
|
2005-07-01 19:58:29 +02:00
|
|
|
mp->mp_effuid != rmp->mp_effuid && mp->mp_effuid != rmp->mp_realuid)
|
|
|
|
return EPERM;
|
|
|
|
|
|
|
|
/* If GET, that's it. */
|
2005-09-11 18:45:46 +02:00
|
|
|
if (call_nr == GETPRIORITY) {
|
2005-07-19 14:11:11 +02:00
|
|
|
return(rmp->mp_nice - PRIO_MIN);
|
2005-07-01 19:58:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Only root is allowed to reduce the nice level. */
|
2005-09-11 18:45:46 +02:00
|
|
|
if (rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
|
2005-07-19 14:11:11 +02:00
|
|
|
return(EACCES);
|
|
|
|
|
2005-07-01 19:58:29 +02:00
|
|
|
/* We're SET, and it's allowed. Do it and tell kernel. */
|
|
|
|
rmp->mp_nice = arg_pri;
|
2006-03-16 10:33:35 +01:00
|
|
|
return sys_nice(rmp->mp_endpoint, arg_pri);
|
2005-07-01 19:58:29 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 18:45:46 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_svrctl *
|
|
|
|
*===========================================================================*/
|
2005-05-03 17:35:52 +02:00
|
|
|
PUBLIC int do_svrctl()
|
|
|
|
{
|
|
|
|
int s, req;
|
|
|
|
vir_bytes ptr;
|
2005-07-22 20:29:58 +02:00
|
|
|
#define MAX_LOCAL_PARAMS 2
|
|
|
|
static struct {
|
|
|
|
char name[30];
|
|
|
|
char value[30];
|
|
|
|
} local_param_overrides[MAX_LOCAL_PARAMS];
|
|
|
|
static int local_params = 0;
|
|
|
|
|
2005-05-03 17:35:52 +02:00
|
|
|
req = m_in.svrctl_req;
|
|
|
|
ptr = (vir_bytes) m_in.svrctl_argp;
|
|
|
|
|
2005-08-03 18:58:22 +02:00
|
|
|
/* Is the request indeed for the MM? */
|
|
|
|
if (((req >> 8) & 0xFF) != 'M') return(EINVAL);
|
2005-05-03 17:35:52 +02:00
|
|
|
|
2005-05-13 10:57:08 +02:00
|
|
|
/* Control operations local to the PM. */
|
2005-05-03 17:35:52 +02:00
|
|
|
switch(req) {
|
2005-07-22 20:29:58 +02:00
|
|
|
case MMSETPARAM:
|
2005-05-03 17:35:52 +02:00
|
|
|
case MMGETPARAM: {
|
|
|
|
struct sysgetenv sysgetenv;
|
|
|
|
char search_key[64];
|
|
|
|
char *val_start;
|
|
|
|
size_t val_len;
|
|
|
|
size_t copy_len;
|
|
|
|
|
2005-05-13 10:57:08 +02:00
|
|
|
/* Copy sysgetenv structure to PM. */
|
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 (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv,
|
2005-05-03 17:35:52 +02:00
|
|
|
sizeof(sysgetenv)) != OK) return(EFAULT);
|
|
|
|
|
2005-07-22 20:29:58 +02:00
|
|
|
/* Set a param override? */
|
2005-09-11 18:45:46 +02:00
|
|
|
if (req == MMSETPARAM) {
|
|
|
|
if (local_params >= MAX_LOCAL_PARAMS) return ENOSPC;
|
|
|
|
if (sysgetenv.keylen <= 0
|
2005-08-29 18:47:18 +02:00
|
|
|
|| sysgetenv.keylen >=
|
|
|
|
sizeof(local_param_overrides[local_params].name)
|
|
|
|
|| sysgetenv.vallen <= 0
|
|
|
|
|| sysgetenv.vallen >=
|
|
|
|
sizeof(local_param_overrides[local_params].value))
|
|
|
|
return EINVAL;
|
2005-07-22 20:29:58 +02:00
|
|
|
|
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_datacopy(who_e, (vir_bytes) sysgetenv.key,
|
2005-08-29 18:47:18 +02:00
|
|
|
SELF, (vir_bytes) local_param_overrides[local_params].name,
|
|
|
|
sysgetenv.keylen)) != OK)
|
|
|
|
return s;
|
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_datacopy(who_e, (vir_bytes) sysgetenv.val,
|
2005-08-29 18:47:18 +02:00
|
|
|
SELF, (vir_bytes) local_param_overrides[local_params].value,
|
2008-11-19 13:26:10 +01:00
|
|
|
sysgetenv.vallen)) != OK)
|
2005-08-29 18:47:18 +02:00
|
|
|
return s;
|
|
|
|
local_param_overrides[local_params].name[sysgetenv.keylen] = '\0';
|
|
|
|
local_param_overrides[local_params].value[sysgetenv.vallen] = '\0';
|
|
|
|
|
|
|
|
local_params++;
|
|
|
|
|
|
|
|
return OK;
|
2005-07-22 20:29:58 +02:00
|
|
|
}
|
|
|
|
|
2005-05-03 17:35:52 +02:00
|
|
|
if (sysgetenv.keylen == 0) { /* copy all parameters */
|
|
|
|
val_start = monitor_params;
|
|
|
|
val_len = sizeof(monitor_params);
|
|
|
|
}
|
|
|
|
else { /* lookup value for key */
|
2005-07-22 20:29:58 +02:00
|
|
|
int p;
|
2005-05-03 17:35:52 +02:00
|
|
|
/* Try to get a copy of the requested key. */
|
|
|
|
if (sysgetenv.keylen > sizeof(search_key)) return(EINVAL);
|
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_datacopy(who_e, (vir_bytes) sysgetenv.key,
|
2005-05-03 17:35:52 +02:00
|
|
|
SELF, (vir_bytes) search_key, sysgetenv.keylen)) != OK)
|
|
|
|
return(s);
|
|
|
|
|
2005-07-22 20:29:58 +02:00
|
|
|
/* Make sure key is null-terminated and lookup value.
|
|
|
|
* First check local overrides.
|
|
|
|
*/
|
2005-05-03 17:35:52 +02:00
|
|
|
search_key[sysgetenv.keylen-1]= '\0';
|
2005-07-22 20:29:58 +02:00
|
|
|
for(p = 0; p < local_params; p++) {
|
2005-09-11 18:45:46 +02:00
|
|
|
if (!strcmp(search_key, local_param_overrides[p].name)) {
|
2005-07-22 20:29:58 +02:00
|
|
|
val_start = local_param_overrides[p].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-09-11 18:45:46 +02:00
|
|
|
if (p >= local_params && (val_start = find_param(search_key)) == NULL)
|
2005-05-03 17:35:52 +02:00
|
|
|
return(ESRCH);
|
|
|
|
val_len = strlen(val_start) + 1;
|
|
|
|
}
|
|
|
|
|
2005-06-20 11:35:23 +02:00
|
|
|
/* See if it fits in the client's buffer. */
|
|
|
|
if (val_len > sysgetenv.vallen)
|
|
|
|
return E2BIG;
|
|
|
|
|
2005-05-03 17:35:52 +02:00
|
|
|
/* Value found, make the actual copy (as far as possible). */
|
2005-06-20 11:35:23 +02:00
|
|
|
copy_len = MIN(val_len, sysgetenv.vallen);
|
2005-05-03 17:35:52 +02:00
|
|
|
if ((s=sys_datacopy(SELF, (vir_bytes) val_start,
|
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
|
|
|
who_e, (vir_bytes) sysgetenv.val, copy_len)) != OK)
|
2005-05-03 17:35:52 +02:00
|
|
|
return(s);
|
|
|
|
|
2005-06-20 11:35:23 +02:00
|
|
|
return OK;
|
2005-05-03 17:35:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
}
|
2006-06-30 16:36:11 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* _brk *
|
|
|
|
*===========================================================================*/
|
|
|
|
|
|
|
|
extern char *_brksize;
|
|
|
|
PUBLIC int brk(brk_addr)
|
|
|
|
char *brk_addr;
|
|
|
|
{
|
2008-11-19 13:26:10 +01:00
|
|
|
int r;
|
2006-06-30 16:36:11 +02:00
|
|
|
/* PM wants to call brk() itself. */
|
2008-11-19 13:26:10 +01:00
|
|
|
if((r=vm_brk(PM_PROC_NR, brk_addr)) != OK) {
|
|
|
|
#if 0
|
|
|
|
printf("PM: own brk(%p) failed: vm_brk() returned %d\n",
|
|
|
|
brk_addr, r);
|
|
|
|
#endif
|
2006-06-30 16:36:11 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
_brksize = brk_addr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|