Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  [PATCH] get stack footprint of pathname resolution back to relative sanity
  [PATCH] double iput() on failure exit in hugetlb
  [PATCH] double dput() on failure exit in tiny-shmem
  [PATCH] fix up new filp allocators
  [PATCH] check for null vfsmount in dentry_open()
  [PATCH] reiserfs: eliminate private use of struct file in xattr
  [PATCH] sanitize hppfs
  hppfs pass vfsmount to dentry_open()
  [PATCH] restore export of do_kern_mount()
  • Loading branch information
Linus Torvalds committed Mar 25, 2008
2 parents a4083c9 + a02f76c commit 7ed7fe5
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 366 deletions.
18 changes: 8 additions & 10 deletions fs/anon_inodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,

if (IS_ERR(anon_inode_inode))
return -ENODEV;
file = get_empty_filp();
if (!file)
return -ENFILE;

error = get_unused_fd();
if (error < 0)
goto err_put_filp;
return error;
fd = error;

/*
Expand All @@ -114,14 +111,15 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
dentry->d_flags &= ~DCACHE_UNHASHED;
d_instantiate(dentry, anon_inode_inode);

file->f_path.mnt = mntget(anon_inode_mnt);
file->f_path.dentry = dentry;
error = -ENFILE;
file = alloc_file(anon_inode_mnt, dentry,
FMODE_READ | FMODE_WRITE, fops);
if (!file)
goto err_dput;
file->f_mapping = anon_inode_inode->i_mapping;

file->f_pos = 0;
file->f_flags = O_RDWR;
file->f_op = fops;
file->f_mode = FMODE_READ | FMODE_WRITE;
file->f_version = 0;
file->private_data = priv;

Expand All @@ -132,10 +130,10 @@ int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
*pfile = file;
return 0;

err_dput:
dput(dentry);
err_put_unused_fd:
put_unused_fd(fd);
err_put_filp:
put_filp(file);
return error;
}
EXPORT_SYMBOL_GPL(anon_inode_getfd);
Expand Down
6 changes: 6 additions & 0 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ int proc_nr_files(ctl_table *table, int write, struct file *filp,
/* Find an unused file structure and return a pointer to it.
* Returns NULL, if there are no more free file structures or
* we run out of memory.
*
* Be very careful using this. You are responsible for
* getting write access to any mount that you might assign
* to this filp, if it is opened for write. If this is not
* done, you will imbalance int the mount's writer count
* and a warning at __fput() time.
*/
struct file *get_empty_filp(void)
{
Expand Down
Loading

0 comments on commit 7ed7fe5

Please sign in to comment.