LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch 5/13] signal/timer/event fds v6 - signalfd compat code ...
@ 2007-03-16  0:22 Davide Libenzi
       [not found] ` <200703172247.51602.arnd@arndb.de>
  0 siblings, 1 reply; 2+ messages in thread
From: Davide Libenzi @ 2007-03-16  0:22 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton, Linus Torvalds, Oleg Nesterov

This patch implement the necessary compat code for the signalfd system call.


Signed-off-by: Davide Libenzi <davidel@xmailserver.org>


- Davide



Index: linux-2.6.21-rc3.quilt/fs/compat.c
===================================================================
--- linux-2.6.21-rc3.quilt.orig/fs/compat.c	2007-02-04 10:44:54.000000000 -0800
+++ linux-2.6.21-rc3.quilt/fs/compat.c	2007-03-15 15:35:58.000000000 -0700
@@ -46,6 +46,7 @@
 #include <linux/rwsem.h>
 #include <linux/tsacct_kern.h>
 #include <linux/highmem.h>
+#include <linux/signal.h>
 #include <linux/poll.h>
 #include <linux/mm.h>
 
@@ -2235,3 +2236,24 @@
 	return sys_ni_syscall();
 }
 #endif
+
+asmlinkage long compat_sys_signalfd(int ufd,
+				    const compat_sigset_t __user *sigmask,
+				    compat_size_t sigsetsize)
+{
+	compat_sigset_t ss32;
+	sigset_t tmp;
+	sigset_t __user *ksigmask;
+
+	if (sigsetsize != sizeof(compat_sigset_t))
+		return -EINVAL;
+	if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
+		return -EFAULT;
+	sigset_from_compat(&tmp, &ss32);
+	ksigmask = compat_alloc_user_space(sizeof(sigset_t));
+	if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
+		return -EFAULT;
+
+	return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
+}
+


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch 5/13] signal/timer/event fds v6 - signalfd compat code ...
       [not found] ` <200703172247.51602.arnd@arndb.de>
@ 2007-03-18 20:42   ` Davide Libenzi
  0 siblings, 0 replies; 2+ messages in thread
From: Davide Libenzi @ 2007-03-18 20:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Kernel Mailing List, Andrew Morton, Linus Torvalds, Oleg Nesterov

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1345 bytes --]

On Sat, 17 Mar 2007, Arnd Bergmann wrote:

> On Friday 16 March 2007 01:22:15 Davide Libenzi wrote:
> > +asmlinkage long compat_sys_signalfd(int ufd,
> > +                                   const compat_sigset_t __user *sigmask,
> > +                                   compat_size_t sigsetsize)
> > +{
> > +       compat_sigset_t ss32;
> > +       sigset_t tmp;
> > +       sigset_t __user *ksigmask;
> > +
> > +       if (sigsetsize != sizeof(compat_sigset_t))
> > +               return -EINVAL;
> > +       if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
> > +               return -EFAULT;
> > +       sigset_from_compat(&tmp, &ss32);
> > +       ksigmask = compat_alloc_user_space(sizeof(sigset_t));
> > +       if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
> > +               return -EFAULT;
> > +
> > +       return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
> > +}
> 
> Doing the compat_alloc_user_space() magic obviously makes the 32 bit
> emulation code less efficient. How about having a
> 
> long do_signalfd(int ufd, const sigset_t *sigmask, size_t sigsetsize);
> 
> that is called directly by both sys_signalfd and compat_sys_signalfd?
> Same obviously applies also to do_timerfd.

Hmm,  copy_*_user (one or two moves) and compat_alloc_user_space are 
pretty fast...



- Davide


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-18 20:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-16  0:22 [patch 5/13] signal/timer/event fds v6 - signalfd compat code Davide Libenzi
     [not found] ` <200703172247.51602.arnd@arndb.de>
2007-03-18 20:42   ` Davide Libenzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).