vserver 1.9.3
[linux-2.6.git] / fs / file_table.c
index 8996d4d..9d71ae0 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mount.h>
 #include <linux/cdev.h>
 #include <linux/vs_limit.h>
+#include <linux/vs_context.h>
 
 /* sysctl tunables... */
 struct files_stat_struct files_stat = {
@@ -88,6 +89,8 @@ static int old_max;
                        f->f_owner.lock = RW_LOCK_UNLOCKED;
                        /* f->f_version: 0 */
                        INIT_LIST_HEAD(&f->f_list);
+                       // set_vx_info(&f->f_vx_info, current->vx_info);
+                       f->f_xid = current->xid;
                        vx_files_inc(f);
                        return f;
                }
@@ -108,52 +111,6 @@ fail:
 
 EXPORT_SYMBOL(get_empty_filp);
 
-/*
- * Clear and initialize a (private) struct file for the given dentry,
- * allocate the security structure, and call the open function (if any).  
- * The file should be released using close_private_file.
- */
-int open_private_file(struct file *filp, struct dentry *dentry, int flags)
-{
-       int error;
-       memset(filp, 0, sizeof(*filp));
-       eventpoll_init_file(filp);
-       filp->f_flags  = flags;
-       filp->f_mode   = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
-       atomic_set(&filp->f_count, 1);
-       filp->f_dentry = dentry;
-       filp->f_mapping = dentry->d_inode->i_mapping;
-       filp->f_uid    = current->fsuid;
-       filp->f_gid    = current->fsgid;
-       filp->f_op     = dentry->d_inode->i_fop;
-       INIT_LIST_HEAD(&filp->f_list);
-       error = security_file_alloc(filp);
-       if (!error)
-               if (filp->f_op && filp->f_op->open) {
-                       error = filp->f_op->open(dentry->d_inode, filp);
-                       if (error)
-                               security_file_free(filp);
-               }
-       return error;
-}
-
-EXPORT_SYMBOL(open_private_file);
-
-/*
- * Release a private file by calling the release function (if any) and
- * freeing the security structure.
- */
-void close_private_file(struct file *file)
-{
-       struct inode * inode = file->f_dentry->d_inode;
-
-       if (file->f_op && file->f_op->release)
-               file->f_op->release(inode, file);
-       security_file_free(file);
-}
-
-EXPORT_SYMBOL(close_private_file);
-
 void fastcall fput(struct file *file)
 {
        if (atomic_dec_and_test(&file->f_count))
@@ -171,6 +128,7 @@ void fastcall __fput(struct file *file)
        struct vfsmount *mnt = file->f_vfsmnt;
        struct inode *inode = dentry->d_inode;
 
+       might_sleep();
        /*
         * The function eventpoll_release() should be the first called
         * in the file cleanup chain.
@@ -187,6 +145,7 @@ void fastcall __fput(struct file *file)
        if (file->f_mode & FMODE_WRITE)
                put_write_access(inode);
        vx_files_dec(file);
+       file->f_xid = 0;
        file_kill(file);
        file->f_dentry = NULL;
        file->f_vfsmnt = NULL;
@@ -242,6 +201,8 @@ void put_filp(struct file *file)
 {
        if (atomic_dec_and_test(&file->f_count)) {
                security_file_free(file);
+               vx_files_dec(file);
+               file->f_xid = 0;
                file_kill(file);
                file_free(file);
        }