fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / file_table.c
index cc11ccb..6e8d15f 100644 (file)
@@ -5,7 +5,6 @@
  *  Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  */
 
-#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/file.h>
@@ -90,6 +89,7 @@ int proc_nr_files(ctl_table *table, int write, struct file *filp,
  */
 struct file *get_empty_filp(void)
 {
+       struct task_struct *tsk;
        static int old_max;
        struct file * f;
 
@@ -114,13 +114,14 @@ struct file *get_empty_filp(void)
        if (security_file_alloc(f))
                goto fail_sec;
 
-       eventpoll_init_file(f);
+       tsk = current;
+       INIT_LIST_HEAD(&f->f_u.fu_list);
        atomic_set(&f->f_count, 1);
-       f->f_uid = current->fsuid;
-       f->f_gid = current->fsgid;
        rwlock_init(&f->f_owner.lock);
+       f->f_uid = tsk->fsuid;
+       f->f_gid = tsk->fsgid;
+       eventpoll_init_file(f);
        /* f->f_version: 0 */
-       INIT_LIST_HEAD(&f->f_u.fu_list);
        f->f_xid = vx_current_xid();
        vx_files_inc(f);
        return f;
@@ -155,8 +156,8 @@ EXPORT_SYMBOL(fput);
  */
 void fastcall __fput(struct file *file)
 {
-       struct dentry *dentry = file->f_dentry;
-       struct vfsmount *mnt = file->f_vfsmnt;
+       struct dentry *dentry = file->f_path.dentry;
+       struct vfsmount *mnt = file->f_path.mnt;
        struct inode *inode = dentry->d_inode;
 
        might_sleep();
@@ -172,16 +173,17 @@ void fastcall __fput(struct file *file)
        if (file->f_op && file->f_op->release)
                file->f_op->release(inode, file);
        security_file_free(file);
-       if (unlikely(inode->i_cdev != NULL))
+       if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL))
                cdev_put(inode->i_cdev);
        fops_put(file->f_op);
        if (file->f_mode & FMODE_WRITE)
                put_write_access(inode);
+       put_pid(file->f_owner.pid);
        vx_files_dec(file);
        file->f_xid = 0;
        file_kill(file);
-       file->f_dentry = NULL;
-       file->f_vfsmnt = NULL;
+       file->f_path.dentry = NULL;
+       file->f_path.mnt = NULL;
        file_free(file);
        dput(dentry);
        mntput(mnt);
@@ -239,6 +241,7 @@ struct file fastcall *fget_light(unsigned int fd, int *fput_needed)
        return file;
 }
 
+EXPORT_SYMBOL_GPL(fget_light);
 
 void put_filp(struct file *file)
 {
@@ -277,7 +280,7 @@ int fs_may_remount_ro(struct super_block *sb)
        file_list_lock();
        list_for_each(p, &sb->s_files) {
                struct file *file = list_entry(p, struct file, f_u.fu_list);
-               struct inode *inode = file->f_dentry->d_inode;
+               struct inode *inode = file->f_path.dentry->d_inode;
 
                /* File with pending delete? */
                if (inode->i_nlink == 0)
@@ -306,5 +309,5 @@ void __init files_init(unsigned long mempages)
        if (files_stat.max_files < NR_FILE)
                files_stat.max_files = NR_FILE;
        files_defer_init();
-       percpu_counter_init(&nr_files);
+       percpu_counter_init(&nr_files, 0);
 }