[Bug 1839] New: call read with a write only file descriptor should fall with EBADF

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Mon Jul 18 06:40:04 UTC 2011


https://www.rtems.org/bugzilla/show_bug.cgi?id=1839

           Summary: call read with a write only file descriptor should
                    fall with EBADF
           Product: RTEMS
           Version: HEAD
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: minor
          Priority: P3
         Component: filesystem
        AssignedTo: chrisj at rtems.org
        ReportedBy: medivhc at gmail.com


In testsuites/psxtests/psxfile01/test.c, line 390


  /*
   * Read from filedes opened for write
   */

  puts( "open /tmp/bha in write only mode -- OK" );
  fd = open( "/tmp/bha", O_CREAT | O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO );
  rtems_test_assert( fd != -1 );

  puts( "attempt fcntl on opened file -- OK" );
  status = fcntl( fd, F_SETFD, 0 );
  rtems_test_assert( status == 0 );

  puts( "attempt to read from /tmp/bha - expect EINVAL" );
  status = read( fd, buffer, 10 );
  rtems_test_assert( status == -1 );
  rtems_test_assert( errno == EINVAL );

According to http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html
in this case, read should fall with EBADF.

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list