vserver 1.9.3
[linux-2.6.git] / arch / um / kernel / irq_user.c
index 57fe9bb..38e66ac 100644 (file)
@@ -6,7 +6,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <string.h>
 #include <sys/poll.h>
@@ -49,7 +48,8 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
 
        if(smp_sigio_handler()) return;
        while(1){
-               if((n = poll(pollfds, pollfds_num, 0)) < 0){
+               n = poll(pollfds, pollfds_num, 0);
+               if(n < 0){
                        if(errno == EINTR) continue;
                        printk("sigio_handler : poll returned %d, "
                               "errno = %d\n", n, errno);
@@ -364,36 +364,47 @@ void deactivate_fd(int fd, int irqnum)
        irq_unlock(flags);
 }
 
-void forward_ipi(int fd, int pid)
+int deactivate_all_fds(void)
 {
-       if(fcntl(fd, F_SETOWN, pid) < 0){
-               int save_errno = errno;
-               if(fcntl(fd, F_GETOWN, 0) != pid){
-                       printk("forward_ipi: F_SETOWN failed, fd = %d, "
-                              "me = %d, target = %d, errno = %d\n", fd, 
-                              os_getpid(), pid, save_errno);
-               }
+       struct irq_fd *irq;
+       int err;
+
+       for(irq=active_fds;irq != NULL;irq = irq->next){
+               err = os_clear_fd_async(irq->fd);
+               if(err)
+                       return(err);
        }
+
+       return(0);
+}
+
+void forward_ipi(int fd, int pid)
+{
+       int err;
+
+       err = os_set_owner(fd, pid);
+       if(err < 0)
+               printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
+                      "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
 }
 
 void forward_interrupts(int pid)
 {
        struct irq_fd *irq;
        unsigned long flags;
+       int err;
 
        flags = irq_lock();
        for(irq=active_fds;irq != NULL;irq = irq->next){
-               if(fcntl(irq->fd, F_SETOWN, pid) < 0){
-                       int save_errno = errno;
-                       if(fcntl(irq->fd, F_GETOWN, 0) != pid){
-                               /* XXX Just remove the irq rather than
-                                * print out an infinite stream of these
-                                */
-                               printk("Failed to forward %d to pid %d, "
-                                      "errno = %d\n", irq->fd, pid, 
-                                      save_errno);
-                       }
+               err = os_set_owner(irq->fd, pid);
+               if(err < 0){
+                       /* XXX Just remove the irq rather than
+                        * print out an infinite stream of these
+                        */
+                       printk("Failed to forward %d to pid %d, err = %d\n",
+                              irq->fd, pid, -err);
                }
+
                irq->pid = pid;
        }
        irq_unlock(flags);