Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 15:11:32 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283396 - in head/sys: amd64/linux32 compat/linux i386/linux
Message-ID:  <201505241511.t4OFBW1c044455@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 24 15:11:32 2015
New Revision: 283396
URL: https://svnweb.freebsd.org/changeset/base/283396

Log:
  Implement rt_sigqueueinfo() system call.
  
  Differential Revision:	https://reviews.freebsd.org/D1047
  Reviewed by:	trasz

Modified:
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/linux/linux_signal.c
  head/sys/compat/linux/linux_signal.h
  head/sys/i386/linux/linux_dummy.c
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/linux32_dummy.c
==============================================================================
--- head/sys/amd64/linux32/linux32_dummy.c	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/amd64/linux32/linux32_dummy.c	Sun May 24 15:11:32 2015	(r283396)
@@ -61,7 +61,6 @@ DUMMY(bdflush);
 DUMMY(sysfs);
 DUMMY(query_module);
 DUMMY(nfsservctl);
-DUMMY(rt_sigqueueinfo);
 DUMMY(sendfile);
 DUMMY(setfsuid);
 DUMMY(setfsgid);

Modified: head/sys/amd64/linux32/syscalls.master
==============================================================================
--- head/sys/amd64/linux32/syscalls.master	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/amd64/linux32/syscalls.master	Sun May 24 15:11:32 2015	(r283396)
@@ -318,7 +318,8 @@
 				    l_siginfo_t *ptr, \
 				    struct l_timeval *timeout, \
 				    l_size_t sigsetsize); }
-178	AUE_NULL	STD	{ int linux_rt_sigqueueinfo(void); }
+178	AUE_NULL	STD	{ int linux_rt_sigqueueinfo(l_pid_t pid, l_int sig, \
+				    l_siginfo_t *info); }
 179	AUE_NULL	STD	{ int linux_rt_sigsuspend( \
 				    l_sigset_t *newset, \
 				    l_size_t sigsetsize); }

Modified: head/sys/compat/linux/linux_signal.c
==============================================================================
--- head/sys/compat/linux/linux_signal.c	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/compat/linux/linux_signal.c	Sun May 24 15:11:32 2015	(r283396)
@@ -751,3 +751,58 @@ siginfo_to_lsiginfo(const siginfo_t *si,
 		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);
+}

Modified: head/sys/compat/linux/linux_signal.h
==============================================================================
--- head/sys/compat/linux/linux_signal.h	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/compat/linux/linux_signal.h	Sun May 24 15:11:32 2015	(r283396)
@@ -51,6 +51,7 @@ void bsd_to_linux_sigset(sigset_t *, l_s
 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)
 

Modified: head/sys/i386/linux/linux_dummy.c
==============================================================================
--- head/sys/i386/linux/linux_dummy.c	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/i386/linux/linux_dummy.c	Sun May 24 15:11:32 2015	(r283396)
@@ -64,7 +64,6 @@ DUMMY(sysfs);
 DUMMY(vm86);
 DUMMY(query_module);
 DUMMY(nfsservctl);
-DUMMY(rt_sigqueueinfo);
 DUMMY(sendfile);		/* different semantics */
 DUMMY(setfsuid);
 DUMMY(setfsgid);

Modified: head/sys/i386/linux/syscalls.master
==============================================================================
--- head/sys/i386/linux/syscalls.master	Sun May 24 15:08:25 2015	(r283395)
+++ head/sys/i386/linux/syscalls.master	Sun May 24 15:11:32 2015	(r283396)
@@ -320,7 +320,8 @@
 				    l_siginfo_t *ptr, \
 				    struct l_timeval *timeout, \
 				    l_size_t sigsetsize); }
-178	AUE_NULL	STD	{ int linux_rt_sigqueueinfo(void); }
+178	AUE_NULL	STD	{ int linux_rt_sigqueueinfo(l_pid_t pid, l_int sig, \
+				    l_siginfo_t *info); }
 179	AUE_NULL	STD	{ int linux_rt_sigsuspend( \
 				    l_sigset_t *newset, \
 				    l_size_t sigsetsize); }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241511.t4OFBW1c044455>