Changeset 1051


Ignore:
Timestamp:
Jan 25, 2004, 3:17:04 AM (22 years ago)
Author:
bird
Message:

We must return EBADF if the handle is is not suitable for read or write accordingly. We used to return EACCES which is wrong.

Location:
trunk/src/emx/src/lib/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/__read.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1050 r1051  
    1010#include <stdlib.h>
    1111#include <memory.h>
     12#include <sys/fcntl.h>
    1213#include <emx/umalloc.h>
    1314#include <emx/io.h>
     
    7879    {
    7980        _sys_set_errno(rc);
     81        /* If we don't have read access, EBADF should be returned, not EACCES. */
     82        if (    errno == EACCES
     83            &&  (pFH->fFlags & O_ACCMODE) != O_RDONLY
     84            &&  (pFH->fFlags & O_ACCMODE) != O_RDWR)
     85            errno = EBADF;
    8086        return -1;
    8187    }
  • trunk/src/emx/src/lib/sys/__write.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1050 r1051  
    1010#include <stdlib.h>
    1111#include <errno.h>
     12#include <sys/fcntl.h>
    1213#include <emx/io.h>
    1314#include <emx/umalloc.h>
     
    8788    {
    8889        _sys_set_errno(rc);
     90        /* If we don't have write access, EBADF should be returned, not EACCES. */
     91        if (    errno == EACCES
     92            &&  (pFH->fFlags & O_ACCMODE) != O_WRONLY
     93            &&  (pFH->fFlags & O_ACCMODE) != O_RDWR)
     94            errno = EBADF;
    8995        return -1;
    9096    }
Note: See TracChangeset for help on using the changeset viewer.