aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 47c15840a381..05c02dc586b1 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -681,38 +681,13 @@ fail_nomem:
681 return retval; 681 return retval;
682} 682}
683 683
684static struct fs_struct *__copy_fs_struct(struct fs_struct *old)
685{
686 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
687 /* We don't need to lock fs - think why ;-) */
688 if (fs) {
689 atomic_set(&fs->count, 1);
690 rwlock_init(&fs->lock);
691 fs->umask = old->umask;
692 read_lock(&old->lock);
693 fs->root = old->root;
694 path_get(&old->root);
695 fs->pwd = old->pwd;
696 path_get(&old->pwd);
697 read_unlock(&old->lock);
698 }
699 return fs;
700}
701
702struct fs_struct *copy_fs_struct(struct fs_struct *old)
703{
704 return __copy_fs_struct(old);
705}
706
707EXPORT_SYMBOL_GPL(copy_fs_struct);
708
709static int copy_fs(unsigned long clone_flags, struct task_struct *tsk) 684static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
710{ 685{
711 if (clone_flags & CLONE_FS) { 686 if (clone_flags & CLONE_FS) {
712 atomic_inc(&current->fs->count); 687 atomic_inc(&current->fs->count);
713 return 0; 688 return 0;
714 } 689 }
715 tsk->fs = __copy_fs_struct(current->fs); 690 tsk->fs = copy_fs_struct(current->fs);
716 if (!tsk->fs) 691 if (!tsk->fs)
717 return -ENOMEM; 692 return -ENOMEM;
718 return 0; 693 return 0;
@@ -1545,7 +1520,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
1545 1520
1546 if ((unshare_flags & CLONE_FS) && 1521 if ((unshare_flags & CLONE_FS) &&
1547 (fs && atomic_read(&fs->count) > 1)) { 1522 (fs && atomic_read(&fs->count) > 1)) {
1548 *new_fsp = __copy_fs_struct(current->fs); 1523 *new_fsp = copy_fs_struct(current->fs);
1549 if (!*new_fsp) 1524 if (!*new_fsp)
1550 return -ENOMEM; 1525 return -ENOMEM;
1551 } 1526 }