Cygwin: drop unused device nodes and clean up socket devices

* 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>
This commit is contained in:
Corinna Vinschen 2018-02-23 13:32:51 +01:00
parent b8a57a2d2a
commit 03f380c2bc
8 changed files with 25 additions and 49 deletions

View File

@ -120,17 +120,11 @@ const _device dev_piper_storage =
const _device dev_pipew_storage =
{"", {FH_PIPEW}, "", exists_internal};
const _device dev_tcp_storage =
{"", {FH_TCP}, "", exists_internal};
const _device dev_af_inet_storage =
{"", {FH_INET}, "", exists_internal};
const _device dev_udp_storage =
{"", {FH_UDP}, "", exists_internal};
const _device dev_stream_storage =
{"", {FH_STREAM}, "", exists_internal};
const _device dev_dgram_storage =
{"", {FH_DGRAM}, "", exists_internal};
const _device dev_af_local_storage =
{"", {FH_LOCAL}, "", exists_internal};
const _device dev_bad_storage =
{"", {FH_NADA}, "", exists_internal};

View File

@ -241,13 +241,9 @@ enum fh_devices
DEV_SOUND_MAJOR = 14,
FH_OSS_DSP = FHDEV (DEV_SOUND_MAJOR, 3),
DEV_TCP_MAJOR = 30,
FH_TCP = FHDEV (DEV_TCP_MAJOR, 36),
FH_UDP = FHDEV (DEV_TCP_MAJOR, 39),
FH_ICMP = FHDEV (DEV_TCP_MAJOR, 33),
FH_UNIX = FHDEV (DEV_TCP_MAJOR, 120),
FH_STREAM = FHDEV (DEV_TCP_MAJOR, 121),
FH_DGRAM = FHDEV (DEV_TCP_MAJOR, 122),
DEV_SOCK_MAJOR = 30,
FH_INET = FHDEV (DEV_SOCK_MAJOR, 36),
FH_LOCAL = FHDEV (DEV_SOCK_MAJOR, 120),
FH_NADA = FHDEV (0, 0),
FH_ERROR = FHDEV (255, 255) /* Set by fh constructor when error detected */
@ -394,14 +390,10 @@ extern const _device *ptmx_dev;
extern const _device *ptys_dev;
extern const _device *urandom_dev;
extern const _device dev_dgram_storage;
#define dgram_dev ((device *) &dev_dgram_storage)
extern const _device dev_stream_storage;
#define stream_dev ((device *) &dev_stream_storage)
extern const _device dev_tcp_storage;
#define tcp_dev ((device *) &dev_tcp_storage)
extern const _device dev_udp_storage;
#define udp_dev ((device *) &dev_udp_storage)
extern const _device dev_af_local_storage;
#define af_local_dev ((device *) &dev_af_local_storage)
extern const _device dev_af_inet_storage;
#define af_inet_dev ((device *) &dev_af_inet_storage)
extern const _device dev_piper_storage;
#define piper_dev ((device *) &dev_piper_storage)

View File

@ -116,17 +116,11 @@ const _device dev_piper_storage =
const _device dev_pipew_storage =
{"", {FH_PIPEW}, "", exists_internal};
const _device dev_tcp_storage =
{"", {FH_TCP}, "", exists_internal};
const _device dev_af_inet_storage =
{"", {FH_INET}, "", exists_internal};
const _device dev_udp_storage =
{"", {FH_UDP}, "", exists_internal};
const _device dev_stream_storage =
{"", {FH_STREAM}, "", exists_internal};
const _device dev_dgram_storage =
{"", {FH_DGRAM}, "", exists_internal};
const _device dev_af_local_storage =
{"", {FH_LOCAL}, "", exists_internal};
const _device dev_bad_storage =
{"", {FH_NADA}, "", exists_internal};

View File

@ -311,7 +311,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
(char *) &rcv, &len)))
{
/* socket */
dev = *tcp_dev;
dev = *af_inet_dev;
name[0] = '\0';
}
else if (fd == 0)
@ -514,14 +514,10 @@ fh_alloc (path_conv& pc)
case FH_PIPEW:
fh = cnew (fhandler_pipe);
break;
case FH_TCP:
case FH_UDP:
case FH_ICMP:
case FH_INET:
fh = cnew (fhandler_socket_inet);
break;
case FH_UNIX:
case FH_STREAM:
case FH_DGRAM:
case FH_LOCAL:
fh = cnew (fhandler_socket_local);
break;
case FH_FS:

View File

@ -871,7 +871,7 @@ fhandler_socket::fstat (struct stat *buf)
res = fhandler_socket::fstat (buf);
if (!res)
{
buf->st_dev = FHDEV (DEV_TCP_MAJOR, 0);
buf->st_dev = FHDEV (DEV_SOCK_MAJOR, 0);
if (!(buf->st_ino = get_plain_ino ()))
sscanf (get_name (), "/proc/%*d/fd/socket:[%lld]",
(long long *) &buf->st_ino);

View File

@ -526,7 +526,7 @@ cygwin_socket (int af, int type, int protocol)
set_errno (EPROTONOSUPPORT);
goto done;
}
dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
dev = af_local_dev;
break;
case AF_INET:
case AF_INET6:
@ -535,7 +535,7 @@ cygwin_socket (int af, int type, int protocol)
set_errno (EINVAL);
goto done;
}
dev = type == SOCK_STREAM ? tcp_dev : udp_dev;
dev = af_inet_dev;
break;
default:
set_errno (EAFNOSUPPORT);
@ -2323,7 +2323,7 @@ socketpair (int af, int type, int protocol, int *sb)
set_errno (EPROTONOSUPPORT);
goto done;
}
dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
dev = af_local_dev;
break;
default:
set_errno (EAFNOSUPPORT);

View File

@ -864,7 +864,7 @@ path_conv::check (const char *src, unsigned opt,
if (component == 0)
{
fileattr = 0;
dev.parse (FH_TCP);
dev.parse (FH_INET);
}
break;
case virt_fsdir:
@ -959,7 +959,7 @@ path_conv::check (const char *src, unsigned opt,
return;
}
fileattr = sym.fileattr;
dev.parse (FH_UNIX);
dev.parse (FH_LOCAL);
dev.setfs (1);
goto out;
}

View File

@ -192,7 +192,7 @@ class path_conv
int is_fs_device () const {return isdevice () && is_fs_special ();}
int is_fs_special () const {return dev.is_fs_special ();}
int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();}
int issocket () const {return dev.is_device (FH_UNIX);}
int issocket () const {return dev.is_device (FH_LOCAL);}
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
int isopen () const {return path_flags & PATH_OPEN;}
int isctty_capable () const {return path_flags & PATH_CTTY;}