upgrade to fedora-2.6.12-1.1398.FC4 + vserver 2.0.rc7
[linux-2.6.git] / fs / fcntl.c
index cfd505e..c9ae39b 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/signal.h>
 #include <linux/vs_limit.h>
 
 #include <asm/poll.h>
@@ -42,38 +43,6 @@ static inline int get_close_on_exec(unsigned int fd)
        return res;
 }
 
-
-/* Expand files.  Return <0 on error; 0 nothing done; 1 files expanded,
- * we may have blocked. 
- *
- * Should be called with the files->file_lock spinlock held for write.
- */
-static int expand_files(struct files_struct *files, int nr)
-{
-       int err, expand = 0;
-#ifdef FDSET_DEBUG     
-       printk (KERN_ERR "%s %d: nr = %d\n", __FUNCTION__, current->pid, nr);
-#endif
-       
-       if (nr >= files->max_fdset) {
-               expand = 1;
-               if ((err = expand_fdset(files, nr)))
-                       goto out;
-       }
-       if (nr >= files->max_fds) {
-               expand = 1;
-               if ((err = expand_fd_array(files, nr)))
-                       goto out;
-       }
-       err = expand;
- out:
-#ifdef FDSET_DEBUG     
-       if (err)
-               printk (KERN_ERR "%s %d: return %d\n", __FUNCTION__, current->pid, err);
-#endif
-       return err;
-}
-
 /*
  * locate_fd finds a free file descriptor in the open_fds fdset,
  * expanding the fd arrays if necessary.  Must be called with the
@@ -143,7 +112,7 @@ 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);
+               vx_openfd_inc(fd);
                fd_install(fd, file);
        } else {
                spin_unlock(&files->file_lock);
@@ -197,6 +166,9 @@ asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
 
        if (tofree)
                filp_close(tofree, files);
+       else
+               vx_openfd_inc(newfd);   /* fd was unused */
+
        err = newfd;
 out:
        return err;
@@ -347,7 +319,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
                break;
        case F_SETSIG:
                /* arg == 0 restores default behaviour. */
-               if (arg < 0 || arg > _NSIG) {
+               if (!valid_signal(arg)) {
                        break;
                }
                err = 0;
@@ -476,7 +448,7 @@ static void send_sigio_to_task(struct task_struct *p,
                        else
                                si.si_band = band_table[reason - POLL_IN];
                        si.si_fd    = fd;
-                       if (!send_sig_info(fown->signum, &si, p))
+                       if (!send_group_sig_info(fown->signum, &si, p))
                                break;
                /* fall-through: fall back on the old plain SIGIO signal */
                case 0:
@@ -546,7 +518,7 @@ int send_sigurg(struct fown_struct *fown)
        return ret;
 }
 
-static rwlock_t fasync_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(fasync_lock);
 static kmem_cache_t *fasync_cache;
 
 /*