PM/VFS protocol: prefix with VFS_PM_

These calls are sent to VFS, and thus should be prefixed with VFS_.
Clean up the protocol and PM's main function a bit.

Since the protocol is substantially big and different from normal VFS
requests, this protocol retains its own numbering range for now.

Change-Id: Ia62104b5c5c929ed787144816d2e4cc70bed3b0b
This commit is contained in:
David van Moolenbroek 2013-10-28 22:19:40 +01:00 committed by Lionel Sambuc
parent 44d3230e40
commit 87c599da2d
12 changed files with 226 additions and 242 deletions

View file

@ -701,75 +701,78 @@
* Messages used between PM and VFS *
*===========================================================================*/
#define PM_RQ_BASE 0x900
#define PM_RS_BASE 0x980
#define VFS_PM_RQ_BASE 0x900
#define VFS_PM_RS_BASE 0x980
/* Requests from PM to VFS */
#define PM_INIT (PM_RQ_BASE + 0) /* Process table exchange */
#define PM_SETUID (PM_RQ_BASE + 1) /* Set new user ID */
#define PM_SETGID (PM_RQ_BASE + 2) /* Set group ID */
#define PM_SETSID (PM_RQ_BASE + 3) /* Set session leader */
#define PM_EXIT (PM_RQ_BASE + 4) /* Process exits */
#define PM_DUMPCORE (PM_RQ_BASE + 5) /* Process is to dump core */
#define PM_EXEC (PM_RQ_BASE + 6) /* Forwarded exec call */
#define PM_FORK (PM_RQ_BASE + 7) /* Newly forked process */
#define PM_SRV_FORK (PM_RQ_BASE + 8) /* fork for system services */
#define PM_UNPAUSE (PM_RQ_BASE + 9) /* Interrupt process call */
#define PM_REBOOT (PM_RQ_BASE + 10) /* System reboot */
#define PM_SETGROUPS (PM_RQ_BASE + 11) /* Tell VFS about setgroups */
#define IS_VFS_PM_RQ(type) (((type) & ~0x7f) == VFS_PM_RQ_BASE)
#define IS_VFS_PM_RS(type) (((type) & ~0x7f) == VFS_PM_RS_BASE)
/* Requests from PM to VFS. */
#define VFS_PM_INIT (VFS_PM_RQ_BASE + 0) /* Process table exchange */
#define VFS_PM_SETUID (VFS_PM_RQ_BASE + 1) /* Set new user ID */
#define VFS_PM_SETGID (VFS_PM_RQ_BASE + 2) /* Set group ID */
#define VFS_PM_SETSID (VFS_PM_RQ_BASE + 3) /* Set session leader */
#define VFS_PM_EXIT (VFS_PM_RQ_BASE + 4) /* Process exits */
#define VFS_PM_DUMPCORE (VFS_PM_RQ_BASE + 5) /* Process is to dump core */
#define VFS_PM_EXEC (VFS_PM_RQ_BASE + 6) /* Forwarded exec call */
#define VFS_PM_FORK (VFS_PM_RQ_BASE + 7) /* Newly forked process */
#define VFS_PM_SRV_FORK (VFS_PM_RQ_BASE + 8) /* fork for system services */
#define VFS_PM_UNPAUSE (VFS_PM_RQ_BASE + 9) /* Interrupt process call */
#define VFS_PM_REBOOT (VFS_PM_RQ_BASE + 10) /* System reboot */
#define VFS_PM_SETGROUPS (VFS_PM_RQ_BASE + 11) /* Set groups */
/* Replies from VFS to PM */
#define PM_SETUID_REPLY (PM_RS_BASE + 1)
#define PM_SETGID_REPLY (PM_RS_BASE + 2)
#define PM_SETSID_REPLY (PM_RS_BASE + 3)
#define PM_EXIT_REPLY (PM_RS_BASE + 4)
#define PM_CORE_REPLY (PM_RS_BASE + 5)
#define PM_EXEC_REPLY (PM_RS_BASE + 6)
#define PM_FORK_REPLY (PM_RS_BASE + 7)
#define PM_SRV_FORK_REPLY (PM_RS_BASE + 8)
#define PM_UNPAUSE_REPLY (PM_RS_BASE + 9)
#define PM_REBOOT_REPLY (PM_RS_BASE + 10)
#define PM_SETGROUPS_REPLY (PM_RS_BASE + 11)
#define VFS_PM_SETUID_REPLY (VFS_PM_RS_BASE + 1)
#define VFS_PM_SETGID_REPLY (VFS_PM_RS_BASE + 2)
#define VFS_PM_SETSID_REPLY (VFS_PM_RS_BASE + 3)
#define VFS_PM_EXIT_REPLY (VFS_PM_RS_BASE + 4)
#define VFS_PM_CORE_REPLY (VFS_PM_RS_BASE + 5)
#define VFS_PM_EXEC_REPLY (VFS_PM_RS_BASE + 6)
#define VFS_PM_FORK_REPLY (VFS_PM_RS_BASE + 7)
#define VFS_PM_SRV_FORK_REPLY (VFS_PM_RS_BASE + 8)
#define VFS_PM_UNPAUSE_REPLY (VFS_PM_RS_BASE + 9)
#define VFS_PM_REBOOT_REPLY (VFS_PM_RS_BASE + 10)
#define VFS_PM_SETGROUPS_REPLY (VFS_PM_RS_BASE + 11)
/* Standard parameters for all requests and replies, except PM_REBOOT */
# define PM_PROC m7_i1 /* process endpoint */
# define VFS_PM_ENDPT m7_i1 /* process endpoint */
/* Additional parameters for PM_INIT */
# define PM_SLOT m7_i2 /* process slot number */
# define PM_PID m7_i3 /* process pid */
# define VFS_PM_SLOT m7_i2 /* process slot number */
# define VFS_PM_PID m7_i3 /* process pid */
/* Additional parameters for PM_SETUID and PM_SETGID */
# define PM_EID m7_i2 /* effective user/group id */
# define PM_RID m7_i3 /* real user/group id */
# define VFS_PM_EID m7_i2 /* effective user/group id */
# define VFS_PM_RID m7_i3 /* real user/group id */
/* Additional parameter for PM_SETGROUPS */
# define PM_GROUP_NO m7_i2 /* number of groups */
# define PM_GROUP_ADDR m7_p1 /* struct holding group data */
# define VFS_PM_GROUP_NO m7_i2 /* number of groups */
# define VFS_PM_GROUP_ADDR m7_p1 /* struct holding group data */
/* Additional parameters for PM_EXEC */
# define PM_PATH m7_p1 /* executable */
# define PM_PATH_LEN m7_i2 /* length of path including
# define VFS_PM_PATH m7_p1 /* executable */
# define VFS_PM_PATH_LEN m7_i2 /* length of path including
* terminating null character
*/
# define PM_FRAME m7_p2 /* arguments and environment */
# define PM_FRAME_LEN m7_i3 /* size of frame */
# define PM_EXECFLAGS m7_i4 /* PMEXEC_FLAGS */
# define PM_PS_STR m7_i5 /* ps_strings pointer */
# define VFS_PM_FRAME m7_p2 /* arguments and environment */
# define VFS_PM_FRAME_LEN m7_i3 /* size of frame */
# define VFS_PM_EXECFLAGS m7_i4 /* PMEXEC_FLAGS */
# define VFS_PM_PS_STR m7_i5 /* ps_strings pointer */
/* Additional parameters for PM_EXEC_REPLY and PM_CORE_REPLY */
# define PM_STATUS m7_i2 /* OK or failure */
# define PM_PC m7_p1 /* program counter */
# define PM_NEWSP m7_p2 /* possibly-changed stack ptr */
# define PM_NEWPS_STR m7_i5 /* possibly-changed ps_strings ptr */
# define VFS_PM_STATUS m7_i2 /* OK or failure */
# define VFS_PM_PC m7_p1 /* program counter */
# define VFS_PM_NEWSP m7_p2 /* possibly-changed stack ptr */
# define VFS_PM_NEWPS_STR m7_i5 /* possibly-changed ps_strings ptr */
/* Additional parameters for PM_FORK and PM_SRV_FORK */
# define PM_PPROC m7_i2 /* parent process endpoint */
# define PM_CPID m7_i3 /* child pid */
# define PM_REUID m7_i4 /* real and effective uid */
# define PM_REGID m7_i5 /* real and effective gid */
# define VFS_PM_PENDPT m7_i2 /* parent process endpoint */
# define VFS_PM_CPID m7_i3 /* child pid */
# define VFS_PM_REUID m7_i4 /* real and effective uid */
# define VFS_PM_REGID m7_i5 /* real and effective gid */
/* Additional parameters for PM_DUMPCORE */
# define PM_TERM_SIG m7_i2 /* process's termination signal */
# define VFS_PM_TERM_SIG m7_i2 /* process's termination signal */
/* Parameters for the EXEC_NEWMEM call */
#define EXC_NM_PROC m1_i1 /* process that needs new map */

View file

@ -11,7 +11,6 @@
#include "pm.h"
#include <signal.h>
#include <sys/time.h>
#include <string.h>
#include <minix/com.h>
#include "mproc.h"
#include "param.h"

View file

@ -24,7 +24,6 @@
#include <minix/com.h>
#include <minix/vm.h>
#include <signal.h>
#include <string.h>
#include <libexec.h>
#include <sys/ptrace.h>
#include "mproc.h"
@ -41,14 +40,15 @@ int do_exec()
message m;
/* Forward call to VFS */
m.m_type = PM_EXEC;
m.PM_PROC = mp->mp_endpoint;
m.PM_PATH = m_in.exec_name;
m.PM_PATH_LEN = m_in.exec_len;
m.PM_FRAME = m_in.frame_ptr;
m.PM_FRAME_LEN = m_in.msg_frame_len;
m.PM_EXECFLAGS = m_in.PMEXEC_FLAGS;
m.PM_PS_STR = (vir_bytes)m_in.m1_p4; /* ps_strings pointer into the frame. */
memset(&m, 0, sizeof(m));
m.m_type = VFS_PM_EXEC;
m.VFS_PM_ENDPT = mp->mp_endpoint;
m.VFS_PM_PATH = m_in.exec_name;
m.VFS_PM_PATH_LEN = m_in.exec_len;
m.VFS_PM_FRAME = m_in.frame_ptr;
m.VFS_PM_FRAME_LEN = m_in.msg_frame_len;
m.VFS_PM_EXECFLAGS = m_in.PMEXEC_FLAGS;
m.VFS_PM_PS_STR = (vir_bytes) m_in.m1_p4; /* strings ptr into frame */
tell_vfs(mp, &m);

