summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common/linux_oldselect.c
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>1998-07-02 23:26:58 +0000
committerthorpej <thorpej@NetBSD.org>1998-07-02 23:26:58 +0000
commit33f066d24ce417e11ca6e2bef9b8e1dc6eda733a (patch)
tree4d8adf0ae48111011383df0af4edb1633e1fefa6 /sys/compat/linux/common/linux_oldselect.c
parent76cd67b8c71e561e369096d7b5cc7b2dfc530e35 (diff)
Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693. Add a comment about how one might implement the growing bit of mremap(2).
Diffstat (limited to 'sys/compat/linux/common/linux_oldselect.c')
-rw-r--r--sys/compat/linux/common/linux_oldselect.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/sys/compat/linux/common/linux_oldselect.c b/sys/compat/linux/common/linux_oldselect.c
index 1c48e12fa2c..c10083abe37 100644
--- a/sys/compat/linux/common/linux_oldselect.c
+++ b/sys/compat/linux/common/linux_oldselect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldselect.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_oldselect.c,v 1.42 1998/07/02 23:26:58 thorpej Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@@ -519,16 +519,50 @@ 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
+ 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);
+ }
- return ENOMEM;
+ /*
+ * No change.
+ */
+ *retval = (register_t)SCARG(uap, old_address);
+ return (0);
}
int