patch-2.3.99-pre6 linux/kernel/fork.c
Next file: linux/kernel/kmod.c
Previous file: linux/kernel/exit.c
Back to the patch index
Back to the overall index
- Lines: 84
- Date:
Fri Apr 21 16:08:45 2000
- Orig file:
v2.3.99-pre5/linux/kernel/fork.c
- Orig date:
Tue Apr 11 15:09:25 2000
diff -u --recursive --new-file v2.3.99-pre5/linux/kernel/fork.c linux/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 @@
* 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 @@
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 @@
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(¤t->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 @@
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;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)