Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328970
b: refs/heads/master
c: f869e8a
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed Sep 27, 2012
1 parent be7abe4 commit 8e1f9c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56007cae94f349387c088e738c7dcb6bc513063b
refs/heads/master: f869e8a7f753e3fd43d6483e796774776f645edb
13 changes: 2 additions & 11 deletions trunk/drivers/staging/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,8 @@ int task_get_unused_fd_flags(struct binder_proc *proc, int flags)
static void task_fd_install(
struct binder_proc *proc, unsigned int fd, struct file *file)
{
struct files_struct *files = proc->files;
struct fdtable *fdt;

if (files == NULL)
return;

spin_lock(&files->file_lock);
fdt = files_fdtable(files);
BUG_ON(fdt->fd[fd] != NULL);
rcu_assign_pointer(fdt->fd[fd], file);
spin_unlock(&files->file_lock);
if (proc->files)
__fd_install(proc->files, fd, file);
}

/*
Expand Down
16 changes: 14 additions & 2 deletions trunk/fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,18 @@ EXPORT_SYMBOL(put_unused_fd);
*
* It should never happen - if we allow dup2() do it, _really_ bad things
* will follow.
*
* NOTE: __fd_install() variant is really, really low-level; don't
* use it unless you are forced to by truly lousy API shoved down
* your throat. 'files' *MUST* be either current->files or obtained
* by get_files_struct(current) done by whoever had given it to you,
* or really bad things will happen. Normally you want to use
* fd_install() instead.
*/

void fd_install(unsigned int fd, struct file *file)
void __fd_install(struct files_struct *files, unsigned int fd,
struct file *file)
{
struct files_struct *files = current->files;
struct fdtable *fdt;
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
Expand All @@ -612,4 +619,9 @@ void fd_install(unsigned int fd, struct file *file)
spin_unlock(&files->file_lock);
}

void fd_install(unsigned int fd, struct file *file)
{
__fd_install(current->files, fd, file);
}

EXPORT_SYMBOL(fd_install);
2 changes: 2 additions & 0 deletions trunk/include/linux/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ struct files_struct *dup_fd(struct files_struct *, int *);

extern int __alloc_fd(struct files_struct *files,
unsigned start, unsigned end, unsigned flags);
extern void __fd_install(struct files_struct *files,
unsigned int fd, struct file *file);

extern struct kmem_cache *files_cachep;

Expand Down

0 comments on commit 8e1f9c8

Please sign in to comment.