Hi,

The below testcase requires to exit with setting errno as EINVAL, as per
the man page.

I tested this on ARM, I686, PPC64 it was fine, for the same on PPC32 it
used exit with errno set as EFAULT.

On further investigation found there was some long obsolete code in
arch/powerpc/kernel/syscalls.c (function ppc_select()), which was
written in 2.2.0 kernel for PPC32 specific , which resulted in EFAULT.

This needs to be verified, I have proposed patch for PPC32, Please check
the link
http://article.gmane.org/gmane.linux.kernel/735922


Please find the below testcase.

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdlib.h>

int main()
{

 int fd;
 fd_set rfds;
 struct timeval tv;
 int ret_val;

 if ((fd = open("test_file", O_RDWR|O_CREAT, 0664)) < 0)
  {
    printf("Open failed\n");
  }

  FD_ZERO(&rfds);
  FD_SET(fd, &rfds);

  /* Wait up to five seconds. */
  tv.tv_sec = 1;
  tv.tv_usec = 0;

  if ( (ret_val = select(-1, &rfds, NULL, NULL, &tv)) < 0)
  {
    if ( errno == EINVAL)
      printf("OK\n");
    else
      printf("Not OK, Got errno %d\n", errno);
  }
  exit(0);
}


Thanks,
Halesh



>-----Original Message-----
>From: Benjamin Herrenschmidt [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, September 23, 2008 10:12 AM
>To: Josh Boyer
>Cc: Sadashiiv, Halesh; linuxppc-embedded@ozlabs.org
>Subject: Re: Regarding select() on PPC
>
>On Mon, 2008-09-22 at 11:24 -0400, Josh Boyer wrote:
>> On Mon, Sep 22, 2008 at 08:45:52PM +0530, Sadashiiv, Halesh wrote:
>> >
>> >
>> >The issue is found only in PPC32.
>> >
>> >Please let me if the patch is applicable.
>>
>> Well, no not really.  Mostly because of procedural issues than
anything
>> else.  Read Documentation/SubmittingPatches in the kernel directory.
>>
>> Also, there is a comment above this function that eludes to some
issues
>> with select on ppc32.  You might want to ask the overall PowerPC
>maintainer
>> if that issue still exits.
>
>I have only half of this thread, what is the problem ?
>
>Ben.
>
>



-------------------------------------------------------------------
This email is confidential and intended only for the use of the individual or 
entity named above and may contain information that is privileged. If you are 
not the intended recipient, you are notified that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email or 
telephone and destroy the original message. - This mail is sent via Sony Asia 
Pacific Mail Gateway.
-------------------------------------------------------------------

_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Reply via email to