From: davi@haxent.com.br
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Davide Libenzi <davidel@xmailserver.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 05/12] pollfs: pollable signal compat code
Date: Sun, 01 Apr 2007 12:58:15 -0300 [thread overview]
Message-ID: <20070401160311.016729000@haxent.com.br> (raw)
In-Reply-To: <20070401155810.277757000@haxent.com.br>
[-- Attachment #1: pollfs-signal-compat.patch --]
[-- Type: text/plain, Size: 2727 bytes --]
Compat handlers for the pollable signal operations.
Signed-off-by: Davi E. M. Arnaut <davi@haxent.com.br>
---
Index: linux-2.6/fs/pollfs/signal.c
===================================================================
--- linux-2.6.orig/fs/pollfs/signal.c
+++ linux-2.6/fs/pollfs/signal.c
@@ -16,6 +16,7 @@
#include <linux/poll.h>
#include <linux/pollfs_fs.h>
#include <linux/signal.h>
+#include <linux/compat.h>
struct pfs_signal {
sigset_t set;
@@ -48,6 +49,24 @@ static ssize_t read(struct pfs_signal *e
return 0;
}
+#ifdef CONFIG_COMPAT
+static ssize_t compat_read(struct pfs_signal *evs,
+ struct compat_siginfo __user *infoup)
+{
+ int signo;
+ siginfo_t info;
+
+ signo = dequeue_signal_lock(evs->task, &evs->set, &info);
+ if (!signo)
+ return -EAGAIN;
+
+ if (copy_siginfo_to_user32(infoup, &info))
+ return -EFAULT;
+
+ return 0;
+}
+#endif
+
static ssize_t write(struct pfs_signal *evs, const sigset_t __user *uset)
{
sigset_t set;
@@ -65,6 +84,28 @@ static ssize_t write(struct pfs_signal *
return 0;
}
+#ifdef CONFIG_COMPAT
+static ssize_t compat_write(struct pfs_signal *evs,
+ const compat_sigset_t __user *uset)
+{
+ sigset_t set;
+ compat_sigset_t cset;
+
+ if (copy_from_user(&cset, uset, sizeof(compat_sigset_t)))
+ return -EFAULT;
+
+ sigset_from_compat(&set, &cset);
+ sigset_adjust(&set);
+
+ spin_lock_irq(&evs->lock);
+ sigemptyset(&evs->set);
+ sigorsets(&evs->set, &evs->set, &set);
+ spin_unlock_irq(&evs->lock);
+
+ return 0;
+}
+#endif
+
static int poll(struct pfs_signal *evs)
{
int ret = 0;
@@ -142,3 +183,47 @@ asmlinkage long sys_plsignal(const sigse
return error;
}
+
+#ifdef CONFIG_COMPAT
+static const struct pfs_operations compat_signal_ops = {
+ /* .read = PFS_READ(compat_read, struct pfs_signal, struct compat_siginfo), */
+ .write = PFS_WRITE(compat_write, struct pfs_signal, compat_sigset_t),
+ .poll = PFS_POLL(poll, struct pfs_signal),
+ .release = PFS_RELEASE(release, struct pfs_signal),
+ /* .rsize = sizeof(compat_siginfo_t), */
+ .wsize = sizeof(sigset_t)
+};
+
+asmlinkage long compat_plsignal(const compat_sigset_t __user *uset)
+{
+ long error;
+ compat_sigset_t cset;
+ struct pfs_signal *evs;
+
+ if (copy_from_user(&cset, uset, sizeof(compat_sigset_t)))
+ return -EFAULT;
+
+ evs = kmalloc(sizeof(*evs), GFP_KERNEL);
+ if (!evs)
+ return -ENOMEM;
+
+ spin_lock_init(&evs->lock);
+
+ evs->task = current;
+ get_task_struct(current);
+
+ sigset_from_compat(&evs->set, &cset);
+ sigset_adjust(&evs->set);
+
+ evs->file.data = evs;
+ evs->file.fops = &compat_signal_ops;
+ evs->file.wait = &evs->task->sigwait;
+
+ error = pfs_open(&evs->file);
+
+ if (error < 0)
+ release(evs);
+
+ return error;
+}
+#endif
--
next prev parent reply other threads:[~2007-04-01 16:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-01 15:58 [patch 00/12] pollfs: a naive filesystem for pollable objects davi
2007-04-01 15:58 ` [patch 01/12] pollfs: kernel-side API header davi
2007-04-01 15:58 ` [patch 02/12] pollfs: file system operations davi
2007-04-01 15:58 ` [patch 03/12] pollfs: asynchronously wait for a signal davi
2007-04-01 15:58 ` [patch 04/12] pollfs: pollable signal davi
2007-04-01 15:58 ` davi [this message]
2007-04-01 15:58 ` [patch 06/12] pollfs: pollable hrtimers davi
2007-04-01 15:58 ` [patch 07/12] pollfs: asynchronous futex wait davi
2007-04-01 15:58 ` [patch 08/12] pollfs: pollable futex davi
2007-04-01 15:58 ` [patch 09/12] pollfs: check if a AIO event ring is empty davi
2007-04-01 15:58 ` [patch 10/12] pollfs: pollable aio davi
2007-04-01 15:58 ` [patch 11/12] pollfs: asynchronous workqueue davi
2007-04-01 15:58 ` [patch 12/12] pollfs: pollable fsync davi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070401160311.016729000@haxent.com.br \
--to=davi@haxent.com.br \
--cc=akpm@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®