summaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-04-28 01:09:25 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-04-28 01:09:25 +0000
commitb9ba7aeb165cffecdffb60aec8c3fa8d590d9ca9 (patch)
tree42d07b0c7246ae2536a702e7c5de9e2732341116 /kernel/fork.c
parent7406b0a326f2d70ade2671c37d1beef62249db97 (diff)
Merge with 2.3.99-pre6.
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 6eca792d9..fa63452e1 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -11,6 +11,7 @@
* management can be a bitch. See 'mm/mm.c': 'copy_page_tables()'
*/
+#include <linux/config.h>
#include <linux/malloc.h>
#include <linux/init.h>
#include <linux/unistd.h>
@@ -98,7 +99,7 @@ static inline struct user_struct *uid_hash_find(unsigned short uid, unsigned int
* the common case (not freeing anything) without having
* any locking.
*/
-#ifdef __SMP__
+#ifdef CONFIG_SMP
#define uid_hash_free(up) (!atomic_read(&(up)->count))
#else
#define uid_hash_free(up) (1)
@@ -242,6 +243,8 @@ static inline int dup_mmap(struct mm_struct * mm)
struct file *file;
retval = -ENOMEM;
+ if(mpnt->vm_flags & VM_DONTCOPY)
+ continue;
tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
if (!tmp)
goto fail_nomem;
@@ -419,21 +422,41 @@ fail_nomem:
return retval;
}
+static inline struct fs_struct *__copy_fs_struct(struct fs_struct *old)
+{
+ struct fs_struct *fs = kmalloc(sizeof(*old), GFP_KERNEL);
+ if (fs) {
+ atomic_set(&fs->count, 1);
+ fs->umask = old->umask;
+ fs->rootmnt = mntget(old->rootmnt);
+ fs->root = dget(old->root);
+ fs->pwdmnt = mntget(old->pwdmnt);
+ fs->pwd = dget(old->pwd);
+ if (old->altroot) {
+ fs->altrootmnt = mntget(old->altrootmnt);
+ fs->altroot = dget(old->altroot);
+ } else {
+ fs->altrootmnt = NULL;
+ fs->altroot = NULL;
+ }
+ }
+ return fs;
+}
+
+struct fs_struct *copy_fs_struct(struct fs_struct *old)
+{
+ return __copy_fs_struct(old);
+}
+
static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk)
{
if (clone_flags & CLONE_FS) {
atomic_inc(&current->fs->count);
return 0;
}
- tsk->fs = kmalloc(sizeof(*tsk->fs), GFP_KERNEL);
+ tsk->fs = __copy_fs_struct(current->fs);
if (!tsk->fs)
return -1;
- atomic_set(&tsk->fs->count, 1);
- tsk->fs->umask = current->fs->umask;
- tsk->fs->root = dget(current->fs->root);
- tsk->fs->pwd = dget(current->fs->pwd);
- tsk->fs->rootmnt = mntget(current->fs->rootmnt);
- tsk->fs->pwdmnt = mntget(current->fs->pwdmnt);
return 0;
}
@@ -673,7 +696,7 @@ int do_fork(unsigned long clone_flags, unsigned long usp, struct pt_regs *regs)
p->tty_old_pgrp = 0;
p->times.tms_utime = p->times.tms_stime = 0;
p->times.tms_cutime = p->times.tms_cstime = 0;
-#ifdef __SMP__
+#ifdef CONFIG_SMP
{
int i;
p->has_cpu = 0;