tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rfc: fcntl() error reporting



Hello.

The standard [1] describes only several errno values for fcntl().
However, NetBSD's implementation could produce some strange error
codes.
There is simple test code.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int main()
{
        int fd, rc;
        fd = open("/dev/null", O_RDWR);
        errno = 0;
        rc = fcntl(fd, -2, 0);
        printf("rc %d, errno %d, EINVAL %d\n", rc, errno, EINVAL);
        close(fd);
        return 0;
}

Results:
andy@FITFIESPPC176:~/tmp$ ./fcntl
rc -1, errno 22, EINVAL 22

13:38 tmp$ ./fcntl
rc -1, errno 14, EINVAL 22

I understand the NetBSD has some extension to the fcntl() which
possible by standard. But the errno for incorrect command values
should be equal to EINVAL, as far as I understood standard.

[1] http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html

P.S. Investigation shows the copyin(), copyout() and other non-related
functions could produce error codes for sys_fcntl().

-- 
With Best Regards,
Andy Shevchenko


Home | Main Index | Thread Index | Old Index