Subject: Re: kern/33671: getpriority(2) under COMPAT_LINUX return wrong values
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Nicolas Joly <njoly@pasteur.fr>
List: netbsd-bugs
Date: 06/10/2006 14:15:04
The following reply was made to PR kern/33671; it has been noted by GNATS.

From: Nicolas Joly <njoly@pasteur.fr>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, njoly@pasteur.fr
Subject: Re: kern/33671: getpriority(2) under COMPAT_LINUX return wrong values
Date: Sat, 10 Jun 2006 16:10:03 +0200

 On Sat, Jun 10, 2006 at 09:00:05AM +0000, David Laight wrote:
 >  > On Thu, Jun 08, 2006 at 06:25:00PM +0000, Nicolas Joly wrote:
 >  > > >Number:         33671
 >  > > >Category:       kern
 >  > > >Synopsis:       getpriority(2) under COMPAT_LINUX return wrong values
 >  > [...]
 >  > > >Description:
 >  > > While running some linux binaries on my -current NetBSD/amd64, i
 >  > > noticed that getpriority(2) return wrong values. According to the
 >  > > linux man page (notes section), this syscall returns values in 40..1
 >  > > interval instead of the expected -20 to 20 range.
 >  > 
 >  > I just got some time to take a closer look ... And made the attached
 >  > patch. I successfully tested it on -current amd64 and i386 boxes, but
 >  > i suspect all other platforms with COMPAT_LINUX need to be fixed too.
 [...]
 >  Since the argument layout is the same, and that is usually assumed for
 >  syscall emulation, isn't it enough to do:
 >  
 >  int
 >  linux_sys_getpriority(struct lwp *l, void *v, register_t retval)
 >  {
 >          int error = sys_getpriority(l, v, retval);
 >          *retval = 20 - *retval;
 >          return error;
 >  }
 
 I didn't know. And i confirm this works, at least, on i386 (i'll check
 with my amd64 at work on monday).
 
 Thanks.
 
 -- 
 Nicolas Joly
 
 Biological Software and Databanks.
 Institut Pasteur, Paris.