diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-04 08:59:09 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-04 08:59:09 +0000 |
commit | 6e701a9a0fac07bcafcc55ce49267d7bcb275c04 (patch) | |
tree | e53ddb250cd0708ae2c40ab0ec886e42d21db287 /sys/compat/linux | |
parent | cb9cdd765870006396d459f1516a265ec9929e09 (diff) |
emulate shrinking in mremap(); boquist@cs.chalmers.se
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index fea39e7d80c..54ad6398f5a 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_misc.c,v 1.16 1998/04/26 10:19:12 deraadt Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.17 1998/07/04 08:59:08 deraadt Exp $ */ /* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ /* @@ -511,15 +511,51 @@ linux_sys_mremap(p, v, retval) void *v; register_t *retval; { -#ifdef notyet + struct linux_sys_mremap_args /* { syscallarg(void *) old_address; syscallarg(size_t) old_size; syscallarg(size_t) new_size; syscallarg(u_long) flags; } */ *uap = v; -#endif - return (ENOMEM); + struct sys_munmap_args mua; + size_t old_size, new_size; + int error; + + old_size = round_page(SCARG(uap, old_size)); + new_size = round_page(SCARG(uap, new_size)); + + /* + * Growing mapped region. + */ + if (new_size > old_size) { + /* + * XXX Implement me. What we probably want to do is + * XXX dig out the guts of the old mapping, mmap that + * XXX object again with the new size, then munmap + * XXX the old mapping. + */ + *retval = 0; + return (ENOMEM); + } + /* + * Shrinking mapped region. + */ + if (new_size < old_size) { + SCARG(&mua, addr) = (caddr_t)SCARG(uap, old_address) + + SCARG(uap, new_size); + SCARG(&mua, len) = old_size - new_size; + error = sys_munmap(p, &mua, retval); + *retval = error ? 0 : (register_t)SCARG(uap, old_address); + return (error); + } + + /* + * No change. + */ + *retval = (register_t)SCARG(uap, old_address); + return (0); + } /* @@ -797,9 +833,9 @@ again: auio.uio_resid = buflen; auio.uio_offset = off; /* - * First we read into the malloc'ed buffer, then - * we massage it into user space, one record at a time. - */ + * First we read into the malloc'ed buffer, then + * we massage it into user space, one record at a time. + */ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookiebuf); if (error) |