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 = const _device dev_pipew_storage =
{"", {FH_PIPEW}, "", exists_internal}; {"", {FH_PIPEW}, "", exists_internal};
const _device dev_tcp_storage = const _device dev_af_inet_storage =
{"", {FH_TCP}, "", exists_internal}; {"", {FH_INET}, "", exists_internal};
const _device dev_udp_storage = const _device dev_af_local_storage =
{"", {FH_UDP}, "", exists_internal}; {"", {FH_LOCAL}, "", exists_internal};
const _device dev_stream_storage =
{"", {FH_STREAM}, "", exists_internal};
const _device dev_dgram_storage =
{"", {FH_DGRAM}, "", exists_internal};
const _device dev_bad_storage = const _device dev_bad_storage =
{"", {FH_NADA}, "", exists_internal}; {"", {FH_NADA}, "", exists_internal};

View File

@ -241,13 +241,9 @@ enum fh_devices
DEV_SOUND_MAJOR = 14, DEV_SOUND_MAJOR = 14,
FH_OSS_DSP = FHDEV (DEV_SOUND_MAJOR, 3), FH_OSS_DSP = FHDEV (DEV_SOUND_MAJOR, 3),
DEV_TCP_MAJOR = 30, DEV_SOCK_MAJOR = 30,
FH_TCP = FHDEV (DEV_TCP_MAJOR, 36), FH_INET = FHDEV (DEV_SOCK_MAJOR, 36),
FH_UDP = FHDEV (DEV_TCP_MAJOR, 39), FH_LOCAL = FHDEV (DEV_SOCK_MAJOR, 120),
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),
FH_NADA = FHDEV (0, 0), FH_NADA = FHDEV (0, 0),
FH_ERROR = FHDEV (255, 255) /* Set by fh constructor when error detected */ 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 *ptys_dev;
extern const _device *urandom_dev; extern const _device *urandom_dev;
extern const _device dev_dgram_storage; extern const _device dev_af_local_storage;
#define dgram_dev ((device *) &dev_dgram_storage) #define af_local_dev ((device *) &dev_af_local_storage)
extern const _device dev_stream_storage; extern const _device dev_af_inet_storage;
#define stream_dev ((device *) &dev_stream_storage) #define af_inet_dev ((device *) &dev_af_inet_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_piper_storage; extern const _device dev_piper_storage;
#define piper_dev ((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 = const _device dev_pipew_storage =
{"", {FH_PIPEW}, "", exists_internal}; {"", {FH_PIPEW}, "", exists_internal};
const _device dev_tcp_storage = const _device dev_af_inet_storage =
{"", {FH_TCP}, "", exists_internal}; {"", {FH_INET}, "", exists_internal};
const _device dev_udp_storage = const _device dev_af_local_storage =
{"", {FH_UDP}, "", exists_internal}; {"", {FH_LOCAL}, "", exists_internal};
const _device dev_stream_storage =
{"", {FH_STREAM}, "", exists_internal};
const _device dev_dgram_storage =
{"", {FH_DGRAM}, "", exists_internal};
const _device dev_bad_storage = const _device dev_bad_storage =
{"", {FH_NADA}, "", exists_internal}; {"", {FH_NADA}, "", exists_internal};

View File

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

View File

@ -871,7 +871,7 @@ fhandler_socket::fstat (struct stat *buf)
res = fhandler_socket::fstat (buf); res = fhandler_socket::fstat (buf);
if (!res) 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 ())) if (!(buf->st_ino = get_plain_ino ()))
sscanf (get_name (), "/proc/%*d/fd/socket:[%lld]", sscanf (get_name (), "/proc/%*d/fd/socket:[%lld]",
(long long *) &buf->st_ino); (long long *) &buf->st_ino);

View File

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

View File

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

View File

@ -192,7 +192,7 @@ class path_conv
int is_fs_device () const {return isdevice () && is_fs_special ();} int is_fs_device () const {return isdevice () && is_fs_special ();}
int is_fs_special () const {return dev.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 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 iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
int isopen () const {return path_flags & PATH_OPEN;} int isopen () const {return path_flags & PATH_OPEN;}
int isctty_capable () const {return path_flags & PATH_CTTY;} int isctty_capable () const {return path_flags & PATH_CTTY;}