summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 15:31:15 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 15:31:15 +0000
commitdf597928134e9f5da5c93e49ebddd53ff910681e (patch)
tree9370d52f57663bc953d18388d8663b4e99e0ebd2 /sys/compat
parent4e3ae75e5e77d5560431b0ad264a03842743c117 (diff)
downloadFreeBSD-src-df597928134e9f5da5c93e49ebddd53ff910681e.zip
FreeBSD-src-df597928134e9f5da5c93e49ebddd53ff910681e.tar.gz
MFC r283396:
Implement rt_sigqueueinfo() system call.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_signal.c55
-rw-r--r--sys/compat/linux/linux_signal.h1
2 files changed, 56 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 4e0a84b..c12e87c 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -751,3 +751,58 @@ siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig)
break;
}
}
+
+void
+lsiginfo_to_ksiginfo(const l_siginfo_t *lsi, ksiginfo_t *ksi, int sig)
+{
+
+ ksi->ksi_signo = sig;
+ ksi->ksi_code = lsi->lsi_code; /* XXX. Convert. */
+ ksi->ksi_pid = lsi->lsi_pid;
+ ksi->ksi_uid = lsi->lsi_uid;
+ ksi->ksi_status = lsi->lsi_status;
+ ksi->ksi_addr = PTRIN(lsi->lsi_addr);
+ ksi->ksi_info.si_value.sival_int = lsi->lsi_int;
+}
+
+int
+linux_rt_sigqueueinfo(struct thread *td, struct linux_rt_sigqueueinfo_args *args)
+{
+ l_siginfo_t linfo;
+ struct proc *p;
+ ksiginfo_t ksi;
+ int error;
+ int sig;
+
+ if (!LINUX_SIG_VALID(args->sig))
+ return (EINVAL);
+
+ error = copyin(args->info, &linfo, sizeof(linfo));
+ if (error != 0)
+ return (error);
+
+ if (linfo.lsi_code >= 0)
+ return (EPERM);
+
+ if (args->sig > 0 && args->sig <= LINUX_SIGTBLSZ)
+ sig = linux_to_bsd_signal[_SIG_IDX(args->sig)];
+ else
+ sig = args->sig;
+
+ error = ESRCH;
+ if ((p = pfind(args->pid)) != NULL ||
+ (p = zpfind(args->pid)) != NULL) {
+ error = p_cansignal(td, p, sig);
+ if (error != 0) {
+ PROC_UNLOCK(p);
+ return (error);
+ }
+
+ ksiginfo_init(&ksi);
+ lsiginfo_to_ksiginfo(&linfo, &ksi, sig);
+ error = tdsendsignal(p, NULL, sig, &ksi);
+ PROC_UNLOCK(p);
+ }
+
+ return (error);
+}
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
index d80578e..21b557a 100644
--- a/sys/compat/linux/linux_signal.h
+++ b/sys/compat/linux/linux_signal.h
@@ -51,6 +51,7 @@ void bsd_to_linux_sigset(sigset_t *, l_sigset_t *);
int linux_do_sigaction(struct thread *, int, l_sigaction_t *, l_sigaction_t *);
void ksiginfo_to_lsiginfo(const ksiginfo_t *ksi, l_siginfo_t *lsi, l_int sig);
void siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig);
+void lsiginfo_to_ksiginfo(const l_siginfo_t *lsi, ksiginfo_t *ksi, int sig);
#define LINUX_SIG_VALID(sig) ((sig) <= LINUX_NSIG && (sig) > 0)
OpenPOWER on IntegriCloud