Bug#517485: manpages: console_ioctl(4) lies about KDGETLED

2009-02-27 Thread Alan Curry
Package: manpages
Severity: normal


This description:

>   KDGETLED
> Get state of LEDs.  argp points to a long.  The lower three bits
> of *argp are set to the state of the LEDs, as follows:
>
> LED_CAP   0x04   caps lock led
> LEC_NUM   0x02   num lock led
> LED_SCR   0x01   scroll lock led

is wrong. The kernel only stores a single byte *argp, so if you give it the
address of a long, you won't necessarily find the results in the low 3 bits
of the long. (It happens to work out that way if you are little-endian.)
Change "long" to "char" and the description will be correct.

Demonstration program (run it on a big-endian machine to see that the actual
behavior is not what the man page says):

#include 
#include 
#include 

int main(void)
{
  int ioctlret;
  long longval;

  longval = -1;

  ioctlret = ioctl(0, KDGETLED, &longval);
  printf("ioctlret=%d longval=%08lx\n", ioctlret, longval);

  return 0;
}

-- System Information:
Debian Release: 5.0
  APT prefers stable
  APT policy: (99, 'stable')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.28.2
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

manpages depends on no packages.

manpages recommends no packages.

Versions of packages manpages suggests:
ii  man-db [man-browser]  2.5.2-4on-line manual pager



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#517485: manpages: console_ioctl(4) lies about KDGETLED

2009-02-28 Thread Michael Kerrisk
tags 517485 fixed-upstream
thanks

Hello Alan,

On 2/28/09, Alan Curry  wrote:
> Package: manpages
> Severity: normal
>
>
> This description:
>
>>   KDGETLED
>>Get state of LEDs.  argp points to a long.  The lower three bits
>>of *argp are set to the state of the LEDs, as follows:
>>
>>LED_CAP   0x04   caps lock led
>>LEC_NUM   0x02   num lock led
>>LED_SCR   0x01   scroll lock led
>
> is wrong. The kernel only stores a single byte *argp, so if you give it the
> address of a long, you won't necessarily find the results in the low 3 bits
> of the long. (It happens to work out that way if you are little-endian.)
> Change "long" to "char" and the description will be correct.
>
> Demonstration program (run it on a big-endian machine to see that the actual
> behavior is not what the man page says):
>
> #include 
> #include 
> #include 
>
> int main(void)
> {
>   int ioctlret;
>   long longval;
>
>   longval = -1;
>
>   ioctlret = ioctl(0, KDGETLED, &longval);
>   printf("ioctlret=%d longval=%08lx\n", ioctlret, longval);
>
>   return 0;
> }

Thanks for the excellently documented report!  As you suggest, I have
changed "long" to "char", and the change will be in ustream 3.20.

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org