From: David van Moolenbroek Date: Tue, 10 Sep 2013 23:07:28 +0000 (+0200) Subject: Retire EBADIOCTL in favor of ENOTTY X-Git-Tag: v3.3.0~581 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.css?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F974%2F2;p=minix.git Retire EBADIOCTL in favor of ENOTTY Change-Id: I6bd0e301d21ab7f2336e350e7e6e15d238c2c93d --- diff --git a/lib/libc/sys-minix/accept.c b/lib/libc/sys-minix/accept.c index 88c9c9c0c..bccb81a2a 100644 --- a/lib/libc/sys-minix/accept.c +++ b/lib/libc/sys-minix/accept.c @@ -33,11 +33,11 @@ int accept(int sock, struct sockaddr *__restrict address, nwio_udpopt_t udpopt; r= _tcp_accept(sock, address, address_len); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) return r; r= _uds_accept(sock, address, address_len); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) return r; /* Unfortunately, we have to return EOPNOTSUPP for a socket that @@ -51,7 +51,7 @@ int accept(int sock, struct sockaddr *__restrict address, errno= EOPNOTSUPP; return -1; } - if ((errno == ENOTTY || errno == EBADIOCTL)) + if (errno == ENOTTY) { errno= ENOTSOCK; return -1; diff --git a/lib/libc/sys-minix/bind.c b/lib/libc/sys-minix/bind.c index 47c90d8cd..faf26d632 100644 --- a/lib/libc/sys-minix/bind.c +++ b/lib/libc/sys-minix/bind.c @@ -45,7 +45,7 @@ int bind(int sock, const struct sockaddr *address, socklen_t address_len) struct sockaddr_un uds_addr; r= ioctl(sock, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -63,7 +63,7 @@ int bind(int sock, const struct sockaddr *address, socklen_t address_len) } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -71,7 +71,7 @@ int bind(int sock, const struct sockaddr *address, socklen_t address_len) } r= ioctl(sock, NWIOGUDSADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; diff --git a/lib/libc/sys-minix/connect.c b/lib/libc/sys-minix/connect.c index 3ef50854e..dd5b7b7f5 100644 --- a/lib/libc/sys-minix/connect.c +++ b/lib/libc/sys-minix/connect.c @@ -39,7 +39,7 @@ int connect(int sock, const struct sockaddr *address, nwio_udpopt_t udpopt; r= ioctl(sock, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -50,7 +50,7 @@ int connect(int sock, const struct sockaddr *address, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -61,9 +61,7 @@ int connect(int sock, const struct sockaddr *address, } r= _uds_connect(sock, address, address_len); - if (r != -1 || - (errno != ENOTTY && errno != EBADIOCTL && - errno != EAFNOSUPPORT)) + if (r != -1 || (errno != ENOTTY && errno != EAFNOSUPPORT)) { if (r == -1) { diff --git a/lib/libc/sys-minix/getpeername.c b/lib/libc/sys-minix/getpeername.c index 38fb54ea1..a537685ef 100644 --- a/lib/libc/sys-minix/getpeername.c +++ b/lib/libc/sys-minix/getpeername.c @@ -35,7 +35,7 @@ int getpeername(int sock, struct sockaddr *__restrict address, struct sockaddr_un uds_addr; r= ioctl(sock, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -47,7 +47,7 @@ int getpeername(int sock, struct sockaddr *__restrict address, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -59,7 +59,7 @@ int getpeername(int sock, struct sockaddr *__restrict address, } r= ioctl(sock, NWIOGUDSPADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/lib/libc/sys-minix/getsockname.c b/lib/libc/sys-minix/getsockname.c index 02e96df97..84b55a845 100644 --- a/lib/libc/sys-minix/getsockname.c +++ b/lib/libc/sys-minix/getsockname.c @@ -48,7 +48,7 @@ int getsockname(int fd, struct sockaddr *__restrict address, #endif r= ioctl(fd, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -60,7 +60,7 @@ int getsockname(int fd, struct sockaddr *__restrict address, } r= ioctl(fd, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -72,7 +72,7 @@ int getsockname(int fd, struct sockaddr *__restrict address, } r= ioctl(fd, NWIOGUDSADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/lib/libc/sys-minix/getsockopt.c b/lib/libc/sys-minix/getsockopt.c index 16408bf49..907d38d0e 100644 --- a/lib/libc/sys-minix/getsockopt.c +++ b/lib/libc/sys-minix/getsockopt.c @@ -39,7 +39,7 @@ int getsockopt(int sock, int level, int option_name, struct sockaddr_un uds_addr; r= ioctl(sock, NWIOGTCPOPT, &tcpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -51,7 +51,7 @@ int getsockopt(int sock, int level, int option_name, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -63,7 +63,7 @@ int getsockopt(int sock, int level, int option_name, } r= ioctl(sock, NWIOGUDSADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/lib/libc/sys-minix/listen.c b/lib/libc/sys-minix/listen.c index e700b77ed..f8e196786 100644 --- a/lib/libc/sys-minix/listen.c +++ b/lib/libc/sys-minix/listen.c @@ -21,11 +21,11 @@ int listen(int sock, int backlog) int r; r= ioctl(sock, NWIOTCPLISTENQ, &backlog); - if (r != -1 || errno != EBADIOCTL) + if (r != -1 || errno != ENOTTY) return r; r= ioctl(sock, NWIOSUDSBLOG, &backlog); - if (r != -1 || errno != EBADIOCTL) + if (r != -1 || errno != ENOTTY) return r; #if DEBUG diff --git a/lib/libc/sys-minix/recvfrom.c b/lib/libc/sys-minix/recvfrom.c index 091559f9e..0cc663321 100644 --- a/lib/libc/sys-minix/recvfrom.c +++ b/lib/libc/sys-minix/recvfrom.c @@ -50,7 +50,7 @@ ssize_t recvfrom(int sock, void *__restrict buffer, size_t length, #endif r= ioctl(sock, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -59,7 +59,7 @@ ssize_t recvfrom(int sock, void *__restrict buffer, size_t length, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -68,7 +68,7 @@ ssize_t recvfrom(int sock, void *__restrict buffer, size_t length, } r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/lib/libc/sys-minix/recvmsg.c b/lib/libc/sys-minix/recvmsg.c index 057d7f1d5..49ee7c13a 100644 --- a/lib/libc/sys-minix/recvmsg.c +++ b/lib/libc/sys-minix/recvmsg.c @@ -26,7 +26,7 @@ ssize_t recvmsg(int sock, struct msghdr *msg, int flags) } r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) { + if (r != -1 || errno != ENOTTY) { if (r == -1) { return r; } diff --git a/lib/libc/sys-minix/sendmsg.c b/lib/libc/sys-minix/sendmsg.c index 6ffa7ab0f..4d97f79ac 100644 --- a/lib/libc/sys-minix/sendmsg.c +++ b/lib/libc/sys-minix/sendmsg.c @@ -29,7 +29,7 @@ ssize_t sendmsg(int sock, const struct msghdr *msg, int flags) } r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) { + if (r != -1 || errno != ENOTTY) { if (r == -1) { return r; } diff --git a/lib/libc/sys-minix/sendto.c b/lib/libc/sys-minix/sendto.c index c3c039d1d..4f174bba2 100644 --- a/lib/libc/sys-minix/sendto.c +++ b/lib/libc/sys-minix/sendto.c @@ -41,7 +41,7 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags, int uds_sotype = -1; r= ioctl(sock, NWIOGTCPOPT, &tcpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -50,7 +50,7 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) return r; @@ -59,7 +59,7 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags, } r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { return r; diff --git a/lib/libc/sys-minix/setsockopt.c b/lib/libc/sys-minix/setsockopt.c index ff4811177..ed36dc77e 100644 --- a/lib/libc/sys-minix/setsockopt.c +++ b/lib/libc/sys-minix/setsockopt.c @@ -35,7 +35,7 @@ int setsockopt(int sock, int level, int option_name, struct sockaddr_un uds_addr; r= ioctl(sock, NWIOGTCPOPT, &tcpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -47,7 +47,7 @@ int setsockopt(int sock, int level, int option_name, } r= ioctl(sock, NWIOGUDPOPT, &udpopt); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -59,7 +59,7 @@ int setsockopt(int sock, int level, int option_name, } r= ioctl(sock, NWIOGUDSADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/lib/libc/sys-minix/shutdown.c b/lib/libc/sys-minix/shutdown.c index 3f86cc516..68236c7de 100644 --- a/lib/libc/sys-minix/shutdown.c +++ b/lib/libc/sys-minix/shutdown.c @@ -27,7 +27,7 @@ int shutdown(int sock, int how) nwio_tcpconf_t tcpconf; r= ioctl(sock, NWIOGTCPCONF, &tcpconf); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { @@ -38,7 +38,7 @@ int shutdown(int sock, int how) } r= ioctl(sock, NWIOGUDSADDR, &uds_addr); - if (r != -1 || (errno != ENOTTY && errno != EBADIOCTL)) + if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/man/man2/intro.2 b/man/man2/intro.2 index 30eeea535..69e1afdcd 100644 --- a/man/man2/intro.2 +++ b/man/man2/intro.2 @@ -266,7 +266,6 @@ caller-provided space. .It Er 51 ENOBUFS Em "\&No buffer space available" . An operation on a socket or pipe was not performed because the system lacked sufficient buffer space or because a queue was full. -.It Er 52 EBADIOCTL Em "Illegal ioctl for device" . .It Er 53 EBADMODE Em "Bad mode in ioctl" . .It Er 54 EWOULDBLOCK Em "Would block" . .It Er 55 ENETUNREACH Em "Network is unreachable" . diff --git a/man/man4/ip.4 b/man/man4/ip.4 index c7b8d7e5c..483971353 100644 --- a/man/man4/ip.4 +++ b/man/man4/ip.4 @@ -1420,7 +1420,7 @@ This indicates an attempt to read or write with a buffer that is too large or too small. .IP ENOBUFS The TCP/IP server has insufficient memory to execute the request. -.IP EBADIOCTL +.IP ENOTTY This indicates an attempt to execute a command the particular server does not understand. For example, a diff --git a/sys/sys/errno.h b/sys/sys/errno.h index d8f1b5b7b..c29599388 100644 --- a/sys/sys/errno.h +++ b/sys/sys/errno.h @@ -79,7 +79,6 @@ /* The following errors relate to networking. */ #define EPACKSIZE (_SIGN 50 ) /* invalid packet size for some protocol */ #define ENOBUFS (_SIGN 51 ) /* not enough buffers left */ -#define EBADIOCTL (_SIGN 52 ) /* illegal ioctl for device */ #define EBADMODE (_SIGN 53 ) /* badmode in ioctl */ #define EWOULDBLOCK (_SIGN 54 ) /* call would block on nonblocking socket */ #define ENETUNREACH (_SIGN 55 ) /* network unreachable */ diff --git a/test/test56.c b/test/test56.c index af55d09fa..05222723c 100644 --- a/test/test56.c +++ b/test/test56.c @@ -599,7 +599,11 @@ void test_listen(void) errno = 0; rc = listen(0, 0); - if (!(rc == -1 && errno == ENOTTY)) { + /* Test on errno disabled here: there's currently no telling what this + * will return. POSIX says it should be ENOTSOCK, MINIX3 libc returns + * ENOSYS, and we used to test for ENOTTY here.. + */ + if (!(rc == -1)) { test_fail("listen(0, 0) should have failed"); }