This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / fcntl.c
index 305abb4..a769c01 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)
@@ -128,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;
@@ -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);
@@ -148,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;
@@ -186,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);
@@ -290,8 +297,6 @@ void f_delown(struct file *filp)
        f_modown(filp, 0, 0, 0, 1);
 }
 
-EXPORT_SYMBOL(f_delown);
-
 static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
                struct file *filp)
 {
@@ -432,11 +437,12 @@ static long band_table[NSIGPOLL] = {
 };
 
 static inline int sigio_perm(struct task_struct *p,
-                             struct fown_struct *fown)
+                             struct fown_struct *fown, int sig)
 {
-       return ((fown->euid == 0) ||
+       return (((fown->euid == 0) ||
                (fown->euid == p->suid) || (fown->euid == p->uid) ||
-               (fown->uid == p->suid) || (fown->uid == 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,
@@ -444,10 +450,7 @@ static void send_sigio_to_task(struct task_struct *p,
                               int fd,
                               int reason)
 {
-       if (!sigio_perm(p, fown))
-               return;
-
-       if (security_file_send_sigiotask(p, fown, fd, reason))
+       if (!sigio_perm(p, fown, fown->signum))
                return;
 
        switch (fown->signum) {
@@ -492,16 +495,14 @@ 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);
                }
        } else {
-               struct list_head *l;
-               struct pid *pidptr;
-               for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) {
+               do_each_task_pid(-pid, PIDTYPE_PGID, p) {
                        send_sigio_to_task(p, fown, fd, band);
-               }
+               } while_each_task_pid(-pid, PIDTYPE_PGID, p);
        }
        read_unlock(&tasklist_lock);
  out_unlock_fown:
@@ -511,7 +512,7 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
 static void send_sigurg_to_task(struct task_struct *p,
                                 struct fown_struct *fown)
 {
-       if (sigio_perm(p, fown))
+       if (sigio_perm(p, fown, SIGURG))
                send_group_sig_info(SIGURG, SEND_SIG_PRIV, p);
 }
 
@@ -529,16 +530,14 @@ 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);
                }
        } else {
-               struct list_head *l;
-               struct pid *pidptr;
-               for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) {
+               do_each_task_pid(-pid, PIDTYPE_PGID, p) {
                        send_sigurg_to_task(p, fown);
-               }
+               } while_each_task_pid(-pid, PIDTYPE_PGID, p);
        }
        read_unlock(&tasklist_lock);
  out_unlock_fown: