summaryrefslogtreecommitdiff
path: root/sys/compat/linux
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
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')
-rw-r--r--sys/compat/linux/common/linux_break.c42
-rw-r--r--sys/compat/linux/common/linux_misc.c42
-rw-r--r--sys/compat/linux/common/linux_misc_notalpha.c42
-rw-r--r--sys/compat/linux/common/linux_oldmmap.c42
-rw-r--r--sys/compat/linux/common/linux_oldolduname.c42
-rw-r--r--sys/compat/linux/common/linux_oldselect.c42
-rw-r--r--sys/compat/linux/common/linux_olduname.c42
-rw-r--r--sys/compat/linux/common/linux_pipe.c42
-rw-r--r--sys/compat/linux/linux_misc.c42
-rw-r--r--sys/compat/linux/multiarch/linux_break.c42
-rw-r--r--sys/compat/linux/multiarch/linux_misc_notalpha.c42
-rw-r--r--sys/compat/linux/multiarch/linux_oldmmap.c42
-rw-r--r--sys/compat/linux/multiarch/linux_oldolduname.c42
-rw-r--r--sys/compat/linux/multiarch/linux_oldselect.c42
-rw-r--r--sys/compat/linux/multiarch/linux_olduname.c42
-rw-r--r--sys/compat/linux/multiarch/linux_pipe.c42
16 files changed, 608 insertions, 64 deletions
diff --git a/sys/compat/linux/common/linux_break.c b/sys/compat/linux/common/linux_break.c
index e6d0ecae8cf..46ce8400089 100644
--- a/sys/compat/linux/common/linux_break.c
+++ b/sys/compat/linux/common/linux_break.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_break.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_break.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
diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c
index c20c25e8db7..49c9e2d7a28 100644
--- a/sys/compat/linux/common/linux_misc.c
+++ b/sys/compat/linux/common/linux_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_misc.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
diff --git a/sys/compat/linux/common/linux_misc_notalpha.c b/sys/compat/linux/common/linux_misc_notalpha.c
index 93bf5ecf701..246dbc3593e 100644
--- a/sys/compat/linux/common/linux_misc_notalpha.c
+++ b/sys/compat/linux/common/linux_misc_notalpha.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc_notalpha.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_misc_notalpha.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
diff --git a/sys/compat/linux/common/linux_oldmmap.c b/sys/compat/linux/common/linux_oldmmap.c
index 541541937f6..5f8515b90a2 100644
--- a/sys/compat/linux/common/linux_oldmmap.c
+++ b/sys/compat/linux/common/linux_oldmmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldmmap.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_oldmmap.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
diff --git a/sys/compat/linux/common/linux_oldolduname.c b/sys/compat/linux/common/linux_oldolduname.c
index 527229d56d6..817d40c821f 100644
--- a/sys/compat/linux/common/linux_oldolduname.c
+++ b/sys/compat/linux/common/linux_oldolduname.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldolduname.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_oldolduname.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
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
diff --git a/sys/compat/linux/common/linux_olduname.c b/sys/compat/linux/common/linux_olduname.c
index 3fe921c6dc2..a4bdf2ebb60 100644
--- a/sys/compat/linux/common/linux_olduname.c
+++ b/sys/compat/linux/common/linux_olduname.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_olduname.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_olduname.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
diff --git a/sys/compat/linux/common/linux_pipe.c b/sys/compat/linux/common/linux_pipe.c
index e14a0cd79ee..df1796d6d5e 100644
--- a/sys/compat/linux/common/linux_pipe.c
+++ b/sys/compat/linux/common/linux_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_pipe.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_pipe.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
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index c20c25e8db7..49c9e2d7a28 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_misc.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
diff --git a/sys/compat/linux/multiarch/linux_break.c b/sys/compat/linux/multiarch/linux_break.c
index e6d0ecae8cf..46ce8400089 100644
--- a/sys/compat/linux/multiarch/linux_break.c
+++ b/sys/compat/linux/multiarch/linux_break.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_break.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_break.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
diff --git a/sys/compat/linux/multiarch/linux_misc_notalpha.c b/sys/compat/linux/multiarch/linux_misc_notalpha.c
index 93bf5ecf701..246dbc3593e 100644
--- a/sys/compat/linux/multiarch/linux_misc_notalpha.c
+++ b/sys/compat/linux/multiarch/linux_misc_notalpha.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc_notalpha.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_misc_notalpha.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
diff --git a/sys/compat/linux/multiarch/linux_oldmmap.c b/sys/compat/linux/multiarch/linux_oldmmap.c
index 541541937f6..5f8515b90a2 100644
--- a/sys/compat/linux/multiarch/linux_oldmmap.c
+++ b/sys/compat/linux/multiarch/linux_oldmmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldmmap.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_oldmmap.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
diff --git a/sys/compat/linux/multiarch/linux_oldolduname.c b/sys/compat/linux/multiarch/linux_oldolduname.c
index 527229d56d6..817d40c821f 100644
--- a/sys/compat/linux/multiarch/linux_oldolduname.c
+++ b/sys/compat/linux/multiarch/linux_oldolduname.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_oldolduname.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_oldolduname.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
diff --git a/sys/compat/linux/multiarch/linux_oldselect.c b/sys/compat/linux/multiarch/linux_oldselect.c
index 1c48e12fa2c..c10083abe37 100644
--- a/sys/compat/linux/multiarch/linux_oldselect.c
+++ b/sys/compat/linux/multiarch/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
diff --git a/sys/compat/linux/multiarch/linux_olduname.c b/sys/compat/linux/multiarch/linux_olduname.c
index 3fe921c6dc2..a4bdf2ebb60 100644
--- a/sys/compat/linux/multiarch/linux_olduname.c
+++ b/sys/compat/linux/multiarch/linux_olduname.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_olduname.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_olduname.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
diff --git a/sys/compat/linux/multiarch/linux_pipe.c b/sys/compat/linux/multiarch/linux_pipe.c
index e14a0cd79ee..df1796d6d5e 100644
--- a/sys/compat/linux/multiarch/linux_pipe.c
+++ b/sys/compat/linux/multiarch/linux_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_pipe.c,v 1.41 1998/03/24 09:47:30 mycroft Exp $ */
+/* $NetBSD: linux_pipe.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