View file

@ -113,12 +113,13 @@ int do_fork()
new_pid = get_free_pid();
rmc->mp_pid = new_pid; /* assign pid to child */
m.m_type = PM_FORK;
m.PM_PROC = rmc->mp_endpoint;
m.PM_PPROC = rmp->mp_endpoint;
m.PM_CPID = rmc->mp_pid;
m.PM_REUID = -1; /* Not used by PM_FORK */
m.PM_REGID = -1; /* Not used by PM_FORK */
memset(&m, 0, sizeof(m));
m.m_type = VFS_PM_FORK;
m.VFS_PM_ENDPT = rmc->mp_endpoint;
m.VFS_PM_PENDPT = rmp->mp_endpoint;
m.VFS_PM_CPID = rmc->mp_pid;
m.VFS_PM_REUID = -1; /* Not used by VFS_PM_FORK */
m.VFS_PM_REGID = -1; /* Not used by VFS_PM_FORK */
tell_vfs(rmc, &m);
@ -204,12 +205,13 @@ int do_srv_fork()
new_pid = get_free_pid();
rmc->mp_pid = new_pid; /* assign pid to child */
m.m_type = PM_SRV_FORK;
m.PM_PROC = rmc->mp_endpoint;
m.PM_PPROC = rmp->mp_endpoint;
m.PM_CPID = rmc->mp_pid;
m.PM_REUID = m_in.m1_i1;
m.PM_REGID = m_in.m1_i2;
memset(&m, 0, sizeof(m));
m.m_type = VFS_PM_SRV_FORK;
m.VFS_PM_ENDPT = rmc->mp_endpoint;
m.VFS_PM_PENDPT = rmp->mp_endpoint;
m.VFS_PM_CPID = rmc->mp_pid;
m.VFS_PM_REUID = m_in.m1_i1;
m.VFS_PM_REGID = m_in.m1_i2;
tell_vfs(rmc, &m);
@ -321,12 +323,13 @@ int dump_core; /* flag indicating whether to dump core */
}
/* Tell VFS about the exiting process. */
m.m_type = dump_core ? PM_DUMPCORE : PM_EXIT;
m.PM_PROC = rmp->mp_endpoint;
memset(&m, 0, sizeof(m));
m.m_type = dump_core ? VFS_PM_DUMPCORE : VFS_PM_EXIT;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
if (dump_core) {
m.PM_TERM_SIG = rmp->mp_sigstatus;
m.PM_PATH = rmp->mp_name;
m.VFS_PM_TERM_SIG = rmp->mp_sigstatus;
m.VFS_PM_PATH = rmp->mp_name;
}
tell_vfs(rmp, &m);

View file

