- check vnet_active before executing runtime vnet code
[linux-2.6.git] / fs / fcntl.c
index a7966c9..cfd505e 100644 (file)
@@ -4,6 +4,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/syscalls.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
@@ -87,7 +88,7 @@ static int locate_fd(struct files_struct *files,
        int error;
 
        error = -EINVAL;
-       if (orig_start >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out;
 
 repeat:
@@ -106,7 +107,7 @@ repeat:
        }
        
        error = -EMFILE;
-       if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out;
        if (!vx_files_avail(1))
                goto out;
@@ -167,7 +168,7 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
        if (newfd == oldfd)
                goto out_unlock;
        err = -EBADF;
-       if (newfd >= current->rlim[RLIMIT_NOFILE].rlim_cur)
+       if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
                goto out_unlock;
        get_file(file);                 /* We are now finished with oldfd */
 
@@ -297,8 +298,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)
 {
@@ -369,7 +368,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
        return err;
 }
 
-asmlinkage long sys_fcntl(int fd, unsigned int cmd, unsigned long arg)
+asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {      
        struct file *filp;
        long err = -EBADF;
@@ -439,11 +438,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) ||
-               (fown->euid == p->suid) || (fown->euid == p->uid) ||
-               (fown->uid == p->suid) || (fown->uid == p->uid));
+       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));
 }
 
 static void send_sigio_to_task(struct task_struct *p,
@@ -451,10 +451,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) {
@@ -499,16 +496,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:
@@ -518,7 +513,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);
 }
 
@@ -536,16 +531,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: