Message type for PM_{KILL,SIGACTION}

Change-Id: I7fac9a894e319671e12bfa7430984ca1cf24da33
This commit is contained in:
Lionel Sambuc 2014-05-13 19:02:12 +02:00
parent dbfa59164b
commit b90d99dab3
5 changed files with 26 additions and 21 deletions

View file

@ -61,13 +61,6 @@
#define NR_PM_CALLS 48 /* highest number from base plus one */ #define NR_PM_CALLS 48 /* highest number from base plus one */
/* Field names for the kill(2), srv_kill(2), and sigaction(2) calls. */
#define PM_SIG_PID m1_i1 /* pid_t */
#define PM_SIG_NR m1_i2 /* int */
#define PM_SIG_ACT m1_p1 /* const struct sigaction * */
#define PM_SIG_OACT m1_p2 /* struct sigaction * */
#define PM_SIG_RET m1_p3 /* int (*)(void) */
/*===========================================================================* /*===========================================================================*
* Calls to VFS * * Calls to VFS *
*===========================================================================*/ *===========================================================================*/

View file

@ -251,6 +251,17 @@ typedef struct {
} mess_lc_pm_sysuname; } mess_lc_pm_sysuname;
_ASSERT_MSG_SIZE(mess_lc_pm_sysuname); _ASSERT_MSG_SIZE(mess_lc_pm_sysuname);
typedef struct {
pid_t pid;
int nr;
vir_bytes act; /* const struct sigaction * */
vir_bytes oact; /* struct sigaction * */
vir_bytes ret; /* int (*)(void) */
uint8_t padding[36];
} mess_lc_pm_sig;
_ASSERT_MSG_SIZE(mess_lc_pm_sig);
typedef struct { typedef struct {
int how; int how;
vir_bytes ctx; vir_bytes ctx;
@ -1117,6 +1128,7 @@ typedef struct {
mess_lc_pm_reboot m_lc_pm_reboot; mess_lc_pm_reboot m_lc_pm_reboot;
mess_lc_pm_setgid m_lc_pm_setgid; mess_lc_pm_setgid m_lc_pm_setgid;
mess_lc_pm_setuid m_lc_pm_setuid; mess_lc_pm_setuid m_lc_pm_setuid;
mess_lc_pm_sig m_lc_pm_sig;
mess_lc_pm_sigset m_lc_pm_sigset; mess_lc_pm_sigset m_lc_pm_sigset;
mess_lc_pm_sysuname m_lc_pm_sysuname; mess_lc_pm_sysuname m_lc_pm_sysuname;
mess_lc_pm_time m_lc_pm_time; mess_lc_pm_time m_lc_pm_time;

View file

@ -16,7 +16,7 @@ int sig; /* signal number */
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.PM_SIG_PID = proc; m.m_lc_pm_sig.pid = proc;
m.PM_SIG_NR = sig; m.m_lc_pm_sig.nr = sig;
return(_syscall(PM_PROC_NR, PM_KILL, &m)); return(_syscall(PM_PROC_NR, PM_KILL, &m));
} }

View file

@ -12,10 +12,10 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
message m; message m;
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.PM_SIG_NR = sig; m.m_lc_pm_sig.nr = sig;
m.PM_SIG_ACT = (char *) __UNCONST(act); m.m_lc_pm_sig.act = (vir_bytes)act;
m.PM_SIG_OACT = (char *) oact; m.m_lc_pm_sig.oact = (vir_bytes)oact;
m.PM_SIG_RET = (char *) __sigreturn; m.m_lc_pm_sig.ret = (vir_bytes)__sigreturn;
return(_syscall(PM_PROC_NR, PM_SIGACTION, &m)); return(_syscall(PM_PROC_NR, PM_SIGACTION, &m));
} }

View file

@ -45,23 +45,23 @@ int do_sigaction(void)
assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED)));
sig_nr = m_in.PM_SIG_NR; sig_nr = m_in.m_lc_pm_sig.nr;
if (sig_nr == SIGKILL) return(OK); if (sig_nr == SIGKILL) return(OK);
if (sig_nr < 1 || sig_nr >= _NSIG) return(EINVAL); if (sig_nr < 1 || sig_nr >= _NSIG) return(EINVAL);
svp = &mp->mp_sigact[sig_nr]; svp = &mp->mp_sigact[sig_nr];
if ((struct sigaction *) m_in.PM_SIG_OACT != (struct sigaction *) NULL) { if (m_in.m_lc_pm_sig.oact != 0) {
r = sys_datacopy(PM_PROC_NR,(vir_bytes) svp, who_e, r = sys_datacopy(PM_PROC_NR,(vir_bytes) svp, who_e,
(vir_bytes) m_in.PM_SIG_OACT, (phys_bytes) sizeof(svec)); m_in.m_lc_pm_sig.oact, (phys_bytes) sizeof(svec));
if (r != OK) return(r); if (r != OK) return(r);
} }
if ((struct sigaction *) m_in.PM_SIG_ACT == (struct sigaction *) NULL) if (m_in.m_lc_pm_sig.act == 0)
return(OK); return(OK);
/* Read in the sigaction structure. */ /* Read in the sigaction structure. */
r = sys_datacopy(who_e, (vir_bytes) m_in.PM_SIG_ACT, r = sys_datacopy(who_e, m_in.m_lc_pm_sig.act, PM_PROC_NR, (vir_bytes) &svec,
PM_PROC_NR, (vir_bytes) &svec, (phys_bytes) sizeof(svec)); (phys_bytes) sizeof(svec));
if (r != OK) return(r); if (r != OK) return(r);
if (svec.sa_handler == SIG_IGN) { if (svec.sa_handler == SIG_IGN) {
@ -81,7 +81,7 @@ int do_sigaction(void)
sigdelset(&svec.sa_mask, SIGSTOP); sigdelset(&svec.sa_mask, SIGSTOP);
mp->mp_sigact[sig_nr].sa_mask = svec.sa_mask; mp->mp_sigact[sig_nr].sa_mask = svec.sa_mask;
mp->mp_sigact[sig_nr].sa_flags = svec.sa_flags; mp->mp_sigact[sig_nr].sa_flags = svec.sa_flags;
mp->mp_sigreturn = (vir_bytes) m_in.PM_SIG_RET; mp->mp_sigreturn = m_in.m_lc_pm_sig.ret;
return(OK); return(OK);
} }
@ -198,7 +198,7 @@ int do_kill(void)
{ {
/* Perform the kill(pid, signo) system call. */ /* Perform the kill(pid, signo) system call. */
return check_sig(m_in.PM_SIG_PID, m_in.PM_SIG_NR, FALSE /* ksig */); return check_sig(m_in.m_lc_pm_sig.pid, m_in.m_lc_pm_sig.nr, FALSE /* ksig */);
} }
/*===========================================================================* /*===========================================================================*