@ -102,6 +102,8 @@ int do_set()
int r, i;
int ngroups;
memset(&m, 0, sizeof(m));
switch(call_nr) {
case SETUID:
case SETEUID:
@ -111,10 +113,10 @@ int do_set()
if(call_nr == SETUID) rmp->mp_realuid = (uid_t) m_in.usr_id;
rmp->mp_effuid = (uid_t) m_in.usr_id;
m.m_type = PM_SETUID;
m.PM_PROC = rmp->mp_endpoint;
m.PM_EID = rmp->mp_effuid;
m.PM_RID = rmp->mp_realuid;
m.m_type = VFS_PM_SETUID;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
m.VFS_PM_EID = rmp->mp_effuid;
m.VFS_PM_RID = rmp->mp_realuid;
break;
@ -126,10 +128,10 @@ int do_set()
if(call_nr == SETGID) rmp->mp_realgid = (gid_t) m_in.grp_id;
rmp->mp_effgid = (gid_t) m_in.grp_id;
m.m_type = PM_SETGID;
m.PM_PROC = rmp->mp_endpoint;
m.PM_EID = rmp->mp_effgid;
m.PM_RID = rmp->mp_realgid;
m.m_type = VFS_PM_SETGID;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
m.VFS_PM_EID = rmp->mp_effgid;
m.VFS_PM_RID = rmp->mp_realgid;
break;
case SETGROUPS:
@ -159,18 +161,18 @@ int do_set()
}
rmp->mp_ngroups = ngroups;
m.m_type = PM_SETGROUPS;
m.PM_PROC = rmp->mp_endpoint;
m.PM_GROUP_NO = rmp->mp_ngroups;
m.PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
m.m_type = VFS_PM_SETGROUPS;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
m.VFS_PM_GROUP_NO = rmp->mp_ngroups;
m.VFS_PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
break;
case SETSID:
if (rmp->mp_procgrp == rmp->mp_pid) return(EPERM);
rmp->mp_procgrp = rmp->mp_pid;
m.m_type = PM_SETSID;
m.PM_PROC = rmp->mp_endpoint;
m.m_type = VFS_PM_SETSID;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
break;

View file

@ -23,7 +23,6 @@
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <string.h>
#include <machine/archtypes.h>
#include <env.h>
#include <assert.h>
@ -54,60 +53,38 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info);
int main()
{
/* Main routine of the process manager. */
int result;
int ipc_status, result;
/* SEF local startup. */
sef_local_startup();
/* This is PM's main loop- get work and do it, forever and forever. */
while (TRUE) {
int ipc_status;
/* Wait for the next message and extract useful information from it. */
/* Wait for the next message. */
if (sef_receive_status(ANY, &m_in, &ipc_status) != OK)
panic("PM sef_receive_status error");
who_e = m_in.m_source; /* who sent the message */
if(pm_isokendpt(who_e, &who_p) != OK)
panic("PM got message from invalid endpoint: %d", who_e);
call_nr = m_in.m_type; /* system call number */
/* Process slot of caller. Misuse PM's own process slot if the kernel is
* calling. This can happen in case of synchronous alarms (CLOCK) or or
* event like pending kernel signals (SYSTEM).
*/
mp = &mproc[who_p < 0 ? PM_PROC_NR : who_p];
if(who_p >= 0 && mp->mp_endpoint != who_e) {
panic("PM endpoint number out of sync with source: %d",
mp->mp_endpoint);
}
/* Drop delayed calls from exiting processes. */
if (mp->mp_flags & EXITING)
continue;
/* Check for system notifications first. Special cases. */
if (is_ipc_notify(ipc_status)) {
if (who_p == CLOCK) {
if (_ENDPOINT_P(m_in.m_source) == CLOCK)
expire_timers(m_in.NOTIFY_TIMESTAMP);
}
/* done, continue */
continue;
}
switch(call_nr)
{
case PM_SETUID_REPLY:
case PM_SETGID_REPLY:
case PM_SETSID_REPLY:
case PM_EXEC_REPLY:
case PM_EXIT_REPLY:
case PM_CORE_REPLY:
case PM_FORK_REPLY:
case PM_SRV_FORK_REPLY:
case PM_UNPAUSE_REPLY:
case PM_REBOOT_REPLY:
case PM_SETGROUPS_REPLY:
/* Extract useful information from the message. */
who_e = m_in.m_source; /* who sent the message */
if (pm_isokendpt(who_e, &who_p) != OK)
panic("PM got message from invalid endpoint: %d", who_e);
mp = &mproc[who_p]; /* process slot of caller */
call_nr = m_in.m_type; /* system call number */
/* Drop delayed calls from exiting processes. */
if (mp->mp_flags & EXITING)
continue;
if (IS_VFS_PM_RS(call_nr)) {
if (who_e == VFS_PROC_NR)
{
handle_vfs_reply();
@ -115,11 +92,8 @@ int main()
}
else
result= ENOSYS;
break;
default:
/* Else, if the system call number is valid, perform the
* call.
*/
} else {
/* If the system call number is valid, perform the call. */
if ((unsigned) call_nr >= NCALLS) {
result = ENOSYS;
} else {
@ -130,7 +104,6 @@ int main()
result = (*call_vec[call_nr])();
}
break;
}
/* Send reply. */
@ -259,17 +232,20 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
rmp->mp_endpoint = ip->endpoint;
/* Tell VFS about this system process. */
mess.m_type = PM_INIT;
mess.PM_SLOT = ip->proc_nr;
mess.PM_PID = rmp->mp_pid;
mess.PM_PROC = rmp->mp_endpoint;
memset(&mess, 0, sizeof(mess));
mess.m_type = VFS_PM_INIT;
mess.VFS_PM_SLOT = ip->proc_nr;
mess.VFS_PM_PID = rmp->mp_pid;
mess.VFS_PM_ENDPT = rmp->mp_endpoint;
if (OK != (s=send(VFS_PROC_NR, &mess)))
panic("can't sync up with VFS: %d", s);
}
}
/* Tell VFS that no more system processes follow and synchronize. */
mess.PR_ENDPT = NONE;
memset(&mess, 0, sizeof(mess));
mess.m_type = VFS_PM_INIT;
mess.VFS_PM_ENDPT = NONE;
if (sendrec(VFS_PROC_NR, &mess) != OK || mess.m_type != OK)
panic("can't sync up with VFS");
@ -338,10 +314,10 @@ static void handle_vfs_reply()
endpoint_t proc_e;
int r, proc_n, new_parent;
/* PM_REBOOT is the only request not associated with a process.
/* VFS_PM_REBOOT is the only request not associated with a process.
* Handle its reply first.
*/
if (call_nr == PM_REBOOT_REPLY) {
if (call_nr == VFS_PM_REBOOT_REPLY) {
/* Ask the kernel to abort. All system services, including
* the PM, will get a HARD_STOP notification. Await the
* notification in the main loop.
@ -352,7 +328,7 @@ static void handle_vfs_reply()
}
/* Get the process associated with this call */
proc_e = m_in.PM_PROC;
proc_e = m_in.VFS_PM_ENDPT;
if (pm_isokendpt(proc_e, &proc_n) != OK) {
panic("handle_vfs_reply: got bad endpoint from VFS: %d", proc_e);
@ -372,40 +348,41 @@ static void handle_vfs_reply()
/* Call-specific handler code */
switch (call_nr) {
case PM_SETUID_REPLY:
case PM_SETGID_REPLY:
case PM_SETGROUPS_REPLY:
case VFS_PM_SETUID_REPLY:
case VFS_PM_SETGID_REPLY:
case VFS_PM_SETGROUPS_REPLY:
/* Wake up the original caller */
reply(rmp-mproc, OK);
break;
case PM_SETSID_REPLY:
case VFS_PM_SETSID_REPLY:
/* Wake up the original caller */
reply(rmp-mproc, rmp->mp_procgrp);
break;
case PM_EXEC_REPLY:
exec_restart(rmp, m_in.PM_STATUS, (vir_bytes)m_in.PM_PC,
(vir_bytes)m_in.PM_NEWSP, (vir_bytes)m_in.PM_NEWPS_STR);
case VFS_PM_EXEC_REPLY:
exec_restart(rmp, m_in.VFS_PM_STATUS, (vir_bytes)m_in.VFS_PM_PC,
(vir_bytes)m_in.VFS_PM_NEWSP,
(vir_bytes)m_in.VFS_PM_NEWPS_STR);
break;
case PM_EXIT_REPLY:
case VFS_PM_EXIT_REPLY:
exit_restart(rmp, FALSE /*dump_core*/);
break;
case PM_CORE_REPLY:
if (m_in.PM_STATUS == OK)
case VFS_PM_CORE_REPLY:
if (m_in.VFS_PM_STATUS == OK)
rmp->mp_sigstatus |= DUMPED;
exit_restart(rmp, TRUE /*dump_core*/);
break;
case PM_FORK_REPLY:
case VFS_PM_FORK_REPLY:
/* Schedule the newly created process ... */
r = OK;
if (rmp->mp_scheduler != KERNEL && rmp->mp_scheduler != NONE) {
@ -434,12 +411,12 @@ static void handle_vfs_reply()
break;
case PM_SRV_FORK_REPLY:
case VFS_PM_SRV_FORK_REPLY:
/* Nothing to do */
break;
case PM_UNPAUSE_REPLY:
case VFS_PM_UNPAUSE_REPLY:
/* The target process must always be stopped while unpausing; otherwise
* it could just end up pausing itself on a new call afterwards.
*/

View file

@ -24,7 +24,6 @@
#include <minix/type.h>
#include <minix/vm.h>
#include <minix/ds.h>
#include <string.h>
#include <machine/archtypes.h>
#include <lib.h>
#include <assert.h>
@ -239,7 +238,8 @@ int do_reboot()
sys_stop(INIT_PROC_NR); /* stop init, but keep it around */
/* Tell VFS to reboot */
m.m_type = PM_REBOOT;
memset(&m, 0, sizeof(m));
m.m_type = VFS_PM_REBOOT;
tell_vfs(&mproc[VFS_PROC_NR], &m);

View file

@ -11,6 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <minix/syslib.h>
#include <minix/sysutil.h>
#include <minix/timers.h>

View file

@ -27,7 +27,6 @@
#include <minix/vm.h>
#include <signal.h>
#include <sys/resource.h>
#include <string.h>
#include <assert.h>
#include "mproc.h"
#include "param.h"
@ -293,7 +292,7 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
int proc_nr;
pid_t proc_id, id;
if(pm_isokendpt(proc_nr_e, &proc_nr) != OK || proc_nr < 0) {
if(pm_isokendpt(proc_nr_e, &proc_nr) != OK) {
printf("PM: process_ksig: %d?? not ok\n", proc_nr_e);
return EDEADEPT; /* process is gone. */
}
@ -747,8 +746,9 @@ struct mproc *rmp; /* which process */
if (!(rmp->mp_flags & PROC_STOPPED) && !stop_proc(rmp, TRUE /*may_delay*/))
return FALSE;
m.m_type = PM_UNPAUSE;
m.PM_PROC = rmp->mp_endpoint;
memset(&m, 0, sizeof(m));
m.m_type = VFS_PM_UNPAUSE;
m.VFS_PM_ENDPT = rmp->mp_endpoint;
tell_vfs(rmp, &m);

View file

@ -23,7 +23,6 @@
#include <minix/config.h>
#include <minix/timers.h>
#include <string.h>
#include <machine/archtypes.h>
#include "kernel/const.h"
#include "kernel/config.h"
@ -120,11 +119,11 @@ int nice_to_priority(int nice, unsigned* new_q)
int pm_isokendpt(int endpoint, int *proc)
{
*proc = _ENDPOINT_P(endpoint);
if(*proc < -NR_TASKS || *proc >= NR_PROCS)
if (*proc < 0 || *proc >= NR_PROCS)
return EINVAL;
if(*proc >= 0 && endpoint != mproc[*proc].mp_endpoint)
if (endpoint != mproc[*proc].mp_endpoint)
return EDEADEPT;
if(*proc >= 0 && !(mproc[*proc].mp_flags & IN_USE))
if (!(mproc[*proc].mp_flags & IN_USE))
return EDEADEPT;
return OK;
}

View file

@ -301,15 +301,15 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *info)
if ((s = sef_receive(PM_PROC_NR, &mess)) != OK)
panic("VFS: couldn't receive from PM: %d", s);
if (mess.m_type != PM_INIT)
if (mess.m_type != VFS_PM_INIT)
panic("unexpected message from PM: %d", mess.m_type);
if (NONE == mess.PM_PROC) break;
if (NONE == mess.VFS_PM_ENDPT) break;
rfp = &fproc[mess.PM_SLOT];
rfp = &fproc[mess.VFS_PM_SLOT];
rfp->fp_flags = FP_NOFLAGS;
rfp->fp_pid = mess.PM_PID;
rfp->fp_endpoint = mess.PM_PROC;
rfp->fp_pid = mess.VFS_PM_PID;
rfp->fp_endpoint = mess.VFS_PM_ENDPT;
rfp->fp_grant = GRANT_INVALID;
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
rfp->fp_realuid = (uid_t) SYS_UID;
@ -569,67 +569,67 @@ void service_pm_postponed(void)
memset(&m_out, 0, sizeof(m_out));
switch(job_call_nr) {
case PM_EXEC:
proc_e = job_m_in.PM_PROC;
exec_path = (vir_bytes)job_m_in.PM_PATH;
exec_path_len = (size_t)job_m_in.PM_PATH_LEN;
stack_frame = (vir_bytes)job_m_in.PM_FRAME;
stack_frame_len = (size_t)job_m_in.PM_FRAME_LEN;
ps_str = (vir_bytes)job_m_in.PM_PS_STR;
case VFS_PM_EXEC:
proc_e = job_m_in.VFS_PM_ENDPT;
exec_path = (vir_bytes) job_m_in.VFS_PM_PATH;
exec_path_len = (size_t) job_m_in.VFS_PM_PATH_LEN;
stack_frame = (vir_bytes) job_m_in.VFS_PM_FRAME;
stack_frame_len = (size_t) job_m_in.VFS_PM_FRAME_LEN;
ps_str = (vir_bytes) job_m_in.VFS_PM_PS_STR;
assert(proc_e == fp->fp_endpoint);
r = pm_exec(exec_path, exec_path_len, stack_frame, stack_frame_len,
&pc, &newsp, &ps_str, job_m_in.PM_EXECFLAGS);
&pc, &newsp, &ps_str, job_m_in.VFS_PM_EXECFLAGS);
/* Reply status to PM */
m_out.m_type = PM_EXEC_REPLY;
m_out.PM_PROC = proc_e;
m_out.PM_PC = (void *)pc;
m_out.PM_STATUS = r;
m_out.PM_NEWSP = (void *)newsp;
m_out.PM_NEWPS_STR = ps_str;
m_out.m_type = VFS_PM_EXEC_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
m_out.VFS_PM_PC = (void *) pc;
m_out.VFS_PM_STATUS = r;
m_out.VFS_PM_NEWSP = (void *) newsp;
m_out.VFS_PM_NEWPS_STR = ps_str;
break;
case PM_EXIT:
proc_e = job_m_in.PM_PROC;
case VFS_PM_EXIT:
proc_e = job_m_in.VFS_PM_ENDPT;
assert(proc_e == fp->fp_endpoint);
pm_exit();
/* Reply dummy status to PM for synchronization */
m_out.m_type = PM_EXIT_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_EXIT_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
break;
case PM_DUMPCORE:
proc_e = job_m_in.PM_PROC;
term_signal = job_m_in.PM_TERM_SIG;
core_path = (vir_bytes) job_m_in.PM_PATH;
case VFS_PM_DUMPCORE:
proc_e = job_m_in.VFS_PM_ENDPT;
term_signal = job_m_in.VFS_PM_TERM_SIG;
core_path = (vir_bytes) job_m_in.VFS_PM_PATH;
assert(proc_e == fp->fp_endpoint);
r = pm_dumpcore(term_signal, core_path);
/* Reply status to PM */
m_out.m_type = PM_CORE_REPLY;
m_out.PM_PROC = proc_e;
m_out.PM_STATUS = r;
m_out.m_type = VFS_PM_CORE_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
m_out.VFS_PM_STATUS = r;
break;
case PM_UNPAUSE:
proc_e = job_m_in.PM_PROC;
case VFS_PM_UNPAUSE:
proc_e = job_m_in.VFS_PM_ENDPT;
assert(proc_e == fp->fp_endpoint);
unpause();
m_out.m_type = PM_UNPAUSE_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_UNPAUSE_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
break;
@ -649,7 +649,7 @@ static void service_pm(void)
{
/* Process a request from PM. This function is called from the main thread, and
* may therefore not block. Any requests that may require blocking the calling
* thread must be executed in a separate thread. Aside from PM_REBOOT, all
* thread must be executed in a separate thread. Aside from VFS_PM_REBOOT, all
* requests from PM involve another, target process: for example, PM tells VFS
* that a process is performing a setuid() call. For some requests however,
* that other process may not be idle, and in that case VFS must serialize the
@ -665,56 +665,56 @@ static void service_pm(void)
memset(&m_out, 0, sizeof(m_out));
switch (call_nr) {
case PM_SETUID:
case VFS_PM_SETUID:
{
endpoint_t proc_e;
uid_t euid, ruid;
proc_e = m_in.PM_PROC;
euid = m_in.PM_EID;
ruid = m_in.PM_RID;
proc_e = m_in.VFS_PM_ENDPT;
euid = m_in.VFS_PM_EID;
ruid = m_in.VFS_PM_RID;
pm_setuid(proc_e, euid, ruid);
m_out.m_type = PM_SETUID_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_SETUID_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
}
break;
case PM_SETGID:
case VFS_PM_SETGID:
{
endpoint_t proc_e;
gid_t egid, rgid;
proc_e = m_in.PM_PROC;
egid = m_in.PM_EID;
rgid = m_in.PM_RID;
proc_e = m_in.VFS_PM_ENDPT;
egid = m_in.VFS_PM_EID;
rgid = m_in.VFS_PM_RID;
pm_setgid(proc_e, egid, rgid);
m_out.m_type = PM_SETGID_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_SETGID_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
}
break;
case PM_SETSID:
case VFS_PM_SETSID:
{
endpoint_t proc_e;
proc_e = m_in.PM_PROC;
proc_e = m_in.VFS_PM_ENDPT;
pm_setsid(proc_e);
m_out.m_type = PM_SETSID_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_SETSID_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
}
break;
case PM_EXEC:
case PM_EXIT:
case PM_DUMPCORE:
case PM_UNPAUSE:
case VFS_PM_EXEC:
case VFS_PM_EXIT:
case VFS_PM_DUMPCORE:
case VFS_PM_UNPAUSE:
{
endpoint_t proc_e = m_in.PM_PROC;
endpoint_t proc_e = m_in.VFS_PM_ENDPT;
if(isokendpt(proc_e, &slot) != OK) {
printf("VFS: proc ep %d not ok\n", proc_e);
@ -731,56 +731,56 @@ static void service_pm(void)
return;
}
case PM_FORK:
case PM_SRV_FORK:
case VFS_PM_FORK:
case VFS_PM_SRV_FORK:
{
endpoint_t pproc_e, proc_e;
pid_t child_pid;
uid_t reuid;
gid_t regid;
pproc_e = m_in.PM_PPROC;
proc_e = m_in.PM_PROC;
child_pid = m_in.PM_CPID;
reuid = m_in.PM_REUID;
regid = m_in.PM_REGID;
pproc_e = m_in.VFS_PM_PENDPT;
proc_e = m_in.VFS_PM_ENDPT;
child_pid = m_in.VFS_PM_CPID;
reuid = m_in.VFS_PM_REUID;
regid = m_in.VFS_PM_REGID;
pm_fork(pproc_e, proc_e, child_pid);
m_out.m_type = PM_FORK_REPLY;
m_out.m_type = VFS_PM_FORK_REPLY;
if (call_nr == PM_SRV_FORK) {
m_out.m_type = PM_SRV_FORK_REPLY;
if (call_nr == VFS_PM_SRV_FORK) {
m_out.m_type = VFS_PM_SRV_FORK_REPLY;
pm_setuid(proc_e, reuid, reuid);
pm_setgid(proc_e, regid, regid);
}
m_out.PM_PROC = proc_e;
m_out.VFS_PM_ENDPT = proc_e;
}
break;
case PM_SETGROUPS:
case VFS_PM_SETGROUPS:
{
endpoint_t proc_e;
int group_no;
gid_t *group_addr;
proc_e = m_in.PM_PROC;
group_no = m_in.PM_GROUP_NO;
group_addr = (gid_t *) m_in.PM_GROUP_ADDR;
proc_e = m_in.VFS_PM_ENDPT;
group_no = m_in.VFS_PM_GROUP_NO;
group_addr = (gid_t *) m_in.VFS_PM_GROUP_ADDR;
pm_setgroups(proc_e, group_no, group_addr);
m_out.m_type = PM_SETGROUPS_REPLY;
m_out.PM_PROC = proc_e;
m_out.m_type = VFS_PM_SETGROUPS_REPLY;
m_out.VFS_PM_ENDPT = proc_e;
}
break;
case PM_REBOOT:
case VFS_PM_REBOOT:
/* Reboot requests are not considered postponed PM work and are instead
* handled from a separate worker thread that is associated with PM's
* process. PM makes no regular VFS calls, and thus, from VFS's
* perspective, PM is always idle. Therefore, we can safely do this.
* We do assume that PM sends us only one PM_REBOOT message at once,
* or ever for that matter. :)
* We do assume that PM sends us only one VFS_PM_REBOOT message at
* once, or ever for that matter. :)
*/
worker_start(fproc_addr(PM_PROC_NR), pm_reboot, &m_in,
FALSE /*use_spare*/);

View file

@ -531,7 +531,7 @@ void pm_reboot()
/* Reply to PM for synchronization */
memset(&m_out, 0, sizeof(m_out));
m_out.m_type = PM_REBOOT_REPLY;
m_out.m_type = VFS_PM_REBOOT_REPLY;
if ((r = send(PM_PROC_NR, &m_out)) != OK)
panic("pm_reboot: send failed: %d", r);