Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Kernel v2.6.24-rc6 /fs/fcntl.c

Filename:/fs/fcntl.c
Lines Added:11
Lines Deleted:6
Also changed in: (Previous) 2.6.24-rc5  2.6.24-rc4  2.6.24-rc3  2.6.24-rc2  2.6.24-rc1  2.6.23-git19 
(Following) 2.6.24-rc7  2.6.24-rc8  2.6.24  2.6.24-git19  2.6.24-git20  2.6.24-git21 

Location
[  2.6.24-rc6
  [  fs
     o  fcntl.c

Patch

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 78b2ff0..8685263 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -18,6 +18,7 @@
 #include <linux/ptrace.h>
 #include <linux/signal.h>
 #include <linux/rcupdate.h>
+#include <linux/pid_namespace.h>
 
 #include <asm/poll.h>
 #include <asm/siginfo.h>
@@ -110,7 +111,7 @@ out:
    return error;
 }
 
-static int dupfd(struct file *file, unsigned int start)
+static int dupfd(struct file *file, unsigned int start, int cloexec)
 {
    struct files_struct * files = current->files;
    struct fdtable *fdt;
@@ -122,7 +123,10 @@ static int dupfd(struct file *file, unsigned int start)
       /* locate_fd() may have expanded fdtable, load the ptr */
       fdt = files_fdtable(files);
       FD_SET(fd, fdt->open_fds);
-      FD_CLR(fd, fdt->close_on_exec);
+      if (cloexec)
+         FD_SET(fd, fdt->close_on_exec);
+      else
+         FD_CLR(fd, fdt->close_on_exec);
       spin_unlock(&files->file_lock);
       fd_install(fd, file);
    } else {
@@ -195,7 +199,7 @@ asmlinkage long sys_dup(unsigned int fildes)
    struct file * file = fget(fildes);
 
    if (file)
-      ret = dupfd(file, 0);
+      ret = dupfd(file, 0, 0);
    return ret;
 }
 
@@ -289,7 +293,7 @@ int f_setown(struct file *filp, unsigned long arg, int force)
       who = -who;
    }
    rcu_read_lock();
-   pid = find_pid(who);
+   pid = find_vpid(who);
    result = __f_setown(filp, pid, type, force);
    rcu_read_unlock();
    return result;
@@ -305,7 +309,7 @@ pid_t f_getown(struct file *filp)
 {
    pid_t pid;
    read_lock(&filp->f_owner.lock);
-   pid = pid_nr(filp->f_owner.pid);
+   pid = pid_nr_ns(filp->f_owner.pid, current->nsproxy->pid_ns);
    if (filp->f_owner.pid_type == PIDTYPE_PGID)
       pid = -pid;
    read_unlock(&filp->f_owner.lock);
@@ -319,8 +323,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
 
    switch (cmd) {
    case F_DUPFD:
+   case F_DUPFD_CLOEXEC:
       get_file(filp);
-      err = dupfd(filp, arg);
+      err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC);
       break;
    case F_GETFD:
       err = get_close_on_exec(fd) ? FD_CLOEXEC : 0;


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.