This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / fcntl.c
index 305abb4..2676d70 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/vs_limit.h>
 
 #include <asm/poll.h>
 #include <asm/siginfo.h>
@@ -107,6 +108,8 @@ repeat:
        error = -EMFILE;
        if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out;
+       if (!vx_files_avail(1))
+               goto out;
 
        error = expand_files(files, newfd);
        if (error < 0)
@@ -139,6 +142,7 @@ static int dupfd(struct file *file, unsigned int start)
                FD_SET(fd, files->open_fds);
                FD_CLR(fd, files->close_on_exec);
                spin_unlock(&files->file_lock);
+               vx_openfd_inc(fd);
                fd_install(fd, file);
        } else {
                spin_unlock(&files->file_lock);
@@ -186,6 +190,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
        FD_SET(newfd, files->open_fds);
        FD_CLR(newfd, files->close_on_exec);
        spin_unlock(&files->file_lock);
+       vx_openfd_inc(newfd);
 
        if (tofree)
                filp_close(tofree, files);
@@ -239,11 +244,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
                                return -EINVAL;
        }
 
-       if (filp->f_op && filp->f_op->check_flags)
-               error = filp->f_op->check_flags(arg);
-       if (error)
-               return error;
-
        lock_kernel();
        if ((arg ^ filp->f_flags) & FASYNC) {
                if (filp->f_op && filp->f_op->fasync) {
@@ -292,8 +292,8 @@ void f_delown(struct file *filp)
 
 EXPORT_SYMBOL(f_delown);
 
-static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
-               struct file *filp)
+long generic_file_fcntl(int fd, unsigned int cmd,
+                       unsigned long arg, struct file *filp)
 {
        long err = -EINVAL;
 
@@ -361,6 +361,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
        }
        return err;
 }
+EXPORT_SYMBOL(generic_file_fcntl);
+
+static long do_fcntl(int fd, unsigned int cmd,
+                       unsigned long arg, struct file *filp)
+{
+       if (filp->f_op && filp->f_op->fcntl)
+               return filp->f_op->fcntl(fd, cmd, arg, filp);
+       return generic_file_fcntl(fd, cmd, arg, filp);
+}
 
 asmlinkage long sys_fcntl(int fd, unsigned int cmd, unsigned long arg)
 {