This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / fcntl.c
index 5aca889..a769c01 100644 (file)
@@ -4,7 +4,6 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
-#include <linux/syscalls.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
@@ -15,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>
@@ -87,7 +87,7 @@ static int locate_fd(struct files_struct *files,
        int error;
 
        error = -EINVAL;
-       if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (orig_start >= current->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out;
 
 repeat:
@@ -106,7 +106,9 @@ repeat:
        }
        
        error = -EMFILE;
-       if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+               goto out;
+       if (!vx_files_avail(1))
                goto out;
 
        error = expand_files(files, newfd);
@@ -129,7 +131,7 @@ out:
        return error;
 }
 
-static int dupfd(struct file *file, unsigned int start)
+int dupfd(struct file *file, unsigned int start)
 {
        struct files_struct * files = current->files;
        int fd;
@@ -140,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);
@@ -149,6 +152,8 @@ static int dupfd(struct file *file, unsigned int start)
        return fd;
 }
 
+EXPORT_SYMBOL_GPL(dupfd);
+
 asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
 {
        int err = -EBADF;
@@ -162,7 +167,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
        if (newfd == oldfd)
                goto out_unlock;
        err = -EBADF;
-       if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out_unlock;
        get_file(file);                 /* We are now finished with oldfd */
 
@@ -187,6 +192,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);
@@ -361,7 +367,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
        return err;
 }
 
-asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
+asmlinkage long sys_fcntl(int fd, unsigned int cmd, unsigned long arg)
 {      
        struct file *filp;
        long err = -EBADF;
@@ -434,9 +440,9 @@ static inline int sigio_perm(struct task_struct *p,
                              struct fown_struct *fown, int sig)
 {
        return (((fown->euid == 0) ||
-                (fown->euid == p->suid) || (fown->euid == p->uid) ||
-                (fown->uid == p->suid) || (fown->uid == p->uid)) &&
-               !security_file_send_sigiotask(p, fown, sig));
+               (fown->euid == p->suid) || (fown->euid == p->uid) ||
+               (fown->uid == p->suid) || (fown->uid == p->uid)) &&
+               !security_file_send_sigiotask(p, fown, sig));
 }
 
 static void send_sigio_to_task(struct task_struct *p,
@@ -489,7 +495,7 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
        
        read_lock(&tasklist_lock);
        if (pid > 0) {
-               p = find_task_by_pid(pid);
+               p = find_task_by_real_pid(pid);
                if (p) {
                        send_sigio_to_task(p, fown, fd, band);
                }
@@ -524,7 +530,7 @@ int send_sigurg(struct fown_struct *fown)
        
        read_lock(&tasklist_lock);
        if (pid > 0) {
-               p = find_task_by_pid(pid);
+               p = find_task_by_real_pid(pid);
                if (p) {
                        send_sigurg_to_task(p, fown);
                }