patch-2.1.117 linux/kernel/fork.c
Next file: linux/kernel/sched.c
Previous file: linux/include/linux/videodev.h
Back to the patch index
Back to the overall index
- Lines: 60
- Date:
Tue Aug 18 22:34:16 1998
- Orig file:
v2.1.116/linux/kernel/fork.c
- Orig date:
Tue Aug 18 22:02:08 1998
diff -u --recursive --new-file v2.1.116/linux/kernel/fork.c linux/kernel/fork.c
@@ -356,8 +356,9 @@
return 0;
}
-/* return value is only accurate by +-sizeof(long)*8 fds */
-/* XXX make this architecture specific */
+/*
+ * Copy a fd_set and compute the maximum fd it contains.
+ */
static inline int __copy_fdset(unsigned long *d, unsigned long *src)
{
int i;
@@ -411,7 +412,6 @@
new_fds = (struct file **) kmalloc(size, GFP_KERNEL);
if (!new_fds)
goto out_release;
- memset((void *) new_fds, 0, size);
atomic_set(&newf->count, 1);
newf->max_fds = NR_OPEN;
@@ -421,13 +421,15 @@
old_fds = oldf->fd;
for (; i != 0; i--) {
- struct file * f = *old_fds;
- old_fds++;
+ struct file *f = *old_fds++;
*new_fds = f;
if (f)
f->f_count++;
new_fds++;
}
+ /* This is long word aligned thus could use a optimized version */
+ memset(new_fds, 0, (char *)newf->fd + size - (char *)new_fds);
+
tsk->files = newf;
error = 0;
out:
@@ -639,20 +641,13 @@
goto bad_fork;
}
-static void files_ctor(void *fp, kmem_cache_t *cachep, unsigned long flags)
-{
- struct files_struct *f = fp;
-
- memset(f, 0, sizeof(*f));
-}
-
__initfunc(void filescache_init(void))
{
files_cachep = kmem_cache_create("files_cache",
sizeof(struct files_struct),
0,
SLAB_HWCACHE_ALIGN,
- files_ctor, NULL);
+ NULL, NULL);
if (!files_cachep)
panic("Cannot create files cache");
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov