Merge branch 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[linux-drm-fsl-dcu.git] / arch / um / drivers / chan_user.c
index 5d50d4a44abf4879220e045b9eaecf0d48d8f9d7..13f0bf852b2a195e8b15ceab084c51e6153ad3eb 100644 (file)
@@ -9,11 +9,11 @@
 #include <termios.h>
 #include <string.h>
 #include <signal.h>
+#include <sched.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include "kern_util.h"
-#include "user_util.h"
 #include "chan_user.h"
 #include "user.h"
 #include "os.h"
@@ -73,7 +73,6 @@ static void winch_handler(int sig)
 struct winch_data {
        int pty_fd;
        int pipe_fd;
-       int close_me;
 };
 
 static int winch_thread(void *arg)
@@ -84,7 +83,6 @@ static int winch_thread(void *arg)
        int count, err;
        char c = 1;
 
-       os_close_file(data->close_me);
        pty_fd = data->pty_fd;
        pipe_fd = data->pipe_fd;
        count = os_write_file(pipe_fd, &c, sizeof(c));
@@ -121,7 +119,7 @@ static int winch_thread(void *arg)
        /* These are synchronization calls between various UML threads on the
         * host - since they are not different kernel threads, we cannot use
         * kernel semaphores. We don't use SysV semaphores because they are
-        * persistant. */
+        * persistent. */
        count = os_read_file(pipe_fd, &c, sizeof(c));
        if(count != sizeof(c))
                printk("winch_thread : failed to read synchronization byte, "
@@ -153,15 +151,16 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
        }
 
        data = ((struct winch_data) { .pty_fd           = fd,
-                                     .pipe_fd          = fds[1],
-                                     .close_me         = fds[0] } );
-       err = run_helper_thread(winch_thread, &data, 0, &stack, 0);
+                                     .pipe_fd          = fds[1] } );
+       /* CLONE_FILES so this thread doesn't hold open files which are open
+        * now, but later closed.  This is a problem with /dev/net/tun.
+        */
+       err = run_helper_thread(winch_thread, &data, CLONE_FILES, &stack, 0);
        if(err < 0){
-               printk("fork of winch_thread failed - errno = %d\n", errno);
+               printk("fork of winch_thread failed - errno = %d\n", -err);
                goto out_close;
        }
 
-       os_close_file(fds[1]);
        *fd_out = fds[0];
        n = os_read_file(fds[0], &c, sizeof(c));
        if(n != sizeof(c)){
@@ -169,13 +168,12 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
                printk("read failed, err = %d\n", -n);
                printk("fd %d will not support SIGWINCH\n", fd);
                 err = -EINVAL;
-               goto out_close1;
+               goto out_close;
        }
        return err ;
 
  out_close:
        os_close_file(fds[1]);
- out_close1:
        os_close_file(fds[0]);
  out:
        return err;
@@ -205,14 +203,3 @@ void register_winch(int fd, struct tty_struct *tty)
                }
        }
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */