Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93484
b: refs/heads/master
c: 6b335d9
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed Apr 25, 2008
1 parent 8a916c6 commit de7155d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 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: 42faad99658eed7ca8bd328ffa4bcb7d78c9bcca
refs/heads/master: 6b335d9c80d7f3c2a3f6545f664ae9007a0f3821
20 changes: 9 additions & 11 deletions trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,6 @@ static int copy_files(unsigned long clone_flags, struct task_struct * tsk)
goto out;
}

/*
* Note: we may be using current for both targets (See exec.c)
* This works because we cache current->files (old) as oldf. Don't
* break this.
*/
tsk->files = NULL;
newf = dup_fd(oldf, &error);
if (!newf)
goto out;
Expand Down Expand Up @@ -855,7 +849,8 @@ static int copy_io(unsigned long clone_flags, struct task_struct *tsk)
int unshare_files(void)
{
struct files_struct *files = current->files;
int rc;
struct files_struct *newf;
int error = 0;

BUG_ON(!files);

Expand All @@ -866,10 +861,13 @@ int unshare_files(void)
atomic_inc(&files->count);
return 0;
}
rc = copy_files(0, current);
if(rc)
current->files = files;
return rc;
newf = dup_fd(files, &error);
if (newf) {
task_lock(current);
current->files = newf;
task_unlock(current);
}
return error;
}

EXPORT_SYMBOL(unshare_files);
Expand Down

0 comments on commit de7155d

Please sign in to comment.