Insert another class fhandler_socket_wsock between fhandler_socket
and fhandler_socket_inet/fhandler_socket_local.
Also, add a new method fhandler::is_wsock_socket to allow asking
for sockets in general (is_socket) vs. Winsock-based sockets
(is_wsock_socket).
This allows to develop a new handler_socket_unix class as derived
class from fhandler_socket without any trace of wsock code left
in fhandler_socket.
While this is basically a temporary measure at this time, it may
prove useful for later interoperability with the upcoming Windows 10
AF_UNIX implementation at one point.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Rename DEV_TCP_MAJOR to DEV_SOCK_MAJOR
* Drop FH_TCP, FH_UDP, FH_ICMP in favor of single FH_INET
* Drop FH_UNIX, FH_STREAM, FH_DGRAM in favor of single FH_LOCAL
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
First cut, still incomplete
* fhandler_socket is now base class for other socket classes
* fhandler_socket_inet handles AF_INET and AF_INET6 sockets
* fhandler_socket_local handles AF_LOCAL/AF_UNIX sockets
* finally get rid of fdsock by using set_socket_handle in accept4
* align file-related calls (fstat, fstatvfs, fchown, fchmod, facl)
to Linux.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- Move definition of windows to POSIX error mapping struct into
cygerrno.h
- Move declaration of winsock errno functions to cygerrno.h
- Input to error mapping functions is DWORD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Dropping the 'LL' specifier leads to 32 bit truncation during timestamp
computation. Revert it. Exempt MSPERSEC which is used for 32 bit values.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Add fhandler_socket::socket method
Add fhandler_socket::set_socket_handle method, basically duplicating
what fdsock is doing. This is the first step in getting rid of fdsock.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Windows does not remove FILE_ATTRIBUTE_TEMPORARY by itself after a
file has been closed. It's just some attribute which can be set or
removed at will, despite its purpose.
Apparently there are tools out there which use FILE_ATTRIBUTE_TEMPORARY
accidentally or wrongly, even Microsoft's own tools are affected. In
the end, the filesystem is potentially full of files with this attribute
set.
Implement O_TMPFILE files with FILE_ATTRIBUTE_TEMPORARY and
FILE_ATTRIBUTE_HIDDEN set. This combination is pretty unlikely.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix an incorrect condition to recognize AF_LOCAL sockets in
file-related functions (fchmod, fchown, fstat, fsttavfs, facl, link).
* Return successfully when called on unnamed or abstract AF_LOCAL sockets,
except link, just as on Linux.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Use 64 bit timestamps
* Use System boot and process start time to compute starttime value per
Linux proc.5 description.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The previous patch introduced a compiler warning on x86.
Given time_t is only 4 bytes on x86 we get a long vs. unsigned long
comparison in timeval_to_ms. Fix it by careful casting.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Redefine NSPERSEC to NS100PERSEC
* Define NSPERSEC as nanosecs per second
* Define USPERSEC as microsecs per second
* Use above constants throughout where appropriate
* Rename to_us to timespec_to_us and inline
* Rename it_bad to timespec_bad and inline
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Rearrange setsockopt/getsockopt into per level/per optname
preprocessing switch, actual call, per level/per optname
postprocessing switch for better readability as well as
extensibility.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Workaround the problem that bind doesn't fail with EADDRINUSE
if a socket with the same local address is still in TIME_WAIT.
Use IP Helper functions to check if such a socket exist and don't
even try this port, if so.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Assuming the address parameter is non-NULL, the test in
cygwin_bindresvport_sa only tests if the address family is
supported at all, which is insufficient.
Check if the incoming address family matches the socket
address family and for being AF_INET in cygwin_bindresvport
since the latter doesn't support any other family.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
We're still using ~SO_REUSEADDR because SO_EXCLUSIVEADDRUSE wasn't
defined in Mingw. But it is in Mingw-w64, so fix it.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>