string: add memcpy_user
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
0bd9472786
commit
e1113ec277
2 changed files with 16 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t num);
|
||||
void *memcpy_user(struct proc *proc, void *dest, const void *src, size_t num);
|
||||
int memcmp(const void *aa, const void *bb, size_t num);
|
||||
int strcmp(const char *a, const char *b);
|
||||
int strncmp(const char *a, const char *b, size_t n);
|
||||
|
|
|
|||
15
lib/string.c
15
lib/string.c
|
|
@ -1,6 +1,8 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <arch/page.h>
|
||||
#include <lib/string.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t num)
|
||||
|
|
@ -245,3 +247,16 @@ char *basename(const char *path)
|
|||
kfree(copy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *memcpy_user(struct proc *proc, void *dest, const void *src, size_t num)
|
||||
{
|
||||
pgd_t *pgd = pgd_get();
|
||||
|
||||
if (pgd != proc->pgd)
|
||||
pgd_load(proc->pgd);
|
||||
|
||||
memcpy(dest, src, num);
|
||||
|
||||
if (pgd != proc->pgd)
|
||||
pgd_load(pgd);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue