jbd: positively dispose the unmapped data buffers in journal_commit_transaction()
[pandora-kernel.git] / fs / fcntl.c
index bfd7765..9679fcb 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/fdtable.h>
 #include <linux/capability.h>
 #include <linux/dnotify.h>
-#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/security.h>
@@ -126,13 +125,16 @@ static int dupfd(struct file *file, unsigned int start, int cloexec)
        return fd;
 }
 
-asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
+asmlinkage long sys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
 {
        int err = -EBADF;
        struct file * file, *tofree;
        struct files_struct * files = current->files;
        struct fdtable *fdt;
 
+       if ((flags & ~O_CLOEXEC) != 0)
+               return -EINVAL;
+
        spin_lock(&files->file_lock);
        if (!(file = fcheck(oldfd)))
                goto out_unlock;
@@ -164,7 +166,10 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
 
        rcu_assign_pointer(fdt->fd[newfd], file);
        FD_SET(newfd, fdt->open_fds);
-       FD_CLR(newfd, fdt->close_on_exec);
+       if (flags & O_CLOEXEC)
+               FD_SET(newfd, fdt->close_on_exec);
+       else
+               FD_CLR(newfd, fdt->close_on_exec);
        spin_unlock(&files->file_lock);
 
        if (tofree)
@@ -182,6 +187,11 @@ out_fput:
        goto out;
 }
 
+asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
+{
+       return sys_dup3(oldfd, newfd, 0);
+}
+
 asmlinkage long sys_dup(unsigned int fildes)
 {
        int ret = -EBADF;
@@ -227,7 +237,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
        if (error)
                return error;
 
-       lock_kernel();
        if ((arg ^ filp->f_flags) & FASYNC) {
                if (filp->f_op && filp->f_op->fasync) {
                        error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
@@ -238,7 +247,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
 
        filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
  out:
-       unlock_kernel();
        return error;
 }