Compat linux/linux32 nice(2) fix. The syscall argument is an increment to be added to the current nice value, not an absolute value to be set.diff -r1.103 -r1.104 src/sys/compat/linux/common/linux_misc_notalpha.c
(njoly)
--- src/sys/compat/linux/common/linux_misc_notalpha.c 2008/07/15 16:18:08 1.103
+++ src/sys/compat/linux/common/linux_misc_notalpha.c 2008/10/03 22:39:36 1.104
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_misc_notalpha.c,v 1.103 2008/07/15 16:18:08 christos Exp $ */ | 1 | /* $NetBSD: linux_misc_notalpha.c,v 1.104 2008/10/03 22:39:36 njoly Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe | 8 | * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe | |
9 | * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. | 9 | * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.103 2008/07/15 16:18:08 christos Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.104 2008/10/03 22:39:36 njoly Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/kernel.h> | 38 | #include <sys/kernel.h> | |
39 | #include <sys/mman.h> | 39 | #include <sys/mman.h> | |
40 | #include <sys/mount.h> | 40 | #include <sys/mount.h> | |
41 | #include <sys/malloc.h> | 41 | #include <sys/malloc.h> | |
42 | #include <sys/mbuf.h> | 42 | #include <sys/mbuf.h> | |
43 | #include <sys/namei.h> | 43 | #include <sys/namei.h> | |
44 | #include <sys/proc.h> | 44 | #include <sys/proc.h> | |
45 | #include <sys/prot.h> | 45 | #include <sys/prot.h> | |
46 | #include <sys/ptrace.h> | 46 | #include <sys/ptrace.h> | |
47 | #include <sys/resource.h> | 47 | #include <sys/resource.h> | |
@@ -189,31 +189,33 @@ linux_sys_alarm(struct lwp *l, const str | @@ -189,31 +189,33 @@ linux_sys_alarm(struct lwp *l, const str | |||
189 | mutex_spin_exit(&timer_lock); | 189 | mutex_spin_exit(&timer_lock); | |
190 | 190 | |||
191 | return 0; | 191 | return 0; | |
192 | } | 192 | } | |
193 | #endif /* !COMPAT_LINUX32 */ | 193 | #endif /* !COMPAT_LINUX32 */ | |
194 | 194 | |||
195 | #if !defined(__amd64__) | 195 | #if !defined(__amd64__) | |
196 | int | 196 | int | |
197 | linux_sys_nice(struct lwp *l, const struct linux_sys_nice_args *uap, register_t *retval) | 197 | linux_sys_nice(struct lwp *l, const struct linux_sys_nice_args *uap, register_t *retval) | |
198 | { | 198 | { | |
199 | /* { | 199 | /* { | |
200 | syscallarg(int) incr; | 200 | syscallarg(int) incr; | |
201 | } */ | 201 | } */ | |
202 | struct proc *p = l->l_proc; | |||
202 | struct sys_setpriority_args bsa; | 203 | struct sys_setpriority_args bsa; | |
203 | 204 | |||
204 | SCARG(&bsa, which) = PRIO_PROCESS; | 205 | SCARG(&bsa, which) = PRIO_PROCESS; | |
205 | SCARG(&bsa, who) = 0; | 206 | SCARG(&bsa, who) = 0; | |
206 | SCARG(&bsa, prio) = SCARG(uap, incr); | 207 | SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr); | |
208 | ||||
207 | return sys_setpriority(l, &bsa, retval); | 209 | return sys_setpriority(l, &bsa, retval); | |
208 | } | 210 | } | |
209 | #endif /* !__amd64__ */ | 211 | #endif /* !__amd64__ */ | |
210 | 212 | |||
211 | #ifndef COMPAT_LINUX32 | 213 | #ifndef COMPAT_LINUX32 | |
212 | #ifndef __amd64__ | 214 | #ifndef __amd64__ | |
213 | /* | 215 | /* | |
214 | * The old Linux readdir was only able to read one entry at a time, | 216 | * The old Linux readdir was only able to read one entry at a time, | |
215 | * even though it had a 'count' argument. In fact, the emulation | 217 | * even though it had a 'count' argument. In fact, the emulation | |
216 | * of the old call was better than the original, because it did handle | 218 | * of the old call was better than the original, because it did handle | |
217 | * the count arg properly. Don't bother with it anymore now, and use | 219 | * the count arg properly. Don't bother with it anymore now, and use | |
218 | * it to distinguish between old and new. The difference is that the | 220 | * it to distinguish between old and new. The difference is that the | |
219 | * newer one actually does multiple entries, and the reclen field | 221 | * newer one actually does multiple entries, and the reclen field |
--- src/sys/compat/linux32/common/linux32_unistd.c 2008/09/22 13:07:46 1.23
+++ src/sys/compat/linux32/common/linux32_unistd.c 2008/10/03 22:39:36 1.24
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux32_unistd.c,v 1.23 2008/09/22 13:07:46 njoly Exp $ */ | 1 | /* $NetBSD: linux32_unistd.c,v 1.24 2008/10/03 22:39:36 njoly Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | 4 | * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | 35 | |||
36 | __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.23 2008/09/22 13:07:46 njoly Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.24 2008/10/03 22:39:36 njoly Exp $"); | |
37 | 37 | |||
38 | #include <sys/types.h> | 38 | #include <sys/types.h> | |
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/fstypes.h> | 40 | #include <sys/fstypes.h> | |
41 | #include <sys/signal.h> | 41 | #include <sys/signal.h> | |
42 | #include <sys/dirent.h> | 42 | #include <sys/dirent.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/fcntl.h> | 44 | #include <sys/fcntl.h> | |
45 | #include <sys/select.h> | 45 | #include <sys/select.h> | |
46 | #include <sys/proc.h> | 46 | #include <sys/proc.h> | |
47 | #include <sys/ucred.h> | 47 | #include <sys/ucred.h> | |
48 | #include <sys/swap.h> | 48 | #include <sys/swap.h> | |
49 | 49 | |||
@@ -381,31 +381,32 @@ linux32_sys_setresgid(struct lwp *l, con | @@ -381,31 +381,32 @@ linux32_sys_setresgid(struct lwp *l, con | |||
381 | SCARG(&ua, rgid) = (SCARG(uap, rgid) == -1) ? -1 : SCARG(uap, rgid); | 381 | SCARG(&ua, rgid) = (SCARG(uap, rgid) == -1) ? -1 : SCARG(uap, rgid); | |
382 | SCARG(&ua, egid) = (SCARG(uap, egid) == -1) ? -1 : SCARG(uap, egid); | 382 | SCARG(&ua, egid) = (SCARG(uap, egid) == -1) ? -1 : SCARG(uap, egid); | |
383 | SCARG(&ua, sgid) = (SCARG(uap, sgid) == -1) ? -1 : SCARG(uap, sgid); | 383 | SCARG(&ua, sgid) = (SCARG(uap, sgid) == -1) ? -1 : SCARG(uap, sgid); | |
384 | 384 | |||
385 | return linux_sys_setresgid(l, &ua, retval); | 385 | return linux_sys_setresgid(l, &ua, retval); | |
386 | } | 386 | } | |
387 | 387 | |||
388 | int | 388 | int | |
389 | linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval) | 389 | linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval) | |
390 | { | 390 | { | |
391 | /* { | 391 | /* { | |
392 | syscallarg(int) incr; | 392 | syscallarg(int) incr; | |
393 | } */ | 393 | } */ | |
394 | struct proc *p = l->l_proc; | |||
394 | struct sys_setpriority_args bsa; | 395 | struct sys_setpriority_args bsa; | |
395 | 396 | |||
396 | SCARG(&bsa, which) = PRIO_PROCESS; | 397 | SCARG(&bsa, which) = PRIO_PROCESS; | |
397 | SCARG(&bsa, who) = 0; | 398 | SCARG(&bsa, who) = 0; | |
398 | SCARG(&bsa, prio) = SCARG(uap, incr); | 399 | SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr); | |
399 | 400 | |||
400 | return sys_setpriority(l, &bsa, retval); | 401 | return sys_setpriority(l, &bsa, retval); | |
401 | } | 402 | } | |
402 | 403 | |||
403 | int | 404 | int | |
404 | linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval) | 405 | linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval) | |
405 | { | 406 | { | |
406 | /* { | 407 | /* { | |
407 | syscallarg(unsigned int) secs; | 408 | syscallarg(unsigned int) secs; | |
408 | } */ | 409 | } */ | |
409 | struct linux_sys_alarm_args ua; | 410 | struct linux_sys_alarm_args ua; | |
410 | 411 | |||
411 | NETBSD32TO64_UAP(secs); | 412 | NETBSD32TO64_UAP(secs); |