proc: add memcpy_user to copy_parent
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
e1113ec277
commit
ef8056ccd7
2 changed files with 11 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <arch/page.h>
|
||||
#include <arch/proc.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <lib/string.h>
|
||||
|
|
@ -55,6 +56,7 @@ static int copy_parent(struct proc *new, struct proc *parent)
|
|||
|
||||
void *vm_alloc = proc_alloc(new, area->len);
|
||||
proc_mmap(new, TO_PHYS(vm_alloc), area->start, area->len, area->flags);
|
||||
memcpy_user(parent, (void *)area->start, vm_alloc, area->len);
|
||||
|
||||
node = rbt_successor(node);
|
||||
}
|
||||
|
|
@ -64,7 +66,7 @@ static int copy_parent(struct proc *new, struct proc *parent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct proc *proc_create(struct proc *parent)
|
||||
struct proc *proc_create(struct thread *parent)
|
||||
{
|
||||
struct proc *ret = slab_alloc(proc_slab);
|
||||
if (!ret)
|
||||
|
|
@ -104,7 +106,7 @@ struct proc *proc_create(struct proc *parent)
|
|||
ret->main_thread = r_mt;
|
||||
|
||||
if (parent) {
|
||||
int res = copy_parent(ret, parent);
|
||||
int res = copy_parent(ret, parent->proc);
|
||||
if (res)
|
||||
kerr("failed to copy parent memmap for new process: %s\n", strerror(-res));
|
||||
}
|
||||
|
|
@ -112,6 +114,12 @@ struct proc *proc_create(struct proc *parent)
|
|||
return ret;
|
||||
}
|
||||
|
||||
pid_t sys_fork()
|
||||
{
|
||||
struct thread *cur_thread = get_cur_thread();
|
||||
struct proc *ret = proc_create(cur_thread);
|
||||
}
|
||||
|
||||
void proc_free(struct proc *proc)
|
||||
{
|
||||
slab_free(proc_slab, proc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue